@luzmo/embed 7.5.0-es2021 → 8.0.0-es2021

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 (82) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +2 -2
  3. package/index.cjs +1589 -143
  4. package/index.js +1583 -129
  5. package/index.rn.cjs +1375 -0
  6. package/index.rn.js +1305 -0
  7. package/index.shared.cjs +1486 -0
  8. package/index.shared.js +1412 -0
  9. package/luzmo-embed.min.js +197 -96
  10. package/package.json +22 -2
  11. package/src/index.common.d.ts +18 -0
  12. package/src/index.d.ts +3 -3
  13. package/src/index.rn.d.ts +1 -0
  14. package/src/index.shared.d.ts +2 -0
  15. package/src/lib/dashboard/dashboard-base.d.ts +5 -1
  16. package/src/lib/iq-components/luzmo-iq-answer.d.ts +1 -2
  17. package/src/lib/iq-components/luzmo-iq-chat.d.ts +1 -1
  18. package/src/lib/shared/constants/class-constants.d.ts +1 -0
  19. package/src/lib/shared/helpers/browser-check.d.ts +2 -0
  20. package/src/lib/shared/helpers/default-parameters.d.ts +2 -0
  21. package/src/lib/shared/helpers/error.d.ts +5 -0
  22. package/src/lib/shared/helpers/extents.d.ts +7 -0
  23. package/src/lib/shared/helpers/get-loader.d.ts +5 -0
  24. package/src/lib/shared/helpers/iframe-url.d.ts +1 -0
  25. package/src/lib/shared/helpers/promise-dispatch.d.ts +3 -0
  26. package/src/lib/shared/helpers/remote-federation.d.ts +56 -0
  27. package/src/lib/shared/helpers/set-selected-data-utils.d.ts +7 -0
  28. package/src/lib/shared/helpers/styles.d.ts +8 -0
  29. package/src/lib/shared/helpers/translations.d.ts +24 -0
  30. package/src/lib/shared/helpers/update-iframe-url.d.ts +1 -0
  31. package/src/lib/shared/helpers/utils.d.ts +27 -0
  32. package/src/lib/shared/methods/export-dashboard.d.ts +5 -0
  33. package/src/lib/shared/methods/get-accessible-dashboards.d.ts +3 -0
  34. package/src/lib/shared/methods/get-dashboard-context.d.ts +3 -0
  35. package/src/lib/shared/methods/get-data.d.ts +3 -0
  36. package/src/lib/shared/methods/get-filters.d.ts +3 -0
  37. package/src/lib/shared/methods/get-insights.d.ts +3 -0
  38. package/src/lib/shared/methods/index.d.ts +13 -0
  39. package/src/lib/shared/methods/refresh-data.d.ts +2 -0
  40. package/src/lib/shared/methods/reload-dashboard.d.ts +2 -0
  41. package/src/lib/shared/methods/send-export-email.d.ts +4 -0
  42. package/src/lib/shared/methods/set-authorization.d.ts +2 -0
  43. package/src/lib/shared/methods/set-edit-mode.d.ts +3 -0
  44. package/src/lib/shared/methods/set-preview.d.ts +3 -0
  45. package/src/lib/shared/methods/set-selected-data.d.ts +4 -0
  46. package/src/lib/shared/models/common.model.d.ts +105 -0
  47. package/src/lib/shared/models/dashboard-context.model.d.ts +50 -0
  48. package/src/lib/shared/models/dashboard.model.d.ts +59 -0
  49. package/src/lib/shared/models/embed-error-event.model.d.ts +17 -0
  50. package/src/lib/shared/models/events.model.d.ts +94 -0
  51. package/src/lib/shared/models/filter-input.model.d.ts +101 -0
  52. package/src/lib/shared/models/filter-output.model.d.ts +17 -0
  53. package/src/lib/shared/models/filters.model.d.ts +26 -0
  54. package/src/lib/shared/models/index.d.ts +12 -0
  55. package/src/lib/shared/models/styles.model.d.ts +32 -0
  56. package/src/lib/shared/models/translation.model.d.ts +2 -0
  57. package/src/lib/shared/models/viz-item-post-message.model.d.ts +56 -0
  58. package/src/lib/shared/models/viz-item.model.d.ts +8 -0
  59. package/src/lib/shared/models/viz-items/areachart.model.d.ts +13 -0
  60. package/src/lib/shared/models/viz-items/barchart.model.d.ts +24 -0
  61. package/src/lib/shared/models/viz-items/choroplethmap.model.d.ts +13 -0
  62. package/src/lib/shared/models/viz-items/circlepack.model.d.ts +2 -0
  63. package/src/lib/shared/models/viz-items/columnchart.model.d.ts +24 -0
  64. package/src/lib/shared/models/viz-items/datetime.model.d.ts +13 -0
  65. package/src/lib/shared/models/viz-items/donutchart.model.d.ts +2 -0
  66. package/src/lib/shared/models/viz-items/dropdownfilter.model.d.ts +13 -0
  67. package/src/lib/shared/models/viz-items/index.d.ts +36 -0
  68. package/src/lib/shared/models/viz-items/linechart.model.d.ts +36 -0
  69. package/src/lib/shared/models/viz-items/parallelcoordinatesplot.model.d.ts +14 -0
  70. package/src/lib/shared/models/viz-items/piechart.model.d.ts +24 -0
  71. package/src/lib/shared/models/viz-items/scatterplot.model.d.ts +13 -0
  72. package/src/lib/shared/models/viz-items/slicer.model.d.ts +24 -0
  73. package/src/lib/shared/models/viz-items/slider.model.d.ts +13 -0
  74. package/src/lib/shared/models/viz-items/stripplot.model.d.ts +15 -0
  75. package/src/lib/shared/models/viz-items/sunburst.model.d.ts +14 -0
  76. package/src/lib/shared/models/viz-items/treemap.model.d.ts +24 -0
  77. package/src/lib/shared/service/calculate-dimensions.d.ts +1 -0
  78. package/src/lib/shared/service/extend-and-validate.d.ts +2 -0
  79. package/src/lib/{helper → utils}/embed-error.utils.d.ts +1 -1
  80. package/src/lib/viz-item/viz-item.base.d.ts +2 -2
  81. /package/src/lib/{helper → utils}/event-bus-handler.d.ts +0 -0
  82. /package/src/lib/{helper → utils}/json-schema-utils.d.ts +0 -0
