@apia/util 2.0.11 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/dist/index.d.ts +1865 -68
  2. package/dist/index.js +2650 -62
  3. package/dist/index.js.map +1 -1
  4. package/package.json +4 -3
  5. package/dist/animate/index.d.ts +0 -4
  6. package/dist/animate/index.d.ts.map +0 -1
  7. package/dist/animate/index.js +0 -24
  8. package/dist/animate/index.js.map +0 -1
  9. package/dist/array/arrayOrArray.d.ts +0 -4
  10. package/dist/array/arrayOrArray.d.ts.map +0 -1
  11. package/dist/array/arrayOrArray.js +0 -8
  12. package/dist/array/arrayOrArray.js.map +0 -1
  13. package/dist/array/getIndex.d.ts +0 -14
  14. package/dist/array/getIndex.d.ts.map +0 -1
  15. package/dist/array/getIndex.js +0 -12
  16. package/dist/array/getIndex.js.map +0 -1
  17. package/dist/crypto/decrypt.d.ts +0 -4
  18. package/dist/crypto/decrypt.d.ts.map +0 -1
  19. package/dist/crypto/decrypt.js +0 -16
  20. package/dist/crypto/decrypt.js.map +0 -1
  21. package/dist/crypto/encrypt.d.ts +0 -4
  22. package/dist/crypto/encrypt.d.ts.map +0 -1
  23. package/dist/crypto/encrypt.js +0 -13
  24. package/dist/crypto/encrypt.js.map +0 -1
  25. package/dist/crypto/generateKey.js +0 -11
  26. package/dist/crypto/generateKey.js.map +0 -1
  27. package/dist/date/apiaDateToStandarFormat.d.ts +0 -4
  28. package/dist/date/apiaDateToStandarFormat.d.ts.map +0 -1
  29. package/dist/date/apiaDateToStandarFormat.js +0 -12
  30. package/dist/date/apiaDateToStandarFormat.js.map +0 -1
  31. package/dist/date/dateToApiaFormat.d.ts +0 -4
  32. package/dist/date/dateToApiaFormat.d.ts.map +0 -1
  33. package/dist/date/dateToApiaFormat.js +0 -9
  34. package/dist/date/dateToApiaFormat.js.map +0 -1
  35. package/dist/date/getDateFormat.d.ts +0 -11
  36. package/dist/date/getDateFormat.d.ts.map +0 -1
  37. package/dist/date/getDateFormat.js +0 -20
  38. package/dist/date/getDateFormat.js.map +0 -1
  39. package/dist/debug/debugDispatcher.d.ts +0 -36
  40. package/dist/debug/debugDispatcher.d.ts.map +0 -1
  41. package/dist/debug/debugDispatcher.js +0 -75
  42. package/dist/debug/debugDispatcher.js.map +0 -1
  43. package/dist/debug/shortcutController.d.ts +0 -57
  44. package/dist/debug/shortcutController.d.ts.map +0 -1
  45. package/dist/debug/shortcutController.js +0 -152
  46. package/dist/debug/shortcutController.js.map +0 -1
  47. package/dist/documents/downloadStringAsDoc.d.ts +0 -8
  48. package/dist/documents/downloadStringAsDoc.d.ts.map +0 -1
  49. package/dist/documents/downloadStringAsDoc.js +0 -12
  50. package/dist/documents/downloadStringAsDoc.js.map +0 -1
  51. package/dist/documents/downloadUrl.d.ts +0 -20
  52. package/dist/documents/downloadUrl.d.ts.map +0 -1
  53. package/dist/documents/downloadUrl.js +0 -18
  54. package/dist/documents/downloadUrl.js.map +0 -1
  55. package/dist/documents/openAndReadFile.d.ts +0 -4
  56. package/dist/documents/openAndReadFile.d.ts.map +0 -1
  57. package/dist/documents/openAndReadFile.js +0 -29
  58. package/dist/documents/openAndReadFile.js.map +0 -1
  59. package/dist/dom/autoDisconnectMutationObserver.d.ts +0 -17
  60. package/dist/dom/autoDisconnectMutationObserver.d.ts.map +0 -1
  61. package/dist/dom/autoDisconnectMutationObserver.js +0 -35
  62. package/dist/dom/autoDisconnectMutationObserver.js.map +0 -1
  63. package/dist/dom/customEvents.d.ts +0 -40
  64. package/dist/dom/customEvents.d.ts.map +0 -1
  65. package/dist/dom/customEvents.js +0 -34
  66. package/dist/dom/customEvents.js.map +0 -1
  67. package/dist/dom/enableChildrenFocus.d.ts +0 -18
  68. package/dist/dom/enableChildrenFocus.d.ts.map +0 -1
  69. package/dist/dom/enableChildrenFocus.js +0 -26
  70. package/dist/dom/enableChildrenFocus.js.map +0 -1
  71. package/dist/dom/findOffsetRelativeToScrollParent.d.ts +0 -7
  72. package/dist/dom/findOffsetRelativeToScrollParent.d.ts.map +0 -1
  73. package/dist/dom/findOffsetRelativeToScrollParent.js +0 -19
  74. package/dist/dom/findOffsetRelativeToScrollParent.js.map +0 -1
  75. package/dist/dom/findScrollContainer.d.ts +0 -8
  76. package/dist/dom/findScrollContainer.d.ts.map +0 -1
  77. package/dist/dom/findScrollContainer.js +0 -9
  78. package/dist/dom/findScrollContainer.js.map +0 -1
  79. package/dist/dom/getFocusSelector.d.ts +0 -25
  80. package/dist/dom/getFocusSelector.d.ts.map +0 -1
  81. package/dist/dom/getFocusSelector.js +0 -30
  82. package/dist/dom/getFocusSelector.js.map +0 -1
  83. package/dist/dom/getSpecificParent.d.ts +0 -23
  84. package/dist/dom/getSpecificParent.d.ts.map +0 -1
  85. package/dist/dom/getSpecificParent.js +0 -19
  86. package/dist/dom/getSpecificParent.js.map +0 -1
  87. package/dist/dom/isChild.d.ts +0 -13
  88. package/dist/dom/isChild.d.ts.map +0 -1
  89. package/dist/dom/isChild.js +0 -8
  90. package/dist/dom/isChild.js.map +0 -1
  91. package/dist/dom/scrollParentIntoElement.d.ts +0 -9
  92. package/dist/dom/scrollParentIntoElement.d.ts.map +0 -1
  93. package/dist/dom/scrollParentIntoElement.js +0 -24
  94. package/dist/dom/scrollParentIntoElement.js.map +0 -1
  95. package/dist/dom/url.d.ts +0 -18
  96. package/dist/dom/url.d.ts.map +0 -1
  97. package/dist/dom/url.js +0 -52
  98. package/dist/dom/url.js.map +0 -1
  99. package/dist/dom/usePanAndZoom.d.ts +0 -14
  100. package/dist/dom/usePanAndZoom.d.ts.map +0 -1
  101. package/dist/dom/usePanAndZoom.js +0 -111
  102. package/dist/dom/usePanAndZoom.js.map +0 -1
  103. package/dist/encoding/index.d.ts +0 -8
  104. package/dist/encoding/index.d.ts.map +0 -1
  105. package/dist/encoding/index.js +0 -12
  106. package/dist/encoding/index.js.map +0 -1
  107. package/dist/events/BouncingEmitter.d.ts +0 -67
  108. package/dist/events/BouncingEmitter.d.ts.map +0 -1
  109. package/dist/events/BouncingEmitter.js +0 -72
  110. package/dist/events/BouncingEmitter.js.map +0 -1
  111. package/dist/events/EventEmitter.d.ts +0 -47
  112. package/dist/events/EventEmitter.d.ts.map +0 -1
  113. package/dist/events/EventEmitter.js +0 -75
  114. package/dist/events/EventEmitter.js.map +0 -1
  115. package/dist/events/StatefulEmitter.d.ts +0 -44
  116. package/dist/events/StatefulEmitter.d.ts.map +0 -1
  117. package/dist/events/StatefulEmitter.js +0 -57
  118. package/dist/events/StatefulEmitter.js.map +0 -1
  119. package/dist/events/types.d.ts +0 -29
  120. package/dist/events/types.d.ts.map +0 -1
  121. package/dist/focus/focusController.d.ts +0 -108
  122. package/dist/focus/focusController.d.ts.map +0 -1
  123. package/dist/focus/focusController.js +0 -295
  124. package/dist/focus/focusController.js.map +0 -1
  125. package/dist/focus/globalFocus.d.ts +0 -24
  126. package/dist/focus/globalFocus.d.ts.map +0 -1
  127. package/dist/focus/globalFocus.js +0 -87
  128. package/dist/focus/globalFocus.js.map +0 -1
  129. package/dist/history/History.d.ts +0 -81
  130. package/dist/history/History.d.ts.map +0 -1
  131. package/dist/history/History.js +0 -122
  132. package/dist/history/History.js.map +0 -1
  133. package/dist/hooks/useCombinedRefs.d.ts +0 -18
  134. package/dist/hooks/useCombinedRefs.d.ts.map +0 -1
  135. package/dist/hooks/useCombinedRefs.js +0 -20
  136. package/dist/hooks/useCombinedRefs.js.map +0 -1
  137. package/dist/hooks/useDebouncedCallback.d.ts +0 -7
  138. package/dist/hooks/useDebouncedCallback.d.ts.map +0 -1
  139. package/dist/hooks/useDebouncedCallback.js +0 -21
  140. package/dist/hooks/useDebouncedCallback.js.map +0 -1
  141. package/dist/hooks/useLatest.d.ts +0 -13
  142. package/dist/hooks/useLatest.d.ts.map +0 -1
  143. package/dist/hooks/useLatest.js +0 -10
  144. package/dist/hooks/useLatest.js.map +0 -1
  145. package/dist/hooks/useMount.d.ts +0 -6
  146. package/dist/hooks/useMount.d.ts.map +0 -1
  147. package/dist/hooks/useMount.js +0 -14
  148. package/dist/hooks/useMount.js.map +0 -1
  149. package/dist/hooks/usePrevious.d.ts +0 -6
  150. package/dist/hooks/usePrevious.d.ts.map +0 -1
  151. package/dist/hooks/usePrevious.js +0 -12
  152. package/dist/hooks/usePrevious.js.map +0 -1
  153. package/dist/hooks/useShallowMemo.d.ts +0 -9
  154. package/dist/hooks/useShallowMemo.d.ts.map +0 -1
  155. package/dist/hooks/useShallowMemo.js +0 -42
  156. package/dist/hooks/useShallowMemo.js.map +0 -1
  157. package/dist/hooks/useStateRef.d.ts +0 -10
  158. package/dist/hooks/useStateRef.d.ts.map +0 -1
  159. package/dist/hooks/useStateRef.js +0 -11
  160. package/dist/hooks/useStateRef.js.map +0 -1
  161. package/dist/hooks/useSubscription.d.ts +0 -31
  162. package/dist/hooks/useSubscription.d.ts.map +0 -1
  163. package/dist/hooks/useSubscription.js +0 -21
  164. package/dist/hooks/useSubscription.js.map +0 -1
  165. package/dist/hooks/useUnmount.d.ts +0 -4
  166. package/dist/hooks/useUnmount.d.ts.map +0 -1
  167. package/dist/hooks/useUnmount.js +0 -10
  168. package/dist/hooks/useUnmount.js.map +0 -1
  169. package/dist/hooks/useUpdateEffect.d.ts +0 -10
  170. package/dist/hooks/useUpdateEffect.d.ts.map +0 -1
  171. package/dist/hooks/useUpdateEffect.js +0 -16
  172. package/dist/hooks/useUpdateEffect.js.map +0 -1
  173. package/dist/imperative/makeImperativeComponent.d.ts +0 -56
  174. package/dist/imperative/makeImperativeComponent.d.ts.map +0 -1
  175. package/dist/imperative/makeImperativeComponent.js +0 -43
  176. package/dist/imperative/makeImperativeComponent.js.map +0 -1
  177. package/dist/imperative/makeSingleImperativeComponent.d.ts +0 -15
  178. package/dist/imperative/makeSingleImperativeComponent.d.ts.map +0 -1
  179. package/dist/imperative/makeSingleImperativeComponent.js +0 -31
  180. package/dist/imperative/makeSingleImperativeComponent.js.map +0 -1
  181. package/dist/imperative/types.d.ts +0 -22
  182. package/dist/imperative/types.d.ts.map +0 -1
  183. package/dist/imperative/types.js +0 -8
  184. package/dist/imperative/types.js.map +0 -1
  185. package/dist/imperative/useImperativeComponentEvents.d.ts +0 -6
  186. package/dist/imperative/useImperativeComponentEvents.d.ts.map +0 -1
  187. package/dist/imperative/useImperativeComponentEvents.js +0 -35
  188. package/dist/imperative/useImperativeComponentEvents.js.map +0 -1
  189. package/dist/imperative/useImperativeIdentifierContext.d.ts +0 -14
  190. package/dist/imperative/useImperativeIdentifierContext.d.ts.map +0 -1
  191. package/dist/imperative/useImperativeIdentifierContext.js +0 -10
  192. package/dist/imperative/useImperativeIdentifierContext.js.map +0 -1
  193. package/dist/labels/formatMessage.d.ts +0 -19
  194. package/dist/labels/formatMessage.d.ts.map +0 -1
  195. package/dist/labels/formatMessage.js +0 -13
  196. package/dist/labels/formatMessage.js.map +0 -1
  197. package/dist/labels/getLabel.d.ts +0 -34
  198. package/dist/labels/getLabel.d.ts.map +0 -1
  199. package/dist/labels/getLabel.js +0 -18
  200. package/dist/labels/getLabel.js.map +0 -1
  201. package/dist/number/index.d.ts +0 -29
  202. package/dist/number/index.d.ts.map +0 -1
  203. package/dist/number/index.js +0 -43
  204. package/dist/number/index.js.map +0 -1
  205. package/dist/objects/getValueByPath.d.ts +0 -23
  206. package/dist/objects/getValueByPath.d.ts.map +0 -1
  207. package/dist/objects/getValueByPath.js +0 -19
  208. package/dist/objects/getValueByPath.js.map +0 -1
  209. package/dist/objects/setValueByPath.d.ts +0 -33
  210. package/dist/objects/setValueByPath.d.ts.map +0 -1
  211. package/dist/objects/setValueByPath.js +0 -35
  212. package/dist/objects/setValueByPath.js.map +0 -1
  213. package/dist/propsStore/propsStore.d.ts +0 -42
  214. package/dist/propsStore/propsStore.d.ts.map +0 -1
  215. package/dist/propsStore/propsStore.js +0 -157
  216. package/dist/propsStore/propsStore.js.map +0 -1
  217. package/dist/propsStore/types.d.ts +0 -24
  218. package/dist/propsStore/types.d.ts.map +0 -1
  219. package/dist/propsStore/usePropsSelector.d.ts +0 -67
  220. package/dist/propsStore/usePropsSelector.d.ts.map +0 -1
  221. package/dist/propsStore/usePropsSelector.js +0 -92
  222. package/dist/propsStore/usePropsSelector.js.map +0 -1
  223. package/dist/screenLock/screenLocker.d.ts +0 -60
  224. package/dist/screenLock/screenLocker.d.ts.map +0 -1
  225. package/dist/screenLock/screenLocker.js +0 -95
  226. package/dist/screenLock/screenLocker.js.map +0 -1
  227. package/dist/states/useDebouncedState.d.ts +0 -10
  228. package/dist/states/useDebouncedState.d.ts.map +0 -1
  229. package/dist/states/useDebouncedState.js +0 -22
  230. package/dist/states/useDebouncedState.js.map +0 -1
  231. package/dist/states/useDomState.d.ts +0 -86
  232. package/dist/states/useDomState.d.ts.map +0 -1
  233. package/dist/states/useDomState.js +0 -35
  234. package/dist/states/useDomState.js.map +0 -1
  235. package/dist/storage/StatefulStore.d.ts +0 -205
  236. package/dist/storage/StatefulStore.d.ts.map +0 -1
  237. package/dist/storage/StatefulStore.js +0 -301
  238. package/dist/storage/StatefulStore.js.map +0 -1
  239. package/dist/storage/persistentStorage.d.ts +0 -12
  240. package/dist/storage/persistentStorage.d.ts.map +0 -1
  241. package/dist/storage/persistentStorage.js +0 -28
  242. package/dist/storage/persistentStorage.js.map +0 -1
  243. package/dist/storage/useLocalStorage.d.ts +0 -7
  244. package/dist/storage/useLocalStorage.d.ts.map +0 -1
  245. package/dist/storage/useLocalStorage.js +0 -40
  246. package/dist/storage/useLocalStorage.js.map +0 -1
  247. package/dist/string/alignment.d.ts +0 -25
  248. package/dist/string/alignment.d.ts.map +0 -1
  249. package/dist/string/alignment.js +0 -26
  250. package/dist/string/alignment.js.map +0 -1
  251. package/dist/string/ucfirst.d.ts +0 -4
  252. package/dist/string/ucfirst.d.ts.map +0 -1
  253. package/dist/string/ucfirst.js +0 -6
  254. package/dist/string/ucfirst.js.map +0 -1
  255. package/dist/typeGuards/toBoolean.d.ts +0 -26
  256. package/dist/typeGuards/toBoolean.d.ts.map +0 -1
  257. package/dist/typeGuards/toBoolean.js +0 -11
  258. package/dist/typeGuards/toBoolean.js.map +0 -1
  259. package/dist/types/apia/common.d.ts +0 -114
  260. package/dist/types/apia/common.d.ts.map +0 -1
  261. package/dist/types/apia/date.d.ts +0 -4
  262. package/dist/types/apia/date.d.ts.map +0 -1
  263. package/dist/types/apia/forms.d.ts +0 -221
  264. package/dist/types/apia/forms.d.ts.map +0 -1
  265. package/dist/types/misc.d.ts +0 -9
  266. package/dist/types/misc.d.ts.map +0 -1
  267. package/dist/xml/parseXmlAsync.d.ts +0 -4
  268. package/dist/xml/parseXmlAsync.d.ts.map +0 -1
  269. package/dist/xml/parseXmlAsync.js +0 -58
  270. package/dist/xml/parseXmlAsync.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,63 +1,2651 @@
