@luzmo/embed 6.2.1-beta.0 → 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 (37) hide show
  1. package/.prettierignore +4 -0
  2. package/CHANGELOG.md +0 -6
  3. package/esbuild.config.cjs +13 -0
  4. package/eslint.config.cjs +8 -0
  5. package/jest.config.ts +11 -0
  6. package/package.json +1 -1
  7. package/project.json +39 -0
  8. package/src/index.ts +42 -0
  9. package/src/lib/dashboard-component/dashboard-base.ts +828 -0
  10. package/src/lib/dashboard-component/dashboard-component.spec.ts +27 -0
  11. package/src/lib/dashboard-component/dashboard-component.ts +12 -0
  12. package/src/lib/dashboard-component/dashboard-styles.ts +117 -0
  13. package/src/lib/helper/event-bus-handler.ts +195 -0
  14. package/src/lib/helper/json-schema-utils.ts +129 -0
  15. package/src/lib/luzmo-iq-components/luzmo-iq-answer.ts +106 -0
  16. package/src/lib/luzmo-iq-components/luzmo-iq-chat.ts +106 -0
  17. package/src/lib/luzmo-service.ts +7 -0
  18. package/src/lib/viz-item/viz-item-component.ts +9 -0
  19. package/src/lib/viz-item/viz-item.base.ts +227 -0
  20. package/src/vite-env.d.ts +1 -0
  21. package/tsconfig.json +27 -0
  22. package/tsconfig.lib.json +10 -0
  23. package/tsconfig.spec.json +9 -0
  24. package/index.cjs +0 -1581
  25. package/index.js +0 -1550
  26. package/luzmo-embed.min.js +0 -3632
  27. package/src/index.d.ts +0 -8
  28. package/src/lib/dashboard-component/dashboard-base.d.ts +0 -98
  29. package/src/lib/dashboard-component/dashboard-component.d.ts +0 -8
  30. package/src/lib/dashboard-component/dashboard-styles.d.ts +0 -1
  31. package/src/lib/helper/event-bus-handler.d.ts +0 -1
  32. package/src/lib/helper/json-schema-utils.d.ts +0 -64
  33. package/src/lib/luzmo-iq-components/luzmo-iq-answer.d.ts +0 -22
  34. package/src/lib/luzmo-iq-components/luzmo-iq-chat.d.ts +0 -23
  35. package/src/lib/luzmo-service.d.ts +0 -6
  36. package/src/lib/viz-item/viz-item-component.d.ts +0 -4
  37. package/src/lib/viz-item/viz-item.base.d.ts +0 -71
