lecom-ui 5.4.23 → 5.4.25

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 (348) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_commonjsHelpers.js +5 -0
  3. package/dist/_virtual/index.js +7 -0
  4. package/dist/components/Collapse/Collapse.js +100 -66
  5. package/dist/components/Combobox/Combobox.js +148 -34
  6. package/dist/components/DataTable/DataTable.js +2 -2
  7. package/dist/components/DataTable/DataTable.utils.js +1 -1
  8. package/dist/components/DataTable/Table.js +1 -1
  9. package/dist/components/Header/SearchInput.js +1 -4
  10. package/dist/components/Input/Input.js +2 -2
  11. package/dist/components/MultiSelect/MultiSelect.js +5 -8
  12. package/dist/components/Table/Table.js +80 -0
  13. package/dist/hooks/use-mobile.js +20 -0
  14. package/dist/i18n/locales/en_us.js +3 -2
  15. package/dist/i18n/locales/es_es.js +2 -1
  16. package/dist/i18n/locales/pt_br.js +2 -1
  17. package/dist/index.d.ts +13 -13
  18. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +806 -0
  19. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +726 -0
  20. package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +347 -0
  21. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +154 -0
  22. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +136 -0
  23. package/dist/node_modules/@radix-ui/number/dist/index.js +6 -0
  24. package/dist/node_modules/@radix-ui/primitive/dist/index.js +11 -0
  25. package/dist/node_modules/@radix-ui/react-accordion/dist/index.js +303 -0
  26. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-collapsible/dist/index.js +144 -0
  27. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-collection/dist/index.js +68 -0
  28. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
  29. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-context/dist/index.js +63 -0
  30. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-direction/dist/index.js +11 -0
  31. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-id/dist/index.js +15 -0
  32. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-presence/dist/index.js +130 -0
  33. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-primitive/dist/index.js +38 -0
  34. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
  35. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +46 -0
  36. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
  37. package/dist/node_modules/@radix-ui/react-arrow/dist/index.js +25 -0
  38. package/dist/node_modules/@radix-ui/react-checkbox/dist/index.js +157 -0
  39. package/dist/node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
  40. package/dist/node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-context/dist/index.js +63 -0
  41. package/dist/node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-presence/dist/index.js +130 -0
  42. package/dist/node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-primitive/dist/index.js +38 -0
  43. package/dist/node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
  44. package/dist/node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +46 -0
  45. package/dist/node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
  46. package/dist/node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-use-previous/dist/index.js +15 -0
  47. package/dist/node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-use-size/dist/index.js +40 -0
  48. package/dist/node_modules/@radix-ui/react-collapsible/dist/index.js +144 -0
  49. package/dist/node_modules/@radix-ui/react-collection/dist/index.js +68 -0
  50. package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
  51. package/dist/node_modules/@radix-ui/react-context/dist/index.js +79 -0
  52. package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +319 -0
  53. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
  54. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-context/dist/index.js +79 -0
  55. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +211 -0
  56. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-focus-guards/dist/index.js +29 -0
  57. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-focus-scope/dist/index.js +207 -0
  58. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-id/dist/index.js +15 -0
  59. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-portal/dist/index.js +17 -0
  60. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-presence/dist/index.js +130 -0
  61. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-primitive/dist/index.js +41 -0
  62. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
  63. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +46 -0
  64. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +18 -0
  65. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
  66. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll/dist/es2015/Combination.js +9 -0
  67. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +160 -0
  68. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll/dist/es2015/UI.js +38 -0
  69. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +21 -0
  70. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +109 -0
  71. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll/dist/es2015/medium.js +5 -0
  72. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll/dist/es2015/sidecar.js +7 -0
  73. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll-bar/dist/es2015/component.js +56 -0
  74. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +10 -0
  75. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +31 -0
  76. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-style-singleton/dist/es2015/component.js +19 -0
  77. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-style-singleton/dist/es2015/hook.js +25 -0
  78. package/dist/node_modules/@radix-ui/react-dialog/node_modules/react-style-singleton/dist/es2015/singleton.js +51 -0
  79. package/dist/node_modules/@radix-ui/react-dialog/node_modules/use-callback-ref/dist/es2015/assignRef.js +24 -0
  80. package/dist/node_modules/@radix-ui/react-dialog/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +48 -0
  81. package/dist/node_modules/@radix-ui/react-dialog/node_modules/use-callback-ref/dist/es2015/useRef.js +42 -0
  82. package/dist/node_modules/@radix-ui/react-dialog/node_modules/use-sidecar/dist/es2015/exports.js +21 -0
  83. package/dist/node_modules/@radix-ui/react-dialog/node_modules/use-sidecar/dist/es2015/medium.js +77 -0
  84. package/dist/node_modules/@radix-ui/react-direction/dist/index.js +11 -0
  85. package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +211 -0
  86. package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +265 -0
  87. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +347 -0
  88. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-arrow/dist/index.js +25 -0
  89. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-collection/dist/index.js +68 -0
  90. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
  91. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-context/dist/index.js +63 -0
  92. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-direction/dist/index.js +11 -0
  93. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +211 -0
  94. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-focus-guards/dist/index.js +29 -0
  95. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-focus-scope/dist/index.js +207 -0
  96. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-id/dist/index.js +15 -0
  97. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-menu/dist/index.js +831 -0
  98. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-popper/dist/index.js +278 -0
  99. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-portal/dist/index.js +17 -0
  100. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-presence/dist/index.js +130 -0
  101. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-primitive/dist/index.js +41 -0
  102. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-roving-focus/dist/index.js +220 -0
  103. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
  104. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +46 -0
  105. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +18 -0
  106. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
  107. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-use-size/dist/index.js +40 -0
  108. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-remove-scroll/dist/es2015/Combination.js +9 -0
  109. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +160 -0
  110. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-remove-scroll/dist/es2015/UI.js +38 -0
  111. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +21 -0
  112. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +109 -0
  113. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-remove-scroll/dist/es2015/medium.js +5 -0
  114. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-remove-scroll/dist/es2015/sidecar.js +7 -0
  115. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-remove-scroll-bar/dist/es2015/component.js +56 -0
  116. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +10 -0
  117. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +31 -0
  118. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-style-singleton/dist/es2015/component.js +19 -0
  119. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-style-singleton/dist/es2015/hook.js +25 -0
  120. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/react-style-singleton/dist/es2015/singleton.js +51 -0
  121. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/use-callback-ref/dist/es2015/assignRef.js +24 -0
  122. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +48 -0
  123. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/use-callback-ref/dist/es2015/useRef.js +42 -0
  124. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/use-sidecar/dist/es2015/exports.js +21 -0
  125. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/use-sidecar/dist/es2015/medium.js +77 -0
  126. package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +29 -0
  127. package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +207 -0
  128. package/dist/node_modules/@radix-ui/react-id/dist/index.js +15 -0
  129. package/dist/node_modules/@radix-ui/react-menu/dist/index.js +831 -0
  130. package/dist/node_modules/@radix-ui/react-popover/dist/index.js +296 -0
  131. package/dist/node_modules/@radix-ui/react-popover/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +347 -0
  132. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-arrow/dist/index.js +25 -0
  133. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
  134. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-context/dist/index.js +63 -0
  135. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +211 -0
  136. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-focus-guards/dist/index.js +29 -0
  137. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-focus-scope/dist/index.js +207 -0
  138. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-id/dist/index.js +15 -0
  139. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-popper/dist/index.js +278 -0
  140. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-portal/dist/index.js +17 -0
  141. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-presence/dist/index.js +130 -0
  142. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-primitive/dist/index.js +41 -0
  143. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
  144. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +46 -0
  145. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +18 -0
  146. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
  147. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-use-size/dist/index.js +40 -0
  148. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-remove-scroll/dist/es2015/Combination.js +9 -0
  149. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +160 -0
  150. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-remove-scroll/dist/es2015/UI.js +38 -0
  151. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +21 -0
  152. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +109 -0
  153. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-remove-scroll/dist/es2015/medium.js +5 -0
  154. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-remove-scroll/dist/es2015/sidecar.js +7 -0
  155. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-remove-scroll-bar/dist/es2015/component.js +56 -0
  156. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +10 -0
  157. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +31 -0
  158. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-style-singleton/dist/es2015/component.js +19 -0
  159. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-style-singleton/dist/es2015/hook.js +25 -0
  160. package/dist/node_modules/@radix-ui/react-popover/node_modules/react-style-singleton/dist/es2015/singleton.js +51 -0
  161. package/dist/node_modules/@radix-ui/react-popover/node_modules/use-callback-ref/dist/es2015/assignRef.js +24 -0
  162. package/dist/node_modules/@radix-ui/react-popover/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +48 -0
  163. package/dist/node_modules/@radix-ui/react-popover/node_modules/use-callback-ref/dist/es2015/useRef.js +42 -0
  164. package/dist/node_modules/@radix-ui/react-popover/node_modules/use-sidecar/dist/es2015/exports.js +21 -0
  165. package/dist/node_modules/@radix-ui/react-popover/node_modules/use-sidecar/dist/es2015/medium.js +77 -0
  166. package/dist/node_modules/@radix-ui/react-popper/dist/index.js +278 -0
  167. package/dist/node_modules/@radix-ui/react-portal/dist/index.js +17 -0
  168. package/dist/node_modules/@radix-ui/react-presence/dist/index.js +130 -0
  169. package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +41 -0
  170. package/dist/node_modules/@radix-ui/react-radio-group/dist/index.js +267 -0
  171. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-collection/dist/index.js +68 -0
  172. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
  173. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-context/dist/index.js +63 -0
  174. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-direction/dist/index.js +11 -0
  175. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-id/dist/index.js +15 -0
  176. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-presence/dist/index.js +130 -0
  177. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-primitive/dist/index.js +38 -0
  178. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-roving-focus/dist/index.js +220 -0
  179. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
  180. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +46 -0
  181. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
  182. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-use-previous/dist/index.js +15 -0
  183. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-use-size/dist/index.js +40 -0
  184. package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.js +220 -0
  185. package/dist/node_modules/@radix-ui/react-scroll-area/dist/index.js +718 -0
  186. package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
  187. package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-context/dist/index.js +63 -0
  188. package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-direction/dist/index.js +11 -0
  189. package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-presence/dist/index.js +130 -0
  190. package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-primitive/dist/index.js +38 -0
  191. package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
  192. package/dist/node_modules/@radix-ui/react-scroll-area/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
  193. package/dist/node_modules/@radix-ui/react-select/dist/index.js +1143 -0
  194. package/dist/node_modules/@radix-ui/react-select/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +347 -0
  195. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-arrow/dist/index.js +25 -0
  196. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-collection/dist/index.js +68 -0
  197. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
  198. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-context/dist/index.js +63 -0
  199. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-direction/dist/index.js +11 -0
  200. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +211 -0
  201. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-focus-guards/dist/index.js +29 -0
  202. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-focus-scope/dist/index.js +207 -0
  203. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-id/dist/index.js +15 -0
  204. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-popper/dist/index.js +278 -0
  205. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-portal/dist/index.js +17 -0
  206. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-primitive/dist/index.js +41 -0
  207. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
  208. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +46 -0
  209. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +18 -0
  210. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
  211. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-use-previous/dist/index.js +15 -0
  212. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-use-size/dist/index.js +40 -0
  213. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-visually-hidden/dist/index.js +34 -0
  214. package/dist/node_modules/@radix-ui/react-select/node_modules/react-remove-scroll/dist/es2015/Combination.js +9 -0
  215. package/dist/node_modules/@radix-ui/react-select/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +160 -0
  216. package/dist/node_modules/@radix-ui/react-select/node_modules/react-remove-scroll/dist/es2015/UI.js +38 -0
  217. package/dist/node_modules/@radix-ui/react-select/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +21 -0
  218. package/dist/node_modules/@radix-ui/react-select/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +109 -0
  219. package/dist/node_modules/@radix-ui/react-select/node_modules/react-remove-scroll/dist/es2015/medium.js +5 -0
  220. package/dist/node_modules/@radix-ui/react-select/node_modules/react-remove-scroll/dist/es2015/sidecar.js +7 -0
  221. package/dist/node_modules/@radix-ui/react-select/node_modules/react-remove-scroll-bar/dist/es2015/component.js +56 -0
  222. package/dist/node_modules/@radix-ui/react-select/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +10 -0
  223. package/dist/node_modules/@radix-ui/react-select/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +31 -0
  224. package/dist/node_modules/@radix-ui/react-select/node_modules/react-style-singleton/dist/es2015/component.js +19 -0
  225. package/dist/node_modules/@radix-ui/react-select/node_modules/react-style-singleton/dist/es2015/hook.js +25 -0
  226. package/dist/node_modules/@radix-ui/react-select/node_modules/react-style-singleton/dist/es2015/singleton.js +51 -0
  227. package/dist/node_modules/@radix-ui/react-select/node_modules/use-callback-ref/dist/es2015/assignRef.js +24 -0
  228. package/dist/node_modules/@radix-ui/react-select/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +48 -0
  229. package/dist/node_modules/@radix-ui/react-select/node_modules/use-callback-ref/dist/es2015/useRef.js +42 -0
  230. package/dist/node_modules/@radix-ui/react-select/node_modules/use-sidecar/dist/es2015/exports.js +21 -0
  231. package/dist/node_modules/@radix-ui/react-select/node_modules/use-sidecar/dist/es2015/medium.js +77 -0
  232. package/dist/node_modules/@radix-ui/react-separator/dist/index.js +30 -0
  233. package/dist/node_modules/@radix-ui/react-separator/node_modules/@radix-ui/react-primitive/dist/index.js +38 -0
  234. package/dist/node_modules/@radix-ui/react-slot/dist/index.js +81 -0
  235. package/dist/node_modules/@radix-ui/react-slot/node_modules/@radix-ui/react-compose-refs/dist/index.js +36 -0
  236. package/dist/node_modules/@radix-ui/react-switch/dist/index.js +137 -0
  237. package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
  238. package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-context/dist/index.js +63 -0
  239. package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-primitive/dist/index.js +38 -0
  240. package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
  241. package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +46 -0
  242. package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
  243. package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-use-previous/dist/index.js +15 -0
  244. package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-use-size/dist/index.js +40 -0
  245. package/dist/node_modules/@radix-ui/react-tooltip/dist/index.js +484 -0
  246. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +347 -0
  247. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-arrow/dist/index.js +25 -0
  248. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
  249. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-context/dist/index.js +63 -0
  250. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +211 -0
  251. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-id/dist/index.js +15 -0
  252. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-popper/dist/index.js +278 -0
  253. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-portal/dist/index.js +17 -0
  254. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-presence/dist/index.js +130 -0
  255. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-primitive/dist/index.js +41 -0
  256. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
  257. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +46 -0
  258. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +18 -0
  259. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
  260. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-use-size/dist/index.js +40 -0
  261. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-visually-hidden/dist/index.js +35 -0
  262. package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
  263. package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +46 -0
  264. package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +18 -0
  265. package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
  266. package/dist/node_modules/@radix-ui/react-use-previous/dist/index.js +15 -0
  267. package/dist/node_modules/@radix-ui/react-use-size/dist/index.js +40 -0
  268. package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.js +35 -0
  269. package/dist/node_modules/@tanstack/react-table/build/lib/index.js +74 -0
  270. package/dist/node_modules/@tanstack/table-core/build/lib/index.js +3023 -0
  271. package/dist/node_modules/aria-hidden/dist/es2015/index.js +136 -0
  272. package/dist/node_modules/class-variance-authority/dist/index.js +44 -0
  273. package/dist/node_modules/clsx/dist/clsx.js +3 -0
  274. package/dist/node_modules/get-nonce/dist/es2015/index.js +8 -0
  275. package/dist/node_modules/hex-color-opacity/lib/index.js +22 -0
  276. package/dist/node_modules/i18next/dist/esm/i18next.js +2228 -0
  277. package/dist/node_modules/lucide-react/dist/esm/Icon.js +44 -0
  278. package/dist/node_modules/lucide-react/dist/esm/createLucideIcon.js +26 -0
  279. package/dist/node_modules/lucide-react/dist/esm/defaultAttributes.js +20 -0
  280. package/dist/node_modules/lucide-react/dist/esm/icons/arrow-up-down.js +18 -0
  281. package/dist/node_modules/lucide-react/dist/esm/icons/check.js +13 -0
  282. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.js +15 -0
  283. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-first.js +16 -0
  284. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-last.js +16 -0
  285. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-left.js +15 -0
  286. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-right.js +15 -0
  287. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.js +13 -0
  288. package/dist/node_modules/lucide-react/dist/esm/icons/circle-alert.js +17 -0
  289. package/dist/node_modules/lucide-react/dist/esm/icons/circle-check.js +16 -0
  290. package/dist/node_modules/lucide-react/dist/esm/icons/circle-help.js +17 -0
  291. package/dist/node_modules/lucide-react/dist/esm/icons/circle.js +15 -0
  292. package/dist/node_modules/lucide-react/dist/esm/icons/ellipsis.js +17 -0
  293. package/dist/node_modules/lucide-react/dist/esm/icons/info.js +17 -0
  294. package/dist/node_modules/lucide-react/dist/esm/icons/menu.js +17 -0
  295. package/dist/node_modules/lucide-react/dist/esm/icons/message-square.js +15 -0
  296. package/dist/node_modules/lucide-react/dist/esm/icons/minus.js +13 -0
  297. package/dist/node_modules/lucide-react/dist/esm/icons/panel-left.js +16 -0
  298. package/dist/node_modules/lucide-react/dist/esm/icons/triangle-alert.js +23 -0
  299. package/dist/node_modules/lucide-react/dist/esm/icons/user.js +16 -0
  300. package/dist/node_modules/lucide-react/dist/esm/icons/x.js +16 -0
  301. package/dist/node_modules/lucide-react/dist/esm/shared/src/utils.js +13 -0
  302. package/dist/node_modules/react-i18next/dist/es/Translation.js +15 -0
  303. package/dist/node_modules/react-i18next/dist/es/context.js +18 -0
  304. package/dist/node_modules/react-i18next/dist/es/defaults.js +21 -0
  305. package/dist/node_modules/react-i18next/dist/es/i18nInstance.js +7 -0
  306. package/dist/node_modules/react-i18next/dist/es/initReactI18next.js +12 -0
  307. package/dist/node_modules/react-i18next/dist/es/unescape.js +27 -0
  308. package/dist/node_modules/react-i18next/dist/es/useTranslation.js +112 -0
  309. package/dist/node_modules/react-i18next/dist/es/utils.js +63 -0
  310. package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +9 -0
  311. package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +160 -0
  312. package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +38 -0
  313. package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +21 -0
  314. package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +109 -0
  315. package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +5 -0
  316. package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +7 -0
  317. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +56 -0
  318. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +10 -0
  319. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +31 -0
  320. package/dist/node_modules/react-style-singleton/dist/es2015/component.js +19 -0
  321. package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +25 -0
  322. package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +51 -0
  323. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +2493 -0
  324. package/dist/node_modules/tslib/tslib.es6.js +56 -0
  325. package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +24 -0
  326. package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +48 -0
  327. package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +42 -0
  328. package/dist/node_modules/use-color-luminance/index.es.js +105 -0
  329. package/dist/node_modules/use-sidecar/dist/es2015/exports.js +21 -0
  330. package/dist/node_modules/use-sidecar/dist/es2015/medium.js +77 -0
  331. package/dist/plugin/extend.js +79 -79
  332. package/dist/plugin/extend.ts +78 -0
  333. package/dist/plugin/fontFaces.js +172 -172
  334. package/dist/plugin/fontFaces.ts +172 -0
  335. package/dist/plugin/general.js +12 -12
  336. package/dist/plugin/general.ts +12 -0
  337. package/dist/plugin/plugin.cjs +7 -0
  338. package/dist/plugin/pluginDev.cjs +5 -5
  339. package/dist/plugin/pluginNextTurbo.cjs +5 -5
  340. package/dist/plugin/template.js +31 -31
  341. package/dist/plugin/template.ts +31 -0
  342. package/dist/plugin/typographies.js +152 -152
  343. package/dist/plugin/typographies.ts +152 -0
  344. package/dist/plugin/varsTheme.js +79 -79
  345. package/dist/plugin/varsTheme.ts +79 -0
  346. package/dist/style.min.css +1 -1
  347. package/package.json +1 -1
  348. package/dist/components/IconHandler/IconHandler.js +0 -99
