@j2inn/fin5-ui-utils 0.0.1-alpha.5 → 0.0.3

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 (91) hide show
  1. package/dist/fantomProps/fantomPropsToObject.js +7 -2
  2. package/dist/fantomProps/fantomPropsToObject.js.map +1 -1
  3. package/dist/fantomProps/generateJsonFromFantomPropsFile.d.ts +3 -0
  4. package/dist/fantomProps/generateJsonFromFantomPropsFile.js +37 -7
  5. package/dist/fantomProps/generateJsonFromFantomPropsFile.js.map +1 -1
  6. package/dist/fantomProps/localePropsToJson.d.ts +1 -0
  7. package/dist/fantomProps/localePropsToJson.js +48 -0
  8. package/dist/fantomProps/localePropsToJson.js.map +1 -0
  9. package/dist/fantomProps/readFantomPropsFile.js +30 -4
  10. package/dist/fantomProps/readFantomPropsFile.js.map +1 -1
  11. package/dist/fin5Top/fin5Top.js +9 -5
  12. package/dist/fin5Top/fin5Top.js.map +1 -1
  13. package/dist/fin5Top/getFin5BinUrl.js +6 -2
  14. package/dist/fin5Top/getFin5BinUrl.js.map +1 -1
  15. package/dist/fin5Top/openFin5Alarm.js +10 -6
  16. package/dist/fin5Top/openFin5Alarm.js.map +1 -1
  17. package/dist/fin5Top/openFin5Historian.js +10 -6
  18. package/dist/fin5Top/openFin5Historian.js.map +1 -1
  19. package/dist/index.d.ts +12 -3
  20. package/dist/index.js +37 -3
  21. package/dist/index.js.map +1 -1
  22. package/dist/react/components/{ErrorDisplayer/index.d.ts → ErrorDisplayer.d.ts} +0 -0
  23. package/dist/react/components/ErrorDisplayer.jsx +44 -0
  24. package/dist/react/components/ErrorDisplayer.jsx.map +1 -0
  25. package/dist/react/components/{LoadingSpinner/index.d.ts → LoadingSpinner.d.ts} +0 -0
  26. package/dist/react/components/LoadingSpinner.jsx +12 -0
  27. package/dist/react/components/LoadingSpinner.jsx.map +1 -0
  28. package/dist/react/components/navigation/BasicLayout.d.ts +20 -0
  29. package/dist/react/components/navigation/BasicLayout.jsx +127 -0
  30. package/dist/react/components/navigation/BasicLayout.jsx.map +1 -0
  31. package/dist/react/components/navigation/{MenuPage/index.d.ts → MenuPage.d.ts} +1 -1
  32. package/dist/react/components/navigation/MenuPage.jsx +34 -0
  33. package/dist/react/components/navigation/MenuPage.jsx.map +1 -0
  34. package/dist/react/components/navigation/Router.d.ts +1 -1
  35. package/dist/react/components/navigation/Router.jsx +40 -10
  36. package/dist/react/components/navigation/Router.jsx.map +1 -1
  37. package/dist_es/fantomProps/fantomPropsToObject.d.ts +8 -0
  38. package/dist_es/fantomProps/fantomPropsToObject.js +176 -0
  39. package/dist_es/fantomProps/fantomPropsToObject.js.map +1 -0
  40. package/dist_es/fantomProps/generateJsonFromFantomPropsFile.d.ts +4 -0
  41. package/dist_es/fantomProps/generateJsonFromFantomPropsFile.js +10 -0
  42. package/dist_es/fantomProps/generateJsonFromFantomPropsFile.js.map +1 -0
  43. package/dist_es/fantomProps/localePropsToJson.d.ts +1 -0
  44. package/dist_es/fantomProps/localePropsToJson.js +19 -0
  45. package/dist_es/fantomProps/localePropsToJson.js.map +1 -0
  46. package/dist_es/fantomProps/readFantomPropsFile.d.ts +5 -0
  47. package/dist_es/fantomProps/readFantomPropsFile.js +33 -0
  48. package/dist_es/fantomProps/readFantomPropsFile.js.map +1 -0
  49. package/dist_es/fin5Top/fin5Top.d.ts +111 -0
  50. package/dist_es/fin5Top/fin5Top.js +52 -0
  51. package/dist_es/fin5Top/fin5Top.js.map +1 -0
  52. package/dist_es/fin5Top/getFin5BinUrl.d.ts +2 -0
  53. package/dist_es/fin5Top/getFin5BinUrl.js +3 -0
  54. package/dist_es/fin5Top/getFin5BinUrl.js.map +1 -0
  55. package/dist_es/fin5Top/openFin5Alarm.d.ts +22 -0
  56. package/dist_es/fin5Top/openFin5Alarm.js +17 -0
  57. package/dist_es/fin5Top/openFin5Alarm.js.map +1 -0
  58. package/dist_es/fin5Top/openFin5Historian.d.ts +3 -0
  59. package/dist_es/fin5Top/openFin5Historian.js +13 -0
  60. package/dist_es/fin5Top/openFin5Historian.js.map +1 -0
  61. package/dist_es/index.d.ts +12 -0
  62. package/dist_es/index.js +22 -0
  63. package/dist_es/index.js.map +1 -0
  64. package/dist_es/react/components/ErrorDisplayer.d.ts +19 -0
  65. package/{dist/react/components/ErrorDisplayer/index.jsx → dist_es/react/components/ErrorDisplayer.jsx} +1 -1
  66. package/{dist/react/components/ErrorDisplayer/index.jsx.map → dist_es/react/components/ErrorDisplayer.jsx.map} +1 -1
  67. package/dist_es/react/components/LoadingSpinner.d.ts +3 -0
  68. package/{dist/react/components/LoadingSpinner/index.jsx → dist_es/react/components/LoadingSpinner.jsx} +1 -1
  69. package/{dist/react/components/LoadingSpinner/index.jsx.map → dist_es/react/components/LoadingSpinner.jsx.map} +1 -1
  70. package/dist_es/react/components/navigation/BasicLayout.d.ts +20 -0
  71. package/{dist/react/components/navigation/BasicLayout/index.jsx → dist_es/react/components/navigation/BasicLayout.jsx} +37 -41
  72. package/dist_es/react/components/navigation/BasicLayout.jsx.map +1 -0
  73. package/dist_es/react/components/navigation/MenuPage.d.ts +33 -0
  74. package/{dist/react/components/navigation/MenuPage/index.jsx → dist_es/react/components/navigation/MenuPage.jsx} +2 -2
  75. package/dist_es/react/components/navigation/MenuPage.jsx.map +1 -0
  76. package/dist_es/react/components/navigation/Router.d.ts +12 -0
  77. package/dist_es/react/components/navigation/Router.jsx +16 -0
  78. package/dist_es/react/components/navigation/Router.jsx.map +1 -0
  79. package/package.json +11 -9
  80. package/dist/fantomProps/index.d.ts +0 -3
  81. package/dist/fantomProps/index.js +0 -4
  82. package/dist/fantomProps/index.js.map +0 -1
  83. package/dist/fin5Top/index.d.ts +0 -4
  84. package/dist/fin5Top/index.js +0 -5
  85. package/dist/fin5Top/index.js.map +0 -1
  86. package/dist/react/components/index.d.ts +0 -5
  87. package/dist/react/components/index.js +0 -6
  88. package/dist/react/components/index.js.map +0 -1
  89. package/dist/react/components/navigation/BasicLayout/index.d.ts +0 -11
  90. package/dist/react/components/navigation/BasicLayout/index.jsx.map +0 -1
  91. package/dist/react/components/navigation/MenuPage/index.jsx.map +0 -1
