@m4l/components 0.1.65 → 0.1.66

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 (58) hide show
  1. package/components/CommonActions/components/ActionCancel/{index.0f471356.js → index.4d0333c0.js} +1 -1
  2. package/components/CommonActions/components/ActionFormCancel/{index.4d2f599e.js → index.298e0109.js} +10 -15
  3. package/components/CommonActions/components/ActionFormIntro/{index.0eed3ba3.js → index.b45922ff.js} +1 -1
  4. package/components/CommonActions/components/ActionIntro/{index.41a598d6.js → index.138101aa.js} +2 -2
  5. package/components/CommonActions/components/Actions/{index.3b882471.js → index.77574633.js} +11 -15
  6. package/components/DataGrid/{index.dc84293a.js → index.ef23d0a9.js} +18 -22
  7. package/components/DynamicFilter/{index.abc697c7.js → index.04ed3d58.js} +28 -32
  8. package/components/HelperText/{index.1a24d41b.js → index.c35dcb93.js} +8 -8
  9. package/components/Icon/{index.6938827f.js → index.fbeeacc8.js} +2 -2
  10. package/components/Image/{index.674024d4.js → index.77396f79.js} +1 -1
  11. package/components/LanguagePopover/{index.47aa8119.js → index.c0fc94c7.js} +9 -9
  12. package/components/ModalDialog/{index.3db4480d.js → index.e600b43a.js} +5 -5
  13. package/components/NavLink/{index.0d125c6b.js → index.3f4e2417.js} +9 -9
  14. package/components/NoItemSelected/{index.1aa96110.js → index.609c3c20.js} +1 -1
  15. package/components/ObjectLogs/{index.05788334.js → index.7f93ba51.js} +14 -18
  16. package/components/PaperForm/{index.b3da0da3.js → index.fb4fa784.js} +1 -1
  17. package/components/Period/{index.a1b7b4cc.js → index.0c5bf66f.js} +12 -16
  18. package/components/Resizeable/{index.ee84ebc5.js → index.4545dd6a.js} +1 -1
  19. package/components/SideBar/{index.99ce4e06.js → index.7d970041.js} +6 -6
  20. package/components/areas/components/index.d.ts +0 -1
  21. package/components/areas/{components/AreasViewer/index.1aa4d12d.js → index.d7519516.js} +2199 -1755
  22. package/components/formatters/BooleanFormatter/{index.7b9e92f8.js → index.0edacc9b.js} +1 -1
  23. package/components/formatters/{index.01b027ad.js → index.879170b2.js} +2 -2
  24. package/components/hook-form/RHFAutocomplete/{index.73d33896.js → index.5f27e28c.js} +10 -10
  25. package/components/hook-form/RHFAutocompleteAsync/{index.21f4cb53.js → index.35e17cd6.js} +2 -2
  26. package/components/hook-form/RHFCheckbox/{index.c3b1884b.js → index.4f134f09.js} +3 -3
  27. package/components/hook-form/RHFPeriod/{index.cc624bb3.js → index.dcaa0c87.js} +2 -2
  28. package/components/hook-form/RHFTextField/{index.15659666.js → index.fc90a570.js} +6 -6
  29. package/components/hook-form/RHFUpload/{index.ecf5c788.js → index.654ad316.js} +1 -1
  30. package/components/modal/{WindowBase.1b0657de.js → WindowBase.230a498f.js} +3 -3
  31. package/components/modal/{WindowConfirm.60028bce.js → WindowConfirm.575b4d41.js} +14 -18
  32. package/components/modal/index.237881ea.js +23 -0
  33. package/components/mui_extended/Accordion/{index.95a1b021.js → index.0b15f939.js} +2 -2
  34. package/components/mui_extended/Button/{index.e4c61b66.js → index.b7b70e5f.js} +3 -3
  35. package/components/mui_extended/IconButton/{index.78a489d3.js → index.a5072cd3.js} +1 -1
  36. package/components/mui_extended/MenuActions/{index.742a57d7.js → index.3a275abb.js} +2 -2
  37. package/components/mui_extended/Pager/{index.a44594e9.js → index.5a69ab10.js} +1 -1
  38. package/components/mui_extended/Typography/{index.86505aed.js → index.eab3d85c.js} +1 -1
  39. package/components/mui_extended/index.35f74599.js +19 -0
  40. package/contexts/ModalContext/{index.bfc47ba9.js → index.de0a3457.js} +1 -1
  41. package/hooks/useModal/{index.979ab2ea.js → index.e103db09.js} +1 -1
  42. package/index.js +89 -98
  43. package/package.json +1 -1
  44. package/{react-draggable.d6441025.js → react-draggable.4d08d714.js} +1 -1
  45. package/{react-resizable.79fb7404.js → react-resizable.23b980cb.js} +3 -3
  46. package/utils/{index.64775c34.js → index.c2e62d8f.js} +1 -1
  47. package/{vendor.2d9f95b4.js → vendor.be57c149.js} +40 -47
  48. package/components/areas/components/AreasAdmin/index.46fab65b.js +0 -135
  49. package/components/areas/components/index.9de77fae.js +0 -12
  50. package/components/areas/contexts/AreasContext/index.b3b26965.js +0 -231
  51. package/components/areas/contexts/DynamicMFParmsContext/index.5b3248df.js +0 -43
  52. package/components/areas/contexts/index.4ebef035.js +0 -21
  53. package/components/areas/hooks/index.ffb1009e.js +0 -28
  54. package/components/areas/hooks/useArea/index.c7e4f3fc.js +0 -34
  55. package/components/areas/hooks/useDynamicMFParameters/index.9a25f88a.js +0 -14
  56. package/components/areas/index.bfe6bf91.js +0 -46
  57. package/components/modal/index.fde6acc3.js +0 -27
  58. package/components/mui_extended/index.61356a6a.js +0 -19
@@ -1,86 +1,93 @@
1
- import { styled } from "@mui/material/styles";
2
- import { r as react_resizable_css } from "../../../../react-resizable.79fb7404.js";
3
- import { generateUtilityClasses, Skeleton, styled as styled$1, Typography as Typography$1, Dialog } from "@mui/material";
4
- import { unstable_composeClasses } from "@mui/base";
5
- import { g as getComponentUtilityClass } from "../../../../utils/index.64775c34.js";
6
- import { a as AREAS_VIEWER_CLASS_NAME, g as getAreasDictionary, I as ICONS } from "../../index.bfe6bf91.js";
7
- import React__default, { createContext, useRef, useEffect, useMemo, useState, useCallback } from "react";
1
+ import { I as IconButton } from "../mui_extended/IconButton/index.a5072cd3.js";
2
+ import { useHostTools, useModuleDictionary, useNetwork, useModuleSkeleton, EmitEvents, useEnvironment, axiosOperation } from "@m4l/core";
8
3
  import { shallow } from "zustand/shallow";
9
- import { useNetwork, useModuleDictionary, useEnvironment, useModuleSkeleton, useHostTools, axiosOperation } from "@m4l/core";
4
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
+ import React__default, { createContext, useRef, useCallback, useEffect, useContext, useMemo, useState } from "react";
6
+ import { generateUtilityClasses, Skeleton, styled as styled$1, Typography as Typography$1, Dialog } from "@mui/material";
7
+ import { I as Icon } from "../Icon/index.fbeeacc8.js";
8
+ import clsx from "clsx";
10
9
  import { createStore, useStore } from "zustand";
11
- import { immer } from "zustand/middleware/immer";
10
+ import { useResponsiveDesktop, useFirstRender, useHostTheme, useFormatter, useLocales } from "@m4l/graphics";
12
11
  import { devtools } from "zustand/middleware";
12
+ import { immer } from "zustand/middleware/immer";
13
+ import { unstable_composeClasses } from "@mui/base";
14
+ import { g as getComponentUtilityClass } from "../../utils/index.c2e62d8f.js";
15
+ import "../mui_extended/Accordion/index.0b15f939.js";
16
+ import "../mui_extended/Avatar/index.fe06afd7.js";
17
+ import "react-router-dom";
18
+ import "@mui/material/Button";
19
+ import { B as Button } from "../mui_extended/Button/index.b7b70e5f.js";
20
+ import { I as Image } from "../Image/index.77396f79.js";
21
+ import "@mui/lab";
22
+ import { T as Typography } from "../mui_extended/Typography/index.eab3d85c.js";
23
+ import "../mui_extended/Popover/index.e271e4f0.js";
24
+ import { M as MenuActions } from "../mui_extended/MenuActions/index.3a275abb.js";
25
+ import "../mui_extended/Pager/index.5a69ab10.js";
26
+ import "../mui_extended/Tab/index.e0653a0a.js";
27
+ import { styled } from "@mui/material/styles";
28
+ import { r as react_resizable_css } from "../../react-resizable.23b980cb.js";
13
29
  import debounce from "lodash/debounce";
14
30
  import cloneDeep from "lodash.clonedeep";
15
- import { u as useAreasStore, a as useArea, b as useAreas, c as useAreaStore } from "../../hooks/useArea/index.c7e4f3fc.js";
16
- import { useResponsiveDesktop, useFirstRender, useHostTheme, useFormatter, useLocales } from "@m4l/graphics";
17
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
18
31
  import { WidthProvider, Responsive } from "react-grid-layout";
19
- import { I as Icon } from "../../../Icon/index.6938827f.js";
20
32
  import { m } from "framer-motion";
21
- import "react-router-dom";
22
- import "../../../animate/LoadingScreen/index.1d0c4307.js";
23
- import "../../../animate/PropagateLoader/index.be5b02c3.js";
24
- import { I as IconButton } from "../../../mui_extended/IconButton/index.78a489d3.js";
25
- import clsx from "clsx";
26
- import "../../contexts/AreasContext/index.b3b26965.js";
27
- import "../AreasAdmin/index.46fab65b.js";
28
- import { W as WindowToolsMFProvider } from "../../contexts/index.4ebef035.js";
29
- import { c as createDynamicMFStore, D as DynamicMFParmsProvider } from "../../contexts/DynamicMFParmsContext/index.5b3248df.js";
33
+ import "../animate/LoadingScreen/index.1d0c4307.js";
34
+ import "../animate/PropagateLoader/index.be5b02c3.js";
30
35
  import "react-hook-form";
31
- import "../../../hook-form/RHFAutocomplete/index.73d33896.js";
32
- import { I as Image } from "../../../Image/index.674024d4.js";
33
- import { T as Typography } from "../../../mui_extended/Typography/index.86505aed.js";
34
- import "../../../mui_extended/Accordion/index.95a1b021.js";
35
- import "../../../mui_extended/Avatar/index.fe06afd7.js";
36
- import "@mui/material/Button";
37
- import { B as Button } from "../../../mui_extended/Button/index.e4c61b66.js";
38
- import "@mui/lab";
39
- import "../../../mui_extended/Popover/index.e271e4f0.js";
40
- import { M as MenuActions } from "../../../mui_extended/MenuActions/index.742a57d7.js";
41
- import "../../../mui_extended/Pager/index.a44594e9.js";
42
- import "../../../mui_extended/Tab/index.e0653a0a.js";
43
- import "../../../HelperText/index.1a24d41b.js";
44
- import "../../../hook-form/RHFAutocompleteAsync/index.21f4cb53.js";
45
- import "../../../hook-form/RHFCheckbox/index.c3b1884b.js";
36
+ import "../hook-form/RHFAutocomplete/index.5f27e28c.js";
37
+ import "../HelperText/index.c35dcb93.js";
38
+ import "../hook-form/RHFAutocompleteAsync/index.35e17cd6.js";
39
+ import "../hook-form/RHFCheckbox/index.4f134f09.js";
46
40
  import "@mui/x-date-pickers";
47
- import "../../../hook-form/RHFDateTime/index.6c129ce4.js";
48
- import "../../../hook-form/RHFTextField/index.15659666.js";
49
- import "../../../hook-form/RHFPeriod/index.cc624bb3.js";
50
- import "../../../Period/index.a1b7b4cc.js";
51
- import "../../../CommonActions/components/Actions/index.3b882471.js";
52
- import "../../../../contexts/ModalContext/index.bfc47ba9.js";
53
- import { c as cjs } from "../../../../react-draggable.d6441025.js";
54
- import "../../../ModalDialog/index.3db4480d.js";
55
- import { R as ResizeableWindow } from "../../../Resizeable/index.ee84ebc5.js";
56
- import "../../../modal/WindowConfirm.60028bce.js";
57
- import "../../../modal/WindowBase.1b0657de.js";
41
+ import "../hook-form/RHFDateTime/index.6c129ce4.js";
42
+ import "../hook-form/RHFTextField/index.fc90a570.js";
43
+ import "../hook-form/RHFPeriod/index.dcaa0c87.js";
44
+ import "../Period/index.0c5bf66f.js";
45
+ import "../CommonActions/components/Actions/index.77574633.js";
46
+ import "../../contexts/ModalContext/index.de0a3457.js";
47
+ import { c as cjs } from "../../react-draggable.4d08d714.js";
48
+ import "../ModalDialog/index.e600b43a.js";
49
+ import { R as ResizeableWindow } from "../Resizeable/index.4545dd6a.js";
50
+ import "../modal/WindowConfirm.575b4d41.js";
51
+ import "../modal/WindowBase.230a498f.js";
58
52
  import "lodash/isString";
59
53
  import "react-dropzone";
60
- import "../../../hook-form/RHFUpload/index.ecf5c788.js";
61
- import "../../../DataGrid/index.dc84293a.js";
54
+ import "../hook-form/RHFUpload/index.654ad316.js";
55
+ import "../DataGrid/index.ef23d0a9.js";
62
56
  import "react-dnd";
63
57
  import "react-dnd-html5-backend";
64
- import "../../../DynamicFilter/index.abc697c7.js";
65
- import "../../../ScrollBar/index.bbe48f4d.js";
58
+ import "../DynamicFilter/index.04ed3d58.js";
59
+ import "../ScrollBar/index.bbe48f4d.js";
66
60
  import "yup";
67
61
  import "@hookform/resolvers/yup";