@@ -0,0 +1,2228 @@
1
+ const isString = obj => typeof obj === 'string';
2
+ const defer = () => {
3
+ let res;
4
+ let rej;
5
+ const promise = new Promise((resolve, reject) => {
6
+ res = resolve;
7
+ rej = reject;
8
+ });
9
+ promise.resolve = res;
10
+ promise.reject = rej;
11
+ return promise;
12
+ };
13
+ const makeString = object => {
14
+ if (object == null) return '';
15
+ return '' + object;
16
+ };
17
+ const copy = (a, s, t) => {
18
+ a.forEach(m => {
19
+ if (s[m]) t[m] = s[m];
20
+ });
21
+ };
22
+ const lastOfPathSeparatorRegExp = /###/g;
23
+ const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
24
+ const canNotTraverseDeeper = object => !object || isString(object);
25
+ const getLastOfPath = (object, path, Empty) => {
26
+ const stack = !isString(path) ? path : path.split('.');
27
+ let stackIndex = 0;
28
+ while (stackIndex < stack.length - 1) {
29
+ if (canNotTraverseDeeper(object)) return {};
30
+ const key = cleanKey(stack[stackIndex]);
31
+ if (!object[key] && Empty) object[key] = new Empty();
32
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
33
+ object = object[key];
34
+ } else {
35
+ object = {};
36
+ }
37
+ ++stackIndex;
38
+ }
39
+ if (canNotTraverseDeeper(object)) return {};
40
+ return {
41
+ obj: object,
42
+ k: cleanKey(stack[stackIndex])
43
+ };
44
+ };
45
+ const setPath = (object, path, newValue) => {
46
+ const {
47
+ obj,
48
+ k
49
+ } = getLastOfPath(object, path, Object);
50
+ if (obj !== undefined || path.length === 1) {
51
+ obj[k] = newValue;
52
+ return;
53
+ }
54
+ let e = path[path.length - 1];
55
+ let p = path.slice(0, path.length - 1);
56
+ let last = getLastOfPath(object, p, Object);
57
+ while (last.obj === undefined && p.length) {
58
+ e = `${p[p.length - 1]}.${e}`;
59
+ p = p.slice(0, p.length - 1);
60
+ last = getLastOfPath(object, p, Object);
61
+ if (last?.obj && typeof last.obj[`${last.k}.${e}`] !== 'undefined') {
62
+ last.obj = undefined;
63
+ }
64
+ }
65
+ last.obj[`${last.k}.${e}`] = newValue;
66
+ };
67
+ const pushPath = (object, path, newValue, concat) => {
68
+ const {
69
+ obj,
70
+ k
71
+ } = getLastOfPath(object, path, Object);
72
+ obj[k] = obj[k] || [];
73
+ obj[k].push(newValue);
74
+ };
75
+ const getPath = (object, path) => {
76
+ const {
77
+ obj,
78
+ k
79
+ } = getLastOfPath(object, path);
80
+ if (!obj) return undefined;
81
+ if (!Object.prototype.hasOwnProperty.call(obj, k)) return undefined;
82
+ return obj[k];
83
+ };
84
+ const getPathWithDefaults = (data, defaultData, key) => {
85
+ const value = getPath(data, key);
86
+ if (value !== undefined) {
87
+ return value;
88
+ }
89
+ return getPath(defaultData, key);
90
+ };
91
+ const deepExtend = (target, source, overwrite) => {
92
+ for (const prop in source) {
93
+ if (prop !== '__proto__' && prop !== 'constructor') {
94
+ if (prop in target) {
95
+ if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
96
+ if (overwrite) target[prop] = source[prop];
97
+ } else {
98
+ deepExtend(target[prop], source[prop], overwrite);
99
+ }
100
+ } else {
101
+ target[prop] = source[prop];
102
+ }
103
+ }
104
+ }
105
+ return target;
106
+ };
107
+ const regexEscape = str => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
108
+ var _entityMap = {
109
+ '&': '&amp;',
110
+ '<': '&lt;',
111
+ '>': '&gt;',
112
+ '"': '&quot;',
113
+ "'": '&#39;',
114
+ '/': '&#x2F;'
115
+ };
116
+ const escape = data => {
117
+ if (isString(data)) {
118
+ return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
119
+ }
120
+ return data;
121
+ };
122
+ class RegExpCache {
123
+ constructor(capacity) {
124
+ this.capacity = capacity;
125
+ this.regExpMap = new Map();
126
+ this.regExpQueue = [];
127
+ }
128
+ getRegExp(pattern) {
129
+ const regExpFromCache = this.regExpMap.get(pattern);
130
+ if (regExpFromCache !== undefined) {
131
+ return regExpFromCache;
132
+ }
133
+ const regExpNew = new RegExp(pattern);
134
+ if (this.regExpQueue.length === this.capacity) {
135
+ this.regExpMap.delete(this.regExpQueue.shift());
136
+ }
137
+ this.regExpMap.set(pattern, regExpNew);
138
+ this.regExpQueue.push(pattern);
139
+ return regExpNew;
140
+ }
141
+ }
142
+ const chars = [' ', ',', '?', '!', ';'];
143
+ const looksLikeObjectPathRegExpCache = new RegExpCache(20);
144
+ const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
145
+ nsSeparator = nsSeparator || '';
146
+ keySeparator = keySeparator || '';
147
+ const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
148
+ if (possibleChars.length === 0) return true;
149
+ const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
150
+ let matched = !r.test(key);
151
+ if (!matched) {
152
+ const ki = key.indexOf(keySeparator);
153
+ if (ki > 0 && !r.test(key.substring(0, ki))) {
154
+ matched = true;
155
+ }
156
+ }
157
+ return matched;
158
+ };
159
+ const deepFind = function (obj, path) {
160
+ let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
161
+ if (!obj) return undefined;
162
+ if (obj[path]) {
163
+ if (!Object.prototype.hasOwnProperty.call(obj, path)) return undefined;
164
+ return obj[path];
165
+ }
166
+ const tokens = path.split(keySeparator);
167
+ let current = obj;
168
+ for (let i = 0; i < tokens.length;) {
169
+ if (!current || typeof current !== 'object') {
170
+ return undefined;
171
+ }
172
+ let next;
173
+ let nextPath = '';
174
+ for (let j = i; j < tokens.length; ++j) {
175
+ if (j !== i) {
176
+ nextPath += keySeparator;
177
+ }
178
+ nextPath += tokens[j];
179
+ next = current[nextPath];
180
+ if (next !== undefined) {
181
+ if (['string', 'number', 'boolean'].indexOf(typeof next) > -1 && j < tokens.length - 1) {
182
+ continue;
183
+ }
184
+ i += j - i + 1;
185
+ break;
186
+ }
187
+ }
188
+ current = next;
189
+ }
190
+ return current;
191
+ };
192
+ const getCleanedCode = code => code?.replace('_', '-');
193
+
194
+ const consoleLogger = {
195
+ type: 'logger',
196
+ log(args) {
197
+ this.output('log', args);
198
+ },
199
+ warn(args) {
200
+ this.output('warn', args);
201
+ },
202
+ error(args) {
203
+ this.output('error', args);
204
+ },
205
+ output(type, args) {
206
+ console?.[type]?.apply?.(console, args);
207
+ }
208
+ };
209
+ class Logger {
210
+ constructor(concreteLogger) {
211
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
212
+ this.init(concreteLogger, options);
213
+ }
214
+ init(concreteLogger) {
215
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
216
+ this.prefix = options.prefix || 'i18next:';
217
+ this.logger = concreteLogger || consoleLogger;
218
+ this.options = options;
219
+ this.debug = options.debug;
220
+ }
221
+ log() {
222
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
223
+ args[_key] = arguments[_key];
224
+ }
225
+ return this.forward(args, 'log', '', true);
226
+ }
227
+ warn() {
228
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
229
+ args[_key2] = arguments[_key2];
230
+ }
231
+ return this.forward(args, 'warn', '', true);
232
+ }
233
+ error() {
234
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
235
+ args[_key3] = arguments[_key3];
236
+ }
237
+ return this.forward(args, 'error', '');
238
+ }
239
+ deprecate() {
240
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
241
+ args[_key4] = arguments[_key4];
242
+ }
243
+ return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
244
+ }
245
+ forward(args, lvl, prefix, debugOnly) {
246
+ if (debugOnly && !this.debug) return null;
247
+ if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
248
+ return this.logger[lvl](args);
249
+ }
250
+ create(moduleName) {
251
+ return new Logger(this.logger, {
252
+ ...{
253
+ prefix: `${this.prefix}:${moduleName}:`
254
+ },
255
+ ...this.options
256
+ });
257
+ }
258
+ clone(options) {
259
+ options = options || this.options;
260
+ options.prefix = options.prefix || this.prefix;
261
+ return new Logger(this.logger, options);
262
+ }
263
+ }
264
+ var baseLogger = new Logger();
265
+
266
+ class EventEmitter {
267
+ constructor() {
268
+ this.observers = {};
269
+ }
270
+ on(events, listener) {
271
+ events.split(' ').forEach(event => {
272
+ if (!this.observers[event]) this.observers[event] = new Map();
273
+ const numListeners = this.observers[event].get(listener) || 0;
274
+ this.observers[event].set(listener, numListeners + 1);
275
+ });
276
+ return this;
277
+ }
278
+ off(event, listener) {
279
+ if (!this.observers[event]) return;
280
+ if (!listener) {
281
+ delete this.observers[event];
282
+ return;
283
+ }
284
+ this.observers[event].delete(listener);
285
+ }
286
+ emit(event) {
287
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
288
+ args[_key - 1] = arguments[_key];
289
+ }
290
+ if (this.observers[event]) {
291
+ const cloned = Array.from(this.observers[event].entries());
292
+ cloned.forEach(_ref => {
293
+ let [observer, numTimesAdded] = _ref;
294
+ for (let i = 0; i < numTimesAdded; i++) {
295
+ observer(...args);
296
+ }
297
+ });
298
+ }
299
+ if (this.observers['*']) {
300
+ const cloned = Array.from(this.observers['*'].entries());
301
+ cloned.forEach(_ref2 => {
302
+ let [observer, numTimesAdded] = _ref2;
303
+ for (let i = 0; i < numTimesAdded; i++) {
304
+ observer.apply(observer, [event, ...args]);
305
+ }
306
+ });
307
+ }
308
+ }
309
+ }
310
+
311
+ class ResourceStore extends EventEmitter {
312
+ constructor(data) {
313
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
314
+ ns: ['translation'],
315
+ defaultNS: 'translation'
316
+ };
317
+ super();
318
+ this.data = data || {};
319
+ this.options = options;
320
+ if (this.options.keySeparator === undefined) {
321
+ this.options.keySeparator = '.';
322
+ }
323
+ if (this.options.ignoreJSONStructure === undefined) {
324
+ this.options.ignoreJSONStructure = true;
325
+ }
326
+ }
327
+ addNamespaces(ns) {
328
+ if (this.options.ns.indexOf(ns) < 0) {
329
+ this.options.ns.push(ns);
330
+ }
331
+ }
332
+ removeNamespaces(ns) {
333
+ const index = this.options.ns.indexOf(ns);
334
+ if (index > -1) {
335
+ this.options.ns.splice(index, 1);
336
+ }
337
+ }
338
+ getResource(lng, ns, key) {
339
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
340
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
341
+ const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
342
+ let path;
343
+ if (lng.indexOf('.') > -1) {
344
+ path = lng.split('.');
345
+ } else {
346
+ path = [lng, ns];
347
+ if (key) {
348
+ if (Array.isArray(key)) {
349
+ path.push(...key);
350
+ } else if (isString(key) && keySeparator) {
351
+ path.push(...key.split(keySeparator));
352
+ } else {
353
+ path.push(key);
354
+ }
355
+ }
356
+ }
357
+ const result = getPath(this.data, path);
358
+ if (!result && !ns && !key && lng.indexOf('.') > -1) {
359
+ lng = path[0];
360
+ ns = path[1];
361
+ key = path.slice(2).join('.');
362
+ }
363
+ if (result || !ignoreJSONStructure || !isString(key)) return result;
364
+ return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
365
+ }
366
+ addResource(lng, ns, key, value) {
367
+ let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
368
+ silent: false
369
+ };
370
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
371
+ let path = [lng, ns];
372
+ if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
373
+ if (lng.indexOf('.') > -1) {
374
+ path = lng.split('.');
375
+ value = ns;
376
+ ns = path[1];
377
+ }
378
+ this.addNamespaces(ns);
379
+ setPath(this.data, path, value);
380
+ if (!options.silent) this.emit('added', lng, ns, key, value);
381
+ }
382
+ addResources(lng, ns, resources) {
383
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
384
+ silent: false
385
+ };
386
+ for (const m in resources) {
387
+ if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
388
+ silent: true
389
+ });
390
+ }
391
+ if (!options.silent) this.emit('added', lng, ns, resources);
392
+ }
393
+ addResourceBundle(lng, ns, resources, deep, overwrite) {
394
+ let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
395
+ silent: false,
396
+ skipCopy: false
397
+ };
398
+ let path = [lng, ns];
399
+ if (lng.indexOf('.') > -1) {
400
+ path = lng.split('.');
401
+ deep = resources;
402
+ resources = ns;
403
+ ns = path[1];
404
+ }
405
+ this.addNamespaces(ns);
406
+ let pack = getPath(this.data, path) || {};
407
+ if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
408
+ if (deep) {
409
+ deepExtend(pack, resources, overwrite);
410
+ } else {
411
+ pack = {
412
+ ...pack,
413
+ ...resources
414
+ };
415
+ }
416
+ setPath(this.data, path, pack);
417
+ if (!options.silent) this.emit('added', lng, ns, resources);
418
+ }
419
+ removeResourceBundle(lng, ns) {
420
+ if (this.hasResourceBundle(lng, ns)) {
421
+ delete this.data[lng][ns];
422
+ }
423
+ this.removeNamespaces(ns);
424
+ this.emit('removed', lng, ns);
425
+ }
426
+ hasResourceBundle(lng, ns) {
427
+ return this.getResource(lng, ns) !== undefined;
428
+ }
429
+ getResourceBundle(lng, ns) {
430
+ if (!ns) ns = this.options.defaultNS;
431
+ return this.getResource(lng, ns);
432
+ }
433
+ getDataByLanguage(lng) {
434
+ return this.data[lng];
435
+ }
436
+ hasLanguageSomeTranslations(lng) {
437
+ const data = this.getDataByLanguage(lng);
438
+ const n = data && Object.keys(data) || [];
439
+ return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
440
+ }
441
+ toJSON() {
442
+ return this.data;
443
+ }
444
+ }
445
+
446
+ var postProcessor = {
447
+ processors: {},
448
+ addPostProcessor(module) {
449
+ this.processors[module.name] = module;
450
+ },
451
+ handle(processors, value, key, options, translator) {
452
+ processors.forEach(processor => {
453
+ value = this.processors[processor]?.process(value, key, options, translator) ?? value;
454
+ });
455
+ return value;
456
+ }
457
+ };
458
+
459
+ const checkedLoadedFor = {};
460
+ const shouldHandleAsObject = res => !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
461
+ class Translator extends EventEmitter {
462
+ constructor(services) {
463
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
464
+ super();
465
+ copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
466
+ this.options = options;
467
+ if (this.options.keySeparator === undefined) {
468
+ this.options.keySeparator = '.';
469
+ }
470
+ this.logger = baseLogger.create('translator');
471
+ }
472
+ changeLanguage(lng) {
473
+ if (lng) this.language = lng;
474
+ }
475
+ exists(key) {
476
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
477
+ interpolation: {}
478
+ };
479
+ if (key == null) {
480
+ return false;
481
+ }
482
+ const resolved = this.resolve(key, options);
483
+ return resolved?.res !== undefined;
484
+ }
485
+ extractFromKey(key, options) {
486
+ let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
487
+ if (nsSeparator === undefined) nsSeparator = ':';
488
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
489
+ let namespaces = options.ns || this.options.defaultNS || [];
490
+ const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
491
+ const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
492
+ if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
493
+ const m = key.match(this.interpolator.nestingRegexp);
494
+ if (m && m.length > 0) {
495
+ return {
496
+ key,
497
+ namespaces: isString(namespaces) ? [namespaces] : namespaces
498
+ };
499
+ }
500
+ const parts = key.split(nsSeparator);
501
+ if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
502
+ key = parts.join(keySeparator);
503
+ }
504
+ return {
505
+ key,
506
+ namespaces: isString(namespaces) ? [namespaces] : namespaces
507
+ };
508
+ }
509
+ translate(keys, options, lastKey) {
510
+ if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
511
+ options = this.options.overloadTranslationOptionHandler(arguments);
512
+ }
513
+ if (typeof options === 'object') options = {
514
+ ...options
515
+ };
516
+ if (!options) options = {};
517
+ if (keys == null) return '';
518
+ if (!Array.isArray(keys)) keys = [String(keys)];
519
+ const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
520
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
521
+ const {
522
+ key,
523
+ namespaces
524
+ } = this.extractFromKey(keys[keys.length - 1], options);
525
+ const namespace = namespaces[namespaces.length - 1];
526
+ const lng = options.lng || this.language;
527
+ const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
528
+ if (lng?.toLowerCase() === 'cimode') {
529
+ if (appendNamespaceToCIMode) {
530
+ const nsSeparator = options.nsSeparator || this.options.nsSeparator;
531
+ if (returnDetails) {
532
+ return {
533
+ res: `${namespace}${nsSeparator}${key}`,
534
+ usedKey: key,
535
+ exactUsedKey: key,
536
+ usedLng: lng,
537
+ usedNS: namespace,
538
+ usedParams: this.getUsedParamsDetails(options)
539
+ };
540
+ }
541
+ return `${namespace}${nsSeparator}${key}`;
542
+ }
543
+ if (returnDetails) {
544
+ return {
545
+ res: key,
546
+ usedKey: key,
547
+ exactUsedKey: key,
548
+ usedLng: lng,
549
+ usedNS: namespace,
550
+ usedParams: this.getUsedParamsDetails(options)
551
+ };
552
+ }
553
+ return key;
554
+ }
555
+ const resolved = this.resolve(keys, options);
556
+ let res = resolved?.res;
557
+ const resUsedKey = resolved?.usedKey || key;
558
+ const resExactUsedKey = resolved?.exactUsedKey || key;
559
+ const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
560
+ const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
561
+ const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
562
+ const needsPluralHandling = options.count !== undefined && !isString(options.count);
563
+ const hasDefaultValue = Translator.hasDefaultValue(options);
564
+ const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
565
+ const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
566
+ ordinal: false
567
+ }) : '';
568
+ const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0;
569
+ const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
570
+ let resForObjHndl = res;
571
+ if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
572
+ resForObjHndl = defaultValue;
573
+ }
574
+ const handleAsObject = shouldHandleAsObject(resForObjHndl);
575
+ const resType = Object.prototype.toString.apply(resForObjHndl);
576
+ if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
577
+ if (!options.returnObjects && !this.options.returnObjects) {
578
+ if (!this.options.returnedObjectHandler) {
579
+ this.logger.warn('accessing an object - but returnObjects options is not enabled!');
580
+ }
581
+ const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
582
+ ...options,
583
+ ns: namespaces
584
+ }) : `key '${key} (${this.language})' returned an object instead of string.`;
585
+ if (returnDetails) {
586
+ resolved.res = r;
587
+ resolved.usedParams = this.getUsedParamsDetails(options);
588
+ return resolved;
589
+ }
590
+ return r;
591
+ }
592
+ if (keySeparator) {
593
+ const resTypeIsArray = Array.isArray(resForObjHndl);
594
+ const copy = resTypeIsArray ? [] : {};
595
+ const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
596
+ for (const m in resForObjHndl) {
597
+ if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
598
+ const deepKey = `${newKeyToUse}${keySeparator}${m}`;
599
+ if (hasDefaultValue && !res) {
600
+ copy[m] = this.translate(deepKey, {
601
+ ...options,
602
+ defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : undefined,
603
+ ...{
604
+ joinArrays: false,
605
+ ns: namespaces
606
+ }
607
+ });
608
+ } else {
609
+ copy[m] = this.translate(deepKey, {
610
+ ...options,
611
+ ...{
612
+ joinArrays: false,
613
+ ns: namespaces
614
+ }
615
+ });
616
+ }
617
+ if (copy[m] === deepKey) copy[m] = resForObjHndl[m];
618
+ }
619
+ }
620
+ res = copy;
621
+ }
622
+ } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
623
+ res = res.join(joinArrays);
624
+ if (res) res = this.extendTranslation(res, keys, options, lastKey);
625
+ } else {
626
+ let usedDefault = false;
627
+ let usedKey = false;
628
+ if (!this.isValidLookup(res) && hasDefaultValue) {
629
+ usedDefault = true;
630
+ res = defaultValue;
631
+ }
632
+ if (!this.isValidLookup(res)) {
633
+ usedKey = true;
634
+ res = key;
635
+ }
636
+ const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
637
+ const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
638
+ const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
639
+ if (usedKey || usedDefault || updateMissing) {
640
+ this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
641
+ if (keySeparator) {
642
+ const fk = this.resolve(key, {
643
+ ...options,
644
+ keySeparator: false
645
+ });
646
+ if (fk && fk.res) this.logger.warn('Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.');
647
+ }
648
+ let lngs = [];
649
+ const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
650
+ if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
651
+ for (let i = 0; i < fallbackLngs.length; i++) {
652
+ lngs.push(fallbackLngs[i]);
653
+ }
654
+ } else if (this.options.saveMissingTo === 'all') {
655
+ lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
656
+ } else {
657
+ lngs.push(options.lng || this.language);
658
+ }
659
+ const send = (l, k, specificDefaultValue) => {
660
+ const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
661
+ if (this.options.missingKeyHandler) {
662
+ this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
663
+ } else if (this.backendConnector?.saveMissing) {
664
+ this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
665
+ }
666
+ this.emit('missingKey', l, namespace, k, res);
667
+ };
668
+ if (this.options.saveMissing) {
669
+ if (this.options.saveMissingPlurals && needsPluralHandling) {
670
+ lngs.forEach(language => {
671
+ const suffixes = this.pluralResolver.getSuffixes(language, options);
672
+ if (needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
673
+ suffixes.push(`${this.options.pluralSeparator}zero`);
674
+ }
675
+ suffixes.forEach(suffix => {
676
+ send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
677
+ });
678
+ });
679
+ } else {
680
+ send(lngs, key, defaultValue);
681
+ }
682
+ }
683
+ }
684
+ res = this.extendTranslation(res, keys, options, resolved, lastKey);
685
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
686
+ if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
687
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
688
+ }
689
+ }
690
+ if (returnDetails) {
691
+ resolved.res = res;
692
+ resolved.usedParams = this.getUsedParamsDetails(options);
693
+ return resolved;
694
+ }
695
+ return res;
696
+ }
697
+ extendTranslation(res, key, options, resolved, lastKey) {
698
+ var _this = this;
699
+ if (this.i18nFormat?.parse) {
700
+ res = this.i18nFormat.parse(res, {
701
+ ...this.options.interpolation.defaultVariables,
702
+ ...options
703
+ }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
704
+ resolved
705
+ });
706
+ } else if (!options.skipInterpolation) {
707
+ if (options.interpolation) this.interpolator.init({
708
+ ...options,
709
+ ...{
710
+ interpolation: {
711
+ ...this.options.interpolation,
712
+ ...options.interpolation
713
+ }
714
+ }
715
+ });
716
+ const skipOnVariables = isString(res) && (options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
717
+ let nestBef;
718
+ if (skipOnVariables) {
719
+ const nb = res.match(this.interpolator.nestingRegexp);
720
+ nestBef = nb && nb.length;
721
+ }
722
+ let data = options.replace && !isString(options.replace) ? options.replace : options;
723
+ if (this.options.interpolation.defaultVariables) data = {
724
+ ...this.options.interpolation.defaultVariables,
725
+ ...data
726
+ };
727
+ res = this.interpolator.interpolate(res, data, options.lng || this.language || resolved.usedLng, options);
728
+ if (skipOnVariables) {
729
+ const na = res.match(this.interpolator.nestingRegexp);
730
+ const nestAft = na && na.length;
731
+ if (nestBef < nestAft) options.nest = false;
732
+ }
733
+ if (!options.lng && resolved && resolved.res) options.lng = this.language || resolved.usedLng;
734
+ if (options.nest !== false) res = this.interpolator.nest(res, function () {
735
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
736
+ args[_key] = arguments[_key];
737
+ }
738
+ if (lastKey?.[0] === args[0] && !options.context) {
739
+ _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
740
+ return null;
741
+ }
742
+ return _this.translate(...args, key);
743
+ }, options);
744
+ if (options.interpolation) this.interpolator.reset();
745
+ }
746
+ const postProcess = options.postProcess || this.options.postProcess;
747
+ const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
748
+ if (res != null && postProcessorNames?.length && options.applyPostProcessor !== false) {
749
+ res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
750
+ i18nResolved: {
751
+ ...resolved,
752
+ usedParams: this.getUsedParamsDetails(options)
753
+ },
754
+ ...options
755
+ } : options, this);
756
+ }
757
+ return res;
758
+ }
759
+ resolve(keys) {
760
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
761
+ let found;
762
+ let usedKey;
763
+ let exactUsedKey;
764
+ let usedLng;
765
+ let usedNS;
766
+ if (isString(keys)) keys = [keys];
767
+ keys.forEach(k => {
768
+ if (this.isValidLookup(found)) return;
769
+ const extracted = this.extractFromKey(k, options);
770
+ const key = extracted.key;
771
+ usedKey = key;
772
+ let namespaces = extracted.namespaces;
773
+ if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
774
+ const needsPluralHandling = options.count !== undefined && !isString(options.count);
775
+ const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0;
776
+ const needsContextHandling = options.context !== undefined && (isString(options.context) || typeof options.context === 'number') && options.context !== '';
777
+ const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
778
+ namespaces.forEach(ns => {
779
+ if (this.isValidLookup(found)) return;
780
+ usedNS = ns;
781
+ if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
782
+ checkedLoadedFor[`${codes[0]}-${ns}`] = true;
783
+ this.logger.warn(`key "${usedKey}" for languages "${codes.join(', ')}" won't get resolved as namespace "${usedNS}" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
784
+ }
785
+ codes.forEach(code => {
786
+ if (this.isValidLookup(found)) return;
787
+ usedLng = code;
788
+ const finalKeys = [key];
789
+ if (this.i18nFormat?.addLookupKeys) {
790
+ this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
791
+ } else {
792
+ let pluralSuffix;
793
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
794
+ const zeroSuffix = `${this.options.pluralSeparator}zero`;
795
+ const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
796
+ if (needsPluralHandling) {
797
+ finalKeys.push(key + pluralSuffix);
798
+ if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
799
+ finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
800
+ }
801
+ if (needsZeroSuffixLookup) {
802
+ finalKeys.push(key + zeroSuffix);
803
+ }
804
+ }
805
+ if (needsContextHandling) {
806
+ const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
807
+ finalKeys.push(contextKey);
808
+ if (needsPluralHandling) {
809
+ finalKeys.push(contextKey + pluralSuffix);
810
+ if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
811
+ finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
812
+ }
813
+ if (needsZeroSuffixLookup) {
814
+ finalKeys.push(contextKey + zeroSuffix);
815
+ }
816
+ }
817
+ }
818
+ }
819
+ let possibleKey;
820
+ while (possibleKey = finalKeys.pop()) {
821
+ if (!this.isValidLookup(found)) {
822
+ exactUsedKey = possibleKey;
823
+ found = this.getResource(code, ns, possibleKey, options);
824
+ }
825
+ }
826
+ });
827
+ });
828
+ });
829
+ return {
830
+ res: found,
831
+ usedKey,
832
+ exactUsedKey,
833
+ usedLng,
834
+ usedNS
835
+ };
836
+ }
837
+ isValidLookup(res) {
838
+ return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
839
+ }
840
+ getResource(code, ns, key) {
841
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
842
+ if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
843
+ return this.resourceStore.getResource(code, ns, key, options);
844
+ }
845
+ getUsedParamsDetails() {
846
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
847
+ const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
848
+ const useOptionsReplaceForData = options.replace && !isString(options.replace);
849
+ let data = useOptionsReplaceForData ? options.replace : options;
850
+ if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
851
+ data.count = options.count;
852
+ }
853
+ if (this.options.interpolation.defaultVariables) {
854
+ data = {
855
+ ...this.options.interpolation.defaultVariables,
856
+ ...data
857
+ };
858
+ }
859
+ if (!useOptionsReplaceForData) {
860
+ data = {
861
+ ...data
862
+ };
863
+ for (const key of optionsKeys) {
864
+ delete data[key];
865
+ }
866
+ }
867
+ return data;
868
+ }
869
+ static hasDefaultValue(options) {
870
+ const prefix = 'defaultValue';
871
+ for (const option in options) {
872
+ if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
873
+ return true;
874
+ }
875
+ }
876
+ return false;
877
+ }
878
+ }
879
+
880
+ class LanguageUtil {
881
+ constructor(options) {
882
+ this.options = options;
883
+ this.supportedLngs = this.options.supportedLngs || false;
884
+ this.logger = baseLogger.create('languageUtils');
885
+ }
886
+ getScriptPartFromCode(code) {
887
+ code = getCleanedCode(code);
888
+ if (!code || code.indexOf('-') < 0) return null;
889
+ const p = code.split('-');
890
+ if (p.length === 2) return null;
891
+ p.pop();
892
+ if (p[p.length - 1].toLowerCase() === 'x') return null;
893
+ return this.formatLanguageCode(p.join('-'));
894
+ }
895
+ getLanguagePartFromCode(code) {
896
+ code = getCleanedCode(code);
897
+ if (!code || code.indexOf('-') < 0) return code;
898
+ const p = code.split('-');
899
+ return this.formatLanguageCode(p[0]);
900
+ }
901
+ formatLanguageCode(code) {
902
+ if (isString(code) && code.indexOf('-') > -1) {
903
+ let formattedCode;
904
+ try {
905
+ formattedCode = Intl.getCanonicalLocales(code)[0];
906
+ } catch (e) {}
907
+ if (formattedCode && this.options.lowerCaseLng) {
908
+ formattedCode = formattedCode.toLowerCase();
909
+ }
910
+ if (formattedCode) return formattedCode;
911
+ if (this.options.lowerCaseLng) {
912
+ return code.toLowerCase();
913
+ }
914
+ return code;
915
+ }
916
+ return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
917
+ }
918
+ isSupportedCode(code) {
919
+ if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
920
+ code = this.getLanguagePartFromCode(code);
921
+ }
922
+ return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
923
+ }
924
+ getBestMatchFromCodes(codes) {
925
+ if (!codes) return null;
926
+ let found;
927
+ codes.forEach(code => {
928
+ if (found) return;
929
+ const cleanedLng = this.formatLanguageCode(code);
930
+ if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
931
+ });
932
+ if (!found && this.options.supportedLngs) {
933
+ codes.forEach(code => {
934
+ if (found) return;
935
+ const lngOnly = this.getLanguagePartFromCode(code);
936
+ if (this.isSupportedCode(lngOnly)) return found = lngOnly;
937
+ found = this.options.supportedLngs.find(supportedLng => {
938
+ if (supportedLng === lngOnly) return supportedLng;
939
+ if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
940
+ if (supportedLng.indexOf('-') > 0 && lngOnly.indexOf('-') < 0 && supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly) return supportedLng;
941
+ if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
942
+ });
943
+ });
944
+ }
945
+ if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
946
+ return found;
947
+ }
948
+ getFallbackCodes(fallbacks, code) {
949
+ if (!fallbacks) return [];
950
+ if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
951
+ if (isString(fallbacks)) fallbacks = [fallbacks];
952
+ if (Array.isArray(fallbacks)) return fallbacks;
953
+ if (!code) return fallbacks.default || [];
954
+ let found = fallbacks[code];
955
+ if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
956
+ if (!found) found = fallbacks[this.formatLanguageCode(code)];
957
+ if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
958
+ if (!found) found = fallbacks.default;
959
+ return found || [];
960
+ }
961
+ toResolveHierarchy(code, fallbackCode) {
962
+ const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
963
+ const codes = [];
964
+ const addCode = c => {
965
+ if (!c) return;
966
+ if (this.isSupportedCode(c)) {
967
+ codes.push(c);
968
+ } else {
969
+ this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
970
+ }
971
+ };
972
+ if (isString(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
973
+ if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
974
+ if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
975
+ if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
976
+ } else if (isString(code)) {
977
+ addCode(this.formatLanguageCode(code));
978
+ }
979
+ fallbackCodes.forEach(fc => {
980
+ if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
981
+ });
982
+ return codes;
983
+ }
984
+ }
985
+
986
+ const suffixesOrder = {
987
+ zero: 0,
988
+ one: 1,
989
+ two: 2,
990
+ few: 3,
991
+ many: 4,
992
+ other: 5
993
+ };
994
+ const dummyRule = {
995
+ select: count => count === 1 ? 'one' : 'other',
996
+ resolvedOptions: () => ({
997
+ pluralCategories: ['one', 'other']
998
+ })
999
+ };
1000
+ class PluralResolver {
1001
+ constructor(languageUtils) {
1002
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1003
+ this.languageUtils = languageUtils;
1004
+ this.options = options;
1005
+ this.logger = baseLogger.create('pluralResolver');
1006
+ this.pluralRulesCache = {};
1007
+ }
1008
+ addRule(lng, obj) {
1009
+ this.rules[lng] = obj;
1010
+ }
1011
+ clearCache() {
1012
+ this.pluralRulesCache = {};
1013
+ }
1014
+ getRule(code) {
1015
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1016
+ const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
1017
+ const type = options.ordinal ? 'ordinal' : 'cardinal';
1018
+ const cacheKey = JSON.stringify({
1019
+ cleanedCode,
1020
+ type
1021
+ });
1022
+ if (cacheKey in this.pluralRulesCache) {
1023
+ return this.pluralRulesCache[cacheKey];
1024
+ }
1025
+ let rule;
1026
+ try {
1027
+ rule = new Intl.PluralRules(cleanedCode, {
1028
+ type
1029
+ });
1030
+ } catch (err) {
1031
+ if (!Intl) {
1032
+ this.logger.error('No Intl support, please use an Intl polyfill!');
1033
+ return dummyRule;
1034
+ }
1035
+ if (!code.match(/-|_/)) return dummyRule;
1036
+ const lngPart = this.languageUtils.getLanguagePartFromCode(code);
1037
+ rule = this.getRule(lngPart, options);
1038
+ }
1039
+ this.pluralRulesCache[cacheKey] = rule;
1040
+ return rule;
1041
+ }
1042
+ needsPlural(code) {
1043
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1044
+ let rule = this.getRule(code, options);
1045
+ if (!rule) rule = this.getRule('dev', options);
1046
+ return rule?.resolvedOptions().pluralCategories.length > 1;
1047
+ }
1048
+ getPluralFormsOfKey(code, key) {
1049
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1050
+ return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
1051
+ }
1052
+ getSuffixes(code) {
1053
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1054
+ let rule = this.getRule(code, options);
1055
+ if (!rule) rule = this.getRule('dev', options);
1056
+ if (!rule) return [];
1057
+ return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
1058
+ }
1059
+ getSuffix(code, count) {
1060
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1061
+ const rule = this.getRule(code, options);
1062
+ if (rule) {
1063
+ return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
1064
+ }
1065
+ this.logger.warn(`no plural rule found for: ${code}`);
1066
+ return this.getSuffix('dev', count, options);
1067
+ }
1068
+ }
1069
+
1070
+ const deepFindWithDefaults = function (data, defaultData, key) {
1071
+ let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
1072
+ let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1073
+ let path = getPathWithDefaults(data, defaultData, key);
1074
+ if (!path && ignoreJSONStructure && isString(key)) {
1075
+ path = deepFind(data, key, keySeparator);
1076
+ if (path === undefined) path = deepFind(defaultData, key, keySeparator);
1077
+ }
1078
+ return path;
1079
+ };
1080
+ const regexSafe = val => val.replace(/\$/g, '$$$$');
1081
+ class Interpolator {
1082
+ constructor() {
1083
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1084
+ this.logger = baseLogger.create('interpolator');
1085
+ this.options = options;
1086
+ this.format = options?.interpolation?.format || (value => value);
1087
+ this.init(options);
1088
+ }
1089
+ init() {
1090
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1091
+ if (!options.interpolation) options.interpolation = {
1092
+ escapeValue: true
1093
+ };
1094
+ const {
1095
+ escape: escape$1,
1096
+ escapeValue,
1097
+ useRawValueToEscape,
1098
+ prefix,
1099
+ prefixEscaped,
1100
+ suffix,
1101
+ suffixEscaped,
1102
+ formatSeparator,
1103
+ unescapeSuffix,
1104
+ unescapePrefix,
1105
+ nestingPrefix,
1106
+ nestingPrefixEscaped,
1107
+ nestingSuffix,
1108
+ nestingSuffixEscaped,
1109
+ nestingOptionsSeparator,
1110
+ maxReplaces,
1111
+ alwaysFormat
1112
+ } = options.interpolation;
1113
+ this.escape = escape$1 !== undefined ? escape$1 : escape;
1114
+ this.escapeValue = escapeValue !== undefined ? escapeValue : true;
1115
+ this.useRawValueToEscape = useRawValueToEscape !== undefined ? useRawValueToEscape : false;
1116
+ this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || '{{';
1117
+ this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || '}}';
1118
+ this.formatSeparator = formatSeparator || ',';
1119
+ this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix || '-';
1120
+ this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix || '';
1121
+ this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape('$t(');
1122
+ this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(')');
1123
+ this.nestingOptionsSeparator = nestingOptionsSeparator || ',';
1124
+ this.maxReplaces = maxReplaces || 1000;
1125
+ this.alwaysFormat = alwaysFormat !== undefined ? alwaysFormat : false;
1126
+ this.resetRegExp();
1127
+ }
1128
+ reset() {
1129
+ if (this.options) this.init(this.options);
1130
+ }
1131
+ resetRegExp() {
1132
+ const getOrResetRegExp = (existingRegExp, pattern) => {
1133
+ if (existingRegExp?.source === pattern) {
1134
+ existingRegExp.lastIndex = 0;
1135
+ return existingRegExp;
1136
+ }
1137
+ return new RegExp(pattern, 'g');
1138
+ };
1139
+ this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
1140
+ this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
1141
+ this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
1142
+ }
1143
+ interpolate(str, data, lng, options) {
1144
+ let match;
1145
+ let value;
1146
+ let replaces;
1147
+ const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1148
+ const handleFormat = key => {
1149
+ if (key.indexOf(this.formatSeparator) < 0) {
1150
+ const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
1151
+ return this.alwaysFormat ? this.format(path, undefined, lng, {
1152
+ ...options,
1153
+ ...data,
1154
+ interpolationkey: key
1155
+ }) : path;
1156
+ }
1157
+ const p = key.split(this.formatSeparator);
1158
+ const k = p.shift().trim();
1159
+ const f = p.join(this.formatSeparator).trim();
1160
+ return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
1161
+ ...options,
1162
+ ...data,
1163
+ interpolationkey: k
1164
+ });
1165
+ };
1166
+ this.resetRegExp();
1167
+ const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
1168
+ const skipOnVariables = options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1169
+ const todos = [{
1170
+ regex: this.regexpUnescape,
1171
+ safeValue: val => regexSafe(val)
1172
+ }, {
1173
+ regex: this.regexp,
1174
+ safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
1175
+ }];
1176
+ todos.forEach(todo => {
1177
+ replaces = 0;
1178
+ while (match = todo.regex.exec(str)) {
1179
+ const matchedVar = match[1].trim();
1180
+ value = handleFormat(matchedVar);
1181
+ if (value === undefined) {
1182
+ if (typeof missingInterpolationHandler === 'function') {
1183
+ const temp = missingInterpolationHandler(str, match, options);
1184
+ value = isString(temp) ? temp : '';
1185
+ } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
1186
+ value = '';
1187
+ } else if (skipOnVariables) {
1188
+ value = match[0];
1189
+ continue;
1190
+ } else {
1191
+ this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1192
+ value = '';
1193
+ }
1194
+ } else if (!isString(value) && !this.useRawValueToEscape) {
1195
+ value = makeString(value);
1196
+ }
1197
+ const safeValue = todo.safeValue(value);
1198
+ str = str.replace(match[0], safeValue);
1199
+ if (skipOnVariables) {
1200
+ todo.regex.lastIndex += value.length;
1201
+ todo.regex.lastIndex -= match[0].length;
1202
+ } else {
1203
+ todo.regex.lastIndex = 0;
1204
+ }
1205
+ replaces++;
1206
+ if (replaces >= this.maxReplaces) {
1207
+ break;
1208
+ }
1209
+ }
1210
+ });
1211
+ return str;
1212
+ }
1213
+ nest(str, fc) {
1214
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1215
+ let match;
1216
+ let value;
1217
+ let clonedOptions;
1218
+ const handleHasOptions = (key, inheritedOptions) => {
1219
+ const sep = this.nestingOptionsSeparator;
1220
+ if (key.indexOf(sep) < 0) return key;
1221
+ const c = key.split(new RegExp(`${sep}[ ]*{`));
1222
+ let optionsString = `{${c[1]}`;
1223
+ key = c[0];
1224
+ optionsString = this.interpolate(optionsString, clonedOptions);
1225
+ const matchedSingleQuotes = optionsString.match(/'/g);
1226
+ const matchedDoubleQuotes = optionsString.match(/"/g);
1227
+ if ((matchedSingleQuotes?.length ?? 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1228
+ optionsString = optionsString.replace(/'/g, '"');
1229
+ }
1230
+ try {
1231
+ clonedOptions = JSON.parse(optionsString);
1232
+ if (inheritedOptions) clonedOptions = {
1233
+ ...inheritedOptions,
1234
+ ...clonedOptions
1235
+ };
1236
+ } catch (e) {
1237
+ this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
1238
+ return `${key}${sep}${optionsString}`;
1239
+ }
1240
+ if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
1241
+ return key;
1242
+ };
1243
+ while (match = this.nestingRegexp.exec(str)) {
1244
+ let formatters = [];
1245
+ clonedOptions = {
1246
+ ...options
1247
+ };
1248
+ clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1249
+ clonedOptions.applyPostProcessor = false;
1250
+ delete clonedOptions.defaultValue;
1251
+ let doReduce = false;
1252
+ if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
1253
+ const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
1254
+ match[1] = r.shift();
1255
+ formatters = r;
1256
+ doReduce = true;
1257
+ }
1258
+ value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1259
+ if (value && match[0] === str && !isString(value)) return value;
1260
+ if (!isString(value)) value = makeString(value);
1261
+ if (!value) {
1262
+ this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1263
+ value = '';
1264
+ }
1265
+ if (doReduce) {
1266
+ value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1267
+ ...options,
1268
+ interpolationkey: match[1].trim()
1269
+ }), value.trim());
1270
+ }
1271
+ str = str.replace(match[0], value);
1272
+ this.regexp.lastIndex = 0;
1273
+ }
1274
+ return str;
1275
+ }
1276
+ }
1277
+
1278
+ const parseFormatStr = formatStr => {
1279
+ let formatName = formatStr.toLowerCase().trim();
1280
+ const formatOptions = {};
1281
+ if (formatStr.indexOf('(') > -1) {
1282
+ const p = formatStr.split('(');
1283
+ formatName = p[0].toLowerCase().trim();
1284
+ const optStr = p[1].substring(0, p[1].length - 1);
1285
+ if (formatName === 'currency' && optStr.indexOf(':') < 0) {
1286
+ if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1287
+ } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
1288
+ if (!formatOptions.range) formatOptions.range = optStr.trim();
1289
+ } else {
1290
+ const opts = optStr.split(';');
1291
+ opts.forEach(opt => {
1292
+ if (opt) {
1293
+ const [key, ...rest] = opt.split(':');
1294
+ const val = rest.join(':').trim().replace(/^'+|'+$/g, '');
1295
+ const trimmedKey = key.trim();
1296
+ if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
1297
+ if (val === 'false') formatOptions[trimmedKey] = false;
1298
+ if (val === 'true') formatOptions[trimmedKey] = true;
1299
+ if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
1300
+ }
1301
+ });
1302
+ }
1303
+ }
1304
+ return {
1305
+ formatName,
1306
+ formatOptions
1307
+ };
1308
+ };
1309
+ const createCachedFormatter = fn => {
1310
+ const cache = {};
1311
+ return (val, lng, options) => {
1312
+ let optForCache = options;
1313
+ if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
1314
+ optForCache = {
1315
+ ...optForCache,
1316
+ [options.interpolationkey]: undefined
1317
+ };
1318
+ }
1319
+ const key = lng + JSON.stringify(optForCache);
1320
+ let formatter = cache[key];
1321
+ if (!formatter) {
1322
+ formatter = fn(getCleanedCode(lng), options);
1323
+ cache[key] = formatter;
1324
+ }
1325
+ return formatter(val);
1326
+ };
1327
+ };
1328
+ class Formatter {
1329
+ constructor() {
1330
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1331
+ this.logger = baseLogger.create('formatter');
1332
+ this.options = options;
1333
+ this.formats = {
1334
+ number: createCachedFormatter((lng, opt) => {
1335
+ const formatter = new Intl.NumberFormat(lng, {
1336
+ ...opt
1337
+ });
1338
+ return val => formatter.format(val);
1339
+ }),
1340
+ currency: createCachedFormatter((lng, opt) => {
1341
+ const formatter = new Intl.NumberFormat(lng, {
1342
+ ...opt,
1343
+ style: 'currency'
1344
+ });
1345
+ return val => formatter.format(val);
1346
+ }),
1347
+ datetime: createCachedFormatter((lng, opt) => {
1348
+ const formatter = new Intl.DateTimeFormat(lng, {
1349
+ ...opt
1350
+ });
1351
+ return val => formatter.format(val);
1352
+ }),
1353
+ relativetime: createCachedFormatter((lng, opt) => {
1354
+ const formatter = new Intl.RelativeTimeFormat(lng, {
1355
+ ...opt
1356
+ });
1357
+ return val => formatter.format(val, opt.range || 'day');
1358
+ }),
1359
+ list: createCachedFormatter((lng, opt) => {
1360
+ const formatter = new Intl.ListFormat(lng, {
1361
+ ...opt
1362
+ });
1363
+ return val => formatter.format(val);
1364
+ })
1365
+ };
1366
+ this.init(options);
1367
+ }
1368
+ init(services) {
1369
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1370
+ interpolation: {}
1371
+ };
1372
+ this.formatSeparator = options.interpolation.formatSeparator || ',';
1373
+ }
1374
+ add(name, fc) {
1375
+ this.formats[name.toLowerCase().trim()] = fc;
1376
+ }
1377
+ addCached(name, fc) {
1378
+ this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1379
+ }
1380
+ format(value, format, lng) {
1381
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1382
+ const formats = format.split(this.formatSeparator);
1383
+ if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
1384
+ const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
1385
+ formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
1386
+ }
1387
+ const result = formats.reduce((mem, f) => {
1388
+ const {
1389
+ formatName,
1390
+ formatOptions
1391
+ } = parseFormatStr(f);
1392
+ if (this.formats[formatName]) {
1393
+ let formatted = mem;
1394
+ try {
1395
+ const valOptions = options?.formatParams?.[options.interpolationkey] || {};
1396
+ const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1397
+ formatted = this.formats[formatName](mem, l, {
1398
+ ...formatOptions,
1399
+ ...options,
1400
+ ...valOptions
1401
+ });
1402
+ } catch (error) {
1403
+ this.logger.warn(error);
1404
+ }
1405
+ return formatted;
1406
+ } else {
1407
+ this.logger.warn(`there was no format function for ${formatName}`);
1408
+ }
1409
+ return mem;
1410
+ }, value);
1411
+ return result;
1412
+ }
1413
+ }
1414
+
1415
+ const removePending = (q, name) => {
1416
+ if (q.pending[name] !== undefined) {
1417
+ delete q.pending[name];
1418
+ q.pendingCount--;
1419
+ }
1420
+ };
1421
+ class Connector extends EventEmitter {
1422
+ constructor(backend, store, services) {
1423
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1424
+ super();
1425
+ this.backend = backend;
1426
+ this.store = store;
1427
+ this.services = services;
1428
+ this.languageUtils = services.languageUtils;
1429
+ this.options = options;
1430
+ this.logger = baseLogger.create('backendConnector');
1431
+ this.waitingReads = [];
1432
+ this.maxParallelReads = options.maxParallelReads || 10;
1433
+ this.readingCalls = 0;
1434
+ this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
1435
+ this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1436
+ this.state = {};
1437
+ this.queue = [];
1438
+ this.backend?.init?.(services, options.backend, options);
1439
+ }
1440
+ queueLoad(languages, namespaces, options, callback) {
1441
+ const toLoad = {};
1442
+ const pending = {};
1443
+ const toLoadLanguages = {};
1444
+ const toLoadNamespaces = {};
1445
+ languages.forEach(lng => {
1446
+ let hasAllNamespaces = true;
1447
+ namespaces.forEach(ns => {
1448
+ const name = `${lng}|${ns}`;
1449
+ if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
1450
+ this.state[name] = 2;
1451
+ } else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
1452
+ if (pending[name] === undefined) pending[name] = true;
1453
+ } else {
1454
+ this.state[name] = 1;
1455
+ hasAllNamespaces = false;
1456
+ if (pending[name] === undefined) pending[name] = true;
1457
+ if (toLoad[name] === undefined) toLoad[name] = true;
1458
+ if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
1459
+ }
1460
+ });
1461
+ if (!hasAllNamespaces) toLoadLanguages[lng] = true;
1462
+ });
1463
+ if (Object.keys(toLoad).length || Object.keys(pending).length) {
1464
+ this.queue.push({
1465
+ pending,
1466
+ pendingCount: Object.keys(pending).length,
1467
+ loaded: {},
1468
+ errors: [],
1469
+ callback
1470
+ });
1471
+ }
1472
+ return {
1473
+ toLoad: Object.keys(toLoad),
1474
+ pending: Object.keys(pending),
1475
+ toLoadLanguages: Object.keys(toLoadLanguages),
1476
+ toLoadNamespaces: Object.keys(toLoadNamespaces)
1477
+ };
1478
+ }
1479
+ loaded(name, err, data) {
1480
+ const s = name.split('|');
1481
+ const lng = s[0];
1482
+ const ns = s[1];
1483
+ if (err) this.emit('failedLoading', lng, ns, err);
1484
+ if (!err && data) {
1485
+ this.store.addResourceBundle(lng, ns, data, undefined, undefined, {
1486
+ skipCopy: true
1487
+ });
1488
+ }
1489
+ this.state[name] = err ? -1 : 2;
1490
+ if (err && data) this.state[name] = 0;
1491
+ const loaded = {};
1492
+ this.queue.forEach(q => {
1493
+ pushPath(q.loaded, [lng], ns);
1494
+ removePending(q, name);
1495
+ if (err) q.errors.push(err);
1496
+ if (q.pendingCount === 0 && !q.done) {
1497
+ Object.keys(q.loaded).forEach(l => {
1498
+ if (!loaded[l]) loaded[l] = {};
1499
+ const loadedKeys = q.loaded[l];
1500
+ if (loadedKeys.length) {
1501
+ loadedKeys.forEach(n => {
1502
+ if (loaded[l][n] === undefined) loaded[l][n] = true;
1503
+ });
1504
+ }
1505
+ });
1506
+ q.done = true;
1507
+ if (q.errors.length) {
1508
+ q.callback(q.errors);
1509
+ } else {
1510
+ q.callback();
1511
+ }
1512
+ }
1513
+ });
1514
+ this.emit('loaded', loaded);
1515
+ this.queue = this.queue.filter(q => !q.done);
1516
+ }
1517
+ read(lng, ns, fcName) {
1518
+ let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1519
+ let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
1520
+ let callback = arguments.length > 5 ? arguments[5] : undefined;
1521
+ if (!lng.length) return callback(null, {});
1522
+ if (this.readingCalls >= this.maxParallelReads) {
1523
+ this.waitingReads.push({
1524
+ lng,
1525
+ ns,
1526
+ fcName,
1527
+ tried,
1528
+ wait,
1529
+ callback
1530
+ });
1531
+ return;
1532
+ }
1533
+ this.readingCalls++;
1534
+ const resolver = (err, data) => {
1535
+ this.readingCalls--;
1536
+ if (this.waitingReads.length > 0) {
1537
+ const next = this.waitingReads.shift();
1538
+ this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
1539
+ }
1540
+ if (err && data && tried < this.maxRetries) {
1541
+ setTimeout(() => {
1542
+ this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
1543
+ }, wait);
1544
+ return;
1545
+ }
1546
+ callback(err, data);
1547
+ };
1548
+ const fc = this.backend[fcName].bind(this.backend);
1549
+ if (fc.length === 2) {
1550
+ try {
1551
+ const r = fc(lng, ns);
1552
+ if (r && typeof r.then === 'function') {
1553
+ r.then(data => resolver(null, data)).catch(resolver);
1554
+ } else {
1555
+ resolver(null, r);
1556
+ }
1557
+ } catch (err) {
1558
+ resolver(err);
1559
+ }
1560
+ return;
1561
+ }
1562
+ return fc(lng, ns, resolver);
1563
+ }
1564
+ prepareLoading(languages, namespaces) {
1565
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1566
+ let callback = arguments.length > 3 ? arguments[3] : undefined;
1567
+ if (!this.backend) {
1568
+ this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1569
+ return callback && callback();
1570
+ }
1571
+ if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
1572
+ if (isString(namespaces)) namespaces = [namespaces];
1573
+ const toLoad = this.queueLoad(languages, namespaces, options, callback);
1574
+ if (!toLoad.toLoad.length) {
1575
+ if (!toLoad.pending.length) callback();
1576
+ return null;
1577
+ }
1578
+ toLoad.toLoad.forEach(name => {
1579
+ this.loadOne(name);
1580
+ });
1581
+ }
1582
+ load(languages, namespaces, callback) {
1583
+ this.prepareLoading(languages, namespaces, {}, callback);
1584
+ }
1585
+ reload(languages, namespaces, callback) {
1586
+ this.prepareLoading(languages, namespaces, {
1587
+ reload: true
1588
+ }, callback);
1589
+ }
1590
+ loadOne(name) {
1591
+ let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1592
+ const s = name.split('|');
1593
+ const lng = s[0];
1594
+ const ns = s[1];
1595
+ this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
1596
+ if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
1597
+ if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
1598
+ this.loaded(name, err, data);
1599
+ });
1600
+ }
1601
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
1602
+ let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1603
+ let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
1604
+ if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
1605
+ this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
1606
+ return;
1607
+ }
1608
+ if (key === undefined || key === null || key === '') return;
1609
+ if (this.backend?.create) {
1610
+ const opts = {
1611
+ ...options,
1612
+ isUpdate
1613
+ };
1614
+ const fc = this.backend.create.bind(this.backend);
1615
+ if (fc.length < 6) {
1616
+ try {
1617
+ let r;
1618
+ if (fc.length === 5) {
1619
+ r = fc(languages, namespace, key, fallbackValue, opts);
1620
+ } else {
1621
+ r = fc(languages, namespace, key, fallbackValue);
1622
+ }
1623
+ if (r && typeof r.then === 'function') {
1624
+ r.then(data => clb(null, data)).catch(clb);
1625
+ } else {
1626
+ clb(null, r);
1627
+ }
1628
+ } catch (err) {
1629
+ clb(err);
1630
+ }
1631
+ } else {
1632
+ fc(languages, namespace, key, fallbackValue, clb, opts);
1633
+ }
1634
+ }
1635
+ if (!languages || !languages[0]) return;
1636
+ this.store.addResource(languages[0], namespace, key, fallbackValue);
1637
+ }
1638
+ }
1639
+
1640
+ const get = () => ({
1641
+ debug: false,
1642
+ initAsync: true,
1643
+ ns: ['translation'],
1644
+ defaultNS: ['translation'],
1645
+ fallbackLng: ['dev'],
1646
+ fallbackNS: false,
1647
+ supportedLngs: false,
1648
+ nonExplicitSupportedLngs: false,
1649
+ load: 'all',
1650
+ preload: false,
1651
+ simplifyPluralSuffix: true,
1652
+ keySeparator: '.',
1653
+ nsSeparator: ':',
1654
+ pluralSeparator: '_',
1655
+ contextSeparator: '_',
1656
+ partialBundledLanguages: false,
1657
+ saveMissing: false,
1658
+ updateMissing: false,
1659
+ saveMissingTo: 'fallback',
1660
+ saveMissingPlurals: true,
1661
+ missingKeyHandler: false,
1662
+ missingInterpolationHandler: false,
1663
+ postProcess: false,
1664
+ postProcessPassResolved: false,
1665
+ returnNull: false,
1666
+ returnEmptyString: true,
1667
+ returnObjects: false,
1668
+ joinArrays: false,
1669
+ returnedObjectHandler: false,
1670
+ parseMissingKeyHandler: false,
1671
+ appendNamespaceToMissingKey: false,
1672
+ appendNamespaceToCIMode: false,
1673
+ overloadTranslationOptionHandler: args => {
1674
+ let ret = {};
1675
+ if (typeof args[1] === 'object') ret = args[1];
1676
+ if (isString(args[1])) ret.defaultValue = args[1];
1677
+ if (isString(args[2])) ret.tDescription = args[2];
1678
+ if (typeof args[2] === 'object' || typeof args[3] === 'object') {
1679
+ const options = args[3] || args[2];
1680
+ Object.keys(options).forEach(key => {
1681
+ ret[key] = options[key];
1682
+ });
1683
+ }
1684
+ return ret;
1685
+ },
1686
+ interpolation: {
1687
+ escapeValue: true,
1688
+ format: value => value,
1689
+ prefix: '{{',
1690
+ suffix: '}}',
1691
+ formatSeparator: ',',
1692
+ unescapePrefix: '-',
1693
+ nestingPrefix: '$t(',
1694
+ nestingSuffix: ')',
1695
+ nestingOptionsSeparator: ',',
1696
+ maxReplaces: 1000,
1697
+ skipOnVariables: true
1698
+ }
1699
+ });
1700
+ const transformOptions = options => {
1701
+ if (isString(options.ns)) options.ns = [options.ns];
1702
+ if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1703
+ if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1704
+ if (options.supportedLngs?.indexOf?.('cimode') < 0) {
1705
+ options.supportedLngs = options.supportedLngs.concat(['cimode']);
1706
+ }
1707
+ if (typeof options.initImmediate === 'boolean') options.initAsync = options.initImmediate;
1708
+ return options;
1709
+ };
1710
+
1711
+ const noop = () => {};
1712
+ const bindMemberFunctions = inst => {
1713
+ const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
1714
+ mems.forEach(mem => {
1715
+ if (typeof inst[mem] === 'function') {
1716
+ inst[mem] = inst[mem].bind(inst);
1717
+ }
1718
+ });
1719
+ };
1720
+ class I18n extends EventEmitter {
1721
+ constructor() {
1722
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1723
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
1724
+ super();
1725
+ this.options = transformOptions(options);
1726
+ this.services = {};
1727
+ this.logger = baseLogger;
1728
+ this.modules = {
1729
+ external: []
1730
+ };
1731
+ bindMemberFunctions(this);
1732
+ if (callback && !this.isInitialized && !options.isClone) {
1733
+ if (!this.options.initAsync) {
1734
+ this.init(options, callback);
1735
+ return this;
1736
+ }
1737
+ setTimeout(() => {
1738
+ this.init(options, callback);
1739
+ }, 0);
1740
+ }
1741
+ }
1742
+ init() {
1743
+ var _this = this;
1744
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1745
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
1746
+ this.isInitializing = true;
1747
+ if (typeof options === 'function') {
1748
+ callback = options;
1749
+ options = {};
1750
+ }
1751
+ if (options.defaultNS == null && options.ns) {
1752
+ if (isString(options.ns)) {
1753
+ options.defaultNS = options.ns;
1754
+ } else if (options.ns.indexOf('translation') < 0) {
1755
+ options.defaultNS = options.ns[0];
1756
+ }
1757
+ }
1758
+ const defOpts = get();
1759
+ this.options = {
1760
+ ...defOpts,
1761
+ ...this.options,
1762
+ ...transformOptions(options)
1763
+ };
1764
+ this.options.interpolation = {
1765
+ ...defOpts.interpolation,
1766
+ ...this.options.interpolation
1767
+ };
1768
+ if (options.keySeparator !== undefined) {
1769
+ this.options.userDefinedKeySeparator = options.keySeparator;
1770
+ }
1771
+ if (options.nsSeparator !== undefined) {
1772
+ this.options.userDefinedNsSeparator = options.nsSeparator;
1773
+ }
1774
+ const createClassOnDemand = ClassOrObject => {
1775
+ if (!ClassOrObject) return null;
1776
+ if (typeof ClassOrObject === 'function') return new ClassOrObject();
1777
+ return ClassOrObject;
1778
+ };
1779
+ if (!this.options.isClone) {
1780
+ if (this.modules.logger) {
1781
+ baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1782
+ } else {
1783
+ baseLogger.init(null, this.options);
1784
+ }
1785
+ let formatter;
1786
+ if (this.modules.formatter) {
1787
+ formatter = this.modules.formatter;
1788
+ } else {
1789
+ formatter = Formatter;
1790
+ }
1791
+ const lu = new LanguageUtil(this.options);
1792
+ this.store = new ResourceStore(this.options.resources, this.options);
1793
+ const s = this.services;
1794
+ s.logger = baseLogger;
1795
+ s.resourceStore = this.store;
1796
+ s.languageUtils = lu;
1797
+ s.pluralResolver = new PluralResolver(lu, {
1798
+ prepend: this.options.pluralSeparator,
1799
+ simplifyPluralSuffix: this.options.simplifyPluralSuffix
1800
+ });
1801
+ if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1802
+ s.formatter = createClassOnDemand(formatter);
1803
+ s.formatter.init(s, this.options);
1804
+ this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1805
+ }
1806
+ s.interpolator = new Interpolator(this.options);
1807
+ s.utils = {
1808
+ hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1809
+ };
1810
+ s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1811
+ s.backendConnector.on('*', function (event) {
1812
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1813
+ args[_key - 1] = arguments[_key];
1814
+ }
1815
+ _this.emit(event, ...args);
1816
+ });
1817
+ if (this.modules.languageDetector) {
1818
+ s.languageDetector = createClassOnDemand(this.modules.languageDetector);
1819
+ if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
1820
+ }
1821
+ if (this.modules.i18nFormat) {
1822
+ s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
1823
+ if (s.i18nFormat.init) s.i18nFormat.init(this);
1824
+ }
1825
+ this.translator = new Translator(this.services, this.options);
1826
+ this.translator.on('*', function (event) {
1827
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1828
+ args[_key2 - 1] = arguments[_key2];
1829
+ }
1830
+ _this.emit(event, ...args);
1831
+ });
1832
+ this.modules.external.forEach(m => {
1833
+ if (m.init) m.init(this);
1834
+ });
1835
+ }
1836
+ this.format = this.options.interpolation.format;
1837
+ if (!callback) callback = noop;
1838
+ if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1839
+ const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1840
+ if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
1841
+ }
1842
+ if (!this.services.languageDetector && !this.options.lng) {
1843
+ this.logger.warn('init: no languageDetector is used and no lng is defined');
1844
+ }
1845
+ const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
1846
+ storeApi.forEach(fcName => {
1847
+ this[fcName] = function () {
1848
+ return _this.store[fcName](...arguments);
1849
+ };
1850
+ });
1851
+ const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
1852
+ storeApiChained.forEach(fcName => {
1853
+ this[fcName] = function () {
1854
+ _this.store[fcName](...arguments);
1855
+ return _this;
1856
+ };
1857
+ });
1858
+ const deferred = defer();
1859
+ const load = () => {
1860
+ const finish = (err, t) => {
1861
+ this.isInitializing = false;
1862
+ if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
1863
+ this.isInitialized = true;
1864
+ if (!this.options.isClone) this.logger.log('initialized', this.options);
1865
+ this.emit('initialized', this.options);
1866
+ deferred.resolve(t);
1867
+ callback(err, t);
1868
+ };
1869
+ if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
1870
+ this.changeLanguage(this.options.lng, finish);
1871
+ };
1872
+ if (this.options.resources || !this.options.initAsync) {
1873
+ load();
1874
+ } else {
1875
+ setTimeout(load, 0);
1876
+ }
1877
+ return deferred;
1878
+ }
1879
+ loadResources(language) {
1880
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
1881
+ let usedCallback = callback;
1882
+ const usedLng = isString(language) ? language : this.language;
1883
+ if (typeof language === 'function') usedCallback = language;
1884
+ if (!this.options.resources || this.options.partialBundledLanguages) {
1885
+ if (usedLng?.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
1886
+ const toLoad = [];
1887
+ const append = lng => {
1888
+ if (!lng) return;
1889
+ if (lng === 'cimode') return;
1890
+ const lngs = this.services.languageUtils.toResolveHierarchy(lng);
1891
+ lngs.forEach(l => {
1892
+ if (l === 'cimode') return;
1893
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
1894
+ });
1895
+ };
1896
+ if (!usedLng) {
1897
+ const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1898
+ fallbacks.forEach(l => append(l));
1899
+ } else {
1900
+ append(usedLng);
1901
+ }
1902
+ this.options.preload?.forEach?.(l => append(l));
1903
+ this.services.backendConnector.load(toLoad, this.options.ns, e => {
1904
+ if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
1905
+ usedCallback(e);
1906
+ });
1907
+ } else {
1908
+ usedCallback(null);
1909
+ }
1910
+ }
1911
+ reloadResources(lngs, ns, callback) {
1912
+ const deferred = defer();
1913
+ if (typeof lngs === 'function') {
1914
+ callback = lngs;
1915
+ lngs = undefined;
1916
+ }
1917
+ if (typeof ns === 'function') {
1918
+ callback = ns;
1919
+ ns = undefined;
1920
+ }
1921
+ if (!lngs) lngs = this.languages;
1922
+ if (!ns) ns = this.options.ns;
1923
+ if (!callback) callback = noop;
1924
+ this.services.backendConnector.reload(lngs, ns, err => {
1925
+ deferred.resolve();
1926
+ callback(err);
1927
+ });
1928
+ return deferred;
1929
+ }
1930
+ use(module) {
1931
+ if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
1932
+ if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
1933
+ if (module.type === 'backend') {
1934
+ this.modules.backend = module;
1935
+ }
1936
+ if (module.type === 'logger' || module.log && module.warn && module.error) {
1937
+ this.modules.logger = module;
1938
+ }
1939
+ if (module.type === 'languageDetector') {
1940
+ this.modules.languageDetector = module;
1941
+ }
1942
+ if (module.type === 'i18nFormat') {
1943
+ this.modules.i18nFormat = module;
1944
+ }
1945
+ if (module.type === 'postProcessor') {
1946
+ postProcessor.addPostProcessor(module);
1947
+ }
1948
+ if (module.type === 'formatter') {
1949
+ this.modules.formatter = module;
1950
+ }
1951
+ if (module.type === '3rdParty') {
1952
+ this.modules.external.push(module);
1953
+ }
1954
+ return this;
1955
+ }
1956
+ setResolvedLanguage(l) {
1957
+ if (!l || !this.languages) return;
1958
+ if (['cimode', 'dev'].indexOf(l) > -1) return;
1959
+ for (let li = 0; li < this.languages.length; li++) {
1960
+ const lngInLngs = this.languages[li];
1961
+ if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
1962
+ if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
1963
+ this.resolvedLanguage = lngInLngs;
1964
+ break;
1965
+ }
1966
+ }
1967
+ }
1968
+ changeLanguage(lng, callback) {
1969
+ var _this2 = this;
1970
+ this.isLanguageChangingTo = lng;
1971
+ const deferred = defer();
1972
+ this.emit('languageChanging', lng);
1973
+ const setLngProps = l => {
1974
+ this.language = l;
1975
+ this.languages = this.services.languageUtils.toResolveHierarchy(l);
1976
+ this.resolvedLanguage = undefined;
1977
+ this.setResolvedLanguage(l);
1978
+ };
1979
+ const done = (err, l) => {
1980
+ if (l) {
1981
+ setLngProps(l);
1982
+ this.translator.changeLanguage(l);
1983
+ this.isLanguageChangingTo = undefined;
1984
+ this.emit('languageChanged', l);
1985
+ this.logger.log('languageChanged', l);
1986
+ } else {
1987
+ this.isLanguageChangingTo = undefined;
1988
+ }
1989
+ deferred.resolve(function () {
1990
+ return _this2.t(...arguments);
1991
+ });
1992
+ if (callback) callback(err, function () {
1993
+ return _this2.t(...arguments);
1994
+ });
1995
+ };
1996
+ const setLng = lngs => {
1997
+ if (!lng && !lngs && this.services.languageDetector) lngs = [];
1998
+ const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
1999
+ if (l) {
2000
+ if (!this.language) {
2001
+ setLngProps(l);
2002
+ }
2003
+ if (!this.translator.language) this.translator.changeLanguage(l);
2004
+ this.services.languageDetector?.cacheUserLanguage?.(l);
2005
+ }
2006
+ this.loadResources(l, err => {
2007
+ done(err, l);
2008
+ });
2009
+ };
2010
+ if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
2011
+ setLng(this.services.languageDetector.detect());
2012
+ } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
2013
+ if (this.services.languageDetector.detect.length === 0) {
2014
+ this.services.languageDetector.detect().then(setLng);
2015
+ } else {
2016
+ this.services.languageDetector.detect(setLng);
2017
+ }
2018
+ } else {
2019
+ setLng(lng);
2020
+ }
2021
+ return deferred;
2022
+ }
2023
+ getFixedT(lng, ns, keyPrefix) {
2024
+ var _this3 = this;
2025
+ const fixedT = function (key, opts) {
2026
+ let options;
2027
+ if (typeof opts !== 'object') {
2028
+ for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2029
+ rest[_key3 - 2] = arguments[_key3];
2030
+ }
2031
+ options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2032
+ } else {
2033
+ options = {
2034
+ ...opts
2035
+ };
2036
+ }
2037
+ options.lng = options.lng || fixedT.lng;
2038
+ options.lngs = options.lngs || fixedT.lngs;
2039
+ options.ns = options.ns || fixedT.ns;
2040
+ if (options.keyPrefix !== '') options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
2041
+ const keySeparator = _this3.options.keySeparator || '.';
2042
+ let resultKey;
2043
+ if (options.keyPrefix && Array.isArray(key)) {
2044
+ resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
2045
+ } else {
2046
+ resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
2047
+ }
2048
+ return _this3.t(resultKey, options);
2049
+ };
2050
+ if (isString(lng)) {
2051
+ fixedT.lng = lng;
2052
+ } else {
2053
+ fixedT.lngs = lng;
2054
+ }
2055
+ fixedT.ns = ns;
2056
+ fixedT.keyPrefix = keyPrefix;
2057
+ return fixedT;
2058
+ }
2059
+ t() {
2060
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2061
+ args[_key4] = arguments[_key4];
2062
+ }
2063
+ return this.translator?.translate(...args);
2064
+ }
2065
+ exists() {
2066
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
2067
+ args[_key5] = arguments[_key5];
2068
+ }
2069
+ return this.translator?.exists(...args);
2070
+ }
2071
+ setDefaultNamespace(ns) {
2072
+ this.options.defaultNS = ns;
2073
+ }
2074
+ hasLoadedNamespace(ns) {
2075
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2076
+ if (!this.isInitialized) {
2077
+ this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2078
+ return false;
2079
+ }
2080
+ if (!this.languages || !this.languages.length) {
2081
+ this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
2082
+ return false;
2083
+ }
2084
+ const lng = options.lng || this.resolvedLanguage || this.languages[0];
2085
+ const fallbackLng = this.options ? this.options.fallbackLng : false;
2086
+ const lastLng = this.languages[this.languages.length - 1];
2087
+ if (lng.toLowerCase() === 'cimode') return true;
2088
+ const loadNotPending = (l, n) => {
2089
+ const loadState = this.services.backendConnector.state[`${l}|${n}`];
2090
+ return loadState === -1 || loadState === 0 || loadState === 2;
2091
+ };
2092
+ if (options.precheck) {
2093
+ const preResult = options.precheck(this, loadNotPending);
2094
+ if (preResult !== undefined) return preResult;
2095
+ }
2096
+ if (this.hasResourceBundle(lng, ns)) return true;
2097
+ if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
2098
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2099
+ return false;
2100
+ }
2101
+ loadNamespaces(ns, callback) {
2102
+ const deferred = defer();
2103
+ if (!this.options.ns) {
2104
+ if (callback) callback();
2105
+ return Promise.resolve();
2106
+ }
2107
+ if (isString(ns)) ns = [ns];
2108
+ ns.forEach(n => {
2109
+ if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
2110
+ });
2111
+ this.loadResources(err => {
2112
+ deferred.resolve();
2113
+ if (callback) callback(err);
2114
+ });
2115
+ return deferred;
2116
+ }
2117
+ loadLanguages(lngs, callback) {
2118
+ const deferred = defer();
2119
+ if (isString(lngs)) lngs = [lngs];
2120
+ const preloaded = this.options.preload || [];
2121
+ const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
2122
+ if (!newLngs.length) {
2123
+ if (callback) callback();
2124
+ return Promise.resolve();
2125
+ }
2126
+ this.options.preload = preloaded.concat(newLngs);
2127
+ this.loadResources(err => {
2128
+ deferred.resolve();
2129
+ if (callback) callback(err);
2130
+ });
2131
+ return deferred;
2132
+ }
2133
+ dir(lng) {
2134
+ if (!lng) lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
2135
+ if (!lng) return 'rtl';
2136
+ const rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];
2137
+ const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
2138
+ return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2139
+ }
2140
+ static createInstance() {
2141
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2142
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
2143
+ return new I18n(options, callback);
2144
+ }
2145
+ cloneInstance() {
2146
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2147
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2148
+ const forkResourceStore = options.forkResourceStore;
2149
+ if (forkResourceStore) delete options.forkResourceStore;
2150
+ const mergedOptions = {
2151
+ ...this.options,
2152
+ ...options,
2153
+ ...{
2154
+ isClone: true
2155
+ }
2156
+ };
2157
+ const clone = new I18n(mergedOptions);
2158
+ if (options.debug !== undefined || options.prefix !== undefined) {
2159
+ clone.logger = clone.logger.clone(options);
2160
+ }
2161
+ const membersToCopy = ['store', 'services', 'language'];
2162
+ membersToCopy.forEach(m => {
2163
+ clone[m] = this[m];
2164
+ });
2165
+ clone.services = {
2166
+ ...this.services
2167
+ };
2168
+ clone.services.utils = {
2169
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2170
+ };
2171
+ if (forkResourceStore) {
2172
+ const clonedData = Object.keys(this.store.data).reduce((prev, l) => {
2173
+ prev[l] = {
2174
+ ...this.store.data[l]
2175
+ };
2176
+ return Object.keys(prev[l]).reduce((acc, n) => {
2177
+ acc[n] = {
2178
+ ...prev[l][n]
2179
+ };
2180
+ return acc;
2181
+ }, {});
2182
+ }, {});
2183
+ clone.store = new ResourceStore(clonedData, mergedOptions);
2184
+ clone.services.resourceStore = clone.store;
2185
+ }
2186
+ clone.translator = new Translator(clone.services, mergedOptions);
2187
+ clone.translator.on('*', function (event) {
2188
+ for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
2189
+ args[_key6 - 1] = arguments[_key6];
2190
+ }
2191
+ clone.emit(event, ...args);
2192
+ });
2193
+ clone.init(mergedOptions, callback);
2194
+ clone.translator.options = mergedOptions;
2195
+ clone.translator.backendConnector.services.utils = {
2196
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2197
+ };
2198
+ return clone;
2199
+ }
2200
+ toJSON() {
2201
+ return {
2202
+ options: this.options,
2203
+ store: this.store,
2204
+ language: this.language,
2205
+ languages: this.languages,
2206
+ resolvedLanguage: this.resolvedLanguage
2207
+ };
2208
+ }
2209
+ }
2210
+ const instance = I18n.createInstance();
2211
+ instance.createInstance = I18n.createInstance;
2212
+
2213
+ instance.createInstance;
2214
+ instance.dir;
2215
+ instance.init;
2216
+ instance.loadResources;
2217
+ instance.reloadResources;
2218
+ instance.use;
2219
+ instance.changeLanguage;
2220
+ instance.getFixedT;
2221
+ instance.t;
2222
+ instance.exists;
2223
+ instance.setDefaultNamespace;
2224
+ instance.hasLoadedNamespace;
2225
+ instance.loadNamespaces;
2226
+ instance.loadLanguages;
2227
+
2228
+ export { instance as default };