@@ -0,0 +1,111 @@
1
+ import { AlarmFilter } from './openFin5Alarm';
2
+ import { HistorianArgs, HistorianType } from './openFin5Historian';
3
+ export declare const getFin5top: (notifyFailure?: () => void) => Fin5Top | null;
4
+ export declare const fin5Top: Fin5Top | null;
5
+ export declare function isWindowTopFin5(notifyFailure?: () => void): boolean;
6
+ export interface Fin5Top {
7
+ app: Fin5App;
8
+ languageManager: LanguageManager;
9
+ finstack?: {
10
+ projectName?: string;
11
+ device?: {
12
+ currentUser?: {
13
+ toObj: () => unknown;
14
+ };
15
+ };
16
+ };
17
+ }
18
+ export interface Fin5App {
19
+ /**
20
+ * Toggles FIN right side menu.
21
+ * The forceTo parameter can be used to enforce a specific status instead of a toggling behaviour,
22
+ * where: true -> menu closed, false -> menu open
23
+ */
24
+ ToggleCollapse: (forceTo: boolean) => void;
25
+ /**
26
+ * Returns current target record id.
27
+ */
28
+ TargetRef: () => TargetRef;
29
+ /**
30
+ * Updates the current target record id.
31
+ * Navigates the current app to the specified
32
+ * <code>targetRef</code>. Target Ref is the id of any equip/site etc..
33
+ */
34
+ NavigateToTargetRef: (targetRef: TargetRef, maintainView: boolean) => void;
35
+ /**
36
+ * Navigates to a particular application (trends, notes .. etc) under a specific target.
37
+ * @param {Fin5AppNames} appName name of the application
38
+ * @param {TargetRef} targetRef id of the target. Is the id of the equip/site.. etc to where the app should navigate
39
+ * @param {boolean} skipRef is the flag indicating where to ignore the target ref if not mentioned. If this flag is true and the target ref is not provided, then the navigation will be made to the root target ref and will not be obtained from where the app already is
40
+ */
41
+ NavigateToApp: (appName: Fin5AppNames, targetRef?: TargetRef, skipRef?: boolean, params?: string[]) => Promise<void>;
42
+ /**
43
+ * Method to open a url on the application LHS. The LHS here is the <code>iframe</code> where all
44
+ * the graphics etc are opened.
45
+ *
46
+ * @method LoadApplication
47
+ * @param {string} url - Is the url which is to be loaded
48
+ * @param {string} title - Specifies the title to be displayed on the iframe object
49
+ * @param {string} targetId - Specifies the id of the equip (etc) to which the main navigation update.
50
+ * @param {object} settings - extra settings that can be passed in when calling hte func
51
+ * @param {boolean} settings.collapse - flag indicating the collapse state of the RHS app panel
52
+ */
53
+ LoadApplication: (url: string, title?: string, targetRef?: TargetRef, settings?: {
54
+ collapse?: boolean;
55
+ }) => Promise<void>;
56
+ /**
57
+ * Get the filters object from the alarms application.
58
+ */
59
+ GetAlarmFilters: () => AlarmFilter;
60
+ /**
61
+ * Sets the filter settings for the alarms.
62
+ * @param {AlarmFilter} filters Is the object that defines the filter properties.
63
+ * @param {boolean} historical Flag indicating if the filter properties need to be applied to the historical alarms.
64
+ */
65
+ SetAlarmFilters: (filters: AlarmFilter, historical?: boolean) => void;
66
+ /**
67
+ * Navigates to the historian app and loads the graphs as per the passed arguments. The graph will be drawn for the passed "point" ids or for a "query" id or for a "string" query
68
+ * @param {HistorianType} type is the type of graph arg. Available args are:
69
+ * - point : the args will have point ids in an array
70
+ * - query : the arg will be the id of a saved chart query
71
+ * - string : the arg will be a query string
72
+ * @param {HistorianArgs} args is the array/string for point ids, the query id or the raw query string
73
+ */
74
+ OpenHistorianWithOptions: (type: HistorianType, args: HistorianArgs) => void;
75
+ findComponent: (name: string) => Fin5AppComponent;
76
+ /**
77
+ * @see https://ractive.js.org/api/#ractiveobserve
78
+ */
79
+ observe: (keypath: string, callback: (newValue: unknown, oldValue: unknown, keypath: string) => void) => {
80
+ cancel: () => void;
81
+ };
82
+ set: (name: string, value: unknown) => Promise<undefined>;
83
+ get: (name: string) => Promise<unknown>;
84
+ APP_NAMES: typeof Fin5AppNames;
85
+ }
86
+ export declare enum Fin5AppNames {
87
+ EQUIP = "equip",
88
+ GRAPHICS = "graphics",
89
+ POINTS = "points",
90
+ ALARMS = "alarms",
91
+ NOTES = "notes",
92
+ SUMMARY = "summary",
93
+ SUMMARY_TOPICS = "summaryList",
94
+ TOOLS = "tools",
95
+ SCHEDULES = "schedules",
96
+ SCHEDULE_LIST = "scheduleList",
97
+ HISTORIAN = "trends",
98
+ TREND_LIST = "trendList",
99
+ SEARCH = "search",
100
+ LOGOUT = "logout",
101
+ GENERIC = "generic",
102
+ REPORTS = "reports"
103
+ }
104
+ interface LanguageManager {
105
+ currentLang: string;
106
+ }
107
+ interface Fin5AppComponent {
108
+ set: (value: unknown) => Promise<undefined>;
109
+ }
110
+ export declare type TargetRef = string | null | undefined;
111
+ export {};
@@ -0,0 +1,52 @@
1
+ class Fin5TopRetriever {
2
+ static _fin5Top;
3
+ static get fin5Top() {
4
+ return this.getFin5top();
5
+ }
6
+ static getFin5top = (notifyFailure) => {
7
+ if (this._fin5Top === undefined) {
8
+ this._fin5Top = isWindowTopFin5(notifyFailure)
9
+ ? window.top // Cast to unknown to obscure properties from Window to simplify usage.
10
+ : null;
11
+ }
12
+ return this._fin5Top;
13
+ };
14
+ }
15
+ export const getFin5top = Fin5TopRetriever.getFin5top;
16
+ export const fin5Top = Fin5TopRetriever.fin5Top;
17
+ export function isWindowTopFin5(notifyFailure) {
18
+ try {
19
+ window?.top?.origin;
20
+ if (window.top.finstack) {
21
+ return true;
22
+ }
23
+ else {
24
+ throw new Error('FIN 5 top not available');
25
+ }
26
+ }
27
+ catch (err) {
28
+ console.warn(err);
29
+ notifyFailure?.();
30
+ return false;
31
+ }
32
+ }
33
+ export var Fin5AppNames;
34
+ (function (Fin5AppNames) {
35
+ Fin5AppNames["EQUIP"] = "equip";
36
+ Fin5AppNames["GRAPHICS"] = "graphics";
37
+ Fin5AppNames["POINTS"] = "points";
38
+ Fin5AppNames["ALARMS"] = "alarms";
39
+ Fin5AppNames["NOTES"] = "notes";
40
+ Fin5AppNames["SUMMARY"] = "summary";
41
+ Fin5AppNames["SUMMARY_TOPICS"] = "summaryList";
42
+ Fin5AppNames["TOOLS"] = "tools";
43
+ Fin5AppNames["SCHEDULES"] = "schedules";
44
+ Fin5AppNames["SCHEDULE_LIST"] = "scheduleList";
45
+ Fin5AppNames["HISTORIAN"] = "trends";
46
+ Fin5AppNames["TREND_LIST"] = "trendList";
47
+ Fin5AppNames["SEARCH"] = "search";
48
+ Fin5AppNames["LOGOUT"] = "logout";
49
+ Fin5AppNames["GENERIC"] = "generic";
50
+ Fin5AppNames["REPORTS"] = "reports";
51
+ })(Fin5AppNames || (Fin5AppNames = {}));
52
+ //# sourceMappingURL=fin5Top.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fin5Top.js","sourceRoot":"","sources":["../../src/fin5Top/fin5Top.ts"],"names":[],"mappings":"AAGA,MAAM,gBAAgB;IACb,MAAM,CAAC,QAAQ,CAAgB;IAEvC,MAAM,KAAK,OAAO;QACjB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAA;IACzB,CAAC;IACD,MAAM,CAAC,UAAU,GAAG,CAAC,aAA0B,EAAkB,EAAE;QAClE,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAChC,IAAI,CAAC,QAAQ,GAAG,eAAe,CAAC,aAAa,CAAC;gBAC7C,CAAC,CAAE,MAAM,CAAC,GAA0B,CAAC,uEAAuE;gBAC5G,CAAC,CAAC,IAAI,CAAA;SACP;QACD,OAAO,IAAI,CAAC,QAAQ,CAAA;IACrB,CAAC,CAAA;;AAGF,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAA;AAErD,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAA;AAE/C,MAAM,UAAU,eAAe,CAAC,aAA0B;IACzD,IAAI;QACH,MAAM,EAAE,GAAG,EAAE,MAAM,CAAA;QACnB,IAAK,MAAM,CAAC,GAA0B,CAAC,QAAQ,EAAE;YAChD,OAAO,IAAI,CAAA;SACX;aAAM;YACN,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;SAC1C;KACD;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACjB,aAAa,EAAE,EAAE,CAAA;QACjB,OAAO,KAAK,CAAA;KACZ;AACF,CAAC;AA8GD,MAAM,CAAN,IAAY,YAiBX;AAjBD,WAAY,YAAY;IACvB,+BAAe,CAAA;IACf,qCAAqB,CAAA;IACrB,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;IACjB,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,8CAA8B,CAAA;IAC9B,+BAAe,CAAA;IACf,uCAAuB,CAAA;IACvB,8CAA8B,CAAA;IAC9B,oCAAoB,CAAA;IACpB,wCAAwB,CAAA;IACxB,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;IACjB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;AACpB,CAAC,EAjBW,YAAY,KAAZ,YAAY,QAiBvB"}
@@ -0,0 +1,2 @@
1
+ import { HRef } from 'haystack-core';
2
+ export declare const getFin5BinUrl: (id: HRef) => string;
@@ -0,0 +1,3 @@
1
+ import { fin5Top } from './fin5Top';
2
+ export const getFin5BinUrl = (id) => `/finGetFile/${fin5Top?.finstack?.projectName}?fileRef=${id?.toString()}`;
3
+ //# sourceMappingURL=getFin5BinUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFin5BinUrl.js","sourceRoot":"","sources":["../../src/fin5Top/getFin5BinUrl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAQ,EAAU,EAAE,CACjD,eAAe,OAAO,EAAE,QAAQ,EAAE,WAAW,YAAY,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { TargetRef } from './fin5Top';
2
+ export interface AlarmFilterTypes {
3
+ alarms: boolean;
4
+ events: boolean;
5
+ acks: boolean;
6
+ }
7
+ export interface AlarmFilter {
8
+ range?: string;
9
+ priorityThreshold?: string;
10
+ acked?: boolean;
11
+ unacked?: boolean;
12
+ inAlarm?: boolean;
13
+ notInAlarm?: boolean;
14
+ search?: string;
15
+ types?: AlarmFilterTypes;
16
+ }
17
+ export declare type AlarmOptions = {
18
+ targetRef?: TargetRef;
19
+ filter: AlarmFilter;
20
+ historical?: boolean;
21
+ };
22
+ export declare const openFin5AlarmsApp: ({ targetRef, filter, historical, }: AlarmOptions) => Promise<void>;
@@ -0,0 +1,17 @@
1
+ //////////////////////////////////////////////////////////////////////////
2
+ // Alarms
3
+ //////////////////////////////////////////////////////////////////////////
4
+ import { fin5Top } from './fin5Top';
5
+ export const openFin5AlarmsApp = async ({ targetRef, filter, historical = false, }) => {
6
+ await fin5Top?.app.NavigateToApp(fin5Top?.app?.APP_NAMES?.ALARMS, targetRef);
7
+ fin5Top?.app.ToggleCollapse(false);
8
+ let alarmFilters = fin5Top?.app?.GetAlarmFilters() ?? {};
9
+ if (filter) {
10
+ alarmFilters = {
11
+ ...alarmFilters,
12
+ ...filter,
13
+ };
14
+ }
15
+ fin5Top?.app?.SetAlarmFilters(alarmFilters, historical);
16
+ };
17
+ //# sourceMappingURL=openFin5Alarm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openFin5Alarm.js","sourceRoot":"","sources":["../../src/fin5Top/openFin5Alarm.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,SAAS;AACT,0EAA0E;AAE1E,OAAO,EAAE,OAAO,EAAa,MAAM,WAAW,CAAA;AAyB9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACvC,SAAS,EACT,MAAM,EACN,UAAU,GAAG,KAAK,GACJ,EAAiB,EAAE;IACjC,MAAM,OAAO,EAAE,GAAG,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;IAC5E,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IAElC,IAAI,YAAY,GAAG,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,CAAA;IACxD,IAAI,MAAM,EAAE;QACX,YAAY,GAAG;YACd,GAAG,YAAY;YACf,GAAG,MAAM;SACT,CAAA;KACD;IAED,OAAO,EAAE,GAAG,EAAE,eAAe,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;AACxD,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare type HistorianType = 'point' | 'query' | 'string';
2
+ export declare type HistorianArgs = string | (string | undefined)[];
3
+ export declare const openFin5HistorianApp: (queryType?: HistorianType, args?: HistorianArgs) => Promise<void>;
@@ -0,0 +1,13 @@
1
+ //////////////////////////////////////////////////////////////////////////
2
+ // Historian
3
+ //////////////////////////////////////////////////////////////////////////
4
+ import { fin5Top } from './fin5Top';
5
+ export const openFin5HistorianApp = async (queryType, args) => {
6
+ if (fin5Top) {
7
+ queryType && args
8
+ ? fin5Top.app.OpenHistorianWithOptions(queryType, args)
9
+ : fin5Top.app.NavigateToApp(fin5Top.app.APP_NAMES.TREND_LIST);
10
+ fin5Top?.app.ToggleCollapse(false);
11
+ }
12
+ };
13
+ //# sourceMappingURL=openFin5Historian.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openFin5Historian.js","sourceRoot":"","sources":["../../src/fin5Top/openFin5Historian.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,YAAY;AACZ,0EAA0E;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAMnC,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACxC,SAAyB,EACzB,IAAoB,EACJ,EAAE;IAClB,IAAI,OAAO,EAAE;QACZ,SAAS,IAAI,IAAI;YAChB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,SAAS,EAAE,IAAI,CAAC;YACvD,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QAC9D,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;KAClC;AACF,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ export * from './fantomProps/fantomPropsToObject';
2
+ export * from './fantomProps/generateJsonFromFantomPropsFile';
3
+ export * from './fantomProps/readFantomPropsFile';
4
+ export * from './fin5Top/fin5Top';
5
+ export * from './fin5Top/getFin5BinUrl';
6
+ export * from './fin5Top/openFin5Alarm';
7
+ export * from './fin5Top/openFin5Historian';
8
+ export * from './react/components/ErrorDisplayer';
9
+ export * from './react/components/LoadingSpinner';
10
+ export * from './react/components/navigation/BasicLayout';
11
+ export * from './react/components/navigation/MenuPage';
12
+ export * from './react/components/navigation/Router';
@@ -0,0 +1,22 @@
1
+ //////////////////////////////////////////////////////////////////////////
2
+ // Fantom Props
3
+ //////////////////////////////////////////////////////////////////////////
4
+ export * from './fantomProps/fantomPropsToObject';
5
+ export * from './fantomProps/generateJsonFromFantomPropsFile';
6
+ export * from './fantomProps/readFantomPropsFile';
7
+ //////////////////////////////////////////////////////////////////////////
8
+ // Fin5 APIs related modules
9
+ //////////////////////////////////////////////////////////////////////////
10
+ export * from './fin5Top/fin5Top';
11
+ export * from './fin5Top/getFin5BinUrl';
12
+ export * from './fin5Top/openFin5Alarm';
13
+ export * from './fin5Top/openFin5Historian';
14
+ //////////////////////////////////////////////////////////////////////////
15
+ // React components
16
+ //////////////////////////////////////////////////////////////////////////
17
+ export * from './react/components/ErrorDisplayer';
18
+ export * from './react/components/LoadingSpinner';
19
+ export * from './react/components/navigation/BasicLayout';
20
+ export * from './react/components/navigation/MenuPage';
21
+ export * from './react/components/navigation/Router';
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,eAAe;AACf,0EAA0E;AAC1E,cAAc,mCAAmC,CAAA;AACjD,cAAc,+CAA+C,CAAA;AAC7D,cAAc,mCAAmC,CAAA;AACjD,0EAA0E;AAC1E,4BAA4B;AAC5B,0EAA0E;AAC1E,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,6BAA6B,CAAA;AAC3C,0EAA0E;AAC1E,mBAAmB;AACnB,0EAA0E;AAC1E,cAAc,mCAAmC,CAAA;AACjD,cAAc,mCAAmC,CAAA;AACjD,cAAc,2CAA2C,CAAA;AACzD,cAAc,wCAAwC,CAAA;AACtD,cAAc,sCAAsC,CAAA"}
@@ -0,0 +1,19 @@
1
+ import React, { ErrorInfo, ReactNode } from 'react';
2
+ interface ErrorBoundaryState {
3
+ error?: Error;
4
+ }
5
+ interface ErrorBoundaryProps {
6
+ children: ReactNode;
7
+ }
8
+ export declare class DefaultErrorBoundary extends React.Component<ErrorBoundaryProps> {
9
+ state: ErrorBoundaryState;
10
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
11
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
12
+ render(): ReactNode;
13
+ }
14
+ export interface ErrorDisplayerProps {
15
+ error: Error;
16
+ extra: React.ReactNode;
17
+ }
18
+ export declare const ErrorDisplayer: React.FC<ErrorDisplayerProps>;
19
+ export {};
@@ -33,4 +33,4 @@ export const ErrorDisplayer = ({ error, extra, }) => {
33
33
  </Collapse>
34
34
  </Container>} extra={extra}/>);