1
- export { animate } from './animate/index.js';
2
- export { decodeHTMLEntities } from './encoding/index.js';
3
- export { addBoundary, noNaN, parseAsSize } from './number/index.js';
4
- export { default as arrayOrArray } from './array/arrayOrArray.js';
5
- export { default as makeImperativeComponent } from './imperative/makeImperativeComponent.js';
6
- export { default as makeSingleImperativeComponent } from './imperative/makeSingleImperativeComponent.js';
7
- export { default as useImperativeComponentContext } from './imperative/useImperativeIdentifierContext.js';
8
- export { getIndex } from './array/getIndex.js';
9
- export { decrypt } from './crypto/decrypt.js';
10
- export { encrypt } from './crypto/encrypt.js';
11
- export { apiaDateToStandarFormat } from './date/apiaDateToStandarFormat.js';
12
- export { dateToApiaFormat } from './date/dateToApiaFormat.js';
13
- export { getDateFormat } from './date/getDateFormat.js';
14
- export { debugDispatcher, enableDebugDispatcher, isDebugDispatcherEnabled } from './debug/debugDispatcher.js';
15
- export { shortcutController } from './debug/shortcutController.js';
16
- export { downloadStringAsDoc } from './documents/downloadStringAsDoc.js';
17
- export { defaultGetNameFromResponse, downloadUrl } from './documents/downloadUrl.js';
18
- export { openAndReadFile } from './documents/openAndReadFile.js';
19
- export { customEvents } from './dom/customEvents.js';
20
- export { cantFocusSelector, focusSelector, getFocusSelector } from './dom/getFocusSelector.js';
21
- export { getSpecificParent } from './dom/getSpecificParent.js';
22
- export { isChild } from './dom/isChild.js';
23
- export { Url } from './dom/url.js';
24
- export { disableChildrenFocus, enableChildrenFocus } from './dom/enableChildrenFocus.js';
25
- export { autoDisconnectMutationObserver } from './dom/autoDisconnectMutationObserver.js';
26
- export { findOffsetRelativeToScrollParent } from './dom/findOffsetRelativeToScrollParent.js';
27
- export { findScrollContainer } from './dom/findScrollContainer.js';
28
- export { scrollParentIntoElement } from './dom/scrollParentIntoElement.js';
29
- export { usePanAndZoom } from './dom/usePanAndZoom.js';
30
- export { BouncingEmitter } from './events/BouncingEmitter.js';
31
- export { EventEmitter } from './events/EventEmitter.js';
32
- export { StatefulEmitter, isSetter } from './events/StatefulEmitter.js';
33
- export { focus, notificationsSelector } from './focus/focusController.js';
34
- export { globalFocus } from './focus/globalFocus.js';
35
- export { History } from './history/History.js';
36
- export { useCombinedRefs } from './hooks/useCombinedRefs.js';
37
- export { useDebouncedCallback } from './hooks/useDebouncedCallback.js';
38
- export { useLatest } from './hooks/useLatest.js';
39
- export { useMount } from './hooks/useMount.js';
40
- export { useUnmount } from './hooks/useUnmount.js';
41
- export { usePrevious } from './hooks/usePrevious.js';
42
- export { useStateRef } from './hooks/useStateRef.js';
43
- export { useSubscription } from './hooks/useSubscription.js';
44
- export { useUpdateEffect } from './hooks/useUpdateEffect.js';
45
- export { shallowCompareArrays, shallowEqual, useShallowMemo } from './hooks/useShallowMemo.js';
46
- export { default as useImperativeComponentEvents } from './imperative/useImperativeComponentEvents.js';
47
- export { getLabel } from './labels/getLabel.js';
48
- export { formatMessage } from './labels/formatMessage.js';
49
- export { getValueByPath } from './objects/getValueByPath.js';
50
- export { setValueByPath } from './objects/setValueByPath.js';
51
- export { PropsSelectorUndefinedObject, PropsStore, propsStore } from './propsStore/propsStore.js';
52
- export { isPropsConfigurationObject, usePropsSelector } from './propsStore/usePropsSelector.js';
53
- export { useDomState } from './states/useDomState.js';
54
- export { useDebouncedState } from './states/useDebouncedState.js';
55
- export { screenLocker } from './screenLock/screenLocker.js';
56
- export { default as persistentStorage } from './storage/persistentStorage.js';
57
- export { useLocalStorage } from './storage/useLocalStorage.js';
58
- export { BasicStoredElement, makeStatefulStore } from './storage/StatefulStore.js';
59
- export { alignment } from './string/alignment.js';
60
- export { ucfirst } from './string/ucfirst.js';
61
- export { toBoolean } from './typeGuards/toBoolean.js';
62
- export { parseXmlAsync } from './xml/parseXmlAsync.js';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import React__default, { useRef, useCallback, useState, useEffect, useMemo, createContext, useContext } from 'react';
4
+ import uniqueId from 'lodash-es/uniqueId';
5
+ import isFunction from 'lodash-es/isFunction';
6
+ import dayjs from 'dayjs';
7
+ import customParseFormat from 'dayjs/plugin/customParseFormat';
8
+ import clone from 'lodash-es/clone';
9
+ import cloneDeep from 'lodash-es/cloneDeep';
10
+ import xml2js from 'xml2js';
11
+ import { parseBooleans, parseNumbers } from 'xml2js/lib/processors';
12
+
13
+ function addBoundary(definition, min, max, loop) {
14
+ const actualNumber = typeof definition === "number" ? definition : definition.number;
15
+ const actualMin = typeof definition === "number" ? min : definition.min;
16
+ const actualMax = typeof definition === "number" ? max : definition.max;
17
+ const isActualLoop = typeof definition === "number" ? loop : definition.loop;
18
+ let newNumber = Number(actualNumber ?? 0);
19
+ if (actualMin !== void 0 && newNumber < actualMin) {
20
+ if (actualMax !== void 0 && isActualLoop) {
21
+ newNumber = actualMax;
22
+ } else {
23
+ newNumber = actualMin;
24
+ }
25
+ }
26
+ if (actualMax !== void 0 && newNumber > actualMax) {
27
+ if (actualMin !== void 0 && isActualLoop) {
28
+ newNumber = actualMin;
29
+ } else {
30
+ newNumber = actualMax;
31
+ }
32
+ }
33
+ return newNumber;
34
+ }
35
+ const sizeUnits = ["b", "kb", "mb", "gb", "tb"];
36
+ function parseAsSize(num) {
37
+ let index = 0;
38
+ let finalSize = num;
39
+ if (finalSize === Infinity)
40
+ return "1000GB";
41
+ while (finalSize > 1024) {
42
+ finalSize /= 1024;
43
+ index++;
44
+ }
45
+ return `${Math.round(finalSize * 10) / 10}${sizeUnits[index]}`;
46
+ }
47
+ function noNaN(number, defaultReturn = 0) {
48
+ const returnNumber = Number(number);
49
+ if (number === null || Number.isNaN(returnNumber))
50
+ return defaultReturn;
51
+ return returnNumber;
52
+ }
53
+
54
+ function animate(duration, callback, onFinish) {
55
+ let initialTime = void 0;
56
+ let suscription;
57
+ function innerAnimate(current) {
58
+ if (initialTime === void 0)
59
+ initialTime = current;
60
+ const ellapsed = current - initialTime;
61
+ const progress = ellapsed / duration;
62
+ callback(addBoundary(progress, 0, 1));
63
+ if (progress < 1)
64
+ suscription = window.requestAnimationFrame(innerAnimate);
65
+ else
66
+ onFinish?.();
67
+ }
68
+ suscription = window.requestAnimationFrame(innerAnimate);
69
+ return () => {
70
+ window.cancelAnimationFrame(suscription);
71
+ };
72
+ }
73
+
74
+ function arrayOrArray(o) {
75
+ if (o === void 0)
76
+ return [];
77
+ return Array.isArray(o) ? o : [o];
78
+ }
79
+
80
+ function getIndex(arr, conditions, defaultIndex) {
81
+ for (let i = 0; i < conditions.length; i++) {
82
+ if (typeof conditions[i] === "boolean" && conditions[i] || isFunction(conditions[i]) && conditions[i]())
83
+ return arr[i];
84
+ }
85
+ return arr[defaultIndex ?? -1];
86
+ }
87
+
88
+ const generateKey = async (salt, passPhrase, keySize, iterationCount) => {
89
+ const CryptoJS = (await import('crypto-js')).default;
90
+ const key = CryptoJS.PBKDF2(passPhrase, CryptoJS.enc.Hex.parse(salt), {
91
+ keySize: keySize / 32,
92
+ iterations: iterationCount
93
+ });
94
+ return key;
95
+ };
96
+
97
+ const decrypt = async (salt, iv, passPhrase, cipherText, keySize, iterationCount) => {
98
+ const CryptoJS = (await import('crypto-js')).default;
99
+ const key = await generateKey(salt, passPhrase, keySize, iterationCount);
100
+ const cipherParams = CryptoJS.lib.CipherParams.create({
101
+ ciphertext: CryptoJS.enc.Base64.parse(cipherText)
102
+ });
103
+ const decrypted = CryptoJS.AES.decrypt(cipherParams, key, {
104
+ iv: CryptoJS.enc.Hex.parse(iv)
105
+ });
106
+ return decrypted.toString(CryptoJS.enc.Utf8);
107
+ };
108
+
109
+ const encrypt = async (salt, iv, passPhrase, plainText, keySize, iterationCount) => {
110
+ const CryptoJS = (await import('crypto-js')).default;
111
+ const key = await generateKey(salt, passPhrase, keySize, iterationCount);
112
+ const encrypted = CryptoJS.AES.encrypt(plainText, key, {
113
+ iv: CryptoJS.enc.Hex.parse(iv)
114
+ });
115
+ return encrypted.ciphertext.toString(CryptoJS.enc.Base64);
116
+ };
117
+
118
+ dayjs.extend(customParseFormat);
119
+ const DEFAULT_DATE_FORMAT = "DD/MM/YYYY";
120
+ const getDateFormat = () => {
121
+ switch (window.DATE_FORMAT) {
122
+ case "m/d/Y":
123
+ return "MM/DD/YYYY";
124
+ case "d/m/Y":
125
+ return DEFAULT_DATE_FORMAT;
126
+ case "Y/m/d":
127
+ return "YYYY/MM/DD";
128
+ default:
129
+ return "DD/MM/YYYY";
130
+ }
131
+ };
132
+
133
+ function apiaDateToStandarFormat(date) {
134
+ const newDate = dayjs(date, getDateFormat());
135
+ if (!newDate.isValid())
136
+ return "";
137
+ return newDate.format("YYYY-MM-DD");
138
+ }
139
+
140
+ function dateToApiaFormat(date) {
141
+ return dayjs(date).format(getDateFormat());
142
+ }
143
+
144
+ const isEnabled = WP_DEVELOP_MODE;
145
+ function isDebugDispatcherEnabled() {
146
+ return isEnabled;
147
+ }
148
+ const debugDispatcher = new class DDispatcher {
149
+ constructor() {
150
+ this.callbacks = {};
151
+ this.actions = {
152
+ shout: () => {
153
+ console.log(Object.keys(this.callbacks));
154
+ }
155
+ };
156
+ this.emit = (action, ...parameters) => {
157
+ try {
158
+ if (this.actions[action])
159
+ this.actions[action]();
160
+ else {
161
+ if ((this.callbacks[action] ?? []).length === 1)
162
+ return this.callbacks[action]?.[0]?.(parameters);
163
+ (this.callbacks[action] ?? []).forEach((cb) => {
164
+ return cb(parameters);
165
+ });
166
+ }
167
+ return null;
168
+ } catch (e) {
169
+ console.error("DD", e);
170
+ }
171
+ };
172
+ }
173
+ on(action, cb, help, onlyDevelop = false) {
174
+ if (!isEnabled && onlyDevelop)
175
+ return () => {
176
+ };
177
+ if (Object.keys(this.actions).includes(action))
178
+ throw new Error(
179
+ `The action ${action} is a reserved word for the dispatcher.`
180
+ );
181
+ if (!this.callbacks[action])
182
+ this.callbacks[action] = [];
183
+ const actionMethod = Object.assign(cb, {
184
+ help: () => {
185
+ if (typeof help === "string")
186
+ console.info(help);
187
+ }
188
+ });
189
+ this.callbacks[action].push(actionMethod);
190
+ this[action] = Object.assign(
191
+ (...props) => {
192
+ this.emit(action, ...props);
193
+ },
194
+ {
195
+ help: () => {
196
+ if (typeof help === "string")
197
+ console.info(help);
198
+ }
199
+ }
200
+ );
201
+ return () => {
202
+ this.off(action, cb);
203
+ };
204
+ }
205
+ off(action, cb) {
206
+ this.callbacks[action] = this.callbacks[action].filter((current) => {
207
+ return current !== cb;
208
+ });
209
+ }
210
+ }();
211
+ window.dd = debugDispatcher;
212
+ window.adt = debugDispatcher;
213
+
214
+ const shortcutController = new class ShortcutController {
215
+ constructor() {
216
+ this.history = [];
217
+ this.candidates = [];
218
+ this.shortcuts = {
219
+ callbacks: [],
220
+ children: [],
221
+ key: { key: "" }
222
+ };
223
+ this.shortcutsStrings = [];
224
+ this.categories = {
225
+ dev: ["shift&D"]
226
+ };
227
+ document.addEventListener("keydown", (ev) => {
228
+ if (ev.key?.length !== 1 && ev.key !== "Escape")
229
+ return;
230
+ this.candidates = [
231
+ ...this.candidates.reduce(
232
+ (accumulated, current) => [
233
+ ...accumulated,
234
+ ...current.children.filter(
235
+ (child) => child.key.key === ev.key && child.key.altKey === ev.altKey && child.key.ctrlKey === ev.ctrlKey && child.key.shiftKey === ev.shiftKey
236
+ )
237
+ ],
238
+ []
239
+ ),
240
+ ...this.shortcuts.children.filter(
241
+ (current) => current.key.key === ev.key && current.key.altKey === ev.altKey && current.key.ctrlKey === ev.ctrlKey && current.key.shiftKey === ev.shiftKey
242
+ )
243
+ ];
244
+ this.candidates.forEach((current) => {
245
+ if (current.fireEvenFromInputs || !(!ev.key || ev.key.length > 1 || ["input", "textarea", "select"].includes(
246
+ ev.target.tagName?.toLowerCase()
247
+ ))) {
248
+ if (current.callbacks)
249
+ current.callbacks.forEach((cb) => cb(ev));
250
+ }
251
+ });
252
+ });
253
+ debugDispatcher.on(
254
+ "shortcuts",
255
+ () => {
256
+ console.info(this.shortcutsStrings);
257
+ console.info(this.shortcuts, this.history);
258
+ },
259
+ "Muestra los shortcuts registrados"
260
+ );
261
+ this.on(
262
+ "short".split(""),
263
+ () => {
264
+ this.shortcutsStrings.forEach((shortcut) => console.info(shortcut));
265
+ },
266
+ "dev"
267
+ );
268
+ }
269
+ parseKeyToString(key) {
270
+ if (typeof key === "string")
271
+ return key;
272
+ return `${key.altKey ? "alt&" : ""}${key.ctrlKey ? "ctrl&" : ""}${key.shiftKey ? "shift&" : ""}${key.key}`;
273
+ }
274
+ parseKey(keyString) {
275
+ const elements = keyString.split("&");
276
+ const altKey = elements.includes("alt");
277
+ const ctrlKey = elements.includes("ctrl");
278
+ const shiftKey = elements.includes("shift");
279
+ const key = elements.find(
280
+ (current) => current !== "shift" && current !== "alt" && current !== "ctrl"
281
+ );
282
+ if (!key)
283
+ throw new Error(`parseKey "${keyString}" does not have key.`);
284
+ return {
285
+ key,
286
+ altKey,
287
+ ctrlKey,
288
+ shiftKey
289
+ };
290
+ }
291
+ /**
292
+ * Para setear un shorcut se puede pasar un string representativo con la
293
+ * forma:
294
+ *
295
+ * **alt**?&**ctrl**?&**shift**?&**(\w)**
296
+ *
297
+ * Donde: alt? ctrl? shift? implica que cualquiera de esas palabras pueden o
298
+ * no aparecer y (\w) es una letra, símbolo o número.
299
+ *
300
+ * Puede aparecer cualquier tecla de control o no, pero el símbolo o letra
301
+ * debe aparecer.
302
+ *
303
+ * @param category
304
+ * Agrega un prefijo de teclas que se deben presionar antes del shortcut para
305
+ * que funcione, de forma que por ejemplo, todos los shortcuts de la categoría
306
+ * dev serán ejecutados solamente si antes se presionó shift&D
307
+ *
308
+ * @example
309
+ *
310
+ shortcutController.on(['shift&A', 'b', 'ctrl&c', 'alt&d'], (ev) => {
311
+ ev.preventDefault();
312
+ console.log('Abctrl+cd'),
313
+ }); // Este shortcut se ejecuta en desarrollo y producción
314
+
315
+ shortcutController.on('unshortcut'.split(''), (ev) => {
316
+ ev.preventDefault();
317
+ console.log('Abctrl+cd'),
318
+ }, 'dev'); // Este shortcut solo se ejecuta en desarrollo
319
+ */
320
+ on(keys, callback, category, fireEvenFromInputs) {
321
+ if (category === "dev" && !isDebugDispatcherEnabled())
322
+ return;
323
+ let container = this.shortcuts;
324
+ const actualKeys = category ? [...this.categories[category], ...keys] : keys;
325
+ if (this.shortcutsStrings.includes(
326
+ actualKeys.map((current) => this.parseKeyToString(current)).join("")
327
+ )) {
328
+ console.warn(
329
+ `The shortcut ${actualKeys.map((current) => this.parseKeyToString(current)).join(
330
+ ""
331
+ )} is being setted twice. The controller wont register more than one instance but this could be a hint if some unexpected behavior.`
332
+ );
333
+ return;
334
+ }
335
+ for (const key of actualKeys) {
336
+ const actualKey = typeof key === "string" ? this.parseKey(key) : key;
337
+ if (actualKey.key === "")
338
+ throw new Error(`Empty key ('') is not allowed`);
339
+ const keyContainer = container.children.find(
340
+ (current) => current.key.key === actualKey.key || current.key.key === "" && current.key.altKey === actualKey.altKey && current.key.ctrlKey === actualKey.ctrlKey && current.key.shiftKey === actualKey.shiftKey && current.fireEvenFromInputs === fireEvenFromInputs
341
+ );
342
+ if (keyContainer)
343
+ container = keyContainer;
344
+ else {
345
+ const newContainer = {
346
+ callbacks: [],
347
+ children: [],
348
+ key: actualKey,
349
+ fireEvenFromInputs
350
+ };
351
+ container.children.push(newContainer);
352
+ container = newContainer;
353
+ }
354
+ }
355
+ this.shortcutsStrings.push(
356
+ actualKeys.map((current) => this.parseKeyToString(current)).join("")
357
+ );
358
+ container.callbacks.push(callback);
359
+ }
360
+ }();
361
+
362
+ async function downloadStringAsDoc(content, options) {
363
+ (await import('file-saver')).default.saveAs(
364
+ new Blob([content], {
365
+ type: "text/plain; charset=utf-8",
366
+ ...options?.blobProps
367
+ }),
368
+ options?.fileName
369
+ );
370
+ }
371
+
372
+ function defaultGetNameFromResponse(blob) {
373
+ return blob.headers["content-disposition"]?.match?.(
374
+ /filename=(?:\\?")?([\w,\s-() ]+(?:\.[A-Za-z]+)?)(?:\\?")?;?/
375
+ )?.[1] ?? "noFileName";
376
+ }
377
+ async function downloadUrl(url, secondParameter = defaultGetNameFromResponse) {
378
+ const blob = await (await import('axios')).default.get(url, {
379
+ responseType: "blob"
380
+ });
381
+ const actualFileName = typeof secondParameter === "string" ? secondParameter : secondParameter(blob);
382
+ (await import('file-saver')).default.saveAs(
383
+ new Blob([blob.data]),
384
+ actualFileName
385
+ );
386
+ }
387
+
388
+ function openAndReadFile() {
389
+ return new Promise((resolve) => {
390
+ const input = document.createElement("input");
391
+ input.type = "file";
392
+ input.style.display = "none";
393
+ document.body.append(input);
394
+ input.click();
395
+ input.addEventListener("change", (ev) => {
396
+ const fileInput = ev.target;
397
+ const file = fileInput?.files?.[0];
398
+ if (file) {
399
+ const reader = new FileReader();
400
+ reader.onload = (event) => {
401
+ fileInput.value = "";
402
+ const content = event.target?.result;
403
+ if (content) {
404
+ resolve(content);
405
+ }
406
+ };
407
+ reader.readAsText(file);
408
+ } else {
409
+ resolve(null);
410
+ }
411
+ });
412
+ });
413
+ }
414
+
415
+ function autoDisconnectMutationObserver(element, callback, conf) {
416
+ let timeoutRegister = -1;
417
+ let isConnected = false;
418
+ function disconnect() {
419
+ if (isConnected) {
420
+ isConnected = false;
421
+ observer.disconnect();
422
+ clearTimeout(timeoutRegister);
423
+ }
424
+ }
425
+ let shoutCallback;
426
+ const observer = new MutationObserver((...props) => {
427
+ if (props[0]?.[0] && (props[0][0].removedNodes || props[0][0].addedNodes)) {
428
+ clearTimeout(shoutCallback);
429
+ shoutCallback = setTimeout(callback, 100);
430
+ clearTimeout(timeoutRegister);
431
+ timeoutRegister = setTimeout(
432
+ disconnect,
433
+ conf?.timeout ?? 100
434
+ );
435
+ }
436
+ });
437
+ isConnected = true;
438
+ observer.observe(element, { subtree: true, childList: true });
439
+ timeoutRegister = setTimeout(
440
+ disconnect,
441
+ conf?.timeout ?? 100
442
+ );
443
+ if (conf?.runCallbackOnInit !== false)
444
+ shoutCallback = setTimeout(callback, 100);
445
+ return disconnect;
446
+ }
447
+
448
+ const REGEXP_SCROLL_PARENT = /^(visible|hidden)/;
449
+ function findScrollContainer(el) {
450
+ return !(el instanceof HTMLElement) || typeof window.getComputedStyle !== "function" ? null : el.scrollHeight >= el.clientHeight && !REGEXP_SCROLL_PARENT.test(
451
+ window.getComputedStyle(el).overflowY || "visible"
452
+ ) ? el : findScrollContainer(el.parentElement) || document.body;
453
+ }
454
+
455
+ function findOffsetRelativeToScrollParent(element, which = "Top") {
456
+ const scrollParent = findScrollContainer(element);
457
+ let currentElement = element;
458
+ let offset = 0;
459
+ let offsetParent = currentElement;
460
+ while (currentElement && currentElement !== scrollParent && currentElement !== document.body && offsetParent !== scrollParent) {
461
+ if (offsetParent !== currentElement.offsetParent) {
462
+ offset += currentElement[`offset${which}`];
463
+ offsetParent = currentElement.offsetParent;
464
+ }
465
+ currentElement = currentElement.parentElement;
466
+ }
467
+ return offset;
468
+ }
469
+
470
+ const scrollIntervals = {};
471
+ function scrollParentIntoElement(element, fixedOffsetTop = 0, tries = 2, timeout = 100, scrollId = void 0) {
472
+ if (scrollId) {
473
+ clearTimeout(scrollIntervals[scrollId]);
474
+ }
475
+ const scrollParent = findScrollContainer(element);
476
+ const offsetTop = findOffsetRelativeToScrollParent(element);
477
+ if (scrollParent && (scrollParent.scrollTop + fixedOffsetTop > offsetTop || (scrollParent?.clientHeight ?? Infinity) - fixedOffsetTop < element.getBoundingClientRect().height)) {
478
+ scrollParent.scrollTop = offsetTop - fixedOffsetTop;
479
+ } else if (scrollParent && scrollParent.scrollTop + scrollParent.clientHeight < offsetTop + element.getBoundingClientRect().height) {
480
+ scrollParent.scrollTop = offsetTop;
481
+ }
482
+ if (tries > 0)
483
+ scrollIntervals[scrollId ?? "noId"] = setTimeout(
484
+ () => scrollParentIntoElement(element, fixedOffsetTop, tries - 1, timeout),
485
+ timeout
486
+ );
487
+ }
488
+
489
+ function usePanAndZoom(effectiveMargin = { left: 0, bottom: 0, right: 0, top: 0 }, blockZoom = true) {
490
+ const boxRef = useRef(null);
491
+ const elementRef = useRef(null);
492
+ const [isPanning, setIsPanning] = React__default.useState(false);
493
+ const [panningPosition, setPanningPosition] = React__default.useState({ x: 0, y: 0 });
494
+ React__default.useEffect(() => {
495
+ if (blockZoom)
496
+ return;
497
+ const container = boxRef.current;
498
+ const innerElement = elementRef.current;
499
+ const handlePanStart = (ev) => {
500
+ ev.preventDefault();
501
+ setIsPanning(true);
502
+ setPanningPosition({ x: ev.clientX, y: ev.clientY });
503
+ };
504
+ const handlePanEnd = (ev) => {
505
+ ev.preventDefault();
506
+ setIsPanning(false);
507
+ };
508
+ const handlePan = (ev) => {
509
+ if (!innerElement || !container) {
510
+ return;
511
+ }
512
+ if (isPanning) {
513
+ ev.preventDefault();
514
+ ev.stopPropagation();
515
+ const dx = ev.clientX - panningPosition.x;
516
+ const dy = ev.clientY - panningPosition.y;
517
+ container.scrollLeft -= dx;
518
+ container.scrollTop -= dy;
519
+ setPanningPosition({ x: ev.clientX, y: ev.clientY });
520
+ }
521
+ };
522
+ if (container) {
523
+ container.addEventListener("mousedown", handlePanStart);
524
+ container.addEventListener("mouseup", handlePanEnd);
525
+ container.addEventListener("mouseleave", handlePanEnd);
526
+ container.addEventListener("mousemove", handlePan);
527
+ return () => {
528
+ container.removeEventListener("mousedown", handlePanStart);
529
+ container.removeEventListener("mousemove", handlePan);
530
+ container.removeEventListener("mouseup", handlePanEnd);
531
+ container.removeEventListener("mouseleave", handlePanEnd);
532
+ };
533
+ }
534
+ }, [isPanning, panningPosition]);
535
+ React__default.useEffect(() => {
536
+ if (blockZoom)
537
+ return;
538
+ const container = boxRef.current;
539
+ const innerElement = elementRef.current;
540
+ let newScale = 1;
541
+ const handleZoom = (ev) => {
542
+ ev.preventDefault();
543
+ const newDelta = ev.deltaY;
544
+ const scaleIncrement = 0.1;
545
+ if (newDelta < 0) {
546
+ if (newScale + scaleIncrement >= 2) {
547
+ return;
548
+ }
549
+ newScale += scaleIncrement;
550
+ } else {
551
+ if (newScale - scaleIncrement <= 0.9) {
552
+ return;
553
+ }
554
+ newScale -= scaleIncrement;
555
+ }
556
+ if (!innerElement || !container) {
557
+ return;
558
+ }
559
+ const containerRect = container.getBoundingClientRect();
560
+ const cursorX = ev.clientX - containerRect.left - effectiveMargin.left;
561
+ const cursorY = ev.clientY - containerRect.top - effectiveMargin.top;
562
+ const cursorXFromCenter = cursorX - containerRect.width / 2;
563
+ const cursorYFromCenter = cursorY - containerRect.height / 2;
564
+ if (newScale <= 1) {
565
+ if (boxRef.current) {
566
+ boxRef.current.style.overflow = "hidden";
567
+ }
568
+ } else {
569
+ if (boxRef.current) {
570
+ boxRef.current.style.overflow = "hidden";
571
+ }
572
+ }
573
+ innerElement.style.transform = `scale(${newScale})`;
574
+ innerElement.style.transformOrigin = "0px 0px";
575
+ if (newDelta < 0) {
576
+ container.scrollLeft += cursorXFromCenter / (newScale * 2);
577
+ container.scrollTop += cursorYFromCenter / (newScale * 2);
578
+ } else {
579
+ container.scrollLeft -= cursorXFromCenter / (newScale * 2);
580
+ container.scrollTop -= cursorYFromCenter / (newScale * 2);
581
+ }
582
+ };
583
+ if (container) {
584
+ container.addEventListener("wheel", handleZoom);
585
+ return () => {
586
+ container.removeEventListener("wheel", handleZoom);
587
+ };
588
+ }
589
+ }, []);
590
+ return {
591
+ boxRef,
592
+ elementRef
593
+ };
594
+ }
595
+
596
+ const customEvents = {
597
+ /**
598
+ * Indica que un elemento necesita recibir el foco,
599
+ * de esta forma, elementos que no se están mostrando
600
+ * en pantalla (por display:none por ejemplo), pueden
601
+ * indicar a sus ancestros que deben expandirse.
602
+ */
603
+ focus: "customFocus",
604
+ /**
605
+ * Indica que debe cambiarse el título del modal
606
+ */
607
+ iframeModalChangeTitle: "iframeModalChangeTitle",
608
+ /**
609
+ * Indica que un iframe modal debe cerrarse
610
+ */
611
+ iframeModalClose: "iframeModalClose",
612
+ /**
613
+ * Indica que un iframe modal debe cerrarse
614
+ */
615
+ iframeModalNotify: "iframeModalNotify",
616
+ /**
617
+ * Indica que un modal debe cerrarse
618
+ */
619
+ modalClose: "modalClose",
620
+ /**
621
+ * Indica que el panel contenedor debe cerrarse porque
622
+ * está vacío
623
+ */
624
+ hidePanel: "hidePanel",
625
+ showPanel: "showPanel"
626
+ };
627
+
628
+ const cantFocusSelector = [
629
+ "[disabled]",
630
+ '[tabIndex="-1"]',
631
+ '[aria-hidden="true"]',
632
+ "[readonly]",
633
+ "[data-focus-guard]",
634
+ ".modal__closeButton"
635
+ ].map((current) => `:not(${current})`).join("");
636
+ const focusSelector = [
637
+ "input",
638
+ "textarea",
639
+ "select",
640
+ "a",
641
+ "button:not(.toggleAccordionElement)",
642
+ "[contenteditable]",
643
+ "[tabIndex]",
644
+ '[role="button"]'
645
+ ].map((current) => `${current}${cantFocusSelector}`).join(",");
646
+ function getFocusSelector(not) {
647
+ return `input${not ?? ""},
648
+ textarea${not ?? ""},
649
+ select${not ?? ""},
650
+ a${not ?? ""},
651
+ button:not(.toggleAccordionElement)${not ?? ""},
652
+ [contenteditable]${not ?? ""},
653
+ [tabIndex]${not ?? ""}`;
654
+ }
655
+
656
+ function getSpecificParent(element, checkParent) {
657
+ let currentElement = element;
658
+ while (element !== document.documentElement && currentElement) {
659
+ const hasFoundTheParent = checkParent(currentElement);
660
+ if (hasFoundTheParent === null)
661
+ return null;
662
+ if (hasFoundTheParent)
663
+ return currentElement;
664
+ const parent = currentElement.parentElement;
665
+ if (parent)
666
+ currentElement = parent;
667
+ else
668
+ return null;
669
+ }
670
+ return null;
671
+ }
672
+
673
+ function isChild(element, checkParent) {
674
+ return !!getSpecificParent(element, checkParent);
675
+ }
676
+
677
+ var __accessCheck$4 = (obj, member, msg) => {
678
+ if (!member.has(obj))
679
+ throw TypeError("Cannot " + msg);
680
+ };
681
+ var __privateGet$4 = (obj, member, getter) => {
682
+ __accessCheck$4(obj, member, "read from private field");
683
+ return getter ? getter.call(obj) : member.get(obj);
684
+ };
685
+ var __privateAdd$4 = (obj, member, value) => {
686
+ if (member.has(obj))
687
+ throw TypeError("Cannot add the same private member more than once");
688
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
689
+ };
690
+ var _parameters;
691
+ class Url {
692
+ constructor(baseUrl, defaultAllowMultiple = true) {
693
+ this.defaultAllowMultiple = defaultAllowMultiple;
694
+ __privateAdd$4(this, _parameters, {});
695
+ const [base, query] = baseUrl.split("?");
696
+ this.base = base;
697
+ query?.split("&").forEach((current) => {
698
+ const [name, ...value] = current.split("=");
699
+ this.addParameter(name, value.join("="));
700
+ });
701
+ }
702
+ addParameter(name, value, allowMultiple) {
703
+ if (allowMultiple === void 0 && !this.defaultAllowMultiple || allowMultiple === false)
704
+ __privateGet$4(this, _parameters)[name] = String(value);
705
+ else
706
+ __privateGet$4(this, _parameters)[name] = __privateGet$4(this, _parameters)[name] ? [...arrayOrArray(__privateGet$4(this, _parameters)[name]), String(value)] : [String(value)];
707
+ }
708
+ addParameters(parameters) {
709
+ parameters.forEach(
710
+ (current) => this.addParameter(current.name, current.value, current.allowMultiple)
711
+ );
712
+ }
713
+ getParameter(name) {
714
+ return __privateGet$4(this, _parameters)[name];
715
+ }
716
+ toString() {
717
+ const parametersArray = Object.entries(__privateGet$4(this, _parameters));
718
+ return `${this.base}${parametersArray.length > 0 ? `?${parametersArray.map(
719
+ ([name, value]) => Array.isArray(value) ? value.map((current) => `${name}=${current}`).join("&") : `${name}=${String(value)}`
720
+ ).join("&")}` : ""}`;
721
+ }
722
+ }
723
+ _parameters = new WeakMap();
724
+
725
+ const previousTabIndexLabel = "data-previous-tabindex";
726
+ function disableChildrenFocus(parent) {
727
+ const focusElement = parent.querySelectorAll(focusSelector);
728
+ focusElement.forEach((element) => {
729
+ element.setAttribute(
730
+ previousTabIndexLabel,
731
+ element.getAttribute("tabindex") ?? ""
732
+ );
733
+ element.setAttribute("tabindex", "-1");
734
+ });
735
+ }
736
+ function enableChildrenFocus(parent) {
737
+ const focusElement = parent.querySelectorAll(`[${previousTabIndexLabel}]`);
738
+ focusElement.forEach((element) => {
739
+ element.setAttribute(
740
+ "tabindex",
741
+ element.getAttribute(previousTabIndexLabel) ?? "0"
742
+ );
743
+ element.removeAttribute(previousTabIndexLabel);
744
+ });
745
+ }
746
+
747
+ const decodeHTMLEntities = (str) => {
748
+ const parser = new DOMParser();
749
+ const dom = parser.parseFromString(
750
+ "<!doctype html><body>" + str,
751
+ "text/html"
752
+ );
753
+ const decodedString = dom.body.textContent;
754
+ return decodedString;
755
+ };
756
+
757
+ class EventEmitter {
758
+ constructor() {
759
+ this.callbacks = {
760
+ on: {},
761
+ once: {}
762
+ };
763
+ this.enabled = true;
764
+ this.debugMode = false;
765
+ }
766
+ debug(enable = true) {
767
+ this.debugMode = enable;
768
+ }
769
+ /**
770
+ * Emits an event with the given data. Any listeners subscribed to this event will be invoked with the passed data.
771
+ *
772
+ * @param event - The event name to emit.
773
+ * @param data - The data associated with the event. Its type is dependent on the event name.
774
+ */
775
+ emit(event, data) {
776
+ this.callbacks.on[event]?.forEach((current) => current(data));
777
+ this.callbacks.once[event]?.forEach((current) => current(data));
778
+ this.callbacks.once[event] = [];
779
+ }
780
+ /**
781
+ * Reflects the current emitter state. A disabled state indicates that the emitter wont call listeners until its functionality gets enabled again.
782
+ */
783
+ get isEnabled() {
784
+ return this.enabled;
785
+ }
786
+ off(event, cb) {
787
+ this.callbacks.on[event] = this.callbacks.on[event]?.filter(
788
+ (c) => c !== cb
789
+ );
790
+ this.callbacks.once[event] = this.callbacks.once[event]?.filter(
791
+ (c) => c !== cb
792
+ );
793
+ }
794
+ /**
795
+ * Subscribes a callback function to an event. The callback is invoked each time the event is emitted.
796
+ *
797
+ * @param event - The event name to listen to.
798
+ * @param cb - The callback function to be invoked when the event is emitted.
799
+ * @returns A function to unsubscribe the event listener.
800
+ */
801
+ on(event, cb) {
802
+ if (!this.callbacks.on[event])
803
+ this.callbacks.on[event] = [];
804
+ this.callbacks.on[event].push(cb);
805
+ return () => {
806
+ this.callbacks.on[event] = this.callbacks.on[event].filter(
807
+ (c) => c !== cb
808
+ );
809
+ };
810
+ }
811
+ /**
812
+ * Subscribes a callback function to an event for a single occurrence. After the event is emitted once, the listener is automatically removed.
813
+ *
814
+ * @param event - The event name to listen to for a single occurrence.
815
+ * @param cb - The callback function to be invoked when the event is emitted.
816
+ * @returns A function to unsubscribe the event listener.
817
+ */
818
+ once(event, cb) {
819
+ if (!this.callbacks.once[event])
820
+ this.callbacks.once[event] = [];
821
+ this.callbacks.once[event].push(cb);
822
+ return () => {
823
+ this.callbacks.once[event] = this.callbacks.once[event].filter(
824
+ (c) => c !== cb
825
+ );
826
+ };
827
+ }
828
+ }
829
+
830
+ function useCombinedRefs(...refs) {
831
+ const [targetRef, setTargetRef] = React.useState();
832
+ React.useEffect(() => {
833
+ refs.forEach((ref) => {
834
+ if (!ref)
835
+ return;
836
+ if (typeof ref === "function") {
837
+ ref(targetRef);
838
+ } else {
839
+ ref.current = targetRef;
840
+ }
841
+ });
842
+ }, [refs, targetRef]);
843
+ return setTargetRef;
844
+ }
845
+
846
+ const useDebouncedCallback = (callback, { runWhenTriggered, timeout } = { runWhenTriggered: false, timeout: 200 }) => {
847
+ const timeoutRef = useRef(-1);
848
+ return useCallback(
849
+ (...params) => {
850
+ if (runWhenTriggered)
851
+ callback(...params);
852
+ clearTimeout(timeoutRef.current);
853
+ timeoutRef.current = setTimeout(
854
+ () => callback(...params),
855
+ timeout
856
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
857
+ );
858
+ },
859
+ [callback, runWhenTriggered, timeout]
860
+ );
861
+ };
862
+
863
+ function usePrevious$1(element) {
864
+ const el = React__default.useRef(element);
865
+ const last = React__default.useRef(null);
866
+ last.current = el.current;
867
+ el.current = element;
868
+ return last;
869
+ }
870
+
871
+ function shallowEqual$1(a, b) {
872
+ if (Object.is(a, b))
873
+ return true;
874
+ if (!Object.is(a, b) && typeof a !== typeof b) {
875
+ return false;
876
+ }
877
+ if (typeof a === "object") {
878
+ if (Array.isArray(a)) {
879
+ if (!Array.isArray(b) || a.length !== b.length) {
880
+ return false;
881
+ }
882
+ for (let i = 0; i < a.length; i++) {
883
+ if (!Object.is(a[i], b[i])) {
884
+ return false;
885
+ }
886
+ }
887
+ return true;
888
+ } else if (a && b) {
889
+ for (const [key, value] of Object.entries(a)) {
890
+ if (!Object.is(value, b[key])) {
891
+ return false;
892
+ }
893
+ }
894
+ for (const [key, value] of Object.entries(b)) {
895
+ if (!Object.is(value, a[key])) {
896
+ return false;
897
+ }
898
+ }
899
+ return true;
900
+ } else if (a && !b || !a && b) {
901
+ return false;
902
+ }
903
+ }
904
+ return a === b;
905
+ }
906
+
907
+ function useIntermediateValue(currentValue) {
908
+ const [innerState, setInnerState] = useState(currentValue);
909
+ const previousValue = usePrevious$1(currentValue);
910
+ if (!shallowEqual$1(currentValue, previousValue.current)) {
911
+ setInnerState(currentValue);
912
+ }
913
+ return [innerState, setInnerState];
914
+ }
915
+
916
+ function useLatest(value) {
917
+ const ref = useRef(value);
918
+ ref.current = value;
919
+ return ref;
920
+ }
921
+
922
+ function useMount(effect) {
923
+ useEffect(() => {
924
+ return effect();
925
+ }, []);
926
+ }
927
+
928
+ function useUnmount(unmountCallback) {
929
+ useEffect(() => {
930
+ return unmountCallback;
931
+ }, []);
932
+ }
933
+
934
+ function usePrevious(value) {
935
+ const previousValue = useRef(void 0);
936
+ const currentValue = useRef(void 0);
937
+ previousValue.current = currentValue.current;
938
+ currentValue.current = value;
939
+ return previousValue;
940
+ }
941
+
942
+ function useStateRef(initialState) {
943
+ const [state, setState] = useState(initialState);
944
+ const stateRef = useRef(state);
945
+ stateRef.current = state;
946
+ return [state, setState, stateRef];
947
+ }
948
+
949
+ function useSubscription({
950
+ getInitialState,
951
+ makeSubscription
952
+ }) {
953
+ const [state, setState] = useState(getInitialState?.());
954
+ useMount(() => {
955
+ let newState = getInitialState?.();
956
+ if (typeof newState === "function")
957
+ newState = newState();
958
+ if (newState !== void 0)
959
+ setState(newState);
960
+ return makeSubscription(setState);
961
+ });
962
+ return state;
963
+ }
964
+
965
+ function useUpdateEffect(effect, deps) {
966
+ const hasRunnedForFirstTime = useRef(false);
967
+ useEffect(() => {
968
+ if (hasRunnedForFirstTime.current) {
969
+ return effect();
970
+ }
971
+ hasRunnedForFirstTime.current = true;
972
+ return () => {
973
+ };
974
+ }, deps);
975
+ }
976
+
977
+ function shallowEqual(a, b) {
978
+ if (typeof a !== typeof b)
979
+ return false;
980
+ if (typeof a === "object" && a && typeof b === "object" && b) {
981
+ const aKeys = Object.keys(a);
982
+ const bKeys = Object.keys(b);
983
+ if (aKeys.length !== bKeys.length)
984
+ return false;
985
+ for (let i = 0; i < aKeys.length; i++) {
986
+ if (a[aKeys[i]] !== b[bKeys[i]])
987
+ return false;
988
+ }
989
+ } else {
990
+ if (a !== b)
991
+ return false;
992
+ }
993
+ return true;
994
+ }
995
+ function shallowCompareArrays(a, b) {
996
+ if (a.length !== b.length)
997
+ return false;
998
+ for (let i = 0; i < a.length; i++) {
999
+ const differ = shallowEqual(a, b);
1000
+ if (!differ)
1001
+ return false;
1002
+ }
1003
+ return true;
1004
+ }
1005
+ function useShallowMemo(creator, deps) {
1006
+ const value = useRef(creator());
1007
+ const previousDeps = usePrevious(deps);
1008
+ if (!shallowEqual(previousDeps.current ?? [], deps)) {
1009
+ value.current = creator();
1010
+ }
1011
+ return value.current;
1012
+ }
1013
+
1014
+ function useWhyUpdated(label, e) {
1015
+ const previousData = usePrevious(e);
1016
+ const diffs = [];
1017
+ Object.entries(e).forEach(([key, value]) => {
1018
+ if (!Object.is(value, previousData.current?.[key])) {
1019
+ diffs.push({ key, value, previous: previousData.current?.[key] });
1020
+ }
1021
+ });
1022
+ if (diffs.length) {
1023
+ console.log(label, diffs);
1024
+ }
1025
+ }
1026
+
1027
+ function isSetter(data) {
1028
+ return typeof data === "function";
1029
+ }
1030
+ class StatefulEmitter extends EventEmitter {
1031
+ constructor(initialState) {
1032
+ super();
1033
+ this.state = {};
1034
+ /**
1035
+ * Allows to consume an event stream as a real time updated state
1036
+ */
1037
+ this.useState = (event) => {
1038
+ return useSubscription({
1039
+ getInitialState: () => this.state[event],
1040
+ makeSubscription: (setState) => {
1041
+ return this.on(event, setState);
1042
+ }
1043
+ });
1044
+ };
1045
+ this.useStateSelector = (event, selector, comparator = Object.is) => {
1046
+ const previousSelection = useRef(null);
1047
+ return useSubscription({
1048
+ getInitialState: () => selector(this.state[event]),
1049
+ makeSubscription: (setState) => {
1050
+ return this.on(event, () => {
1051
+ const selection = selector(this.state[event]);
1052
+ if (!comparator(selection, previousSelection.current)) {
1053
+ setState(selection);
1054
+ }
1055
+ });
1056
+ }
1057
+ });
1058
+ };
1059
+ this.state = Object.assign({}, initialState);
1060
+ }
1061
+ emit(event, data) {
1062
+ this.state[event] = data;
1063
+ super.emit(event, data);
1064
+ }
1065
+ on(event, cb) {
1066
+ if (this.state[event])
1067
+ this.emit(event, this.state[event]);
1068
+ return super.on(event, cb);
1069
+ }
1070
+ once(event, cb) {
1071
+ if (this.state[event]) {
1072
+ this.emit(event, this.state[event]);
1073
+ return () => {
1074
+ };
1075
+ }
1076
+ return super.once(event, cb);
1077
+ }
1078
+ /**
1079
+ * Retrieves the stored state for a given event
1080
+ */
1081
+ getState(event) {
1082
+ return this.state[event];
1083
+ }
1084
+ /**
1085
+ * Just an alias for emit, with the advantage that can be called with a callback as second parameter in which case behaves exactly as react's setState.
1086
+ */
1087
+ setState(event, data) {
1088
+ const actualData = isSetter(data) ? data(this.getState(event)) : data;
1089
+ this.emit(event, actualData);
1090
+ }
1091
+ }
1092
+
1093
+ const NullObject = Symbol("NullObject");
1094
+ class BouncingEmitter extends StatefulEmitter {
1095
+ constructor() {
1096
+ super(...arguments);
1097
+ this.bouncingTimeouts = {};
1098
+ this.defaultTiming = 100;
1099
+ /**
1100
+ * Throttles a event emit with the warranty that the data will be emitted at most every (timing)ms. Take the following event throttling, where each E is a call to this method and each character represents 20ms:
1101
+ *
1102
+ * E_E_E_E_E_E_E_E_E
1103
+ *
1104
+ * If timing is configured to 100ms, which is the default, the emission will occur as follows:
1105
+ *
1106
+ * ____E____E____E______E
1107
+ *
1108
+ * @param configuration.emitOnStart - Emits an event on the first call to throttle when no pending throttle is stored. **If emitOnStart is true and an only call to throttle is made, it will emit an only event.**
1109
+ */
1110
+ this.throttleData = {};
1111
+ this.throttleEmittedOnInit = {};
1112
+ }
1113
+ /**
1114
+ * Debounces a event emit with until there is no call to the emit methods by (timing)ms. Take the following event throttling, where each E is a call to this method and each character represents 20ms:
1115
+ *
1116
+ * E_E_E_E_E_E_E_E_E
1117
+ *
1118
+ * If timing is configured to 100ms, which is the default, the emission will occur as follows:
1119
+ *
1120
+ * _____________________E
1121
+ */
1122
+ debounce(event, data, configuration) {
1123
+ clearTimeout(this.bouncingTimeouts[event]);
1124
+ this.bouncingTimeouts[event] = setTimeout(() => {
1125
+ this.emit(event, data);
1126
+ }, configuration?.timing ?? this.defaultTiming);
1127
+ }
1128
+ throttle(event, data, configuration) {
1129
+ if (!this.throttleEmittedOnInit[event] && configuration?.emitOnStart) {
1130
+ this.throttleEmittedOnInit[event] = true;
1131
+ setTimeout(() => {
1132
+ this.throttleEmittedOnInit[event] = false;
1133
+ }, configuration?.timing ?? this.defaultTiming);
1134
+ this.emit(event, data);
1135
+ } else if (!configuration?.emitOnStart) {
1136
+ if (this.throttleData[event] === NullObject || !(event in this.throttleData)) {
1137
+ setTimeout(() => {
1138
+ this.emit(event, this.throttleData[event]);
1139
+ this.throttleData[event] = NullObject;
1140
+ }, configuration?.timing ?? this.defaultTiming);
1141
+ }
1142
+ this.throttleData[event] = data;
1143
+ }
1144
+ }
1145
+ /**
1146
+ * This method is a mix between setState and debounce
1147
+ */
1148
+ setStateDebounced(event, data, configuration) {
1149
+ const actualData = isSetter(data) ? data(this.getState(event)) : data;
1150
+ this.debounce(event, actualData, configuration);
1151
+ }
1152
+ /**
1153
+ * This method is a mix between setState and throttle
1154
+ */
1155
+ setStateThrottled(event, data, configuration) {
1156
+ const actualData = isSetter(data) ? data(this.getState(event)) : data;
1157
+ this.throttle(event, actualData, configuration);
1158
+ }
1159
+ }
1160
+
1161
+ var __accessCheck$3 = (obj, member, msg) => {
1162
+ if (!member.has(obj))
1163
+ throw TypeError("Cannot " + msg);
1164
+ };
1165
+ var __privateGet$3 = (obj, member, getter) => {
1166
+ __accessCheck$3(obj, member, "read from private field");
1167
+ return getter ? getter.call(obj) : member.get(obj);
1168
+ };
1169
+ var __privateAdd$3 = (obj, member, value) => {
1170
+ if (member.has(obj))
1171
+ throw TypeError("Cannot add the same private member more than once");
1172
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1173
+ };
1174
+ var __privateSet$3 = (obj, member, value, setter) => {
1175
+ __accessCheck$3(obj, member, "write to private field");
1176
+ setter ? setter.call(obj, value) : member.set(obj, value);
1177
+ return value;
1178
+ };
1179
+ var _onFocusCallbacks, _a$1;
1180
+ const historySize = 50;
1181
+ const globalFocus = new (_a$1 = class {
1182
+ constructor() {
1183
+ this.focused = [];
1184
+ __privateAdd$3(this, _onFocusCallbacks, []);
1185
+ debugDispatcher.on(
1186
+ "focusHistory",
1187
+ () => {
1188
+ console.info(this.focused);
1189
+ },
1190
+ "Muestra el historial de elementos que recibieron foco."
1191
+ );
1192
+ }
1193
+ offFocus(cb) {
1194
+ __privateSet$3(this, _onFocusCallbacks, __privateGet$3(this, _onFocusCallbacks).filter(
1195
+ (current) => current !== cb
1196
+ ));
1197
+ }
1198
+ onFocus(cb) {
1199
+ __privateGet$3(this, _onFocusCallbacks).push(cb);
1200
+ return () => {
1201
+ this.offFocus(cb);
1202
+ };
1203
+ }
1204
+ inDocument(el) {
1205
+ return el instanceof Function || el instanceof HTMLElement && el.offsetParent !== null;
1206
+ }
1207
+ set focus(element) {
1208
+ this.focused = this.focused.filter((el) => {
1209
+ const existsInDocument = this.inDocument(el) && element !== el;
1210
+ return existsInDocument;
1211
+ });
1212
+ this.focused.unshift(element);
1213
+ if (this.focused.length > historySize) {
1214
+ this.focused = this.focused.splice(0, historySize);
1215
+ }
1216
+ __privateGet$3(this, _onFocusCallbacks).forEach((cb) => cb());
1217
+ }
1218
+ get list() {
1219
+ return [...this.focused];
1220
+ }
1221
+ /**
1222
+ * @param querySelector A query selector against which the element should match
1223
+ * @returns The last HTMLElement if no querySelector argument provided or else, the last which matches
1224
+ * against that query selector.
1225
+ * */
1226
+ last(querySelector, omit = 0) {
1227
+ if (querySelector)
1228
+ for (let i = omit; i <= this.focused.length; i++) {
1229
+ const storedElement = this.focused[i];
1230
+ const element = (
1231
+ // eslint-disable-next-line no-nested-ternary
1232
+ storedElement?.id !== void 0 ? storedElement : isFunction(storedElement) ? storedElement(false) : null
1233
+ );
1234
+ if (element && this.inDocument(element) && element.matches && element.matches(querySelector))
1235
+ return element;
1236
+ }
1237
+ else
1238
+ return this.focused[this.focused.length - 1];
1239
+ return null;
1240
+ }
1241
+ }, _onFocusCallbacks = new WeakMap(), _a$1)();
1242
+
1243
+ var __accessCheck$2 = (obj, member, msg) => {
1244
+ if (!member.has(obj))
1245
+ throw TypeError("Cannot " + msg);
1246
+ };
1247
+ var __privateGet$2 = (obj, member, getter) => {
1248
+ __accessCheck$2(obj, member, "read from private field");
1249
+ return getter ? getter.call(obj) : member.get(obj);
1250
+ };
1251
+ var __privateAdd$2 = (obj, member, value) => {
1252
+ if (member.has(obj))
1253
+ throw TypeError("Cannot add the same private member more than once");
1254
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1255
+ };
1256
+ var __privateSet$2 = (obj, member, value, setter) => {
1257
+ __accessCheck$2(obj, member, "write to private field");
1258
+ setter ? setter.call(obj, value) : member.set(obj, value);
1259
+ return value;
1260
+ };
1261
+ var __privateMethod$1 = (obj, member, method) => {
1262
+ __accessCheck$2(obj, member, "access private method");
1263
+ return method;
1264
+ };
1265
+ var _hasReleasedFirstTime, _wasReleasedFirstTime, _isForced, _locks, _shoutLockState, shoutLockState_fn;
1266
+ class ScreenLocker extends EventEmitter {
1267
+ constructor() {
1268
+ super();
1269
+ __privateAdd$2(this, _shoutLockState);
1270
+ __privateAdd$2(this, _hasReleasedFirstTime, false);
1271
+ __privateAdd$2(this, _wasReleasedFirstTime, false);
1272
+ __privateAdd$2(this, _isForced, false);
1273
+ __privateAdd$2(this, _locks, {
1274
+ common: false
1275
+ });
1276
+ this.emit("ready", null);
1277
+ }
1278
+ get hasReleasedFirstTime() {
1279
+ return __privateGet$2(this, _hasReleasedFirstTime);
1280
+ }
1281
+ get isForced() {
1282
+ return __privateGet$2(this, _isForced);
1283
+ }
1284
+ /**
1285
+ * Permite saber si un bloqueo determinado está activo o si la clase tiene
1286
+ * forceLock activo.
1287
+ */
1288
+ isLocked(lockName = "common") {
1289
+ return __privateGet$2(this, _locks)[lockName] || __privateGet$2(this, _isForced);
1290
+ }
1291
+ lock(lockName = "common") {
1292
+ __privateGet$2(this, _locks)[lockName] = true;
1293
+ __privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this, lockName);
1294
+ }
1295
+ unlock(lockName = "common") {
1296
+ if (lockName === "common")
1297
+ __privateSet$2(this, _hasReleasedFirstTime, true);
1298
+ __privateGet$2(this, _locks)[lockName] = false;
1299
+ __privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this, lockName);
1300
+ }
1301
+ force() {
1302
+ __privateSet$2(this, _isForced, true);
1303
+ __privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this);
1304
+ }
1305
+ releaseForced() {
1306
+ __privateSet$2(this, _isForced, false);
1307
+ __privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this);
1308
+ }
1309
+ }
1310
+ _hasReleasedFirstTime = new WeakMap();
1311
+ _wasReleasedFirstTime = new WeakMap();
1312
+ _isForced = new WeakMap();
1313
+ _locks = new WeakMap();
1314
+ _shoutLockState = new WeakSet();
1315
+ shoutLockState_fn = function(lockName) {
1316
+ if (__privateGet$2(this, _isForced) || lockName === void 0) {
1317
+ this.emit("forcedStateChange", {
1318
+ isForced: __privateGet$2(this, _isForced),
1319
+ hasReleasedFirstTime: __privateGet$2(this, _hasReleasedFirstTime)
1320
+ });
1321
+ } else {
1322
+ if (lockName === "common" && !__privateGet$2(this, _wasReleasedFirstTime) && __privateGet$2(this, _hasReleasedFirstTime)) {
1323
+ this.emit("releaseForFirstTime", null);
1324
+ }
1325
+ this.emit("lockStateChange", {
1326
+ lockName,
1327
+ hasReleasedFirstTime: __privateGet$2(this, _hasReleasedFirstTime),
1328
+ isLocked: __privateGet$2(this, _locks)[lockName]
1329
+ });
1330
+ }
1331
+ };
1332
+ const screenLocker = new ScreenLocker();
1333
+
1334
+ var __accessCheck$1 = (obj, member, msg) => {
1335
+ if (!member.has(obj))
1336
+ throw TypeError("Cannot " + msg);
1337
+ };
1338
+ var __privateGet$1 = (obj, member, getter) => {
1339
+ __accessCheck$1(obj, member, "read from private field");
1340
+ return getter ? getter.call(obj) : member.get(obj);
1341
+ };
1342
+ var __privateAdd$1 = (obj, member, value) => {
1343
+ if (member.has(obj))
1344
+ throw TypeError("Cannot add the same private member more than once");
1345
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1346
+ };
1347
+ var __privateSet$1 = (obj, member, value, setter) => {
1348
+ __accessCheck$1(obj, member, "write to private field");
1349
+ setter ? setter.call(obj, value) : member.set(obj, value);
1350
+ return value;
1351
+ };
1352
+ var _onUpdateCbs;
1353
+ function upper(s) {
1354
+ return `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
1355
+ }
1356
+ function isUpdater(props) {
1357
+ return typeof props === "function";
1358
+ }
1359
+ class BasicStoredElement {
1360
+ constructor(props) {
1361
+ __privateAdd$1(this, _onUpdateCbs, []);
1362
+ this.props = {};
1363
+ this.shoutUpdates = () => {
1364
+ __privateGet$1(this, _onUpdateCbs).forEach((current) => current());
1365
+ };
1366
+ this.useProps = () => {
1367
+ const [props, setState] = useState(this.props);
1368
+ useMount(() => {
1369
+ setState({ ...this.props });
1370
+ return this.onUpdate(() => {
1371
+ setState({ ...this.props });
1372
+ });
1373
+ });
1374
+ return props;
1375
+ };
1376
+ this.props = props;
1377
+ }
1378
+ onUpdate(cb) {
1379
+ __privateGet$1(this, _onUpdateCbs).push(cb);
1380
+ return () => {
1381
+ __privateSet$1(this, _onUpdateCbs, __privateGet$1(this, _onUpdateCbs).filter((current) => current !== cb));
1382
+ };
1383
+ }
1384
+ update(newProps) {
1385
+ const actualNewProps = isUpdater(newProps) ? newProps(this.props) : newProps;
1386
+ this.props = { ...this.props, ...actualNewProps };
1387
+ this.shoutUpdates();
1388
+ }
1389
+ }
1390
+ _onUpdateCbs = new WeakMap();
1391
+ class People extends BasicStoredElement {
1392
+ getId() {
1393
+ return this.props.name;
1394
+ }
1395
+ }
1396
+ makeStatefulStore({
1397
+ people: People.prototype
1398
+ });
1399
+ function makeStatefulStore(entries, initialStates) {
1400
+ const hookUseState = {};
1401
+ const hookUseList = {};
1402
+ const hookUseStateById = {};
1403
+ const suscribeById = {};
1404
+ const suscribeToList = {};
1405
+ const suscribeToListCount = {};
1406
+ const addActions = {};
1407
+ const emptyActions = {};
1408
+ const removeActions = {};
1409
+ const updateListActions = {};
1410
+ const getItemActions = {};
1411
+ const getStateActions = {};
1412
+ const updateItemActions = {};
1413
+ Object.keys(entries).forEach((name) => {
1414
+ const initialStateKey = `${upper(name)}State`;
1415
+ let store = {};
1416
+ const initialState = initialStates?.[initialStateKey];
1417
+ initialState?.forEach((current) => {
1418
+ store[current.getId()] = current;
1419
+ });
1420
+ let listStateChangeHandlers = [];
1421
+ function shoutListStateChange() {
1422
+ listStateChangeHandlers.forEach((current) => current());
1423
+ }
1424
+ const elementChangeHandlers = {};
1425
+ function shoutListElementChange(id) {
1426
+ elementChangeHandlers[id]?.forEach((current) => current());
1427
+ }
1428
+ let listCountChangeHandlers = [];
1429
+ function shoutListCountChange() {
1430
+ listCountChangeHandlers.forEach((current) => current());
1431
+ }
1432
+ const onUpdateElementSuscriptions = {};
1433
+ const addKey = `add${upper(name)}`;
1434
+ addActions[addKey] = (newElement) => {
1435
+ let elId = newElement.getId();
1436
+ let lastProps = { ...newElement.props };
1437
+ store[elId] = newElement;
1438
+ const suscription = newElement.onUpdate(() => {
1439
+ const id = newElement.getId();
1440
+ if (id !== elId) {
1441
+ if (store[id]) {
1442
+ newElement.update(lastProps);
1443
+ throw new Error(
1444
+ `Cannot set new id ${id} because it already exists`
1445
+ );
1446
+ }
1447
+ delete store[elId];
1448
+ store[id] = newElement;
1449
+ elId = id;
1450
+ lastProps = newElement.props;
1451
+ }
1452
+ shoutListElementChange(id);
1453
+ shoutListStateChange();
1454
+ });
1455
+ onUpdateElementSuscriptions[newElement.getId()] = suscription;
1456
+ shoutListStateChange();
1457
+ shoutListCountChange();
1458
+ shoutListElementChange(elId);
1459
+ };
1460
+ const emptyKey = `empty${upper(name)}`;
1461
+ emptyActions[emptyKey] = () => {
1462
+ Object.values(onUpdateElementSuscriptions).forEach(
1463
+ (current) => current()
1464
+ );
1465
+ store = {};
1466
+ shoutListCountChange();
1467
+ shoutListStateChange();
1468
+ Object.keys(elementChangeHandlers).forEach(
1469
+ (current) => shoutListElementChange(current)
1470
+ );
1471
+ };
1472
+ const removeKey = `remove${upper(name)}`;
1473
+ removeActions[removeKey] = (id) => {
1474
+ onUpdateElementSuscriptions[id]?.();
1475
+ delete store[id];
1476
+ shoutListCountChange();
1477
+ shoutListStateChange();
1478
+ shoutListElementChange(id);
1479
+ };
1480
+ const updateListKey = `update${upper(
1481
+ name
1482
+ )}List`;
1483
+ updateListActions[updateListKey] = (list) => {
1484
+ store[name] = list;
1485
+ shoutListCountChange();
1486
+ shoutListStateChange();
1487
+ };
1488
+ const getStateKey = `get${upper(name)}State`;
1489
+ getStateActions[getStateKey] = () => {
1490
+ return Object.values(store);
1491
+ };
1492
+ const getState = getStateActions[getStateKey];
1493
+ const getItemKey = `get${upper(name)}`;
1494
+ getItemActions[getItemKey] = (id) => {
1495
+ return store[id];
1496
+ };
1497
+ const updateItemKey = `update${upper(name)}`;
1498
+ updateItemActions[updateItemKey] = (id, newProps) => {
1499
+ store[id].update(newProps);
1500
+ };
1501
+ const hookUseStateKey = `use${upper(name)}`;
1502
+ hookUseState[hookUseStateKey] = () => {
1503
+ const [state2, setState] = useState(getState());
1504
+ useMount(() => {
1505
+ setState(getState());
1506
+ const eventHandler = () => {
1507
+ setState(getState());
1508
+ };
1509
+ listStateChangeHandlers.push(eventHandler);
1510
+ return () => {
1511
+ listStateChangeHandlers = listStateChangeHandlers.filter(
1512
+ (current) => current !== eventHandler
1513
+ );
1514
+ };
1515
+ });
1516
+ return state2;
1517
+ };
1518
+ const hookUseListKey = `use${upper(name)}List`;
1519
+ hookUseList[hookUseListKey] = () => {
1520
+ const [state2, setState] = useState(getState());
1521
+ useMount(() => {
1522
+ setState(getState());
1523
+ const eventHandler = () => {
1524
+ setState(getState());
1525
+ };
1526
+ listCountChangeHandlers.push(eventHandler);
1527
+ return () => {
1528
+ listCountChangeHandlers = listCountChangeHandlers.filter(
1529
+ (current) => current !== eventHandler
1530
+ );
1531
+ };
1532
+ });
1533
+ return state2;
1534
+ };
1535
+ const hookUseStateByIdKey = `use${upper(
1536
+ name
1537
+ )}ById`;
1538
+ hookUseStateById[hookUseStateByIdKey] = (id) => {
1539
+ const [state2, setState] = useState({ obj: store[id] });
1540
+ useMount(() => {
1541
+ setState({ obj: store[id] });
1542
+ const eventHandler = () => {
1543
+ setState({ obj: store[id] });
1544
+ };
1545
+ if (!elementChangeHandlers[id])
1546
+ elementChangeHandlers[id] = [];
1547
+ elementChangeHandlers[id].push(eventHandler);
1548
+ return () => {
1549
+ elementChangeHandlers[id] = elementChangeHandlers[id].filter(
1550
+ (current) => current !== eventHandler
1551
+ );
1552
+ };
1553
+ });
1554
+ return state2.obj;
1555
+ };
1556
+ const onChangeElementKey = `change${upper(
1557
+ name
1558
+ )}Element`;
1559
+ suscribeById[onChangeElementKey] = (id, cb) => {
1560
+ if (!elementChangeHandlers[id])
1561
+ elementChangeHandlers[id] = [];
1562
+ const innerCb = () => {
1563
+ cb(store[id]);
1564
+ };
1565
+ elementChangeHandlers[id].push(innerCb);
1566
+ return () => {
1567
+ elementChangeHandlers[id] = elementChangeHandlers[id].filter(
1568
+ (current) => current !== innerCb
1569
+ );
1570
+ };
1571
+ };
1572
+ const onChangeListKey = `change${upper(
1573
+ name
1574
+ )}`;
1575
+ suscribeToList[onChangeListKey] = (cb) => {
1576
+ const innerCb = () => {
1577
+ cb(getState());
1578
+ };
1579
+ listStateChangeHandlers.push(innerCb);
1580
+ return () => {
1581
+ listStateChangeHandlers = listStateChangeHandlers.filter(
1582
+ (current) => current !== innerCb
1583
+ );
1584
+ };
1585
+ };
1586
+ const onChangeListCountKey = `change${upper(
1587
+ name
1588
+ )}Ammount`;
1589
+ suscribeToListCount[onChangeListCountKey] = (cb) => {
1590
+ const innerCb = () => {
1591
+ cb(getState());
1592
+ };
1593
+ listCountChangeHandlers.push(innerCb);
1594
+ return () => {
1595
+ listCountChangeHandlers = listCountChangeHandlers.filter(
1596
+ (current) => current !== innerCb
1597
+ );
1598
+ };
1599
+ };
1600
+ });
1601
+ const actions = Object.assign(
1602
+ {},
1603
+ addActions,
1604
+ removeActions,
1605
+ emptyActions,
1606
+ updateListActions
1607
+ );
1608
+ const hooks = Object.assign({}, hookUseState, hookUseStateById, hookUseList);
1609
+ const on = Object.assign(
1610
+ {},
1611
+ suscribeById,
1612
+ suscribeToList,
1613
+ suscribeToListCount
1614
+ );
1615
+ const state = Object.assign(
1616
+ {},
1617
+ getStateActions,
1618
+ getItemActions,
1619
+ updateItemActions
1620
+ );
1621
+ return Object.assign(
1622
+ {},
1623
+ { hooks },
1624
+ { actions },
1625
+ { state },
1626
+ { on }
1627
+ );
1628
+ }
1629
+
1630
+ const persistentStorage = new Proxy(
1631
+ {
1632
+ remove(prop) {
1633
+ localStorage.removeItem(prop);
1634
+ }
1635
+ },
1636
+ {
1637
+ get(_, prop) {
1638
+ try {
1639
+ const value = localStorage.getItem(String(prop));
1640
+ if (!value)
1641
+ return void 0;
1642
+ return JSON.parse(value);
1643
+ } catch {
1644
+ return void 0;
1645
+ }
1646
+ },
1647
+ set(_, prop, value) {
1648
+ localStorage.setItem(String(prop), JSON.stringify(value));
1649
+ return true;
1650
+ }
1651
+ }
1652
+ );
1653
+ window.persistentStorage = persistentStorage;
1654
+ var persistentStorage$1 = persistentStorage;
1655
+
1656
+ const localStorageController = new class LocalSctorageController extends EventEmitter {
1657
+ }();
1658
+ function useLocalStorage(prop, defaultValue) {
1659
+ const actualProp = useMemo(() => prop, []);
1660
+ const storageValue = useMemo(
1661
+ () => localStorage.getItem(actualProp),
1662
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1663
+ []
1664
+ );
1665
+ const [value, setValue] = useState(
1666
+ storageValue ? JSON.parse(storageValue) : defaultValue
1667
+ );
1668
+ useEffect(() => {
1669
+ setValue(JSON.parse(storageValue));
1670
+ return localStorageController.on("update", (ev) => {
1671
+ if (ev.prop === actualProp) {
1672
+ setValue(ev.value);
1673
+ localStorage.setItem(actualProp, JSON.stringify(ev.value));
1674
+ }
1675
+ });
1676
+ }, []);
1677
+ return [
1678
+ value,
1679
+ useCallback(
1680
+ (newValue) => {
1681
+ localStorageController.emit("update", {
1682
+ prop: actualProp,
1683
+ value: newValue
1684
+ });
1685
+ },
1686
+ [actualProp]
1687
+ )
1688
+ ];
1689
+ }
1690
+
1691
+ var __accessCheck = (obj, member, msg) => {
1692
+ if (!member.has(obj))
1693
+ throw TypeError("Cannot " + msg);
1694
+ };
1695
+ var __privateGet = (obj, member, getter) => {
1696
+ __accessCheck(obj, member, "read from private field");
1697
+ return getter ? getter.call(obj) : member.get(obj);
1698
+ };
1699
+ var __privateAdd = (obj, member, value) => {
1700
+ if (member.has(obj))
1701
+ throw TypeError("Cannot add the same private member more than once");
1702
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1703
+ };
1704
+ var __privateSet = (obj, member, value, setter) => {
1705
+ __accessCheck(obj, member, "write to private field");
1706
+ setter ? setter.call(obj, value) : member.set(obj, value);
1707
+ return value;
1708
+ };
1709
+ var __privateWrapper = (obj, member, setter, getter) => ({
1710
+ set _(value) {
1711
+ __privateSet(obj, member, value, setter);
1712
+ },
1713
+ get _() {
1714
+ return __privateGet(obj, member, getter);
1715
+ }
1716
+ });
1717
+ var __privateMethod = (obj, member, method) => {
1718
+ __accessCheck(obj, member, "access private method");
1719
+ return method;
1720
+ };
1721
+ var _root, _props, _actualFocusQuery, _currentInstruction, _focusDelay, _focusRetries, _focusTimeout, _isIntervalRunning, _focusQuery, focusQuery_get, _checkInstruction, checkInstruction_fn, _doFocus, doFocus_fn, _resetInterval, resetInterval_fn, _runFocusInterval, runFocusInterval_fn, _a;
1722
+ const notificationsSelector = ".notification";
1723
+ const focus = new (_a = class {
1724
+ constructor(root, props) {
1725
+ __privateAdd(this, _focusQuery);
1726
+ __privateAdd(this, _checkInstruction);
1727
+ __privateAdd(this, _doFocus);
1728
+ __privateAdd(this, _resetInterval);
1729
+ __privateAdd(this, _runFocusInterval);
1730
+ __privateAdd(this, _root, void 0);
1731
+ __privateAdd(this, _props, void 0);
1732
+ this.afterNotificationFocus = void 0;
1733
+ __privateAdd(this, _actualFocusQuery, []);
1734
+ __privateAdd(this, _currentInstruction, 0);
1735
+ __privateAdd(this, _focusDelay, 300);
1736
+ __privateAdd(this, _focusRetries, 3);
1737
+ __privateAdd(this, _focusTimeout, -1);
1738
+ __privateAdd(this, _isIntervalRunning, false);
1739
+ this.focusOnReload = null;
1740
+ __privateSet(this, _root, root);
1741
+ __privateSet(this, _props, props);
1742
+ window.focusStatus = {};
1743
+ globalFocus.onFocus(() => {
1744
+ __privateMethod(this, _resetInterval, resetInterval_fn).call(this);
1745
+ });
1746
+ }
1747
+ /**
1748
+ * Da la instrucción de colocar el foco en el elemento provisto como
1749
+ * parámetro una vez que todas las notificaciones se hayan cerrado. En caso
1750
+ * de no existir notificaciones abiertas, hace foco en el elemento
1751
+ * directamente.
1752
+ */
1753
+ afterNotifications(element, configuration) {
1754
+ if (!element)
1755
+ return;
1756
+ void this.on(element, configuration);
1757
+ }
1758
+ /**
1759
+ * Da la instrucción de colocar el foco en el elemento provisto como
1760
+ * parámetro luego de recargar la página.
1761
+ *
1762
+ * Los parámetros pasados serán ordenados en orden de importancia priorizando
1763
+ * en el siguiente orden:
1764
+ * - id
1765
+ * - name
1766
+ * - className
1767
+ * - selector
1768
+ */
1769
+ afterReload({
1770
+ className,
1771
+ id,
1772
+ name,
1773
+ selector
1774
+ }) {
1775
+ persistentStorage$1.focusOnReload = [
1776
+ id ? `#${id}` : void 0,
1777
+ name ? `[name="${name}"]` : void 0,
1778
+ className ? `.${className}` : void 0,
1779
+ selector
1780
+ ].filter((el) => el !== void 0).join(",");
1781
+ }
1782
+ /**
1783
+ * Da la instrucción de colocar el foco el elemento pasado como parámetro.
1784
+ * Se puede pasar también una función que devuelva HTMLElement | false |
1785
+ * null.
1786
+ *
1787
+ * El segundo parámetro del método on es un objeto de tipo
1788
+ * ScrollIntoViewOptions, que permite modificar el comportamiento del scroll
1789
+ * a en el elemento.
1790
+ *
1791
+ * @see TFocusRetriever para más detalles sobre la función como parámetro.
1792
+ */
1793
+ async on(element, configuration) {
1794
+ if (element) {
1795
+ const focusElement = {
1796
+ element,
1797
+ configuration
1798
+ };
1799
+ for (let i = 0; i < __privateGet(this, _focusRetries); i++)
1800
+ __privateGet(this, _focusQuery, focusQuery_get).unshift(focusElement);
1801
+ __privateMethod(this, _resetInterval, resetInterval_fn).call(this);
1802
+ return __privateMethod(this, _runFocusInterval, runFocusInterval_fn).call(this, focusElement);
1803
+ }
1804
+ return false;
1805
+ }
1806
+ restore() {
1807
+ void this.on(
1808
+ globalFocus.last(":not(body), body#tinymce") || document.querySelector(focusSelector)
1809
+ );
1810
+ }
1811
+ init() {
1812
+ const modalsObserver = new MutationObserver((mutation) => {
1813
+ if (mutation[0].removedNodes.length === 0)
1814
+ return;
1815
+ this.afterNotifications(
1816
+ globalFocus.last(
1817
+ ":not(body):not(.notificationsView *), body#tinymce"
1818
+ )
1819
+ );
1820
+ });
1821
+ const appModalsBox = (__privateGet(this, _props)?.modalsContainerRetriever ?? (() => __privateGet(this, _root).querySelector("#AppModals")))();
1822
+ if (appModalsBox)
1823
+ modalsObserver.observe(appModalsBox, { childList: true });
1824
+ screenLocker.on("releaseForFirstTime", () => {
1825
+ if (persistentStorage$1.focusOnReload)
1826
+ this.focusOnReload = persistentStorage$1.focusOnReload;
1827
+ persistentStorage$1.focusOnReload = null;
1828
+ this.afterNotifications(() => {
1829
+ if (this.focusOnReload) {
1830
+ const initialFocusElement = document.querySelector(
1831
+ this.focusOnReload
1832
+ );
1833
+ const scrollTop = noNaN(
1834
+ window.CURRENT_TAB?.split(
1835
+ "~"
1836
+ )[1]
1837
+ );
1838
+ if (document.scrollingElement)
1839
+ document.scrollingElement.scrollTop = scrollTop;
1840
+ return initialFocusElement;
1841
+ }
1842
+ return false;
1843
+ });
1844
+ });
1845
+ }
1846
+ }, _root = new WeakMap(), _props = new WeakMap(), _actualFocusQuery = new WeakMap(), _currentInstruction = new WeakMap(), _focusDelay = new WeakMap(), _focusRetries = new WeakMap(), _focusTimeout = new WeakMap(), _isIntervalRunning = new WeakMap(), _focusQuery = new WeakSet(), focusQuery_get = function() {
1847
+ return new Proxy(__privateGet(this, _actualFocusQuery), {
1848
+ get: (target, key) => {
1849
+ if (key in target) {
1850
+ const prop = target[key];
1851
+ if (isFunction(prop))
1852
+ return (...props) => {
1853
+ const result = target[key].bind(target, ...props)();
1854
+ return result;
1855
+ };
1856
+ return prop;
1857
+ }
1858
+ return void 0;
1859
+ }
1860
+ });
1861
+ }, _checkInstruction = new WeakSet(), checkInstruction_fn = function(focusCheck) {
1862
+ return focusCheck.currentInstruction === __privateGet(this, _currentInstruction);
1863
+ }, _doFocus = new WeakSet(), doFocus_fn = async function(HTMLElement, focusCheck, isLastTry, configuration) {
1864
+ if (screenLocker.isLocked("common") && !configuration?.focusEvenWhenScreenLocked) {
1865
+ return null;
1866
+ }
1867
+ const actualHTMLElement = isFunction(HTMLElement) ? HTMLElement(isLastTry) : HTMLElement;
1868
+ if (actualHTMLElement) {
1869
+ if (actualHTMLElement.disabled)
1870
+ return false;
1871
+ actualHTMLElement.focus();
1872
+ return new Promise((resolve) => {
1873
+ if (configuration?.dispatchCustomEvent !== false) {
1874
+ const customFocusEvent = new CustomEvent(customEvents.focus, {
1875
+ bubbles: true
1876
+ });
1877
+ actualHTMLElement.dispatchEvent(customFocusEvent);
1878
+ }
1879
+ setTimeout(() => {
1880
+ if (!__privateMethod(this, _checkInstruction, checkInstruction_fn).call(this, focusCheck)) {
1881
+ resolve(false);
1882
+ return;
1883
+ }
1884
+ try {
1885
+ if (configuration?.scrollIntoViewOptions)
1886
+ actualHTMLElement?.scrollIntoView(
1887
+ configuration.scrollIntoViewOptions
1888
+ );
1889
+ } catch (e) {
1890
+ console.error(e);
1891
+ }
1892
+ setTimeout(() => {
1893
+ if (!__privateMethod(this, _checkInstruction, checkInstruction_fn).call(this, focusCheck)) {
1894
+ resolve(false);
1895
+ } else if (document.activeElement?.tagName === "IFRAME") {
1896
+ resolve(
1897
+ document.activeElement.contentDocument?.contains(actualHTMLElement) ? actualHTMLElement : null
1898
+ );
1899
+ } else
1900
+ resolve(
1901
+ document.activeElement === actualHTMLElement ? actualHTMLElement : null
1902
+ );
1903
+ }, 0);
1904
+ }, 0);
1905
+ });
1906
+ }
1907
+ return actualHTMLElement;
1908
+ }, _resetInterval = new WeakSet(), resetInterval_fn = function() {
1909
+ clearTimeout(__privateGet(this, _focusTimeout));
1910
+ __privateSet(this, _focusTimeout, -1);
1911
+ __privateSet(this, _isIntervalRunning, false);
1912
+ __privateWrapper(this, _currentInstruction)._++;
1913
+ }, _runFocusInterval = new WeakSet(), runFocusInterval_fn = async function(focusElement, internalCall) {
1914
+ if (!internalCall && (__privateGet(this, _focusTimeout) !== -1 || __privateGet(this, _isIntervalRunning)))
1915
+ return false;
1916
+ const currentInstruction = {
1917
+ currentInstruction: __privateGet(this, _currentInstruction)
1918
+ };
1919
+ __privateSet(this, _isIntervalRunning, true);
1920
+ return new Promise((resolve) => {
1921
+ const resolvePromise = async () => {
1922
+ const element = focusElement ?? __privateGet(this, _focusQuery, focusQuery_get).shift();
1923
+ if (element) {
1924
+ const hasFocused = await __privateMethod(this, _doFocus, doFocus_fn).call(this, element.element, currentInstruction, element !== __privateGet(this, _focusQuery, focusQuery_get)[0], element.configuration);
1925
+ if (!__privateMethod(this, _checkInstruction, checkInstruction_fn).call(this, currentInstruction)) {
1926
+ resolve(false);
1927
+ return;
1928
+ }
1929
+ if (hasFocused !== null && hasFocused !== false) {
1930
+ __privateSet(this, _actualFocusQuery, []);
1931
+ resolve(hasFocused);
1932
+ __privateSet(this, _isIntervalRunning, false);
1933
+ return;
1934
+ }
1935
+ if (hasFocused === false) {
1936
+ __privateSet(this, _actualFocusQuery, __privateGet(this, _actualFocusQuery).filter(
1937
+ (current) => current !== element
1938
+ ));
1939
+ }
1940
+ }
1941
+ if (!__privateMethod(this, _checkInstruction, checkInstruction_fn).call(this, currentInstruction)) {
1942
+ resolve(false);
1943
+ return;
1944
+ }
1945
+ if (__privateGet(this, _actualFocusQuery).length > 0) {
1946
+ __privateSet(this, _focusTimeout, setTimeout(() => {
1947
+ const runInterval = async () => {
1948
+ const result = await __privateMethod(this, _runFocusInterval, runFocusInterval_fn).call(this, void 0, true);
1949
+ resolve(result);
1950
+ __privateSet(this, _isIntervalRunning, true);
1951
+ };
1952
+ void runInterval();
1953
+ }, __privateGet(this, _focusDelay)));
1954
+ } else {
1955
+ const lastFocused = globalFocus.last(":not(body)");
1956
+ if (lastFocused) {
1957
+ const result = await __privateMethod(this, _doFocus, doFocus_fn).call(this, lastFocused, currentInstruction, element !== __privateGet(this, _focusQuery, focusQuery_get)[0], element?.configuration);
1958
+ if (!__privateMethod(this, _checkInstruction, checkInstruction_fn).call(this, currentInstruction)) {
1959
+ resolve(false);
1960
+ return;
1961
+ }
1962
+ if (result)
1963
+ resolve(result);
1964
+ else
1965
+ resolve(false);
1966
+ __privateSet(this, _isIntervalRunning, true);
1967
+ }
1968
+ resolve(false);
1969
+ __privateSet(this, _isIntervalRunning, true);
1970
+ }
1971
+ };
1972
+ void resolvePromise();
1973
+ });
1974
+ }, _a)(document.getElementById("root"));
1975
+
1976
+ class History extends EventEmitter {
1977
+ constructor(onCloseWindow, configuration = { maxLength: 100 }) {
1978
+ super();
1979
+ this.configuration = configuration;
1980
+ this.autocloseTimeout = -1;
1981
+ this.currentStep = 0;
1982
+ this.content = [];
1983
+ this.emitting = 0;
1984
+ this.enabled = true;
1985
+ this._isOpen = false;
1986
+ this.timeoutMs = 350;
1987
+ this.closeWindow = () => {
1988
+ if (this._isOpen) {
1989
+ this.onCloseWindow(this.push.bind(this));
1990
+ this._isOpen = false;
1991
+ }
1992
+ };
1993
+ this.getEvent = () => {
1994
+ const stepCount = this.content.length - 1;
1995
+ const event = {
1996
+ content: this.content[this.currentStep],
1997
+ currentStep: this.currentStep,
1998
+ stepCount,
1999
+ hasNext: this.currentStep < stepCount,
2000
+ hasPrevious: this.currentStep >= 0
2001
+ };
2002
+ return event;
2003
+ };
2004
+ this.push = (el) => {
2005
+ this.content = [...this.content.slice(0, this.currentStep + 1), el];
2006
+ this.content = this.content.slice(
2007
+ Math.max(0, this.content.length - this.configuration.maxLength)
2008
+ );
2009
+ this.currentStep = this.content.length - 1;
2010
+ this.shoutStepChange(true);
2011
+ };
2012
+ this.shoutStepChange = (fromPush) => {
2013
+ try {
2014
+ this.emit("stepChange", { ...this.getEvent(), fromPush });
2015
+ } catch (e) {
2016
+ console.error(e);
2017
+ }
2018
+ };
2019
+ this.hooks = {
2020
+ useCountChange: (onChange) => {
2021
+ useMount(() => {
2022
+ onChange(this.getEvent());
2023
+ this.on("stepChange", () => {
2024
+ onChange(this.getEvent());
2025
+ });
2026
+ });
2027
+ }
2028
+ };
2029
+ this.back = () => {
2030
+ clearTimeout(this.autocloseTimeout);
2031
+ if (this.currentStep >= 0) {
2032
+ this.currentStep -= 1;
2033
+ this.shoutStepChange();
2034
+ }
2035
+ };
2036
+ this.disable = () => {
2037
+ this.enabled = false;
2038
+ };
2039
+ this.enable = () => {
2040
+ this.enabled = true;
2041
+ };
2042
+ this.forward = () => {
2043
+ clearTimeout(this.autocloseTimeout);
2044
+ if (this.currentStep < this.content.length - 1) {
2045
+ this.currentStep += 1;
2046
+ this.shoutStepChange();
2047
+ }
2048
+ };
2049
+ this.openWindow = () => {
2050
+ if (!this.enabled || this.emitting !== 0)
2051
+ return;
2052
+ this._isOpen = true;
2053
+ clearTimeout(this.autocloseTimeout);
2054
+ this.autocloseTimeout = setTimeout(() => {
2055
+ this.closeWindow();
2056
+ }, this.timeoutMs);
2057
+ };
2058
+ this.reset = () => {
2059
+ clearTimeout(this.autocloseTimeout);
2060
+ this.content = [];
2061
+ this.currentStep = -1;
2062
+ this.openWindow();
2063
+ };
2064
+ this.updateConfig = (newConfiguration) => {
2065
+ this.configuration = { ...this.configuration, ...newConfiguration };
2066
+ };
2067
+ this.useStep = () => {
2068
+ const [hasPrevious, setHasPrevious] = useState({ hasNext: false, hasPrevious: false, currentStep: 0 });
2069
+ useMount(() => {
2070
+ return this.on("stepChange", (ev) => {
2071
+ setHasPrevious({
2072
+ currentStep: ev.currentStep,
2073
+ hasNext: ev.hasNext,
2074
+ hasPrevious: ev.hasPrevious
2075
+ });
2076
+ });
2077
+ });
2078
+ return hasPrevious;
2079
+ };
2080
+ this.onCloseWindow = onCloseWindow;
2081
+ }
2082
+ emit(eventName, params) {
2083
+ this.emitting++;
2084
+ super.emit(eventName, params);
2085
+ this.emitting--;
2086
+ }
2087
+ get isOpen() {
2088
+ return this._isOpen;
2089
+ }
2090
+ }
2091
+
2092
+ const ImperativeComponentContext = createContext(
2093
+ {}
2094
+ );
2095
+
2096
+ function makeImperativeComponent() {
2097
+ return function ImperativeComponent({
2098
+ Component,
2099
+ initialState,
2100
+ methods
2101
+ }) {
2102
+ const setStates = {};
2103
+ const actualMethods = {};
2104
+ Object.entries(methods ?? {}).forEach(([key, method]) => {
2105
+ actualMethods[key] = (id, ...args) => {
2106
+ if (setStates[id]) {
2107
+ method(setStates[id], ...args);
2108
+ return true;
2109
+ } else {
2110
+ return false;
2111
+ }
2112
+ };
2113
+ });
2114
+ const eventsHandlers = {};
2115
+ const fireEvent = (id, ev, args) => {
2116
+ if (eventsHandlers[id]) {
2117
+ eventsHandlers[id]?.[ev]?.forEach((current) => current.cb(args));
2118
+ return true;
2119
+ } else {
2120
+ return false;
2121
+ }
2122
+ };
2123
+ const ActualComponent = ({
2124
+ id,
2125
+ ...props
2126
+ }) => {
2127
+ const [state, innerSetState] = useState(initialState);
2128
+ setStates[id] = (newState) => innerSetState((current) => ({ ...current, ...newState }));
2129
+ return /* @__PURE__ */ jsx(
2130
+ ImperativeComponentContext.Provider,
2131
+ {
2132
+ value: useMemo(() => ({ id, eventsStore: eventsHandlers }), [id]),
2133
+ children: /* @__PURE__ */ jsx(Component, { ...props, ...state })
2134
+ }
2135
+ );
2136
+ };
2137
+ return [actualMethods, fireEvent, ActualComponent];
2138
+ };
2139
+ }
2140
+
2141
+ function makeSingleImperativeComponent() {
2142
+ return function SingleImperativeComponent({
2143
+ initialState,
2144
+ methods,
2145
+ Component
2146
+ }) {
2147
+ const id = uniqueId();
2148
+ const [actualMethods, originalFireEvent, ImperativeComponent] = makeImperativeComponent()({
2149
+ initialState,
2150
+ methods,
2151
+ Component
2152
+ });
2153
+ const fireEvent = (ev, args) => originalFireEvent(id, ev, args);
2154
+ const newMethods = {};
2155
+ Object.entries(actualMethods).forEach(([name, method]) => {
2156
+ newMethods[name] = (...args) => method(id, ...args);
2157
+ });
2158
+ return [
2159
+ newMethods,
2160
+ fireEvent,
2161
+ (props) => /* @__PURE__ */ jsx(ImperativeComponent, { ...props, id })
2162
+ ];
2163
+ };
2164
+ }
2165
+
2166
+ function useImperativeComponentContext() {
2167
+ const context = useContext(ImperativeComponentContext);
2168
+ return context;
2169
+ }
2170
+
2171
+ const useImperativeComponentEvents = (handlers) => {
2172
+ const uniqueHookId = useMemo(() => uniqueId("hook"), []);
2173
+ const { id, eventsStore } = useImperativeComponentContext();
2174
+ const hasRegistered = useRef(false);
2175
+ const registerEvents = useCallback(() => {
2176
+ Object.entries(handlers).forEach(([name, callback]) => {
2177
+ if (!eventsStore[id])
2178
+ eventsStore[id] = {};
2179
+ if (!eventsStore[id][name])
2180
+ eventsStore[id][name] = [];
2181
+ eventsStore[id][name]?.push({
2182
+ cb: callback,
2183
+ uniqueHookId
2184
+ });
2185
+ });
2186
+ }, [eventsStore, handlers, id, uniqueHookId]);
2187
+ useEffect(() => {
2188
+ registerEvents();
2189
+ return () => {
2190
+ hasRegistered.current = false;
2191
+ Object.entries(handlers).forEach(([name]) => {
2192
+ eventsStore[id][name] = (eventsStore[id][name] ?? []).filter((current) => current.uniqueHookId !== uniqueHookId);
2193
+ });
2194
+ };
2195
+ }, [eventsStore, handlers, id, registerEvents, uniqueHookId]);
2196
+ return uniqueHookId;
2197
+ };
2198
+ var useImperativeComponentEvents$1 = useImperativeComponentEvents;
2199
+
2200
+ const formatMessage = (str, obj) => {
2201
+ let newStr = str;
2202
+ Object.entries(obj).forEach(([key, value]) => {
2203
+ const placeHolder = `<${key}>`;
2204
+ if (newStr?.includes(placeHolder)) {
2205
+ newStr = newStr.replace(placeHolder, value ?? "");
2206
+ }
2207
+ });
2208
+ return newStr;
2209
+ };
2210
+
2211
+ function getLabel(name, replaceTokens) {
2212
+ const label = {
2213
+ ...window.labels[name] ?? {
2214
+ text: `Not preloaded: ${name}`,
2215
+ tooltip: `Not preloaded: ${name}`
2216
+ }
2217
+ };
2218
+ if (replaceTokens?.text !== void 0)
2219
+ label.text = formatMessage(label.text, replaceTokens.text);
2220
+ if (replaceTokens?.title !== void 0)
2221
+ label.tooltip = formatMessage(label.tooltip, replaceTokens.title);
2222
+ return label;
2223
+ }
2224
+
2225
+ function getValueByPath(obj, path, separator = ".") {
2226
+ const actualPath = typeof path === "string" ? path.split(separator) : path;
2227
+ if (typeof obj !== "object" || !obj) {
2228
+ if (actualPath.length === 0)
2229
+ return obj;
2230
+ return void 0;
2231
+ }
2232
+ const currentStep = actualPath.shift();
2233
+ if (actualPath.length === 0)
2234
+ return obj[currentStep];
2235
+ return getValueByPath(
2236
+ obj[currentStep],
2237
+ actualPath,
2238
+ separator
2239
+ );
2240
+ }
2241
+
2242
+ function setValueByPath(obj, path, value) {
2243
+ if (path === "")
2244
+ return value;
2245
+ const steps = path.split(".");
2246
+ if (steps.length === 0) {
2247
+ console.warn(`An empty path was provoided ${path}`);
2248
+ return null;
2249
+ }
2250
+ const originalClonedObject = clone(obj ?? {});
2251
+ let currentObj = originalClonedObject;
2252
+ for (let i = 0; i < steps.length - 1; i++) {
2253
+ if (!currentObj[steps[i]])
2254
+ currentObj[steps[i]] = {};
2255
+ if (typeof currentObj[steps[i]] === "object") {
2256
+ currentObj = currentObj[steps[i]];
2257
+ } else {
2258
+ console.info({
2259
+ originalObject: obj,
2260
+ originalPath: path,
2261
+ currentObj,
2262
+ currentStep: steps[i]
2263
+ });
2264
+ throw new Error(
2265
+ `The provided path ${path} cannot be applied due to it is not an object's path.`
2266
+ );
2267
+ }
2268
+ }
2269
+ currentObj[steps.pop()] = value;
2270
+ return originalClonedObject;
2271
+ }
2272
+
2273
+ const propsLog = "propsLog";
2274
+ const PropsSelectorUndefinedObject = {};
2275
+ class PropsStore {
2276
+ constructor(configuration) {
2277
+ this.configuration = configuration;
2278
+ this.log = persistentStorage$1[propsLog];
2279
+ this.fields = {};
2280
+ this.suscriptors = {};
2281
+ this.loggers = {
2282
+ propsLog: ([log]) => {
2283
+ this.log = log;
2284
+ persistentStorage$1[propsLog] = log;
2285
+ },
2286
+ propsStore: ([fieldId]) => {
2287
+ if (fieldId)
2288
+ console.info(this.fields[fieldId]);
2289
+ else
2290
+ console.info(this.fields);
2291
+ },
2292
+ propsSuscriptors: ([fieldId]) => {
2293
+ if (fieldId)
2294
+ console.info(this.suscriptors[fieldId]);
2295
+ else
2296
+ console.info(this.suscriptors);
2297
+ },
2298
+ updateProp: ([fieldId, newProps]) => {
2299
+ this.updateField(fieldId, newProps);
2300
+ }
2301
+ };
2302
+ if (this.configuration) {
2303
+ if (this.configuration.logCommands.propsStore)
2304
+ debugDispatcher.on(
2305
+ this.configuration.logCommands.propsStore,
2306
+ this.loggers.propsStore,
2307
+ "Muestra el contenido actual del propsStore"
2308
+ );
2309
+ if (this.configuration.logCommands.updateProp)
2310
+ debugDispatcher.on(
2311
+ this.configuration.logCommands.updateProp,
2312
+ this.loggers.updateProp,
2313
+ "dd.updateProp(fieldId, newProps). El objeto newProps ser\xE1 mergeado sobre las props actuales"
2314
+ );
2315
+ if (this.configuration.logCommands.propsSuscriptors)
2316
+ debugDispatcher.on(
2317
+ this.configuration.logCommands.propsSuscriptors,
2318
+ this.loggers.propsSuscriptors,
2319
+ "Muestra los suscriptores actuales del propsStore"
2320
+ );
2321
+ if (this.configuration.logCommands.propsLog)
2322
+ debugDispatcher.on(
2323
+ this.configuration.logCommands.propsLog,
2324
+ this.loggers.propsLog,
2325
+ "Si se pasa como true, hace log de las acciones. Si se pasa como trace(fieldId), se hace log de todas las acciones y trace del campo especificado. Si se pasa trace(), hace log y trace de todas las acciones."
2326
+ );
2327
+ }
2328
+ }
2329
+ destructor() {
2330
+ if (this.configuration) {
2331
+ if (this.configuration.logCommands.propsStore)
2332
+ debugDispatcher.off(
2333
+ this.configuration.logCommands.propsStore,
2334
+ this.loggers.propsStore
2335
+ );
2336
+ if (this.configuration.logCommands.updateProp)
2337
+ debugDispatcher.off(
2338
+ this.configuration.logCommands.updateProp,
2339
+ this.loggers.updateProp
2340
+ );
2341
+ if (this.configuration.logCommands.propsSuscriptors)
2342
+ debugDispatcher.off(
2343
+ this.configuration.logCommands.propsSuscriptors,
2344
+ this.loggers.propsSuscriptors
2345
+ );
2346
+ if (this.configuration.logCommands.propsLog)
2347
+ debugDispatcher.off(
2348
+ this.configuration.logCommands.propsLog,
2349
+ this.loggers.propsLog
2350
+ );
2351
+ }
2352
+ }
2353
+ getAllFields() {
2354
+ return cloneDeep(this.fields);
2355
+ }
2356
+ /**
2357
+ * Devuelve los props actuales de un campo.
2358
+ */
2359
+ getFieldProps(fieldId) {
2360
+ return this.fields[fieldId];
2361
+ }
2362
+ removeField(fieldId) {
2363
+ this.suscriptors[fieldId] = [];
2364
+ delete this.fields[fieldId];
2365
+ if (this.log)
2366
+ console.info(`propsStore: removeNode ${fieldId}`);
2367
+ }
2368
+ /**
2369
+ * Permite establecer un suscriptor que será llamado
2370
+ * cada vez que las props del campo especificado cambien.
2371
+ */
2372
+ suscribe(fieldId, callback) {
2373
+ if (!this.suscriptors[fieldId])
2374
+ this.suscriptors[fieldId] = [];
2375
+ this.suscriptors[fieldId].push(callback);
2376
+ callback(this.fields[fieldId] ?? PropsSelectorUndefinedObject);
2377
+ return () => {
2378
+ this.suscriptors[fieldId] = this.suscriptors[fieldId].filter(
2379
+ (current) => {
2380
+ return current !== callback;
2381
+ }
2382
+ );
2383
+ };
2384
+ }
2385
+ /**
2386
+ * Actualiza o crea las props de un campo.
2387
+ *
2388
+ * La tercera prop está relacionada
2389
+ */
2390
+ updateField(fieldId, props, conf) {
2391
+ if (fieldId === void 0)
2392
+ return;
2393
+ const { noEmit, isUrgent } = conf ?? {};
2394
+ const newProps = { ...this.fields[fieldId], ...props };
2395
+ this.fields[fieldId] = newProps;
2396
+ if (this.log === true || this.log === fieldId)
2397
+ console.info({ fieldId, props });
2398
+ if (this.log === "trace")
2399
+ console.trace();
2400
+ else {
2401
+ const logId = typeof this.log === "string" && (this.log.match(/trace\(([^)]+)\)/) ?? [])[1];
2402
+ if (fieldId === logId)
2403
+ console.trace();
2404
+ }
2405
+ if (!noEmit) {
2406
+ this.suscriptors[fieldId]?.forEach((current) => {
2407
+ return current(newProps, isUrgent);
2408
+ });
2409
+ this.suscriptors.any?.forEach((current) => {
2410
+ return current({ ...newProps, fieldId }, isUrgent);
2411
+ });
2412
+ }
2413
+ }
2414
+ }
2415
+ const propsStore = new PropsStore({
2416
+ logCommands: {
2417
+ propsLog: "propsLog",
2418
+ propsStore: "propsStore",
2419
+ propsSuscriptors: "propsSuscriptors",
2420
+ updateProp: "updateProp"
2421
+ }
2422
+ });
2423
+
2424
+ const defaultComparator = (a, b) => {
2425
+ return a === b;
2426
+ };
2427
+ function getDefaultSelector() {
2428
+ return (current) => {
2429
+ return current;
2430
+ };
2431
+ }
2432
+ function isPropsConfigurationObject(value) {
2433
+ return typeof value === "object" && value && ("selector" in value || "comparator" in value || "initialValue" in value);
2434
+ }
2435
+ function usePropsSelector(fieldId, par1, par2, par3) {
2436
+ const selector = React__default.useMemo(
2437
+ () => {
2438
+ return isPropsConfigurationObject(par1) ? par1.selector : par1;
2439
+ },
2440
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2441
+ []
2442
+ );
2443
+ const comparator = React__default.useMemo(
2444
+ () => {
2445
+ return isPropsConfigurationObject(par1) ? par1.comparator : par2;
2446
+ },
2447
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2448
+ []
2449
+ );
2450
+ const initialValue = React__default.useMemo(
2451
+ () => {
2452
+ return isPropsConfigurationObject(par1) ? par1.initialValue : void 0;
2453
+ },
2454
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2455
+ []
2456
+ );
2457
+ const actualPropsStore = React__default.useMemo(
2458
+ () => {
2459
+ return par3 ?? (isPropsConfigurationObject(par1) ? par1.propsStore : propsStore) ?? propsStore;
2460
+ },
2461
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2462
+ [
2463
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2464
+ par3 ?? (isPropsConfigurationObject(par1) ? par1.propsStore : propsStore) ?? propsStore
2465
+ ]
2466
+ );
2467
+ const getCurrentProps = React__default.useCallback(() => {
2468
+ const currentProps = actualPropsStore.getFieldProps(fieldId);
2469
+ const willSetInitialValue = currentProps !== void 0 && initialValue !== void 0;
2470
+ if (willSetInitialValue) {
2471
+ actualPropsStore.updateField(
2472
+ fieldId,
2473
+ initialValue
2474
+ );
2475
+ }
2476
+ return (selector ?? getDefaultSelector())(
2477
+ currentProps ?? PropsSelectorUndefinedObject
2478
+ );
2479
+ }, []);
2480
+ const [props, setProps] = React__default.useState(getCurrentProps);
2481
+ const prevProps = useRef(props);
2482
+ const prevFieldId = useRef(fieldId);
2483
+ React__default.useEffect(() => {
2484
+ const unsuscribe = actualPropsStore.suscribe(
2485
+ fieldId,
2486
+ (newProps, isUrgent) => {
2487
+ const newSelectedProps = (selector ?? getDefaultSelector())(
2488
+ newProps
2489
+ );
2490
+ if (!(comparator ?? defaultComparator)(
2491
+ prevProps.current,
2492
+ newSelectedProps
2493
+ ) || prevFieldId.current !== fieldId) {
2494
+ if (isUrgent)
2495
+ setProps(newSelectedProps);
2496
+ else
2497
+ React__default.startTransition(() => {
2498
+ setProps(newSelectedProps);
2499
+ });
2500
+ }
2501
+ prevProps.current = newSelectedProps;
2502
+ }
2503
+ );
2504
+ return () => {
2505
+ unsuscribe();
2506
+ };
2507
+ }, [fieldId, actualPropsStore, selector, comparator]);
2508
+ return props;
2509
+ }
2510
+
2511
+ function assignProps(el, { style, ...props }) {
2512
+ if (style) {
2513
+ Object.entries(style).forEach(([name, value]) => {
2514
+ el.style[name] = value;
2515
+ });
2516
+ }
2517
+ Object.assign(el, props);
2518
+ }
2519
+ function useDomState(initialDomProps) {
2520
+ const domProps = React__default.useRef({
2521
+ ...initialDomProps ?? {},
2522
+ ref: React__default.useCallback((el) => {
2523
+ ref.current = el;
2524
+ assignProps(ref.current, domProps.current);
2525
+ }, [])
2526
+ });
2527
+ const ref = React__default.useRef(null);
2528
+ return {
2529
+ domProps: domProps.current,
2530
+ setDomProps: React__default.useCallback(({ style, ...newDomProps }) => {
2531
+ if (style) {
2532
+ const newStyles = { ...domProps.current.style, ...style };
2533
+ domProps.current.style = newStyles;
2534
+ }
2535
+ Object.assign(domProps.current, newDomProps);
2536
+ if (ref.current)
2537
+ assignProps(ref.current, domProps.current);
2538
+ }, [])
2539
+ };
2540
+ }
2541
+
2542
+ function useDebouncedState(timeout, initialState) {
2543
+ const [state, innerSetState] = useState(initialState);
2544
+ const t = useRef(-1);
2545
+ const setState = useCallback(
2546
+ (newState, immediate) => {
2547
+ clearTimeout(t.current);
2548
+ if (immediate)
2549
+ innerSetState(newState);
2550
+ else
2551
+ t.current = setTimeout(() => {
2552
+ innerSetState(newState);
2553
+ }, timeout);
2554
+ },
2555
+ [timeout]
2556
+ );
2557
+ return [state, setState];
2558
+ }
2559
+
2560
+ function alignment(a, b) {
2561
+ const m = a.length;
2562
+ const n = b.length;
2563
+ const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
2564
+ for (let i = 0; i <= m; i++)
2565
+ dp[i][0] = i;
2566
+ for (let j = 0; j <= n; j++)
2567
+ dp[0][j] = j;
2568
+ for (let i = 1; i <= m; i++) {
2569
+ for (let j = 1; j <= n; j++) {
2570
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
2571
+ dp[i][j] = Math.min(
2572
+ dp[i - 1][j] + 1,
2573
+ // deletion
2574
+ dp[i][j - 1] + 1,
2575
+ // insertion
2576
+ dp[i - 1][j - 1] + cost
2577
+ // substitution
2578
+ );
2579
+ }
2580
+ }
2581
+ return dp[m][n];
2582
+ }
2583
+
2584
+ function ucfirst(word) {
2585
+ return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
2586
+ }
2587
+
2588
+ function toBoolean(value) {
2589
+ if (typeof value === "string") {
2590
+ return !["false", ""].includes(value.toLowerCase());
2591
+ }
2592
+ if (Array.isArray(value))
2593
+ return value.length > 0;
2594
+ return !!value;
2595
+ }
2596
+
2597
+ const processAjaxEventTagNames = (name) => {
2598
+ return name;
2599
+ };
2600
+ const processAjaxEventAttrNames = (name) => {
2601
+ return name;
2602
+ };
2603
+ const processAjaxEventResponse = (value, name) => {
2604
+ if (name === "v" && value === "T")
2605
+ return true;
2606
+ if (name === "v" && value === "F")
2607
+ return false;
2608
+ return value;
2609
+ };
2610
+ const processStringObj = (value, key) => {
2611
+ if (key === "value" && typeof value === "number" && Number.isNaN(value)) {
2612
+ return "";
2613
+ }
2614
+ if (key === "valueType" && typeof value === "string" && value === "null") {
2615
+ return "";
2616
+ }
2617
+ if ((key === "cols" || key === "rows" || key === "x" || key === "y" || key === "length") && typeof value === "string") {
2618
+ return parseNumbers(value);
2619
+ }
2620
+ return value;
2621
+ };
2622
+ const parseXmlAsync = async (xml) => {
2623
+ const parser = new xml2js.Parser({
2624
+ trim: true,
2625
+ normalize: true,
2626
+ explicitRoot: false,
2627
+ mergeAttrs: true,
2628
+ explicitArray: false,
2629
+ charkey: "content",
2630
+ attrValueProcessors: [
2631
+ parseBooleans,
2632
+ processStringObj,
2633
+ processAjaxEventResponse
2634
+ ],
2635
+ tagNameProcessors: [processAjaxEventTagNames],
2636
+ attrNameProcessors: [processAjaxEventAttrNames]
2637
+ });
2638
+ const result = await new Promise((resolve, reject) => {
2639
+ parser.parseString(xml, (err, innerResult) => {
2640
+ if (err)
2641
+ reject(err);
2642
+ else {
2643
+ resolve(innerResult);
2644
+ }
2645
+ });
2646
+ });
2647
+ return result;
2648
+ };
2649
+
2650
+ export { BasicStoredElement, BouncingEmitter, EventEmitter, History, PropsSelectorUndefinedObject, PropsStore, StatefulEmitter, Url, addBoundary, alignment, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, cantFocusSelector, customEvents, dateToApiaFormat, debugDispatcher, decodeHTMLEntities, decrypt, defaultGetNameFromResponse, disableChildrenFocus, downloadStringAsDoc, downloadUrl, enableChildrenFocus, encrypt, findOffsetRelativeToScrollParent, findScrollContainer, focus, focusSelector, formatMessage, getDateFormat, getFocusSelector, getIndex, getLabel, getSpecificParent, getValueByPath, globalFocus, isChild, isDebugDispatcherEnabled, isPropsConfigurationObject, isSetter, makeImperativeComponent, makeSingleImperativeComponent, makeStatefulStore, noNaN, notificationsSelector, openAndReadFile, parseAsSize, parseXmlAsync, persistentStorage$1 as persistentStorage, propsStore, screenLocker, scrollParentIntoElement, setValueByPath, shallowCompareArrays, shallowEqual, shortcutController, toBoolean, ucfirst, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents$1 as useImperativeComponentEvents, useIntermediateValue, useLatest, useLocalStorage, useMount, usePanAndZoom, usePrevious, usePropsSelector, useShallowMemo, useStateRef, useSubscription, useUnmount, useUpdateEffect, useWhyUpdated };
63
2651
  //# sourceMappingURL=index.js.map