68
- import "../../../../contexts/RHFormContext/index.a7511399.js";
69
- import { D as DraggableWindow } from "../../../../vendor.2d9f95b4.js";
70
- import "../../../LanguagePopover/index.47aa8119.js";
71
- import "../../../NavLink/index.0d125c6b.js";
72
- import "../../../NoItemSelected/index.1aa96110.js";
73
- import "../../../ObjectLogs/index.05788334.js";
74
- import "../../../../react-json-view.57125fcf.js";
75
- import "../../../PaperForm/index.b3da0da3.js";
76
- import "../../../Page/index.4237c241.js";
77
- import "../../../PropertyValue/index.dfcfe1ba.js";
78
- import "../../../../react-splitter-layout.8b1655c8.js";
79
- import "../../../SplitLayout/index.5a8355d8.js";
80
- import "../../../SideBar/index.99ce4e06.js";
81
- import { a as useWindow, b as useWindowStore } from "../../hooks/index.ffb1009e.js";
82
- import { L as LinearProgress } from "../../../mui_extended/LinearProgress/index.c92b9ba9.js";
83
- import { v as varBounce } from "../../../animate/variants/bounce.784aaaaa.js";
62
+ import "../../contexts/RHFormContext/index.a7511399.js";
63
+ import { D as DraggableWindow } from "../../vendor.be57c149.js";
64
+ import "../LanguagePopover/index.c0fc94c7.js";
65
+ import "../NavLink/index.3f4e2417.js";
66
+ import "../NoItemSelected/index.609c3c20.js";
67
+ import "../ObjectLogs/index.7f93ba51.js";
68
+ import "../../react-json-view.57125fcf.js";
69
+ import "../PaperForm/index.fb4fa784.js";
70
+ import "../Page/index.4237c241.js";
71
+ import "../PropertyValue/index.dfcfe1ba.js";
72
+ import "../../react-splitter-layout.8b1655c8.js";
73
+ import "../SplitLayout/index.5a8355d8.js";
74
+ import "../SideBar/index.7d970041.js";
75
+ import { L as LinearProgress } from "../mui_extended/LinearProgress/index.c92b9ba9.js";
76
+ import { v as varBounce } from "../animate/variants/bounce.784aaaaa.js";
77
+ const AREAS_DICTIONARY_ID = "areas";
78
+ function getAreasComponentsDictionary() {
79
+ return [AREAS_DICTIONARY_ID];
80
+ }
81
+ const LABEL_FILTER_BUTTON = "filter_tooltip";
82
+ const DICCTIONARY = {
83
+ label_new_area: "label_new_area",
84
+ label_persist_module_cookies: "label_persist_module_cookies"
85
+ };
86
+ const getAreasDictionary = (key) => {
87
+ return `${AREAS_DICTIONARY_ID}.${key}`;
88
+ };
89
+ const AREAS_VIEWER_CLASS_NAME = "M4LAreasViewer";
90
+ const AREAS_ADMIN_CLASS_NAME = "M4LAreasAdmin";
84
91
  const areasViewerClasses = generateUtilityClasses(AREAS_VIEWER_CLASS_NAME, [
85
92
  "root",
86
93
  "areaRoot",
@@ -118,124 +125,54 @@ const useAreasViewerUtilityClasses = (ownerState) => {
118
125
  };
119
126
  return unstable_composeClasses(slots, getComponentUtilityClass(AREAS_VIEWER_CLASS_NAME), {});
120
127
  };
121
- const ROW_HEIGTH_GRIDLAYOUT = 100;
122
- const CONTAINER_PADDING_GRIDLAYOUT = 3;
123
- const DEBOUCED_SAVE_TIME = 500;
124
- const COOKIE_BREAKPOINT_LAYOUTS = "layoutPros";
125
- const COOKIE_WINDOWS = "windows";
126
- const NORMALIZED_BREAKPOINTS = { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 };
127
- const NORMALIZED_COLS = { lg: 24, md: 20, sm: 12, xs: 8, xxs: 2 };
128
- const MAXIMIZED_COLS = { lg: 24, md: 20, sm: 12, xs: 8, xxs: 2 };
129
- const getParmsFromValue = (key, data) => {
130
- try {
131
- if (Array.isArray(data)) {
132
- let ob = data.find((f) => f.id === key);
133
- if (ob) {
134
- ob = JSON.parse(ob.value);
135
- }
136
- return ob;
137
- }
138
- } catch (error) {
139
- }
140
- return void 0;
128
+ const areasAdminClasses = generateUtilityClasses(AREAS_ADMIN_CLASS_NAME, [
129
+ "root",
130
+ "areaChipRoot",
131
+ "areaChipTitle",
132
+ "areaChipDeleteButton",
133
+ "areaChipEditButton",
134
+ "areasAddButton",
135
+ "selected",
136
+ "isMobile"
137
+ ], AREAS_ADMIN_CLASS_NAME);
138
+ const useAreasAdminUtilityClasses = (ownerState) => {
139
+ const slots = {
140
+ root: ["root", ownerState.status, ownerState.isMobile && "isMobile", ownerState.isSkeleton && "isSkeleton"],
141
+ areaChipRoot: ["areaChipRoot"],
142
+ areaChipTitle: ["areaChipTitle"],
143
+ areaChipDeleteButton: ["areaChipDeleteButton"],
144
+ areaChipEditButton: ["areaChipEditButton"],
145
+ areasAddButton: ["areasAddButton"]
146
+ };
147
+ return unstable_composeClasses(slots, getComponentUtilityClass(AREAS_ADMIN_CLASS_NAME), {});
141
148
  };
142
- function setAddBreakPoints(state, newLayout) {
143
- const layoutsBreakPoints = state.breakpointsLayouts;
144
- const beforeMaximizebreakpointsLayouts = state.beforeMaximizebreakpointsLayouts;
145
- for (const key in layoutsBreakPoints) {
146
- const layoutBreakpoint = layoutsBreakPoints[key];
147
- layoutBreakpoint.push(newLayout);
148
- }
149
- if (state.viewMode === "single") {
150
- for (const key in beforeMaximizebreakpointsLayouts) {
151
- const beforeLayoutBreakpoint = beforeMaximizebreakpointsLayouts[key];
152
- beforeLayoutBreakpoint.push(newLayout);
153
- }
154
- }
155
- return layoutsBreakPoints;
156
- }
157
- function setBreakPointsMaximized(state, layoutId) {
158
- const layoutsBreakPoints = state.breakpointsLayouts;
159
- const container = document.getElementsByClassName(`${areasViewerClasses.areaRoot}`)[0];
160
- console.log(`Setting breakpoints`, container);
161
- if (container) {
162
- const clientHeight = container.clientHeight;
163
- for (const key in layoutsBreakPoints) {
164
- const layoutBreakpoint = layoutsBreakPoints[key];
165
- const cols = key in MAXIMIZED_COLS ? MAXIMIZED_COLS[key] : 1;
166
- const heigth_by_rowheigth = clientHeight / (ROW_HEIGTH_GRIDLAYOUT + 2 * CONTAINER_PADDING_GRIDLAYOUT);
167
- for (let index = 0; index < layoutBreakpoint.length; index++) {
168
- const l = layoutBreakpoint[index];
169
- if (l.i === layoutId) {
170
- l.x = 0;
171
- l.y = 0;
172
- l.h = heigth_by_rowheigth;
173
- l.w = cols;
174
- l.minW = 0;
175
- l.maxW = cols;
176
- l.minH = 0;
177
- l.maxH = heigth_by_rowheigth;
178
- l.isResizable = false;
179
- l.isDraggable = false;
180
- } else {
181
- l.x = 0;
182
- l.y = 1;
183
- l.h = 0;
184
- l.w = 0;
185
- l.minW = 0;
186
- l.maxW = 0;
187
- l.minH = 0;
188
- l.maxH = 0;
189
- }
190
- l.isResizable = false;
191
- l.isDraggable = false;
192
- }
193
- }
194
- }
195
- return layoutsBreakPoints;
196
- }
197
- function getDataFromResponse(data, state) {
198
- const newBreakPointsLayouts = getParmsFromValue(COOKIE_BREAKPOINT_LAYOUTS, data);
199
- const windows = getParmsFromValue(COOKIE_WINDOWS, data);
200
- const newGridLayouts = [];
201
- const newHashWindowLayouts = {};
202
- if (windows) {
203
- for (const key in windows) {
204
- const element = windows[key];
205
- if (element && element["layoutProps"] && element["mfProps"] && element["emergeType"] === "layout" && element["winType"] === "microfrontend") {
206
- element["layoutProps"].i = key;
207
- newGridLayouts.push(element["layoutProps"]);
208
- newHashWindowLayouts[key] = {
209
- ...element,
210
- windowId: key,
211
- emergeType: "layout",
212
- onClose: state.actions.closeWindowLayout
213
- };
214
- }
215
- }
149
+ const addArea = (state) => {
150
+ let newName = "";
151
+ const newId = `area_${new Date().getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
152
+ newName = `${state.getLabel(getAreasDictionary("label_new_area"))} ${state.areas.length + 1}`;
153
+ state.areas.push({ id: newId, name: newName, loadWindows: false });
154
+ state.currentArea = newId;
155
+ if (state.loadAreasFromNetwork) {
156
+ state.networkOperation({
157
+ method: "POST",
158
+ endPoint: `areas`,
159
+ data: { id: newId, name: newName },
160
+ toastSuccess: false,
161
+ toastError: false
162
+ });
216
163
  }
217
- return {
218
- newBreakPointsLayouts,
219
- newGridLayouts,
220
- newHashWindowLayouts
221
- };
222
- }
223
- const createAreaStore = (initProps) => {
164
+ return newId;
165
+ };
166
+ const updateOwnerStateClasses = (state) => {
167
+ state.viwerClasses = useAreasViewerUtilityClasses(state.ownerState);
168
+ state.adminClasses = useAreasAdminUtilityClasses(state.ownerState);
169
+ };
170
+ const createAreasStore = (initProps) => {
224
171
  const startProps = {
225
- zPopUpIndex: 999,
226
- status: "init",
227
- breakpointsLayouts: {},
228
- beforeMaximizebreakpointsLayouts: {},
229
- gridLayouts: [],
230
- windowModal: null,
231
- windowsPopUps: [],
232
- hashWindowsPopups: {},
233
- hashWindowsLayouts: {},
234
- currentLayoutId: "",
235
- currentPopUpId: "",
236
- viewMode: initProps.isDesktop ? "multiple" : "single",
237
- breakpoints: NORMALIZED_BREAKPOINTS,
238
- cols: NORMALIZED_COLS,
172
+ viwerClasses: useAreasViewerUtilityClasses(initProps.ownerState),
173
+ adminClasses: useAreasAdminUtilityClasses(initProps.ownerState),
174
+ currentArea: "",
175
+ areas: [],
239
176
  ...initProps
240
177
  };
241
178
  return createStore(
@@ -243,1708 +180,2190 @@ const createAreaStore = (initProps) => {
243
180
  immer((set, get) => ({
244
181
  ...startProps,
245
182
  actions: {
246
- addWindow: (newWindowProps) => {
247
- const windowId = `${get().id}_window_${new Date().getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
248
- console.log("addWindow", newWindowProps.emergeType);
249
- if (newWindowProps.emergeType === "layout") {
250
- get().actions.addWindowLayout(windowId, newWindowProps);
251
- } else if (newWindowProps.emergeType === "popup") {
252
- get().actions.addWindowPopUp(windowId, newWindowProps);
253
- } else if (newWindowProps.emergeType === "modal") {
254
- get().actions.addWindowModal(windowId, newWindowProps);
183
+ init: () => {
184
+ if (get().ownerState.status === "init") {
185
+ if (!get().loadAreasFromNetwork) {
186
+ get().actions.addArea();
187
+ set((state) => {
188
+ state.ownerState.status = "loaded";
189
+ updateOwnerStateClasses(state);
190
+ });
191
+ } else {
192
+ set((state) => {
193
+ state.ownerState.status = "loading";
194
+ updateOwnerStateClasses(state);
195
+ state.networkOperation({
196
+ method: "GET",
197
+ endPoint: `areas`,
198
+ parms: {},
199
+ toastSuccess: false
200
+ }).then((response) => {
201
+ set((otherState) => {
202
+ if (response?.data && Array.isArray(response.data) && response.data.length > 0) {
203
+ otherState.areas = response.data;
204
+ otherState.currentArea = response.data[0].id;
205
+ } else {
206
+ addArea(otherState);
207
+ }
208
+ });
209
+ }).finally(() => {
210
+ set((state2) => {
211
+ state2.ownerState.status = "loaded";
212
+ updateOwnerStateClasses(state2);
213
+ });
214
+ });
215
+ });
216
+ }
255
217
  }
256
218
  },
257
- closeWindowModal: () => {
258
- set((state) => {
259
- state.windowModal = void 0;
260
- });
261
- },
262
- addWindowModal: (container_id, newWindowModalProps) => {
219
+ addArea: () => {
220
+ let newId = "";
263
221
  set((state) => {
264
- state.windowModal = { ...newWindowModalProps, windowId: container_id };
222
+ newId = addArea(state);
265
223
  });
224
+ return newId;
266
225
  },
267
- closeWindowPopUp: (removePopUpId) => {
226
+ deleteArea: (areaId) => {
268
227
  set((state) => {
269
- const removeIndex = state.windowsPopUps.findIndex(
270
- (wpId) => wpId === removePopUpId
271
- );
228
+ const removeIndex = state.areas.findIndex((area) => area.id === areaId);
272
229
  if (removeIndex > -1) {
273
- state.windowsPopUps.splice(removeIndex, 1);
230
+ state.areas.splice(removeIndex, 1);
274
231
  }
275
- delete state.hashWindowsPopups[removePopUpId];
276
- });
277
- },
278
- addWindowPopUp: (windowId, newWindowPopupProps) => {
279
- let popUpId = windowId;
280
- set((state) => {
281
- if (newWindowPopupProps.replaceMeId) {
282
- for (const key in state.hashWindowsPopups) {
283
- const WindoPopUp = state.hashWindowsPopups[key];
284
- if (WindoPopUp.replaceMeId === newWindowPopupProps.replaceMeId) {
285
- popUpId = key;
286
- state.hashWindowsPopups[key].dynamicParams = newWindowPopupProps.dynamicParams;
287
- break;
288
- }
232
+ if (state.currentArea === areaId) {
233
+ if (state.areas.length > 0) {
234
+ state.currentArea = state.areas[0].id;
235
+ } else {
236
+ state.currentArea = "";
289
237
  }
290
238
  }
291
- if (popUpId === windowId) {
292
- state.windowsPopUps.push(windowId);
293
- state.hashWindowsPopups[windowId] = {
294
- ...newWindowPopupProps,
295
- emergeType: "popup",
296
- windowId,
297
- onClose: get().actions.closeWindowPopUp,
298
- zIndex: state.zPopUpIndex
299
- };
300
- state.currentPopUpId = windowId;
239
+ if (state.loadAreasFromNetwork) {
240
+ state.networkOperation({
241
+ method: "DELETE",
242
+ endPoint: `areas/${areaId}`,
243
+ parms: {},
244
+ toastSuccess: false,
245
+ toastError: false
246
+ });
301
247
  }
302
248
  });
303
- get().actions.selectWindowPopUp(popUpId);
304
249
  },
305
- closeWindowLayout: (removeLayoutId) => {
250
+ selectArea: (newAreaId) => {
306
251
  set((state) => {
307
- const removeIndex = state.gridLayouts.findIndex(
308
- (gl) => gl.i === removeLayoutId
309
- );
310
- if (removeIndex > -1) {
311
- state.gridLayouts.splice(removeIndex, 1);
252
+ if (state.areas.findIndex((area) => area.id === newAreaId) > -1) {
253
+ state.currentArea = newAreaId;
312
254
  }
313
- delete state.hashWindowsLayouts[removeLayoutId];
314
255
  });
315
- get().actions.saveLayouts();
316
- if (get().singleId === removeLayoutId) {
317
- get().actions.maximizeLayout();
318
- }
319
- },
320
- addWindowLayout: (windowId, newWindow) => {
321
- const newLayout = {
322
- ...newWindow.layoutProps,
323
- i: windowId,
324
- isDraggable: true,
325
- isResizable: true,
326
- winType: newWindow.winType
327
- };
256
+ }
257
+ },
258
+ internalActions: {
259
+ setHandlerGetLabel: (newHandler) => {
328
260
  set((state) => {
329
- state.gridLayouts.push(newLayout);
330
- state.hashWindowsLayouts[windowId] = {
331
- ...newWindow,
332
- windowId,
333
- emergeType: "layout",
334
- onClose: get().actions.closeWindowLayout
335
- };
336
- setAddBreakPoints(state, newLayout);
261
+ state.getLabel = newHandler;
337
262
  });
338
- get().actions.selectWindowLayout(windowId);
339
- if (get().viewMode === "single") {
340
- get().actions.maximizeLayout(windowId);
341
- }
342
- get().actions.saveLayouts();
343
- get().actions.bouncedSaveBreakpointsLayouts();
344
263
  },
345
- saveLayouts: () => {
346
- let nrKeys = 0;
347
- const saveObjetc = {};
348
- for (const key in get().hashWindowsLayouts) {
349
- const element = get().hashWindowsLayouts[key];
350
- if (element.winType === "microfrontend") {
351
- const newElement = { ...element };
352
- delete newElement.onClose;
353
- delete newElement.devCookies;
354
- saveObjetc[key] = newElement;
355
- nrKeys++;
264
+ setAreaLink: (areaId, store) => {
265
+ set((state) => {
266
+ const areaIndex = state.areas.findIndex((area) => area.id === areaId);
267
+ if (areaIndex > -1) {
268
+ state.areas[areaIndex].store = store;
269
+ state.areas[areaIndex].linked = true;
356
270
  }
357
- }
358
- if (nrKeys > 0) {
359
- get().networkOperation({
360
- method: "PUT",
361
- endPoint: `cookies/${get().id}/${COOKIE_WINDOWS}`,
362
- data: {
363
- value: JSON.stringify(saveObjetc)
364
- },
365
- toastSuccess: false,
366
- toastError: false
367
- });
368
- } else {
369
- get().networkOperation({
370
- method: "DELETE",
371
- endPoint: `cookies`,
372
- data: { f: [{ n: "container_id", o: "c", o1: get().id }] },
373
- toastSuccess: false,
374
- toastError: false
375
- });
376
- }
377
- },
378
- bouncedSaveBreakpointsLayouts: debounce(
379
- () => {
380
- const purgedLayouts = {
381
- ...get().viewMode === "multiple" ? get().breakpointsLayouts : get().beforeMaximizebreakpointsLayouts
382
- };
383
- const finalLayouts = {};
384
- for (const key in purgedLayouts) {
385
- const element = purgedLayouts[key];
386
- purgedLayouts[key] = element.filter((l) => {
387
- if (l.i === "none") {
388
- return false;
389
- }
390
- if (get().hashWindowsLayouts[l.i]) {
391
- return true;
392
- }
393
- return false;
394
- });
395
- if (purgedLayouts[key].length > 0) {
396
- finalLayouts[key] = purgedLayouts[key];
397
- }
398
- }
399
- if (Object.keys(finalLayouts).length > 0) {
400
- get().networkOperation({
401
- method: "PUT",
402
- endPoint: `cookies/${get().id}/${COOKIE_BREAKPOINT_LAYOUTS}`,
403
- data: {
404
- value: JSON.stringify(finalLayouts)
405
- },
406
- toastSuccess: false,
407
- toastError: false
408
- });
409
- }
410
- },
411
- DEBOUCED_SAVE_TIME
412
- ),
413
- onBreakpointsLayoutsChange: (_currentLayouts, newAllLayouts) => {
414
- set((state) => {
415
- state.breakpointsLayouts = newAllLayouts;
416
- });
417
- if (!get().singleId) {
418
- get().actions.bouncedSaveBreakpointsLayouts();
419
- }
420
- },
421
- selectWindowLayout: (layoutId) => {
422
- set((state) => {
423
- state.currentLayoutId = layoutId;
424
- if (state.currentPopUpId !== "" && state.hashWindowsPopups[state.currentPopUpId]) {
425
- const windowPopup = state.hashWindowsPopups[state.currentPopUpId];
426
- if (windowPopup.parentLayoutId !== layoutId) {
427
- state.currentPopUpId = "";
428
- }
429
- }
430
- });
431
- },
432
- selectWindowPopUp: (popUpId) => {
433
- set((state) => {
434
- state.zPopUpIndex++;
435
- state.currentPopUpId = popUpId;
436
- state.zPopUpIndex++;
437
- state.currentPopUpId = popUpId;
438
- state.hashWindowsPopups[popUpId].zIndex = state.zPopUpIndex;
439
- if (state.hashWindowsPopups[popUpId].parentLayoutId && state.hashWindowsPopups[popUpId].parentLayoutId !== "") {
440
- state.currentLayoutId = state.hashWindowsPopups[popUpId].parentLayoutId;
441
- } else {
442
- state.currentLayoutId = "";
443
- }
444
- });
445
- setTimeout(() => {
446
- const container = document.getElementsByClassName(
447
- `${areasViewerClasses.areaGridLayoutPanelContainer}-${get().id}`
448
- )[0];
449
- const element = document.getElementsByClassName(
450
- `${areasViewerClasses.windowPopupRoot}-${popUpId}`
451
- )[0];
452
- if (element && container) {
453
- const { top, left } = element.getBoundingClientRect();
454
- const { top: containerTop, left: containerLeft } = container.getBoundingClientRect();
455
- container.scrollTop = container.scrollTop + top - containerTop;
456
- container.scrollLeft = container.scrollLeft + left - containerLeft;
457
- }
458
- }, 100);
459
- },
460
- maximizeLayout: (layoutId) => {
461
- let finalLayoutId = layoutId;
462
- set((state) => {
463
- if (state.viewMode === "multiple") {
464
- state.beforeMaximizebreakpointsLayouts = cloneDeep(
465
- state.breakpointsLayouts
466
- );
467
- }
468
- if (!finalLayoutId) {
469
- if (state.gridLayouts.length > 0) {
470
- finalLayoutId = state.gridLayouts[0].i;
471
- }
472
- }
473
- state.viewMode = "single";
474
- state.singleId = finalLayoutId;
475
- setBreakPointsMaximized(state, finalLayoutId);
476
- });
477
- if (finalLayoutId) {
478
- get().actions.selectWindowLayout(finalLayoutId);
479
- }
480
- },
481
- normalizeLayouts: () => {
482
- set((state) => {
483
- if (!state.isDesktop)
484
- return;
485
- if (state.isDesktop && state.viewMode === "single") {
486
- state.viewMode = "multiple";
487
- state.singleId = void 0;
488
- state.breakpointsLayouts = state.beforeMaximizebreakpointsLayouts;
489
- }
490
- });
491
- }
492
- },
493
- internalActions: {
494
- loadFromApi: () => {
495
- if (get().status !== "init") {
496
- return;
497
- }
498
- if (!get().loadAreasFromNetwork || !get().loadWindows) {
499
- set((state) => {
500
- state.status = "loaded";
501
- });
502
- return;
503
- }
504
- get().networkOperation({
505
- method: "GET",
506
- endPoint: `cookies`,
507
- parms: { f: [{ n: "container_id", o: "e", o1: get().id }] },
508
- toastSuccess: false,
509
- toastError: false
510
- }).then((response) => {
511
- set((state) => {
512
- const {
513
- newBreakPointsLayouts,
514
- newGridLayouts,
515
- newHashWindowLayouts
516
- } = getDataFromResponse(response.data, state);
517
- if (state.viewMode === "multiple") {
518
- state.breakpointsLayouts = newBreakPointsLayouts;
519
- } else {
520
- state.breakpointsLayouts = newBreakPointsLayouts;
521
- state.beforeMaximizebreakpointsLayouts = newBreakPointsLayouts;
522
- }
523
- state.gridLayouts = newGridLayouts;
524
- state.hashWindowsLayouts = newHashWindowLayouts;
525
- state.status = "loaded";
526
- });
527
- console.log("loadFromApi", get().viewMode);
528
- if (get().viewMode === "single") {
529
- get().actions.maximizeLayout();
530
- }
531
- }).catch((_response) => {
532
- set((state) => {
533
- state.status = "loaded";
534
- });
535
271
  });
536
272
  },
537
- changeDesktopBreakpoint: (isDesktop) => {
538
- const previousState = get().isDesktop;
273
+ setExternalState: (newExternalState) => {
539
274
  set((state) => {
540
- state.isDesktop = isDesktop;
275
+ state.ownerState = { ...state.ownerState, ...newExternalState };
276
+ updateOwnerStateClasses(state);
541
277
  });
542
- if (previousState != isDesktop) {
543
- if (isDesktop) {
544
- get().actions.normalizeLayouts();
545
- } else {
546
- if (get().viewMode === "multiple") {
547
- if (get().gridLayouts.length > 0) {
548
- get().actions.maximizeLayout(get().gridLayouts[0].i);
549
- }
550
- }
551
- }
552
- }
553
278
  }
554
279
  }
555
280
  })),
556
- { name: `Area state ${initProps.id}` }
281
+ { name: `Areas store` }
557
282
  )
558
283
  );
559
284
  };
560
- const AreaContext = createContext(null);
561
- const AreaProvider = (props) => {
285
+ const AreasContext = createContext(null);
286
+ function AreasProvider(props) {
562
287
  const {
563
288
  children,
564
- id,
565
- selected: active,
566
- loadWindows = true
289
+ loadAreasFromNetwork,
290
+ loadCookiesFromNetwork,
291
+ onLoad
567
292
  } = props;
568
- const [loadAreasFromNetwork, loadCookiesFromNetwork] = useAreasStore((state) => [state.loadAreasFromNetwork, state.loadCookiesFromNetwork], shallow);
569
293
  const {
570
- setAreaLink
571
- } = useAreasStore((state) => state.internalActions);
572
- const isDesktop = useResponsiveDesktop();
573
- const isFirstRender = useFirstRender([isDesktop]);
294
+ events_add_listener,
295
+ events_remove_listener
296
+ } = useHostTools();
297
+ const {
298
+ getLabel
299
+ } = useModuleDictionary();
574
300
  const {
575
301
  networkOperation
576
302
  } = useNetwork();
577
- const areaStoreRef = useRef();
578
- if (!areaStoreRef.current) {
579
- areaStoreRef.current = createAreaStore({
580
- id,
581
- networkOperation,
303
+ const isDesktop = useResponsiveDesktop();
304
+ const isSkeleton = useModuleSkeleton();
305
+ const isFirstRender = useFirstRender([getLabel]);
306
+ const areasStoreRef = useRef();
307
+ if (!areasStoreRef.current) {
308
+ areasStoreRef.current = createAreasStore({
309
+ getLabel,
582
310
  loadAreasFromNetwork,
583
311
  loadCookiesFromNetwork,
584
- loadWindows,
585
- isDesktop: !!isDesktop
312
+ networkOperation,
313
+ ownerState: {
314
+ status: "init",
315
+ isMobile: !isDesktop,
316
+ isSkeleton
317
+ }
586
318
  });
319
+ areasStoreRef.current?.getState().actions.init();
587
320
  }
321
+ const status = useStore(areasStoreRef.current, (state) => state.ownerState.status, shallow);
588
322
  const {
589
- loadFromApi,
590
- changeDesktopBreakpoint
591
- } = useStore(areaStoreRef.current, (state) => state.internalActions, shallow);
592
- const status = useStore(areaStoreRef.current, (state) => state.status, shallow);
323
+ setHandlerGetLabel
324
+ } = useStore(areasStoreRef.current, (state) => state.internalActions, shallow);
325
+ const addWindow = useCallback((newWindow) => {
326
+ const currentArea = areasStoreRef.current?.getState().currentArea;
327
+ const areas = areasStoreRef.current?.getState().areas;
328
+ if (currentArea && areas) {
329
+ const areaIndex = areas.findIndex((area) => area.id == currentArea);
330
+ if (areaIndex > -1 && areas[areaIndex].store) {
331
+ areas[areaIndex].store?.getState().actions.addWindow(newWindow);
332
+ }
333
+ }
334
+ }, []);
593
335
  useEffect(() => {
594
- if (!isFirstRender) {
595
- changeDesktopBreakpoint(!!isDesktop);
336
+ if (status === "loaded") {
337
+ onLoad && onLoad();
596
338
  }
597
- }, [isDesktop]);
339
+ }, [status]);
598
340
  useEffect(() => {
599
- if (areaStoreRef.current) {
600
- setAreaLink(id, areaStoreRef.current);
341
+ if (!isFirstRender) {
342
+ setHandlerGetLabel(getLabel);
601
343
  }
344
+ }, [getLabel]);
345
+ useEffect(() => {
346
+ events_add_listener(EmitEvents.EMMIT_EVENT_HOST_EMERGE_WINDOW, addWindow);
602
347
  return () => {
348
+ events_remove_listener(EmitEvents.EMMIT_EVENT_HOST_EMERGE_WINDOW, addWindow);
603
349
  };
604
350
  }, []);
605
351
  useEffect(() => {
606
- if (active && status === "init") {
607
- loadFromApi();
352
+ if (isFirstRender) {
353
+ return;
608
354
  }
609
- }, [active]);
610
- return /* @__PURE__ */ jsx(AreaContext.Provider, {
611
- value: areaStoreRef.current,
355
+ areasStoreRef.current?.getState().internalActions.setExternalState({
356
+ isMobile: !isDesktop,
357
+ isSkeleton
358
+ });
359
+ }, [isDesktop, isSkeleton]);
360
+ return /* @__PURE__ */ jsx(AreasContext.Provider, {
361
+ value: areasStoreRef.current,
612
362
  children
613
363
  });
614
- };
615
- if (process.env.NODE_ENV !== "production") {
616
- AreaProvider.displayName = "AreaProvider";
617
364
  }
618
- React__default.memo(AreaProvider);
619
- function getCookiesContainer(data, containerId) {
620
- const cookies = {};
621
- try {
622
- if (Array.isArray(data)) {
623
- for (let i = 0; i < data.length; i++) {
624
- if (data[i]?.container_id === containerId && data[i]?.id) {
625
- cookies[data[i]?.id] = JSON.parse(data[i].value);
626
- }
627
- }
628
- }
629
- } catch (error) {
630
- }
631
- return cookies;
365
+ function useAreas() {
366
+ const context = useContext(AreasContext);
367
+ if (!context)
368
+ throw new Error("useAreas context must be use inside AreasContext");
369
+ return context;
632
370
  }
633
- const createWindowStore = (initProps) => {
634
- const startProps = {
635
- status: "init",
636
- moduleActions: [],
637
- cookies: initProps.devCookies || { moduleCookies: {}, windowCookies: {} },
638
- ...initProps
639
- };
640
- delete startProps.devCookies;
641
- return createStore(
642
- devtools(
643
- immer((set, get, _api) => ({
644
- ...startProps,
645
- actions: {
646
- setActions: (newActions, version) => {
647
- set((state) => {
648
- state.moduleActions = cloneDeep(newActions);
649
- state.version = version;
650
- console.log("LLEGO Version", version);
651
- });
652
- },
653
- close: () => {
654
- const onClose = get().onClose;
655
- if (onClose) {
656
- onClose(get().windowId);
657
- }
658
- },
659
- getWindowId: () => {
660
- return get().windowId;
661
- },
662
- getCookie: (id) => {
663
- return get().cookies.windowCookies[id] || get().cookies.moduleCookies[id];
664
- },
665
- getCookies: (type) => {
666
- if (type === "window") {
667
- return get().cookies.windowCookies;
668
- } else {
669
- return get().cookies.moduleCookies;
670
- }
671
- },
672
- setCookie: (id, type, cookie) => {
673
- get().networkOperation({
674
- method: "PUT",
675
- endPoint: `cookies/${type === "module" ? get().moduleId : get().windowId}/${id}`,
676
- data: {
677
- value: JSON.stringify(cookie)
678
- },
679
- toastSuccess: false,
680
- toastError: false
681
- });
682
- set((state) => {
683
- if (type === "window") {
684
- state.cookies.windowCookies[id] = cookie;
685
- } else {
686
- state.cookies.moduleCookies[id] = cookie;
687
- }
688
- });
689
- }
690
- },
691
- internalActions: {
692
- loadCookiesFromApi: () => {
693
- if (get().status === "init") {
694
- get().networkOperation({
695
- method: "GET",
696
- endPoint: `cookies`,
697
- parms: {
698
- f: [
699
- { n: "container_id", o: "e", o1: get().windowId },
700
- { n: "container_id", o: "e", o1: get().moduleId }
701
- ]
702
- },
703
- toastSuccess: false,
704
- toastError: false
705
- }).then((response) => {
706
- set((state) => {
707
- state.cookies.moduleCookies = getCookiesContainer(
708
- response.data,
709
- state.moduleId
710
- );
711
- state.cookies.windowCookies = getCookiesContainer(
712
- response.data,
713
- state.windowId
714
- );
715
- state.status = "loaded";
716
- });
717
- }).catch((_response) => {
718
- set((state) => {
719
- state.status = "loaded";
720
- });
721
- });
722
- }
723
- },
724
- saveModuleCookies: () => {
725
- for (const key in get().cookies.windowCookies) {
726
- const cookie = get().cookies.windowCookies[key];
727
- get().networkOperation({
728
- method: "PUT",
729
- endPoint: `cookies/${get().moduleId}/${key}`,
730
- data: {
731
- value: JSON.stringify(cookie)
732
- },
733
- toastSuccess: false,
734
- toastError: false
735
- });
736
- }
737
- }
738
- }
739
- })),
740
- {
741
- name: `window store ${initProps.windowId}`,
742
- store: `window dev store ${initProps.windowId}`,
743
- trace: true
744
- }
745
- )
746
- );
371
+ function useAreasStore(selector, equalityFn) {
372
+ const context = useContext(AreasContext);
373
+ if (!context)
374
+ throw new Error("useAreasStore context must be use inside AreasContext");
375
+ return useStore(context, selector, equalityFn);
376
+ }
377
+ const ICONS = {
378
+ CLOSE: "close.svg",
379
+ MAXIMIZE: "maximize.svg",
380
+ NORMALIZE: "normalize.svg",
381
+ DELETE_AREA: "delete_area.svg",
382
+ ADD_AREA: "add_area.svg",
383
+ EDIT_AREA: "edit_area.svg"
747
384
  };
748
- const WindowContext = createContext(null);
749
- function WindowMFProvider(props) {
385
+ const AreaChip = (props) => {
750
386
  const {
751
- children,
752
- ...other
387
+ areaId,
388
+ selected,
389
+ areaName
753
390
  } = props;
754
391
  const {
755
- networkOperation
756
- } = useNetwork();
757
- const windowStoreRef = useRef();
758
- const dynamicMFStoreRef = useRef();
759
- const areaStore = useArea();
760
- const areasStore = useAreas();
761
- if (!dynamicMFStoreRef.current) {
762
- dynamicMFStoreRef.current = createDynamicMFStore({
763
- dynamicMFParameters: props.dynamicParams,
764
- windowId: props.windowId
765
- });
766
- }
767
- if (!windowStoreRef.current) {
768
- windowStoreRef.current = createWindowStore({
769
- ...other,
770
- dynamicMFStore: dynamicMFStoreRef.current,
771
- networkOperation,
772
- areaStore,
773
- areasStore
774
- });
775
- }
776
- useEffect(() => {
777
- windowStoreRef.current?.getState().internalActions.loadCookiesFromApi();
778
- return () => {
779
- console.debug("useEffect cleanUP WindowMFProvider", props.windowId, windowStoreRef.current);
780
- };
781
- }, []);
782
- useEffect(() => {
783
- if (windowStoreRef.current?.getState().status === "loaded") {
784
- dynamicMFStoreRef.current?.getState().actions.changeData(props.dynamicParams);
785
- }
786
- }, [props.dynamicParams]);
787
- return /* @__PURE__ */ jsx(WindowContext.Provider, {
788
- value: windowStoreRef.current,
789
- children
790
- });
791
- }
792
- const Component = (props) => {
392
+ host_static_assets,
393
+ environment_assets
394
+ } = useEnvironment();
793
395
  const {
794
- component
795
- } = props;
796
- const store = useWindow();
797
- const dynamicMFStore = useWindowStore((state) => state.dynamicMFStore);
798
- const actions = useWindowStore((state) => state.actions, shallow);
799
- return /* @__PURE__ */ jsx(WindowToolsMFProvider, {
800
- ...actions,
801
- children: /* @__PURE__ */ jsx(DynamicMFParmsProvider, {
802
- store: dynamicMFStore,
803
- children: typeof component === "function" ? component(store) : component
804
- })
396
+ deleteArea,
397
+ selectArea
398
+ } = useAreasStore((state) => state.actions);
399
+ const onClickDeleteArea = (e) => {
400
+ e.stopPropagation();
401
+ deleteArea(areaId);
402
+ };
403
+ return /* @__PURE__ */ jsxs("div", {
404
+ role: "presentation",
405
+ className: clsx(areasAdminClasses.areaChipRoot, selected ? areasAdminClasses.selected : null),
406
+ onClick: () => {
407
+ selectArea(areaId);
408
+ },
409
+ children: [/* @__PURE__ */ jsx("span", {
410
+ className: areasAdminClasses.areaChipTitle,
411
+ children: areaName
412
+ }), /* @__PURE__ */ jsx(IconButton, {
413
+ className: areasAdminClasses.areaChipDeleteButton,
414
+ src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.DELETE_AREA}`,
415
+ size: "small",
416
+ onClick: onClickDeleteArea
417
+ })]
805
418
  });
806
419
  };
807
- React__default.memo(Component);
808
- styled("div")(({
809
- theme
810
- }) => ({
811
- display: "flex",
812
- alignItems: "center",
813
- position: "relative",
814
- justifyContent: "space-between",
815
- minHeight: theme.spacing(5),
816
- borderBottom: `1px solid ${theme.palette.divider}`,
817
- overflow: "hidden",
818
- cursor: "move",
819
- height: "60px",
820
- " > span": {
821
- marginRight: "12px"
822
- },
823
- "& > h5": {
824
- paddingRight: theme.spacing(3),
825
- borderRight: `1px solid ${theme.palette.divider}`
826
- },
827
- " > nav": {
828
- marginRight: "12px",
829
- flexGrow: 1
830
- },
831
- "& .splitactions.Mui-disabled": {
832
- color: theme.palette.primary.main
833
- },
834
- "& svg ": {
835
- width: "20px",
836
- height: "20px"
837
- }
838
- }));
839
- styled("div")(({
840
- theme
841
- }) => ({
842
- display: "flex",
843
- alignItems: "center",
844
- position: "relative",
845
- borderBottom: `1px solid ${theme.palette.divider}`,
846
- height: "60px",
847
- minHeight: "60px",
848
- " > span": {
849
- marginRight: "12px"
850
- },
851
- "& > h5": {
852
- paddingRight: theme.spacing(3),
853
- borderRight: `1px solid ${theme.palette.divider}`
854
- },
855
- " > nav": {
856
- marginRight: "12px",
857
- flexGrow: 1
858
- },
859
- "& .splitactions.Mui-disabled": {
860
- color: theme.palette.primary.main
861
- },
862
- "& svg ": {
863
- width: "20px",
864
- height: "20px"
420
+ AreaChip.displayName = "AreaButtons";
421
+ const AreasAdminRoot = styled("div")`
422
+ display: flex;
423
+ position: relative;
424
+
425
+ //areaRoot
426
+ & .${areasAdminClasses.areaChipRoot} {
427
+ display: flex;
428
+ }
429
+
430
+ & .${areasAdminClasses.areaChipRoot}.${areasAdminClasses.selected}::before {
431
+ content: "";
432
+ background-color: ${(props) => props.theme.palette.primary.main};
433
+ height: 100%;
434
+ width: 8px;
435
+ },
436
+
437
+ ${(props) => props.theme.components?.M4LAreasAdmin}
438
+
439
+ `;
440
+ function AreasAdmin() {
441
+ const areas = useAreasStore((state) => state.areas, shallow);
442
+ const currentArea = useAreasStore((state) => state.currentArea, shallow);
443
+ const status = useAreasStore((state) => state.ownerState.status);
444
+ const classesRoot = useAreasStore((state) => state.adminClasses.root);
445
+ const {
446
+ addArea: addArea2
447
+ } = useAreasStore((state) => state.actions, shallow);
448
+ const {
449
+ host_static_assets,
450
+ environment_assets
451
+ } = useEnvironment();
452
+ console.log("Render AreasAdmin", status, areas);
453
+ if (status !== "loaded") {
454
+ return null;
865
455
  }
866
- }));
867
- const Wrapper = styled("div")(({
868
- theme
869
- }) => ({
870
- display: "flex",
871
- justifyContent: "space-between",
872
- padding: `0 0`,
873
- borderBottom: `1px solid ${theme.palette.divider}`,
874
- minHeight: "60px"
875
- }));
876
- const ModuleTitleContent = styled("div")(({
877
- theme
878
- }) => ({
879
- display: "grid",
880
- gridTemplateColumns: "auto",
881
- gridGap: theme.spacing(1.75),
882
- alignItems: "center",
883
- width: "auto",
884
- height: "auto",
885
- [theme.breakpoints.up("sm")]: {
886
- gridTemplateColumns: "repeat(3, auto)"
887
- }
888
- }));
889
- const ModuleTitle = styled("div")(({
890
- theme
891
- }) => ({
892
- display: "grid",
893
- gridTemplateColumns: `${theme.spacing(3)} auto`,
894
- gridGap: theme.spacing(2),
895
- alignItems: "center",
896
- width: "auto",
897
- height: "auto"
898
- }));
899
- const Separator = styled("div")(({
900
- theme
901
- }) => ({
902
- display: "none",
903
- alignItems: "center",
904
- width: "1px",
905
- background: theme.palette.divider,
906
- height: "100%",
907
- margin: `0 ${theme.spacing(2)}`,
908
- [theme.breakpoints.up("sm")]: {
909
- display: "flex"
910
- }
911
- }));
912
- const Breadcrumbs = styled("div")(({
913
- theme
914
- }) => ({
915
- display: "grid",
916
- alignItems: "center",
917
- gridTemplateColumns: `repeat(3, auto)`,
918
- gridGap: theme.spacing(2)
919
- }));
920
- const ModuleActions = styled("div")(({
921
- theme
922
- }) => ({
923
- display: "grid",
924
- gridTemplateColumns: "auto",
925
- alignItems: "center",
926
- width: "auto",
927
- height: "auto",
928
- [theme.breakpoints.up("sm")]: {
929
- gridTemplateColumns: `repeat(3, ${theme.spacing(3)})`,
930
- gridGap: theme.spacing(2)
931
- }
932
- }));
933
- function SKTModuleHeader() {
934
- const isDesktop = useResponsiveDesktop();
935
- return /* @__PURE__ */ jsxs(Wrapper, {
936
- id: "HeaderSkeleton",
937
- children: [/* @__PURE__ */ jsxs(ModuleTitleContent, {
938
- children: [/* @__PURE__ */ jsxs(ModuleTitle, {
939
- children: [/* @__PURE__ */ jsx(Skeleton, {
940
- variant: "circular",
941
- width: 24,
942
- height: 24
943
- }), /* @__PURE__ */ jsx(Skeleton, {
944
- variant: "text",
945
- width: 120,
946
- height: 14
947
- })]
948
- }), /* @__PURE__ */ jsx(Separator, {}), /* @__PURE__ */ jsxs(Breadcrumbs, {
949
- children: [/* @__PURE__ */ jsx(Skeleton, {
950
- variant: "text",
951
- width: 68,
952
- height: 14
953
- }), /* @__PURE__ */ jsx(Skeleton, {
954
- variant: "circular",
955
- width: 4,
956
- height: 4
957
- }), /* @__PURE__ */ jsx(Skeleton, {
958
- variant: "text",
959
- width: 68,
960
- height: 14
961
- })]
962
- })]
963
- }), /* @__PURE__ */ jsx(ModuleActions, {
964
- children: isDesktop ? /* @__PURE__ */ jsxs(Fragment, {
965
- children: [/* @__PURE__ */ jsx(Skeleton, {
966
- variant: "circular",
967
- width: 24,
968
- height: 24
969
- }), /* @__PURE__ */ jsx(Skeleton, {
970
- variant: "circular",
971
- width: 24,
972
- height: 24
973
- }), /* @__PURE__ */ jsx(Skeleton, {
974
- variant: "circular",
975
- width: 24,
976
- height: 24
977
- })]
978
- }) : /* @__PURE__ */ jsx(Skeleton, {
979
- variant: "circular",
980
- width: 24,
981
- height: 24
982
- })
456
+ return /* @__PURE__ */ jsxs(AreasAdminRoot, {
457
+ className: classesRoot,
458
+ children: [areas.map((area) => /* @__PURE__ */ jsx(AreaChip, {
459
+ areaId: area.id,
460
+ selected: area.id === currentArea,
461
+ areaName: area.name
462
+ }, area.id)), /* @__PURE__ */ jsx(IconButton, {
463
+ className: areasAdminClasses.areasAddButton,
464
+ src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.ADD_AREA}`,
465
+ size: "small",
466
+ onClick: addArea2
983
467
  })]
984
468
  });
985
469
  }
986
- function getMainActions(isDesktop, moduleActions) {
987
- let mainActions = [];
988
- if (isDesktop !== void 0 && isDesktop) {
989
- mainActions = mainActions.concat(
990
- moduleActions.filter((action) => action.visibility === "main")
991
- );
992
- }
993
- mainActions = mainActions.concat(
994
- moduleActions.filter((action) => action.visibility === "allways")
995
- );
996
- return mainActions;
997
- }
998
- function getMenuActions(isDesktop, moduleActions, urlPrefix, saveModuleCookies, version) {
999
- let menuActions = [...moduleActions.filter((action) => action.visibility !== "allways")];
1000
- if (isDesktop !== void 0 && isDesktop) {
1001
- menuActions = menuActions.filter((action) => action.visibility === "normal");
1002
- }
1003
- console.log("getMenuActions", version);
1004
- const savePropsAction = {
1005
- urlIcon: `${urlPrefix}/frontend/components/areas/assets/icons/split_vertical.svg`,
1006
- onClick: () => saveModuleCookies,
1007
- disabled: false,
1008
- visibility: "normal",
1009
- dictionaryId: getAreasDictionary("label_persist_module_cookies"),
1010
- key: "save_props"
1011
- };
1012
- menuActions.push(savePropsAction);
1013
- if (version) {
1014
- const versionAction = {
1015
- urlIcon: `${urlPrefix}/frontend/components/areas/assets/icons/version.svg`,
1016
- onClick: () => {
1017
- },
1018
- disabled: true,
1019
- visibility: "normal",
1020
- label: version,
1021
- key: "version"
1022
- };
1023
- menuActions.push(versionAction);
1024
- }
1025
- return menuActions;
1026
- }
1027
- function MainActions() {
1028
- const [moduleActions] = useWindowStore((state) => [state.moduleActions], shallow);
1029
- const {
1030
- getLabel
1031
- } = useModuleDictionary();
1032
- const isDesktop = useResponsiveDesktop();
1033
- const mainActions = useMemo(() => {
1034
- return getMainActions(isDesktop, moduleActions);
1035
- }, [moduleActions, isDesktop]);
1036
- return /* @__PURE__ */ jsx("div", {
1037
- className: areasViewerClasses.windowHeaderMainActions,
1038
- children: mainActions.map((mainAction) => {
1039
- const tooltip = mainAction.label !== void 0 ? mainAction.label : getLabel(mainAction.dictionaryId || "");
1040
- return /* @__PURE__ */ jsx(IconButton, {
1041
- src: mainAction.urlIcon,
1042
- className: mainAction.className,
1043
- onClick: mainAction.onClick,
1044
- "aria-label": mainAction.label,
1045
- disabled: mainAction.disabled,
1046
- tooltip
1047
- }, mainAction.key);
1048
- })
1049
- });
1050
- }
1051
- function Header() {
1052
- const [url_icon, title, moduleActions, onClose, container_id, version] = useWindowStore((state) => [state.url_icon, state.title, state.moduleActions, state.onClose, state.windowId, state.version], shallow);
1053
- const {
1054
- saveModuleCookies
1055
- } = useWindowStore((state) => state.internalActions);
1056
- const emergeType = useWindowStore((state) => state.emergeType);
1057
- const maximizedId = useAreaStore((state) => state.singleId);
1058
- const {
1059
- maximizeLayout,
1060
- normalizeLayouts
1061
- } = useAreaStore((state) => state.actions, shallow);
1062
- const {
1063
- host_static_assets,
1064
- environment_assets
1065
- } = useEnvironment();
1066
- const isDesktop = useResponsiveDesktop();
1067
- const isSkeleton = useModuleSkeleton();
1068
- const urlPrefix = `${host_static_assets}/${environment_assets}`;
1069
- const menuActions = useMemo(() => {
1070
- return getMenuActions(isDesktop, moduleActions, urlPrefix, saveModuleCookies, version);
1071
- }, [moduleActions, isDesktop]);
1072
- const onCloseLocal = () => {
1073
- onClose && onClose(container_id);
1074
- };
1075
- const maxNormalize = () => {
1076
- if (maximizedId) {
1077
- normalizeLayouts();
1078
- } else {
1079
- maximizeLayout(container_id);
470
+ const AreasViewerRoot = styled("div")`
471
+
472
+ /* display: flex; */
473
+ width: 100%;
474
+ height: 100%;
475
+ overflow: hidden;
476
+ /* flex-grow: 1; */
477
+ position: relative;
478
+
479
+
480
+
481
+ //areaRoot
482
+ & .${areasViewerClasses.areaRoot} {
483
+ display: none;
484
+ position: absolute;
485
+ /* flex-grow: 1; */
486
+ flex-direction: row;
487
+ inset: 0;
488
+ /* width: 100%; */
489
+ overflow: hidden;
490
+ justify-content: top;
491
+ align-items: flex-start;
492
+
493
+ visibility: hidden;
1080
494
  }
1081
- };
1082
- if (isSkeleton) {
1083
- return /* @__PURE__ */ jsx(SKTModuleHeader, {});
1084
- }
1085
- return /* @__PURE__ */ jsxs("div", {
1086
- className: clsx(areasViewerClasses.windowHeader, "m4l_draggable_handle"),
1087
- children: [/* @__PURE__ */ jsx(Icon, {
1088
- src: url_icon,
1089
- size: "medium"
1090
- }), /* @__PURE__ */ jsx(Typography, {
1091
- className: areasViewerClasses.windowHeaderTitle,
1092
- variant: "h5",
1093
- children: `${title}`
1094
- }), /* @__PURE__ */ jsx(MainActions, {}), isDesktop && emergeType === "layout" && /* @__PURE__ */ jsx(IconButton, {
1095
- onClick: maxNormalize,
1096
- "aria-label": "click",
1097
- src: maximizedId ? `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.NORMALIZE}` : `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.MAXIMIZE}`
1098
- }), menuActions.length > 0 && /* @__PURE__ */ jsx(MenuActions, {
1099
- arrowType: "no-arrow",
1100
- marginTop: "12px!important",
1101
- marginLeft: "14px!important",
1102
- anchorOrigin: {
1103
- vertical: "bottom",
1104
- horizontal: "right"
1105
- },
1106
- transformOrigin: {
1107
- vertical: "top",
1108
- horizontal: "right"
1109
- },
1110
- menuActions
1111
- }), onClose && /* @__PURE__ */ jsx(IconButton, {
1112
- onClick: onCloseLocal,
1113
- "aria-label": "click",
1114
- src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.CLOSE}`
1115
- })]
1116
- });
495
+
496
+ & .${areasViewerClasses.areaRoot}.${areasViewerClasses.selected} {
497
+ display: block;
498
+ visibility: visible;
499
+ }
500
+
501
+ &.${areasViewerClasses.isMobile} .${areasViewerClasses.areaRoot} {
502
+
503
+ }
504
+
505
+ // areaGridLayoutPanelContainer
506
+ & .${areasViewerClasses.areaGridLayoutPanelContainer} {
507
+ display: flex;
508
+ flex-direction: row;
509
+ height: 100%;
510
+ width: 100%;
511
+ overflow: hidden;
512
+ }
513
+ &.${areasViewerClasses.isMobile} .${areasViewerClasses.areaGridLayoutPanelContainer} {
514
+ flex-direction: column-reverse;
515
+ }
516
+ // areaGridLayout
517
+ & .${areasViewerClasses.areaGridLayout} {
518
+ height: 100%!important;
519
+ overflow: auto;
520
+ flex-grow: 1;
521
+ }
522
+ &.${areasViewerClasses.isMobile} .${areasViewerClasses.areaGridLayout} {
523
+ flex-direction: column-reverse;
524
+ height: unset;
525
+ width: 100%;
526
+ }
527
+ // areaGridLayoutPopupsContainer
528
+ & .${areasViewerClasses.areaGridLayoutPopupsContainer} {
529
+ z-index: 1; //Garantizar q el contenedor de los popus este por encima de los layouts
530
+ // // ' .react-draggable': {
531
+ // // position: 'absolute',
532
+ // // },
533
+ }
534
+
535
+ // PanelWindowsRoot
536
+ & .${areasViewerClasses.panelWindowsRoot} {
537
+ display: flex;
538
+ flex-direction: column;
539
+ position: relative;
540
+ }
541
+ &.${areasViewerClasses.isMobile} .${areasViewerClasses.panelWindowsRoot} {
542
+ flex-direction: row;
543
+ }
544
+ & .${areasViewerClasses.panelWindowsButtonContainer}.${areasViewerClasses.selected} {
545
+ border: 1px solid red;
546
+ }
547
+
548
+ // windowRoot
549
+ & .${areasViewerClasses.windowRoot} {
550
+ inset:0;
551
+ position: absolute;
552
+ display: flex;
553
+ flex-direction: column;
554
+ /* height: 100%; */
555
+ /* width: 100%; */
556
+ overflow: hidden;
557
+ border: 1px solid gray;
558
+
559
+ background-color: ${(props) => props.theme.palette.background.default};
560
+ padding: ${(props) => props.theme.spacing(0)};
561
+ }
562
+
563
+ & .${areasViewerClasses.windowRoot}.${areasViewerClasses.selected} {
564
+ border-top: 1px solid green;
565
+ }
566
+ // windowHeader
567
+ & .${areasViewerClasses.windowHeader} {
568
+ display: flex;
569
+ gap: 4px;
570
+
571
+ align-items: center;
572
+ position: relative;
573
+
574
+ padding: 8px;
575
+ justify-content: end;
576
+ min-height: ${(props) => props.theme.spacing(5)} ;
577
+
578
+ border-bottom: 1px solid ${(props) => props.theme.palette.divider},
579
+ overflow: hidden;
580
+ cursor: move;
581
+ height: 60px;
582
+
583
+
584
+
585
+ > span: {
586
+ margin-right: 12px;
587
+ }
588
+ }
589
+ // windowHeaderTitle
590
+ & .${areasViewerClasses.windowHeaderTitle} {
591
+ width: 100%;
592
+ max-width: 100%;
593
+ overflow: hidden;
594
+ white-space: nowrap;
595
+ color: ${(props) => props.theme.palette.text.primary};
596
+ margin-left: 12px;
597
+ margin-right: 24px;
598
+ text-overflow: ellipsis;
599
+ }
600
+ // windowHeaderMainActions
601
+ & .${areasViewerClasses.windowHeaderMainActions} {
602
+ display: flex;
603
+
604
+ gap: 4px;
605
+ }
606
+
607
+
608
+ // windowHeaderMainActions
609
+ & .${areasViewerClasses.windowContent} {
610
+ flex-grow: 1;
611
+ position: relative;
612
+ }
613
+
614
+ // windowModalRoot
615
+ & .${areasViewerClasses.windowModalRoot} .${areasViewerClasses.windowRoot}{
616
+ padding: 16px;
617
+ }
618
+
619
+ .react-grid-layout {
620
+ position: relative;
621
+ transition: height 200ms ease;
622
+ }
623
+ .react-grid-item {
624
+ transition: all 200ms ease;
625
+ transition-property: left, top;
626
+ }
627
+ .react-grid-item img {
628
+ pointer-events: none;
629
+ user-select: none;
630
+ }
631
+ .react-grid-item.cssTransforms {
632
+ transition-property: transform;
633
+ }
634
+ .react-grid-item.resizing {
635
+ z-index: 1;
636
+ will-change: width, height;
637
+ }
638
+
639
+ .react-grid-item.react-draggable-dragging {
640
+ transition: none;
641
+ z-index: 3;
642
+ will-change: transform;
643
+ }
644
+
645
+ .react-grid-item.dropping {
646
+ visibility: hidden;
647
+ }
648
+
649
+ .react-grid-item.react-grid-placeholder {
650
+ background: green;
651
+ opacity: 0.2;
652
+ transition-duration: 100ms;
653
+ z-index: 2;
654
+ -webkit-user-select: none;
655
+ -moz-user-select: none;
656
+ -ms-user-select: none;
657
+ -o-user-select: none;
658
+ user-select: none;
659
+ }
660
+
661
+ .react-grid-item > .react-resizable-handle {
662
+ position: absolute;
663
+ width: 20px;
664
+ height: 20px;
665
+ }
666
+
667
+ .react-grid-item > .react-resizable-handle::after {
668
+ content: "";
669
+ position: absolute;
670
+ right: 3px;
671
+ bottom: 3px;
672
+ width: 5px;
673
+ height: 5px;
674
+ border-right: 2px solid rgba(0, 0, 0, 0.4);
675
+ border-bottom: 2px solid rgba(0, 0, 0, 0.4);
676
+ }
677
+
678
+ .react-resizable-hide > .react-resizable-handle {
679
+ display: none;
680
+ }
681
+
682
+ .react-grid-item > .react-resizable-handle.react-resizable-handle-sw {
683
+ bottom: 0;
684
+ left: 0;
685
+ cursor: sw-resize;
686
+ transform: rotate(90deg);
687
+ }
688
+ .react-grid-item > .react-resizable-handle.react-resizable-handle-se {
689
+ bottom: 0;
690
+ right: 0;
691
+ cursor: se-resize;
692
+ }
693
+ .react-grid-item > .react-resizable-handle.react-resizable-handle-nw {
694
+ top: 0;
695
+ left: 0;
696
+ cursor: nw-resize;
697
+ transform: rotate(180deg);
698
+ }
699
+ .react-grid-item > .react-resizable-handle.react-resizable-handle-ne {
700
+ top: 0;
701
+ right: 0;
702
+ cursor: ne-resize;
703
+ transform: rotate(270deg);
704
+ }
705
+ .react-grid-item > .react-resizable-handle.react-resizable-handle-w,
706
+ .react-grid-item > .react-resizable-handle.react-resizable-handle-e {
707
+ top: 50%;
708
+ margin-top: -10px;
709
+ cursor: ew-resize;
710
+ }
711
+ .react-grid-item > .react-resizable-handle.react-resizable-handle-w {
712
+ left: 0;
713
+ transform: rotate(135deg);
714
+ }
715
+ .react-grid-item > .react-resizable-handle.react-resizable-handle-e {
716
+ right: 0;
717
+ transform: rotate(315deg);
718
+ }
719
+ .react-grid-item > .react-resizable-handle.react-resizable-handle-n,
720
+ .react-grid-item > .react-resizable-handle.react-resizable-handle-s {
721
+ left: 50%;
722
+ margin-left: -10px;
723
+ cursor: ns-resize;
724
+ }
725
+ .react-grid-item > .react-resizable-handle.react-resizable-handle-n {
726
+ top: 0;
727
+ transform: rotate(225deg);
728
+ }
729
+ .react-grid-item > .react-resizable-handle.react-resizable-handle-s {
730
+ bottom: 0;
731
+ transform: rotate(45deg);
732
+ }
733
+
734
+
735
+ ${react_resizable_css}
736
+
737
+
738
+ ${(props) => props.theme.components?.M4LAreasViewer}
739
+
740
+
741
+ `;
742
+ const ROW_HEIGTH_GRIDLAYOUT = 100;
743
+ const CONTAINER_PADDING_GRIDLAYOUT = 3;
744
+ const DEBOUCED_SAVE_TIME = 500;
745
+ const COOKIE_BREAKPOINT_LAYOUTS = "layoutPros";
746
+ const COOKIE_WINDOWS = "windows";
747
+ const NORMALIZED_BREAKPOINTS = { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 };
748
+ const NORMALIZED_COLS = { lg: 24, md: 20, sm: 12, xs: 8, xxs: 2 };
749
+ const MAXIMIZED_COLS = { lg: 24, md: 20, sm: 12, xs: 8, xxs: 2 };
750
+ const getParmsFromValue = (key, data) => {
751
+ try {
752
+ if (Array.isArray(data)) {
753
+ let ob = data.find((f) => f.id === key);
754
+ if (ob) {
755
+ ob = JSON.parse(ob.value);
756
+ }
757
+ return ob;
758
+ }
759
+ } catch (error) {
760
+ }
761
+ return void 0;
762
+ };
763
+ function setAddBreakPoints(state, newLayout) {
764
+ const layoutsBreakPoints = state.breakpointsLayouts;
765
+ const beforeMaximizebreakpointsLayouts = state.beforeMaximizebreakpointsLayouts;
766
+ for (const key in layoutsBreakPoints) {
767
+ const layoutBreakpoint = layoutsBreakPoints[key];
768
+ layoutBreakpoint.push(newLayout);
769
+ }
770
+ if (state.viewMode === "single") {
771
+ for (const key in beforeMaximizebreakpointsLayouts) {
772
+ const beforeLayoutBreakpoint = beforeMaximizebreakpointsLayouts[key];
773
+ beforeLayoutBreakpoint.push(newLayout);
774
+ }
775
+ }
776
+ return layoutsBreakPoints;
1117
777
  }
1118
- const WrapperLinearProgress = styled$1("div")(() => ({
1119
- width: "70%",
1120
- margin: "auto auto"
1121
- }));
1122
- const WrapperFallBackNotFound = styled$1("div")(({
1123
- theme
1124
- }) => ({
1125
- width: "100%",
1126
- height: "100%",
1127
- display: "flex",
1128
- flexDirection: "column",
1129
- justifyContent: "center",
1130
- alignItems: "center",
1131
- gap: theme.spacing(3)
1132
- }));
1133
- function FallBackNotFound(props) {
1134
- const {
1135
- setNetworkRefresh
1136
- } = props;
1137
- const {
1138
- getLabel
1139
- } = useModuleDictionary();
1140
- const {
1141
- host_static_assets,
1142
- environment_assets
1143
- } = useEnvironment();
1144
- const handlerClick = () => {
1145
- setNetworkRefresh((prop) => !prop);
1146
- };
1147
- return /* @__PURE__ */ jsxs(WrapperFallBackNotFound, {
1148
- children: [/* @__PURE__ */ jsx(m.div, {
1149
- variants: varBounce().in,
1150
- children: /* @__PURE__ */ jsx(Typography$1, {
1151
- variant: "h3",
1152
- paragraph: true,
1153
- children: getLabel("loading_mf_title")
1154
- })
1155
- }), /* @__PURE__ */ jsx(Typography$1, {
1156
- sx: {
1157
- color: "text.secondary"
1158
- },
1159
- children: getLabel("loading_mf_description")
1160
- }), /* @__PURE__ */ jsx(m.div, {
1161
- variants: varBounce().in,
1162
- children: /* @__PURE__ */ jsx(Image, {
1163
- src: `${host_static_assets}/${environment_assets}/frontend/domain/host/commons/assets/img/illustration_noauth.png`,
1164
- ratio: "1:1"
1165
- })
1166
- }), /* @__PURE__ */ jsx(Button, {
1167
- size: "medium",
1168
- variant: "contained",
1169
- onClick: handlerClick,
1170
- children: getLabel("loading_mf_intro")
1171
- })]
1172
- });
778
+ function setBreakPointsMaximized(state, layoutId) {
779
+ const layoutsBreakPoints = state.breakpointsLayouts;
780
+ const container = document.getElementsByClassName(`${areasViewerClasses.areaRoot}`)[0];
781
+ console.log(`Setting breakpoints`, container);
782
+ if (container) {
783
+ const clientHeight = container.clientHeight;
784
+ for (const key in layoutsBreakPoints) {
785
+ const layoutBreakpoint = layoutsBreakPoints[key];
786
+ const cols = key in MAXIMIZED_COLS ? MAXIMIZED_COLS[key] : 1;
787
+ const heigth_by_rowheigth = clientHeight / (ROW_HEIGTH_GRIDLAYOUT + 2 * CONTAINER_PADDING_GRIDLAYOUT);
788
+ for (let index = 0; index < layoutBreakpoint.length; index++) {
789
+ const l = layoutBreakpoint[index];
790
+ if (l.i === layoutId) {
791
+ l.x = 0;
792
+ l.y = 0;
793
+ l.h = heigth_by_rowheigth;
794
+ l.w = cols;
795
+ l.minW = 0;
796
+ l.maxW = cols;
797
+ l.minH = 0;
798
+ l.maxH = heigth_by_rowheigth;
799
+ l.isResizable = false;
800
+ l.isDraggable = false;
801
+ } else {
802
+ l.x = 0;
803
+ l.y = 1;
804
+ l.h = 0;
805
+ l.w = 0;
806
+ l.minW = 0;
807
+ l.maxW = 0;
808
+ l.minH = 0;
809
+ l.maxH = 0;
810
+ }
811
+ l.isResizable = false;
812
+ l.isDraggable = false;
813
+ }
814
+ }
815
+ }
816
+ return layoutsBreakPoints;
1173
817
  }
1174
- const LoadingMF = (props) => {
1175
- const {
1176
- loadingProgress,
1177
- setNetworkRefresh
1178
- } = props;
1179
- if (loadingProgress !== -1) {
1180
- return /* @__PURE__ */ jsx(WrapperLinearProgress, {
1181
- id: "WrapperLinearProgress",
1182
- children: /* @__PURE__ */ jsx(LinearProgress, {
1183
- variant: "determinate",
1184
- value: loadingProgress
1185
- })
1186
- });
818
+ function getDataFromResponse(data, state) {
819
+ const newBreakPointsLayouts = getParmsFromValue(COOKIE_BREAKPOINT_LAYOUTS, data);
820
+ const windows = getParmsFromValue(COOKIE_WINDOWS, data);
821
+ const newGridLayouts = [];
822
+ const newHashWindowLayouts = {};
823
+ if (windows) {
824
+ for (const key in windows) {
825
+ const element = windows[key];
826
+ if (element && element["layoutProps"] && element["mfProps"] && element["emergeType"] === "layout" && element["winType"] === "microfrontend") {
827
+ element["layoutProps"].i = key;
828
+ newGridLayouts.push(element["layoutProps"]);
829
+ newHashWindowLayouts[key] = {
830
+ ...element,
831
+ windowId: key,
832
+ emergeType: "layout",
833
+ onClose: state.actions.closeWindowLayout
834
+ };
835
+ }
836
+ }
1187
837
  }
1188
- return /* @__PURE__ */ jsx(FallBackNotFound, {
1189
- setNetworkRefresh
1190
- });
838
+ return {
839
+ newBreakPointsLayouts,
840
+ newGridLayouts,
841
+ newHashWindowLayouts
842
+ };
843
+ }
844
+ const createAreaStore = (initProps) => {
845
+ const startProps = {
846
+ zPopUpIndex: 999,
847
+ status: "init",
848
+ breakpointsLayouts: {},
849
+ beforeMaximizebreakpointsLayouts: {},
850
+ gridLayouts: [],
851
+ windowModal: null,
852
+ windowsPopUps: [],
853
+ hashWindowsPopups: {},
854
+ hashWindowsLayouts: {},
855
+ currentLayoutId: "",
856
+ currentPopUpId: "",
857
+ viewMode: initProps.isDesktop ? "multiple" : "single",
858
+ breakpoints: NORMALIZED_BREAKPOINTS,
859
+ cols: NORMALIZED_COLS,
860
+ ...initProps
861
+ };
862
+ return createStore(
863
+ devtools(
864
+ immer((set, get) => ({
865
+ ...startProps,
866
+ actions: {
867
+ addWindow: (newWindowProps) => {
868
+ const windowId = `${get().id}_window_${new Date().getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
869
+ console.log("addWindow", newWindowProps.emergeType);
870
+ if (newWindowProps.emergeType === "layout") {
871
+ get().actions.addWindowLayout(windowId, newWindowProps);
872
+ } else if (newWindowProps.emergeType === "popup") {
873
+ get().actions.addWindowPopUp(windowId, newWindowProps);
874
+ } else if (newWindowProps.emergeType === "modal") {
875
+ get().actions.addWindowModal(windowId, newWindowProps);
876
+ }
877
+ },
878
+ closeWindowModal: () => {
879
+ set((state) => {
880
+ state.windowModal = void 0;
881
+ });
882
+ },
883
+ addWindowModal: (container_id, newWindowModalProps) => {
884
+ set((state) => {
885
+ state.windowModal = { ...newWindowModalProps, windowId: container_id };
886
+ });
887
+ },
888
+ closeWindowPopUp: (removePopUpId) => {
889
+ set((state) => {
890
+ const removeIndex = state.windowsPopUps.findIndex(
891
+ (wpId) => wpId === removePopUpId
892
+ );
893
+ if (removeIndex > -1) {
894
+ state.windowsPopUps.splice(removeIndex, 1);
895
+ }
896
+ delete state.hashWindowsPopups[removePopUpId];
897
+ });
898
+ },
899
+ addWindowPopUp: (windowId, newWindowPopupProps) => {
900
+ let popUpId = windowId;
901
+ set((state) => {
902
+ if (newWindowPopupProps.replaceMeId) {
903
+ for (const key in state.hashWindowsPopups) {
904
+ const WindoPopUp = state.hashWindowsPopups[key];
905
+ if (WindoPopUp.replaceMeId === newWindowPopupProps.replaceMeId) {
906
+ popUpId = key;
907
+ state.hashWindowsPopups[key].dynamicParams = newWindowPopupProps.dynamicParams;
908
+ break;
909
+ }
910
+ }
911
+ }
912
+ if (popUpId === windowId) {
913
+ state.windowsPopUps.push(windowId);
914
+ state.hashWindowsPopups[windowId] = {
915
+ ...newWindowPopupProps,
916
+ emergeType: "popup",
917
+ windowId,
918
+ onClose: get().actions.closeWindowPopUp,
919
+ zIndex: state.zPopUpIndex
920
+ };
921
+ state.currentPopUpId = windowId;
922
+ }
923
+ });
924
+ get().actions.selectWindowPopUp(popUpId);
925
+ },
926
+ closeWindowLayout: (removeLayoutId) => {
927
+ set((state) => {
928
+ const removeIndex = state.gridLayouts.findIndex(
929
+ (gl) => gl.i === removeLayoutId
930
+ );
931
+ if (removeIndex > -1) {
932
+ state.gridLayouts.splice(removeIndex, 1);
933
+ }
934
+ delete state.hashWindowsLayouts[removeLayoutId];
935
+ });
936
+ get().actions.saveLayouts();
937
+ if (get().singleId === removeLayoutId) {
938
+ get().actions.maximizeLayout();
939
+ }
940
+ },
941
+ addWindowLayout: (windowId, newWindow) => {
942
+ const newLayout = {
943
+ ...newWindow.layoutProps,
944
+ i: windowId,
945
+ isDraggable: true,
946
+ isResizable: true,
947
+ winType: newWindow.winType
948
+ };
949
+ set((state) => {
950
+ state.gridLayouts.push(newLayout);
951
+ state.hashWindowsLayouts[windowId] = {
952
+ ...newWindow,
953
+ windowId,
954
+ emergeType: "layout",
955
+ onClose: get().actions.closeWindowLayout
956
+ };
957
+ setAddBreakPoints(state, newLayout);
958
+ });
959
+ get().actions.selectWindowLayout(windowId);
960
+ if (get().viewMode === "single") {
961
+ get().actions.maximizeLayout(windowId);
962
+ }
963
+ get().actions.saveLayouts();
964
+ get().actions.bouncedSaveBreakpointsLayouts();
965
+ },
966
+ saveLayouts: () => {
967
+ let nrKeys = 0;
968
+ const saveObjetc = {};
969
+ for (const key in get().hashWindowsLayouts) {
970
+ const element = get().hashWindowsLayouts[key];
971
+ if (element.winType === "microfrontend") {
972
+ const newElement = { ...element };
973
+ delete newElement.onClose;
974
+ delete newElement.devCookies;
975
+ saveObjetc[key] = newElement;
976
+ nrKeys++;
977
+ }
978
+ }
979
+ if (nrKeys > 0) {
980
+ get().networkOperation({
981
+ method: "PUT",
982
+ endPoint: `cookies/${get().id}/${COOKIE_WINDOWS}`,
983
+ data: {
984
+ value: JSON.stringify(saveObjetc)
985
+ },
986
+ toastSuccess: false,
987
+ toastError: false
988
+ });
989
+ } else {
990
+ get().networkOperation({
991
+ method: "DELETE",
992
+ endPoint: `cookies`,
993
+ data: { f: [{ n: "container_id", o: "c", o1: get().id }] },
994
+ toastSuccess: false,
995
+ toastError: false
996
+ });
997
+ }
998
+ },
999
+ bouncedSaveBreakpointsLayouts: debounce(
1000
+ () => {
1001
+ const purgedLayouts = {
1002
+ ...get().viewMode === "multiple" ? get().breakpointsLayouts : get().beforeMaximizebreakpointsLayouts
1003
+ };
1004
+ const finalLayouts = {};
1005
+ for (const key in purgedLayouts) {
1006
+ const element = purgedLayouts[key];
1007
+ purgedLayouts[key] = element.filter((l) => {
1008
+ if (l.i === "none") {
1009
+ return false;
1010
+ }
1011
+ if (get().hashWindowsLayouts[l.i]) {
1012
+ return true;
1013
+ }
1014
+ return false;
1015
+ });
1016
+ if (purgedLayouts[key].length > 0) {
1017
+ finalLayouts[key] = purgedLayouts[key];
1018
+ }
1019
+ }
1020
+ if (Object.keys(finalLayouts).length > 0) {
1021
+ get().networkOperation({
1022
+ method: "PUT",
1023
+ endPoint: `cookies/${get().id}/${COOKIE_BREAKPOINT_LAYOUTS}`,
1024
+ data: {
1025
+ value: JSON.stringify(finalLayouts)
1026
+ },
1027
+ toastSuccess: false,
1028
+ toastError: false
1029
+ });
1030
+ }
1031
+ },
1032
+ DEBOUCED_SAVE_TIME
1033
+ ),
1034
+ onBreakpointsLayoutsChange: (_currentLayouts, newAllLayouts) => {
1035
+ set((state) => {
1036
+ state.breakpointsLayouts = newAllLayouts;
1037
+ });
1038
+ if (!get().singleId) {
1039
+ get().actions.bouncedSaveBreakpointsLayouts();
1040
+ }
1041
+ },
1042
+ selectWindowLayout: (layoutId) => {
1043
+ set((state) => {
1044
+ state.currentLayoutId = layoutId;
1045
+ if (state.currentPopUpId !== "" && state.hashWindowsPopups[state.currentPopUpId]) {
1046
+ const windowPopup = state.hashWindowsPopups[state.currentPopUpId];
1047
+ if (windowPopup.parentLayoutId !== layoutId) {
1048
+ state.currentPopUpId = "";
1049
+ }
1050
+ }
1051
+ });
1052
+ },
1053
+ selectWindowPopUp: (popUpId) => {
1054
+ set((state) => {
1055
+ state.zPopUpIndex++;
1056
+ state.currentPopUpId = popUpId;
1057
+ state.zPopUpIndex++;
1058
+ state.currentPopUpId = popUpId;
1059
+ state.hashWindowsPopups[popUpId].zIndex = state.zPopUpIndex;
1060
+ if (state.hashWindowsPopups[popUpId].parentLayoutId && state.hashWindowsPopups[popUpId].parentLayoutId !== "") {
1061
+ state.currentLayoutId = state.hashWindowsPopups[popUpId].parentLayoutId;
1062
+ } else {
1063
+ state.currentLayoutId = "";
1064
+ }
1065
+ });
1066
+ setTimeout(() => {
1067
+ const container = document.getElementsByClassName(
1068
+ `${areasViewerClasses.areaGridLayoutPanelContainer}-${get().id}`
1069
+ )[0];
1070
+ const element = document.getElementsByClassName(
1071
+ `${areasViewerClasses.windowPopupRoot}-${popUpId}`
1072
+ )[0];
1073
+ if (element && container) {
1074
+ const { top, left } = element.getBoundingClientRect();
1075
+ const { top: containerTop, left: containerLeft } = container.getBoundingClientRect();
1076
+ container.scrollTop = container.scrollTop + top - containerTop;
1077
+ container.scrollLeft = container.scrollLeft + left - containerLeft;
1078
+ }
1079
+ }, 100);
1080
+ },
1081
+ maximizeLayout: (layoutId) => {
1082
+ let finalLayoutId = layoutId;
1083
+ set((state) => {
1084
+ if (state.viewMode === "multiple") {
1085
+ state.beforeMaximizebreakpointsLayouts = cloneDeep(
1086
+ state.breakpointsLayouts
1087
+ );
1088
+ }
1089
+ if (!finalLayoutId) {
1090
+ if (state.gridLayouts.length > 0) {
1091
+ finalLayoutId = state.gridLayouts[0].i;
1092
+ }
1093
+ }
1094
+ state.viewMode = "single";
1095
+ state.singleId = finalLayoutId;
1096
+ setBreakPointsMaximized(state, finalLayoutId);
1097
+ });
1098
+ if (finalLayoutId) {
1099
+ get().actions.selectWindowLayout(finalLayoutId);
1100
+ }
1101
+ },
1102
+ normalizeLayouts: () => {
1103
+ set((state) => {
1104
+ if (!state.isDesktop)
1105
+ return;
1106
+ if (state.isDesktop && state.viewMode === "single") {
1107
+ state.viewMode = "multiple";
1108
+ state.singleId = void 0;
1109
+ state.breakpointsLayouts = state.beforeMaximizebreakpointsLayouts;
1110
+ }
1111
+ });
1112
+ }
1113
+ },
1114
+ internalActions: {
1115
+ loadFromApi: () => {
1116
+ if (get().status !== "init") {
1117
+ return;
1118
+ }
1119
+ if (!get().loadAreasFromNetwork || !get().loadWindows) {
1120
+ set((state) => {
1121
+ state.status = "loaded";
1122
+ });
1123
+ return;
1124
+ }
1125
+ get().networkOperation({
1126
+ method: "GET",
1127
+ endPoint: `cookies`,
1128
+ parms: { f: [{ n: "container_id", o: "e", o1: get().id }] },
1129
+ toastSuccess: false,
1130
+ toastError: false
1131
+ }).then((response) => {
1132
+ set((state) => {
1133
+ const {
1134
+ newBreakPointsLayouts,
1135
+ newGridLayouts,
1136
+ newHashWindowLayouts
1137
+ } = getDataFromResponse(response.data, state);
1138
+ if (state.viewMode === "multiple") {
1139
+ state.breakpointsLayouts = newBreakPointsLayouts;
1140
+ } else {
1141
+ state.breakpointsLayouts = newBreakPointsLayouts;
1142
+ state.beforeMaximizebreakpointsLayouts = newBreakPointsLayouts;
1143
+ }
1144
+ state.gridLayouts = newGridLayouts;
1145
+ state.hashWindowsLayouts = newHashWindowLayouts;
1146
+ state.status = "loaded";
1147
+ });
1148
+ console.log("loadFromApi", get().viewMode);
1149
+ if (get().viewMode === "single") {
1150
+ get().actions.maximizeLayout();
1151
+ }
1152
+ }).catch((_response) => {
1153
+ set((state) => {
1154
+ state.status = "loaded";
1155
+ });
1156
+ });
1157
+ },
1158
+ changeDesktopBreakpoint: (isDesktop) => {
1159
+ const previousState = get().isDesktop;
1160
+ set((state) => {
1161
+ state.isDesktop = isDesktop;
1162
+ });
1163
+ if (previousState != isDesktop) {
1164
+ if (isDesktop) {
1165
+ get().actions.normalizeLayouts();
1166
+ } else {
1167
+ if (get().viewMode === "multiple") {
1168
+ if (get().gridLayouts.length > 0) {
1169
+ get().actions.maximizeLayout(get().gridLayouts[0].i);
1170
+ }
1171
+ }
1172
+ }
1173
+ }
1174
+ }
1175
+ }
1176
+ })),
1177
+ { name: `Area state ${initProps.id}` }
1178
+ )
1179
+ );
1191
1180
  };
1192
- function getDivScritId(prefix, moduleId) {
1193
- const rotational_id = `${Math.round(new Date().getTime() / 1e3)}_rnd_${Math.round(Math.random() * 1e3)}`;
1194
- return {
1195
- divContainerId: `container_${prefix}_${moduleId}_${rotational_id}`,
1196
- scriptId: `script_${moduleId}_${rotational_id}`,
1197
- moduleId
1198
- };
1199
- }
1200
- function MFLoader(props) {
1181
+ const AreaContext = createContext(null);
1182
+ const AreaProvider = (props) => {
1201
1183
  const {
1202
- prefix,
1203
- moduleId,
1204
- cache = true,
1205
- debug_port,
1206
- dynamicMFStore,
1207
- windowTools
1184
+ children,
1185
+ id,
1186
+ selected: active,
1187
+ loadWindows = true
1208
1188
  } = props;
1189
+ const [loadAreasFromNetwork, loadCookiesFromNetwork] = useAreasStore((state) => [state.loadAreasFromNetwork, state.loadCookiesFromNetwork], shallow);
1209
1190
  const {
1210
- hostThemeOptions,
1211
- fnComponentsOverrides
1212
- } = useHostTheme();
1191
+ setAreaLink
1192
+ } = useAreasStore((state) => state.internalActions);
1193
+ const isDesktop = useResponsiveDesktop();
1194
+ const isFirstRender = useFirstRender([isDesktop]);
1213
1195
  const {
1214
1196
  networkOperation
1215
1197
  } = useNetwork();
1216
- const environment = useEnvironment();
1217
- const hostTools = useHostTools();
1218
- const formatter = useFormatter();
1219
- const [isLoading, setIsLoading] = useState(true);
1220
- const [networkProgress, setNetworkProgress] = useState(-1);
1221
- const [_networkRefresh, setNetworkRefresh] = useState(false);
1222
- const {
1223
- currentLocale
1224
- } = useLocales();
1225
- const [divScript, setDivScript] = useState(getDivScritId(prefix, moduleId));
1226
- const refTime = useRef(0);
1227
- const isFirstRender = useFirstRender([moduleId]);
1228
- const final_host = environment.isLocalhost ? `https://localhost:${debug_port}` : `https://${window.location.host}/mf/${moduleId}`;
1229
- function cleanUp(dScript) {
1230
- try {
1231
- if (window[`unmount_${prefix}_${dScript.moduleId}`]) {
1232
- window[`unmount_${prefix}_${dScript.moduleId}`](dScript.divContainerId);
1233
- }
1234
- } catch (error) {
1235
- }
1236
- if (!cache) {
1237
- const script = document.getElementById(dScript.scriptId);
1238
- if (script) {
1239
- try {
1240
- document.head.removeChild(script);
1241
- delete window[`render_${prefix}_${dScript.moduleId}`];
1242
- delete window[`unmount_${prefix}_${dScript.moduleId}`];
1243
- } catch (error) {
1244
- }
1245
- }
1246
- }
1198
+ const areaStoreRef = useRef();
1199
+ if (!areaStoreRef.current) {
1200
+ areaStoreRef.current = createAreaStore({
1201
+ id,
1202
+ networkOperation,
1203
+ loadAreasFromNetwork,
1204
+ loadCookiesFromNetwork,
1205
+ loadWindows,
1206
+ isDesktop: !!isDesktop
1207
+ });
1247
1208
  }
1248
- const renderMicroFrontend = useCallback((newDScript) => {
1249
- try {
1250
- setIsLoading(false);
1251
- window[`render_${prefix}_${newDScript.moduleId}`](newDScript.divContainerId, environment, hostTools, currentLocale, {
1252
- hostThemeOptions,
1253
- fnComponentsOverrides
1254
- }, axiosOperation, formatter, dynamicMFStore, windowTools);
1255
- } catch (error) {
1256
- }
1257
- }, [hostThemeOptions, currentLocale, formatter]);
1258
- const debouncedSetDivScript = useCallback(debounce((newName) => {
1259
- const newDivScript = getDivScritId(prefix, newName);
1260
- if (newName !== divScript.moduleId) {
1261
- setDivScript({
1262
- ...newDivScript
1263
- });
1264
- }
1265
- }, 200), [divScript]);
1209
+ const {
1210
+ loadFromApi,
1211
+ changeDesktopBreakpoint
1212
+ } = useStore(areaStoreRef.current, (state) => state.internalActions, shallow);
1213
+ const status = useStore(areaStoreRef.current, (state) => state.status, shallow);
1266
1214
  useEffect(() => {
1267
1215
  if (!isFirstRender) {
1268
- debouncedSetDivScript(moduleId + "");
1269
- if (moduleId !== divScript.moduleId)
1270
- ;
1216
+ changeDesktopBreakpoint(!!isDesktop);
1217
+ }
1218
+ }, [isDesktop]);
1219
+ useEffect(() => {
1220
+ if (areaStoreRef.current) {
1221
+ setAreaLink(id, areaStoreRef.current);
1271
1222
  }
1272
1223
  return () => {
1273
1224
  };
1274
- }, [moduleId]);
1225
+ }, []);
1275
1226
  useEffect(() => {
1276
- setIsLoading(true);
1277
- let mounted = true;
1278
- const controller = new AbortController();
1279
- const dsScript = {
1280
- ...divScript
1281
- };
1282
- const loadIfNotLoaded = async () => {
1283
- if (!window[`render_${prefix}_${moduleId}`]) {
1284
- let urlFile = "";
1285
- setNetworkProgress(0);
1286
- const manifest = await fetch(`${final_host}/manifest.json?rnd=${Math.random()}`).then((res) => res.json()).catch(() => {
1287
- console.debug("Error fetching manifest", `${final_host}/manifest.json`);
1288
- return void 0;
1289
- });
1290
- if (!manifest) {
1291
- return;
1227
+ if (active && status === "init") {
1228
+ loadFromApi();
1229
+ }
1230
+ }, [active]);
1231
+ return /* @__PURE__ */ jsx(AreaContext.Provider, {
1232
+ value: areaStoreRef.current,
1233
+ children
1234
+ });
1235
+ };
1236
+ if (process.env.NODE_ENV !== "production") {
1237
+ AreaProvider.displayName = "AreaProvider";
1238
+ }
1239
+ React__default.memo(AreaProvider);
1240
+ const useArea = () => {
1241
+ const context = useContext(AreaContext);
1242
+ if (!context)
1243
+ throw new Error("useArea context must be use inside AreaContext");
1244
+ return context;
1245
+ };
1246
+ function useAreaStore(selector, equalityFn) {
1247
+ const context = useContext(AreaContext);
1248
+ if (!context)
1249
+ throw new Error("useAreaStore context must be use inside AreaContext");
1250
+ return useStore(context, selector, equalityFn);
1251
+ }
1252
+ const WindowToolsMFContext = createContext(null);
1253
+ function WindowToolsMFProvider(props) {
1254
+ const {
1255
+ children,
1256
+ ...other
1257
+ } = props;
1258
+ return /* @__PURE__ */ jsx(WindowToolsMFContext.Provider, {
1259
+ value: {
1260
+ ...other
1261
+ },
1262
+ children
1263
+ });
1264
+ }
1265
+ React__default.memo(WindowToolsMFProvider);
1266
+ const DynamicMFParmsContext = createContext(null);
1267
+ function DynamicMFParmsProvider(props) {
1268
+ const {
1269
+ children,
1270
+ store
1271
+ } = props;
1272
+ return /* @__PURE__ */ jsx(DynamicMFParmsContext.Provider, {
1273
+ value: store,
1274
+ children
1275
+ });
1276
+ }
1277
+ const MemonizedDynamicMFParmsProvider = React__default.memo(DynamicMFParmsProvider);
1278
+ const createDynamicMFStore = (initProps) => {
1279
+ const startProps = {
1280
+ ...initProps
1281
+ };
1282
+ return createStore(
1283
+ devtools(
1284
+ immer((set, _get) => ({
1285
+ ...startProps,
1286
+ actions: {
1287
+ changeData: (newDynamicMFState) => {
1288
+ set((state) => {
1289
+ state.dynamicMFParameters = newDynamicMFState;
1290
+ });
1291
+ }
1292
1292
  }
1293
- setNetworkProgress(10);
1294
- if (mounted) {
1295
- urlFile = `${final_host}/${manifest["src/index.tsx"]["file"]}?rnd=${Math.random()}`;
1296
- refTime.current = 0;
1297
- await networkOperation({
1298
- method: "GET",
1299
- endPoint: urlFile,
1300
- isRemote: !environment.isLocalhost,
1301
- headers: {
1302
- "Content-Type": "application/json"
1303
- },
1304
- onDownloadProgress: (progressEvent) => {
1305
- let percentCompleted = 0;
1306
- try {
1307
- if (progressEvent.lengthComputable) {
1308
- percentCompleted = 10 + Math.round(progressEvent.loaded * 90 / progressEvent.total);
1309
- } else {
1310
- if (refTime.current === 0) {
1311
- refTime.current = new Date().getTime();
1312
- }
1313
- percentCompleted = 10 + progressEvent.loaded / 15e5 * 90;
1314
- if (percentCompleted > 95)
1315
- percentCompleted = 95;
1316
- }
1317
- } catch (error) {
1318
- }
1319
- if (mounted) {
1320
- setNetworkProgress(percentCompleted);
1321
- }
1322
- },
1323
- isExternalUrl: true,
1324
- responseType: "text",
1325
- signal: controller.signal
1326
- }).then(() => {
1327
- if (mounted) {
1328
- setNetworkProgress(100);
1293
+ })),
1294
+ { name: `dyamic store ${initProps.windowId}` }
1295
+ )
1296
+ );
1297
+ };
1298
+ function getCookiesContainer(data, containerId) {
1299
+ const cookies = {};
1300
+ try {
1301
+ if (Array.isArray(data)) {
1302
+ for (let i = 0; i < data.length; i++) {
1303
+ if (data[i]?.container_id === containerId && data[i]?.id) {
1304
+ cookies[data[i]?.id] = JSON.parse(data[i].value);
1305
+ }
1306
+ }
1307
+ }
1308
+ } catch (error) {
1309
+ }
1310
+ return cookies;
1311
+ }
1312
+ const createWindowStore = (initProps) => {
1313
+ const startProps = {
1314
+ status: "init",
1315
+ moduleActions: [],
1316
+ cookies: initProps.devCookies || { moduleCookies: {}, windowCookies: {} },
1317
+ ...initProps
1318
+ };
1319
+ delete startProps.devCookies;
1320
+ return createStore(
1321
+ devtools(
1322
+ immer((set, get, _api) => ({
1323
+ ...startProps,
1324
+ actions: {
1325
+ setActions: (newActions, version) => {
1326
+ set((state) => {
1327
+ state.moduleActions = cloneDeep(newActions);
1328
+ state.version = version;
1329
+ console.log("LLEGO Version", version);
1330
+ });
1331
+ },
1332
+ close: () => {
1333
+ const onClose = get().onClose;
1334
+ if (onClose) {
1335
+ onClose(get().windowId);
1336
+ }
1337
+ },
1338
+ getWindowId: () => {
1339
+ return get().windowId;
1340
+ },
1341
+ getCookie: (id) => {
1342
+ return get().cookies.windowCookies[id] || get().cookies.moduleCookies[id];
1343
+ },
1344
+ getCookies: (type) => {
1345
+ if (type === "window") {
1346
+ return get().cookies.windowCookies;
1347
+ } else {
1348
+ return get().cookies.moduleCookies;
1329
1349
  }
1330
- }).catch(() => {
1331
- });
1332
- if (mounted) {
1333
- const script = document.createElement("script");
1334
- script.id = divScript.scriptId;
1335
- script.crossOrigin = "";
1336
- script.type = "module";
1337
- script.src = urlFile || "";
1338
- script.onload = () => {
1339
- if (mounted) {
1340
- console.debug("Script loaded", new Date().getTime());
1341
- setNetworkProgress(100);
1342
- renderMicroFrontend(dsScript);
1350
+ },
1351
+ setCookie: (id, type, cookie) => {
1352
+ get().networkOperation({
1353
+ method: "PUT",
1354
+ endPoint: `cookies/${type === "module" ? get().moduleId : get().windowId}/${id}`,
1355
+ data: {
1356
+ value: JSON.stringify(cookie)
1357
+ },
1358
+ toastSuccess: false,
1359
+ toastError: false
1360
+ });
1361
+ set((state) => {
1362
+ if (type === "window") {
1363
+ state.cookies.windowCookies[id] = cookie;
1364
+ } else {
1365
+ state.cookies.moduleCookies[id] = cookie;
1343
1366
  }
1344
- };
1345
- document.head.appendChild(script);
1346
- console.debug("Script appened", new Date().getTime());
1367
+ });
1368
+ }
1369
+ },
1370
+ internalActions: {
1371
+ loadCookiesFromApi: () => {
1372
+ if (get().status === "init") {
1373
+ get().networkOperation({
1374
+ method: "GET",
1375
+ endPoint: `cookies`,
1376
+ parms: {
1377
+ f: [
1378
+ { n: "container_id", o: "e", o1: get().windowId },
1379
+ { n: "container_id", o: "e", o1: get().moduleId }
1380
+ ]
1381
+ },
1382
+ toastSuccess: false,
1383
+ toastError: false
1384
+ }).then((response) => {
1385
+ set((state) => {
1386
+ state.cookies.moduleCookies = getCookiesContainer(
1387
+ response.data,
1388
+ state.moduleId
1389
+ );
1390
+ state.cookies.windowCookies = getCookiesContainer(
1391
+ response.data,
1392
+ state.windowId
1393
+ );
1394
+ state.status = "loaded";
1395
+ });
1396
+ }).catch((_response) => {
1397
+ set((state) => {
1398
+ state.status = "loaded";
1399
+ });
1400
+ });
1401
+ }
1402
+ },
1403
+ saveModuleCookies: () => {
1404
+ for (const key in get().cookies.windowCookies) {
1405
+ const cookie = get().cookies.windowCookies[key];
1406
+ get().networkOperation({
1407
+ method: "PUT",
1408
+ endPoint: `cookies/${get().moduleId}/${key}`,
1409
+ data: {
1410
+ value: JSON.stringify(cookie)
1411
+ },
1412
+ toastSuccess: false,
1413
+ toastError: false
1414
+ });
1415
+ }
1347
1416
  }
1348
1417
  }
1349
- } else {
1350
- if (mounted) {
1351
- renderMicroFrontend(dsScript);
1352
- }
1418
+ })),
1419
+ {
1420
+ name: `window store ${initProps.windowId}`,
1421
+ store: `window dev store ${initProps.windowId}`,
1422
+ trace: true
1353
1423
  }
1354
- };
1355
- loadIfNotLoaded();
1424
+ )
1425
+ );
1426
+ };
1427
+ const WindowContext = createContext(null);
1428
+ function WindowMFProvider(props) {
1429
+ const {
1430
+ children,
1431
+ ...other
1432
+ } = props;
1433
+ const {
1434
+ networkOperation
1435
+ } = useNetwork();
1436
+ const windowStoreRef = useRef();
1437
+ const dynamicMFStoreRef = useRef();
1438
+ const areaStore = useArea();
1439
+ const areasStore = useAreas();
1440
+ if (!dynamicMFStoreRef.current) {
1441
+ dynamicMFStoreRef.current = createDynamicMFStore({
1442
+ dynamicMFParameters: props.dynamicParams,
1443
+ windowId: props.windowId
1444
+ });
1445
+ }
1446
+ if (!windowStoreRef.current) {
1447
+ windowStoreRef.current = createWindowStore({
1448
+ ...other,
1449
+ dynamicMFStore: dynamicMFStoreRef.current,
1450
+ networkOperation,
1451
+ areaStore,
1452
+ areasStore
1453
+ });
1454
+ }
1455
+ useEffect(() => {
1456
+ windowStoreRef.current?.getState().internalActions.loadCookiesFromApi();
1356
1457
  return () => {
1357
- mounted = false;
1358
- controller.abort();
1359
- cleanUp(dsScript);
1458
+ console.debug("useEffect cleanUP WindowMFProvider", props.windowId, windowStoreRef.current);
1360
1459
  };
1361
- }, [divScript]);
1362
- return /* @__PURE__ */ jsxs(Fragment, {
1363
- children: [/* @__PURE__ */ jsx("div", {
1364
- id: divScript.divContainerId
1365
- }), isLoading ? /* @__PURE__ */ jsx(LoadingMF, {
1366
- loadingProgress: networkProgress,
1367
- setNetworkRefresh
1368
- }) : null]
1460
+ }, []);
1461
+ useEffect(() => {
1462
+ if (windowStoreRef.current?.getState().status === "loaded") {
1463
+ dynamicMFStoreRef.current?.getState().actions.changeData(props.dynamicParams);
1464
+ }
1465
+ }, [props.dynamicParams]);
1466
+ return /* @__PURE__ */ jsx(WindowContext.Provider, {
1467
+ value: windowStoreRef.current,
1468
+ children
1369
1469
  });
1370
1470
  }
1371
- MFLoader.defaultProps = {
1372
- document,
1373
- window
1471
+ const useWindow = () => {
1472
+ const context = useContext(WindowContext);
1473
+ if (!context)
1474
+ throw new Error("useWindow context must be use inside WindowContext");
1475
+ return context;
1374
1476
  };
1375
- const MicroFrontend = (props) => {
1376
- const dynamicMFStore = useWindowStore((state) => state.dynamicMFStore, shallow);
1377
- const moduleId = useWindowStore((state) => state.moduleId, shallow);
1477
+ function useWindowStore(selector, equalityFn) {
1478
+ const store = useContext(WindowContext);
1479
+ if (!store)
1480
+ throw new Error("useWindow context must be use inside WindowContext");
1481
+ return useStore(store, selector, equalityFn);
1482
+ }
1483
+ const Component = (props) => {
1484
+ const {
1485
+ component
1486
+ } = props;
1487
+ const store = useWindow();
1488
+ const dynamicMFStore = useWindowStore((state) => state.dynamicMFStore);
1378
1489
  const actions = useWindowStore((state) => state.actions, shallow);
1379
- return /* @__PURE__ */ jsx(MFLoader, {
1380
- ...props,
1381
- moduleId,
1382
- dynamicMFStore,
1383
- windowTools: {
1384
- ...actions
1385
- }
1490
+ return /* @__PURE__ */ jsx(WindowToolsMFProvider, {
1491
+ ...actions,
1492
+ children: /* @__PURE__ */ jsx(DynamicMFParmsProvider, {
1493
+ store: dynamicMFStore,
1494
+ children: typeof component === "function" ? component(store) : component
1495
+ })
1386
1496
  });
1387
1497
  };
1388
- React__default.memo(MicroFrontend);
1389
- const InnerForHooks$1 = (props) => {
1390
- const {
1391
- winType
1392
- } = props;
1393
- const status = useWindowStore((state) => state.status);
1394
- if (status !== "loaded") {
1395
- return null;
1498
+ React__default.memo(Component);
1499
+ styled("div")(({
1500
+ theme
1501
+ }) => ({
1502
+ display: "flex",
1503
+ alignItems: "center",
1504
+ position: "relative",
1505
+ justifyContent: "space-between",
1506
+ minHeight: theme.spacing(5),
1507
+ borderBottom: `1px solid ${theme.palette.divider}`,
1508
+ overflow: "hidden",
1509
+ cursor: "move",
1510
+ height: "60px",
1511
+ " > span": {
1512
+ marginRight: "12px"
1513
+ },
1514
+ "& > h5": {
1515
+ paddingRight: theme.spacing(3),
1516
+ borderRight: `1px solid ${theme.palette.divider}`
1517
+ },
1518
+ " > nav": {
1519
+ marginRight: "12px",
1520
+ flexGrow: 1
1521
+ },
1522
+ "& .splitactions.Mui-disabled": {
1523
+ color: theme.palette.primary.main
1524
+ },
1525
+ "& svg ": {
1526
+ width: "20px",
1527
+ height: "20px"
1528
+ }
1529
+ }));
1530
+ styled("div")(({
1531
+ theme
1532
+ }) => ({
1533
+ display: "flex",
1534
+ alignItems: "center",
1535
+ position: "relative",
1536
+ borderBottom: `1px solid ${theme.palette.divider}`,
1537
+ height: "60px",
1538
+ minHeight: "60px",
1539
+ " > span": {
1540
+ marginRight: "12px"
1541
+ },
1542
+ "& > h5": {
1543
+ paddingRight: theme.spacing(3),
1544
+ borderRight: `1px solid ${theme.palette.divider}`
1545
+ },
1546
+ " > nav": {
1547
+ marginRight: "12px",
1548
+ flexGrow: 1
1549
+ },
1550
+ "& .splitactions.Mui-disabled": {
1551
+ color: theme.palette.primary.main
1552
+ },
1553
+ "& svg ": {
1554
+ width: "20px",
1555
+ height: "20px"
1556
+ }
1557
+ }));
1558
+ const Wrapper = styled("div")(({
1559
+ theme
1560
+ }) => ({
1561
+ display: "flex",
1562
+ justifyContent: "space-between",
1563
+ padding: `0 0`,
1564
+ borderBottom: `1px solid ${theme.palette.divider}`,
1565
+ minHeight: "60px"
1566
+ }));
1567
+ const ModuleTitleContent = styled("div")(({
1568
+ theme
1569
+ }) => ({
1570
+ display: "grid",
1571
+ gridTemplateColumns: "auto",
1572
+ gridGap: theme.spacing(1.75),
1573
+ alignItems: "center",
1574
+ width: "auto",
1575
+ height: "auto",
1576
+ [theme.breakpoints.up("sm")]: {
1577
+ gridTemplateColumns: "repeat(3, auto)"
1396
1578
  }
1397
- return /* @__PURE__ */ jsxs(Fragment, {
1398
- children: [/* @__PURE__ */ jsx(Header, {}), /* @__PURE__ */ jsx("div", {
1399
- className: areasViewerClasses.windowContent,
1400
- children: winType === "microfrontend" ? /* @__PURE__ */ jsx(MicroFrontend, {
1401
- ...props.mfProps
1402
- }) : /* @__PURE__ */ jsx(Component, {
1403
- component: props.component
1579
+ }));
1580
+ const ModuleTitle = styled("div")(({
1581
+ theme
1582
+ }) => ({
1583
+ display: "grid",
1584
+ gridTemplateColumns: `${theme.spacing(3)} auto`,
1585
+ gridGap: theme.spacing(2),
1586
+ alignItems: "center",
1587
+ width: "auto",
1588
+ height: "auto"
1589
+ }));
1590
+ const Separator = styled("div")(({
1591
+ theme
1592
+ }) => ({
1593
+ display: "none",
1594
+ alignItems: "center",
1595
+ width: "1px",
1596
+ background: theme.palette.divider,
1597
+ height: "100%",
1598
+ margin: `0 ${theme.spacing(2)}`,
1599
+ [theme.breakpoints.up("sm")]: {
1600
+ display: "flex"
1601
+ }
1602
+ }));
1603
+ const Breadcrumbs = styled("div")(({
1604
+ theme
1605
+ }) => ({
1606
+ display: "grid",
1607
+ alignItems: "center",
1608
+ gridTemplateColumns: `repeat(3, auto)`,
1609
+ gridGap: theme.spacing(2)
1610
+ }));
1611
+ const ModuleActions = styled("div")(({
1612
+ theme
1613
+ }) => ({
1614
+ display: "grid",
1615
+ gridTemplateColumns: "auto",
1616
+ alignItems: "center",
1617
+ width: "auto",
1618
+ height: "auto",
1619
+ [theme.breakpoints.up("sm")]: {
1620
+ gridTemplateColumns: `repeat(3, ${theme.spacing(3)})`,
1621
+ gridGap: theme.spacing(2)
1622
+ }
1623
+ }));
1624
+ function SKTModuleHeader() {
1625
+ const isDesktop = useResponsiveDesktop();
1626
+ return /* @__PURE__ */ jsxs(Wrapper, {
1627
+ id: "HeaderSkeleton",
1628
+ children: [/* @__PURE__ */ jsxs(ModuleTitleContent, {
1629
+ children: [/* @__PURE__ */ jsxs(ModuleTitle, {
1630
+ children: [/* @__PURE__ */ jsx(Skeleton, {
1631
+ variant: "circular",
1632
+ width: 24,
1633
+ height: 24
1634
+ }), /* @__PURE__ */ jsx(Skeleton, {
1635
+ variant: "text",
1636
+ width: 120,
1637
+ height: 14
1638
+ })]
1639
+ }), /* @__PURE__ */ jsx(Separator, {}), /* @__PURE__ */ jsxs(Breadcrumbs, {
1640
+ children: [/* @__PURE__ */ jsx(Skeleton, {
1641
+ variant: "text",
1642
+ width: 68,
1643
+ height: 14
1644
+ }), /* @__PURE__ */ jsx(Skeleton, {
1645
+ variant: "circular",
1646
+ width: 4,
1647
+ height: 4
1648
+ }), /* @__PURE__ */ jsx(Skeleton, {
1649
+ variant: "text",
1650
+ width: 68,
1651
+ height: 14
1652
+ })]
1653
+ })]
1654
+ }), /* @__PURE__ */ jsx(ModuleActions, {
1655
+ children: isDesktop ? /* @__PURE__ */ jsxs(Fragment, {
1656
+ children: [/* @__PURE__ */ jsx(Skeleton, {
1657
+ variant: "circular",
1658
+ width: 24,
1659
+ height: 24
1660
+ }), /* @__PURE__ */ jsx(Skeleton, {
1661
+ variant: "circular",
1662
+ width: 24,
1663
+ height: 24
1664
+ }), /* @__PURE__ */ jsx(Skeleton, {
1665
+ variant: "circular",
1666
+ width: 24,
1667
+ height: 24
1668
+ })]
1669
+ }) : /* @__PURE__ */ jsx(Skeleton, {
1670
+ variant: "circular",
1671
+ width: 24,
1672
+ height: 24
1404
1673
  })
1405
1674
  })]
1406
1675
  });
1407
- };
1408
- React__default.memo(InnerForHooks$1);
1409
- const Window = (props) => {
1410
- const {
1411
- emergeType
1412
- } = props;
1413
- const selected = useAreaStore((state) => emergeType === "layout" ? state.currentLayoutId : state.currentPopUpId) === props.windowId;
1414
- const {
1415
- selectWindowPopUp,
1416
- selectWindowLayout
1417
- } = useAreaStore((state) => state.actions);
1418
- const onTouch = () => {
1419
- if (!selected) {
1420
- if (emergeType === "popup") {
1421
- selectWindowPopUp(props.windowId);
1422
- } else if (emergeType === "layout") {
1423
- selectWindowLayout(props.windowId);
1424
- }
1425
- }
1676
+ }
1677
+ function getMainActions(isDesktop, moduleActions) {
1678
+ let mainActions = [];
1679
+ if (isDesktop !== void 0 && isDesktop) {
1680
+ mainActions = mainActions.concat(
1681
+ moduleActions.filter((action) => action.visibility === "main")
1682
+ );
1683
+ }
1684
+ mainActions = mainActions.concat(
1685
+ moduleActions.filter((action) => action.visibility === "allways")
1686
+ );
1687
+ return mainActions;
1688
+ }
1689
+ function getMenuActions(isDesktop, moduleActions, urlPrefix, saveModuleCookies, version) {
1690
+ let menuActions = [...moduleActions.filter((action) => action.visibility !== "allways")];
1691
+ if (isDesktop !== void 0 && isDesktop) {
1692
+ menuActions = menuActions.filter((action) => action.visibility === "normal");
1693
+ }
1694
+ console.log("getMenuActions", version);
1695
+ const savePropsAction = {
1696
+ urlIcon: `${urlPrefix}/frontend/components/areas/assets/icons/split_vertical.svg`,
1697
+ onClick: () => saveModuleCookies,
1698
+ disabled: false,
1699
+ visibility: "normal",
1700
+ dictionaryId: getAreasDictionary("label_persist_module_cookies"),
1701
+ key: "save_props"
1426
1702
  };
1703
+ menuActions.push(savePropsAction);
1704
+ if (version) {
1705
+ const versionAction = {
1706
+ urlIcon: `${urlPrefix}/frontend/components/areas/assets/icons/version.svg`,
1707
+ onClick: () => {
1708
+ },
1709
+ disabled: true,
1710
+ visibility: "normal",
1711
+ label: version,
1712
+ key: "version"
1713
+ };
1714
+ menuActions.push(versionAction);
1715
+ }
1716
+ return menuActions;
1717
+ }
1718
+ function MainActions() {
1719
+ const [moduleActions] = useWindowStore((state) => [state.moduleActions], shallow);
1720
+ const {
1721
+ getLabel
1722
+ } = useModuleDictionary();
1723
+ const isDesktop = useResponsiveDesktop();
1724
+ const mainActions = useMemo(() => {
1725
+ return getMainActions(isDesktop, moduleActions);
1726
+ }, [moduleActions, isDesktop]);
1427
1727
  return /* @__PURE__ */ jsx("div", {
1428
- role: "presentation",
1429
- className: clsx(areasViewerClasses.windowRoot, selected ? areasViewerClasses.selected : null),
1430
- onMouseDown: onTouch,
1431
- children: /* @__PURE__ */ jsx(WindowMFProvider, {
1432
- ...props,
1433
- children: /* @__PURE__ */ jsx(InnerForHooks$1, {
1434
- ...props
1435
- })
1728
+ className: areasViewerClasses.windowHeaderMainActions,
1729
+ children: mainActions.map((mainAction) => {
1730
+ const tooltip = mainAction.label !== void 0 ? mainAction.label : getLabel(mainAction.dictionaryId || "");
1731
+ return /* @__PURE__ */ jsx(IconButton, {
1732
+ src: mainAction.urlIcon,
1733
+ className: mainAction.className,
1734
+ onClick: mainAction.onClick,
1735
+ "aria-label": mainAction.label,
1736
+ disabled: mainAction.disabled,
1737
+ tooltip
1738
+ }, mainAction.key);
1436
1739
  })
1437
1740
  });
1438
- };
1439
- const MemonizedWindow = React__default.memo(Window);
1440
- const WindowPopUp = (props) => {
1741
+ }
1742
+ function Header() {
1743
+ const [url_icon, title, moduleActions, onClose, container_id, version] = useWindowStore((state) => [state.url_icon, state.title, state.moduleActions, state.onClose, state.windowId, state.version], shallow);
1441
1744
  const {
1442
- windowProps,
1443
- windowId
1444
- } = props;
1745
+ saveModuleCookies
1746
+ } = useWindowStore((state) => state.internalActions);
1747
+ const emergeType = useWindowStore((state) => state.emergeType);
1748
+ const maximizedId = useAreaStore((state) => state.singleId);
1445
1749
  const {
1446
- selectWindowPopUp
1447
- } = useAreaStore((store) => store.actions);
1448
- const selectedPopUpId = useAreaStore((store) => store.currentPopUpId);
1449
- const zIndex = useAreaStore((store) => store.hashWindowsPopups[props.windowId].zIndex);
1450
- const isSelected = props.windowId === selectedPopUpId;
1451
- const onTouch = () => {
1452
- if (!isSelected) {
1453
- selectWindowPopUp(props.windowId);
1750
+ maximizeLayout,
1751
+ normalizeLayouts
1752
+ } = useAreaStore((state) => state.actions, shallow);
1753
+ const {
1754
+ host_static_assets,
1755
+ environment_assets
1756
+ } = useEnvironment();
1757
+ const isDesktop = useResponsiveDesktop();
1758
+ const isSkeleton = useModuleSkeleton();
1759
+ const urlPrefix = `${host_static_assets}/${environment_assets}`;
1760
+ const menuActions = useMemo(() => {
1761
+ return getMenuActions(isDesktop, moduleActions, urlPrefix, saveModuleCookies, version);
1762
+ }, [moduleActions, isDesktop]);
1763
+ const onCloseLocal = () => {
1764
+ onClose && onClose(container_id);
1765
+ };
1766
+ const maxNormalize = () => {
1767
+ if (maximizedId) {
1768
+ normalizeLayouts();
1769
+ } else {
1770
+ maximizeLayout(container_id);
1454
1771
  }
1455
1772
  };
1456
- return /* @__PURE__ */ jsx(DraggableWindow, {
1457
- handle: ".m4l_draggable_handle",
1458
- cancel: "",
1459
- defaultPosition: windowProps,
1460
- children: /* @__PURE__ */ jsx(ResizeableWindow, {
1461
- className: clsx(areasViewerClasses.windowPopupRoot, `${areasViewerClasses.windowPopupRoot}-${windowId}`),
1462
- width: windowProps.width,
1463
- height: windowProps.height,
1464
- style: {
1465
- zIndex,
1466
- position: "absolute"
1773
+ if (isSkeleton) {
1774
+ return /* @__PURE__ */ jsx(SKTModuleHeader, {});
1775
+ }
1776
+ return /* @__PURE__ */ jsxs("div", {
1777
+ className: clsx(areasViewerClasses.windowHeader, "m4l_draggable_handle"),
1778
+ children: [/* @__PURE__ */ jsx(Icon, {
1779
+ src: url_icon,
1780
+ size: "medium"
1781
+ }), /* @__PURE__ */ jsx(Typography, {
1782
+ className: areasViewerClasses.windowHeaderTitle,
1783
+ variant: "h5",
1784
+ children: `${title}`
1785
+ }), /* @__PURE__ */ jsx(MainActions, {}), isDesktop && emergeType === "layout" && /* @__PURE__ */ jsx(IconButton, {
1786
+ onClick: maxNormalize,
1787
+ "aria-label": "click",
1788
+ src: maximizedId ? `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.NORMALIZE}` : `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.MAXIMIZE}`
1789
+ }), menuActions.length > 0 && /* @__PURE__ */ jsx(MenuActions, {
1790
+ arrowType: "no-arrow",
1791
+ marginTop: "12px!important",
1792
+ marginLeft: "14px!important",
1793
+ anchorOrigin: {
1794
+ vertical: "bottom",
1795
+ horizontal: "right"
1467
1796
  },
1468
- onResizeStart: () => {
1469
- onTouch();
1797
+ transformOrigin: {
1798
+ vertical: "top",
1799
+ horizontal: "right"
1470
1800
  },
1471
- children: /* @__PURE__ */ jsx(Window, {
1472
- ...props
1473
- })
1474
- })
1801
+ menuActions
1802
+ }), onClose && /* @__PURE__ */ jsx(IconButton, {
1803
+ onClick: onCloseLocal,
1804
+ "aria-label": "click",
1805
+ src: `${host_static_assets}/${environment_assets}/frontend/components/areas/assets/icons/${ICONS.CLOSE}`
1806
+ })]
1475
1807
  });
1476
- };
1477
- const MemonizedWindowPopUp = React__default.memo(WindowPopUp);
1478
- styled("div")(({ theme }) => ({
1808
+ }
1809
+ const WrapperLinearProgress = styled$1("div")(() => ({
1810
+ width: "70%",
1811
+ margin: "auto auto"
1812
+ }));
1813
+ const WrapperFallBackNotFound = styled$1("div")(({
1814
+ theme
1815
+ }) => ({
1816
+ width: "100%",
1817
+ height: "100%",
1479
1818
  display: "flex",
1480
1819
  flexDirection: "column",
1481
- height: "100%",
1482
- overflow: "hidden",
1483
- padding: theme.spacing(3)
1484
- }));
1485
- const WrapperWindowModal = styled(Dialog)(() => ({
1486
- "& .MuiDialog-container": {},
1487
- "&.m4l_selected": {
1488
- borderTop: "1px solid green"
1489
- }
1820
+ justifyContent: "center",
1821
+ alignItems: "center",
1822
+ gap: theme.spacing(3)
1490
1823
  }));
1491
- const WindowModal = (props) => {
1824
+ function FallBackNotFound(props) {
1492
1825
  const {
1493
- closeWindowModal
1494
- } = useAreaStore((state) => state.actions);
1495
- const isDesktop = useResponsiveDesktop();
1496
- const onClose = () => {
1497
- closeWindowModal();
1498
- };
1499
- const DragabblePaperComponent = (_props) => {
1500
- return /* @__PURE__ */ jsx(cjs.exports, {
1501
- handle: ".m4l_draggable_handle",
1502
- bounds: "parent",
1503
- children: /* @__PURE__ */ jsx(ResizeableWindow, {
1504
- className: areasViewerClasses.windowModalRoot,
1505
- width: props.width,
1506
- height: props.height,
1507
- children: /* @__PURE__ */ jsx(Window, {
1508
- ...props,
1509
- onClose
1510
- })
1511
- })
1512
- });
1513
- };
1514
- function PaperComponent(_props) {
1515
- return /* @__PURE__ */ jsx(Window, {
1516
- ...props,
1517
- onClose
1518
- });
1519
- }
1520
- return /* @__PURE__ */ jsx(WrapperWindowModal, {
1521
- open: true,
1522
- disablePortal: true,
1523
- scroll: "paper",
1524
- onKeyDown: (event) => {
1525
- if (event.key === "Escape") {
1526
- onClose();
1527
- }
1528
- },
1529
- "aria-labelledby": "child-modal-title",
1530
- "aria-describedby": "child-modal-description",
1531
- PaperComponent: isDesktop ? DragabblePaperComponent : PaperComponent,
1532
- maxWidth: false,
1533
- fullWidth: !isDesktop,
1534
- fullScreen: false,
1535
- disableEnforceFocus: true
1536
- });
1537
- };
1538
- const MemonizedWindowModal = React__default.memo(WindowModal);
1539
- const ResponsiveGridLayout = WidthProvider(Responsive);
1540
- const GridLayout = () => {
1541
- const gridLayouts = useAreaStore((state) => state.gridLayouts, shallow);
1542
- const hashWindowsPopups = useAreaStore((state) => state.hashWindowsPopups, shallow);
1543
- const hashWindowsLayouts = useAreaStore((state) => state.hashWindowsLayouts, shallow);
1544
- const breakPointsLayouts = useAreaStore((state) => state.breakpointsLayouts, shallow);
1545
- const windowsPopUps = useAreaStore((state) => state.windowsPopUps, shallow);
1546
- const windowModal = useAreaStore((state) => state.windowModal, shallow);
1547
- const breakpoints = useAreaStore((state) => state.breakpoints, shallow);
1548
- const viewMode = useAreaStore((state) => state.viewMode, shallow);
1549
- const cols = useAreaStore((state) => state.cols, shallow);
1826
+ setNetworkRefresh
1827
+ } = props;
1550
1828
  const {
1551
- onBreakpointsLayoutsChange
1552
- } = useAreaStore((state) => state.actions);
1553
- function onBreakpointChange(_newBreakpoint, _newCols) {
1554
- }
1555
- useEffect(() => {
1556
- console.log("ResponsiveGridLayout resize");
1557
- window.dispatchEvent(new Event("resize"));
1558
- }, [viewMode, gridLayouts]);
1559
- return /* @__PURE__ */ jsxs(Fragment, {
1560
- children: [/* @__PURE__ */ jsxs(ResponsiveGridLayout, {
1561
- autoSize: false,
1562
- compactType: "vertical",
1563
- measureBeforeMount: true,
1564
- resizeHandles: ["nw", "se"],
1565
- className: areasViewerClasses.areaGridLayout,
1566
- layouts: breakPointsLayouts,
1567
- onLayoutChange: onBreakpointsLayoutsChange,
1568
- onBreakpointChange,
1569
- breakpoints,
1570
- cols,
1571
- rowHeight: ROW_HEIGTH_GRIDLAYOUT,
1572
- margin: [5, 5],
1573
- containerPadding: [CONTAINER_PADDING_GRIDLAYOUT, CONTAINER_PADDING_GRIDLAYOUT],
1574
- draggableHandle: ".m4l_draggable_handle",
1575
- isBounded: false,
1576
- preventCollision: false,
1577
- children: [/* @__PURE__ */ jsx("div", {
1578
- className: areasViewerClasses.areaGridLayoutPopupsContainer,
1579
- "data-grid": {
1580
- i: "none",
1581
- x: 0,
1582
- y: 0,
1583
- w: 0,
1584
- h: 0,
1585
- maxW: 0,
1586
- maxH: 0,
1587
- minW: 0,
1588
- minH: 0,
1589
- static: true,
1590
- isDraggable: false,
1591
- isResizable: false
1592
- },
1593
- children: windowsPopUps.map((wp) => {
1594
- if (hashWindowsPopups[wp]) {
1595
- return /* @__PURE__ */ jsx(MemonizedWindowPopUp, {
1596
- ...hashWindowsPopups[wp]
1597
- }, hashWindowsPopups[wp].windowId);
1598
- }
1599
- return null;
1600
- })
1601
- }, "none"), gridLayouts.map((l) => {
1602
- if (hashWindowsLayouts[l.i]) {
1603
- return /* @__PURE__ */ jsx("div", {
1604
- children: /* @__PURE__ */ jsx(MemonizedWindow, {
1605
- ...hashWindowsLayouts[l.i]
1606
- })
1607
- }, l.i);
1608
- }
1609
- return null;
1610
- })]
1611
- }), windowModal && /* @__PURE__ */ jsx(MemonizedWindowModal, {
1612
- ...windowModal
1613
- })]
1614
- });
1615
- };
1616
- const InnerForHooks = () => {
1617
- const status = useAreaStore((state) => state.status);
1618
- if (status === "loaded") {
1619
- return /* @__PURE__ */ jsx(GridLayout, {});
1620
- } else {
1621
- return /* @__PURE__ */ jsx("div", {
1622
- children: "Loading.. Intentar si falla."
1623
- });
1624
- }
1625
- };
1626
- const PanelWindows = () => {
1627
- const status = useAreaStore((state) => state.status);
1628
- const mode = useAreaStore((state) => state.viewMode);
1629
- const singleId = useAreaStore((state) => state.singleId);
1630
- const gridLayouts = useAreaStore((state) => state.gridLayouts, shallow);
1631
- const hashWindowsLayouts = useAreaStore((state) => state.hashWindowsLayouts, shallow);
1829
+ getLabel
1830
+ } = useModuleDictionary();
1632
1831
  const {
1633
- maximizeLayout
1634
- } = useAreaStore((state) => state.actions);
1635
- const onTouched = (layoutId) => {
1636
- maximizeLayout(layoutId);
1832
+ host_static_assets,
1833
+ environment_assets
1834
+ } = useEnvironment();
1835
+ const handlerClick = () => {
1836
+ setNetworkRefresh((prop) => !prop);
1637
1837
  };
1638
- if (status === "loaded") {
1639
- if (mode !== "single" || gridLayouts.length < 2) {
1640
- return null;
1641
- }
1642
- return /* @__PURE__ */ jsx("div", {
1643
- className: areasViewerClasses.panelWindowsRoot,
1644
- children: gridLayouts.map((l) => {
1645
- return /* @__PURE__ */ jsx("div", {
1646
- className: clsx(areasViewerClasses.panelWindowsButtonContainer, singleId === l.i ? areasViewerClasses.selected : null),
1647
- children: /* @__PURE__ */ jsx(IconButton, {
1648
- src: hashWindowsLayouts[l.i].url_icon,
1649
- size: "small",
1650
- onClick: () => onTouched(l.i)
1651
- })
1652
- }, l.i);
1838
+ return /* @__PURE__ */ jsxs(WrapperFallBackNotFound, {
1839
+ children: [/* @__PURE__ */ jsx(m.div, {
1840
+ variants: varBounce().in,
1841
+ children: /* @__PURE__ */ jsx(Typography$1, {
1842
+ variant: "h3",
1843
+ paragraph: true,
1844
+ children: getLabel("loading_mf_title")
1653
1845
  })
1654
- });
1655
- } else {
1656
- return null;
1657
- }
1658
- };
1659
- const Area = (props) => {
1846
+ }), /* @__PURE__ */ jsx(Typography$1, {
1847
+ sx: {
1848
+ color: "text.secondary"
1849
+ },
1850
+ children: getLabel("loading_mf_description")
1851
+ }), /* @__PURE__ */ jsx(m.div, {
1852
+ variants: varBounce().in,
1853
+ children: /* @__PURE__ */ jsx(Image, {
1854
+ src: `${host_static_assets}/${environment_assets}/frontend/domain/host/commons/assets/img/illustration_noauth.png`,
1855
+ ratio: "1:1"
1856
+ })
1857
+ }), /* @__PURE__ */ jsx(Button, {
1858
+ size: "medium",
1859
+ variant: "contained",
1860
+ onClick: handlerClick,
1861
+ children: getLabel("loading_mf_intro")
1862
+ })]
1863
+ });
1864
+ }
1865
+ const LoadingMF = (props) => {
1660
1866
  const {
1661
- selected
1867
+ loadingProgress,
1868
+ setNetworkRefresh
1662
1869
  } = props;
1663
- const classesAreaRoot = useAreasStore((state) => state.viwerClasses.areaRoot);
1664
- return /* @__PURE__ */ jsx("div", {
1665
- className: clsx(classesAreaRoot, selected ? areasViewerClasses.selected : null),
1666
- children: /* @__PURE__ */ jsx(AreaProvider, {
1667
- ...props,
1668
- children: /* @__PURE__ */ jsxs("div", {
1669
- className: clsx(areasViewerClasses.areaGridLayoutPanelContainer, `${areasViewerClasses.areaGridLayoutPanelContainer}-${props.id}`),
1670
- children: [/* @__PURE__ */ jsx(InnerForHooks, {}), /* @__PURE__ */ jsx(PanelWindows, {})]
1870
+ if (loadingProgress !== -1) {
1871
+ return /* @__PURE__ */ jsx(WrapperLinearProgress, {
1872
+ id: "WrapperLinearProgress",
1873
+ children: /* @__PURE__ */ jsx(LinearProgress, {
1874
+ variant: "determinate",
1875
+ value: loadingProgress
1671
1876
  })
1672
- })
1877
+ });
1878
+ }
1879
+ return /* @__PURE__ */ jsx(FallBackNotFound, {
1880
+ setNetworkRefresh
1673
1881
  });
1674
1882
  };
1675
- Area.displayName = "Area";
1676
- const AreasViewerRoot = styled("div")`
1677
-
1678
- /* display: flex; */
1679
- width: 100%;
1680
- height: 100%;
1681
- overflow: hidden;
1682
- /* flex-grow: 1; */
1683
- position: relative;
1684
-
1685
-
1686
-
1687
- //areaRoot
1688
- & .${areasViewerClasses.areaRoot} {
1689
- display: none;
1690
- position: absolute;
1691
- /* flex-grow: 1; */
1692
- flex-direction: row;
1693
- inset: 0;
1694
- /* width: 100%; */
1695
- overflow: hidden;
1696
- justify-content: top;
1697
- align-items: flex-start;
1698
-
1699
- visibility: hidden;
1700
- }
1701
-
1702
- & .${areasViewerClasses.areaRoot}.${areasViewerClasses.selected} {
1703
- display: block;
1704
- visibility: visible;
1705
- }
1706
-
1707
- &.${areasViewerClasses.isMobile} .${areasViewerClasses.areaRoot} {
1708
-
1709
- }
1710
-
1711
- // areaGridLayoutPanelContainer
1712
- & .${areasViewerClasses.areaGridLayoutPanelContainer} {
1713
- display: flex;
1714
- flex-direction: row;
1715
- height: 100%;
1716
- width: 100%;
1717
- overflow: hidden;
1718
- }
1719
- &.${areasViewerClasses.isMobile} .${areasViewerClasses.areaGridLayoutPanelContainer} {
1720
- flex-direction: column-reverse;
1721
- }
1722
- // areaGridLayout
1723
- & .${areasViewerClasses.areaGridLayout} {
1724
- height: 100%!important;
1725
- overflow: auto;
1726
- flex-grow: 1;
1727
- }
1728
- &.${areasViewerClasses.isMobile} .${areasViewerClasses.areaGridLayout} {
1729
- flex-direction: column-reverse;
1730
- height: unset;
1731
- width: 100%;
1732
- }
1733
- // areaGridLayoutPopupsContainer
1734
- & .${areasViewerClasses.areaGridLayoutPopupsContainer} {
1735
- z-index: 1; //Garantizar q el contenedor de los popus este por encima de los layouts
1736
- // // ' .react-draggable': {
1737
- // // position: 'absolute',
1738
- // // },
1739
- }
1740
-
1741
- // PanelWindowsRoot
1742
- & .${areasViewerClasses.panelWindowsRoot} {
1743
- display: flex;
1744
- flex-direction: column;
1745
- position: relative;
1746
- }
1747
- &.${areasViewerClasses.isMobile} .${areasViewerClasses.panelWindowsRoot} {
1748
- flex-direction: row;
1749
- }
1750
- & .${areasViewerClasses.panelWindowsButtonContainer}.${areasViewerClasses.selected} {
1751
- border: 1px solid red;
1752
- }
1753
-
1754
- // windowRoot
1755
- & .${areasViewerClasses.windowRoot} {
1756
- inset:0;
1757
- position: absolute;
1758
- display: flex;
1759
- flex-direction: column;
1760
- /* height: 100%; */
1761
- /* width: 100%; */
1762
- overflow: hidden;
1763
- border: 1px solid gray;
1764
-
1765
- background-color: ${(props) => props.theme.palette.background.default};
1766
- padding: ${(props) => props.theme.spacing(0)};
1767
- }
1768
-
1769
- & .${areasViewerClasses.windowRoot}.${areasViewerClasses.selected} {
1770
- border-top: 1px solid green;
1771
- }
1772
- // windowHeader
1773
- & .${areasViewerClasses.windowHeader} {
1774
- display: flex;
1775
- gap: 4px;
1776
-
1777
- align-items: center;
1778
- position: relative;
1779
-
1780
- padding: 8px;
1781
- justify-content: end;
1782
- min-height: ${(props) => props.theme.spacing(5)} ;
1783
-
1784
- border-bottom: 1px solid ${(props) => props.theme.palette.divider},
1785
- overflow: hidden;
1786
- cursor: move;
1787
- height: 60px;
1788
-
1789
-
1790
-
1791
- > span: {
1792
- margin-right: 12px;
1793
- }
1794
- }
1795
- // windowHeaderTitle
1796
- & .${areasViewerClasses.windowHeaderTitle} {
1797
- width: 100%;
1798
- max-width: 100%;
1799
- overflow: hidden;
1800
- white-space: nowrap;
1801
- color: ${(props) => props.theme.palette.text.primary};
1802
- margin-left: 12px;
1803
- margin-right: 24px;
1804
- text-overflow: ellipsis;
1805
- }
1806
- // windowHeaderMainActions
1807
- & .${areasViewerClasses.windowHeaderMainActions} {
1808
- display: flex;
1809
-
1810
- gap: 4px;
1811
- }
1812
-
1813
-
1814
- // windowHeaderMainActions
1815
- & .${areasViewerClasses.windowContent} {
1816
- flex-grow: 1;
1817
- position: relative;
1818
- }
1819
-
1820
- // windowModalRoot
1821
- & .${areasViewerClasses.windowModalRoot} .${areasViewerClasses.windowRoot}{
1822
- padding: 16px;
1823
- }
1824
-
1825
- .react-grid-layout {
1826
- position: relative;
1827
- transition: height 200ms ease;
1828
- }
1829
- .react-grid-item {
1830
- transition: all 200ms ease;
1831
- transition-property: left, top;
1832
- }
1833
- .react-grid-item img {
1834
- pointer-events: none;
1835
- user-select: none;
1836
- }
1837
- .react-grid-item.cssTransforms {
1838
- transition-property: transform;
1839
- }
1840
- .react-grid-item.resizing {
1841
- z-index: 1;
1842
- will-change: width, height;
1843
- }
1844
-
1845
- .react-grid-item.react-draggable-dragging {
1846
- transition: none;
1847
- z-index: 3;
1848
- will-change: transform;
1849
- }
1850
-
1851
- .react-grid-item.dropping {
1852
- visibility: hidden;
1853
- }
1854
-
1855
- .react-grid-item.react-grid-placeholder {
1856
- background: green;
1857
- opacity: 0.2;
1858
- transition-duration: 100ms;
1859
- z-index: 2;
1860
- -webkit-user-select: none;
1861
- -moz-user-select: none;
1862
- -ms-user-select: none;
1863
- -o-user-select: none;
1864
- user-select: none;
1865
- }
1866
-
1867
- .react-grid-item > .react-resizable-handle {
1868
- position: absolute;
1869
- width: 20px;
1870
- height: 20px;
1871
- }
1872
-
1873
- .react-grid-item > .react-resizable-handle::after {
1874
- content: "";
1875
- position: absolute;
1876
- right: 3px;
1877
- bottom: 3px;
1878
- width: 5px;
1879
- height: 5px;
1880
- border-right: 2px solid rgba(0, 0, 0, 0.4);
1881
- border-bottom: 2px solid rgba(0, 0, 0, 0.4);
1882
- }
1883
-
1884
- .react-resizable-hide > .react-resizable-handle {
1885
- display: none;
1886
- }
1887
-
1888
- .react-grid-item > .react-resizable-handle.react-resizable-handle-sw {
1889
- bottom: 0;
1890
- left: 0;
1891
- cursor: sw-resize;
1892
- transform: rotate(90deg);
1893
- }
1894
- .react-grid-item > .react-resizable-handle.react-resizable-handle-se {
1895
- bottom: 0;
1896
- right: 0;
1897
- cursor: se-resize;
1883
+ function getDivScritId(prefix, moduleId) {
1884
+ const rotational_id = `${Math.round(new Date().getTime() / 1e3)}_rnd_${Math.round(Math.random() * 1e3)}`;
1885
+ return {
1886
+ divContainerId: `container_${prefix}_${moduleId}_${rotational_id}`,
1887
+ scriptId: `script_${moduleId}_${rotational_id}`,
1888
+ moduleId
1889
+ };
1890
+ }
1891
+ function MFLoader(props) {
1892
+ const {
1893
+ prefix,
1894
+ moduleId,
1895
+ cache = true,
1896
+ debug_port,
1897
+ dynamicMFStore,
1898
+ windowTools
1899
+ } = props;
1900
+ const {
1901
+ hostThemeOptions,
1902
+ fnComponentsOverrides
1903
+ } = useHostTheme();
1904
+ const {
1905
+ networkOperation
1906
+ } = useNetwork();
1907
+ const environment = useEnvironment();
1908
+ const hostTools = useHostTools();
1909
+ const formatter = useFormatter();
1910
+ const [isLoading, setIsLoading] = useState(true);
1911
+ const [networkProgress, setNetworkProgress] = useState(-1);
1912
+ const [_networkRefresh, setNetworkRefresh] = useState(false);
1913
+ const {
1914
+ currentLocale
1915
+ } = useLocales();
1916
+ const [divScript, setDivScript] = useState(getDivScritId(prefix, moduleId));
1917
+ const refTime = useRef(0);
1918
+ const isFirstRender = useFirstRender([moduleId]);
1919
+ const final_host = environment.isLocalhost ? `https://localhost:${debug_port}` : `https://${window.location.host}/mf/${moduleId}`;
1920
+ function cleanUp(dScript) {
1921
+ try {
1922
+ if (window[`unmount_${prefix}_${dScript.moduleId}`]) {
1923
+ window[`unmount_${prefix}_${dScript.moduleId}`](dScript.divContainerId);
1924
+ }
1925
+ } catch (error) {
1898
1926
  }
1899
- .react-grid-item > .react-resizable-handle.react-resizable-handle-nw {
1900
- top: 0;
1901
- left: 0;
1902
- cursor: nw-resize;
1903
- transform: rotate(180deg);
1927
+ if (!cache) {
1928
+ const script = document.getElementById(dScript.scriptId);
1929
+ if (script) {
1930
+ try {
1931
+ document.head.removeChild(script);
1932
+ delete window[`render_${prefix}_${dScript.moduleId}`];
1933
+ delete window[`unmount_${prefix}_${dScript.moduleId}`];
1934
+ } catch (error) {
1935
+ }
1936
+ }
1904
1937
  }
1905
- .react-grid-item > .react-resizable-handle.react-resizable-handle-ne {
1906
- top: 0;
1907
- right: 0;
1908
- cursor: ne-resize;
1909
- transform: rotate(270deg);
1938
+ }
1939
+ const renderMicroFrontend = useCallback((newDScript) => {
1940
+ try {
1941
+ setIsLoading(false);
1942
+ window[`render_${prefix}_${newDScript.moduleId}`](newDScript.divContainerId, environment, hostTools, currentLocale, {
1943
+ hostThemeOptions,
1944
+ fnComponentsOverrides
1945
+ }, axiosOperation, formatter, dynamicMFStore, windowTools);
1946
+ } catch (error) {
1910
1947
  }
1911
- .react-grid-item > .react-resizable-handle.react-resizable-handle-w,
1912
- .react-grid-item > .react-resizable-handle.react-resizable-handle-e {
1913
- top: 50%;
1914
- margin-top: -10px;
1915
- cursor: ew-resize;
1948
+ }, [hostThemeOptions, currentLocale, formatter]);
1949
+ const debouncedSetDivScript = useCallback(debounce((newName) => {
1950
+ const newDivScript = getDivScritId(prefix, newName);
1951
+ if (newName !== divScript.moduleId) {
1952
+ setDivScript({
1953
+ ...newDivScript
1954
+ });
1916
1955
  }
1917
- .react-grid-item > .react-resizable-handle.react-resizable-handle-w {
1918
- left: 0;
1919
- transform: rotate(135deg);
1956
+ }, 200), [divScript]);
1957
+ useEffect(() => {
1958
+ if (!isFirstRender) {
1959
+ debouncedSetDivScript(moduleId + "");
1960
+ if (moduleId !== divScript.moduleId)
1961
+ ;
1920
1962
  }
1921
- .react-grid-item > .react-resizable-handle.react-resizable-handle-e {
1922
- right: 0;
1923
- transform: rotate(315deg);
1963
+ return () => {
1964
+ };
1965
+ }, [moduleId]);
1966
+ useEffect(() => {
1967
+ setIsLoading(true);
1968
+ let mounted = true;
1969
+ const controller = new AbortController();
1970
+ const dsScript = {
1971
+ ...divScript
1972
+ };
1973
+ const loadIfNotLoaded = async () => {
1974
+ if (!window[`render_${prefix}_${moduleId}`]) {
1975
+ let urlFile = "";
1976
+ setNetworkProgress(0);
1977
+ const manifest = await fetch(`${final_host}/manifest.json?rnd=${Math.random()}`).then((res) => res.json()).catch(() => {
1978
+ console.debug("Error fetching manifest", `${final_host}/manifest.json`);
1979
+ return void 0;
1980
+ });
1981
+ if (!manifest) {
1982
+ return;
1983
+ }
1984
+ setNetworkProgress(10);
1985
+ if (mounted) {
1986
+ urlFile = `${final_host}/${manifest["src/index.tsx"]["file"]}?rnd=${Math.random()}`;
1987
+ refTime.current = 0;
1988
+ await networkOperation({
1989
+ method: "GET",
1990
+ endPoint: urlFile,
1991
+ isRemote: !environment.isLocalhost,
1992
+ headers: {
1993
+ "Content-Type": "application/json"
1994
+ },
1995
+ onDownloadProgress: (progressEvent) => {
1996
+ let percentCompleted = 0;
1997
+ try {
1998
+ if (progressEvent.lengthComputable) {
1999
+ percentCompleted = 10 + Math.round(progressEvent.loaded * 90 / progressEvent.total);
2000
+ } else {
2001
+ if (refTime.current === 0) {
2002
+ refTime.current = new Date().getTime();
2003
+ }
2004
+ percentCompleted = 10 + progressEvent.loaded / 15e5 * 90;
2005
+ if (percentCompleted > 95)
2006
+ percentCompleted = 95;
2007
+ }
2008
+ } catch (error) {
2009
+ }
2010
+ if (mounted) {
2011
+ setNetworkProgress(percentCompleted);
2012
+ }
2013
+ },
2014
+ isExternalUrl: true,
2015
+ responseType: "text",
2016
+ signal: controller.signal
2017
+ }).then(() => {
2018
+ if (mounted) {
2019
+ setNetworkProgress(100);
2020
+ }
2021
+ }).catch(() => {
2022
+ });
2023
+ if (mounted) {
2024
+ const script = document.createElement("script");
2025
+ script.id = divScript.scriptId;
2026
+ script.crossOrigin = "";
2027
+ script.type = "module";
2028
+ script.src = urlFile || "";
2029
+ script.onload = () => {
2030
+ if (mounted) {
2031
+ console.debug("Script loaded", new Date().getTime());
2032
+ setNetworkProgress(100);
2033
+ renderMicroFrontend(dsScript);
2034
+ }
2035
+ };
2036
+ document.head.appendChild(script);
2037
+ console.debug("Script appened", new Date().getTime());
2038
+ }
2039
+ }
2040
+ } else {
2041
+ if (mounted) {
2042
+ renderMicroFrontend(dsScript);
2043
+ }
2044
+ }
2045
+ };
2046
+ loadIfNotLoaded();
2047
+ return () => {
2048
+ mounted = false;
2049
+ controller.abort();
2050
+ cleanUp(dsScript);
2051
+ };
2052
+ }, [divScript]);
2053
+ return /* @__PURE__ */ jsxs(Fragment, {
2054
+ children: [/* @__PURE__ */ jsx("div", {
2055
+ id: divScript.divContainerId
2056
+ }), isLoading ? /* @__PURE__ */ jsx(LoadingMF, {
2057
+ loadingProgress: networkProgress,
2058
+ setNetworkRefresh
2059
+ }) : null]
2060
+ });
2061
+ }
2062
+ MFLoader.defaultProps = {
2063
+ document,
2064
+ window
2065
+ };
2066
+ const MicroFrontend = (props) => {
2067
+ const dynamicMFStore = useWindowStore((state) => state.dynamicMFStore, shallow);
2068
+ const moduleId = useWindowStore((state) => state.moduleId, shallow);
2069
+ const actions = useWindowStore((state) => state.actions, shallow);
2070
+ return /* @__PURE__ */ jsx(MFLoader, {
2071
+ ...props,
2072
+ moduleId,
2073
+ dynamicMFStore,
2074
+ windowTools: {
2075
+ ...actions
1924
2076
  }
1925
- .react-grid-item > .react-resizable-handle.react-resizable-handle-n,
1926
- .react-grid-item > .react-resizable-handle.react-resizable-handle-s {
1927
- left: 50%;
1928
- margin-left: -10px;
1929
- cursor: ns-resize;
2077
+ });
2078
+ };
2079
+ React__default.memo(MicroFrontend);
2080
+ const InnerForHooks$1 = (props) => {
2081
+ const {
2082
+ winType
2083
+ } = props;
2084
+ const status = useWindowStore((state) => state.status);
2085
+ if (status !== "loaded") {
2086
+ return null;
2087
+ }
2088
+ return /* @__PURE__ */ jsxs(Fragment, {
2089
+ children: [/* @__PURE__ */ jsx(Header, {}), /* @__PURE__ */ jsx("div", {
2090
+ className: areasViewerClasses.windowContent,
2091
+ children: winType === "microfrontend" ? /* @__PURE__ */ jsx(MicroFrontend, {
2092
+ ...props.mfProps
2093
+ }) : /* @__PURE__ */ jsx(Component, {
2094
+ component: props.component
2095
+ })
2096
+ })]
2097
+ });
2098
+ };
2099
+ React__default.memo(InnerForHooks$1);
2100
+ const Window = (props) => {
2101
+ const {
2102
+ emergeType
2103
+ } = props;
2104
+ const selected = useAreaStore((state) => emergeType === "layout" ? state.currentLayoutId : state.currentPopUpId) === props.windowId;
2105
+ const {
2106
+ selectWindowPopUp,
2107
+ selectWindowLayout
2108
+ } = useAreaStore((state) => state.actions);
2109
+ const onTouch = () => {
2110
+ if (!selected) {
2111
+ if (emergeType === "popup") {
2112
+ selectWindowPopUp(props.windowId);
2113
+ } else if (emergeType === "layout") {
2114
+ selectWindowLayout(props.windowId);
2115
+ }
1930
2116
  }
1931
- .react-grid-item > .react-resizable-handle.react-resizable-handle-n {
1932
- top: 0;
1933
- transform: rotate(225deg);
2117
+ };
2118
+ return /* @__PURE__ */ jsx("div", {
2119
+ role: "presentation",
2120
+ className: clsx(areasViewerClasses.windowRoot, selected ? areasViewerClasses.selected : null),
2121
+ onMouseDown: onTouch,
2122
+ children: /* @__PURE__ */ jsx(WindowMFProvider, {
2123
+ ...props,
2124
+ children: /* @__PURE__ */ jsx(InnerForHooks$1, {
2125
+ ...props
2126
+ })
2127
+ })
2128
+ });
2129
+ };
2130
+ const MemonizedWindow = React__default.memo(Window);
2131
+ const WindowPopUp = (props) => {
2132
+ const {
2133
+ windowProps,
2134
+ windowId
2135
+ } = props;
2136
+ const {
2137
+ selectWindowPopUp
2138
+ } = useAreaStore((store) => store.actions);
2139
+ const selectedPopUpId = useAreaStore((store) => store.currentPopUpId);
2140
+ const zIndex = useAreaStore((store) => store.hashWindowsPopups[props.windowId].zIndex);
2141
+ const isSelected = props.windowId === selectedPopUpId;
2142
+ const onTouch = () => {
2143
+ if (!isSelected) {
2144
+ selectWindowPopUp(props.windowId);
1934
2145
  }
1935
- .react-grid-item > .react-resizable-handle.react-resizable-handle-s {
1936
- bottom: 0;
1937
- transform: rotate(45deg);
2146
+ };
2147
+ return /* @__PURE__ */ jsx(DraggableWindow, {
2148
+ handle: ".m4l_draggable_handle",
2149
+ cancel: "",
2150
+ defaultPosition: windowProps,
2151
+ children: /* @__PURE__ */ jsx(ResizeableWindow, {
2152
+ className: clsx(areasViewerClasses.windowPopupRoot, `${areasViewerClasses.windowPopupRoot}-${windowId}`),
2153
+ width: windowProps.width,
2154
+ height: windowProps.height,
2155
+ style: {
2156
+ zIndex,
2157
+ position: "absolute"
2158
+ },
2159
+ onResizeStart: () => {
2160
+ onTouch();
2161
+ },
2162
+ children: /* @__PURE__ */ jsx(Window, {
2163
+ ...props
2164
+ })
2165
+ })
2166
+ });
2167
+ };
2168
+ const MemonizedWindowPopUp = React__default.memo(WindowPopUp);
2169
+ styled("div")(({ theme }) => ({
2170
+ display: "flex",
2171
+ flexDirection: "column",
2172
+ height: "100%",
2173
+ overflow: "hidden",
2174
+ padding: theme.spacing(3)
2175
+ }));
2176
+ const WrapperWindowModal = styled(Dialog)(() => ({
2177
+ "& .MuiDialog-container": {},
2178
+ "&.m4l_selected": {
2179
+ borderTop: "1px solid green"
2180
+ }
2181
+ }));
2182
+ const WindowModal = (props) => {
2183
+ const {
2184
+ closeWindowModal
2185
+ } = useAreaStore((state) => state.actions);
2186
+ const isDesktop = useResponsiveDesktop();
2187
+ const onClose = () => {
2188
+ closeWindowModal();
2189
+ };
2190
+ const DragabblePaperComponent = (_props) => {
2191
+ return /* @__PURE__ */ jsx(cjs.exports, {
2192
+ handle: ".m4l_draggable_handle",
2193
+ bounds: "parent",
2194
+ children: /* @__PURE__ */ jsx(ResizeableWindow, {
2195
+ className: areasViewerClasses.windowModalRoot,
2196
+ width: props.width,
2197
+ height: props.height,
2198
+ children: /* @__PURE__ */ jsx(Window, {
2199
+ ...props,
2200
+ onClose
2201
+ })
2202
+ })
2203
+ });
2204
+ };
2205
+ function PaperComponent(_props) {
2206
+ return /* @__PURE__ */ jsx(Window, {
2207
+ ...props,
2208
+ onClose
2209
+ });
2210
+ }
2211
+ return /* @__PURE__ */ jsx(WrapperWindowModal, {
2212
+ open: true,
2213
+ disablePortal: true,
2214
+ scroll: "paper",
2215
+ onKeyDown: (event) => {
2216
+ if (event.key === "Escape") {
2217
+ onClose();
2218
+ }
2219
+ },
2220
+ "aria-labelledby": "child-modal-title",
2221
+ "aria-describedby": "child-modal-description",
2222
+ PaperComponent: isDesktop ? DragabblePaperComponent : PaperComponent,
2223
+ maxWidth: false,
2224
+ fullWidth: !isDesktop,
2225
+ fullScreen: false,
2226
+ disableEnforceFocus: true
2227
+ });
2228
+ };
2229
+ const MemonizedWindowModal = React__default.memo(WindowModal);
2230
+ const ResponsiveGridLayout = WidthProvider(Responsive);
2231
+ const GridLayout = () => {
2232
+ const gridLayouts = useAreaStore((state) => state.gridLayouts, shallow);
2233
+ const hashWindowsPopups = useAreaStore((state) => state.hashWindowsPopups, shallow);
2234
+ const hashWindowsLayouts = useAreaStore((state) => state.hashWindowsLayouts, shallow);
2235
+ const breakPointsLayouts = useAreaStore((state) => state.breakpointsLayouts, shallow);
2236
+ const windowsPopUps = useAreaStore((state) => state.windowsPopUps, shallow);
2237
+ const windowModal = useAreaStore((state) => state.windowModal, shallow);
2238
+ const breakpoints = useAreaStore((state) => state.breakpoints, shallow);
2239
+ const viewMode = useAreaStore((state) => state.viewMode, shallow);
2240
+ const cols = useAreaStore((state) => state.cols, shallow);
2241
+ const {
2242
+ onBreakpointsLayoutsChange
2243
+ } = useAreaStore((state) => state.actions);
2244
+ function onBreakpointChange(_newBreakpoint, _newCols) {
2245
+ }
2246
+ useEffect(() => {
2247
+ console.log("ResponsiveGridLayout resize");
2248
+ window.dispatchEvent(new Event("resize"));
2249
+ }, [viewMode, gridLayouts]);
2250
+ return /* @__PURE__ */ jsxs(Fragment, {
2251
+ children: [/* @__PURE__ */ jsxs(ResponsiveGridLayout, {
2252
+ autoSize: false,
2253
+ compactType: "vertical",
2254
+ measureBeforeMount: true,
2255
+ resizeHandles: ["nw", "se"],
2256
+ className: areasViewerClasses.areaGridLayout,
2257
+ layouts: breakPointsLayouts,
2258
+ onLayoutChange: onBreakpointsLayoutsChange,
2259
+ onBreakpointChange,
2260
+ breakpoints,
2261
+ cols,
2262
+ rowHeight: ROW_HEIGTH_GRIDLAYOUT,
2263
+ margin: [5, 5],
2264
+ containerPadding: [CONTAINER_PADDING_GRIDLAYOUT, CONTAINER_PADDING_GRIDLAYOUT],
2265
+ draggableHandle: ".m4l_draggable_handle",
2266
+ isBounded: false,
2267
+ preventCollision: false,
2268
+ children: [/* @__PURE__ */ jsx("div", {
2269
+ className: areasViewerClasses.areaGridLayoutPopupsContainer,
2270
+ "data-grid": {
2271
+ i: "none",
2272
+ x: 0,
2273
+ y: 0,
2274
+ w: 0,
2275
+ h: 0,
2276
+ maxW: 0,
2277
+ maxH: 0,
2278
+ minW: 0,
2279
+ minH: 0,
2280
+ static: true,
2281
+ isDraggable: false,
2282
+ isResizable: false
2283
+ },
2284
+ children: windowsPopUps.map((wp) => {
2285
+ if (hashWindowsPopups[wp]) {
2286
+ return /* @__PURE__ */ jsx(MemonizedWindowPopUp, {
2287
+ ...hashWindowsPopups[wp]
2288
+ }, hashWindowsPopups[wp].windowId);
2289
+ }
2290
+ return null;
2291
+ })
2292
+ }, "none"), gridLayouts.map((l) => {
2293
+ if (hashWindowsLayouts[l.i]) {
2294
+ return /* @__PURE__ */ jsx("div", {
2295
+ children: /* @__PURE__ */ jsx(MemonizedWindow, {
2296
+ ...hashWindowsLayouts[l.i]
2297
+ })
2298
+ }, l.i);
2299
+ }
2300
+ return null;
2301
+ })]
2302
+ }), windowModal && /* @__PURE__ */ jsx(MemonizedWindowModal, {
2303
+ ...windowModal
2304
+ })]
2305
+ });
2306
+ };
2307
+ const InnerForHooks = () => {
2308
+ const status = useAreaStore((state) => state.status);
2309
+ if (status === "loaded") {
2310
+ return /* @__PURE__ */ jsx(GridLayout, {});
2311
+ } else {
2312
+ return /* @__PURE__ */ jsx("div", {
2313
+ children: "Loading.. Intentar si falla."
2314
+ });
2315
+ }
2316
+ };
2317
+ const PanelWindows = () => {
2318
+ const status = useAreaStore((state) => state.status);
2319
+ const mode = useAreaStore((state) => state.viewMode);
2320
+ const singleId = useAreaStore((state) => state.singleId);
2321
+ const gridLayouts = useAreaStore((state) => state.gridLayouts, shallow);
2322
+ const hashWindowsLayouts = useAreaStore((state) => state.hashWindowsLayouts, shallow);
2323
+ const {
2324
+ maximizeLayout
2325
+ } = useAreaStore((state) => state.actions);
2326
+ const onTouched = (layoutId) => {
2327
+ maximizeLayout(layoutId);
2328
+ };
2329
+ if (status === "loaded") {
2330
+ if (mode !== "single" || gridLayouts.length < 2) {
2331
+ return null;
1938
2332
  }
1939
-
1940
-
1941
- ${react_resizable_css}
1942
-
1943
-
1944
- ${(props) => props.theme.components?.M4LAreasViewer}
1945
-
1946
-
1947
- `;
2333
+ return /* @__PURE__ */ jsx("div", {
2334
+ className: areasViewerClasses.panelWindowsRoot,
2335
+ children: gridLayouts.map((l) => {
2336
+ return /* @__PURE__ */ jsx("div", {
2337
+ className: clsx(areasViewerClasses.panelWindowsButtonContainer, singleId === l.i ? areasViewerClasses.selected : null),
2338
+ children: /* @__PURE__ */ jsx(IconButton, {
2339
+ src: hashWindowsLayouts[l.i].url_icon,
2340
+ size: "small",
2341
+ onClick: () => onTouched(l.i)
2342
+ })
2343
+ }, l.i);
2344
+ })
2345
+ });
2346
+ } else {
2347
+ return null;
2348
+ }
2349
+ };
2350
+ const Area = (props) => {
2351
+ const {
2352
+ selected
2353
+ } = props;
2354
+ const classesAreaRoot = useAreasStore((state) => state.viwerClasses.areaRoot);
2355
+ return /* @__PURE__ */ jsx("div", {
2356
+ className: clsx(classesAreaRoot, selected ? areasViewerClasses.selected : null),
2357
+ children: /* @__PURE__ */ jsx(AreaProvider, {
2358
+ ...props,
2359
+ children: /* @__PURE__ */ jsxs("div", {
2360
+ className: clsx(areasViewerClasses.areaGridLayoutPanelContainer, `${areasViewerClasses.areaGridLayoutPanelContainer}-${props.id}`),
2361
+ children: [/* @__PURE__ */ jsx(InnerForHooks, {}), /* @__PURE__ */ jsx(PanelWindows, {})]
2362
+ })
2363
+ })
2364
+ });
2365
+ };
2366
+ Area.displayName = "Area";
1948
2367
  function AreasViewer() {
1949
2368
  const areas = useAreasStore((state) => state.areas);
1950
2369
  const currentArea = useAreasStore((state) => state.currentArea);
@@ -1963,10 +2382,35 @@ function AreasViewer() {
1963
2382
  })
1964
2383
  });
1965
2384
  }
2385
+ function useDynamicMFParametersStore(selector, equalityFn) {
2386
+ const store = useContext(DynamicMFParmsContext);
2387
+ if (!store)
2388
+ throw new Error(
2389
+ "useDynamicMFParametersStore context must be use inside DynamicMFParmsContext"
2390
+ );
2391
+ return useStore(store, selector, equalityFn);
2392
+ }
2393
+ const useWindowToolsMF = () => {
2394
+ const context = useContext(WindowToolsMFContext);
2395
+ if (!context)
2396
+ throw new Error("useWindowToolsMF context must be use inside WindowToolsMFContext");
2397
+ return context;
2398
+ };
1966
2399
  export {
1967
- AreaContext as A,
1968
- WindowContext as W,
1969
- Area as a,
1970
- AreasViewer as b,
1971
- useAreasViewerUtilityClasses as u
2400
+ AreasAdmin as A,
2401
+ DICCTIONARY as D,
2402
+ LABEL_FILTER_BUTTON as L,
2403
+ MemonizedDynamicMFParmsProvider as M,
2404
+ WindowToolsMFProvider as W,
2405
+ AreasViewer as a,
2406
+ WindowToolsMFContext as b,
2407
+ AreasProvider as c,
2408
+ AreasContext as d,
2409
+ useDynamicMFParametersStore as e,
2410
+ AREAS_DICTIONARY_ID as f,
2411
+ getAreasComponentsDictionary as g,
2412
+ getAreasDictionary as h,
2413
+ DynamicMFParmsProvider as i,
2414
+ DynamicMFParmsContext as j,
2415
+ useWindowToolsMF as u
1972
2416
  };