package/index.rn.js ADDED
@@ -0,0 +1,1305 @@
1
+ // libs/embed-libs/embed/src/lib/shared/helpers/error.ts
2
+ var _handleError = (errorMessage, parameters) => {
3
+ let message = "The dashboard component encountered an error";
4
+ if (typeof parameters?.dashboardId === "string") {
5
+ message += ` for dashboard with id ${parameters.dashboardId}`;
6
+ }
7
+ if (typeof parameters?.dashboardSlug === "string") {
8
+ message += ` for dashboard with slug ${parameters.dashboardSlug}`;
9
+ }
10
+ if (typeof parameters?.container === "string") {
11
+ message += ` in container ${parameters.container}`;
12
+ }
13
+ if (errorMessage) {
14
+ message += `:
15
+ ${errorMessage}`;
16
+ console.warn(message);
17
+ }
18
+ };
19
+
20
+ // libs/embed-libs/embed/src/lib/shared/helpers/browser-check.ts
21
+ var _browserCheck = (dashboardComponent) => {
22
+ let hasError = false;
23
+ let errorMessage = "";
24
+ const document_ = document.body || document.documentElement;
25
+ const style = document_.style;
26
+ const browserCheck = {
27
+ svg: !!("createElementNS" in document && document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect),
28
+ flexbox: style.webkitFlexWrap === "" || style.flexWrap === "",
29
+ postMessage: !!window.postMessage
30
+ };
31
+ const browserCheckKeys = ["svg", "flexbox", "postMessage"];
32
+ for (const key of browserCheckKeys) {
33
+ if (!browserCheck[key]) {
34
+ hasError = true;
35
+ dashboardComponent.browserNotSupported = dashboardComponent.browserNotSupported || [];
36
+ dashboardComponent.browserNotSupported.push(key);
37
+ errorMessage += `Your browser does not support: ${key}
38
+ `;
39
+ }
40
+ }
41
+ const ua = window.navigator.userAgent;
42
+ const msie = ua.includes("MSIE");
43
+ const trident = ua.includes("Trident/");
44
+ if (msie || trident) {
45
+ hasError = true;
46
+ errorMessage = "IE is not supported.";
47
+ }
48
+ if (hasError) {
49
+ _handleError(errorMessage);
50
+ }
51
+ };
52
+
53
+ // libs/embed-libs/embed/src/lib/shared/helpers/default-parameters.ts
54
+ var DEFAULT_PARAMETERS = {
55
+ appServer: "https://app.luzmo.com/",
56
+ apiHost: "https://api.luzmo.com/",
57
+ dashboardId: null,
58
+ dashboardSlug: null,
59
+ container: null,
60
+ key: null,
61
+ token: null,
62
+ language: "auto",
63
+ editorLanguage: "auto",
64
+ editMode: null,
65
+ screenMode: null,
66
+ switchScreenModeOnResize: true,
67
+ itemId: null,
68
+ theme: "",
69
+ mainColor: "",
70
+ itemDimensions: {
71
+ width: "auto",
72
+ height: "auto"
73
+ },
74
+ loaderBackground: "#f9f9f9",
75
+ loaderFontColor: "#5a5a5a",
76
+ loaderSpinnerColor: "rgb(68, 52, 255)",
77
+ loaderSpinnerBackground: "rgba(169, 169, 169, 0.14)",
78
+ timezoneId: null,
79
+ contextId: null
80
+ };
81
+
82
+ // libs/embed-libs/embed/src/lib/shared/helpers/extents.ts
83
+ var EXTENTS = [
84
+ { mode: "mobile", width: [150, 767] },
85
+ { mode: "tablet", width: [768, 1199] },
86
+ { mode: "desktop", width: [1200, 1599] },
87
+ { mode: "largeScreen", width: [1600, 9999] },
88
+ { mode: "fixed", width: [] }
89
+ ];
90
+
91
+ // libs/embed-libs/embed/src/lib/shared/helpers/translations.ts
92
+ var TRANSLATIONS = {
93
+ initializing: {
94
+ en: "Initializing...",
95
+ nl: "Laden...",
96
+ fr: "Chargement...",
97
+ de: "Initialisiere...",
98
+ es: "Inicializando..."
99
+ },
100
+ errorDashboard: {
101
+ en: "Oops, we could not load this dashboard!",
102
+ nl: "Oeps, we konden het dashboard niet laden.",
103
+ fr: "Le chargement a echou\xE9.",
104
+ de: "Hoppla, wir konnten dieses Dashboard nicht laden!",
105
+ es: "\xA1Ups! No pudimos cargar este tablero."
106
+ },
107
+ errorItem: {
108
+ en: "Oops, we could not load this item!",
109
+ nl: "Oeps, we konden de grafiek niet laden.",
110
+ fr: "Le chargement a echou\xE9.",
111
+ de: "Hoppla, wir konnten dieses Diagramm nicht laden!",
112
+ es: "\xA1Ups! No pudimos cargar este elemento."
113
+ }
114
+ };
115
+ var translations_default = TRANSLATIONS;
116
+
117
+ // libs/embed-libs/embed/src/lib/shared/helpers/utils.ts
118
+ var addTrailingSlash = (serverUrl) => {
119
+ if (!serverUrl) {
120
+ return "";
121
+ }
122
+ return serverUrl.endsWith("/") ? serverUrl : `${serverUrl}/`;
123
+ };
124
+ var removeTrailingSlash = (serverUrl) => {
125
+ if (!serverUrl) {
126
+ return "";
127
+ }
128
+ return serverUrl.endsWith("/") ? serverUrl.slice(0, -1) : serverUrl;
129
+ };
130
+ var formatDashboardList = (dashboards, integrationId, user, dashboardComponent) => {
131
+ const combineRights = (securable, accessUser) => {
132
+ const matchingUser = securable.users.find((u) => u.id === accessUser.id);
133
+ const securableAccessRights = matchingUser && matchingUser.userAccessRight ? {
134
+ flagRead: matchingUser.userAccessRight.flagRead,
135
+ flagUse: matchingUser.userAccessRight.flagUse,
136
+ flagModify: matchingUser.userAccessRight.flagModify,
137
+ flagOwn: matchingUser.userAccessRight.flagOwn
138
+ } : {
139
+ flagRead: false,
140
+ flagUse: false,
141
+ flagModify: false,
142
+ flagOwn: false
143
+ };
144
+ const groups = securable.groups.filter(
145
+ (group) => accessUser.userGroups.includes(group.id) || group.public === true
146
+ );
147
+ const groupsAccess = groups.map((group) => {
148
+ if (group.groupAccessRight) {
149
+ return group.groupAccessRight;
150
+ }
151
+ });
152
+ for (const groupAccess of groupsAccess) {
153
+ if (!securableAccessRights.flagRead && groupAccess.flagRead) {
154
+ securableAccessRights.flagRead = groupAccess.flagRead;
155
+ }
156
+ if (!securableAccessRights.flagUse && groupAccess.flagUse) {
157
+ securableAccessRights.flagUse = groupAccess.flagUse;
158
+ }
159
+ if (!securableAccessRights.flagModify && groupAccess.flagModify) {
160
+ securableAccessRights.flagModify = groupAccess.flagModify;
161
+ }
162
+ if (!securableAccessRights.flagOwn && groupAccess.flagOwn) {
163
+ securableAccessRights.flagOwn = groupAccess.flagOwn;
164
+ }
165
+ }
166
+ const integrationsAccess = securable.integrations?.length > 0 ? securable.integrations.map((integration) => {
167
+ if (integration.integrationAccessRight) {
168
+ return integration.integrationAccessRight;
169
+ }
170
+ }) : [];
171
+ for (const integrationAccess of integrationsAccess) {
172
+ if (!securableAccessRights.flagRead && integrationAccess.flagRead) {
173
+ securableAccessRights.flagRead = integrationAccess.flagRead;
174
+ }
175
+ if (!securableAccessRights.flagUse && integrationAccess.flagUse) {
176
+ securableAccessRights.flagUse = integrationAccess.flagUse;
177
+ }
178
+ if (!securableAccessRights.flagModify && integrationAccess.flagModify) {
179
+ securableAccessRights.flagModify = integrationAccess.flagModify;
180
+ }
181
+ }
182
+ return securableAccessRights;
183
+ };
184
+ const localize = (item, locale) => {
185
+ if (item === null || item === void 0) {
186
+ return "";
187
+ }
188
+ if (typeof item !== "object" || Object.keys(item).length === 0) {
189
+ if (typeof item === "object" && Object.keys(item).length === 0) {
190
+ return "";
191
+ }
192
+ return item;
193
+ }
194
+ let localizedItem;
195
+ localizedItem = locale && item[locale] ? item[locale] : item[Object.keys(item)[0]];
196
+ if (localizedItem === void 0 || localizedItem === null) {
197
+ localizedItem = "";
198
+ }
199
+ return localizedItem;
200
+ };
201
+ const treatedDashboards = [];
202
+ for (const dashboard of dashboards) {
203
+ const treatedDashboard = {
204
+ accessibleBy: [],
205
+ accessRights: combineRights(dashboard, user),
206
+ id: dashboard.id,
207
+ modifiedAt: dashboard.modified_at,
208
+ name: localize(dashboard.name, dashboardComponent.language),
209
+ slug: null,
210
+ tags: dashboard.tags.map((t) => t.tag).sort((t1, t2) => t1.localeCompare(t2))
211
+ };
212
+ const currentIntegration = dashboard.integrations.find(
213
+ (i) => i.id === integrationId
214
+ );
215
+ if (currentIntegration?.integrationAccessRight?.slug) {
216
+ treatedDashboard.slug = currentIntegration.integrationAccessRight.slug;
217
+ }
218
+ const users = dashboard.users.map((u) => ({
219
+ model: "User",
220
+ id: u.id,
221
+ name: localize(u.name, user.locale_id)
222
+ }));
223
+ const groups = dashboard.groups.map((g) => ({
224
+ model: "Group",
225
+ id: g.id,
226
+ name: localize(g.name, user.locale_id) || {}
227
+ }));
228
+ const integrations = dashboard.integrations.map((i) => ({
229
+ model: "Integration",
230
+ id: i.id,
231
+ name: localize(i.name, user.locale_id) || {}
232
+ }));
233
+ treatedDashboard.accessibleBy = [...users, ...groups, ...integrations];
234
+ treatedDashboards.push(treatedDashboard);
235
+ }
236
+ return treatedDashboards;
237
+ };
238
+ var VERSION = "0.0.0-unknown-luzmo";
239
+ var sanitizeUrl = (url) => {
240
+ const invalidPrototcolRegex = /^(%20|\s)*(javascript|data)/im;
241
+ const ctrlCharactersRegex = /[^\u0020-\u007E]/gim;
242
+ const urlSchemeRegex = /^([^:]+):/gm;
243
+ const relativeFirstCharacters = /* @__PURE__ */ new Set([".", "/"]);
244
+ const isRelativeUrlWithoutProtocol = (relativeUrl) => relativeFirstCharacters.has(relativeUrl[0]);
245
+ if (!url) {
246
+ return "about:blank";
247
+ }
248
+ const sanitizedUrl = url.replaceAll(ctrlCharactersRegex, "").trim();
249
+ if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
250
+ return sanitizedUrl;
251
+ }
252
+ const urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex);
253
+ if (!urlSchemeParseResults) {
254
+ return sanitizedUrl;
255
+ }
256
+ const urlScheme = urlSchemeParseResults[0];
257
+ if (invalidPrototcolRegex.test(urlScheme)) {
258
+ return "about:blank";
259
+ }
260
+ return sanitizedUrl;
261
+ };
262
+ var cloneDeep = (obj) => JSON.parse(JSON.stringify(obj));
263
+ var isObject = (o) => o && typeof o === "object";
264
+ var defaultsDeep = (target, defaults) => {
265
+ Object.entries(defaults).forEach(([k, v]) => {
266
+ if (k in target) {
267
+ if (target[k] === void 0) {
268
+ target[k] = v;
269
+ } else {
270
+ target[k] = isObject(v) ? defaultsDeep(
271
+ target[k],
272
+ v
273
+ ) : target[k];
274
+ }
275
+ } else {
276
+ target[k] = v;
277
+ }
278
+ });
279
+ return target;
280
+ };
281
+ var s4 = () => Math.floor((1 + Math.random()) * 65536).toString(16).slice(1);
282
+ var uuidv4 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g, function(c) {
283
+ const r = Math.trunc(Math.random() * 16);
284
+ const v = c === "x" ? r : r & 3 | 8;
285
+ return v.toString(16);
286
+ });
287
+
288
+ // libs/embed-libs/embed/src/lib/shared/helpers/iframe-url.ts
289
+ var createIframeUrl = (dashboardContent) => {
290
+ const searchString = [];
291
+ const {
292
+ appServer,
293
+ language,
294
+ editorLanguage,
295
+ loaderBackground,
296
+ loaderSpinnerColor,
297
+ loaderSpinnerBackground,
298
+ loaderFontColor,
299
+ screenMode,
300
+ key,
301
+ token,
302
+ timezoneId,
303
+ itemEmbedding,
304
+ itemDimensions,
305
+ dashboardId,
306
+ dashboardSlug,
307
+ itemId,
308
+ theme,
309
+ mainColor,
310
+ editMode
311
+ } = dashboardContent.params;
312
+ if (language && language !== "auto") {
313
+ searchString.push(`language=${language}`);
314
+ }
315
+ if (editorLanguage && editorLanguage !== "auto") {
316
+ searchString.push(`editorLanguage=${editorLanguage}`);
317
+ }
318
+ if (loaderBackground) {
319
+ searchString.push(`ldrbg=${loaderBackground}`);
320
+ }
321
+ if (loaderFontColor) {
322
+ searchString.push(`ldrftclr=${loaderFontColor}`);
323
+ }
324
+ if (loaderSpinnerColor) {
325
+ searchString.push(`ldrspclr=${loaderSpinnerColor}`);
326
+ }
327
+ if (loaderSpinnerBackground) {
328
+ searchString.push(`ldrspbg=${loaderSpinnerBackground}`);
329
+ }
330
+ if (theme) {
331
+ searchString.push(`theme=${theme}`);
332
+ }
333
+ if (mainColor) {
334
+ searchString.push(`mainColor=${mainColor}`);
335
+ }
336
+ if (screenMode && screenMode !== "auto") {
337
+ searchString.push(`screenMode=${screenMode}`);
338
+ }
339
+ if (timezoneId) {
340
+ searchString.push("timezoneId=" + timezoneId);
341
+ }
342
+ if (itemEmbedding && itemDimensions && itemDimensions.width) {
343
+ searchString.push("width=" + itemDimensions.width);
344
+ }
345
+ if (itemEmbedding && itemDimensions && itemDimensions.height) {
346
+ searchString.push("height=" + itemDimensions.height);
347
+ }
348
+ if (editMode) {
349
+ searchString.push("editMode=" + editMode);
350
+ }
351
+ const keyTokenUrlAnchor = key && token ? "#" + key + ":" + token : "";
352
+ searchString.push("version=" + (dashboardContent.libVersion || VERSION));
353
+ const appServerWithSlash = addTrailingSlash(appServer);
354
+ const iframeUrl = itemEmbedding ? `${appServerWithSlash}i/${dashboardId || dashboardSlug}/${itemId}?${encodeURIComponent(
355
+ searchString.join("&")
356
+ )}${keyTokenUrlAnchor}` : `${appServerWithSlash}i/${dashboardId || dashboardSlug}?${encodeURIComponent(
357
+ searchString.join("&")
358
+ )}${keyTokenUrlAnchor}`;
359
+ return sanitizeUrl(iframeUrl);
360
+ };
361
+
362
+ // libs/embed-libs/embed/src/lib/shared/helpers/get-loader.ts
363
+ var getLoader = (dashboardComponent) => {
364
+ let errorMsg;
365
+ if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
366
+ dashboardComponent.params.error = true;
367
+ if (dashboardComponent.browserNotSupported) {
368
+ errorMsg = "Browser is not supported.";
369
+ }
370
+ }
371
+ const loadingMsg = translations_default.initializing[dashboardComponent.params.language] || translations_default.initializing.en;
372
+ return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
373
+ };
374
+
375
+ // libs/embed-libs/embed/src/lib/shared/helpers/promise-dispatch.ts
376
+ function resolvePromise(dashboardComponent, requestId, data) {
377
+ if (dashboardComponent.promises[requestId]) {
378
+ dashboardComponent.promises[requestId].resolve(data);
379
+ delete dashboardComponent.promises[requestId];
380
+ }
381
+ }
382
+ function rejectPromise(dashboardComponent, requestId, data) {
383
+ if (dashboardComponent.promises[requestId]) {
384
+ dashboardComponent.promises[requestId].reject(data);
385
+ delete dashboardComponent.promises[requestId];
386
+ }
387
+ }
388
+
389
+ // libs/embed-libs/embed/src/lib/shared/helpers/styles.ts
390
+ function containerStyles(dashboardComponent) {
391
+ const styles = {};
392
+ if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
393
+ styles.background = dashboardComponent.params.loaderBackground;
394
+ }
395
+ return styles;
396
+ }
397
+ function containerLoaderStyles(dashboardComponent) {
398
+ const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
399
+ const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
400
+ const display = dashboardComponent.iframeLoaded ? "none" : "";
401
+ return {
402
+ display,
403
+ height: `${chartHeightDefined ? height : dashboardComponent.minHeight}px`
404
+ };
405
+ }
406
+ function loaderStyles(dashboardComponent) {
407
+ const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
408
+ if (dashboardComponent.params.itemEmbedding) {
409
+ dashboardComponent.loaderSize = 24;
410
+ dashboardComponent.borderWidth = 4;
411
+ dashboardComponent.minHeight = 200;
412
+ const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
413
+ const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
414
+ const chartWidthDefined = width !== "auto";
415
+ const chartHeightDefined = height !== "auto";
416
+ return {
417
+ background,
418
+ width: chartWidthDefined ? `${width}px` : "100%",
419
+ height: `${chartHeightDefined ? height : "200"}px`,
420
+ "min-height": chartHeightDefined ? "" : "200px"
421
+ };
422
+ }
423
+ return {
424
+ background
425
+ };
426
+ }
427
+ function generateBorderStyle(borderWidth, color) {
428
+ return `${borderWidth}px solid ${color}`;
429
+ }
430
+ function plStyles(dashboardComponent) {
431
+ const {
432
+ loaderSpinnerColor: defaultSpinnerColor,
433
+ loaderSpinnerBackground: defaultSpinnerBackground
434
+ } = DEFAULT_PARAMETERS;
435
+ const spinnerColorBorder = generateBorderStyle(
436
+ dashboardComponent.borderWidth,
437
+ dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
438
+ );
439
+ const spinnerBackgroundBorder = generateBorderStyle(
440
+ dashboardComponent.borderWidth,
441
+ dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
442
+ );
443
+ const size = `${dashboardComponent.loaderSize}px`;
444
+ return {
445
+ "border-top": spinnerColorBorder,
446
+ "border-right": spinnerColorBorder,
447
+ "border-bottom": spinnerBackgroundBorder,
448
+ "border-left": spinnerBackgroundBorder,
449
+ width: size,
450
+ height: size
451
+ };
452
+ }
453
+ function lcStyles(dashboardComponent) {
454
+ const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
455
+ const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
456
+ const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
457
+ const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
458
+ return {
459
+ padding: `${verticalPadding} 16px`
460
+ };
461
+ }
462
+ function calculateIframeStyles(dashboardComponent) {
463
+ const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
464
+ const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
465
+ if (dashboardComponent.params.itemEmbedding && height !== "auto") {
466
+ dashboardComponent.iframeHeight = `${height}px`;
467
+ } else if (dashboardComponent.params.itemEmbedding) {
468
+ dashboardComponent.iframeHeight = "200px";
469
+ } else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
470
+ dashboardComponent.iframeHeight = "100%";
471
+ } else {
472
+ dashboardComponent.iframeHeight = "400px";
473
+ }
474
+ dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
475
+ const styles = {
476
+ height: dashboardComponent.iframeHeight,
477
+ width: dashboardComponent.iframeWidth
478
+ };
479
+ if (dashboardComponent.iframeLoaded) {
480
+ styles.opacity = 1;
481
+ } else if (dashboardComponent.error) {
482
+ styles.opacity = 1;
483
+ styles.width = "100%";
484
+ styles.height = "400px";
485
+ } else {
486
+ styles.opacity = 0;
487
+ }
488
+ return styles;
489
+ }
490
+
491
+ // libs/embed-libs/embed/src/lib/shared/helpers/update-iframe-url.ts
492
+ var updateIframeUrl = (iframe, iframeUrl) => {
493
+ if (iframe?.contentWindow) {
494
+ iframe.contentWindow.location.replace(iframeUrl);
495
+ }
496
+ };
497
+
498
+ // libs/embed-libs/embed/src/lib/shared/helpers/set-selected-data-utils.ts
499
+ var selectedDataUtils = {
500
+ merge(...filters) {
501
+ return filters.reduce((acc, filter) => {
502
+ acc.and.push(...filter.and);
503
+ return acc;
504
+ }, {
505
+ and: []
506
+ });
507
+ },
508
+ isIn(slot, values, otherOptions) {
509
+ return {
510
+ and: [{
511
+ expression: "? in ?",
512
+ parameters: [
513
+ {
514
+ slot,
515
+ ...otherOptions
516
+ },
517
+ values
518
+ ]
519
+ }]
520
+ };
521
+ },
522
+ between(slot, values, otherOptions) {
523
+ return {
524
+ and: [{
525
+ expression: "? between ?",
526
+ parameters: [
527
+ {
528
+ slot,
529
+ ...otherOptions
530
+ },
531
+ [values[0], values[1]]
532
+ ]
533
+ }]
534
+ };
535
+ },
536
+ range(slot, values, otherOptions) {
537
+ const expressions = otherOptions?.expressions ?? ["? >= ?", "? < ?"];
538
+ return {
539
+ and: [{
540
+ expression: expressions[0],
541
+ parameters: [
542
+ {
543
+ slot,
544
+ ...otherOptions
545
+ },
546
+ [values[0]]
547
+ ]
548
+ }, {
549
+ expression: expressions[1],
550
+ parameters: [
551
+ {
552
+ slot,
553
+ ...otherOptions
554
+ },
555
+ [values[1]]
556
+ ]
557
+ }]
558
+ };
559
+ }
560
+ };
561
+
562
+ // libs/embed-libs/embed/src/lib/shared/methods/export-dashboard.ts
563
+ var exportDashboard = (dashboardComponent, iframe, format) => {
564
+ const requestId = uuidv4();
565
+ if (iframe?.contentWindow) {
566
+ iframe.contentWindow.postMessage(
567
+ {
568
+ action: "exportDashboard",
569
+ format: format || "png",
570
+ _version: dashboardComponent.libVersion,
571
+ requestId
572
+ },
573
+ "*"
574
+ );
575
+ return new Promise((resolve, reject) => {
576
+ dashboardComponent.promises[requestId] = { resolve, reject };
577
+ setTimeout(() => {
578
+ if (dashboardComponent.promises[requestId]) {
579
+ const errorMessage = "exportDashboard request timed out.";
580
+ dashboardComponent.promises[requestId].reject(
581
+ new Error(errorMessage)
582
+ );
583
+ delete dashboardComponent.promises[requestId];
584
+ }
585
+ }, 12e5);
586
+ });
587
+ }
588
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
589
+ };
590
+
591
+ // libs/embed-libs/embed/src/lib/shared/methods/get-accessible-dashboards.ts
592
+ var getAccessibleDashboards = async (dashboardComponent) => {
593
+ await dashboardComponent.updateComplete;
594
+ if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
595
+ const fetchUser = new Promise((resolve, reject) => {
596
+ void (() => {
597
+ try {
598
+ const responsePromise = window.fetch(
599
+ // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
600
+ // Fixes incorrect url with embedMode="webComponent"
601
+ `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/authorization`,
602
+ {
603
+ method: "POST",
604
+ mode: "cors",
605
+ cache: "no-cache",
606
+ headers: { "Content-Type": "application/json" },
607
+ redirect: "follow",
608
+ body: JSON.stringify({
609
+ action: "get",
610
+ version: "0.1.0",
611
+ key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
612
+ token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
613
+ find: {
614
+ where: { id: dashboardComponent.authKey },
615
+ attributes: ["id", "integration_id"],
616
+ include: [
617
+ {
618
+ model: "User",
619
+ attributes: ["id", "name", "locale_id"],
620
+ include: [{ model: "Group" }]
621
+ }
622
+ ]
623
+ }
624
+ })
625
+ }
626
+ );
627
+ responsePromise.then((response) => response.json()).then((data) => {
628
+ if (!data || !data.rows || data.rows.length === 0 || !data.rows[0].user) {
629
+ reject("Authorization failed, please check authKey and authToken. If the problem persists, please contact support@luzmo.com.");
630
+ } else {
631
+ data.rows[0].user.userGroups = data.rows[0].user.groups.map(
632
+ (group) => group.id
633
+ );
634
+ delete data.rows[0].user.groups;
635
+ resolve({
636
+ integrationId: data.rows[0].integration_id,
637
+ user: data.rows[0].user
638
+ });
639
+ }
640
+ });
641
+ } catch (error) {
642
+ reject(error);
643
+ }
644
+ })();
645
+ });
646
+ return new Promise((resolve, reject) => void (() => {
647
+ try {
648
+ fetchUser.then((authorizationData) => {
649
+ const responsePromise = window.fetch(
650
+ // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
651
+ // Fixes incorrect url with embedMode="webComponent"
652
+ `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/securable`,
653
+ {
654
+ method: "POST",
655
+ mode: "cors",
656
+ cache: "no-cache",
657
+ headers: { "Content-Type": "application/json" },
658
+ redirect: "follow",
659
+ body: JSON.stringify({
660
+ action: "get",
661
+ version: "0.1.0",
662
+ key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
663
+ token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
664
+ find: {
665
+ where: { type: "dashboard", is_variant: false },
666
+ attributes: ["id", "name", "modified_at"],
667
+ order: [["modified_at", "desc"]],
668
+ include: [
669
+ { model: "Tag", attributes: ["tag"] },
670
+ { model: "User", attributes: ["id", "name"] },
671
+ {
672
+ model: "Group",
673
+ attributes: ["id", "name", "public"]
674
+ },
675
+ { model: "Integration", attributes: ["id", "name"] }
676
+ ]
677
+ }
678
+ })
679
+ }
680
+ );
681
+ responsePromise.then((response) => response.json()).then((data) => {
682
+ const dashboardList = data.rows.length > 0 ? formatDashboardList(
683
+ data.rows,
684
+ authorizationData.integrationId,
685
+ authorizationData.user,
686
+ dashboardComponent
687
+ ) : [];
688
+ resolve(dashboardList);
689
+ });
690
+ }).catch((error) => {
691
+ reject(error);
692
+ });
693
+ } catch (error) {
694
+ reject(error);
695
+ }
696
+ })());
697
+ }
698
+ throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
699
+ };
700
+
701
+ // libs/embed-libs/embed/src/lib/shared/methods/get-dashboard-context.ts
702
+ var getDashboardContext = (dashboardComponent, iframe) => {
703
+ if (iframe?.contentWindow) {
704
+ const requestId = uuidv4();
705
+ iframe.contentWindow.postMessage(
706
+ { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
707
+ "*"
708
+ );
709
+ return new Promise((resolve, reject) => {
710
+ dashboardComponent.promises[requestId] = { resolve, reject };
711
+ setTimeout(() => {
712
+ if (dashboardComponent.promises[requestId]) {
713
+ const errorMessage = "getDashboardContext request timed out.";
714
+ dashboardComponent.promises[requestId].reject(
715
+ new Error(errorMessage)
716
+ );
717
+ delete dashboardComponent.promises[requestId];
718
+ }
719
+ }, 2e3);
720
+ });
721
+ }
722
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
723
+ };
724
+
725
+ // libs/embed-libs/embed/src/lib/shared/methods/get-data.ts
726
+ var getData = (dashboardComponent, iframe, itemId) => {
727
+ if (iframe?.contentWindow) {
728
+ const requestId = uuidv4();
729
+ iframe.contentWindow.postMessage(
730
+ {
731
+ action: "getData",
732
+ id: itemId,
733
+ _version: dashboardComponent.libVersion,
734
+ requestId
735
+ },
736
+ "*"
737
+ );
738
+ return new Promise((resolve, reject) => {
739
+ dashboardComponent.promises[requestId] = { resolve, reject };
740
+ setTimeout(() => {
741
+ if (dashboardComponent.promises[requestId]) {
742
+ const errorMessage = "getData request timed out.";
743
+ dashboardComponent.promises[requestId].reject(
744
+ new Error(errorMessage)
745
+ );
746
+ delete dashboardComponent.promises[requestId];
747
+ }
748
+ }, 2e3);
749
+ });
750
+ }
751
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
752
+ };
753
+
754
+ // libs/embed-libs/embed/src/lib/shared/methods/get-filters.ts
755
+ var getFilters = (dashboardComponent, iframe) => {
756
+ if (iframe?.contentWindow) {
757
+ const requestId = uuidv4();
758
+ iframe.contentWindow.postMessage(
759
+ { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
760
+ "*"
761
+ );
762
+ return new Promise((resolve, reject) => {
763
+ dashboardComponent.promises[requestId] = { resolve, reject };
764
+ setTimeout(() => {
765
+ if (dashboardComponent.promises[requestId]) {
766
+ const errorMessage = "getFilters request timed out.";
767
+ dashboardComponent.promises[requestId].reject(
768
+ new Error(errorMessage)
769
+ );
770
+ delete dashboardComponent.promises[requestId];
771
+ }
772
+ }, 2e3);
773
+ });
774
+ }
775
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
776
+ };
777
+
778
+ // libs/embed-libs/embed/src/lib/shared/methods/get-insights.ts
779
+ var getInsights = (dashboardComponent, iframe, options = {}) => {
780
+ if (!iframe?.contentWindow) {
781
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
782
+ }
783
+ const requestId = uuidv4();
784
+ iframe.contentWindow.postMessage(
785
+ {
786
+ action: "getInsights",
787
+ options,
788
+ _version: dashboardComponent.libVersion,
789
+ requestId
790
+ },
791
+ "*"
792
+ );
793
+ return new Promise((resolve, reject) => {
794
+ dashboardComponent.promises[requestId] = { resolve, reject };
795
+ setTimeout(() => {
796
+ if (dashboardComponent.promises[requestId]) {
797
+ dashboardComponent.promises[requestId].reject(new Error("getInsights request timed out."));
798
+ delete dashboardComponent.promises[requestId];
799
+ }
800
+ }, 6e4);
801
+ });
802
+ };
803
+
804
+ // libs/embed-libs/embed/src/lib/shared/methods/refresh-data.ts
805
+ var refreshData = (dashboardComponent, iframe, itemId) => {
806
+ if (iframe) {
807
+ iframe.contentWindow.postMessage(
808
+ {
809
+ action: "refreshData",
810
+ id: itemId ?? null,
811
+ _version: dashboardComponent.libVersion
812
+ },
813
+ "*"
814
+ );
815
+ return Promise.resolve();
816
+ }
817
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
818
+ };
819
+
820
+ // libs/embed-libs/embed/src/lib/shared/methods/reload-dashboard.ts
821
+ var reloadDashboard = (dashboardComponent, iframe) => {
822
+ if (iframe) {
823
+ iframe.contentWindow.postMessage(
824
+ { action: "reloadDashboard", _version: dashboardComponent.libVersion },
825
+ "*"
826
+ );
827
+ return Promise.resolve();
828
+ }
829
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
830
+ };
831
+
832
+ // libs/embed-libs/embed/src/lib/shared/methods/send-export-email.ts
833
+ var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
834
+ if (iframe) {
835
+ iframe.contentWindow.postMessage(
836
+ {
837
+ action: "sendExportEmail",
838
+ type: type || "once",
839
+ subject,
840
+ message,
841
+ _version: dashboardComponent.libVersion
842
+ },
843
+ "*"
844
+ );
845
+ return Promise.resolve();
846
+ }
847
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
848
+ };
849
+
850
+ // libs/embed-libs/embed/src/lib/shared/methods/set-authorization.ts
851
+ var setAuthorization = (dashboardComponent, iframe, key, token) => {
852
+ if (iframe) {
853
+ iframe.contentWindow.postMessage(
854
+ {
855
+ action: "setAuthorization",
856
+ key,
857
+ token,
858
+ _version: dashboardComponent.libVersion
859
+ },
860
+ "*"
861
+ );
862
+ return Promise.resolve();
863
+ }
864
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
865
+ };
866
+
867
+ // libs/embed-libs/embed/src/lib/shared/methods/set-edit-mode.ts
868
+ var setEditMode = (dashboardComponent, iframe, editMode) => {
869
+ if (iframe && iframe.contentWindow) {
870
+ const requestId = uuidv4();
871
+ if (dashboardComponent.params.editMode === editMode) {
872
+ return Promise.reject(
873
+ new Error("editMode parameter is currently already set to " + editMode)
874
+ );
875
+ } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
876
+ return Promise.reject(
877
+ new Error(
878
+ "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
879
+ )
880
+ );
881
+ }
882
+ iframe.contentWindow.postMessage(
883
+ {
884
+ action: "setEditMode",
885
+ editMode,
886
+ _version: dashboardComponent.libVersion,
887
+ requestId
888
+ },
889
+ "*"
890
+ );
891
+ return new Promise((resolve, reject) => {
892
+ dashboardComponent.promises[requestId] = { resolve, reject };
893
+ });
894
+ }
895
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
896
+ };
897
+
898
+ // libs/embed-libs/embed/src/lib/shared/methods/set-preview.ts
899
+ var setPreview = (dashboardComponent, iframe, preview) => {
900
+ if (iframe) {
901
+ const requestId = uuidv4();
902
+ iframe.contentWindow.postMessage(
903
+ {
904
+ action: "setPreview",
905
+ preview,
906
+ requestId,
907
+ _version: dashboardComponent.libVersion
908
+ },
909
+ "*"
910
+ );
911
+ return new Promise((resolve, reject) => {
912
+ dashboardComponent.promises[requestId] = { resolve, reject };
913
+ setTimeout(() => {
914
+ if (dashboardComponent.promises[requestId]) {
915
+ const errorMessage = "setPreview request timed out.";
916
+ dashboardComponent.promises[requestId].reject(
917
+ new Error(errorMessage)
918
+ );
919
+ delete dashboardComponent.promises[requestId];
920
+ }
921
+ }, 2e3);
922
+ });
923
+ }
924
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
925
+ };
926
+
927
+ // libs/embed-libs/embed/src/lib/shared/methods/set-selected-data.ts
928
+ var setSelectedData = (dashboardComponent, iframe, itemId, filters) => {
929
+ if (iframe) {
930
+ const requestId = uuidv4();
931
+ iframe.contentWindow.postMessage(
932
+ {
933
+ action: "setSelectedData",
934
+ itemId,
935
+ filters,
936
+ _version: dashboardComponent.libVersion,
937
+ requestId
938
+ },
939
+ "*"
940
+ );
941
+ return new Promise((resolve, reject) => {
942
+ dashboardComponent.promises[requestId] = { resolve, reject };
943
+ setTimeout(() => {
944
+ if (dashboardComponent.promises[requestId]) {
945
+ const errorMessage = "setSelectedData request timed out.";
946
+ dashboardComponent.promises[requestId].reject(
947
+ new Error(errorMessage)
948
+ );
949
+ delete dashboardComponent.promises[requestId];
950
+ }
951
+ }, 2e3);
952
+ });
953
+ }
954
+ return Promise.reject();
955
+ };
956
+
957
+ // libs/embed-libs/embed/src/lib/shared/service/calculate-dimensions.ts
958
+ var _setCalculatedDimensions = (dashboardComponent) => {
959
+ if (!dashboardComponent.dimensions) {
960
+ dashboardComponent.params.error = true;
961
+ _handleError("Got no valid dimensions.", dashboardComponent.params);
962
+ return;
963
+ }
964
+ const dashboardDimensionKeys = Object.keys(
965
+ dashboardComponent.dimensions
966
+ );
967
+ const availableScreenModeExtents = [];
968
+ let currentMode;
969
+ let currentWidth = 0;
970
+ let currentHeight = 0;
971
+ if (!dashboardComponent.params.switchScreenModeOnResize && dashboardComponent.currentScreenMode) {
972
+ dashboardComponent.params.screenMode = dashboardComponent.currentScreenMode;
973
+ }
974
+ if (dashboardComponent.dimensions && dashboardDimensionKeys?.[0] === "fixed") {
975
+ currentMode = "fixed";
976
+ currentWidth = dashboardComponent.dimensions.fixed[0];
977
+ currentHeight = dashboardComponent.dimensions.fixed[1];
978
+ } else {
979
+ const screenModes = [
980
+ "mobile",
981
+ "tablet",
982
+ "desktop",
983
+ "largeScreen"
984
+ ];
985
+ if (dashboardComponent.params.itemEmbedding) {
986
+ const [firstMatch] = dashboardDimensionKeys;
987
+ let match = firstMatch;
988
+ for (const screenMode of screenModes) {
989
+ const found = dashboardDimensionKeys.find((key) => key === screenMode);
990
+ if (found) {
991
+ match = found;
992
+ } else {
993
+ dashboardComponent.dimensions[screenMode] = dashboardComponent.dimensions[match];
994
+ }
995
+ }
996
+ }
997
+ for (const key of dashboardDimensionKeys) {
998
+ if (screenModes.includes(key)) {
999
+ const screenMode = EXTENTS.find((extent) => extent.mode === key);
1000
+ availableScreenModeExtents.push({
1001
+ ...screenMode,
1002
+ height: dashboardComponent.dimensions[key][1] || 50
1003
+ });
1004
+ }
1005
+ }
1006
+ if (!availableScreenModeExtents.map((screenModeExtent) => screenModeExtent.mode).includes(dashboardComponent.params.screenMode)) {
1007
+ dashboardComponent.params.screenMode = "auto";
1008
+ }
1009
+ if (dashboardComponent.params.screenMode === "auto") {
1010
+ availableScreenModeExtents.sort(
1011
+ (a, b) => screenModes.indexOf(a.mode) - screenModes.indexOf(b.mode)
1012
+ );
1013
+ for (const screenModeExtent of availableScreenModeExtents) {
1014
+ const [screenModeExtentMinWidth, screenModeExtentMaxWidth] = screenModeExtent.width;
1015
+ if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
1016
+ if (screenModeExtentMinWidth < dashboardComponent.params.itemDimensions.width) {
1017
+ currentMode = screenModeExtent.mode;
1018
+ currentWidth = Number.parseInt(
1019
+ dashboardComponent.params.itemDimensions.width,
1020
+ 10
1021
+ );
1022
+ currentHeight = dashboardComponent.dimensions[currentMode][1];
1023
+ }
1024
+ } else {
1025
+ if (screenModeExtentMinWidth < dashboardComponent.containerWidth) {
1026
+ currentMode = screenModeExtent.mode;
1027
+ if (dashboardComponent.params.itemEmbedding) {
1028
+ currentWidth = dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto" ? Number.parseInt(
1029
+ dashboardComponent.params.itemDimensions.width,
1030
+ 10
1031
+ ) : Math.min(
1032
+ dashboardComponent.containerWidth,
1033
+ screenModeExtentMaxWidth
1034
+ );
1035
+ currentHeight = dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto" ? Number.parseInt(
1036
+ dashboardComponent.params.itemDimensions.height,
1037
+ 10
1038
+ ) : dashboardComponent.dimensions[currentMode][1];
1039
+ if (dashboardComponent.params.itemDimensions && dashboardComponent.params.itemDimensions.width !== "auto" && dashboardComponent.params.itemDimensions.height === "auto") {
1040
+ currentWidth = Number.parseInt(
1041
+ dashboardComponent.params.itemDimensions.width,
1042
+ 10
1043
+ );
1044
+ currentHeight = dashboardComponent.dimensions[currentMode][1];
1045
+ }
1046
+ } else {
1047
+ currentWidth = Math.max(
1048
+ Math.min(
1049
+ screenModeExtentMaxWidth,
1050
+ dashboardComponent.containerWidth
1051
+ ),
1052
+ screenModeExtentMinWidth
1053
+ );
1054
+ currentHeight = screenModeExtent.height;
1055
+ }
1056
+ }
1057
+ }
1058
+ }
1059
+ } else {
1060
+ const {
1061
+ height: chosenModeHeight,
1062
+ width: [chosenModeMinWidth, chosenModeMaxWidth]
1063
+ } = availableScreenModeExtents.find(
1064
+ (d) => d.mode === dashboardComponent.params.screenMode
1065
+ );
1066
+ currentMode = dashboardComponent.params.screenMode;
1067
+ currentWidth = Math.max(
1068
+ Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
1069
+ chosenModeMinWidth
1070
+ );
1071
+ currentHeight = chosenModeHeight;
1072
+ if (dashboardComponent.params.itemEmbedding) {
1073
+ if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
1074
+ currentWidth = Number.parseInt(
1075
+ dashboardComponent.params.itemDimensions.width,
1076
+ 10
1077
+ );
1078
+ }
1079
+ if (dashboardComponent.params.itemDimensions?.height && dashboardComponent.params.itemDimensions?.height !== "auto") {
1080
+ currentHeight = Number.parseInt(
1081
+ dashboardComponent.params.itemDimensions.height,
1082
+ 10
1083
+ );
1084
+ }
1085
+ }
1086
+ }
1087
+ if (!currentMode && availableScreenModeExtents.length > 0) {
1088
+ const [lowestModeExtent] = availableScreenModeExtents;
1089
+ currentMode = lowestModeExtent.mode;
1090
+ currentWidth = lowestModeExtent.width[0];
1091
+ currentHeight = lowestModeExtent.height;
1092
+ }
1093
+ }
1094
+ dashboardComponent.currentScreenMode = currentMode;
1095
+ const style = {
1096
+ height: currentHeight === 0 ? "100%" : `${String(currentHeight)}px`,
1097
+ width: currentWidth === 0 ? "100%" : `${String(currentWidth)}px`,
1098
+ opacity: 1
1099
+ };
1100
+ const dashboardEditModes = ["editFull", "editLimited"];
1101
+ if (dashboardEditModes.includes(dashboardComponent.params.editMode)) {
1102
+ style.height = "100%";
1103
+ style.width = "100%";
1104
+ } else if (dashboardComponent.params.itemEmbedding && dashboardComponent.params.itemDimensions) {
1105
+ style.height = dashboardComponent.params.itemDimensions.height === "auto" ? style.height : `${String(dashboardComponent.params.itemDimensions.height).replace(
1106
+ "px",
1107
+ ""
1108
+ )}px`;
1109
+ style.width = dashboardComponent.params.itemDimensions.width === "auto" ? style.width : `${String(dashboardComponent.params.itemDimensions.width).replace(
1110
+ "px",
1111
+ ""
1112
+ )}px`;
1113
+ } else {
1114
+ style.height = currentHeight === 0 ? "100%" : `${String(currentHeight)}px`;
1115
+ style.width = currentWidth === 0 ? "100%" : `${String(currentWidth)}px`;
1116
+ }
1117
+ dashboardComponent.currentScreenMode = currentMode;
1118
+ dashboardComponent.iframeStyle = style;
1119
+ };
1120
+
1121
+ // libs/embed-libs/embed/src/lib/shared/service/extend-and-validate.ts
1122
+ var _extendAndValidate = (dashboardContent) => {
1123
+ const defaultKeys = Object.keys(
1124
+ DEFAULT_PARAMETERS
1125
+ );
1126
+ const errorMessages = [];
1127
+ const requiredStringParams = [
1128
+ "appServer",
1129
+ "language",
1130
+ "apiHost"
1131
+ ];
1132
+ const requiredStringOrEmptyParams = [
1133
+ "key",
1134
+ "token",
1135
+ "screenMode",
1136
+ "timezoneId",
1137
+ "itemId",
1138
+ "container",
1139
+ "loaderBackground",
1140
+ "loaderFontColor",
1141
+ "loaderSpinnerColor",
1142
+ "loaderSpinnerBackground"
1143
+ ];
1144
+ const objectParams = ["itemDimensions"];
1145
+ const screenModes = [
1146
+ "mobile",
1147
+ "tablet",
1148
+ "desktop",
1149
+ "largeScreen",
1150
+ "fixed",
1151
+ "auto"
1152
+ ];
1153
+ for (const key of defaultKeys) {
1154
+ if (dashboardContent.params[key] === null) {
1155
+ delete dashboardContent.params[key];
1156
+ }
1157
+ }
1158
+ dashboardContent.params = defaultsDeep(
1159
+ dashboardContent.params,
1160
+ DEFAULT_PARAMETERS
1161
+ );
1162
+ if ((!dashboardContent.params.dashboardId || typeof dashboardContent.params.dashboardId !== "string") && (!dashboardContent.params.dashboardSlug || typeof dashboardContent.params.dashboardSlug !== "string")) {
1163
+ delete dashboardContent.params.dashboardId;
1164
+ delete dashboardContent.params.dashboardSlug;
1165
+ }
1166
+ for (const key of requiredStringParams) {
1167
+ if (typeof dashboardContent.params[key] !== "string") {
1168
+ delete dashboardContent.params[key];
1169
+ errorMessages.push(`${key} needs to be of type string.`);
1170
+ }
1171
+ }
1172
+ for (const key of requiredStringOrEmptyParams) {
1173
+ if (typeof dashboardContent.params[key] !== "string" && dashboardContent.params[key] !== null && dashboardContent.params[key] !== void 0) {
1174
+ delete dashboardContent.params[key];
1175
+ errorMessages.push(`${key} needs to be of type string or empty.`);
1176
+ }
1177
+ }
1178
+ if (dashboardContent.params.screenMode && !screenModes.includes(dashboardContent.params.screenMode)) {
1179
+ const validTypesString = screenModes.map((mode) => `"${mode}"`).join(", ");
1180
+ errorMessages.push(
1181
+ `"screenMode" needs should be one of these types: ${validTypesString}`
1182
+ );
1183
+ dashboardContent.params.screenMode = "auto";
1184
+ }
1185
+ if (dashboardContent.params.itemId) {
1186
+ dashboardContent.params.itemEmbedding = true;
1187
+ }
1188
+ for (const key of objectParams) {
1189
+ if (typeof dashboardContent.params[key] !== "object" && dashboardContent.params[key] !== null) {
1190
+ delete dashboardContent.params[key];
1191
+ errorMessages.push(`${key} needs to be of type object or empty.`);
1192
+ }
1193
+ }
1194
+ if (typeof dashboardContent.params.switchScreenModeOnResize !== "boolean") {
1195
+ errorMessages.push("switchScreenModeOnResize needs to be of type boolean.");
1196
+ dashboardContent.params.switchScreenModeOnResize = true;
1197
+ }
1198
+ if (dashboardContent.params.itemDimensions) {
1199
+ const itemDimensionsKeys = [
1200
+ "width",
1201
+ "height"
1202
+ ];
1203
+ for (const key of itemDimensionsKeys) {
1204
+ if (!["string", "number"].includes(
1205
+ typeof dashboardContent.params.itemDimensions[key]
1206
+ ) && dashboardContent.params.itemDimensions[key] !== null) {
1207
+ errorMessages.push(
1208
+ `itemDimensions ${key} needs to be of type string, number or empty.`
1209
+ );
1210
+ }
1211
+ }
1212
+ }
1213
+ dashboardContent.params = defaultsDeep(
1214
+ dashboardContent.params,
1215
+ DEFAULT_PARAMETERS
1216
+ );
1217
+ if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
1218
+ dashboardContent.params.switchScreenModeOnResize = false;
1219
+ }
1220
+ if (dashboardContent.params.itemDimensions.width !== "auto") {
1221
+ dashboardContent.params.itemDimensions.width = Number.parseInt(
1222
+ `${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
1223
+ 10
1224
+ ) || "auto";
1225
+ }
1226
+ if (dashboardContent.params.itemDimensions.height !== "auto") {
1227
+ dashboardContent.params.itemDimensions.height = Number.parseInt(
1228
+ `${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
1229
+ 10
1230
+ ) || "auto";
1231
+ }
1232
+ dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
1233
+ if (dashboardContent.params.error || errorMessages.length > 0) {
1234
+ _handleError(errorMessages.join("\n"), dashboardContent.params);
1235
+ }
1236
+ };
1237
+
1238
+ // libs/embed-libs/embed/src/lib/shared/models/viz-item.model.ts
1239
+ var libraryTypeToWebComponentTypeMapping = {
1240
+ type: "type",
1241
+ slots: "slots",
1242
+ options: "options",
1243
+ appServer: "app-server",
1244
+ apiHost: "api-host",
1245
+ authKey: "auth-key",
1246
+ authToken: "auth-token",
1247
+ contextId: "context-id",
1248
+ canFilter: "can-filter",
1249
+ filters: "filters",
1250
+ dashboardId: "dashboard-id",
1251
+ itemId: "item-id",
1252
+ aiMessageAssetId: "ai-message-asset-id",
1253
+ dashboardContentsVersion: "dashboard-contents-version",
1254
+ libVersion: "lib-version"
1255
+ };
1256
+ var libraryAcceptedParametersList = ["appServer", "apiHost", "options", "type", "authKey", "authToken", "slots", "filters", "canFilter", "contextId", "itemId", "dashboardId", "aiMessageAssetId", "libVersion"];
1257
+
1258
+ // libs/embed-libs/embed/src/lib/shared/constants/class-constants.ts
1259
+ var luzmoEmbedContainerClass = "luzmo-embed-container";
1260
+ export {
1261
+ DEFAULT_PARAMETERS,
1262
+ EXTENTS,
1263
+ TRANSLATIONS,
1264
+ VERSION,
1265
+ _browserCheck,
1266
+ _extendAndValidate,
1267
+ _handleError,
1268
+ _setCalculatedDimensions,
1269
+ addTrailingSlash,
1270
+ calculateIframeStyles,
1271
+ cloneDeep,
1272
+ containerLoaderStyles,
1273
+ containerStyles,
1274
+ createIframeUrl,
1275
+ defaultsDeep,
1276
+ exportDashboard,
1277
+ formatDashboardList,
1278
+ getAccessibleDashboards,
1279
+ getDashboardContext,
1280
+ getData,
1281
+ getFilters,
1282
+ getInsights,
1283
+ getLoader,
1284
+ lcStyles,
1285
+ libraryAcceptedParametersList,
1286
+ libraryTypeToWebComponentTypeMapping,
1287
+ loaderStyles,
1288
+ luzmoEmbedContainerClass,
1289
+ plStyles,
1290
+ refreshData,
1291
+ rejectPromise,
1292
+ reloadDashboard,
1293
+ removeTrailingSlash,
1294
+ resolvePromise,
1295
+ s4,
1296
+ sanitizeUrl,
1297
+ selectedDataUtils,
1298
+ sendExportEmail,
1299
+ setAuthorization,
1300
+ setEditMode,
1301
+ setPreview,
1302
+ setSelectedData,
1303
+ updateIframeUrl,
1304
+ uuidv4
1305
+ };