@@ -1,3632 +0,0 @@
1
- (function(g,f){if(typeof define=="function"&&define.amd){define(f)}else if(typeof exports=="object" && typeof module<"u"){module.exports=f()}else{var m=f();for(var i in m) g[i]=m[i]}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(){var exports={};var __exports=exports;var module={exports};
2
- "use strict";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var __decorateClass = (decorators, target, key, kind) => {
21
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
22
- for (var i4 = decorators.length - 1, decorator; i4 >= 0; i4--)
23
- if (decorator = decorators[i4])
24
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
25
- if (kind && result)
26
- __defProp(target, key, result);
27
- return result;
28
- };
29
-
30
- // libs/embed-libs/embed/src/index.ts
31
- var src_exports2 = {};
32
- __export(src_exports2, {
33
- LuzmoEmbedDashboard: () => LuzmoEmbedDashboard,
34
- LuzmoEmbedVizItem: () => LuzmoEmbedVizItem,
35
- LuzmoIQEmbedAnswerComponent: () => LuzmoIQEmbedAnswerComponent,
36
- LuzmoIQEmbedChatComponent: () => LuzmoIQEmbedChatComponent,
37
- addJSONSchemas: () => addJSONSchemas,
38
- fetchJSONSchema: () => fetchJSONSchema,
39
- getCachedJSONSchema: () => getCachedJSONSchema,
40
- getCachedJSONSchemas: () => getCachedJSONSchemas,
41
- getJSONSchemaUrl: () => getJSONSchemaUrl,
42
- luzmoRefParserOptions: () => luzmoRefParserOptions,
43
- selectedDataUtils: () => selectedDataUtils
44
- });
45
- module.exports = __toCommonJS(src_exports2);
46
-
47
- // libs/embed-libs/shared-embed/src/lib/helpers/error.ts
48
- var _handleError = (errorMessage, parameters) => {
49
- let message = "The dashboard component encountered an error";
50
- if (typeof parameters?.dashboardId === "string") {
51
- message += ` for dashboard with id ${parameters.dashboardId}`;
52
- }
53
- if (typeof parameters?.dashboardSlug === "string") {
54
- message += ` for dashboard with slug ${parameters.dashboardSlug}`;
55
- }
56
- if (typeof parameters?.container === "string") {
57
- message += ` in container ${parameters.container}`;
58
- }
59
- if (errorMessage) {
60
- message += `:
61
- ${errorMessage}`;
62
- console.warn(message);
63
- }
64
- };
65
-
66
- // libs/embed-libs/shared-embed/src/lib/helpers/browser-check.ts
67
- var _browserCheck = (dashboardComponent) => {
68
- let hasError = false;
69
- let errorMessage = "";
70
- const document_ = document.body || document.documentElement;
71
- const style = document_.style;
72
- const browserCheck = {
73
- svg: !!("createElementNS" in document && document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect),
74
- flexbox: style.webkitFlexWrap === "" || style.flexWrap === "",
75
- postMessage: !!window.postMessage
76
- };
77
- const browserCheckKeys = ["svg", "flexbox", "postMessage"];
78
- for (const key of browserCheckKeys) {
79
- if (!browserCheck[key]) {
80
- hasError = true;
81
- dashboardComponent.browserNotSupported = dashboardComponent.browserNotSupported || [];
82
- dashboardComponent.browserNotSupported.push(key);
83
- errorMessage += `Your browser does not support: ${key}
84
- `;
85
- }
86
- }
87
- const ua = window.navigator.userAgent;
88
- const msie = ua.includes("MSIE");
89
- const trident = ua.includes("Trident/");
90
- if (msie || trident) {
91
- hasError = true;
92
- errorMessage = "IE is not supported.";
93
- }
94
- if (hasError) {
95
- _handleError(errorMessage);
96
- }
97
- };
98
-
99
- // libs/embed-libs/shared-embed/src/lib/helpers/default-parameters.ts
100
- var DEFAULT_PARAMETERS = {
101
- appServer: "https://app.luzmo.com/",
102
- apiHost: "https://api.luzmo.com/",
103
- dashboardId: null,
104
- dashboardSlug: null,
105
- container: null,
106
- key: null,
107
- token: null,
108
- language: "auto",
109
- qeVersion: null,
110
- editMode: null,
111
- screenMode: null,
112
- switchScreenModeOnResize: true,
113
- itemId: null,
114
- mainColor: "",
115
- accentColor: "",
116
- itemDimensions: {
117
- width: "auto",
118
- height: "auto"
119
- },
120
- loaderBackground: "#f9f9f9",
121
- loaderFontColor: "#5a5a5a",
122
- loaderSpinnerColor: "rgba(255, 165, 0, 0.7)",
123
- loaderSpinnerBackground: "rgba(169, 169, 169, 0.14)",
124
- timezoneId: null,
125
- contextId: null
126
- };
127
-
128
- // libs/embed-libs/shared-embed/src/lib/helpers/extents.ts
129
- var EXTENTS = [
130
- { mode: "mobile", width: [150, 767] },
131
- { mode: "tablet", width: [768, 1199] },
132
- { mode: "desktop", width: [1200, 1599] },
133
- { mode: "largeScreen", width: [1600, 9999] },
134
- { mode: "fixed", width: [] }
135
- ];
136
-
137
- // libs/embed-libs/shared-embed/src/lib/helpers/translations.ts
138
- var TRANSLATIONS = {
139
- initializing: {
140
- en: "Initializing...",
141
- nl: "Laden...",
142
- fr: "Chargement...",
143
- de: "Initialisiere...",
144
- es: "Inicializando..."
145
- },
146
- errorDashboard: {
147
- en: "Oops, we could not load this dashboard!",
148
- nl: "Oeps, we konden het dashboard niet laden.",
149
- fr: "Le chargement a echou\xE9.",
150
- de: "Hoppla, wir konnten dieses Dashboard nicht laden!",
151
- es: "\xA1Ups! No pudimos cargar este tablero."
152
- },
153
- errorItem: {
154
- en: "Oops, we could not load this item!",
155
- nl: "Oeps, we konden de grafiek niet laden.",
156
- fr: "Le chargement a echou\xE9.",
157
- de: "Hoppla, wir konnten dieses Diagramm nicht laden!",
158
- es: "\xA1Ups! No pudimos cargar este elemento."
159
- }
160
- };
161
- var translations_default = TRANSLATIONS;
162
-
163
- // libs/embed-libs/shared-embed/src/lib/helpers/utils.ts
164
- var addTrailingSlash = (serverUrl) => {
165
- if (!serverUrl) {
166
- return "";
167
- }
168
- return serverUrl.endsWith("/") ? serverUrl : `${serverUrl}/`;
169
- };
170
- var removeTrailingSlash = (serverUrl) => {
171
- if (!serverUrl) {
172
- return "";
173
- }
174
- return serverUrl.endsWith("/") ? serverUrl.slice(0, -1) : serverUrl;
175
- };
176
- var formatDashboardList = (dashboards, integrationId, user, dashboardComponent) => {
177
- const combineRights = (securable, user2) => {
178
- const matchingUser = securable.users.find((u2) => u2.id === user2.id);
179
- const securableAccessRights = matchingUser && matchingUser.userAccessRight ? {
180
- flagRead: matchingUser.userAccessRight.flagRead,
181
- flagUse: matchingUser.userAccessRight.flagUse,
182
- flagModify: matchingUser.userAccessRight.flagModify,
183
- flagOwn: matchingUser.userAccessRight.flagOwn
184
- } : {
185
- flagRead: false,
186
- flagUse: false,
187
- flagModify: false,
188
- flagOwn: false
189
- };
190
- const groups = securable.groups.filter(
191
- (group) => user2.userGroups.includes(group.id) || group.public === true
192
- );
193
- const groupsAccess = groups.map((group) => {
194
- if (group.groupAccessRight) {
195
- return group.groupAccessRight;
196
- }
197
- });
198
- for (const groupAccess of groupsAccess) {
199
- if (!securableAccessRights.flagRead && groupAccess.flagRead) {
200
- securableAccessRights.flagRead = groupAccess.flagRead;
201
- }
202
- if (!securableAccessRights.flagUse && groupAccess.flagUse) {
203
- securableAccessRights.flagUse = groupAccess.flagUse;
204
- }
205
- if (!securableAccessRights.flagModify && groupAccess.flagModify) {
206
- securableAccessRights.flagModify = groupAccess.flagModify;
207
- }
208
- if (!securableAccessRights.flagOwn && groupAccess.flagOwn) {
209
- securableAccessRights.flagOwn = groupAccess.flagOwn;
210
- }
211
- }
212
- const integrationsAccess = securable.integrations?.length > 0 ? securable.integrations.map((integration) => {
213
- if (integration.integrationAccessRight) {
214
- return integration.integrationAccessRight;
215
- }
216
- }) : [];
217
- for (const integrationAccess of integrationsAccess) {
218
- if (!securableAccessRights.flagRead && integrationAccess.flagRead) {
219
- securableAccessRights.flagRead = integrationAccess.flagRead;
220
- }
221
- if (!securableAccessRights.flagUse && integrationAccess.flagUse) {
222
- securableAccessRights.flagUse = integrationAccess.flagUse;
223
- }
224
- if (!securableAccessRights.flagModify && integrationAccess.flagModify) {
225
- securableAccessRights.flagModify = integrationAccess.flagModify;
226
- }
227
- }
228
- return securableAccessRights;
229
- };
230
- const localize = (item, locale) => {
231
- if (item === null || item === void 0) {
232
- return "";
233
- }
234
- if (typeof item !== "object" || Object.keys(item).length === 0) {
235
- if (typeof item === "object" && Object.keys(item).length === 0) {
236
- return "";
237
- }
238
- return item;
239
- }
240
- let localizedItem;
241
- localizedItem = locale && item[locale] ? item[locale] : item[Object.keys(item)[0]];
242
- if (localizedItem === void 0 || localizedItem === null) {
243
- localizedItem = "";
244
- }
245
- return localizedItem;
246
- };
247
- const treatedDashboards = [];
248
- for (const dashboard of dashboards) {
249
- const treatedDashboard = {
250
- accessibleBy: [],
251
- accessRights: combineRights(dashboard, user),
252
- id: dashboard.id,
253
- modifiedAt: dashboard.modified_at,
254
- name: localize(dashboard.name, dashboardComponent.language),
255
- slug: null,
256
- tags: dashboard.tags.map((t3) => t3.tag).sort((t1, t22) => t1.localeCompare(t22))
257
- };
258
- const currentIntegration = dashboard.integrations.find(
259
- (i4) => i4.id === integrationId
260
- );
261
- if (currentIntegration?.integrationAccessRight?.slug) {
262
- treatedDashboard.slug = currentIntegration.integrationAccessRight.slug;
263
- }
264
- const users = dashboard.users.map((u2) => ({
265
- model: "User",
266
- id: u2.id,
267
- name: localize(u2.name, user.locale_id)
268
- }));
269
- const groups = dashboard.groups.map((g2) => ({
270
- model: "Group",
271
- id: g2.id,
272
- name: localize(g2.name, user.locale_id) || {}
273
- }));
274
- const integrations = dashboard.integrations.map((i4) => ({
275
- model: "Integration",
276
- id: i4.id,
277
- name: localize(i4.name, user.locale_id) || {}
278
- }));
279
- treatedDashboard.accessibleBy = [...users, ...groups, ...integrations];
280
- treatedDashboards.push(treatedDashboard);
281
- }
282
- return treatedDashboards;
283
- };
284
- var VERSION = "0.0.0-unknown-luzmo";
285
- var sanitizeUrl = (url) => {
286
- const invalidPrototcolRegex = /^(%20|\s)*(javascript|data)/im;
287
- const ctrlCharactersRegex = /[^\u0020-\u007E]/gim;
288
- const urlSchemeRegex = /^([^:]+):/gm;
289
- const relativeFirstCharacters = /* @__PURE__ */ new Set([".", "/"]);
290
- const isRelativeUrlWithoutProtocol = (relativeUrl) => relativeFirstCharacters.has(relativeUrl[0]);
291
- if (!url) {
292
- return "about:blank";
293
- }
294
- const sanitizedUrl = url.replaceAll(ctrlCharactersRegex, "").trim();
295
- if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
296
- return sanitizedUrl;
297
- }
298
- const urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex);
299
- if (!urlSchemeParseResults) {
300
- return sanitizedUrl;
301
- }
302
- const urlScheme = urlSchemeParseResults[0];
303
- if (invalidPrototcolRegex.test(urlScheme)) {
304
- return "about:blank";
305
- }
306
- return sanitizedUrl;
307
- };
308
- var cloneDeep = (obj) => JSON.parse(JSON.stringify(obj));
309
- var isObject = (o4) => o4 && typeof o4 === "object";
310
- var defaultsDeep = (target, defaults) => {
311
- Object.entries(defaults).forEach(([k2, v2]) => {
312
- if (k2 in target) {
313
- if (target[k2] === void 0) {
314
- target[k2] = v2;
315
- } else {
316
- target[k2] = isObject(v2) ? defaultsDeep(
317
- target[k2],
318
- v2
319
- ) : target[k2];
320
- }
321
- } else {
322
- target[k2] = v2;
323
- }
324
- });
325
- return target;
326
- };
327
- var uuidv4 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g, function(c4) {
328
- const r5 = Math.random() * 16 | 0;
329
- const v2 = c4 == "x" ? r5 : r5 & 3 | 8;
330
- return v2.toString(16);
331
- });
332
-
333
- // libs/embed-libs/shared-embed/src/lib/helpers/iframe-url.ts
334
- var createIframeUrl = (dashboardContent) => {
335
- const searchString = [];
336
- const {
337
- appServer,
338
- language,
339
- qeVersion,
340
- loaderBackground,
341
- loaderSpinnerColor,
342
- loaderSpinnerBackground,
343
- loaderFontColor,
344
- screenMode,
345
- key,
346
- token,
347
- timezoneId,
348
- itemEmbedding,
349
- itemDimensions,
350
- dashboardId,
351
- dashboardSlug,
352
- itemId,
353
- mainColor,
354
- accentColor,
355
- editMode
356
- } = dashboardContent.params;
357
- if (language && language !== "auto") {
358
- searchString.push("language=" + language);
359
- }
360
- if (qeVersion) {
361
- searchString.push(`qe_version=${qeVersion}`);
362
- }
363
- if (loaderBackground) {
364
- searchString.push(`ldrbg=${loaderBackground}`);
365
- }
366
- if (loaderFontColor) {
367
- searchString.push(`ldrftclr=${loaderFontColor}`);
368
- }
369
- if (loaderSpinnerColor) {
370
- searchString.push(`ldrspclr=${loaderSpinnerColor}`);
371
- }
372
- if (loaderSpinnerBackground) {
373
- searchString.push(`ldrspbg=${loaderSpinnerBackground}`);
374
- }
375
- if (mainColor) {
376
- searchString.push(`mainColor=${mainColor}`);
377
- }
378
- if (accentColor) {
379
- searchString.push(`accentColor=${accentColor}`);
380
- }
381
- if (screenMode && screenMode !== "auto") {
382
- searchString.push("screenMode=" + screenMode);
383
- }
384
- if (timezoneId) {
385
- searchString.push("timezoneId=" + timezoneId);
386
- }
387
- if (itemEmbedding && itemDimensions && itemDimensions.width) {
388
- searchString.push("width=" + itemDimensions.width);
389
- }
390
- if (itemEmbedding && itemDimensions && itemDimensions.height) {
391
- searchString.push("height=" + itemDimensions.height);
392
- }
393
- if (editMode) {
394
- searchString.push("editMode=" + editMode);
395
- }
396
- const keyTokenUrlAnchor = key && token ? "#" + key + ":" + token : "";
397
- searchString.push("version=" + (dashboardContent.libVersion || VERSION));
398
- const iframeUrl = itemEmbedding ? `${appServer}i/${dashboardId || dashboardSlug}/${itemId}?${encodeURIComponent(
399
- searchString.join("&")
400
- )}${keyTokenUrlAnchor}` : `${appServer}i/${dashboardId || dashboardSlug}?${encodeURIComponent(
401
- searchString.join("&")
402
- )}${keyTokenUrlAnchor}`;
403
- return sanitizeUrl(iframeUrl);
404
- };
405
-
406
- // libs/embed-libs/shared-embed/src/lib/helpers/get-loader.ts
407
- var getLoader = (dashboardComponent) => {
408
- let errorMsg;
409
- if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
410
- dashboardComponent.params.error = true;
411
- if (dashboardComponent.browserNotSupported) {
412
- errorMsg = "Browser is not supported.";
413
- }
414
- }
415
- const loadingMsg = translations_default.initializing[dashboardComponent.params.language] || translations_default.initializing.en;
416
- return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
417
- };
418
-
419
- // libs/embed-libs/shared-embed/src/lib/helpers/promise-dispatch.ts
420
- function resolvePromise(dashboardComponent, requestId, data) {
421
- if (dashboardComponent.promises[requestId]) {
422
- dashboardComponent.promises[requestId].resolve(data);
423
- delete dashboardComponent.promises[requestId];
424
- }
425
- }
426
- function rejectPromise(dashboardComponent, requestId, data) {
427
- if (dashboardComponent.promises[requestId]) {
428
- dashboardComponent.promises[requestId].reject(data);
429
- delete dashboardComponent.promises[requestId];
430
- }
431
- }
432
-
433
- // libs/embed-libs/shared-embed/src/lib/helpers/styles.ts
434
- function containerStyles(dashboardComponent) {
435
- const styles = {};
436
- if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
437
- styles.background = dashboardComponent.params.loaderBackground;
438
- }
439
- return styles;
440
- }
441
- function containerLoaderStyles(dashboardComponent) {
442
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
443
- const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
444
- const display = dashboardComponent.iframeLoaded ? "none" : "";
445
- return {
446
- display,
447
- height: `${chartHeightDefined ? height : dashboardComponent.minHeight}px`
448
- };
449
- }
450
- function loaderStyles(dashboardComponent) {
451
- const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
452
- if (dashboardComponent.params.itemEmbedding) {
453
- dashboardComponent.loaderSize = 24;
454
- dashboardComponent.borderWidth = 4;
455
- dashboardComponent.minHeight = 200;
456
- const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
457
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
458
- const chartWidthDefined = width !== "auto";
459
- const chartHeightDefined = height !== "auto";
460
- return {
461
- background,
462
- width: chartWidthDefined ? `${width}px` : "100%",
463
- height: `${chartHeightDefined ? height : "200"}px`,
464
- "min-height": chartHeightDefined ? "" : "200px"
465
- };
466
- }
467
- return {
468
- background
469
- };
470
- }
471
- function plStyles(dashboardComponent) {
472
- const {
473
- loaderSpinnerColor: defaultSpinnerColor,
474
- loaderSpinnerBackground: defaultSpinnerBackground
475
- } = DEFAULT_PARAMETERS;
476
- const spinnerColorBorder = generateBorderStyle(
477
- dashboardComponent.borderWidth,
478
- dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
479
- );
480
- const spinnerBackgroundBorder = generateBorderStyle(
481
- dashboardComponent.borderWidth,
482
- dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
483
- );
484
- const size = `${dashboardComponent.loaderSize}px`;
485
- return {
486
- "border-top": spinnerColorBorder,
487
- "border-right": spinnerColorBorder,
488
- "border-bottom": spinnerBackgroundBorder,
489
- "border-left": spinnerBackgroundBorder,
490
- width: size,
491
- height: size
492
- };
493
- }
494
- function lcStyles(dashboardComponent) {
495
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
496
- const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
497
- const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
498
- const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
499
- return {
500
- padding: `${verticalPadding} 16px`
501
- };
502
- }
503
- function calculateIframeStyles(dashboardComponent) {
504
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
505
- const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
506
- if (dashboardComponent.params.itemEmbedding && height !== "auto") {
507
- dashboardComponent.iframeHeight = `${height}px`;
508
- } else if (dashboardComponent.params.itemEmbedding) {
509
- dashboardComponent.iframeHeight = "200px";
510
- } else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
511
- dashboardComponent.iframeHeight = "100%";
512
- } else {
513
- dashboardComponent.iframeHeight = "400px";
514
- }
515
- dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
516
- const styles = {
517
- height: dashboardComponent.iframeHeight,
518
- width: dashboardComponent.iframeWidth
519
- };
520
- if (dashboardComponent.iframeLoaded) {
521
- styles.opacity = 1;
522
- } else if (dashboardComponent.error) {
523
- styles.opacity = 1;
524
- styles.width = "100%";
525
- styles.height = "400px";
526
- } else {
527
- styles.opacity = 0;
528
- }
529
- return styles;
530
- }
531
- function generateBorderStyle(borderWidth, color) {
532
- return `${borderWidth}px solid ${color}`;
533
- }
534
-
535
- // libs/embed-libs/shared-embed/src/lib/helpers/update-iframe-url.ts
536
- var updateIframeUrl = (iframe, iframeUrl) => {
537
- if (iframe?.contentWindow) {
538
- iframe.contentWindow.location.replace(iframeUrl);
539
- }
540
- };
541
-
542
- // libs/embed-libs/shared-embed/src/lib/helpers/set-selected-data-utils.ts
543
- var selectedDataUtils = {
544
- merge(...filters) {
545
- return filters.reduce((acc, filter) => {
546
- acc.and.push(...filter.and);
547
- return acc;
548
- }, {
549
- and: []
550
- });
551
- },
552
- isIn(slot, values, otherOptions) {
553
- return {
554
- and: [{
555
- expression: "? in ?",
556
- parameters: [
557
- {
558
- slot,
559
- ...otherOptions
560
- },
561
- values
562
- ]
563
- }]
564
- };
565
- },
566
- between(slot, values, otherOptions) {
567
- return {
568
- and: [{
569
- expression: "? between ?",
570
- parameters: [
571
- {
572
- slot,
573
- ...otherOptions
574
- },
575
- [values[0], values[1]]
576
- ]
577
- }]
578
- };
579
- },
580
- range(slot, values, otherOptions) {
581
- const expressions = otherOptions?.expressions ?? ["? >= ?", "? < ?"];
582
- return {
583
- and: [{
584
- expression: expressions[0],
585
- parameters: [
586
- {
587
- slot,
588
- ...otherOptions
589
- },
590
- [values[0]]
591
- ]
592
- }, {
593
- expression: expressions[1],
594
- parameters: [
595
- {
596
- slot,
597
- ...otherOptions
598
- },
599
- [values[1]]
600
- ]
601
- }]
602
- };
603
- }
604
- };
605
-
606
- // libs/embed-libs/shared-embed/src/lib/methods/export-dashboard.ts
607
- var exportDashboard = (dashboardComponent, iframe, format) => {
608
- const requestId = uuidv4();
609
- if (iframe?.contentWindow) {
610
- iframe.contentWindow.postMessage(
611
- {
612
- action: "exportDashboard",
613
- format: format || "png",
614
- _version: dashboardComponent.libVersion,
615
- requestId
616
- },
617
- "*"
618
- );
619
- return new Promise((resolve, reject) => {
620
- dashboardComponent.promises[requestId] = { resolve, reject };
621
- setTimeout(() => {
622
- if (dashboardComponent.promises[requestId]) {
623
- const errorMessage = "exportDashboard request timed out.";
624
- dashboardComponent.promises[requestId].reject(
625
- new Error(errorMessage)
626
- );
627
- delete dashboardComponent.promises[requestId];
628
- }
629
- }, 12e5);
630
- });
631
- }
632
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
633
- };
634
-
635
- // libs/embed-libs/shared-embed/src/lib/methods/get-accessible-dashboards.ts
636
- var getAccessibleDashboards = async (dashboardComponent) => {
637
- await dashboardComponent.updateComplete;
638
- if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
639
- const fetchUser = new Promise((resolve, reject) => {
640
- void (() => {
641
- try {
642
- const responsePromise = window.fetch(
643
- // With experimental=true URLs remove the trailing slash, since the web component expects them to not have it.
644
- // Fixes incorrect url with experimental=true
645
- `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/authorization`,
646
- {
647
- method: "POST",
648
- mode: "cors",
649
- cache: "no-cache",
650
- headers: { "Content-Type": "application/json" },
651
- redirect: "follow",
652
- body: JSON.stringify({
653
- action: "get",
654
- version: "0.1.0",
655
- key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
656
- token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
657
- find: {
658
- where: { id: dashboardComponent.authKey },
659
- attributes: ["id", "integration_id"],
660
- include: [
661
- {
662
- model: "User",
663
- attributes: ["id", "name", "locale_id"],
664
- include: [{ model: "Group" }]
665
- }
666
- ]
667
- }
668
- })
669
- }
670
- );
671
- responsePromise.then((response) => response.json()).then((data) => {
672
- if (!data || !data.rows || data.rows.length === 0 || !data.rows[0].user) {
673
- reject("Authorization failed, please check authKey and authToken. If the problem persists, please contact support@luzmo.com.");
674
- } else {
675
- data.rows[0].user.userGroups = data.rows[0].user.groups.map(
676
- (group) => group.id
677
- );
678
- delete data.rows[0].user.groups;
679
- resolve({
680
- integrationId: data.rows[0].integration_id,
681
- user: data.rows[0].user
682
- });
683
- }
684
- });
685
- } catch (error) {
686
- reject(error);
687
- }
688
- })();
689
- });
690
- return new Promise((resolve, reject) => void (() => {
691
- try {
692
- fetchUser.then((authorizationData) => {
693
- const responsePromise = window.fetch(
694
- // With experimental=true URLs remove the trailing slash, since the web component expects them to not have it.
695
- // Fixes incorrect url with experimental=true
696
- `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/securable`,
697
- {
698
- method: "POST",
699
- mode: "cors",
700
- cache: "no-cache",
701
- headers: { "Content-Type": "application/json" },
702
- redirect: "follow",
703
- body: JSON.stringify({
704
- action: "get",
705
- version: "0.1.0",
706
- key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
707
- token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
708
- find: {
709
- where: { type: "dashboard", is_variant: false },
710
- attributes: ["id", "name", "modified_at"],
711
- order: [["modified_at", "desc"]],
712
- include: [
713
- { model: "Tag", attributes: ["tag"] },
714
- { model: "User", attributes: ["id", "name"] },
715
- {
716
- model: "Group",
717
- attributes: ["id", "name", "public"]
718
- },
719
- { model: "Integration", attributes: ["id", "name"] }
720
- ]
721
- }
722
- })
723
- }
724
- );
725
- responsePromise.then((response) => response.json()).then((data) => {
726
- const dashboardList = data.rows.length > 0 ? formatDashboardList(
727
- data.rows,
728
- authorizationData.integrationId,
729
- authorizationData.user,
730
- dashboardComponent
731
- ) : [];
732
- resolve(dashboardList);
733
- });
734
- }).catch((error) => {
735
- reject(error);
736
- });
737
- } catch (error) {
738
- reject(error);
739
- }
740
- })());
741
- }
742
- throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
743
- };
744
-
745
- // libs/embed-libs/shared-embed/src/lib/methods/get-data.ts
746
- var getData = (dashboardComponent, iframe, itemId) => {
747
- if (iframe?.contentWindow) {
748
- const requestId = uuidv4();
749
- iframe.contentWindow.postMessage(
750
- {
751
- action: "getData",
752
- id: itemId,
753
- _version: dashboardComponent.libVersion,
754
- requestId
755
- },
756
- "*"
757
- );
758
- return new Promise((resolve, reject) => {
759
- dashboardComponent.promises[requestId] = { resolve, reject };
760
- setTimeout(() => {
761
- if (dashboardComponent.promises[requestId]) {
762
- const errorMessage = "getData request timed out.";
763
- dashboardComponent.promises[requestId].reject(
764
- new Error(errorMessage)
765
- );
766
- delete dashboardComponent.promises[requestId];
767
- }
768
- }, 2e3);
769
- });
770
- }
771
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
772
- };
773
-
774
- // libs/embed-libs/shared-embed/src/lib/methods/get-filters.ts
775
- var getFilters = (dashboardComponent, iframe) => {
776
- if (iframe?.contentWindow) {
777
- const requestId = uuidv4();
778
- iframe.contentWindow.postMessage(
779
- { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
780
- "*"
781
- );
782
- return new Promise((resolve, reject) => {
783
- dashboardComponent.promises[requestId] = { resolve, reject };
784
- setTimeout(() => {
785
- if (dashboardComponent.promises[requestId]) {
786
- const errorMessage = "getFilters request timed out.";
787
- dashboardComponent.promises[requestId].reject(
788
- new Error(errorMessage)
789
- );
790
- delete dashboardComponent.promises[requestId];
791
- }
792
- }, 2e3);
793
- });
794
- }
795
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
796
- };
797
-
798
- // libs/embed-libs/shared-embed/src/lib/methods/refresh-data.ts
799
- var refreshData = (dashboardComponent, iframe, itemId) => {
800
- if (iframe) {
801
- iframe.contentWindow.postMessage(
802
- {
803
- action: "refreshData",
804
- id: itemId ?? null,
805
- _version: dashboardComponent.libVersion
806
- },
807
- "*"
808
- );
809
- return Promise.resolve();
810
- }
811
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
812
- };
813
-
814
- // libs/embed-libs/shared-embed/src/lib/methods/reload-dashboard.ts
815
- var reloadDashboard = (dashboardComponent, iframe) => {
816
- if (iframe) {
817
- iframe.contentWindow.postMessage(
818
- { action: "reloadDashboard", _version: dashboardComponent.libVersion },
819
- "*"
820
- );
821
- return Promise.resolve();
822
- }
823
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
824
- };
825
-
826
- // libs/embed-libs/shared-embed/src/lib/methods/set-authorization.ts
827
- var setAuthorization = (dashboardComponent, iframe, key, token) => {
828
- if (iframe) {
829
- iframe.contentWindow.postMessage(
830
- {
831
- action: "setAuthorization",
832
- key,
833
- token,
834
- _version: dashboardComponent.libVersion
835
- },
836
- "*"
837
- );
838
- return Promise.resolve();
839
- }
840
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
841
- };
842
-
843
- // libs/embed-libs/shared-embed/src/lib/methods/set-edit-mode.ts
844
- var setEditMode = (dashboardComponent, iframe, editMode) => {
845
- if (iframe && iframe.contentWindow) {
846
- const requestId = uuidv4();
847
- if (dashboardComponent.params.editMode === editMode) {
848
- return Promise.reject(
849
- new Error("editMode parameter is currently already set to " + editMode)
850
- );
851
- } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
852
- return Promise.reject(
853
- new Error(
854
- "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
855
- )
856
- );
857
- }
858
- iframe.contentWindow.postMessage(
859
- {
860
- action: "setEditMode",
861
- editMode,
862
- _version: dashboardComponent.libVersion,
863
- requestId
864
- },
865
- "*"
866
- );
867
- return new Promise((resolve, reject) => {
868
- dashboardComponent.promises[requestId] = { resolve, reject };
869
- });
870
- }
871
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
872
- };
873
-
874
- // libs/embed-libs/shared-embed/src/lib/methods/set-selected-data.ts
875
- var setSelectedData = (dashboardComponent, iframe, itemId, filters) => {
876
- if (iframe) {
877
- const requestId = uuidv4();
878
- iframe.contentWindow.postMessage(
879
- {
880
- action: "setSelectedData",
881
- itemId,
882
- filters,
883
- _version: dashboardComponent.libVersion,
884
- requestId
885
- },
886
- "*"
887
- );
888
- return new Promise((resolve, reject) => {
889
- dashboardComponent.promises[requestId] = { resolve, reject };
890
- setTimeout(() => {
891
- if (dashboardComponent.promises[requestId]) {
892
- const errorMessage = "setSelectedData request timed out.";
893
- dashboardComponent.promises[requestId].reject(
894
- new Error(errorMessage)
895
- );
896
- delete dashboardComponent.promises[requestId];
897
- }
898
- }, 2e3);
899
- });
900
- }
901
- return Promise.reject();
902
- };
903
-
904
- // libs/embed-libs/shared-embed/src/lib/methods/set-preview.ts
905
- var setPreview = (dashboardComponent, iframe, preview) => {
906
- if (iframe) {
907
- const requestId = uuidv4();
908
- iframe.contentWindow.postMessage(
909
- {
910
- action: "setPreview",
911
- preview,
912
- requestId,
913
- _version: dashboardComponent.libVersion
914
- },
915
- "*"
916
- );
917
- return new Promise((resolve, reject) => {
918
- dashboardComponent.promises[requestId] = { resolve, reject };
919
- setTimeout(() => {
920
- if (dashboardComponent.promises[requestId]) {
921
- const errorMessage = "setPreview request timed out.";
922
- dashboardComponent.promises[requestId].reject(
923
- new Error(errorMessage)
924
- );
925
- delete dashboardComponent.promises[requestId];
926
- }
927
- }, 2e3);
928
- });
929
- }
930
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
931
- };
932
-
933
- // libs/embed-libs/shared-embed/src/lib/service/calculate-dimensions.ts
934
- var _setCalculatedDimensions = (dashboardComponent) => {
935
- if (!dashboardComponent.dimensions) {
936
- dashboardComponent.params.error = true;
937
- _handleError("Got no valid dimensions.", dashboardComponent.params);
938
- return;
939
- }
940
- const dashboardDimensionKeys = Object.keys(
941
- dashboardComponent.dimensions
942
- );
943
- const availableScreenModeExtents = [];
944
- let currentMode;
945
- let currentWidth = 0;
946
- let currentHeight = 0;
947
- if (!dashboardComponent.params.switchScreenModeOnResize && dashboardComponent.currentScreenMode) {
948
- dashboardComponent.params.screenMode = dashboardComponent.currentScreenMode;
949
- }
950
- if (dashboardComponent.dimensions && dashboardDimensionKeys?.[0] === "fixed") {
951
- currentMode = "fixed";
952
- currentWidth = dashboardComponent.dimensions.fixed[0];
953
- currentHeight = dashboardComponent.dimensions.fixed[1];
954
- } else {
955
- const screenModes = [
956
- "mobile",
957
- "tablet",
958
- "desktop",
959
- "largeScreen"
960
- ];
961
- if (dashboardComponent.params.itemEmbedding) {
962
- const [firstMatch] = dashboardDimensionKeys;
963
- let match = cloneDeep(firstMatch);
964
- for (const screenMode of screenModes) {
965
- const found = dashboardDimensionKeys.find((key) => key === screenMode);
966
- if (found) {
967
- match = cloneDeep(found);
968
- } else {
969
- dashboardComponent.dimensions[screenMode] = dashboardComponent.dimensions[match];
970
- }
971
- }
972
- }
973
- for (const key of dashboardDimensionKeys) {
974
- if (screenModes.includes(key)) {
975
- const screenMode = EXTENTS.find((extent) => extent.mode === key);
976
- availableScreenModeExtents.push({
977
- ...screenMode,
978
- height: dashboardComponent.dimensions[key][1] || 50
979
- });
980
- }
981
- }
982
- if (!availableScreenModeExtents.map((screenModeExtent) => screenModeExtent.mode).includes(dashboardComponent.params.screenMode)) {
983
- dashboardComponent.params.screenMode = "auto";
984
- }
985
- if (dashboardComponent.params.screenMode === "auto") {
986
- availableScreenModeExtents.sort(
987
- (a2, b2) => screenModes.indexOf(a2.mode) - screenModes.indexOf(b2.mode)
988
- );
989
- for (const screenModeExtent of availableScreenModeExtents) {
990
- const [screenModeExtentMinWidth, screenModeExtentMaxWidth] = screenModeExtent.width;
991
- if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
992
- if (screenModeExtentMinWidth < dashboardComponent.params.itemDimensions.width) {
993
- currentMode = screenModeExtent.mode;
994
- currentWidth = Number.parseInt(
995
- dashboardComponent.params.itemDimensions.width,
996
- 10
997
- );
998
- currentHeight = dashboardComponent.dimensions[currentMode][1];
999
- }
1000
- } else {
1001
- if (screenModeExtentMinWidth < dashboardComponent.containerWidth) {
1002
- currentMode = screenModeExtent.mode;
1003
- if (dashboardComponent.params.itemEmbedding) {
1004
- currentWidth = dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto" ? Number.parseInt(
1005
- dashboardComponent.params.itemDimensions.width,
1006
- 10
1007
- ) : Math.min(
1008
- dashboardComponent.containerWidth,
1009
- screenModeExtentMaxWidth
1010
- );
1011
- currentHeight = dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto" ? Number.parseInt(
1012
- dashboardComponent.params.itemDimensions.height,
1013
- 10
1014
- ) : dashboardComponent.dimensions[currentMode][1];
1015
- if (dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
1016
- currentWidth = Number.parseInt(
1017
- dashboardComponent.params.itemDimensions.width,
1018
- 10
1019
- );
1020
- currentHeight = dashboardComponent.dimensions[currentMode][1];
1021
- }
1022
- } else {
1023
- currentWidth = Math.max(
1024
- Math.min(
1025
- screenModeExtentMaxWidth,
1026
- dashboardComponent.containerWidth
1027
- ),
1028
- screenModeExtentMinWidth
1029
- );
1030
- currentHeight = screenModeExtent.height;
1031
- }
1032
- }
1033
- }
1034
- }
1035
- } else {
1036
- const {
1037
- height: chosenModeHeight,
1038
- width: [chosenModeMinWidth, chosenModeMaxWidth]
1039
- } = availableScreenModeExtents.find(
1040
- (d2) => d2.mode === dashboardComponent.params.screenMode
1041
- );
1042
- currentMode = dashboardComponent.params.screenMode;
1043
- currentWidth = Math.max(
1044
- Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
1045
- chosenModeMinWidth
1046
- );
1047
- currentHeight = chosenModeHeight;
1048
- if (dashboardComponent.params.itemEmbedding) {
1049
- if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
1050
- currentWidth = Number.parseInt(
1051
- dashboardComponent.params.itemDimensions.width,
1052
- 10
1053
- );
1054
- }
1055
- if (dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto") {
1056
- currentHeight = Number.parseInt(
1057
- dashboardComponent.params.itemDimensions.height,
1058
- 10
1059
- );
1060
- }
1061
- }
1062
- }
1063
- if (!currentMode && availableScreenModeExtents.length > 0) {
1064
- const [lowestModeExtent] = availableScreenModeExtents;
1065
- currentMode = lowestModeExtent.mode;
1066
- currentWidth = lowestModeExtent.width[0];
1067
- currentHeight = lowestModeExtent.height;
1068
- }
1069
- }
1070
- dashboardComponent.currentScreenMode = currentMode;
1071
- const style = {
1072
- height: currentHeight === 0 ? "100%" : `${String(currentHeight)}px`,
1073
- width: currentWidth === 0 ? "100%" : `${String(currentWidth)}px`,
1074
- opacity: 1
1075
- };
1076
- const dashboardEditModes = ["editFull", "editLimited"];
1077
- if (dashboardEditModes.includes(dashboardComponent.params.editMode)) {
1078
- style.height = "100%";
1079
- style.width = "100%";
1080
- } else if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions) {
1081
- style.height = dashboardComponent.params.itemDimensions.height === "auto" ? style.height : `${String(dashboardComponent.params.itemDimensions.height).replace(
1082
- "px",
1083
- ""
1084
- )}px`;
1085
- style.width = dashboardComponent.params.itemDimensions.width === "auto" ? style.width : `${String(dashboardComponent.params.itemDimensions.width).replace(
1086
- "px",
1087
- ""
1088
- )}px`;
1089
- } else {
1090
- style.height = currentHeight === 0 ? "100%" : `${String(currentHeight)}px`;
1091
- style.width = currentWidth === 0 ? "100%" : `${String(currentWidth)}px`;
1092
- }
1093
- dashboardComponent.currentScreenMode = currentMode;
1094
- dashboardComponent.iframeStyle = style;
1095
- };
1096
-
1097
- // libs/embed-libs/shared-embed/src/lib/service/extend-and-validate.ts
1098
- var _extendAndValidate = (dashboardContent) => {
1099
- const defaultKeys = Object.keys(
1100
- DEFAULT_PARAMETERS
1101
- );
1102
- const errorMessages = [];
1103
- const requiredStringParams = [
1104
- "appServer",
1105
- "language",
1106
- "apiHost"
1107
- ];
1108
- const requiredStringOrEmptyParams = [
1109
- "key",
1110
- "token",
1111
- "screenMode",
1112
- "timezoneId",
1113
- "itemId",
1114
- "container",
1115
- "loaderBackground",
1116
- "loaderFontColor",
1117
- "loaderSpinnerColor",
1118
- "loaderSpinnerBackground"
1119
- ];
1120
- const objectParams = ["itemDimensions"];
1121
- const screenModes = [
1122
- "mobile",
1123
- "tablet",
1124
- "desktop",
1125
- "largeScreen",
1126
- "fixed",
1127
- "auto"
1128
- ];
1129
- for (const key of defaultKeys) {
1130
- if (dashboardContent.params[key] === null) {
1131
- delete dashboardContent.params[key];
1132
- }
1133
- }
1134
- dashboardContent.params = defaultsDeep(
1135
- dashboardContent.params,
1136
- DEFAULT_PARAMETERS
1137
- );
1138
- if ((!dashboardContent.params.dashboardId || typeof dashboardContent.params.dashboardId !== "string") && (!dashboardContent.params.dashboardSlug || typeof dashboardContent.params.dashboardSlug !== "string")) {
1139
- delete dashboardContent.params.dashboardId;
1140
- delete dashboardContent.params.dashboardSlug;
1141
- }
1142
- for (const key of requiredStringParams) {
1143
- if (typeof dashboardContent.params[key] !== "string") {
1144
- delete dashboardContent.params[key];
1145
- errorMessages.push(`${key} needs to be of type string.`);
1146
- }
1147
- }
1148
- for (const key of requiredStringOrEmptyParams) {
1149
- if (typeof dashboardContent.params[key] !== "string" && dashboardContent.params[key] !== null && dashboardContent.params[key] !== void 0) {
1150
- delete dashboardContent.params[key];
1151
- errorMessages.push(`${key} needs to be of type string or empty.`);
1152
- }
1153
- }
1154
- if (dashboardContent.params.screenMode && !screenModes.includes(dashboardContent.params.screenMode)) {
1155
- const validTypesString = screenModes.map((mode) => `"${mode}"`).join(", ");
1156
- errorMessages.push(
1157
- `"screenMode" needs should be one of these types: ${validTypesString}`
1158
- );
1159
- dashboardContent.params.screenMode = "auto";
1160
- }
1161
- if (dashboardContent.params.itemId) {
1162
- dashboardContent.params.itemEmbedding = true;
1163
- }
1164
- for (const key of objectParams) {
1165
- if (typeof dashboardContent.params[key] !== "object" && dashboardContent.params[key] !== null) {
1166
- delete dashboardContent.params[key];
1167
- errorMessages.push(`${key} needs to be of type object or empty.`);
1168
- }
1169
- }
1170
- if (typeof dashboardContent.params.switchScreenModeOnResize !== "boolean") {
1171
- errorMessages.push("switchScreenModeOnResize needs to be of type boolean.");
1172
- dashboardContent.params.switchScreenModeOnResize = true;
1173
- }
1174
- if (dashboardContent.params.itemDimensions) {
1175
- const itemDimensionsKeys = [
1176
- "width",
1177
- "height"
1178
- ];
1179
- for (const key of itemDimensionsKeys) {
1180
- if (!["string", "number"].includes(
1181
- typeof dashboardContent.params.itemDimensions[key]
1182
- ) && dashboardContent.params.itemDimensions[key] !== null) {
1183
- errorMessages.push(
1184
- `itemDimensions ${key} needs to be of type string, number or empty.`
1185
- );
1186
- }
1187
- }
1188
- }
1189
- dashboardContent.params = defaultsDeep(
1190
- dashboardContent.params,
1191
- DEFAULT_PARAMETERS
1192
- );
1193
- if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
1194
- dashboardContent.params.switchScreenModeOnResize = false;
1195
- }
1196
- if (dashboardContent.params.itemDimensions.width !== "auto") {
1197
- dashboardContent.params.itemDimensions.width = Number.parseInt(
1198
- `${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
1199
- 10
1200
- ) || "auto";
1201
- }
1202
- if (dashboardContent.params.itemDimensions.height !== "auto") {
1203
- dashboardContent.params.itemDimensions.height = Number.parseInt(
1204
- `${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
1205
- 10
1206
- ) || "auto";
1207
- }
1208
- dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
1209
- if (dashboardContent.params.error || errorMessages.length > 0) {
1210
- _handleError(errorMessages.join("\n"), dashboardContent.params);
1211
- }
1212
- };
1213
-
1214
- // libs/embed-libs/shared-embed/src/lib/models/viz-item.model.ts
1215
- var libraryTypeToWebComponentTypeMapping = {
1216
- type: "type",
1217
- slots: "slots",
1218
- options: "options",
1219
- appServer: "app-server",
1220
- apiHost: "api-host",
1221
- authKey: "auth-key",
1222
- authToken: "auth-token",
1223
- contextId: "context-id",
1224
- canFilter: "can-filter",
1225
- filters: "filters",
1226
- dashboardId: "dashboard-id",
1227
- itemId: "item-id",
1228
- dashboardContentsVersion: "dashboard-contents-version",
1229
- libVersion: "lib-version"
1230
- };
1231
-
1232
- // libs/embed-libs/shared-embed/src/lib/constants/class-constants.ts
1233
- var luzmoEmbedContainerClass = "luzmo-embed-container";
1234
-
1235
- // libs/embed-libs/shared-embed/src/lib/helpers/remote-federation.ts
1236
- var remotesMap = {
1237
- // "remote_app": { url: "http://localhost:4201/remoteEntry.mjs", format: "esm", from: "vite" },
1238
- };
1239
- var loadJS = async (url, fn) => {
1240
- const resolvedUrl = typeof url === "function" ? await url() : url;
1241
- const script = document.createElement("script");
1242
- script.type = "text/javascript";
1243
- script.addEventListener("load", fn);
1244
- script.src = resolvedUrl;
1245
- document.querySelectorAll("head")[0].append(script);
1246
- };
1247
- var wrapShareModule = (remoteFrom) => ({});
1248
- async function __federationMethodEnsure(remoteId) {
1249
- const remote = remotesMap[remoteId];
1250
- if (remote.inited) {
1251
- return remote.lib;
1252
- }
1253
- if (remote.format === "var") {
1254
- return new Promise((resolve) => {
1255
- const callback = () => {
1256
- if (!remote.inited) {
1257
- remote.lib = window[remoteId];
1258
- remote.lib.init(wrapShareModule(remote.from));
1259
- remote.inited = true;
1260
- }
1261
- resolve(remote.lib);
1262
- };
1263
- return loadJS(remote.url, callback);
1264
- });
1265
- } else if (["esm", "systemjs"].includes(remote.format)) {
1266
- return new Promise((resolve, reject) => {
1267
- const getUrl = typeof remote.url === "function" ? remote.url : () => Promise.resolve(remote.url);
1268
- getUrl().then((url) => {
1269
- import(
1270
- /* @vite-ignore */
1271
- /* webpackIgnore: true */
1272
- url
1273
- ).then((lib) => {
1274
- if (!remote.inited) {
1275
- const shareScope = wrapShareModule(remote.from);
1276
- lib.init(shareScope);
1277
- remote.lib = lib;
1278
- remote.lib.init(shareScope);
1279
- remote.inited = true;
1280
- }
1281
- resolve(remote.lib);
1282
- }).catch(reject);
1283
- });
1284
- });
1285
- }
1286
- }
1287
- function __federationMethodWrapDefault(module2, need) {
1288
- if (!(module2 == null ? void 0 : module2.default) && need) {
1289
- const obj = /* @__PURE__ */ Object.create(null);
1290
- obj.default = module2;
1291
- obj.__esModule = true;
1292
- return obj;
1293
- }
1294
- return module2;
1295
- }
1296
- async function __federationMethodGetRemote(remoteName, componentName) {
1297
- return __federationMethodEnsure(remoteName).then((remote) => remote.get(componentName).then((factory) => factory()));
1298
- }
1299
- async function loadLibrary(appServer, componentName = "DashboardApp") {
1300
- const remotesMapIndex = appServer + componentName;
1301
- if (remotesMap[remotesMapIndex]) {
1302
- return remotesMap[remotesMapIndex].module;
1303
- }
1304
- let url = `${removeTrailingSlash(appServer)}/remoteEntry.mjs`;
1305
- if (!appServer.startsWith("http://localhost")) {
1306
- if (componentName === "DashboardApp") {
1307
- url = `${removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`;
1308
- } else if (componentName === "Component") {
1309
- url = `${removeTrailingSlash(appServer)}/iq-components/remoteEntry.mjs`;
1310
- }
1311
- }
1312
- remotesMap[remotesMapIndex] = {
1313
- url,
1314
- format: "esm",
1315
- from: "vite",
1316
- module: void 0
1317
- };
1318
- const module2 = await __federationMethodGetRemote(remotesMapIndex, `./${componentName}`);
1319
- const wrappedModule = __federationMethodWrapDefault(module2, true);
1320
- remotesMap[remotesMapIndex].module = wrappedModule;
1321
- return wrappedModule;
1322
- }
1323
-
1324
- // node_modules/@lit/reactive-element/css-tag.js
1325
- var t = globalThis;
1326
- var e = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype;
1327
- var s = Symbol();
1328
- var o = /* @__PURE__ */ new WeakMap();
1329
- var n = class {
1330
- constructor(t3, e6, o4) {
1331
- if (this._$cssResult$ = true, o4 !== s)
1332
- throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
1333
- this.cssText = t3, this.t = e6;
1334
- }
1335
- get styleSheet() {
1336
- let t3 = this.o;
1337
- const s2 = this.t;
1338
- if (e && void 0 === t3) {
1339
- const e6 = void 0 !== s2 && 1 === s2.length;
1340
- e6 && (t3 = o.get(s2)), void 0 === t3 && ((this.o = t3 = new CSSStyleSheet()).replaceSync(this.cssText), e6 && o.set(s2, t3));
1341
- }
1342
- return t3;
1343
- }
1344
- toString() {
1345
- return this.cssText;
1346
- }
1347
- };
1348
- var r = (t3) => new n("string" == typeof t3 ? t3 : t3 + "", void 0, s);
1349
- var i = (t3, ...e6) => {
1350
- const o4 = 1 === t3.length ? t3[0] : e6.reduce((e7, s2, o5) => e7 + ((t4) => {
1351
- if (true === t4._$cssResult$)
1352
- return t4.cssText;
1353
- if ("number" == typeof t4)
1354
- return t4;
1355
- throw Error("Value passed to 'css' function must be a 'css' function result: " + t4 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
1356
- })(s2) + t3[o5 + 1], t3[0]);
1357
- return new n(o4, t3, s);
1358
- };
1359
- var S = (s2, o4) => {
1360
- if (e)
1361
- s2.adoptedStyleSheets = o4.map((t3) => t3 instanceof CSSStyleSheet ? t3 : t3.styleSheet);
1362
- else
1363
- for (const e6 of o4) {
1364
- const o5 = document.createElement("style"), n5 = t.litNonce;
1365
- void 0 !== n5 && o5.setAttribute("nonce", n5), o5.textContent = e6.cssText, s2.appendChild(o5);
1366
- }
1367
- };
1368
- var c = e ? (t3) => t3 : (t3) => t3 instanceof CSSStyleSheet ? ((t4) => {
1369
- let e6 = "";
1370
- for (const s2 of t4.cssRules)
1371
- e6 += s2.cssText;
1372
- return r(e6);
1373
- })(t3) : t3;
1374
-
1375
- // node_modules/@lit/reactive-element/reactive-element.js
1376
- var { is: i2, defineProperty: e2, getOwnPropertyDescriptor: r2, getOwnPropertyNames: h, getOwnPropertySymbols: o2, getPrototypeOf: n2 } = Object;
1377
- var a = globalThis;
1378
- var c2 = a.trustedTypes;
1379
- var l = c2 ? c2.emptyScript : "";
1380
- var p = a.reactiveElementPolyfillSupport;
1381
- var d = (t3, s2) => t3;
1382
- var u = { toAttribute(t3, s2) {
1383
- switch (s2) {
1384
- case Boolean:
1385
- t3 = t3 ? l : null;
1386
- break;
1387
- case Object:
1388
- case Array:
1389
- t3 = null == t3 ? t3 : JSON.stringify(t3);
1390
- }
1391
- return t3;
1392
- }, fromAttribute(t3, s2) {
1393
- let i4 = t3;
1394
- switch (s2) {
1395
- case Boolean:
1396
- i4 = null !== t3;
1397
- break;
1398
- case Number:
1399
- i4 = null === t3 ? null : Number(t3);
1400
- break;
1401
- case Object:
1402
- case Array:
1403
- try {
1404
- i4 = JSON.parse(t3);
1405
- } catch (t4) {
1406
- i4 = null;
1407
- }
1408
- }
1409
- return i4;
1410
- } };
1411
- var f = (t3, s2) => !i2(t3, s2);
1412
- var y = { attribute: true, type: String, converter: u, reflect: false, hasChanged: f };
1413
- Symbol.metadata ??= Symbol("metadata"), a.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
1414
- var b = class extends HTMLElement {
1415
- static addInitializer(t3) {
1416
- this._$Ei(), (this.l ??= []).push(t3);
1417
- }
1418
- static get observedAttributes() {
1419
- return this.finalize(), this._$Eh && [...this._$Eh.keys()];
1420
- }
1421
- static createProperty(t3, s2 = y) {
1422
- if (s2.state && (s2.attribute = false), this._$Ei(), this.elementProperties.set(t3, s2), !s2.noAccessor) {
1423
- const i4 = Symbol(), r5 = this.getPropertyDescriptor(t3, i4, s2);
1424
- void 0 !== r5 && e2(this.prototype, t3, r5);
1425
- }
1426
- }
1427
- static getPropertyDescriptor(t3, s2, i4) {
1428
- const { get: e6, set: h4 } = r2(this.prototype, t3) ?? { get() {
1429
- return this[s2];
1430
- }, set(t4) {
1431
- this[s2] = t4;
1432
- } };
1433
- return { get() {
1434
- return e6?.call(this);
1435
- }, set(s3) {
1436
- const r5 = e6?.call(this);
1437
- h4.call(this, s3), this.requestUpdate(t3, r5, i4);
1438
- }, configurable: true, enumerable: true };
1439
- }
1440
- static getPropertyOptions(t3) {
1441
- return this.elementProperties.get(t3) ?? y;
1442
- }
1443
- static _$Ei() {
1444
- if (this.hasOwnProperty(d("elementProperties")))
1445
- return;
1446
- const t3 = n2(this);
1447
- t3.finalize(), void 0 !== t3.l && (this.l = [...t3.l]), this.elementProperties = new Map(t3.elementProperties);
1448
- }
1449
- static finalize() {
1450
- if (this.hasOwnProperty(d("finalized")))
1451
- return;
1452
- if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d("properties"))) {
1453
- const t4 = this.properties, s2 = [...h(t4), ...o2(t4)];
1454
- for (const i4 of s2)
1455
- this.createProperty(i4, t4[i4]);
1456
- }
1457
- const t3 = this[Symbol.metadata];
1458
- if (null !== t3) {
1459
- const s2 = litPropertyMetadata.get(t3);
1460
- if (void 0 !== s2)
1461
- for (const [t4, i4] of s2)
1462
- this.elementProperties.set(t4, i4);
1463
- }
1464
- this._$Eh = /* @__PURE__ */ new Map();
1465
- for (const [t4, s2] of this.elementProperties) {
1466
- const i4 = this._$Eu(t4, s2);
1467
- void 0 !== i4 && this._$Eh.set(i4, t4);
1468
- }
1469
- this.elementStyles = this.finalizeStyles(this.styles);
1470
- }
1471
- static finalizeStyles(s2) {
1472
- const i4 = [];
1473
- if (Array.isArray(s2)) {
1474
- const e6 = new Set(s2.flat(1 / 0).reverse());
1475
- for (const s3 of e6)
1476
- i4.unshift(c(s3));
1477
- } else
1478
- void 0 !== s2 && i4.push(c(s2));
1479
- return i4;
1480
- }
1481
- static _$Eu(t3, s2) {
1482
- const i4 = s2.attribute;
1483
- return false === i4 ? void 0 : "string" == typeof i4 ? i4 : "string" == typeof t3 ? t3.toLowerCase() : void 0;
1484
- }
1485
- constructor() {
1486
- super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
1487
- }
1488
- _$Ev() {
1489
- this._$ES = new Promise((t3) => this.enableUpdating = t3), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach((t3) => t3(this));
1490
- }
1491
- addController(t3) {
1492
- (this._$EO ??= /* @__PURE__ */ new Set()).add(t3), void 0 !== this.renderRoot && this.isConnected && t3.hostConnected?.();
1493
- }
1494
- removeController(t3) {
1495
- this._$EO?.delete(t3);
1496
- }
1497
- _$E_() {
1498
- const t3 = /* @__PURE__ */ new Map(), s2 = this.constructor.elementProperties;
1499
- for (const i4 of s2.keys())
1500
- this.hasOwnProperty(i4) && (t3.set(i4, this[i4]), delete this[i4]);
1501
- t3.size > 0 && (this._$Ep = t3);
1502
- }
1503
- createRenderRoot() {
1504
- const t3 = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
1505
- return S(t3, this.constructor.elementStyles), t3;
1506
- }
1507
- connectedCallback() {
1508
- this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach((t3) => t3.hostConnected?.());
1509
- }
1510
- enableUpdating(t3) {
1511
- }
1512
- disconnectedCallback() {
1513
- this._$EO?.forEach((t3) => t3.hostDisconnected?.());
1514
- }
1515
- attributeChangedCallback(t3, s2, i4) {
1516
- this._$AK(t3, i4);
1517
- }
1518
- _$EC(t3, s2) {
1519
- const i4 = this.constructor.elementProperties.get(t3), e6 = this.constructor._$Eu(t3, i4);
1520
- if (void 0 !== e6 && true === i4.reflect) {
1521
- const r5 = (void 0 !== i4.converter?.toAttribute ? i4.converter : u).toAttribute(s2, i4.type);
1522
- this._$Em = t3, null == r5 ? this.removeAttribute(e6) : this.setAttribute(e6, r5), this._$Em = null;
1523
- }
1524
- }
1525
- _$AK(t3, s2) {
1526
- const i4 = this.constructor, e6 = i4._$Eh.get(t3);
1527
- if (void 0 !== e6 && this._$Em !== e6) {
1528
- const t4 = i4.getPropertyOptions(e6), r5 = "function" == typeof t4.converter ? { fromAttribute: t4.converter } : void 0 !== t4.converter?.fromAttribute ? t4.converter : u;
1529
- this._$Em = e6, this[e6] = r5.fromAttribute(s2, t4.type), this._$Em = null;
1530
- }
1531
- }
1532
- requestUpdate(t3, s2, i4) {
1533
- if (void 0 !== t3) {
1534
- if (i4 ??= this.constructor.getPropertyOptions(t3), !(i4.hasChanged ?? f)(this[t3], s2))
1535
- return;
1536
- this.P(t3, s2, i4);
1537
- }
1538
- false === this.isUpdatePending && (this._$ES = this._$ET());
1539
- }
1540
- P(t3, s2, i4) {
1541
- this._$AL.has(t3) || this._$AL.set(t3, s2), true === i4.reflect && this._$Em !== t3 && (this._$Ej ??= /* @__PURE__ */ new Set()).add(t3);
1542
- }
1543
- async _$ET() {
1544
- this.isUpdatePending = true;
1545
- try {
1546
- await this._$ES;
1547
- } catch (t4) {
1548
- Promise.reject(t4);
1549
- }
1550
- const t3 = this.scheduleUpdate();
1551
- return null != t3 && await t3, !this.isUpdatePending;
1552
- }
1553
- scheduleUpdate() {
1554
- return this.performUpdate();
1555
- }
1556
- performUpdate() {
1557
- if (!this.isUpdatePending)
1558
- return;
1559
- if (!this.hasUpdated) {
1560
- if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
1561
- for (const [t5, s3] of this._$Ep)
1562
- this[t5] = s3;
1563
- this._$Ep = void 0;
1564
- }
1565
- const t4 = this.constructor.elementProperties;
1566
- if (t4.size > 0)
1567
- for (const [s3, i4] of t4)
1568
- true !== i4.wrapped || this._$AL.has(s3) || void 0 === this[s3] || this.P(s3, this[s3], i4);
1569
- }
1570
- let t3 = false;
1571
- const s2 = this._$AL;
1572
- try {
1573
- t3 = this.shouldUpdate(s2), t3 ? (this.willUpdate(s2), this._$EO?.forEach((t4) => t4.hostUpdate?.()), this.update(s2)) : this._$EU();
1574
- } catch (s3) {
1575
- throw t3 = false, this._$EU(), s3;
1576
- }
1577
- t3 && this._$AE(s2);
1578
- }
1579
- willUpdate(t3) {
1580
- }
1581
- _$AE(t3) {
1582
- this._$EO?.forEach((t4) => t4.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t3)), this.updated(t3);
1583
- }
1584
- _$EU() {
1585
- this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false;
1586
- }
1587
- get updateComplete() {
1588
- return this.getUpdateComplete();
1589
- }
1590
- getUpdateComplete() {
1591
- return this._$ES;
1592
- }
1593
- shouldUpdate(t3) {
1594
- return true;
1595
- }
1596
- update(t3) {
1597
- this._$Ej &&= this._$Ej.forEach((t4) => this._$EC(t4, this[t4])), this._$EU();
1598
- }
1599
- updated(t3) {
1600
- }
1601
- firstUpdated(t3) {
1602
- }
1603
- };
1604
- b.elementStyles = [], b.shadowRootOptions = { mode: "open" }, b[d("elementProperties")] = /* @__PURE__ */ new Map(), b[d("finalized")] = /* @__PURE__ */ new Map(), p?.({ ReactiveElement: b }), (a.reactiveElementVersions ??= []).push("2.0.4");
1605
-
1606
- // node_modules/lit-html/lit-html.js
1607
- var n3 = globalThis;
1608
- var c3 = n3.trustedTypes;
1609
- var h2 = c3 ? c3.createPolicy("lit-html", { createHTML: (t3) => t3 }) : void 0;
1610
- var f2 = "$lit$";
1611
- var v = `lit$${Math.random().toFixed(9).slice(2)}$`;
1612
- var m = "?" + v;
1613
- var _ = `<${m}>`;
1614
- var w = document;
1615
- var lt = () => w.createComment("");
1616
- var st = (t3) => null === t3 || "object" != typeof t3 && "function" != typeof t3;
1617
- var g = Array.isArray;
1618
- var $ = (t3) => g(t3) || "function" == typeof t3?.[Symbol.iterator];
1619
- var x = "[ \n\f\r]";
1620
- var T = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g;
1621
- var E = /-->/g;
1622
- var k = />/g;
1623
- var O = RegExp(`>|${x}(?:([^\\s"'>=/]+)(${x}*=${x}*(?:[^
1624
- \f\r"'\`<>=]|("|')|))|$)`, "g");
1625
- var S2 = /'/g;
1626
- var j = /"/g;
1627
- var M = /^(?:script|style|textarea|title)$/i;
1628
- var P = (t3) => (i4, ...s2) => ({ _$litType$: t3, strings: i4, values: s2 });
1629
- var ke = P(1);
1630
- var Oe = P(2);
1631
- var Se = P(3);
1632
- var R = Symbol.for("lit-noChange");
1633
- var D = Symbol.for("lit-nothing");
1634
- var V = /* @__PURE__ */ new WeakMap();
1635
- var I = w.createTreeWalker(w, 129);
1636
- function N(t3, i4) {
1637
- if (!g(t3) || !t3.hasOwnProperty("raw"))
1638
- throw Error("invalid template strings array");
1639
- return void 0 !== h2 ? h2.createHTML(i4) : i4;
1640
- }
1641
- var U = (t3, i4) => {
1642
- const s2 = t3.length - 1, e6 = [];
1643
- let h4, o4 = 2 === i4 ? "<svg>" : 3 === i4 ? "<math>" : "", n5 = T;
1644
- for (let i5 = 0; i5 < s2; i5++) {
1645
- const s3 = t3[i5];
1646
- let r5, l2, c4 = -1, a2 = 0;
1647
- for (; a2 < s3.length && (n5.lastIndex = a2, l2 = n5.exec(s3), null !== l2); )
1648
- a2 = n5.lastIndex, n5 === T ? "!--" === l2[1] ? n5 = E : void 0 !== l2[1] ? n5 = k : void 0 !== l2[2] ? (M.test(l2[2]) && (h4 = RegExp("</" + l2[2], "g")), n5 = O) : void 0 !== l2[3] && (n5 = O) : n5 === O ? ">" === l2[0] ? (n5 = h4 ?? T, c4 = -1) : void 0 === l2[1] ? c4 = -2 : (c4 = n5.lastIndex - l2[2].length, r5 = l2[1], n5 = void 0 === l2[3] ? O : '"' === l2[3] ? j : S2) : n5 === j || n5 === S2 ? n5 = O : n5 === E || n5 === k ? n5 = T : (n5 = O, h4 = void 0);
1649
- const u2 = n5 === O && t3[i5 + 1].startsWith("/>") ? " " : "";
1650
- o4 += n5 === T ? s3 + _ : c4 >= 0 ? (e6.push(r5), s3.slice(0, c4) + f2 + s3.slice(c4) + v + u2) : s3 + v + (-2 === c4 ? i5 : u2);
1651
- }
1652
- return [N(t3, o4 + (t3[s2] || "<?>") + (2 === i4 ? "</svg>" : 3 === i4 ? "</math>" : "")), e6];
1653
- };
1654
- var B = class _B {
1655
- constructor({ strings: t3, _$litType$: i4 }, s2) {
1656
- let e6;
1657
- this.parts = [];
1658
- let h4 = 0, o4 = 0;
1659
- const n5 = t3.length - 1, r5 = this.parts, [l2, a2] = U(t3, i4);
1660
- if (this.el = _B.createElement(l2, s2), I.currentNode = this.el.content, 2 === i4 || 3 === i4) {
1661
- const t4 = this.el.content.firstChild;
1662
- t4.replaceWith(...t4.childNodes);
1663
- }
1664
- for (; null !== (e6 = I.nextNode()) && r5.length < n5; ) {
1665
- if (1 === e6.nodeType) {
1666
- if (e6.hasAttributes())
1667
- for (const t4 of e6.getAttributeNames())
1668
- if (t4.endsWith(f2)) {
1669
- const i5 = a2[o4++], s3 = e6.getAttribute(t4).split(v), n6 = /([.?@])?(.*)/.exec(i5);
1670
- r5.push({ type: 1, index: h4, name: n6[2], strings: s3, ctor: "." === n6[1] ? Y : "?" === n6[1] ? Z : "@" === n6[1] ? q : G }), e6.removeAttribute(t4);
1671
- } else
1672
- t4.startsWith(v) && (r5.push({ type: 6, index: h4 }), e6.removeAttribute(t4));
1673
- if (M.test(e6.tagName)) {
1674
- const t4 = e6.textContent.split(v), i5 = t4.length - 1;
1675
- if (i5 > 0) {
1676
- e6.textContent = c3 ? c3.emptyScript : "";
1677
- for (let s3 = 0; s3 < i5; s3++)
1678
- e6.append(t4[s3], lt()), I.nextNode(), r5.push({ type: 2, index: ++h4 });
1679
- e6.append(t4[i5], lt());
1680
- }
1681
- }
1682
- } else if (8 === e6.nodeType)
1683
- if (e6.data === m)
1684
- r5.push({ type: 2, index: h4 });
1685
- else {
1686
- let t4 = -1;
1687
- for (; -1 !== (t4 = e6.data.indexOf(v, t4 + 1)); )
1688
- r5.push({ type: 7, index: h4 }), t4 += v.length - 1;
1689
- }
1690
- h4++;
1691
- }
1692
- }
1693
- static createElement(t3, i4) {
1694
- const s2 = w.createElement("template");
1695
- return s2.innerHTML = t3, s2;
1696
- }
1697
- };
1698
- function z(t3, i4, s2 = t3, e6) {
1699
- if (i4 === R)
1700
- return i4;
1701
- let h4 = void 0 !== e6 ? s2.o?.[e6] : s2.l;
1702
- const o4 = st(i4) ? void 0 : i4._$litDirective$;
1703
- return h4?.constructor !== o4 && (h4?._$AO?.(false), void 0 === o4 ? h4 = void 0 : (h4 = new o4(t3), h4._$AT(t3, s2, e6)), void 0 !== e6 ? (s2.o ??= [])[e6] = h4 : s2.l = h4), void 0 !== h4 && (i4 = z(t3, h4._$AS(t3, i4.values), h4, e6)), i4;
1704
- }
1705
- var F = class {
1706
- constructor(t3, i4) {
1707
- this._$AV = [], this._$AN = void 0, this._$AD = t3, this._$AM = i4;
1708
- }
1709
- get parentNode() {
1710
- return this._$AM.parentNode;
1711
- }
1712
- get _$AU() {
1713
- return this._$AM._$AU;
1714
- }
1715
- u(t3) {
1716
- const { el: { content: i4 }, parts: s2 } = this._$AD, e6 = (t3?.creationScope ?? w).importNode(i4, true);
1717
- I.currentNode = e6;
1718
- let h4 = I.nextNode(), o4 = 0, n5 = 0, r5 = s2[0];
1719
- for (; void 0 !== r5; ) {
1720
- if (o4 === r5.index) {
1721
- let i5;
1722
- 2 === r5.type ? i5 = new et(h4, h4.nextSibling, this, t3) : 1 === r5.type ? i5 = new r5.ctor(h4, r5.name, r5.strings, this, t3) : 6 === r5.type && (i5 = new K(h4, this, t3)), this._$AV.push(i5), r5 = s2[++n5];
1723
- }
1724
- o4 !== r5?.index && (h4 = I.nextNode(), o4++);
1725
- }
1726
- return I.currentNode = w, e6;
1727
- }
1728
- p(t3) {
1729
- let i4 = 0;
1730
- for (const s2 of this._$AV)
1731
- void 0 !== s2 && (void 0 !== s2.strings ? (s2._$AI(t3, s2, i4), i4 += s2.strings.length - 2) : s2._$AI(t3[i4])), i4++;
1732
- }
1733
- };
1734
- var et = class _et {
1735
- get _$AU() {
1736
- return this._$AM?._$AU ?? this.v;
1737
- }
1738
- constructor(t3, i4, s2, e6) {
1739
- this.type = 2, this._$AH = D, this._$AN = void 0, this._$AA = t3, this._$AB = i4, this._$AM = s2, this.options = e6, this.v = e6?.isConnected ?? true;
1740
- }
1741
- get parentNode() {
1742
- let t3 = this._$AA.parentNode;
1743
- const i4 = this._$AM;
1744
- return void 0 !== i4 && 11 === t3?.nodeType && (t3 = i4.parentNode), t3;
1745
- }
1746
- get startNode() {
1747
- return this._$AA;
1748
- }
1749
- get endNode() {
1750
- return this._$AB;
1751
- }
1752
- _$AI(t3, i4 = this) {
1753
- t3 = z(this, t3, i4), st(t3) ? t3 === D || null == t3 || "" === t3 ? (this._$AH !== D && this._$AR(), this._$AH = D) : t3 !== this._$AH && t3 !== R && this._(t3) : void 0 !== t3._$litType$ ? this.$(t3) : void 0 !== t3.nodeType ? this.T(t3) : $(t3) ? this.k(t3) : this._(t3);
1754
- }
1755
- O(t3) {
1756
- return this._$AA.parentNode.insertBefore(t3, this._$AB);
1757
- }
1758
- T(t3) {
1759
- this._$AH !== t3 && (this._$AR(), this._$AH = this.O(t3));
1760
- }
1761
- _(t3) {
1762
- this._$AH !== D && st(this._$AH) ? this._$AA.nextSibling.data = t3 : this.T(w.createTextNode(t3)), this._$AH = t3;
1763
- }
1764
- $(t3) {
1765
- const { values: i4, _$litType$: s2 } = t3, e6 = "number" == typeof s2 ? this._$AC(t3) : (void 0 === s2.el && (s2.el = B.createElement(N(s2.h, s2.h[0]), this.options)), s2);
1766
- if (this._$AH?._$AD === e6)
1767
- this._$AH.p(i4);
1768
- else {
1769
- const t4 = new F(e6, this), s3 = t4.u(this.options);
1770
- t4.p(i4), this.T(s3), this._$AH = t4;
1771
- }
1772
- }
1773
- _$AC(t3) {
1774
- let i4 = V.get(t3.strings);
1775
- return void 0 === i4 && V.set(t3.strings, i4 = new B(t3)), i4;
1776
- }
1777
- k(t3) {
1778
- g(this._$AH) || (this._$AH = [], this._$AR());
1779
- const i4 = this._$AH;
1780
- let s2, e6 = 0;
1781
- for (const h4 of t3)
1782
- e6 === i4.length ? i4.push(s2 = new _et(this.O(lt()), this.O(lt()), this, this.options)) : s2 = i4[e6], s2._$AI(h4), e6++;
1783
- e6 < i4.length && (this._$AR(s2 && s2._$AB.nextSibling, e6), i4.length = e6);
1784
- }
1785
- _$AR(t3 = this._$AA.nextSibling, i4) {
1786
- for (this._$AP?.(false, true, i4); t3 && t3 !== this._$AB; ) {
1787
- const i5 = t3.nextSibling;
1788
- t3.remove(), t3 = i5;
1789
- }
1790
- }
1791
- setConnected(t3) {
1792
- void 0 === this._$AM && (this.v = t3, this._$AP?.(t3));
1793
- }
1794
- };
1795
- var G = class {
1796
- get tagName() {
1797
- return this.element.tagName;
1798
- }
1799
- get _$AU() {
1800
- return this._$AM._$AU;
1801
- }
1802
- constructor(t3, i4, s2, e6, h4) {
1803
- this.type = 1, this._$AH = D, this._$AN = void 0, this.element = t3, this.name = i4, this._$AM = e6, this.options = h4, s2.length > 2 || "" !== s2[0] || "" !== s2[1] ? (this._$AH = Array(s2.length - 1).fill(new String()), this.strings = s2) : this._$AH = D;
1804
- }
1805
- _$AI(t3, i4 = this, s2, e6) {
1806
- const h4 = this.strings;
1807
- let o4 = false;
1808
- if (void 0 === h4)
1809
- t3 = z(this, t3, i4, 0), o4 = !st(t3) || t3 !== this._$AH && t3 !== R, o4 && (this._$AH = t3);
1810
- else {
1811
- const e7 = t3;
1812
- let n5, r5;
1813
- for (t3 = h4[0], n5 = 0; n5 < h4.length - 1; n5++)
1814
- r5 = z(this, e7[s2 + n5], i4, n5), r5 === R && (r5 = this._$AH[n5]), o4 ||= !st(r5) || r5 !== this._$AH[n5], r5 === D ? t3 = D : t3 !== D && (t3 += (r5 ?? "") + h4[n5 + 1]), this._$AH[n5] = r5;
1815
- }
1816
- o4 && !e6 && this.j(t3);
1817
- }
1818
- j(t3) {
1819
- t3 === D ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t3 ?? "");
1820
- }
1821
- };
1822
- var Y = class extends G {
1823
- constructor() {
1824
- super(...arguments), this.type = 3;
1825
- }
1826
- j(t3) {
1827
- this.element[this.name] = t3 === D ? void 0 : t3;
1828
- }
1829
- };
1830
- var Z = class extends G {
1831
- constructor() {
1832
- super(...arguments), this.type = 4;
1833
- }
1834
- j(t3) {
1835
- this.element.toggleAttribute(this.name, !!t3 && t3 !== D);
1836
- }
1837
- };
1838
- var q = class extends G {
1839
- constructor(t3, i4, s2, e6, h4) {
1840
- super(t3, i4, s2, e6, h4), this.type = 5;
1841
- }
1842
- _$AI(t3, i4 = this) {
1843
- if ((t3 = z(this, t3, i4, 0) ?? D) === R)
1844
- return;
1845
- const s2 = this._$AH, e6 = t3 === D && s2 !== D || t3.capture !== s2.capture || t3.once !== s2.once || t3.passive !== s2.passive, h4 = t3 !== D && (s2 === D || e6);
1846
- e6 && this.element.removeEventListener(this.name, this, s2), h4 && this.element.addEventListener(this.name, this, t3), this._$AH = t3;
1847
- }
1848
- handleEvent(t3) {
1849
- "function" == typeof this._$AH ? this._$AH.call(this.options?.host ?? this.element, t3) : this._$AH.handleEvent(t3);
1850
- }
1851
- };
1852
- var K = class {
1853
- constructor(t3, i4, s2) {
1854
- this.element = t3, this.type = 6, this._$AN = void 0, this._$AM = i4, this.options = s2;
1855
- }
1856
- get _$AU() {
1857
- return this._$AM._$AU;
1858
- }
1859
- _$AI(t3) {
1860
- z(this, t3);
1861
- }
1862
- };
1863
- var Re = n3.litHtmlPolyfillSupport;
1864
- Re?.(B, et), (n3.litHtmlVersions ??= []).push("3.2.0");
1865
- var Q = (t3, i4, s2) => {
1866
- const e6 = s2?.renderBefore ?? i4;
1867
- let h4 = e6._$litPart$;
1868
- if (void 0 === h4) {
1869
- const t4 = s2?.renderBefore ?? null;
1870
- e6._$litPart$ = h4 = new et(i4.insertBefore(lt(), t4), t4, void 0, s2 ?? {});
1871
- }
1872
- return h4._$AI(t3), h4;
1873
- };
1874
-
1875
- // node_modules/lit-element/lit-element.js
1876
- var h3 = class extends b {
1877
- constructor() {
1878
- super(...arguments), this.renderOptions = { host: this }, this.o = void 0;
1879
- }
1880
- createRenderRoot() {
1881
- const t3 = super.createRenderRoot();
1882
- return this.renderOptions.renderBefore ??= t3.firstChild, t3;
1883
- }
1884
- update(t3) {
1885
- const e6 = this.render();
1886
- this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t3), this.o = Q(e6, this.renderRoot, this.renderOptions);
1887
- }
1888
- connectedCallback() {
1889
- super.connectedCallback(), this.o?.setConnected(true);
1890
- }
1891
- disconnectedCallback() {
1892
- super.disconnectedCallback(), this.o?.setConnected(false);
1893
- }
1894
- render() {
1895
- return R;
1896
- }
1897
- };
1898
- h3._$litElement$ = true, h3["finalized"] = true, globalThis.litElementHydrateSupport?.({ LitElement: h3 });
1899
- var f3 = globalThis.litElementPolyfillSupport;
1900
- f3?.({ LitElement: h3 });
1901
- (globalThis.litElementVersions ??= []).push("4.1.0");
1902
-
1903
- // node_modules/@lit/reactive-element/decorators/property.js
1904
- var o3 = { attribute: true, type: String, converter: u, reflect: false, hasChanged: f };
1905
- var r3 = (t3 = o3, e6, r5) => {
1906
- const { kind: n5, metadata: i4 } = r5;
1907
- let s2 = globalThis.litPropertyMetadata.get(i4);
1908
- if (void 0 === s2 && globalThis.litPropertyMetadata.set(i4, s2 = /* @__PURE__ */ new Map()), s2.set(r5.name, t3), "accessor" === n5) {
1909
- const { name: o4 } = r5;
1910
- return { set(r6) {
1911
- const n6 = e6.get.call(this);
1912
- e6.set.call(this, r6), this.requestUpdate(o4, n6, t3);
1913
- }, init(e7) {
1914
- return void 0 !== e7 && this.P(o4, void 0, t3), e7;
1915
- } };
1916
- }
1917
- if ("setter" === n5) {
1918
- const { name: o4 } = r5;
1919
- return function(r6) {
1920
- const n6 = this[o4];
1921
- e6.call(this, r6), this.requestUpdate(o4, n6, t3);
1922
- };
1923
- }
1924
- throw Error("Unsupported decorator location: " + n5);
1925
- };
1926
- function n4(t3) {
1927
- return (e6, o4) => "object" == typeof o4 ? r3(t3, e6, o4) : ((t4, e7, o5) => {
1928
- const r5 = e7.hasOwnProperty(o5);
1929
- return e7.constructor.createProperty(o5, r5 ? { ...t4, wrapped: true } : t4), r5 ? Object.getOwnPropertyDescriptor(e7, o5) : void 0;
1930
- })(t3, e6, o4);
1931
- }
1932
-
1933
- // node_modules/@lit/reactive-element/decorators/state.js
1934
- function r4(r5) {
1935
- return n4({ ...r5, state: true, attribute: false });
1936
- }
1937
-
1938
- // node_modules/@lit/reactive-element/decorators/base.js
1939
- var e3 = (e6, t3, c4) => (c4.configurable = true, c4.enumerable = true, Reflect.decorate && "object" != typeof t3 && Object.defineProperty(e6, t3, c4), c4);
1940
-
1941
- // node_modules/@lit/reactive-element/decorators/query.js
1942
- function e4(e6, r5) {
1943
- return (n5, s2, i4) => {
1944
- const o4 = (t3) => t3.renderRoot?.querySelector(e6) ?? null;
1945
- if (r5) {
1946
- const { get: e7, set: r6 } = "object" == typeof s2 ? n5 : i4 ?? (() => {
1947
- const t3 = Symbol();
1948
- return { get() {
1949
- return this[t3];
1950
- }, set(e8) {
1951
- this[t3] = e8;
1952
- } };
1953
- })();
1954
- return e3(n5, s2, { get() {
1955
- let t3 = e7.call(this);
1956
- return void 0 === t3 && (t3 = o4(this), (null !== t3 || this.hasUpdated) && r6.call(this, t3)), t3;
1957
- } });
1958
- }
1959
- return e3(n5, s2, { get() {
1960
- return o4(this);
1961
- } });
1962
- };
1963
- }
1964
-
1965
- // node_modules/lit-html/directive.js
1966
- var t2 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 };
1967
- var e5 = (t3) => (...e6) => ({ _$litDirective$: t3, values: e6 });
1968
- var i3 = class {
1969
- constructor(t3) {
1970
- }
1971
- get _$AU() {
1972
- return this._$AM._$AU;
1973
- }
1974
- _$AT(t3, e6, i4) {
1975
- this.t = t3, this._$AM = e6, this.i = i4;
1976
- }
1977
- _$AS(t3, e6) {
1978
- return this.update(t3, e6);
1979
- }
1980
- update(t3, e6) {
1981
- return this.render(...e6);
1982
- }
1983
- };
1984
-
1985
- // node_modules/lit-html/directives/style-map.js
1986
- var ee = "important";
1987
- var ie = " !" + ee;
1988
- var se = e5(class extends i3 {
1989
- constructor(e6) {
1990
- if (super(e6), e6.type !== t2.ATTRIBUTE || "style" !== e6.name || e6.strings?.length > 2)
1991
- throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
1992
- }
1993
- render(t3) {
1994
- return Object.keys(t3).reduce((e6, r5) => {
1995
- const s2 = t3[r5];
1996
- return null == s2 ? e6 : e6 + `${r5 = r5.includes("-") ? r5 : r5.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${s2};`;
1997
- }, "");
1998
- }
1999
- update(t3, [e6]) {
2000
- const { style: r5 } = t3.element;
2001
- if (void 0 === this.ft)
2002
- return this.ft = new Set(Object.keys(e6)), this.render(e6);
2003
- for (const t4 of this.ft)
2004
- null == e6[t4] && (this.ft.delete(t4), t4.includes("-") ? r5.removeProperty(t4) : r5[t4] = null);
2005
- for (const t4 in e6) {
2006
- const s2 = e6[t4];
2007
- if (null != s2) {
2008
- this.ft.add(t4);
2009
- const e7 = "string" == typeof s2 && s2.endsWith(ie);
2010
- t4.includes("-") || e7 ? r5.setProperty(t4, e7 ? s2.slice(0, -11) : s2, e7 ? ee : "") : r5[t4] = s2;
2011
- }
2012
- }
2013
- return R;
2014
- }
2015
- });
2016
-
2017
- // libs/embed-libs/embed/package.json
2018
- var version = "6.2.1-beta.0";
2019
-
2020
- // libs/embed-libs/embed/src/lib/luzmo-service.ts
2021
- var LuzmoService = class {
2022
- constructor() {
2023
- this._components = [];
2024
- }
2025
- };
2026
- var luzmo_service_default = new LuzmoService();
2027
-
2028
- // libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
2029
- var _setEventHandler = () => {
2030
- if (typeof window.__luzmoMessageHandler === "function") {
2031
- return;
2032
- }
2033
- window.__luzmoMessageHandler = (event) => {
2034
- const dashboardComponent = luzmo_service_default._components.find(
2035
- (c4) => event.data.name === c4._iframeId
2036
- );
2037
- if (!dashboardComponent) {
2038
- return;
2039
- }
2040
- switch (event.data?.type) {
2041
- case "load": {
2042
- dashboardComponent.dispatchEvent(
2043
- new CustomEvent("load", { detail: { data: event.data } })
2044
- );
2045
- if (dashboardComponent._loadTimeoutHandle) {
2046
- clearTimeout(dashboardComponent._loadTimeoutHandle);
2047
- dashboardComponent._loadTimeoutHandle = void 0;
2048
- }
2049
- dashboardComponent.iframeLoaded = true;
2050
- dashboardComponent.dimensions = event.data.dimensions;
2051
- dashboardComponent._calculateDimAfterDashboardLoaded();
2052
- break;
2053
- }
2054
- case "error": {
2055
- dashboardComponent.dashboardError = true;
2056
- if (dashboardComponent._loadTimeoutHandle) {
2057
- clearTimeout(dashboardComponent._loadTimeoutHandle);
2058
- dashboardComponent._loadTimeoutHandle = void 0;
2059
- }
2060
- dashboardComponent.iframeLoaded = true;
2061
- dashboardComponent._displayError();
2062
- console.error("Dashboard error: ", event.data.errorMsg ?? event.data.error?.msg);
2063
- break;
2064
- }
2065
- case "data": {
2066
- resolvePromise(
2067
- dashboardComponent,
2068
- event.data.requestId,
2069
- event.data.data
2070
- );
2071
- break;
2072
- }
2073
- case "filters": {
2074
- resolvePromise(
2075
- dashboardComponent,
2076
- event.data.requestId,
2077
- event.data.filters
2078
- );
2079
- break;
2080
- }
2081
- case "getAccessibleDashboards": {
2082
- resolvePromise(
2083
- dashboardComponent,
2084
- event.data.requestId,
2085
- event.data.accessibleDashboards
2086
- );
2087
- break;
2088
- }
2089
- case "dashboardAction": {
2090
- dashboardComponent.dispatchEvent(
2091
- new CustomEvent("dashboardAction", { detail: { data: event.data } })
2092
- );
2093
- break;
2094
- }
2095
- case "export": {
2096
- if (event.data.error) {
2097
- rejectPromise(
2098
- dashboardComponent,
2099
- event.data.requestId,
2100
- event.data
2101
- );
2102
- } else {
2103
- dashboardComponent.dispatchEvent(
2104
- new CustomEvent("exported", { detail: { data: event.data } })
2105
- );
2106
- resolvePromise(
2107
- dashboardComponent,
2108
- event.data.requestId,
2109
- event.data
2110
- );
2111
- }
2112
- break;
2113
- }
2114
- case "changedFilters": {
2115
- dashboardComponent.dispatchEvent(
2116
- new CustomEvent("changedFilters", { detail: { data: event.data } })
2117
- );
2118
- break;
2119
- }
2120
- case "customEvent": {
2121
- dashboardComponent.dispatchEvent(
2122
- new CustomEvent("customEvent", { detail: { data: event.data } })
2123
- );
2124
- break;
2125
- }
2126
- case "chartsRendered":
2127
- case "itemsRendered": {
2128
- event.data.type = "itemsRendered";
2129
- dashboardComponent.dispatchEvent(
2130
- new CustomEvent("itemsRendered", { detail: { data: event.data } })
2131
- );
2132
- break;
2133
- }
2134
- case "setEditMode": {
2135
- if (event.data.error) {
2136
- rejectPromise(
2137
- dashboardComponent,
2138
- event.data.requestId,
2139
- event.data
2140
- );
2141
- } else {
2142
- resolvePromise(
2143
- dashboardComponent,
2144
- event.data.requestId,
2145
- event.data
2146
- );
2147
- dashboardComponent.params.editMode = event.data.editMode;
2148
- dashboardComponent._containerStyle = containerStyles(dashboardComponent);
2149
- if (dashboardComponent.dimensions) {
2150
- _setCalculatedDimensions(dashboardComponent);
2151
- }
2152
- }
2153
- break;
2154
- }
2155
- case "setSelectedData":
2156
- case "setFilters": {
2157
- event.data.error ? rejectPromise(
2158
- dashboardComponent,
2159
- event.data.requestId,
2160
- event.data
2161
- ) : resolvePromise(
2162
- dashboardComponent,
2163
- event.data.requestId,
2164
- event.data
2165
- );
2166
- break;
2167
- }
2168
- case "setPreview": {
2169
- event.data.error ? rejectPromise(
2170
- dashboardComponent,
2171
- event.data.requestId,
2172
- event.data
2173
- ) : resolvePromise(
2174
- dashboardComponent,
2175
- event.data.requestId,
2176
- event.data
2177
- );
2178
- break;
2179
- }
2180
- }
2181
- };
2182
- window.addEventListener("message", window.__luzmoMessageHandler, false);
2183
- };
2184
-
2185
- // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-styles.ts
2186
- var dashboardStyles = i`
2187
- :host {
2188
- display: block;
2189
- height: 100%;
2190
- }
2191
-
2192
- @-webkit-keyframes spin {
2193
- 0% {
2194
- -webkit-transform: rotate(0deg);
2195
- transform: rotate(0deg);
2196
- }
2197
- 100% {
2198
- -webkit-transform: rotate(360deg);
2199
- transform: rotate(360deg);
2200
- }
2201
- }
2202
-
2203
- @keyframes spin {
2204
- 0% {
2205
- -webkit-transform: rotate(0deg);
2206
- transform: rotate(0deg);
2207
- }
2208
- 100% {
2209
- -webkit-transform: rotate(360deg);
2210
- transform: rotate(360deg);
2211
- }
2212
- }
2213
- :host {
2214
- position: relative;
2215
- width: 100%;
2216
- }
2217
-
2218
- .luzmo-embed-dashboard {
2219
- background: transparent;
2220
- padding: 0;
2221
- border: 0;
2222
- }
2223
-
2224
- .luzmo-embed-dashboard-ede {
2225
- }
2226
-
2227
- .luzmo-embed-container-ede {
2228
- width: 100%;
2229
- height: 100%;
2230
- }
2231
-
2232
- .luzmo-container-loader {
2233
- width: 100%;
2234
- position: relative;
2235
- }
2236
-
2237
- .luzmo-lc {
2238
- margin: 0 auto;
2239
- }
2240
-
2241
- .luzmo-loading-message {
2242
- width: 100%;
2243
- height: 20px;
2244
- text-align: center;
2245
- margin-bottom: 16px;
2246
- font-family: Helvetica, Arial, sans-serif;
2247
- font-size: 14px;
2248
- }
2249
-
2250
- .luzmo-loading-circle {
2251
- box-sizing: border-box;
2252
- margin: 16px auto;
2253
- position: relative;
2254
- text-indent: -9999em;
2255
- animation: spin 0.6s infinite linear;
2256
- }
2257
-
2258
- .luzmo-loading-circle,
2259
- .luzmo-loading-circle:after {
2260
- border-radius: 50%;
2261
- width: 32px;
2262
- height: 32px;
2263
- }
2264
-
2265
- .itemEmbedding:after {
2266
- width: 24px;
2267
- height: 24px;
2268
- }
2269
-
2270
- .luzmo-error {
2271
- background: transparent;
2272
- padding: 48px 0;
2273
- margin: 0 auto;
2274
- width: 80%;
2275
- border: 0;
2276
- text-align: center;
2277
- min-height: 192px;
2278
- }
2279
-
2280
- .dashboard-error {
2281
- font-size: 30px;
2282
- background: transparent;
2283
- padding: 48px 0;
2284
- margin: 0 auto;
2285
- width: 80%;
2286
- border: 0;
2287
- text-align: center;
2288
- min-height: 192px;
2289
- }
2290
-
2291
- .luzmo-loader {
2292
- top: 0;
2293
- left: 0;
2294
- width: 100%;
2295
- min-height: 400px;
2296
- position: absolute;
2297
- transition-duration: 0.3s;
2298
- }
2299
- `;
2300
-
2301
- // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
2302
- var LuzmoDashboard = class extends h3 {
2303
- constructor() {
2304
- super();
2305
- this.language = "auto";
2306
- this.screenMode = "auto";
2307
- this.switchScreenModeOnResize = true;
2308
- this.editMode = "view";
2309
- this.experimental = false;
2310
- this.iframeStyle = {};
2311
- this._containerStyle = {};
2312
- this._loaderStyle = {};
2313
- this._lcStyle = {};
2314
- this._loadingCircleStyle = {};
2315
- this._containerLoaderStyle = {};
2316
- this._loaderMsg = "";
2317
- this._itemEmbedding = false;
2318
- this.browserError = false;
2319
- this.browserErrorMsg = "";
2320
- this.dashboardError = false;
2321
- this.browserNotSupported = [];
2322
- this.libVersion = version + "-wc-luzmo";
2323
- this.isLibraryLoaded = false;
2324
- this.currentAuthKey = null;
2325
- this.currentAuthToken = null;
2326
- this.isInitCalled = false;
2327
- this.attributesMap = {
2328
- dashboardId: "dashboard-id",
2329
- dashboardSlug: "dashboard-slug",
2330
- itemId: "item-id",
2331
- language: "language",
2332
- qeVersion: "qe-version",
2333
- screenMode: "screen-mode",
2334
- switchScreenModeOnResize: "switch-screen-mode-on-resize",
2335
- authKey: "auth-key",
2336
- authToken: "auth-token",
2337
- editMode: "edit-mode",
2338
- mainColor: "main-color",
2339
- accentColor: "accent-color",
2340
- loaderBackground: "loader-background",
2341
- loaderFontColor: "loader-font-color",
2342
- loaderSpinnerColor: "loader-spinner-color",
2343
- loaderSpinnerBackground: "loader-spinner-background",
2344
- appServer: "app-server",
2345
- apiHost: "api-host",
2346
- itemDimensions: "item-dimensions",
2347
- timezoneId: "timezone-id"
2348
- };
2349
- this.loaderSize = 32;
2350
- this.borderWidth = 3;
2351
- this.minHeight = 400;
2352
- this._containerId = uuidv4();
2353
- this._iframeId = `luzmo-dashboard-${this._containerId}`;
2354
- this.iframeLoaded = false;
2355
- this.promises = {};
2356
- this.params = this._setOptions();
2357
- this._onResize = () => {
2358
- if (this.shadowRoot?.querySelector(".dashboard-container")) {
2359
- this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
2360
- if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
2361
- for (const d2 of EXTENTS) {
2362
- if (d2.width[0] <= window.innerWidth && window.innerWidth <= d2.width[1]) {
2363
- this.currentScreenMode = d2.mode;
2364
- }
2365
- }
2366
- }
2367
- if (this.iframeLoaded) {
2368
- this._calculateDimAfterDashboardLoaded();
2369
- } else {
2370
- if (this.dimensions) {
2371
- this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
2372
- _setCalculatedDimensions(this);
2373
- }
2374
- }
2375
- }
2376
- };
2377
- this._resizeObserver = new ResizeObserver((entries) => {
2378
- window.requestAnimationFrame(() => {
2379
- if (!Array.isArray(entries) || entries.length === 0) {
2380
- return;
2381
- }
2382
- this._onResize();
2383
- });
2384
- });
2385
- }
2386
- // Set resize event listener
2387
- connectedCallback() {
2388
- super.connectedCallback();
2389
- }
2390
- // Set resize event listener
2391
- disconnectedCallback() {
2392
- super.disconnectedCallback();
2393
- this._resizeObserver.disconnect();
2394
- for (const promiseKey of Object.keys(this.promises)) {
2395
- this.promises[promiseKey].reject(
2396
- new Error("Dashboard component was removed")
2397
- );
2398
- }
2399
- }
2400
- firstUpdated() {
2401
- this._loaderMsg = getLoader(this)?.loadingMsg;
2402
- this._loaderStyles();
2403
- luzmo_service_default._components.push(this);
2404
- if (this.luzmoEmbedContainer) {
2405
- this._resizeObserver.observe(this.luzmoEmbedContainer);
2406
- }
2407
- }
2408
- initComponent() {
2409
- this.params = this._setOptions();
2410
- if (this.getIsViewMode()) {
2411
- loadLibrary(this.params.appServer).then(async () => {
2412
- this.isLibraryLoaded = true;
2413
- await this.updateComplete;
2414
- const oldReference = this.renderRoot.querySelector("dashboard-component");
2415
- this.dashboardReference = oldReference.cloneNode(true);
2416
- oldReference.replaceWith(this.dashboardReference);
2417
- this.dashboardReference.addEventListener("load", (payload) => {
2418
- this.containerWidth = this.dashboardReference.offsetWidth;
2419
- this.dimensions = payload.detail.dimensions;
2420
- _setCalculatedDimensions(this);
2421
- window.dispatchEvent(new Event("resize"));
2422
- this.dispatchEvent(new CustomEvent("load", payload));
2423
- });
2424
- this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
2425
- this.dashboardReference.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
2426
- this.dashboardReference.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
2427
- this.dashboardReference.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
2428
- this.dashboardReference.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
2429
- this.setAllAttributes();
2430
- });
2431
- } else {
2432
- this.containerWidth = this.container?.clientWidth;
2433
- _extendAndValidate(this);
2434
- _browserCheck(this);
2435
- this._setupLoader();
2436
- if (!this.params.error) {
2437
- this._loaderStyles();
2438
- _setEventHandler();
2439
- this._iframeUrl = createIframeUrl(this);
2440
- this.iframe?.setAttribute("src", this._iframeUrl);
2441
- this.iframeStyle = calculateIframeStyles(this);
2442
- }
2443
- }
2444
- }
2445
- setAllAttributes() {
2446
- if (this.dashboardReference) {
2447
- for (const key in this.attributesMap) {
2448
- if (!["authKey", "authToken", "apiHost", "itemDimensions"].includes(key) && this.params[key]) {
2449
- this.dashboardReference.setAttribute(this.attributesMap[key], this.params[key]);
2450
- }
2451
- }
2452
- if (this.params.itemDimensions) {
2453
- this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
2454
- }
2455
- if (this.params.apiHost) {
2456
- this.dashboardReference.setAttribute("api-host", removeTrailingSlash(this.params.apiHost));
2457
- }
2458
- if (this.params.key) {
2459
- this.dashboardReference.setAttribute("auth-key", this.params.key);
2460
- }
2461
- if (this.params.token) {
2462
- this.dashboardReference.setAttribute("auth-token", this.params.token);
2463
- }
2464
- }
2465
- }
2466
- // Reload dashboard when triggerproperty changes
2467
- updated(changedProperties) {
2468
- const triggerProperties = /* @__PURE__ */ new Set([
2469
- "dashboardId",
2470
- "dashboardSlug",
2471
- "itemId",
2472
- "language",
2473
- "qeVersion",
2474
- "editMode",
2475
- "screenMode",
2476
- "switchScreenModeOnResize",
2477
- "authToken",
2478
- "authKey",
2479
- "appServer",
2480
- "apiHost",
2481
- "timezoneId",
2482
- "itemDimensions"
2483
- ]);
2484
- const conditionsToCheck = ["dashboardId", "dashboardSlug", "itemId"];
2485
- let callInitComponent = false;
2486
- for (const condition of conditionsToCheck) {
2487
- callInitComponent = callInitComponent || changedProperties.get(condition) === void 0 && this[condition] !== void 0;
2488
- }
2489
- if (callInitComponent && !this.isInitCalled) {
2490
- this.initComponent();
2491
- this.isInitCalled = true;
2492
- return;
2493
- }
2494
- if (this.getIsViewMode()) {
2495
- if (this.dashboardReference) {
2496
- for (const [propertyName] of changedProperties.entries()) {
2497
- if (propertyName === "appSever") {
2498
- loadLibrary(changedProperties[propertyName]).then(async () => {
2499
- this.isLibraryLoaded = true;
2500
- await this.updateComplete;
2501
- this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
2502
- this.setAllAttributes();
2503
- });
2504
- } else if (this.attributesMap[propertyName]) {
2505
- const mappedAttributeName = this.attributesMap[propertyName] ?? propertyName;
2506
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() || this[propertyName];
2507
- this.dashboardReference.setAttribute(mappedAttributeName, attributeValue);
2508
- }
2509
- }
2510
- }
2511
- } else {
2512
- for (const [propertyName] of changedProperties.entries()) {
2513
- if (triggerProperties.has(propertyName) && propertyName !== "editMode") {
2514
- this.iframeLoaded = false;
2515
- if (this._loadTimeoutHandle) {
2516
- clearTimeout(this._loadTimeoutHandle);
2517
- }
2518
- this._loadTimeoutHandle = setTimeout(() => {
2519
- console.warn(
2520
- "Failed to load dashboard, appServer is likely down or unreachable."
2521
- );
2522
- }, 15 * 1e3);
2523
- this.params = this._setOptions();
2524
- _extendAndValidate(this);
2525
- this._setupLoader();
2526
- this._loaderStyles();
2527
- this._iframeUrl = createIframeUrl(this);
2528
- if (this.iframe) {
2529
- this._updateIframeUrl();
2530
- }
2531
- this.iframeStyle = calculateIframeStyles(this);
2532
- } else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
2533
- if (this.iframeLoaded) {
2534
- this.setEditMode(this.editMode);
2535
- }
2536
- this.params = this._setOptions();
2537
- }
2538
- }
2539
- }
2540
- }
2541
- // Set params
2542
- _setOptions() {
2543
- const defaultParameters = {
2544
- dashboardId: this.dashboardId,
2545
- dashboardSlug: this.dashboardSlug
2546
- };
2547
- if (this.itemId) {
2548
- defaultParameters.itemId = this.itemId;
2549
- this._itemEmbedding = true;
2550
- } else {
2551
- this._itemEmbedding = false;
2552
- }
2553
- if (this.language) {
2554
- defaultParameters.language = this.language;
2555
- }
2556
- if (this.qeVersion) {
2557
- defaultParameters.qeVersion = this.qeVersion;
2558
- }
2559
- if (this.screenMode) {
2560
- defaultParameters.screenMode = this.screenMode;
2561
- }
2562
- defaultParameters.switchScreenModeOnResize = this.switchScreenModeOnResize;
2563
- if (this.authToken) {
2564
- defaultParameters.token = this.authToken;
2565
- }
2566
- if (this.authKey) {
2567
- defaultParameters.key = this.authKey;
2568
- }
2569
- if (this.editMode) {
2570
- defaultParameters.editMode = this.editMode;
2571
- }
2572
- if (this.mainColor) {
2573
- defaultParameters.mainColor = this.mainColor;
2574
- }
2575
- if (this.accentColor) {
2576
- defaultParameters.accentColor = this.accentColor;
2577
- }
2578
- if (this.loaderBackground) {
2579
- defaultParameters.loaderBackground = this.loaderBackground;
2580
- }
2581
- if (this.loaderFontColor) {
2582
- defaultParameters.loaderFontColor = this.loaderFontColor;
2583
- }
2584
- if (this.loaderSpinnerColor) {
2585
- defaultParameters.loaderSpinnerColor = this.loaderSpinnerColor;
2586
- }
2587
- if (this.loaderSpinnerBackground) {
2588
- defaultParameters.loaderSpinnerBackground = this.loaderSpinnerBackground;
2589
- }
2590
- if (this.timezoneId) {
2591
- defaultParameters.timezoneId = this.timezoneId;
2592
- }
2593
- if (this.itemDimensions) {
2594
- defaultParameters.itemDimensions = this.itemDimensions;
2595
- }
2596
- if (this.appServer) {
2597
- this.appServer = this.getIsViewMode() ? removeTrailingSlash(this.appServer) : addTrailingSlash(this.appServer);
2598
- defaultParameters.appServer = this.appServer;
2599
- } else {
2600
- this.appServer = addTrailingSlash(
2601
- DEFAULT_PARAMETERS.appServer
2602
- );
2603
- defaultParameters.appServer = this.appServer;
2604
- }
2605
- if (this.apiHost) {
2606
- this.apiHost = this.getIsViewMode() ? removeTrailingSlash(this.apiHost) : addTrailingSlash(this.apiHost);
2607
- defaultParameters.apiHost = this.apiHost;
2608
- } else {
2609
- this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
2610
- defaultParameters.apiHost = this.apiHost;
2611
- }
2612
- this.currentAuthKey = this.authKey;
2613
- this.currentAuthToken = this.authToken;
2614
- return defaultParameters;
2615
- }
2616
- _updateIframeUrl() {
2617
- updateIframeUrl(this.iframe, this._iframeUrl);
2618
- }
2619
- // Setup loader / browser error
2620
- _setupLoader() {
2621
- const data = getLoader(this);
2622
- this._loaderMsg = data.loadingMsg;
2623
- if (data.errorMsg) {
2624
- this.browserError = true;
2625
- this.browserErrorMsg = data.errorMsg;
2626
- this._displayError();
2627
- }
2628
- }
2629
- _displayError() {
2630
- if (this.dashboardError) {
2631
- this._loaderStyles();
2632
- this.iframeStyle.opacity = 1;
2633
- }
2634
- if (this.browserError) {
2635
- this._containerStyle.display = "none";
2636
- }
2637
- }
2638
- _calculateDimAfterDashboardLoaded() {
2639
- this.dashboardError = false;
2640
- this._loaderStyles();
2641
- _setCalculatedDimensions(this);
2642
- }
2643
- // Set loader styles
2644
- _loaderStyles() {
2645
- this._containerStyle = containerStyles(this);
2646
- this._loaderStyle = loaderStyles(this);
2647
- this._loadingCircleStyle = plStyles(this);
2648
- this._containerLoaderStyle = containerLoaderStyles(this);
2649
- this._lcStyle = lcStyles(this);
2650
- }
2651
- static get styles() {
2652
- return [dashboardStyles];
2653
- }
2654
- render() {
2655
- let toBeRenderedHTML;
2656
- const loader = ke`
2657
- <div
2658
- class="luzmo-container-loader"
2659
- id="luzmo-container-loader-${this._containerId}"
2660
- style=${se(
2661
- this._containerLoaderStyle
2662
- )}
2663
- >
2664
- <div
2665
- class="luzmo-loader"
2666
- id="luzmo-loader-${this._containerId}"
2667
- style=${se(this._loaderStyle)}
2668
- >
2669
- <div
2670
- class="luzmo-lc"
2671
- style=${se(this._lcStyle)}
2672
- >
2673
- <div
2674
- class="luzmo-loading-circle"
2675
- style=${se(
2676
- this._loadingCircleStyle
2677
- )}
2678
- ></div>
2679
- ${this._itemEmbedding ? "" : ke`
2680
- <div
2681
- class="luzmo-loading-message"
2682
- style=${se({ color: this.loaderFontColor })}
2683
- >
2684
- ${this._loaderMsg}
2685
- </div>
2686
- `}
2687
- </div>
2688
- </div>
2689
- </div>
2690
- `;
2691
- if (this.getIsViewMode()) {
2692
- toBeRenderedHTML = this.isLibraryLoaded ? ke`
2693
- ${this.dashboardId || this.dashboardSlug ? ke`
2694
- <dashboard-component dashboard-id="${this.params.dashboardId}" app-server="${this.params.appServer}"
2695
- api-host="${this.params.apiHost}"></dashboard-component>` : ke`
2696
- <div id="luzmo-error-${this._containerId}">
2697
- <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
2698
- </div>
2699
- `}
2700
- ` : ke`${loader}`;
2701
- } else {
2702
- toBeRenderedHTML = ke`
2703
- ${this.dashboardId || this.dashboardSlug ? ke`
2704
- ${loader}
2705
- <iframe
2706
- class="luzmo-embed-dashboard ${!this.getIsViewMode() ? `luzmo-embed-dashboard-ede` : ""}"
2707
- id="${this._iframeId}"
2708
- name="${this._iframeId}"
2709
- style=${se(this.iframeStyle)}
2710
- src="${this._iframeUrl}"
2711
- frameborder="0"
2712
- ></iframe>
2713
- ` : ke`<!-- the dashboard will inititialize when you provide a dashboardSlug or a dashboardId -->`}
2714
- ${this.browserError ? ke`
2715
- <div id="luzmo-error-${this._containerId}">
2716
- <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
2717
- </div>
2718
- ` : ""}
2719
- `;
2720
- }
2721
- return ke`
2722
- <div class="${luzmoEmbedContainerClass} ${!this.getIsViewMode() ? `${luzmoEmbedContainerClass}-ede` : ""}">
2723
- <div
2724
- class="dashboard-container"
2725
- style=${se(Object.assign({}, this._containerStyle, {
2726
- width: this.iframeStyle.width ?? "100%",
2727
- height: this.iframeStyle.height ?? "100%"
2728
- }))}
2729
- >
2730
- ${toBeRenderedHTML}
2731
- </div>
2732
- </div>
2733
-
2734
- `;
2735
- }
2736
- getDashboards() {
2737
- return new Promise(
2738
- (resolve) => resolve(luzmo_service_default._components)
2739
- );
2740
- }
2741
- // Public methods
2742
- getData(itemId) {
2743
- if (this.getIsViewMode() && this.dashboardReference) {
2744
- return this.dashboardReference.getData(itemId);
2745
- }
2746
- if (!this.getIsViewMode()) {
2747
- return getData(this, this.iframe, itemId);
2748
- }
2749
- return Promise.reject();
2750
- }
2751
- getFilters() {
2752
- if (this.getIsViewMode() && this.dashboardReference) {
2753
- return this.dashboardReference.getFilters();
2754
- }
2755
- if (!this.getIsViewMode()) {
2756
- return getFilters(this, this.iframe);
2757
- }
2758
- return Promise.reject();
2759
- }
2760
- setSelectedData(itemId, filters) {
2761
- if (this.getIsViewMode() && this.dashboardReference) {
2762
- return this.dashboardReference.setSelectedData(itemId, filters);
2763
- }
2764
- if (!this.getIsViewMode()) {
2765
- return setSelectedData(this, this.iframe, itemId, filters);
2766
- }
2767
- return Promise.reject();
2768
- }
2769
- setAuthorization(key, token) {
2770
- this.currentAuthKey = key;
2771
- this.currentAuthToken = token;
2772
- if (this.getIsViewMode() && this.dashboardReference) {
2773
- return this.dashboardReference.setAuthorization(key, token);
2774
- }
2775
- if (!this.getIsViewMode()) {
2776
- return setAuthorization(this, this.iframe, key, token);
2777
- }
2778
- return Promise.reject();
2779
- }
2780
- refreshData(itemId) {
2781
- if (this.getIsViewMode() && this.dashboardReference) {
2782
- return this.dashboardReference.refreshData(itemId);
2783
- }
2784
- if (!this.getIsViewMode()) {
2785
- return itemId ? refreshData(this, this.iframe, itemId) : refreshData(this, this.iframe);
2786
- }
2787
- return Promise.reject();
2788
- }
2789
- reloadDashboard() {
2790
- if (this.getIsViewMode() && this.dashboardReference) {
2791
- return this.dashboardReference.reloadDashboard();
2792
- }
2793
- if (!this.getIsViewMode()) {
2794
- return reloadDashboard(this, this.iframe);
2795
- }
2796
- return Promise.reject();
2797
- }
2798
- exportDashboard(format) {
2799
- if (this.getIsViewMode() && this.dashboardReference) {
2800
- return this.dashboardReference.exportDashboard(format);
2801
- }
2802
- if (!this.getIsViewMode()) {
2803
- return format ? exportDashboard(this, this.iframe, format) : exportDashboard(this, this.iframe);
2804
- }
2805
- return Promise.reject();
2806
- }
2807
- getAccessibleDashboards() {
2808
- return getAccessibleDashboards(this);
2809
- }
2810
- addFilters(itemId, filters) {
2811
- return this.dashboardReference.addFilters(itemId, filters);
2812
- }
2813
- setEditMode(editMode) {
2814
- if (this.dashboardReference && editMode === "view") {
2815
- this.editMode = "view";
2816
- this.params.editMode = "view";
2817
- this.initComponent();
2818
- return Promise.resolve({
2819
- type: "setEditMode",
2820
- editMode
2821
- });
2822
- }
2823
- if (this.dashboardReference && ["editFull", "editLimited"].includes(editMode)) {
2824
- this.editMode = editMode;
2825
- this.params.editMode = editMode;
2826
- this.initComponent();
2827
- return Promise.resolve({
2828
- type: "setEditMode",
2829
- editMode
2830
- });
2831
- }
2832
- if (this.getIsViewMode() && this.dashboardReference) {
2833
- return this.dashboardReference.setEditMode(editMode);
2834
- }
2835
- if (!this.getIsViewMode()) {
2836
- return setEditMode(this, this.iframe, editMode);
2837
- }
2838
- return Promise.reject();
2839
- }
2840
- setPreview(preview) {
2841
- if (this.getIsViewMode() && this.dashboardReference) {
2842
- return this.dashboardReference.setPreview(preview);
2843
- }
2844
- return setPreview(this, this.iframe, preview);
2845
- }
2846
- getIsViewMode() {
2847
- return this.experimental && this.params.editMode === "view" || this.params.editMode === void 0;
2848
- }
2849
- };
2850
- __decorateClass([
2851
- e4(".dashboard-container")
2852
- ], LuzmoDashboard.prototype, "container", 2);
2853
- __decorateClass([
2854
- e4(`.${luzmoEmbedContainerClass}`)
2855
- ], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2);
2856
- __decorateClass([
2857
- e4("iframe")
2858
- ], LuzmoDashboard.prototype, "iframe", 2);
2859
- __decorateClass([
2860
- n4()
2861
- ], LuzmoDashboard.prototype, "dashboardId", 2);
2862
- __decorateClass([
2863
- n4()
2864
- ], LuzmoDashboard.prototype, "dashboardSlug", 2);
2865
- __decorateClass([
2866
- n4()
2867
- ], LuzmoDashboard.prototype, "itemId", 2);
2868
- __decorateClass([
2869
- n4()
2870
- ], LuzmoDashboard.prototype, "language", 2);
2871
- __decorateClass([
2872
- n4()
2873
- ], LuzmoDashboard.prototype, "qeVersion", 2);
2874
- __decorateClass([
2875
- n4()
2876
- ], LuzmoDashboard.prototype, "screenMode", 2);
2877
- __decorateClass([
2878
- n4({
2879
- converter: {
2880
- fromAttribute: (value) => value === "true",
2881
- toAttribute: String
2882
- }
2883
- })
2884
- ], LuzmoDashboard.prototype, "switchScreenModeOnResize", 2);
2885
- __decorateClass([
2886
- n4()
2887
- ], LuzmoDashboard.prototype, "editMode", 2);
2888
- __decorateClass([
2889
- n4()
2890
- ], LuzmoDashboard.prototype, "mainColor", 2);
2891
- __decorateClass([
2892
- n4()
2893
- ], LuzmoDashboard.prototype, "accentColor", 2);
2894
- __decorateClass([
2895
- n4()
2896
- ], LuzmoDashboard.prototype, "authToken", 2);
2897
- __decorateClass([
2898
- n4()
2899
- ], LuzmoDashboard.prototype, "authKey", 2);
2900
- __decorateClass([
2901
- n4()
2902
- ], LuzmoDashboard.prototype, "loaderBackground", 2);
2903
- __decorateClass([
2904
- n4()
2905
- ], LuzmoDashboard.prototype, "loaderFontColor", 2);
2906
- __decorateClass([
2907
- n4()
2908
- ], LuzmoDashboard.prototype, "loaderSpinnerColor", 2);
2909
- __decorateClass([
2910
- n4()
2911
- ], LuzmoDashboard.prototype, "loaderSpinnerBackground", 2);
2912
- __decorateClass([
2913
- n4()
2914
- ], LuzmoDashboard.prototype, "appServer", 2);
2915
- __decorateClass([
2916
- n4()
2917
- ], LuzmoDashboard.prototype, "timezoneId", 2);
2918
- __decorateClass([
2919
- n4()
2920
- ], LuzmoDashboard.prototype, "apiHost", 2);
2921
- __decorateClass([
2922
- n4({ type: Object })
2923
- ], LuzmoDashboard.prototype, "itemDimensions", 2);
2924
- __decorateClass([
2925
- n4({
2926
- converter: {
2927
- fromAttribute: (value) => value === "true",
2928
- toAttribute: String
2929
- }
2930
- })
2931
- ], LuzmoDashboard.prototype, "experimental", 2);
2932
- __decorateClass([
2933
- n4({ attribute: false })
2934
- ], LuzmoDashboard.prototype, "_containerId", 2);
2935
- __decorateClass([
2936
- n4({ attribute: false })
2937
- ], LuzmoDashboard.prototype, "_iframeId", 2);
2938
- __decorateClass([
2939
- n4({ attribute: false })
2940
- ], LuzmoDashboard.prototype, "params", 2);
2941
- __decorateClass([
2942
- n4({ attribute: false })
2943
- ], LuzmoDashboard.prototype, "_iframeUrl", 2);
2944
- __decorateClass([
2945
- n4({ attribute: false })
2946
- ], LuzmoDashboard.prototype, "iframeLoaded", 2);
2947
- __decorateClass([
2948
- n4({ attribute: false })
2949
- ], LuzmoDashboard.prototype, "promises", 2);
2950
- __decorateClass([
2951
- n4({ attribute: false })
2952
- ], LuzmoDashboard.prototype, "iframeStyle", 2);
2953
- __decorateClass([
2954
- n4({ attribute: false })
2955
- ], LuzmoDashboard.prototype, "_containerStyle", 2);
2956
- __decorateClass([
2957
- n4({ attribute: false })
2958
- ], LuzmoDashboard.prototype, "_loaderStyle", 2);
2959
- __decorateClass([
2960
- n4({ attribute: false })
2961
- ], LuzmoDashboard.prototype, "_lcStyle", 2);
2962
- __decorateClass([
2963
- n4({ attribute: false })
2964
- ], LuzmoDashboard.prototype, "_loadingCircleStyle", 2);
2965
- __decorateClass([
2966
- n4({ attribute: false })
2967
- ], LuzmoDashboard.prototype, "_containerLoaderStyle", 2);
2968
- __decorateClass([
2969
- n4({ attribute: false })
2970
- ], LuzmoDashboard.prototype, "_loaderMsg", 2);
2971
- __decorateClass([
2972
- n4({ attribute: false })
2973
- ], LuzmoDashboard.prototype, "containerWidth", 2);
2974
- __decorateClass([
2975
- n4({ attribute: false })
2976
- ], LuzmoDashboard.prototype, "dimensions", 2);
2977
- __decorateClass([
2978
- n4({ attribute: false })
2979
- ], LuzmoDashboard.prototype, "currentScreenMode", 2);
2980
- __decorateClass([
2981
- n4({ attribute: false })
2982
- ], LuzmoDashboard.prototype, "_itemEmbedding", 2);
2983
- __decorateClass([
2984
- n4({ attribute: false })
2985
- ], LuzmoDashboard.prototype, "browserError", 2);
2986
- __decorateClass([
2987
- n4({ attribute: false })
2988
- ], LuzmoDashboard.prototype, "browserErrorMsg", 2);
2989
- __decorateClass([
2990
- n4({ attribute: false })
2991
- ], LuzmoDashboard.prototype, "dashboardError", 2);
2992
- __decorateClass([
2993
- n4({ attribute: false })
2994
- ], LuzmoDashboard.prototype, "browserNotSupported", 2);
2995
- __decorateClass([
2996
- n4()
2997
- ], LuzmoDashboard.prototype, "libVersion", 2);
2998
- __decorateClass([
2999
- r4()
3000
- ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
3001
- __decorateClass([
3002
- r4()
3003
- ], LuzmoDashboard.prototype, "dashboardReference", 2);
3004
- __decorateClass([
3005
- r4()
3006
- ], LuzmoDashboard.prototype, "currentAuthKey", 2);
3007
- __decorateClass([
3008
- r4()
3009
- ], LuzmoDashboard.prototype, "currentAuthToken", 2);
3010
- __decorateClass([
3011
- r4()
3012
- ], LuzmoDashboard.prototype, "isInitCalled", 2);
3013
-
3014
- // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
3015
- var LuzmoEmbedDashboard = class extends LuzmoDashboard {
3016
- };
3017
- if (!customElements.get("luzmo-embed-dashboard")) {
3018
- customElements.define("luzmo-embed-dashboard", LuzmoEmbedDashboard);
3019
- }
3020
-
3021
- // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
3022
- var dashboardContentsVersion = "0.1.91";
3023
- var LuzmoBaseVizItem = class extends h3 {
3024
- constructor() {
3025
- super(...arguments);
3026
- this.appServer = "https://app.luzmo.com";
3027
- this.apiHost = "https://api.luzmo.com";
3028
- this.slots = [];
3029
- this.version = version + "-wc-luzmo";
3030
- this.dashboardContentsVersion = dashboardContentsVersion;
3031
- this.libVersion = version + "-wc-luzmo";
3032
- this.postInitCallQueue = [];
3033
- }
3034
- static {
3035
- // Static styles to set host display to block, else it is not shown at all for some reason.
3036
- this.styles = i`
3037
- :host {
3038
- display: block;
3039
- width: 100%;
3040
- height: 100%;
3041
- }
3042
-
3043
- luzmo-embed-viz-item {
3044
- width: 100%;
3045
- height: 1000%;
3046
- display: block;
3047
- }
3048
- `;
3049
- }
3050
- createRenderRoot() {
3051
- if (!this.style.display) {
3052
- this.style.display = "block";
3053
- }
3054
- if (!this.style.height) {
3055
- this.style.height = "100%";
3056
- }
3057
- if (!this.style.width) {
3058
- this.style.width = "100%";
3059
- }
3060
- return this;
3061
- }
3062
- canInitializeVizItem() {
3063
- return !!(this.type || this.dashboardId && this.itemId);
3064
- }
3065
- getFilters() {
3066
- return this.chartElement.getFilters();
3067
- }
3068
- export() {
3069
- return this.chartElement.export();
3070
- }
3071
- getData() {
3072
- return this.chartElement.getData();
3073
- }
3074
- refreshData() {
3075
- return this.chartElement.refreshData();
3076
- }
3077
- setSelectedData(selectedDataInput) {
3078
- return this.chartElement.setSelectedData(void 0, selectedDataInput);
3079
- }
3080
- setAuthorization(key, token) {
3081
- return this.chartElement.setAuthorization(key, token);
3082
- }
3083
- attributeChangedCallback(name, _old, value) {
3084
- super.attributeChangedCallback(name, _old, value);
3085
- if (name === "selecteddata") {
3086
- if (this.chartElement) {
3087
- this.setSelectedData(JSON.parse(value ?? "{}"));
3088
- } else {
3089
- this.postInitCallQueue.push([this.setSelectedData, [JSON.parse(value ?? "{}")]]);
3090
- }
3091
- }
3092
- }
3093
- async firstUpdated(_changedProperties) {
3094
- super.firstUpdated(_changedProperties);
3095
- if (this.canInitializeVizItem()) {
3096
- await loadLibrary(this.appServer, "DashboardApp");
3097
- this.createAndAppendElement();
3098
- }
3099
- }
3100
- createAndAppendElement() {
3101
- if (!this.chartElement) {
3102
- this.chartElement = document.createElement("chart-component");
3103
- this.chartElement.setAttribute("embedding-mode", "chart");
3104
- this.chartElement.style.height = "100%";
3105
- this.chartElement.style.width = "100%";
3106
- this.chartElement.style.display = "block";
3107
- this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
3108
- this.chartElement.addEventListener("rendered", (payload) => {
3109
- if (this.postInitCallQueue?.length > 0) {
3110
- for (const functionToCall of this.postInitCallQueue) {
3111
- functionToCall[0].bind(this)(...functionToCall[1]);
3112
- }
3113
- } else {
3114
- if (this.selectedData) {
3115
- this.setSelectedData(this.selectedData);
3116
- }
3117
- }
3118
- this.dispatchEvent(new CustomEvent("rendered", payload));
3119
- });
3120
- this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
3121
- this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
3122
- this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
3123
- this.updateVizItemProperties();
3124
- this.renderRoot.append(this.chartElement);
3125
- }
3126
- }
3127
- updateVizItemProperties() {
3128
- if (this.chartElement) {
3129
- for (const key in libraryTypeToWebComponentTypeMapping) {
3130
- const value = this[key];
3131
- if (value) {
3132
- const attributeValue = ["appServer", "apiHost"].includes(key) ? removeTrailingSlash(value) : value;
3133
- this.chartElement.setAttribute(
3134
- libraryTypeToWebComponentTypeMapping[key],
3135
- typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
3136
- );
3137
- }
3138
- }
3139
- }
3140
- }
3141
- async updated(changedProperties) {
3142
- if (this.chartElement) {
3143
- for (const [propertyName] of changedProperties.entries()) {
3144
- const mappedAttributeName = libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
3145
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
3146
- this.chartElement.setAttribute(mappedAttributeName, attributeValue);
3147
- }
3148
- } else {
3149
- if (this.canInitializeVizItem()) {
3150
- await loadLibrary(this.appServer, "DashboardApp");
3151
- this.createAndAppendElement();
3152
- }
3153
- }
3154
- }
3155
- render() {
3156
- return ke` `;
3157
- }
3158
- };
3159
- __decorateClass([
3160
- n4()
3161
- ], LuzmoBaseVizItem.prototype, "appServer", 2);
3162
- __decorateClass([
3163
- n4()
3164
- ], LuzmoBaseVizItem.prototype, "apiHost", 2);
3165
- __decorateClass([
3166
- n4({ type: Array })
3167
- ], LuzmoBaseVizItem.prototype, "slots", 2);
3168
- __decorateClass([
3169
- n4({ type: Object })
3170
- ], LuzmoBaseVizItem.prototype, "options", 2);
3171
- __decorateClass([
3172
- n4()
3173
- ], LuzmoBaseVizItem.prototype, "type", 2);
3174
- __decorateClass([
3175
- n4()
3176
- ], LuzmoBaseVizItem.prototype, "authKey", 2);
3177
- __decorateClass([
3178
- n4()
3179
- ], LuzmoBaseVizItem.prototype, "authToken", 2);
3180
- __decorateClass([
3181
- n4()
3182
- ], LuzmoBaseVizItem.prototype, "version", 2);
3183
- __decorateClass([
3184
- n4()
3185
- ], LuzmoBaseVizItem.prototype, "contextId", 2);
3186
- __decorateClass([
3187
- n4({
3188
- converter: (value) => {
3189
- try {
3190
- return JSON.parse(value);
3191
- } catch {
3192
- return value;
3193
- }
3194
- }
3195
- })
3196
- ], LuzmoBaseVizItem.prototype, "canFilter", 2);
3197
- __decorateClass([
3198
- n4({ type: Array })
3199
- ], LuzmoBaseVizItem.prototype, "filters", 2);
3200
- __decorateClass([
3201
- n4()
3202
- ], LuzmoBaseVizItem.prototype, "dashboardId", 2);
3203
- __decorateClass([
3204
- n4()
3205
- ], LuzmoBaseVizItem.prototype, "itemId", 2);
3206
- __decorateClass([
3207
- n4({ type: Object })
3208
- ], LuzmoBaseVizItem.prototype, "selectedData", 2);
3209
- __decorateClass([
3210
- n4()
3211
- ], LuzmoBaseVizItem.prototype, "dashboardContentsVersion", 2);
3212
- __decorateClass([
3213
- n4()
3214
- ], LuzmoBaseVizItem.prototype, "libVersion", 2);
3215
-
3216
- // libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
3217
- var LuzmoEmbedVizItem = class extends LuzmoBaseVizItem {
3218
- };
3219
- if (!customElements.get("luzmo-embed-viz-item")) {
3220
- customElements.define("luzmo-embed-viz-item", LuzmoEmbedVizItem);
3221
- }
3222
-
3223
- // libs/embed-libs/embed/src/lib/luzmo-iq-components/luzmo-iq-chat.ts
3224
- var inputMap = {
3225
- aiEndpoint: "ai-endpoint",
3226
- appServer: "app-server",
3227
- apiHost: "api-host",
3228
- options: "options",
3229
- initialSuggestionsDatasetId: "initialSuggestionsDatasetId",
3230
- authKey: "auth-key",
3231
- authToken: "auth-token",
3232
- version: "version",
3233
- libVersion: "lib-version",
3234
- aydHost: "ayd-host"
3235
- };
3236
- var LuzmoIQEmbedChatComponent = class extends h3 {
3237
- constructor() {
3238
- super(...arguments);
3239
- this.appServer = "https://app.luzmo.com";
3240
- this.apiHost = "https://api.luzmo.com";
3241
- this.version = version + "-wc-luzmo";
3242
- this.libVersion = version + "-wc-luzmo";
3243
- this.remoteEntryServer = "http://localhost:4202/";
3244
- this.aydHost = "https://ayd.luzmo.com/";
3245
- }
3246
- static {
3247
- // Static styles to set host display to block, else it is not shown at all for some reason.
3248
- this.styles = i`
3249
- :host {
3250
- display: block;
3251
- width: 100%;
3252
- height: 100%;
3253
- }
3254
- `;
3255
- }
3256
- createRenderRoot() {
3257
- return this;
3258
- }
3259
- async firstUpdated(_changedProperties) {
3260
- super.firstUpdated(_changedProperties);
3261
- await loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
3262
- this.createAndAppendElement();
3263
- }
3264
- createAndAppendElement() {
3265
- if (!this.chartElement) {
3266
- this.chartElement = document.createElement("luzmo-iq-chat-component");
3267
- this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
3268
- this.updateVizItemProperties();
3269
- this.renderRoot.append(this.chartElement);
3270
- }
3271
- }
3272
- updateVizItemProperties() {
3273
- if (this.chartElement) {
3274
- for (const key in inputMap) {
3275
- const value = this[key];
3276
- if (value) {
3277
- const attributeValue = ["appServer", "apiHost", "aydHost"].includes(key) ? removeTrailingSlash(value) : value;
3278
- this.chartElement.setAttribute(
3279
- inputMap[key],
3280
- typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
3281
- );
3282
- }
3283
- }
3284
- }
3285
- }
3286
- async updated(changedProperties) {
3287
- if (this.chartElement) {
3288
- for (const [propertyName] of changedProperties.entries()) {
3289
- const mappedAttributeName = inputMap[propertyName] ?? propertyName;
3290
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
3291
- this.chartElement.setAttribute(mappedAttributeName, attributeValue);
3292
- }
3293
- } else {
3294
- await loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
3295
- this.createAndAppendElement();
3296
- }
3297
- }
3298
- render() {
3299
- return ke`
3300
- <slot name="custom-chat-widget-content"></slot>
3301
- `;
3302
- }
3303
- };
3304
- __decorateClass([
3305
- n4()
3306
- ], LuzmoIQEmbedChatComponent.prototype, "appServer", 2);
3307
- __decorateClass([
3308
- n4()
3309
- ], LuzmoIQEmbedChatComponent.prototype, "apiHost", 2);
3310
- __decorateClass([
3311
- n4({ type: Object })
3312
- ], LuzmoIQEmbedChatComponent.prototype, "options", 2);
3313
- __decorateClass([
3314
- n4({ type: String })
3315
- ], LuzmoIQEmbedChatComponent.prototype, "initialSuggestionsDatasetId", 2);
3316
- __decorateClass([
3317
- n4()
3318
- ], LuzmoIQEmbedChatComponent.prototype, "aiEndpoint", 2);
3319
- __decorateClass([
3320
- n4()
3321
- ], LuzmoIQEmbedChatComponent.prototype, "authKey", 2);
3322
- __decorateClass([
3323
- n4()
3324
- ], LuzmoIQEmbedChatComponent.prototype, "authToken", 2);
3325
- __decorateClass([
3326
- n4()
3327
- ], LuzmoIQEmbedChatComponent.prototype, "version", 2);
3328
- __decorateClass([
3329
- n4()
3330
- ], LuzmoIQEmbedChatComponent.prototype, "libVersion", 2);
3331
- __decorateClass([
3332
- n4()
3333
- ], LuzmoIQEmbedChatComponent.prototype, "remoteEntryServer", 2);
3334
- __decorateClass([
3335
- n4()
3336
- ], LuzmoIQEmbedChatComponent.prototype, "aydHost", 2);
3337
- if (!customElements.get("luzmo-iq-embed-chat")) {
3338
- customElements.define("luzmo-iq-embed-chat", LuzmoIQEmbedChatComponent);
3339
- }
3340
-
3341
- // libs/embed-libs/embed/src/lib/luzmo-iq-components/luzmo-iq-answer.ts
3342
- var inputMap2 = {
3343
- aiEndPoint: "ai-end-point",
3344
- appServer: "app-server",
3345
- apiHost: "api-host",
3346
- options: "options",
3347
- authKey: "auth-key",
3348
- authToken: "auth-token",
3349
- version: "version",
3350
- libVersion: "lib-version",
3351
- messages: "messages"
3352
- };
3353
- var LuzmoIQEmbedAnswerComponent = class extends h3 {
3354
- constructor() {
3355
- super(...arguments);
3356
- this.appServer = "https://app.luzmo.com";
3357
- this.apiHost = "https://api.luzmo.com";
3358
- this.version = version + "-wc-luzmo";
3359
- this.libVersion = version + "-wc-luzmo";
3360
- this.remoteEntryServer = "http://localhost:4202";
3361
- }
3362
- static {
3363
- // Static styles to set host display to block, else it is not shown at all for some reason.
3364
- this.styles = i`
3365
- :host {
3366
- display: block;
3367
- width: 100%;
3368
- height: 100%;
3369
- }
3370
- `;
3371
- }
3372
- createRenderRoot() {
3373
- return this;
3374
- }
3375
- async firstUpdated(_changedProperties) {
3376
- super.firstUpdated(_changedProperties);
3377
- await loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
3378
- this.createAndAppendElement();
3379
- }
3380
- createAndAppendElement() {
3381
- if (!this.chartElement) {
3382
- this.chartElement = document.createElement("luzmo-iq-answer-component");
3383
- this.chartElement.addEventListener("addQuestion", (payload) => this.dispatchEvent(new CustomEvent("addQuestion", payload)));
3384
- this.chartElement.addEventListener("addAnswer", (payload) => this.dispatchEvent(new CustomEvent("addAnswer", payload)));
3385
- this.updateVizItemProperties();
3386
- this.renderRoot.append(this.chartElement);
3387
- }
3388
- }
3389
- updateVizItemProperties() {
3390
- if (this.chartElement) {
3391
- for (const key in inputMap2) {
3392
- const value = this[key];
3393
- if (value) {
3394
- const attributeValue = ["appServer", "apiHost"].includes(key) ? removeTrailingSlash(value) : value;
3395
- this.chartElement.setAttribute(
3396
- inputMap2[key],
3397
- typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
3398
- );
3399
- }
3400
- }
3401
- }
3402
- }
3403
- async updated(changedProperties) {
3404
- if (this.chartElement) {
3405
- for (const [propertyName] of changedProperties.entries()) {
3406
- const mappedAttributeName = inputMap2[propertyName] ?? propertyName;
3407
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
3408
- this.chartElement.setAttribute(mappedAttributeName, attributeValue);
3409
- }
3410
- } else {
3411
- await loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
3412
- this.createAndAppendElement();
3413
- }
3414
- }
3415
- render() {
3416
- return ke` `;
3417
- }
3418
- };
3419
- __decorateClass([
3420
- n4()
3421
- ], LuzmoIQEmbedAnswerComponent.prototype, "appServer", 2);
3422
- __decorateClass([
3423
- n4()
3424
- ], LuzmoIQEmbedAnswerComponent.prototype, "apiHost", 2);
3425
- __decorateClass([
3426
- n4({ type: Object })
3427
- ], LuzmoIQEmbedAnswerComponent.prototype, "options", 2);
3428
- __decorateClass([
3429
- n4()
3430
- ], LuzmoIQEmbedAnswerComponent.prototype, "aiEndPoint", 2);
3431
- __decorateClass([
3432
- n4()
3433
- ], LuzmoIQEmbedAnswerComponent.prototype, "authKey", 2);
3434
- __decorateClass([
3435
- n4()
3436
- ], LuzmoIQEmbedAnswerComponent.prototype, "authToken", 2);
3437
- __decorateClass([
3438
- n4()
3439
- ], LuzmoIQEmbedAnswerComponent.prototype, "messages", 2);
3440
- __decorateClass([
3441
- n4()
3442
- ], LuzmoIQEmbedAnswerComponent.prototype, "version", 2);
3443
- __decorateClass([
3444
- n4()
3445
- ], LuzmoIQEmbedAnswerComponent.prototype, "libVersion", 2);
3446
- __decorateClass([
3447
- n4()
3448
- ], LuzmoIQEmbedAnswerComponent.prototype, "remoteEntryServer", 2);
3449
- if (!customElements.get("luzmo-iq-embed-answer")) {
3450
- customElements.define("luzmo-iq-embed-answer", LuzmoIQEmbedAnswerComponent);
3451
- }
3452
-
3453
- // libs/embed-libs/embed/src/lib/helper/json-schema-utils.ts
3454
- var cachedSchemas = {};
3455
- function addJSONSchemas(schemas) {
3456
- if (schemas.some((schema) => !schema.$id)) {
3457
- throw new Error("To add schemas they all must have an $id property.");
3458
- }
3459
- schemas.forEach((schema) => {
3460
- cachedSchemas[schema.$id] = schema;
3461
- });
3462
- }
3463
- function getCachedJSONSchema(schemaUrl) {
3464
- return cachedSchemas[schemaUrl];
3465
- }
3466
- function getCachedJSONSchemas() {
3467
- return cachedSchemas;
3468
- }
3469
- function getJSONSchemaUrl(schemaName) {
3470
- return `https://developer.luzmo.com/assets/json-schemas/${dashboardContentsVersion}/${schemaName}.schema.json`;
3471
- }
3472
- async function fetchJSONSchema(schemaName) {
3473
- const schemaUrl = getJSONSchemaUrl(schemaName);
3474
- if (getCachedJSONSchema(schemaUrl)) {
3475
- return getCachedJSONSchema(schemaUrl);
3476
- }
3477
- try {
3478
- const response = await fetch(schemaUrl, { credentials: "omit" });
3479
- if (!response.ok) {
3480
- throw new Error(`Failed to fetch schema ${schemaUrl}, response status: ${response.status}`);
3481
- }
3482
- const schema = await response.json();
3483
- addJSONSchemas([schema]);
3484
- return schema;
3485
- } catch (error) {
3486
- console.error(error);
3487
- }
3488
- }
3489
- var luzmoRefParserResolver = {
3490
- order: 101,
3491
- // 101 would make it run after the file resolver, but before the HTTP resolver
3492
- canRead: (file) => {
3493
- const isLuzmoUrl = file.url.startsWith("https://developer.luzmo.com");
3494
- if (isLuzmoUrl) {
3495
- return !!getCachedJSONSchema(file.url);
3496
- }
3497
- return false;
3498
- },
3499
- read: (file, callback) => {
3500
- callback(null, getCachedJSONSchema(file.url));
3501
- }
3502
- };
3503
- var luzmoRefParserOptions = {
3504
- mutateInputSchema: false,
3505
- resolve: {
3506
- luzmo: luzmoRefParserResolver,
3507
- external: true
3508
- }
3509
- };
3510
- /*! Bundled license information:
3511
-
3512
- @lit/reactive-element/css-tag.js:
3513
- (**
3514
- * @license
3515
- * Copyright 2019 Google LLC
3516
- * SPDX-License-Identifier: BSD-3-Clause
3517
- *)
3518
-
3519
- @lit/reactive-element/reactive-element.js:
3520
- (**
3521
- * @license
3522
- * Copyright 2017 Google LLC
3523
- * SPDX-License-Identifier: BSD-3-Clause
3524
- *)
3525
-
3526
- lit-html/lit-html.js:
3527
- (**
3528
- * @license
3529
- * Copyright 2017 Google LLC
3530
- * SPDX-License-Identifier: BSD-3-Clause
3531
- *)
3532
-
3533
- lit-element/lit-element.js:
3534
- (**
3535
- * @license
3536
- * Copyright 2017 Google LLC
3537
- * SPDX-License-Identifier: BSD-3-Clause
3538
- *)
3539
-
3540
- lit-html/is-server.js:
3541
- (**
3542
- * @license
3543
- * Copyright 2022 Google LLC
3544
- * SPDX-License-Identifier: BSD-3-Clause
3545
- *)
3546
-
3547
- @lit/reactive-element/decorators/custom-element.js:
3548
- (**
3549
- * @license
3550
- * Copyright 2017 Google LLC
3551
- * SPDX-License-Identifier: BSD-3-Clause
3552
- *)
3553
-
3554
- @lit/reactive-element/decorators/property.js:
3555
- (**
3556
- * @license
3557
- * Copyright 2017 Google LLC
3558
- * SPDX-License-Identifier: BSD-3-Clause
3559
- *)
3560
-
3561
- @lit/reactive-element/decorators/state.js:
3562
- (**
3563
- * @license
3564
- * Copyright 2017 Google LLC
3565
- * SPDX-License-Identifier: BSD-3-Clause
3566
- *)
3567
-
3568
- @lit/reactive-element/decorators/event-options.js:
3569
- (**
3570
- * @license
3571
- * Copyright 2017 Google LLC
3572
- * SPDX-License-Identifier: BSD-3-Clause
3573
- *)
3574
-
3575
- @lit/reactive-element/decorators/base.js:
3576
- (**
3577
- * @license
3578
- * Copyright 2017 Google LLC
3579
- * SPDX-License-Identifier: BSD-3-Clause
3580
- *)
3581
-
3582
- @lit/reactive-element/decorators/query.js:
3583
- (**
3584
- * @license
3585
- * Copyright 2017 Google LLC
3586
- * SPDX-License-Identifier: BSD-3-Clause
3587
- *)
3588
-
3589
- @lit/reactive-element/decorators/query-all.js:
3590
- (**
3591
- * @license
3592
- * Copyright 2017 Google LLC
3593
- * SPDX-License-Identifier: BSD-3-Clause
3594
- *)
3595
-
3596
- @lit/reactive-element/decorators/query-async.js:
3597
- (**
3598
- * @license
3599
- * Copyright 2017 Google LLC
3600
- * SPDX-License-Identifier: BSD-3-Clause
3601
- *)
3602
-
3603
- @lit/reactive-element/decorators/query-assigned-elements.js:
3604
- (**
3605
- * @license
3606
- * Copyright 2021 Google LLC
3607
- * SPDX-License-Identifier: BSD-3-Clause
3608
- *)
3609
-
3610
- @lit/reactive-element/decorators/query-assigned-nodes.js:
3611
- (**
3612
- * @license
3613
- * Copyright 2017 Google LLC
3614
- * SPDX-License-Identifier: BSD-3-Clause
3615
- *)
3616
-
3617
- lit-html/directive.js:
3618
- (**
3619
- * @license
3620
- * Copyright 2017 Google LLC
3621
- * SPDX-License-Identifier: BSD-3-Clause
3622
- *)
3623
-
3624
- lit-html/directives/style-map.js:
3625
- (**
3626
- * @license
3627
- * Copyright 2018 Google LLC
3628
- * SPDX-License-Identifier: BSD-3-Clause
3629
- *)
3630
- */
3631
-
3632
- if(__exports != exports)module.exports = exports;return module.exports}));