35
35
  };
36
- //# sourceMappingURL=index.jsx.map
36
+ //# sourceMappingURL=ErrorDisplayer.jsx.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.jsx","sourceRoot":"","sources":["../../../../src/react/components/ErrorDisplayer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC3E,OAAO,KAA+B,MAAM,OAAO,CAAA;AAUnD,MAAM,OAAO,oBAAqB,SAAQ,KAAK,CAAC,SAA6B;IACnE,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CAAA;SACD;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAA;IAC3B,CAAC;CACD;AAOD,MAAM,CAAC,MAAM,cAAc,GAAkC,CAAC,EAC7D,KAAK,EACL,KAAK,GACL,EAAE,EAAE;IACJ,OAAO,CACN,CAAC,MAAM,CACN,MAAM,CAAC,OAAO,CACd,KAAK,CAAC,8BAA8B,CACpC,QAAQ,CAAC,CACR,CAAC,SAAS,CAAC,MAAM,CAChB;KAAA,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAClD;MAAA,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CACrD;OAAA,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CACtC;QAAA,CAAC,KAAK,CAAC,KAAK,CACb;OAAA,EAAE,UAAU,CAAC,IAAI,CAClB;MAAA,EAAE,QAAQ,CAAC,KAAK,CACjB;KAAA,EAAE,QAAQ,CACX;IAAA,EAAE,SAAS,CAAC,CACZ,CACD,KAAK,CAAC,CAAC,KAAK,CAAC,EACZ,CACF,CAAA;AACF,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const LoadingSpinner: React.FC;
3
+ export default LoadingSpinner;
@@ -4,4 +4,4 @@ const LoadingSpinner = () => (<Container center style={{ height: '100%', width:
4
4
  <Spin size='large'></Spin>
5
5
  </Container>);
6
6
  export default LoadingSpinner;
7
- //# sourceMappingURL=index.jsx.map
7
+ //# sourceMappingURL=LoadingSpinner.jsx.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.jsx","sourceRoot":"","sources":["../../../../src/react/components/LoadingSpinner/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,cAAc,GAAa,GAAG,EAAE,CAAC,CACtC,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAC1D;EAAA,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAC1B;CAAA,EAAE,SAAS,CAAC,CACZ,CAAA;AAED,eAAe,cAAc,CAAA"}
1
+ {"version":3,"file":"LoadingSpinner.jsx","sourceRoot":"","sources":["../../../src/react/components/LoadingSpinner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,cAAc,GAAa,GAAG,EAAE,CAAC,CACtC,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAC1D;EAAA,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAC1B;CAAA,EAAE,SAAS,CAAC,CACZ,CAAA;AAED,eAAe,cAAc,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { LayoutProps, MenuProps } from 'antd';
2
+ import React from 'react';
3
+ import { MenuPage } from './MenuPage';
4
+ export interface BasicLayoutProps {
5
+ /**
6
+ * List of pages for the menu and the routing
7
+ */
8
+ pages?: MenuPage[];
9
+ defaultPage?: string;
10
+ onPageChange?: (page: string) => void;
11
+ compactSider?: boolean;
12
+ layoutProps?: LayoutProps;
13
+ mobileHeaderProps?: LayoutProps;
14
+ contentProps?: LayoutProps;
15
+ menuProps?: Omit<MenuProps, 'items' | 'selectedKeys' | 'onSelect'>;
16
+ }
17
+ /**
18
+ * Basic layout that combines menu and routing into one.
19
+ */
20
+ export declare const BasicLayout: React.FC<BasicLayoutProps>;
@@ -1,19 +1,20 @@
1
- import { MenuUnfoldOutlined } from '@ant-design/icons';
1
+ import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
2
2
  import { Button, Layout, Menu } from '@j2inn/ui';
3
3
  import React, { useEffect, useState } from 'react';
4
4
  import { createUseStyles } from 'react-jss';
5
- import { ErrorDisplayer } from '../../ErrorDisplayer';
6
- import { getPage } from '../MenuPage';
7
- import { Router } from '../Router';
5
+ import { ErrorDisplayer } from '../ErrorDisplayer';
6
+ import { findPageByName } from './MenuPage';
7
+ import { Router } from './Router';
8
+ const HEADER_HEIGHT = 45;
8
9
  const useStyles = createUseStyles((theme) => {
9
- console.log('theme ->', theme);
10
10
  return {
11
11
  header: {
12
12
  position: 'fixed',
13
13
  width: '100%',
14
14
  zIndex: 1000,
15
- color: theme.textColorInverse,
16
- background: theme.primary,
15
+ padding: 0,
16
+ height: HEADER_HEIGHT,
17
+ lineHeight: '45px',
17
18
  },
18
19
  sider: {
19
20
  overflow: 'auto',
@@ -23,8 +24,7 @@ const useStyles = createUseStyles((theme) => {
23
24
  top: 0,
24
25
  bottom: 0,
25
26
  zIndex: 999,
26
- color: 'red',
27
- backgroundColor: theme.primary,
27
+ paddingTop: ({ isMobile }) => isMobile ? HEADER_HEIGHT : 0,
28
28
  },
29
29
  menuTrigger: {
30
30
  width: 45,
@@ -35,23 +35,24 @@ const useStyles = createUseStyles((theme) => {
35
35
  transition: 'color 0.3s ease-in-out',
36
36
  backgroundColor: 'transparent',
37
37
  color: 'white',
38
+ '&:hover': {
39
+ color: theme.linkActiveColor,
40
+ },
38
41
  },
39
- // '&:hover': {
40
- // menuTrigger: {
41
- // color: theme.primary,
42
- // backgroundColor: theme.backgroundColorBase,
43
- // },
44
- // },
42
+ content: ({ isMobile, compactSider }) => ({
43
+ paddingLeft: isMobile ? 0 : compactSider ? 45 : 200,
44
+ paddingTop: isMobile ? HEADER_HEIGHT : 0,
45
+ }),
45
46
  };
46
47
  });
47
48
  // Workaround j2inn/ui exporting problem
48
49
  const Header = Layout.Header;
49
50
  const Sider = Layout.Sider;
50
51
  const Content = Layout.Content;
51
- const DEFAULT_UNCOLLAPSED_MENU_WIDTH = 45;
52
- const COLLAPSED_MENU_WIDTH = 0;
53
- export const BasicLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', onPageChange, uncollapsedMenuWidth = DEFAULT_UNCOLLAPSED_MENU_WIDTH, menuProps, }) => {
54
- const classes = useStyles();
52
+ /**
53
+ * Basic layout that combines menu and routing into one.
54
+ */
55
+ export const BasicLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', onPageChange, compactSider, layoutProps, mobileHeaderProps, contentProps, menuProps, }) => {
55
56
  const [currentPage, setCurrentPage] = useState(defaultPage);
56
57
  // Fire onChange
57
58
  useEffect(() => {
@@ -60,39 +61,34 @@ export const BasicLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', on
60
61
  // manage mobile navigation
61
62
  const [isMobile, setIsMobile] = useState(false);
62
63
  const [hiddenSider, setHiddenSider] = useState(false);
63
- // const [collapsedSider, setCollapsedSider] = useState(false)
64
- // const actualCollapsedMenuWidth =
65
- // hiddenSider && isMobile ? 0 : COLLAPSED_MENU_WIDTH
66
- return (<Layout hasSider>
67
- {isMobile && (<Header className={classes.header}>
68
- <MenuUnfoldOutlined className={classes.menuTrigger} onClick={() => {
69
- setHiddenSider(!hiddenSider);
70
- }}/>
64
+ const classes = useStyles({ isMobile, compactSider });
65
+ return (<Layout hasSider {...layoutProps}>
66
+ {isMobile && (<Header className={classes.header} {...mobileHeaderProps}>
67
+ {hiddenSider ? (<MenuUnfoldOutlined className={classes.menuTrigger} onClick={() => {
68
+ setHiddenSider(!hiddenSider);
69
+ }}/>) : (<MenuFoldOutlined className={classes.menuTrigger} onClick={() => {
70
+ setHiddenSider(!hiddenSider);
71
+ }}/>)}
71
72
  </Header>)}
72
73
  <Sider breakpoint='md' onBreakpoint={(broken) => {
73
74
  setIsMobile(broken);
74
75
  setHiddenSider(true);
75
- }} collapsed={isMobile && hiddenSider} collapsedWidth={COLLAPSED_MENU_WIDTH} trigger={null} className={classes.sider} style={{
76
- paddingTop: isMobile
77
- ? uncollapsedMenuWidth
78
- : COLLAPSED_MENU_WIDTH,
79
- }}>
80
- <Menu mode='inline' {...menuProps} items={pages} selectedKeys={[currentPage]} onSelect={({ key }) => {
76
+ }} collapsed={(isMobile && hiddenSider) || compactSider} collapsedWidth={isMobile && hiddenSider
77
+ ? 0
78
+ : compactSider
79
+ ? HEADER_HEIGHT
80
+ : 0} trigger={null} className={classes.sider}>
81
+ <Menu {...menuProps} items={pages} selectedKeys={[currentPage]} onSelect={({ key }) => {
81
82
  if (!hiddenSider) {
82
83
  setHiddenSider(true);
83
84
  }
84
- const page = getPage(pages, key);
85
+ const page = findPageByName(pages, key);
85
86
  if (page?.component) {
86
87
  setCurrentPage(key);
87
88
  }
88
89
  }}/>
89
90
  </Sider>
90
- <Content style={{
91
- // paddingLeft: actualMenuWidth,
92
- paddingTop: isMobile
93
- ? uncollapsedMenuWidth
94
- : COLLAPSED_MENU_WIDTH,
95
- }}>
91
+ <Content className={classes.content} {...contentProps}>
96
92
  <Router pages={pages} currentPage={currentPage ?? defaultPage} fallbackComponent={<ErrorDisplayer error={new Error('Page Not Found')} extra={[
97
93
  <Button type='primary' key='refresh' onClick={() => setCurrentPage(defaultPage)}>
98
94
  Go Home
@@ -101,4 +97,4 @@ export const BasicLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', on
101
97
  </Content>
102
98
  </Layout>);
103
99
  };
104
- //# sourceMappingURL=index.jsx.map
100
+ //# sourceMappingURL=BasicLayout.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BasicLayout.jsx","sourceRoot":"","sources":["../../../../src/react/components/navigation/BasicLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,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EAAE,GAAG,EAAE,EAAE,EAAE;YACrB,IAAI,CAAC,WAAW,EAAE;gBACjB,cAAc,CAAC,IAAI,CAAC,CAAA;aACpB;YACD,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;YACvC,IAAI,IAAI,EAAE,SAAS,EAAE;gBACpB,cAAc,CAAC,GAAG,CAAC,CAAA;aACnB;QACF,CAAC,CAAC,EAEJ;GAAA,EAAE,KAAK,CACP;GAAA,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,YAAY,CAAC,CACrD;IAAA,CAAC,MAAM,CACN,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,WAAW,CAAC,CAAC,WAAW,IAAI,WAAW,CAAC,CACxC,iBAAiB,CAAC,CACjB,CAAC,cAAc,CACd,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CACnC,KAAK,CAAC,CAAC;gBACN,CAAC,MAAM,CACN,IAAI,CAAC,SAAS,CACd,GAAG,CAAC,SAAS,CACb,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAC3C;;QACD,EAAE,MAAM,CAAC;aACT,CAAC,EACD,CACF,EAEH;GAAA,EAAE,OAAO,CACV;EAAA,EAAE,MAAM,CAAC,CACT,CAAA;AACF,CAAC,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { ItemType } from 'antd/lib/menu/hooks/useItems';
2
+ import React, { PropsWithChildren } from 'react';
3
+ /**
4
+ * Menu page has both the data required by the menu and the data required to actually render the page.
5
+ */
6
+ export declare type MenuPage<T = Record<string, unknown>> = ItemType & Page<T>;
7
+ /**
8
+ * Menu Item that represents an application page
9
+ */
10
+ interface Page<T = Record<string, unknown>> {
11
+ key: string;
12
+ component?: React.LazyExoticComponent<React.FC<T>>;
13
+ props?: PropsWithChildren<T>;
14
+ children?: Page<T>[];
15
+ disabled?: boolean;
16
+ }
17
+ /**
18
+ * Retrieve a specific page or subPage from a root page list
19
+ * @param name the name of the searched page
20
+ * @param pages the list of root pages
21
+ */
22
+ export declare function findPageByName<T extends MenuPage>(pages: T[], name?: string): T | undefined;
23
+ /**
24
+ * Expands the list of pages to include all the subpages
25
+ */
26
+ export declare function pageTreeToPageList<T extends MenuPage>(pages: T[]): T[];
27
+ /**
28
+ * Recursively get all the subPages of a root page
29
+ * @param page root page
30
+ * @returns the whole tree of subPages as a list
31
+ */
32
+ export declare function getAllSubPages<T extends MenuPage>(page: T): T[];
33
+ export {};
@@ -3,7 +3,7 @@
3
3
  * @param name the name of the searched page
4
4
  * @param pages the list of root pages
5
5
  */
6
- export function getPage(pages, name) {
6
+ export function findPageByName(pages, name) {
7
7
  return pageTreeToPageList(pages).find((page) => page.key === name && !page.disabled);
8
8
  }
9
9
  /**
@@ -25,4 +25,4 @@ export function getAllSubPages(page) {
25
25
  return [page];
26
26
  }
27
27
  }
28
- //# sourceMappingURL=index.jsx.map
28
+ //# sourceMappingURL=MenuPage.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuPage.jsx","sourceRoot":"","sources":["../../../../src/react/components/navigation/MenuPage.tsx"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC7B,KAAU,EACV,IAAa;IAEb,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,IAAI,CACpC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAC7C,CAAA;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAqB,KAAU;IAChE,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAS,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAqB,IAAO;IACzD,IAAI,IAAI,CAAC,QAAQ,EAAE;QAClB,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CACnB,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,OAAY,CAAC,CAAC,CAC/D,CAAA;KACD;SAAM;QACN,OAAO,CAAC,IAAI,CAAC,CAAA;KACb;AACF,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { PropsWithChildren, ReactElement } from 'react';
2
+ import { MenuPage } from './MenuPage';
3
+ export interface RouterProps<T extends MenuPage> {
4
+ pages?: T[];
5
+ currentPage: string;
6
+ onPageChange?: (selectedPage?: T) => void;
7
+ fallbackComponent?: ReactElement;
8
+ }
9
+ /**
10
+ * Renders the currently selected page from a tree of pages
11
+ */
12
+ export declare function Router<T extends MenuPage>({ pages, currentPage, onPageChange, fallbackComponent, }: PropsWithChildren<RouterProps<T>>): JSX.Element;
@@ -0,0 +1,16 @@
1
+ import React, { Suspense, useEffect, useMemo, } from 'react';
2
+ import LoadingSpinner from '../LoadingSpinner';
3
+ import { findPageByName } from './MenuPage';
4
+ /**
5
+ * Renders the currently selected page from a tree of pages
6
+ */
7
+ export function Router({ pages = [], currentPage, onPageChange, fallbackComponent, }) {
8
+ const page = useMemo(() => findPageByName(pages, currentPage), [pages, currentPage]);
9
+ useEffect(() => {
10
+ onPageChange?.(page);
11
+ }, [page]);
12
+ return page?.component ? (<Suspense fallback={<LoadingSpinner />}>
13
+ {React.createElement(page.component, page?.props)}
14
+ </Suspense>) : (fallbackComponent ?? <div>{currentPage} page not found</div>);
15
+ }
16
+ //# sourceMappingURL=Router.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Router.jsx","sourceRoot":"","sources":["../../../../src/react/components/navigation/Router.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAGb,QAAQ,EACR,SAAS,EACT,OAAO,GACP,MAAM,OAAO,CAAA;AACd,OAAO,cAAc,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAY,MAAM,YAAY,CAAA;AASrD;;GAEG;AACH,MAAM,UAAU,MAAM,CAAqB,EAC1C,KAAK,GAAG,EAAE,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,GACkB;IACnC,MAAM,IAAI,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,CAAC,EACxC,CAAC,KAAK,EAAE,WAAW,CAAC,CACpB,CAAA;IAED,SAAS,CAAC,GAAG,EAAE;QACd,YAAY,EAAE,CAAC,IAAI,CAAC,CAAA;IACrB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,OAAO,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CACxB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,AAAD,EAAG,CAAC,CACtC;GAAA,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAClD;EAAA,EAAE,QAAQ,CAAC,CACX,CAAC,CAAC,CAAC,CACH,iBAAiB,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,CAAE,eAAc,EAAE,GAAG,CAAC,CAC5D,CAAA;AACF,CAAC"}