@dso-toolkit/core 66.1.0 → 66.3.0

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 (464) hide show
  1. package/dist/cjs/{annotation-body-b062e93f.js → annotation-body-0cf33638.js} +2 -2
  2. package/dist/cjs/{annotation-body-b062e93f.js.map → annotation-body-0cf33638.js.map} +1 -1
  3. package/dist/cjs/{annotation-symbol-slot-e9741f0b.js → annotation-symbol-slot-6665ae62.js} +2 -2
  4. package/dist/cjs/{annotation-symbol-slot-e9741f0b.js.map → annotation-symbol-slot-6665ae62.js.map} +1 -1
  5. package/dist/cjs/dso-accordion-section.cjs.entry.js +1 -1
  6. package/dist/cjs/dso-accordion.cjs.entry.js +1 -1
  7. package/dist/cjs/dso-action-list-item.cjs.entry.js +1 -1
  8. package/dist/cjs/dso-action-list.cjs.entry.js +1 -1
  9. package/dist/cjs/dso-advanced-select.cjs.entry.js +1 -1
  10. package/dist/cjs/dso-alert_6.cjs.entry.js +31 -24
  11. package/dist/cjs/dso-alert_6.cjs.entry.js.map +1 -1
  12. package/dist/cjs/dso-annotation-activiteit.cjs.entry.js +4 -4
  13. package/dist/cjs/dso-annotation-activiteit.cjs.entry.js.map +1 -1
  14. package/dist/cjs/dso-annotation-gebiedsaanwijzing.cjs.entry.js +4 -4
  15. package/dist/cjs/dso-annotation-gebiedsaanwijzing.cjs.entry.js.map +1 -1
  16. package/dist/cjs/dso-annotation-kaart.cjs.entry.js +3 -3
  17. package/dist/cjs/dso-annotation-kaart.cjs.entry.js.map +1 -1
  18. package/dist/cjs/dso-annotation-locatie_2.cjs.entry.js +6 -6
  19. package/dist/cjs/dso-annotation-locatie_2.cjs.entry.js.map +1 -1
  20. package/dist/cjs/dso-annotation-omgevingsnormwaarde.cjs.entry.js +4 -4
  21. package/dist/cjs/dso-annotation-omgevingsnormwaarde.cjs.entry.js.map +1 -1
  22. package/dist/cjs/dso-attachments-counter_2.cjs.entry.js +1 -1
  23. package/dist/cjs/dso-autosuggest.cjs.entry.js +24 -8
  24. package/dist/cjs/dso-autosuggest.cjs.entry.js.map +1 -1
  25. package/dist/cjs/dso-banner.cjs.entry.js +1 -1
  26. package/dist/cjs/dso-card-container.cjs.entry.js +1 -1
  27. package/dist/cjs/dso-card.cjs.entry.js +1 -1
  28. package/dist/cjs/dso-date-picker-legacy.cjs.entry.js +1 -1
  29. package/dist/cjs/dso-date-picker.cjs.entry.js +1 -1
  30. package/dist/cjs/dso-document-card.cjs.entry.js +1 -1
  31. package/dist/cjs/dso-dropdown-menu.cjs.entry.js +2 -2
  32. package/dist/cjs/dso-header.cjs.entry.js +28 -4
  33. package/dist/cjs/dso-header.cjs.entry.js.map +1 -1
  34. package/dist/cjs/dso-helpcenter-panel.cjs.entry.js +1 -1
  35. package/dist/cjs/dso-highlight-box.cjs.entry.js +1 -1
  36. package/dist/cjs/dso-icon.cjs.entry.js +1 -1
  37. package/dist/cjs/dso-info-button.cjs.entry.js +1 -1
  38. package/dist/cjs/dso-info_2.cjs.entry.js +2 -2
  39. package/dist/cjs/dso-input-range.cjs.entry.js +1 -1
  40. package/dist/cjs/dso-label_2.cjs.entry.js +1 -1
  41. package/dist/cjs/dso-legend-item.cjs.entry.js +1 -1
  42. package/dist/cjs/dso-list-button.cjs.entry.js +1 -1
  43. package/dist/cjs/dso-logo.cjs.entry.js +8 -4
  44. package/dist/cjs/dso-logo.cjs.entry.js.map +1 -1
  45. package/dist/cjs/dso-map-base-layers.cjs.entry.js +19 -3
  46. package/dist/cjs/dso-map-base-layers.cjs.entry.js.map +1 -1
  47. package/dist/cjs/dso-map-controls.cjs.entry.js +26 -3
  48. package/dist/cjs/dso-map-controls.cjs.entry.js.map +1 -1
  49. package/dist/cjs/dso-map-overlays.cjs.entry.js +19 -3
  50. package/dist/cjs/dso-map-overlays.cjs.entry.js.map +1 -1
  51. package/dist/cjs/dso-mark-bar.cjs.entry.js +2 -2
  52. package/dist/cjs/dso-modal.cjs.entry.js +21 -4
  53. package/dist/cjs/dso-modal.cjs.entry.js.map +1 -1
  54. package/dist/cjs/dso-pagination.cjs.entry.js +1 -1
  55. package/dist/cjs/dso-plekinfo-card.cjs.entry.js +7 -3
  56. package/dist/cjs/dso-plekinfo-card.cjs.entry.js.map +1 -1
  57. package/dist/cjs/dso-progress-bar.cjs.entry.js +2 -2
  58. package/dist/cjs/dso-progress-indicator.cjs.entry.js +19 -3
  59. package/dist/cjs/dso-progress-indicator.cjs.entry.js.map +1 -1
  60. package/dist/cjs/dso-project-item.cjs.entry.js +2 -2
  61. package/dist/cjs/dso-renvooi_2.cjs.entry.js +20 -17
  62. package/dist/cjs/dso-renvooi_2.cjs.entry.js.map +1 -1
  63. package/dist/cjs/dso-responsive-element.cjs.entry.js +2 -2
  64. package/dist/cjs/dso-scrollable.cjs.entry.js +3 -3
  65. package/dist/cjs/dso-skiplink.cjs.entry.js +32 -0
  66. package/dist/cjs/dso-skiplink.cjs.entry.js.map +1 -0
  67. package/dist/cjs/dso-tab.cjs.entry.js +1 -1
  68. package/dist/cjs/dso-tabs.cjs.entry.js +1 -1
  69. package/dist/cjs/dso-toggletip.cjs.entry.js +1 -1
  70. package/dist/cjs/dso-toolkit.cjs.js +3 -3
  71. package/dist/cjs/dso-toolkit.cjs.js.map +1 -1
  72. package/dist/cjs/dso-tree-view.cjs.entry.js +1 -1
  73. package/dist/cjs/dso-viewer-grid.cjs.entry.js +1 -1
  74. package/dist/cjs/dsot-document-component-demo.cjs.entry.js +9 -3
  75. package/dist/cjs/dsot-document-component-demo.cjs.entry.js.map +1 -1
  76. package/dist/cjs/i18n-012dfc26.js +2387 -0
  77. package/dist/cjs/i18n-012dfc26.js.map +1 -0
  78. package/dist/cjs/{index-848434f1.js → index-af1ebee1.js} +31 -14
  79. package/dist/cjs/index-af1ebee1.js.map +1 -0
  80. package/dist/cjs/loader.cjs.js +2 -2
  81. package/dist/cjs/v4-6fbeaa38.js +65 -0
  82. package/dist/cjs/v4-6fbeaa38.js.map +1 -0
  83. package/dist/collection/collection-manifest.json +3 -2
  84. package/dist/collection/components/alert/alert.i18n.js +19 -0
  85. package/dist/collection/components/alert/alert.i18n.js.map +1 -0
  86. package/dist/collection/components/alert/alert.js +6 -8
  87. package/dist/collection/components/alert/alert.js.map +1 -1
  88. package/dist/collection/components/annotation/annotation.css +5 -0
  89. package/dist/collection/components/autosuggest/autosuggest.i18n.js +13 -0
  90. package/dist/collection/components/autosuggest/autosuggest.i18n.js.map +1 -0
  91. package/dist/collection/components/autosuggest/autosuggest.js +11 -7
  92. package/dist/collection/components/autosuggest/autosuggest.js.map +1 -1
  93. package/dist/collection/components/document-component/document-component.css +35 -4
  94. package/dist/collection/components/document-component/document-component.js +2 -2
  95. package/dist/collection/components/document-component/document-component.js.map +1 -1
  96. package/dist/collection/components/document-component-demo/document-component.demo.js +8 -2
  97. package/dist/collection/components/document-component-demo/document-component.demo.js.map +1 -1
  98. package/dist/collection/components/header/header.i18n.js +22 -0
  99. package/dist/collection/components/header/header.i18n.js.map +1 -0
  100. package/dist/collection/components/header/header.js +6 -3
  101. package/dist/collection/components/header/header.js.map +1 -1
  102. package/dist/collection/components/image-overlay/image-overlay.css +10 -0
  103. package/dist/collection/components/logo/logo.js +25 -3
  104. package/dist/collection/components/logo/logo.js.map +1 -1
  105. package/dist/collection/components/map-base-layers/map-base-layers.i18n.js +13 -0
  106. package/dist/collection/components/map-base-layers/map-base-layers.i18n.js.map +1 -0
  107. package/dist/collection/components/map-base-layers/map-base-layers.js +5 -1
  108. package/dist/collection/components/map-base-layers/map-base-layers.js.map +1 -1
  109. package/dist/collection/components/map-controls/map-controls.i18n.js +21 -0
  110. package/dist/collection/components/map-controls/map-controls.i18n.js.map +1 -0
  111. package/dist/collection/components/map-controls/map-controls.js +6 -3
  112. package/dist/collection/components/map-controls/map-controls.js.map +1 -1
  113. package/dist/collection/components/map-overlays/map-overlays.i18n.js +13 -0
  114. package/dist/collection/components/map-overlays/map-overlays.i18n.js.map +1 -0
  115. package/dist/collection/components/map-overlays/map-overlays.js +5 -1
  116. package/dist/collection/components/map-overlays/map-overlays.js.map +1 -1
  117. package/dist/collection/components/mark-bar/mark-bar.js +1 -1
  118. package/dist/collection/components/modal/modal.i18n.js +15 -0
  119. package/dist/collection/components/modal/modal.i18n.js.map +1 -0
  120. package/dist/collection/components/modal/modal.js +5 -2
  121. package/dist/collection/components/modal/modal.js.map +1 -1
  122. package/dist/collection/components/ozon-content/nodes/figuur.node.js +1 -10
  123. package/dist/collection/components/ozon-content/nodes/figuur.node.js.map +1 -1
  124. package/dist/collection/components/ozon-content/ozon-content.css +19 -5
  125. package/dist/collection/components/ozon-content/ozon-content.js +1 -1
  126. package/dist/collection/components/panel/panel.css +7 -5
  127. package/dist/collection/components/plekinfo-card/plekinfo-card.css +12 -4
  128. package/dist/collection/components/plekinfo-card/plekinfo-card.js +26 -2
  129. package/dist/collection/components/plekinfo-card/plekinfo-card.js.map +1 -1
  130. package/dist/collection/components/progress-bar/progress-bar.js +1 -1
  131. package/dist/collection/components/progress-indicator/progress-indicator.i18n.js +13 -0
  132. package/dist/collection/components/progress-indicator/progress-indicator.i18n.js.map +1 -0
  133. package/dist/collection/components/progress-indicator/progress-indicator.js +9 -6
  134. package/dist/collection/components/progress-indicator/progress-indicator.js.map +1 -1
  135. package/dist/collection/components/project-item/project-item.js +1 -1
  136. package/dist/collection/components/renvooi/renvooi.css +9 -0
  137. package/dist/collection/components/renvooi/renvooi.js +17 -14
  138. package/dist/collection/components/renvooi/renvooi.js.map +1 -1
  139. package/dist/collection/components/responsive-element/responsive-element.js +1 -1
  140. package/dist/collection/components/scrollable/scrollable.js +2 -2
  141. package/dist/collection/components/selectable/selectable.js +1 -1
  142. package/dist/collection/components/skiplink/skiplink.css +40 -0
  143. package/dist/collection/components/skiplink/skiplink.interfaces.js +2 -0
  144. package/dist/collection/components/skiplink/skiplink.interfaces.js.map +1 -0
  145. package/dist/collection/components/skiplink/skiplink.js +92 -0
  146. package/dist/collection/components/skiplink/skiplink.js.map +1 -0
  147. package/dist/collection/utils/i18n.js +34 -0
  148. package/dist/collection/utils/i18n.js.map +1 -0
  149. package/dist/components/alert.js +24 -8
  150. package/dist/components/alert.js.map +1 -1
  151. package/dist/components/annotation-locatie.js +1 -1
  152. package/dist/components/annotation-locatie.js.map +1 -1
  153. package/dist/components/document-component.js +3 -3
  154. package/dist/components/document-component.js.map +1 -1
  155. package/dist/components/dso-annotation-activiteit.js +1 -1
  156. package/dist/components/dso-annotation-activiteit.js.map +1 -1
  157. package/dist/components/dso-annotation-gebiedsaanwijzing.js +1 -1
  158. package/dist/components/dso-annotation-gebiedsaanwijzing.js.map +1 -1
  159. package/dist/components/dso-annotation-kaart.js +1 -1
  160. package/dist/components/dso-annotation-kaart.js.map +1 -1
  161. package/dist/components/dso-annotation-omgevingsnormwaarde.js +1 -1
  162. package/dist/components/dso-annotation-omgevingsnormwaarde.js.map +1 -1
  163. package/dist/components/dso-autosuggest.js +22 -6
  164. package/dist/components/dso-autosuggest.js.map +1 -1
  165. package/dist/components/dso-header.js +27 -3
  166. package/dist/components/dso-header.js.map +1 -1
  167. package/dist/components/dso-logo.js +8 -3
  168. package/dist/components/dso-logo.js.map +1 -1
  169. package/dist/components/dso-map-base-layers.js +17 -1
  170. package/dist/components/dso-map-base-layers.js.map +1 -1
  171. package/dist/components/dso-map-controls.js +26 -3
  172. package/dist/components/dso-map-controls.js.map +1 -1
  173. package/dist/components/dso-map-overlays.js +17 -1
  174. package/dist/components/dso-map-overlays.js.map +1 -1
  175. package/dist/components/dso-mark-bar.js +1 -1
  176. package/dist/components/dso-modal.js +19 -2
  177. package/dist/components/dso-modal.js.map +1 -1
  178. package/dist/components/dso-plekinfo-card.js +8 -3
  179. package/dist/components/dso-plekinfo-card.js.map +1 -1
  180. package/dist/components/dso-progress-bar.js +1 -1
  181. package/dist/components/dso-project-item.js +1 -1
  182. package/dist/components/dso-skiplink.d.ts +11 -0
  183. package/dist/components/dso-skiplink.js +55 -0
  184. package/dist/components/dso-skiplink.js.map +1 -0
  185. package/dist/components/dsot-document-component-demo.js +8 -2
  186. package/dist/components/dsot-document-component-demo.js.map +1 -1
  187. package/dist/components/i18n.js +2385 -0
  188. package/dist/components/i18n.js.map +1 -0
  189. package/dist/components/image-overlay.js +1 -1
  190. package/dist/components/image-overlay.js.map +1 -1
  191. package/dist/components/index.d.ts +2 -0
  192. package/dist/components/index.js +1 -0
  193. package/dist/components/index.js.map +1 -1
  194. package/dist/components/ozon-content.js +3 -12
  195. package/dist/components/ozon-content.js.map +1 -1
  196. package/dist/components/panel.js +1 -1
  197. package/dist/components/panel.js.map +1 -1
  198. package/dist/components/progress-indicator.js +18 -2
  199. package/dist/components/progress-indicator.js.map +1 -1
  200. package/dist/components/renvooi.js +19 -21
  201. package/dist/components/renvooi.js.map +1 -1
  202. package/dist/components/responsive-element.js +1 -1
  203. package/dist/components/scrollable.js +2 -2
  204. package/dist/components/selectable.js +1 -1
  205. package/dist/components/v4.js +46 -48
  206. package/dist/components/v4.js.map +1 -1
  207. package/dist/dso-toolkit/dso-toolkit.esm.js +1 -1
  208. package/dist/dso-toolkit/dso-toolkit.esm.js.map +1 -1
  209. package/dist/dso-toolkit/p-00838920.entry.js +2 -0
  210. package/dist/dso-toolkit/p-00838920.entry.js.map +1 -0
  211. package/dist/dso-toolkit/p-036ff12b.js +2 -0
  212. package/dist/dso-toolkit/p-036ff12b.js.map +1 -0
  213. package/dist/dso-toolkit/{p-dd6cf2cd.entry.js → p-08121fee.entry.js} +2 -2
  214. package/dist/dso-toolkit/p-13396f6d.js +2 -0
  215. package/dist/dso-toolkit/p-221c5d0b.entry.js +2 -0
  216. package/dist/dso-toolkit/p-221c5d0b.entry.js.map +1 -0
  217. package/dist/dso-toolkit/{p-8e699eb2.entry.js → p-226833eb.entry.js} +2 -2
  218. package/dist/dso-toolkit/p-26fe4ae2.entry.js +2 -0
  219. package/dist/dso-toolkit/p-26fe4ae2.entry.js.map +1 -0
  220. package/dist/dso-toolkit/{p-fc82b0d0.entry.js → p-278837c5.entry.js} +2 -2
  221. package/dist/dso-toolkit/p-2d2eae19.entry.js +2 -0
  222. package/dist/dso-toolkit/p-2d2eae19.entry.js.map +1 -0
  223. package/dist/dso-toolkit/{p-e9896db2.entry.js → p-38cc23e1.entry.js} +2 -2
  224. package/dist/dso-toolkit/p-3e9068cd.entry.js +2 -0
  225. package/dist/dso-toolkit/p-3e9068cd.entry.js.map +1 -0
  226. package/dist/dso-toolkit/p-3f21e21c.entry.js +2 -0
  227. package/dist/dso-toolkit/p-3f21e21c.entry.js.map +1 -0
  228. package/dist/dso-toolkit/{p-cd1a65e7.entry.js → p-40810e10.entry.js} +2 -2
  229. package/dist/dso-toolkit/{p-6a414b15.entry.js → p-47ae7799.entry.js} +2 -2
  230. package/dist/dso-toolkit/{p-a705c684.entry.js → p-4cb8ef54.entry.js} +2 -2
  231. package/dist/dso-toolkit/{p-2dc8e61f.entry.js.map → p-4cb8ef54.entry.js.map} +1 -1
  232. package/dist/dso-toolkit/{p-404ea2b9.entry.js → p-52a2c0b3.entry.js} +2 -2
  233. package/dist/dso-toolkit/{p-404ea2b9.entry.js.map → p-52a2c0b3.entry.js.map} +1 -1
  234. package/dist/dso-toolkit/p-5a832300.entry.js +2 -0
  235. package/dist/dso-toolkit/p-5a832300.entry.js.map +1 -0
  236. package/dist/dso-toolkit/{p-b5744b74.entry.js → p-5c047dfd.entry.js} +2 -2
  237. package/dist/dso-toolkit/{p-9ebf26d8.entry.js → p-5e6704bb.entry.js} +2 -2
  238. package/dist/dso-toolkit/{p-331f52b3.entry.js → p-636a2ad2.entry.js} +2 -2
  239. package/dist/dso-toolkit/{p-a801f428.entry.js → p-74e0e63e.entry.js} +2 -2
  240. package/dist/dso-toolkit/{p-bda2d5ce.entry.js → p-75c65097.entry.js} +2 -2
  241. package/dist/dso-toolkit/{p-54fff8c0.entry.js → p-76dfbee3.entry.js} +2 -2
  242. package/dist/dso-toolkit/{p-ea46d648.entry.js → p-7dfc15c1.entry.js} +2 -2
  243. package/dist/dso-toolkit/p-7fc1e494.js +3 -0
  244. package/dist/dso-toolkit/p-7fc1e494.js.map +1 -0
  245. package/dist/dso-toolkit/{p-cc6c428b.entry.js → p-83f89965.entry.js} +2 -2
  246. package/dist/dso-toolkit/p-86cdbaf9.entry.js +2 -0
  247. package/dist/dso-toolkit/p-86cdbaf9.entry.js.map +1 -0
  248. package/dist/dso-toolkit/{p-a6f19891.entry.js → p-8bc5ab4d.entry.js} +2 -2
  249. package/dist/dso-toolkit/{p-8b9ee8d3.entry.js → p-921fe0b7.entry.js} +2 -2
  250. package/dist/dso-toolkit/p-92a7d8b0.entry.js +2 -0
  251. package/dist/dso-toolkit/p-92a7d8b0.entry.js.map +1 -0
  252. package/dist/dso-toolkit/{p-3cdfb92e.entry.js → p-9424e171.entry.js} +2 -2
  253. package/dist/dso-toolkit/{p-065ea3f8.entry.js → p-99995b02.entry.js} +2 -2
  254. package/dist/dso-toolkit/{p-3be4c978.entry.js → p-9d8395bc.entry.js} +2 -2
  255. package/dist/dso-toolkit/{p-e8322c5b.entry.js → p-9df0ed5f.entry.js} +2 -2
  256. package/dist/dso-toolkit/{p-2dc8e61f.entry.js → p-a3c7e119.entry.js} +2 -2
  257. package/dist/dso-toolkit/{p-a705c684.entry.js.map → p-a3c7e119.entry.js.map} +1 -1
  258. package/dist/dso-toolkit/{p-e96183ae.entry.js → p-a64e9cd5.entry.js} +2 -2
  259. package/dist/dso-toolkit/p-abe7047e.entry.js +2 -0
  260. package/dist/dso-toolkit/p-abe7047e.entry.js.map +1 -0
  261. package/dist/dso-toolkit/{p-e132910b.entry.js → p-b032496d.entry.js} +2 -2
  262. package/dist/dso-toolkit/{p-d885c651.entry.js → p-b0a3dfcb.entry.js} +2 -2
  263. package/dist/dso-toolkit/{p-bb87ef29.entry.js → p-b2f92815.entry.js} +2 -2
  264. package/dist/dso-toolkit/p-b2f92815.entry.js.map +1 -0
  265. package/dist/dso-toolkit/p-bc0a6bac.entry.js +2 -0
  266. package/dist/dso-toolkit/p-bc0a6bac.entry.js.map +1 -0
  267. package/dist/dso-toolkit/{p-ea804e9e.entry.js → p-c05d8f55.entry.js} +2 -2
  268. package/dist/dso-toolkit/{p-34f1afd3.entry.js → p-c3e38404.entry.js} +2 -2
  269. package/dist/dso-toolkit/{p-64bf55d1.entry.js → p-cb0a7103.entry.js} +2 -2
  270. package/dist/dso-toolkit/{p-786f3a41.entry.js → p-cdbb39ad.entry.js} +2 -2
  271. package/dist/dso-toolkit/p-d4317bc8.entry.js +2 -0
  272. package/dist/dso-toolkit/p-d4317bc8.entry.js.map +1 -0
  273. package/dist/dso-toolkit/{p-ab22347c.entry.js → p-de63f553.entry.js} +2 -2
  274. package/dist/dso-toolkit/{p-ef8fbe01.entry.js → p-e42e0cb4.entry.js} +2 -2
  275. package/dist/dso-toolkit/{p-778c0381.entry.js → p-e665556c.entry.js} +2 -2
  276. package/dist/dso-toolkit/{p-e283ee51.entry.js → p-ea87d930.entry.js} +2 -2
  277. package/dist/dso-toolkit/{p-e283ee51.entry.js.map → p-ea87d930.entry.js.map} +1 -1
  278. package/dist/dso-toolkit/p-eb579735.entry.js +2 -0
  279. package/dist/dso-toolkit/p-eb579735.entry.js.map +1 -0
  280. package/dist/dso-toolkit/{p-a644f41c.entry.js → p-ef087d87.entry.js} +2 -2
  281. package/dist/dso-toolkit/{p-ae8b8810.js → p-f11d080a.js} +2 -2
  282. package/dist/dso-toolkit/{p-487469c5.entry.js → p-f3717d91.entry.js} +2 -2
  283. package/dist/dso-toolkit/{p-05094f69.entry.js → p-fb5e4dc9.entry.js} +2 -2
  284. package/dist/dso-toolkit/p-ffb34aa5.js +2 -0
  285. package/dist/dso-toolkit/p-ffb34aa5.js.map +1 -0
  286. package/dist/esm/{annotation-body-75f77191.js → annotation-body-b9b58856.js} +2 -2
  287. package/dist/esm/{annotation-body-75f77191.js.map → annotation-body-b9b58856.js.map} +1 -1
  288. package/dist/esm/{annotation-symbol-slot-1947dce6.js → annotation-symbol-slot-74bf6f43.js} +2 -2
  289. package/dist/esm/{annotation-symbol-slot-1947dce6.js.map → annotation-symbol-slot-74bf6f43.js.map} +1 -1
  290. package/dist/esm/dso-accordion-section.entry.js +1 -1
  291. package/dist/esm/dso-accordion.entry.js +1 -1
  292. package/dist/esm/dso-action-list-item.entry.js +1 -1
  293. package/dist/esm/dso-action-list.entry.js +1 -1
  294. package/dist/esm/dso-advanced-select.entry.js +1 -1
  295. package/dist/esm/dso-alert_6.entry.js +31 -24
  296. package/dist/esm/dso-alert_6.entry.js.map +1 -1
  297. package/dist/esm/dso-annotation-activiteit.entry.js +4 -4
  298. package/dist/esm/dso-annotation-activiteit.entry.js.map +1 -1
  299. package/dist/esm/dso-annotation-gebiedsaanwijzing.entry.js +4 -4
  300. package/dist/esm/dso-annotation-gebiedsaanwijzing.entry.js.map +1 -1
  301. package/dist/esm/dso-annotation-kaart.entry.js +3 -3
  302. package/dist/esm/dso-annotation-kaart.entry.js.map +1 -1
  303. package/dist/esm/dso-annotation-locatie_2.entry.js +6 -6
  304. package/dist/esm/dso-annotation-locatie_2.entry.js.map +1 -1
  305. package/dist/esm/dso-annotation-omgevingsnormwaarde.entry.js +4 -4
  306. package/dist/esm/dso-annotation-omgevingsnormwaarde.entry.js.map +1 -1
  307. package/dist/esm/dso-attachments-counter_2.entry.js +1 -1
  308. package/dist/esm/dso-autosuggest.entry.js +24 -8
  309. package/dist/esm/dso-autosuggest.entry.js.map +1 -1
  310. package/dist/esm/dso-banner.entry.js +1 -1
  311. package/dist/esm/dso-card-container.entry.js +1 -1
  312. package/dist/esm/dso-card.entry.js +1 -1
  313. package/dist/esm/dso-date-picker-legacy.entry.js +1 -1
  314. package/dist/esm/dso-date-picker.entry.js +1 -1
  315. package/dist/esm/dso-document-card.entry.js +1 -1
  316. package/dist/esm/dso-dropdown-menu.entry.js +2 -2
  317. package/dist/esm/dso-header.entry.js +28 -4
  318. package/dist/esm/dso-header.entry.js.map +1 -1
  319. package/dist/esm/dso-helpcenter-panel.entry.js +1 -1
  320. package/dist/esm/dso-highlight-box.entry.js +1 -1
  321. package/dist/esm/dso-icon.entry.js +1 -1
  322. package/dist/esm/dso-info-button.entry.js +1 -1
  323. package/dist/esm/dso-info_2.entry.js +2 -2
  324. package/dist/esm/dso-input-range.entry.js +1 -1
  325. package/dist/esm/dso-label_2.entry.js +1 -1
  326. package/dist/esm/dso-legend-item.entry.js +1 -1
  327. package/dist/esm/dso-list-button.entry.js +1 -1
  328. package/dist/esm/dso-logo.entry.js +8 -4
  329. package/dist/esm/dso-logo.entry.js.map +1 -1
  330. package/dist/esm/dso-map-base-layers.entry.js +19 -3
  331. package/dist/esm/dso-map-base-layers.entry.js.map +1 -1
  332. package/dist/esm/dso-map-controls.entry.js +26 -3
  333. package/dist/esm/dso-map-controls.entry.js.map +1 -1
  334. package/dist/esm/dso-map-overlays.entry.js +19 -3
  335. package/dist/esm/dso-map-overlays.entry.js.map +1 -1
  336. package/dist/esm/dso-mark-bar.entry.js +2 -2
  337. package/dist/esm/dso-modal.entry.js +21 -4
  338. package/dist/esm/dso-modal.entry.js.map +1 -1
  339. package/dist/esm/dso-pagination.entry.js +1 -1
  340. package/dist/esm/dso-plekinfo-card.entry.js +7 -3
  341. package/dist/esm/dso-plekinfo-card.entry.js.map +1 -1
  342. package/dist/esm/dso-progress-bar.entry.js +2 -2
  343. package/dist/esm/dso-progress-indicator.entry.js +19 -3
  344. package/dist/esm/dso-progress-indicator.entry.js.map +1 -1
  345. package/dist/esm/dso-project-item.entry.js +2 -2
  346. package/dist/esm/dso-renvooi_2.entry.js +20 -17
  347. package/dist/esm/dso-renvooi_2.entry.js.map +1 -1
  348. package/dist/esm/dso-responsive-element.entry.js +2 -2
  349. package/dist/esm/dso-scrollable.entry.js +3 -3
  350. package/dist/esm/dso-skiplink.entry.js +28 -0
  351. package/dist/esm/dso-skiplink.entry.js.map +1 -0
  352. package/dist/esm/dso-tab.entry.js +1 -1
  353. package/dist/esm/dso-tabs.entry.js +1 -1
  354. package/dist/esm/dso-toggletip.entry.js +1 -1
  355. package/dist/esm/dso-toolkit.js +4 -4
  356. package/dist/esm/dso-toolkit.js.map +1 -1
  357. package/dist/esm/dso-tree-view.entry.js +1 -1
  358. package/dist/esm/dso-viewer-grid.entry.js +1 -1
  359. package/dist/esm/dsot-document-component-demo.entry.js +9 -3
  360. package/dist/esm/dsot-document-component-demo.entry.js.map +1 -1
  361. package/dist/esm/i18n-c3546551.js +2385 -0
  362. package/dist/esm/i18n-c3546551.js.map +1 -0
  363. package/dist/esm/{index-1a8f2a10.js → index-75547ccd.js} +31 -14
  364. package/dist/esm/index-75547ccd.js.map +1 -0
  365. package/dist/esm/loader.js +3 -3
  366. package/dist/esm/v4-692dad5f.js +63 -0
  367. package/dist/esm/v4-692dad5f.js.map +1 -0
  368. package/dist/types/components/alert/alert.d.ts +2 -1
  369. package/dist/types/components/alert/alert.i18n.d.ts +2 -0
  370. package/dist/types/components/autosuggest/autosuggest.d.ts +1 -0
  371. package/dist/types/components/autosuggest/autosuggest.i18n.d.ts +2 -0
  372. package/dist/types/components/document-component-demo/document-component.demo.d.ts +1 -0
  373. package/dist/types/components/header/header.d.ts +2 -1
  374. package/dist/types/components/header/header.i18n.d.ts +2 -0
  375. package/dist/types/components/logo/logo.d.ts +9 -1
  376. package/dist/types/components/map-base-layers/map-base-layers.d.ts +3 -1
  377. package/dist/types/components/map-base-layers/map-base-layers.i18n.d.ts +2 -0
  378. package/dist/types/components/map-controls/map-controls.d.ts +2 -1
  379. package/dist/types/components/map-controls/map-controls.i18n.d.ts +2 -0
  380. package/dist/types/components/map-overlays/map-overlays.d.ts +3 -1
  381. package/dist/types/components/map-overlays/map-overlays.i18n.d.ts +2 -0
  382. package/dist/types/components/modal/modal.d.ts +1 -0
  383. package/dist/types/components/modal/modal.i18n.d.ts +2 -0
  384. package/dist/types/components/ozon-content/nodes/figuur.node.d.ts +0 -3
  385. package/dist/types/components/plekinfo-card/plekinfo-card.d.ts +7 -0
  386. package/dist/types/components/progress-indicator/progress-indicator.d.ts +3 -1
  387. package/dist/types/components/progress-indicator/progress-indicator.i18n.d.ts +2 -0
  388. package/dist/types/components/skiplink/skiplink.d.ts +18 -0
  389. package/dist/types/components/skiplink/skiplink.interfaces.d.ts +5 -0
  390. package/dist/types/components.d.ts +67 -1
  391. package/dist/types/stencil-public-runtime.d.ts +6 -0
  392. package/dist/types/utils/i18n.d.ts +5 -0
  393. package/package.json +10 -9
  394. package/dist/cjs/index-848434f1.js.map +0 -1
  395. package/dist/cjs/v4-7014b8b0.js +0 -67
  396. package/dist/cjs/v4-7014b8b0.js.map +0 -1
  397. package/dist/dso-toolkit/p-00caab3b.js +0 -2
  398. package/dist/dso-toolkit/p-228e4c2d.entry.js +0 -2
  399. package/dist/dso-toolkit/p-228e4c2d.entry.js.map +0 -1
  400. package/dist/dso-toolkit/p-2d9b7138.entry.js +0 -2
  401. package/dist/dso-toolkit/p-2d9b7138.entry.js.map +0 -1
  402. package/dist/dso-toolkit/p-46e446b0.entry.js +0 -2
  403. package/dist/dso-toolkit/p-46e446b0.entry.js.map +0 -1
  404. package/dist/dso-toolkit/p-587779a5.entry.js +0 -2
  405. package/dist/dso-toolkit/p-587779a5.entry.js.map +0 -1
  406. package/dist/dso-toolkit/p-608835d8.entry.js +0 -2
  407. package/dist/dso-toolkit/p-608835d8.entry.js.map +0 -1
  408. package/dist/dso-toolkit/p-950d43d8.entry.js +0 -2
  409. package/dist/dso-toolkit/p-950d43d8.entry.js.map +0 -1
  410. package/dist/dso-toolkit/p-a168dbd1.entry.js +0 -2
  411. package/dist/dso-toolkit/p-a168dbd1.entry.js.map +0 -1
  412. package/dist/dso-toolkit/p-a9427715.entry.js +0 -2
  413. package/dist/dso-toolkit/p-a9427715.entry.js.map +0 -1
  414. package/dist/dso-toolkit/p-ae076d5b.entry.js +0 -2
  415. package/dist/dso-toolkit/p-ae076d5b.entry.js.map +0 -1
  416. package/dist/dso-toolkit/p-b623c74b.js +0 -3
  417. package/dist/dso-toolkit/p-b623c74b.js.map +0 -1
  418. package/dist/dso-toolkit/p-bb87ef29.entry.js.map +0 -1
  419. package/dist/dso-toolkit/p-dcea90be.entry.js +0 -2
  420. package/dist/dso-toolkit/p-dcea90be.entry.js.map +0 -1
  421. package/dist/dso-toolkit/p-e3fea9f8.entry.js +0 -2
  422. package/dist/dso-toolkit/p-e3fea9f8.entry.js.map +0 -1
  423. package/dist/dso-toolkit/p-e773c47e.entry.js +0 -2
  424. package/dist/dso-toolkit/p-e773c47e.entry.js.map +0 -1
  425. package/dist/dso-toolkit/p-f5ff676c.js +0 -2
  426. package/dist/dso-toolkit/p-f5ff676c.js.map +0 -1
  427. package/dist/esm/index-1a8f2a10.js.map +0 -1
  428. package/dist/esm/v4-a79185f4.js +0 -65
  429. package/dist/esm/v4-a79185f4.js.map +0 -1
  430. /package/dist/dso-toolkit/{p-dd6cf2cd.entry.js.map → p-08121fee.entry.js.map} +0 -0
  431. /package/dist/dso-toolkit/{p-00caab3b.js.map → p-13396f6d.js.map} +0 -0
  432. /package/dist/dso-toolkit/{p-8e699eb2.entry.js.map → p-226833eb.entry.js.map} +0 -0
  433. /package/dist/dso-toolkit/{p-fc82b0d0.entry.js.map → p-278837c5.entry.js.map} +0 -0
  434. /package/dist/dso-toolkit/{p-e9896db2.entry.js.map → p-38cc23e1.entry.js.map} +0 -0
  435. /package/dist/dso-toolkit/{p-cd1a65e7.entry.js.map → p-40810e10.entry.js.map} +0 -0
  436. /package/dist/dso-toolkit/{p-6a414b15.entry.js.map → p-47ae7799.entry.js.map} +0 -0
  437. /package/dist/dso-toolkit/{p-b5744b74.entry.js.map → p-5c047dfd.entry.js.map} +0 -0
  438. /package/dist/dso-toolkit/{p-9ebf26d8.entry.js.map → p-5e6704bb.entry.js.map} +0 -0
  439. /package/dist/dso-toolkit/{p-331f52b3.entry.js.map → p-636a2ad2.entry.js.map} +0 -0
  440. /package/dist/dso-toolkit/{p-a801f428.entry.js.map → p-74e0e63e.entry.js.map} +0 -0
  441. /package/dist/dso-toolkit/{p-bda2d5ce.entry.js.map → p-75c65097.entry.js.map} +0 -0
  442. /package/dist/dso-toolkit/{p-54fff8c0.entry.js.map → p-76dfbee3.entry.js.map} +0 -0
  443. /package/dist/dso-toolkit/{p-ea46d648.entry.js.map → p-7dfc15c1.entry.js.map} +0 -0
  444. /package/dist/dso-toolkit/{p-cc6c428b.entry.js.map → p-83f89965.entry.js.map} +0 -0
  445. /package/dist/dso-toolkit/{p-a6f19891.entry.js.map → p-8bc5ab4d.entry.js.map} +0 -0
  446. /package/dist/dso-toolkit/{p-8b9ee8d3.entry.js.map → p-921fe0b7.entry.js.map} +0 -0
  447. /package/dist/dso-toolkit/{p-3cdfb92e.entry.js.map → p-9424e171.entry.js.map} +0 -0
  448. /package/dist/dso-toolkit/{p-065ea3f8.entry.js.map → p-99995b02.entry.js.map} +0 -0
  449. /package/dist/dso-toolkit/{p-3be4c978.entry.js.map → p-9d8395bc.entry.js.map} +0 -0
  450. /package/dist/dso-toolkit/{p-e8322c5b.entry.js.map → p-9df0ed5f.entry.js.map} +0 -0
  451. /package/dist/dso-toolkit/{p-e96183ae.entry.js.map → p-a64e9cd5.entry.js.map} +0 -0
  452. /package/dist/dso-toolkit/{p-e132910b.entry.js.map → p-b032496d.entry.js.map} +0 -0
  453. /package/dist/dso-toolkit/{p-d885c651.entry.js.map → p-b0a3dfcb.entry.js.map} +0 -0
  454. /package/dist/dso-toolkit/{p-ea804e9e.entry.js.map → p-c05d8f55.entry.js.map} +0 -0
  455. /package/dist/dso-toolkit/{p-34f1afd3.entry.js.map → p-c3e38404.entry.js.map} +0 -0
  456. /package/dist/dso-toolkit/{p-64bf55d1.entry.js.map → p-cb0a7103.entry.js.map} +0 -0
  457. /package/dist/dso-toolkit/{p-786f3a41.entry.js.map → p-cdbb39ad.entry.js.map} +0 -0
  458. /package/dist/dso-toolkit/{p-ab22347c.entry.js.map → p-de63f553.entry.js.map} +0 -0
  459. /package/dist/dso-toolkit/{p-ef8fbe01.entry.js.map → p-e42e0cb4.entry.js.map} +0 -0
  460. /package/dist/dso-toolkit/{p-778c0381.entry.js.map → p-e665556c.entry.js.map} +0 -0
  461. /package/dist/dso-toolkit/{p-a644f41c.entry.js.map → p-ef087d87.entry.js.map} +0 -0
  462. /package/dist/dso-toolkit/{p-ae8b8810.js.map → p-f11d080a.js.map} +0 -0
  463. /package/dist/dso-toolkit/{p-487469c5.entry.js.map → p-f3717d91.entry.js.map} +0 -0
  464. /package/dist/dso-toolkit/{p-05094f69.entry.js.map → p-fb5e4dc9.entry.js.map} +0 -0
@@ -0,0 +1,2387 @@
1
+ 'use strict';
2
+
3
+ const isString = obj => typeof obj === 'string';
4
+ const defer = () => {
5
+ let res;
6
+ let rej;
7
+ const promise = new Promise((resolve, reject) => {
8
+ res = resolve;
9
+ rej = reject;
10
+ });
11
+ promise.resolve = res;
12
+ promise.reject = rej;
13
+ return promise;
14
+ };
15
+ const makeString = object => {
16
+ if (object == null) return '';
17
+ return '' + object;
18
+ };
19
+ const copy = (a, s, t) => {
20
+ a.forEach(m => {
21
+ if (s[m]) t[m] = s[m];
22
+ });
23
+ };
24
+ const lastOfPathSeparatorRegExp = /###/g;
25
+ const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
26
+ const canNotTraverseDeeper = object => !object || isString(object);
27
+ const getLastOfPath = (object, path, Empty) => {
28
+ const stack = !isString(path) ? path : path.split('.');
29
+ let stackIndex = 0;
30
+ while (stackIndex < stack.length - 1) {
31
+ if (canNotTraverseDeeper(object)) return {};
32
+ const key = cleanKey(stack[stackIndex]);
33
+ if (!object[key] && Empty) object[key] = new Empty();
34
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
35
+ object = object[key];
36
+ } else {
37
+ object = {};
38
+ }
39
+ ++stackIndex;
40
+ }
41
+ if (canNotTraverseDeeper(object)) return {};
42
+ return {
43
+ obj: object,
44
+ k: cleanKey(stack[stackIndex])
45
+ };
46
+ };
47
+ const setPath = (object, path, newValue) => {
48
+ const {
49
+ obj,
50
+ k
51
+ } = getLastOfPath(object, path, Object);
52
+ if (obj !== undefined || path.length === 1) {
53
+ obj[k] = newValue;
54
+ return;
55
+ }
56
+ let e = path[path.length - 1];
57
+ let p = path.slice(0, path.length - 1);
58
+ let last = getLastOfPath(object, p, Object);
59
+ while (last.obj === undefined && p.length) {
60
+ e = `${p[p.length - 1]}.${e}`;
61
+ p = p.slice(0, p.length - 1);
62
+ last = getLastOfPath(object, p, Object);
63
+ if (last && last.obj && typeof last.obj[`${last.k}.${e}`] !== 'undefined') {
64
+ last.obj = undefined;
65
+ }
66
+ }
67
+ last.obj[`${last.k}.${e}`] = newValue;
68
+ };
69
+ const pushPath = (object, path, newValue, concat) => {
70
+ const {
71
+ obj,
72
+ k
73
+ } = getLastOfPath(object, path, Object);
74
+ obj[k] = obj[k] || [];
75
+ obj[k].push(newValue);
76
+ };
77
+ const getPath = (object, path) => {
78
+ const {
79
+ obj,
80
+ k
81
+ } = getLastOfPath(object, path);
82
+ if (!obj) return undefined;
83
+ return obj[k];
84
+ };
85
+ const getPathWithDefaults = (data, defaultData, key) => {
86
+ const value = getPath(data, key);
87
+ if (value !== undefined) {
88
+ return value;
89
+ }
90
+ return getPath(defaultData, key);
91
+ };
92
+ const deepExtend = (target, source, overwrite) => {
93
+ for (const prop in source) {
94
+ if (prop !== '__proto__' && prop !== 'constructor') {
95
+ if (prop in target) {
96
+ if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
97
+ if (overwrite) target[prop] = source[prop];
98
+ } else {
99
+ deepExtend(target[prop], source[prop], overwrite);
100
+ }
101
+ } else {
102
+ target[prop] = source[prop];
103
+ }
104
+ }
105
+ }
106
+ return target;
107
+ };
108
+ const regexEscape = str => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
109
+ var _entityMap = {
110
+ '&': '&amp;',
111
+ '<': '&lt;',
112
+ '>': '&gt;',
113
+ '"': '&quot;',
114
+ "'": '&#39;',
115
+ '/': '&#x2F;'
116
+ };
117
+ const escape = data => {
118
+ if (isString(data)) {
119
+ return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
120
+ }
121
+ return data;
122
+ };
123
+ class RegExpCache {
124
+ constructor(capacity) {
125
+ this.capacity = capacity;
126
+ this.regExpMap = new Map();
127
+ this.regExpQueue = [];
128
+ }
129
+ getRegExp(pattern) {
130
+ const regExpFromCache = this.regExpMap.get(pattern);
131
+ if (regExpFromCache !== undefined) {
132
+ return regExpFromCache;
133
+ }
134
+ const regExpNew = new RegExp(pattern);
135
+ if (this.regExpQueue.length === this.capacity) {
136
+ this.regExpMap.delete(this.regExpQueue.shift());
137
+ }
138
+ this.regExpMap.set(pattern, regExpNew);
139
+ this.regExpQueue.push(pattern);
140
+ return regExpNew;
141
+ }
142
+ }
143
+ const chars = [' ', ',', '?', '!', ';'];
144
+ const looksLikeObjectPathRegExpCache = new RegExpCache(20);
145
+ const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
146
+ nsSeparator = nsSeparator || '';
147
+ keySeparator = keySeparator || '';
148
+ const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
149
+ if (possibleChars.length === 0) return true;
150
+ const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
151
+ let matched = !r.test(key);
152
+ if (!matched) {
153
+ const ki = key.indexOf(keySeparator);
154
+ if (ki > 0 && !r.test(key.substring(0, ki))) {
155
+ matched = true;
156
+ }
157
+ }
158
+ return matched;
159
+ };
160
+ const deepFind = function (obj, path) {
161
+ let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
162
+ if (!obj) return undefined;
163
+ if (obj[path]) return obj[path];
164
+ const tokens = path.split(keySeparator);
165
+ let current = obj;
166
+ for (let i = 0; i < tokens.length;) {
167
+ if (!current || typeof current !== 'object') {
168
+ return undefined;
169
+ }
170
+ let next;
171
+ let nextPath = '';
172
+ for (let j = i; j < tokens.length; ++j) {
173
+ if (j !== i) {
174
+ nextPath += keySeparator;
175
+ }
176
+ nextPath += tokens[j];
177
+ next = current[nextPath];
178
+ if (next !== undefined) {
179
+ if (['string', 'number', 'boolean'].indexOf(typeof next) > -1 && j < tokens.length - 1) {
180
+ continue;
181
+ }
182
+ i += j - i + 1;
183
+ break;
184
+ }
185
+ }
186
+ current = next;
187
+ }
188
+ return current;
189
+ };
190
+ const getCleanedCode = code => code && code.replace('_', '-');
191
+
192
+ const consoleLogger = {
193
+ type: 'logger',
194
+ log(args) {
195
+ this.output('log', args);
196
+ },
197
+ warn(args) {
198
+ this.output('warn', args);
199
+ },
200
+ error(args) {
201
+ this.output('error', args);
202
+ },
203
+ output(type, args) {
204
+ if (console && console[type]) console[type].apply(console, args);
205
+ }
206
+ };
207
+ class Logger {
208
+ constructor(concreteLogger) {
209
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
210
+ this.init(concreteLogger, options);
211
+ }
212
+ init(concreteLogger) {
213
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
214
+ this.prefix = options.prefix || 'i18next:';
215
+ this.logger = concreteLogger || consoleLogger;
216
+ this.options = options;
217
+ this.debug = options.debug;
218
+ }
219
+ log() {
220
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
221
+ args[_key] = arguments[_key];
222
+ }
223
+ return this.forward(args, 'log', '', true);
224
+ }
225
+ warn() {
226
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
227
+ args[_key2] = arguments[_key2];
228
+ }
229
+ return this.forward(args, 'warn', '', true);
230
+ }
231
+ error() {
232
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
233
+ args[_key3] = arguments[_key3];
234
+ }
235
+ return this.forward(args, 'error', '');
236
+ }
237
+ deprecate() {
238
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
239
+ args[_key4] = arguments[_key4];
240
+ }
241
+ return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
242
+ }
243
+ forward(args, lvl, prefix, debugOnly) {
244
+ if (debugOnly && !this.debug) return null;
245
+ if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
246
+ return this.logger[lvl](args);
247
+ }
248
+ create(moduleName) {
249
+ return new Logger(this.logger, {
250
+ ...{
251
+ prefix: `${this.prefix}:${moduleName}:`
252
+ },
253
+ ...this.options
254
+ });
255
+ }
256
+ clone(options) {
257
+ options = options || this.options;
258
+ options.prefix = options.prefix || this.prefix;
259
+ return new Logger(this.logger, options);
260
+ }
261
+ }
262
+ var baseLogger = new Logger();
263
+
264
+ class EventEmitter {
265
+ constructor() {
266
+ this.observers = {};
267
+ }
268
+ on(events, listener) {
269
+ events.split(' ').forEach(event => {
270
+ if (!this.observers[event]) this.observers[event] = new Map();
271
+ const numListeners = this.observers[event].get(listener) || 0;
272
+ this.observers[event].set(listener, numListeners + 1);
273
+ });
274
+ return this;
275
+ }
276
+ off(event, listener) {
277
+ if (!this.observers[event]) return;
278
+ if (!listener) {
279
+ delete this.observers[event];
280
+ return;
281
+ }
282
+ this.observers[event].delete(listener);
283
+ }
284
+ emit(event) {
285
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
286
+ args[_key - 1] = arguments[_key];
287
+ }
288
+ if (this.observers[event]) {
289
+ const cloned = Array.from(this.observers[event].entries());
290
+ cloned.forEach(_ref => {
291
+ let [observer, numTimesAdded] = _ref;
292
+ for (let i = 0; i < numTimesAdded; i++) {
293
+ observer(...args);
294
+ }
295
+ });
296
+ }
297
+ if (this.observers['*']) {
298
+ const cloned = Array.from(this.observers['*'].entries());
299
+ cloned.forEach(_ref2 => {
300
+ let [observer, numTimesAdded] = _ref2;
301
+ for (let i = 0; i < numTimesAdded; i++) {
302
+ observer.apply(observer, [event, ...args]);
303
+ }
304
+ });
305
+ }
306
+ }
307
+ }
308
+
309
+ class ResourceStore extends EventEmitter {
310
+ constructor(data) {
311
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
312
+ ns: ['translation'],
313
+ defaultNS: 'translation'
314
+ };
315
+ super();
316
+ this.data = data || {};
317
+ this.options = options;
318
+ if (this.options.keySeparator === undefined) {
319
+ this.options.keySeparator = '.';
320
+ }
321
+ if (this.options.ignoreJSONStructure === undefined) {
322
+ this.options.ignoreJSONStructure = true;
323
+ }
324
+ }
325
+ addNamespaces(ns) {
326
+ if (this.options.ns.indexOf(ns) < 0) {
327
+ this.options.ns.push(ns);
328
+ }
329
+ }
330
+ removeNamespaces(ns) {
331
+ const index = this.options.ns.indexOf(ns);
332
+ if (index > -1) {
333
+ this.options.ns.splice(index, 1);
334
+ }
335
+ }
336
+ getResource(lng, ns, key) {
337
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
338
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
339
+ const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
340
+ let path;
341
+ if (lng.indexOf('.') > -1) {
342
+ path = lng.split('.');
343
+ } else {
344
+ path = [lng, ns];
345
+ if (key) {
346
+ if (Array.isArray(key)) {
347
+ path.push(...key);
348
+ } else if (isString(key) && keySeparator) {
349
+ path.push(...key.split(keySeparator));
350
+ } else {
351
+ path.push(key);
352
+ }
353
+ }
354
+ }
355
+ const result = getPath(this.data, path);
356
+ if (!result && !ns && !key && lng.indexOf('.') > -1) {
357
+ lng = path[0];
358
+ ns = path[1];
359
+ key = path.slice(2).join('.');
360
+ }
361
+ if (result || !ignoreJSONStructure || !isString(key)) return result;
362
+ return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
363
+ }
364
+ addResource(lng, ns, key, value) {
365
+ let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
366
+ silent: false
367
+ };
368
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
369
+ let path = [lng, ns];
370
+ if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
371
+ if (lng.indexOf('.') > -1) {
372
+ path = lng.split('.');
373
+ value = ns;
374
+ ns = path[1];
375
+ }
376
+ this.addNamespaces(ns);
377
+ setPath(this.data, path, value);
378
+ if (!options.silent) this.emit('added', lng, ns, key, value);
379
+ }
380
+ addResources(lng, ns, resources) {
381
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
382
+ silent: false
383
+ };
384
+ for (const m in resources) {
385
+ if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
386
+ silent: true
387
+ });
388
+ }
389
+ if (!options.silent) this.emit('added', lng, ns, resources);
390
+ }
391
+ addResourceBundle(lng, ns, resources, deep, overwrite) {
392
+ let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
393
+ silent: false,
394
+ skipCopy: false
395
+ };
396
+ let path = [lng, ns];
397
+ if (lng.indexOf('.') > -1) {
398
+ path = lng.split('.');
399
+ deep = resources;
400
+ resources = ns;
401
+ ns = path[1];
402
+ }
403
+ this.addNamespaces(ns);
404
+ let pack = getPath(this.data, path) || {};
405
+ if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
406
+ if (deep) {
407
+ deepExtend(pack, resources, overwrite);
408
+ } else {
409
+ pack = {
410
+ ...pack,
411
+ ...resources
412
+ };
413
+ }
414
+ setPath(this.data, path, pack);
415
+ if (!options.silent) this.emit('added', lng, ns, resources);
416
+ }
417
+ removeResourceBundle(lng, ns) {
418
+ if (this.hasResourceBundle(lng, ns)) {
419
+ delete this.data[lng][ns];
420
+ }
421
+ this.removeNamespaces(ns);
422
+ this.emit('removed', lng, ns);
423
+ }
424
+ hasResourceBundle(lng, ns) {
425
+ return this.getResource(lng, ns) !== undefined;
426
+ }
427
+ getResourceBundle(lng, ns) {
428
+ if (!ns) ns = this.options.defaultNS;
429
+ if (this.options.compatibilityAPI === 'v1') return {
430
+ ...{},
431
+ ...this.getResource(lng, ns)
432
+ };
433
+ return this.getResource(lng, ns);
434
+ }
435
+ getDataByLanguage(lng) {
436
+ return this.data[lng];
437
+ }
438
+ hasLanguageSomeTranslations(lng) {
439
+ const data = this.getDataByLanguage(lng);
440
+ const n = data && Object.keys(data) || [];
441
+ return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
442
+ }
443
+ toJSON() {
444
+ return this.data;
445
+ }
446
+ }
447
+
448
+ var postProcessor = {
449
+ processors: {},
450
+ addPostProcessor(module) {
451
+ this.processors[module.name] = module;
452
+ },
453
+ handle(processors, value, key, options, translator) {
454
+ processors.forEach(processor => {
455
+ if (this.processors[processor]) value = this.processors[processor].process(value, key, options, translator);
456
+ });
457
+ return value;
458
+ }
459
+ };
460
+
461
+ const checkedLoadedFor = {};
462
+ class Translator extends EventEmitter {
463
+ constructor(services) {
464
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
465
+ super();
466
+ copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
467
+ this.options = options;
468
+ if (this.options.keySeparator === undefined) {
469
+ this.options.keySeparator = '.';
470
+ }
471
+ this.logger = baseLogger.create('translator');
472
+ }
473
+ changeLanguage(lng) {
474
+ if (lng) this.language = lng;
475
+ }
476
+ exists(key) {
477
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
478
+ interpolation: {}
479
+ };
480
+ if (key === undefined || key === null) {
481
+ return false;
482
+ }
483
+ const resolved = this.resolve(key, options);
484
+ return resolved && resolved.res !== undefined;
485
+ }
486
+ extractFromKey(key, options) {
487
+ let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
488
+ if (nsSeparator === undefined) nsSeparator = ':';
489
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
490
+ let namespaces = options.ns || this.options.defaultNS || [];
491
+ const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
492
+ const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
493
+ if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
494
+ const m = key.match(this.interpolator.nestingRegexp);
495
+ if (m && m.length > 0) {
496
+ return {
497
+ key,
498
+ namespaces
499
+ };
500
+ }
501
+ const parts = key.split(nsSeparator);
502
+ if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
503
+ key = parts.join(keySeparator);
504
+ }
505
+ if (isString(namespaces)) namespaces = [namespaces];
506
+ return {
507
+ key,
508
+ namespaces
509
+ };
510
+ }
511
+ translate(keys, options, lastKey) {
512
+ if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
513
+ options = this.options.overloadTranslationOptionHandler(arguments);
514
+ }
515
+ if (typeof options === 'object') options = {
516
+ ...options
517
+ };
518
+ if (!options) options = {};
519
+ if (keys === undefined || keys === null) return '';
520
+ if (!Array.isArray(keys)) keys = [String(keys)];
521
+ const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
522
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
523
+ const {
524
+ key,
525
+ namespaces
526
+ } = this.extractFromKey(keys[keys.length - 1], options);
527
+ const namespace = namespaces[namespaces.length - 1];
528
+ const lng = options.lng || this.language;
529
+ const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
530
+ if (lng && lng.toLowerCase() === 'cimode') {
531
+ if (appendNamespaceToCIMode) {
532
+ const nsSeparator = options.nsSeparator || this.options.nsSeparator;
533
+ if (returnDetails) {
534
+ return {
535
+ res: `${namespace}${nsSeparator}${key}`,
536
+ usedKey: key,
537
+ exactUsedKey: key,
538
+ usedLng: lng,
539
+ usedNS: namespace,
540
+ usedParams: this.getUsedParamsDetails(options)
541
+ };
542
+ }
543
+ return `${namespace}${nsSeparator}${key}`;
544
+ }
545
+ if (returnDetails) {
546
+ return {
547
+ res: key,
548
+ usedKey: key,
549
+ exactUsedKey: key,
550
+ usedLng: lng,
551
+ usedNS: namespace,
552
+ usedParams: this.getUsedParamsDetails(options)
553
+ };
554
+ }
555
+ return key;
556
+ }
557
+ const resolved = this.resolve(keys, options);
558
+ let res = resolved && resolved.res;
559
+ const resUsedKey = resolved && resolved.usedKey || key;
560
+ const resExactUsedKey = resolved && resolved.exactUsedKey || key;
561
+ const resType = Object.prototype.toString.apply(res);
562
+ const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
563
+ const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
564
+ const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
565
+ const handleAsObject = !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
566
+ if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(res))) {
567
+ if (!options.returnObjects && !this.options.returnObjects) {
568
+ if (!this.options.returnedObjectHandler) {
569
+ this.logger.warn('accessing an object - but returnObjects options is not enabled!');
570
+ }
571
+ const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {
572
+ ...options,
573
+ ns: namespaces
574
+ }) : `key '${key} (${this.language})' returned an object instead of string.`;
575
+ if (returnDetails) {
576
+ resolved.res = r;
577
+ resolved.usedParams = this.getUsedParamsDetails(options);
578
+ return resolved;
579
+ }
580
+ return r;
581
+ }
582
+ if (keySeparator) {
583
+ const resTypeIsArray = Array.isArray(res);
584
+ const copy = resTypeIsArray ? [] : {};
585
+ const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
586
+ for (const m in res) {
587
+ if (Object.prototype.hasOwnProperty.call(res, m)) {
588
+ const deepKey = `${newKeyToUse}${keySeparator}${m}`;
589
+ copy[m] = this.translate(deepKey, {
590
+ ...options,
591
+ ...{
592
+ joinArrays: false,
593
+ ns: namespaces
594
+ }
595
+ });
596
+ if (copy[m] === deepKey) copy[m] = res[m];
597
+ }
598
+ }
599
+ res = copy;
600
+ }
601
+ } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
602
+ res = res.join(joinArrays);
603
+ if (res) res = this.extendTranslation(res, keys, options, lastKey);
604
+ } else {
605
+ let usedDefault = false;
606
+ let usedKey = false;
607
+ const needsPluralHandling = options.count !== undefined && !isString(options.count);
608
+ const hasDefaultValue = Translator.hasDefaultValue(options);
609
+ const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
610
+ const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
611
+ ordinal: false
612
+ }) : '';
613
+ const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
614
+ const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
615
+ if (!this.isValidLookup(res) && hasDefaultValue) {
616
+ usedDefault = true;
617
+ res = defaultValue;
618
+ }
619
+ if (!this.isValidLookup(res)) {
620
+ usedKey = true;
621
+ res = key;
622
+ }
623
+ const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
624
+ const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
625
+ const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
626
+ if (usedKey || usedDefault || updateMissing) {
627
+ this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
628
+ if (keySeparator) {
629
+ const fk = this.resolve(key, {
630
+ ...options,
631
+ keySeparator: false
632
+ });
633
+ 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.');
634
+ }
635
+ let lngs = [];
636
+ const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
637
+ if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
638
+ for (let i = 0; i < fallbackLngs.length; i++) {
639
+ lngs.push(fallbackLngs[i]);
640
+ }
641
+ } else if (this.options.saveMissingTo === 'all') {
642
+ lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
643
+ } else {
644
+ lngs.push(options.lng || this.language);
645
+ }
646
+ const send = (l, k, specificDefaultValue) => {
647
+ const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
648
+ if (this.options.missingKeyHandler) {
649
+ this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
650
+ } else if (this.backendConnector && this.backendConnector.saveMissing) {
651
+ this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
652
+ }
653
+ this.emit('missingKey', l, namespace, k, res);
654
+ };
655
+ if (this.options.saveMissing) {
656
+ if (this.options.saveMissingPlurals && needsPluralHandling) {
657
+ lngs.forEach(language => {
658
+ const suffixes = this.pluralResolver.getSuffixes(language, options);
659
+ if (needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
660
+ suffixes.push(`${this.options.pluralSeparator}zero`);
661
+ }
662
+ suffixes.forEach(suffix => {
663
+ send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
664
+ });
665
+ });
666
+ } else {
667
+ send(lngs, key, defaultValue);
668
+ }
669
+ }
670
+ }
671
+ res = this.extendTranslation(res, keys, options, resolved, lastKey);
672
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
673
+ if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
674
+ if (this.options.compatibilityAPI !== 'v1') {
675
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
676
+ } else {
677
+ res = this.options.parseMissingKeyHandler(res);
678
+ }
679
+ }
680
+ }
681
+ if (returnDetails) {
682
+ resolved.res = res;
683
+ resolved.usedParams = this.getUsedParamsDetails(options);
684
+ return resolved;
685
+ }
686
+ return res;
687
+ }
688
+ extendTranslation(res, key, options, resolved, lastKey) {
689
+ var _this = this;
690
+ if (this.i18nFormat && this.i18nFormat.parse) {
691
+ res = this.i18nFormat.parse(res, {
692
+ ...this.options.interpolation.defaultVariables,
693
+ ...options
694
+ }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
695
+ resolved
696
+ });
697
+ } else if (!options.skipInterpolation) {
698
+ if (options.interpolation) this.interpolator.init({
699
+ ...options,
700
+ ...{
701
+ interpolation: {
702
+ ...this.options.interpolation,
703
+ ...options.interpolation
704
+ }
705
+ }
706
+ });
707
+ const skipOnVariables = isString(res) && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
708
+ let nestBef;
709
+ if (skipOnVariables) {
710
+ const nb = res.match(this.interpolator.nestingRegexp);
711
+ nestBef = nb && nb.length;
712
+ }
713
+ let data = options.replace && !isString(options.replace) ? options.replace : options;
714
+ if (this.options.interpolation.defaultVariables) data = {
715
+ ...this.options.interpolation.defaultVariables,
716
+ ...data
717
+ };
718
+ res = this.interpolator.interpolate(res, data, options.lng || this.language || resolved.usedLng, options);
719
+ if (skipOnVariables) {
720
+ const na = res.match(this.interpolator.nestingRegexp);
721
+ const nestAft = na && na.length;
722
+ if (nestBef < nestAft) options.nest = false;
723
+ }
724
+ if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = this.language || resolved.usedLng;
725
+ if (options.nest !== false) res = this.interpolator.nest(res, function () {
726
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
727
+ args[_key] = arguments[_key];
728
+ }
729
+ if (lastKey && lastKey[0] === args[0] && !options.context) {
730
+ _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
731
+ return null;
732
+ }
733
+ return _this.translate(...args, key);
734
+ }, options);
735
+ if (options.interpolation) this.interpolator.reset();
736
+ }
737
+ const postProcess = options.postProcess || this.options.postProcess;
738
+ const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
739
+ if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
740
+ res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
741
+ i18nResolved: {
742
+ ...resolved,
743
+ usedParams: this.getUsedParamsDetails(options)
744
+ },
745
+ ...options
746
+ } : options, this);
747
+ }
748
+ return res;
749
+ }
750
+ resolve(keys) {
751
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
752
+ let found;
753
+ let usedKey;
754
+ let exactUsedKey;
755
+ let usedLng;
756
+ let usedNS;
757
+ if (isString(keys)) keys = [keys];
758
+ keys.forEach(k => {
759
+ if (this.isValidLookup(found)) return;
760
+ const extracted = this.extractFromKey(k, options);
761
+ const key = extracted.key;
762
+ usedKey = key;
763
+ let namespaces = extracted.namespaces;
764
+ if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
765
+ const needsPluralHandling = options.count !== undefined && !isString(options.count);
766
+ const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
767
+ const needsContextHandling = options.context !== undefined && (isString(options.context) || typeof options.context === 'number') && options.context !== '';
768
+ const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
769
+ namespaces.forEach(ns => {
770
+ if (this.isValidLookup(found)) return;
771
+ usedNS = ns;
772
+ if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(usedNS)) {
773
+ checkedLoadedFor[`${codes[0]}-${ns}`] = true;
774
+ 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!!!');
775
+ }
776
+ codes.forEach(code => {
777
+ if (this.isValidLookup(found)) return;
778
+ usedLng = code;
779
+ const finalKeys = [key];
780
+ if (this.i18nFormat && this.i18nFormat.addLookupKeys) {
781
+ this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
782
+ } else {
783
+ let pluralSuffix;
784
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
785
+ const zeroSuffix = `${this.options.pluralSeparator}zero`;
786
+ const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
787
+ if (needsPluralHandling) {
788
+ finalKeys.push(key + pluralSuffix);
789
+ if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
790
+ finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
791
+ }
792
+ if (needsZeroSuffixLookup) {
793
+ finalKeys.push(key + zeroSuffix);
794
+ }
795
+ }
796
+ if (needsContextHandling) {
797
+ const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
798
+ finalKeys.push(contextKey);
799
+ if (needsPluralHandling) {
800
+ finalKeys.push(contextKey + pluralSuffix);
801
+ if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
802
+ finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
803
+ }
804
+ if (needsZeroSuffixLookup) {
805
+ finalKeys.push(contextKey + zeroSuffix);
806
+ }
807
+ }
808
+ }
809
+ }
810
+ let possibleKey;
811
+ while (possibleKey = finalKeys.pop()) {
812
+ if (!this.isValidLookup(found)) {
813
+ exactUsedKey = possibleKey;
814
+ found = this.getResource(code, ns, possibleKey, options);
815
+ }
816
+ }
817
+ });
818
+ });
819
+ });
820
+ return {
821
+ res: found,
822
+ usedKey,
823
+ exactUsedKey,
824
+ usedLng,
825
+ usedNS
826
+ };
827
+ }
828
+ isValidLookup(res) {
829
+ return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
830
+ }
831
+ getResource(code, ns, key) {
832
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
833
+ if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
834
+ return this.resourceStore.getResource(code, ns, key, options);
835
+ }
836
+ getUsedParamsDetails() {
837
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
838
+ const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
839
+ const useOptionsReplaceForData = options.replace && !isString(options.replace);
840
+ let data = useOptionsReplaceForData ? options.replace : options;
841
+ if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
842
+ data.count = options.count;
843
+ }
844
+ if (this.options.interpolation.defaultVariables) {
845
+ data = {
846
+ ...this.options.interpolation.defaultVariables,
847
+ ...data
848
+ };
849
+ }
850
+ if (!useOptionsReplaceForData) {
851
+ data = {
852
+ ...data
853
+ };
854
+ for (const key of optionsKeys) {
855
+ delete data[key];
856
+ }
857
+ }
858
+ return data;
859
+ }
860
+ static hasDefaultValue(options) {
861
+ const prefix = 'defaultValue';
862
+ for (const option in options) {
863
+ if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
864
+ return true;
865
+ }
866
+ }
867
+ return false;
868
+ }
869
+ }
870
+
871
+ const capitalize = string => string.charAt(0).toUpperCase() + string.slice(1);
872
+ class LanguageUtil {
873
+ constructor(options) {
874
+ this.options = options;
875
+ this.supportedLngs = this.options.supportedLngs || false;
876
+ this.logger = baseLogger.create('languageUtils');
877
+ }
878
+ getScriptPartFromCode(code) {
879
+ code = getCleanedCode(code);
880
+ if (!code || code.indexOf('-') < 0) return null;
881
+ const p = code.split('-');
882
+ if (p.length === 2) return null;
883
+ p.pop();
884
+ if (p[p.length - 1].toLowerCase() === 'x') return null;
885
+ return this.formatLanguageCode(p.join('-'));
886
+ }
887
+ getLanguagePartFromCode(code) {
888
+ code = getCleanedCode(code);
889
+ if (!code || code.indexOf('-') < 0) return code;
890
+ const p = code.split('-');
891
+ return this.formatLanguageCode(p[0]);
892
+ }
893
+ formatLanguageCode(code) {
894
+ if (isString(code) && code.indexOf('-') > -1) {
895
+ if (typeof Intl !== 'undefined' && typeof Intl.getCanonicalLocales !== 'undefined') {
896
+ try {
897
+ let formattedCode = Intl.getCanonicalLocales(code)[0];
898
+ if (formattedCode && this.options.lowerCaseLng) {
899
+ formattedCode = formattedCode.toLowerCase();
900
+ }
901
+ if (formattedCode) return formattedCode;
902
+ } catch (e) {}
903
+ }
904
+ const specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
905
+ let p = code.split('-');
906
+ if (this.options.lowerCaseLng) {
907
+ p = p.map(part => part.toLowerCase());
908
+ } else if (p.length === 2) {
909
+ p[0] = p[0].toLowerCase();
910
+ p[1] = p[1].toUpperCase();
911
+ if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
912
+ } else if (p.length === 3) {
913
+ p[0] = p[0].toLowerCase();
914
+ if (p[1].length === 2) p[1] = p[1].toUpperCase();
915
+ if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
916
+ if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
917
+ if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
918
+ }
919
+ return p.join('-');
920
+ }
921
+ return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
922
+ }
923
+ isSupportedCode(code) {
924
+ if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
925
+ code = this.getLanguagePartFromCode(code);
926
+ }
927
+ return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
928
+ }
929
+ getBestMatchFromCodes(codes) {
930
+ if (!codes) return null;
931
+ let found;
932
+ codes.forEach(code => {
933
+ if (found) return;
934
+ const cleanedLng = this.formatLanguageCode(code);
935
+ if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
936
+ });
937
+ if (!found && this.options.supportedLngs) {
938
+ codes.forEach(code => {
939
+ if (found) return;
940
+ const lngOnly = this.getLanguagePartFromCode(code);
941
+ if (this.isSupportedCode(lngOnly)) return found = lngOnly;
942
+ found = this.options.supportedLngs.find(supportedLng => {
943
+ if (supportedLng === lngOnly) return supportedLng;
944
+ if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
945
+ if (supportedLng.indexOf('-') > 0 && lngOnly.indexOf('-') < 0 && supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly) return supportedLng;
946
+ if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
947
+ });
948
+ });
949
+ }
950
+ if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
951
+ return found;
952
+ }
953
+ getFallbackCodes(fallbacks, code) {
954
+ if (!fallbacks) return [];
955
+ if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
956
+ if (isString(fallbacks)) fallbacks = [fallbacks];
957
+ if (Array.isArray(fallbacks)) return fallbacks;
958
+ if (!code) return fallbacks.default || [];
959
+ let found = fallbacks[code];
960
+ if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
961
+ if (!found) found = fallbacks[this.formatLanguageCode(code)];
962
+ if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
963
+ if (!found) found = fallbacks.default;
964
+ return found || [];
965
+ }
966
+ toResolveHierarchy(code, fallbackCode) {
967
+ const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
968
+ const codes = [];
969
+ const addCode = c => {
970
+ if (!c) return;
971
+ if (this.isSupportedCode(c)) {
972
+ codes.push(c);
973
+ } else {
974
+ this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
975
+ }
976
+ };
977
+ if (isString(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
978
+ if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
979
+ if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
980
+ if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
981
+ } else if (isString(code)) {
982
+ addCode(this.formatLanguageCode(code));
983
+ }
984
+ fallbackCodes.forEach(fc => {
985
+ if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
986
+ });
987
+ return codes;
988
+ }
989
+ }
990
+
991
+ let sets = [{
992
+ lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
993
+ nr: [1, 2],
994
+ fc: 1
995
+ }, {
996
+ lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kk', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
997
+ nr: [1, 2],
998
+ fc: 2
999
+ }, {
1000
+ lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
1001
+ nr: [1],
1002
+ fc: 3
1003
+ }, {
1004
+ lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
1005
+ nr: [1, 2, 5],
1006
+ fc: 4
1007
+ }, {
1008
+ lngs: ['ar'],
1009
+ nr: [0, 1, 2, 3, 11, 100],
1010
+ fc: 5
1011
+ }, {
1012
+ lngs: ['cs', 'sk'],
1013
+ nr: [1, 2, 5],
1014
+ fc: 6
1015
+ }, {
1016
+ lngs: ['csb', 'pl'],
1017
+ nr: [1, 2, 5],
1018
+ fc: 7
1019
+ }, {
1020
+ lngs: ['cy'],
1021
+ nr: [1, 2, 3, 8],
1022
+ fc: 8
1023
+ }, {
1024
+ lngs: ['fr'],
1025
+ nr: [1, 2],
1026
+ fc: 9
1027
+ }, {
1028
+ lngs: ['ga'],
1029
+ nr: [1, 2, 3, 7, 11],
1030
+ fc: 10
1031
+ }, {
1032
+ lngs: ['gd'],
1033
+ nr: [1, 2, 3, 20],
1034
+ fc: 11
1035
+ }, {
1036
+ lngs: ['is'],
1037
+ nr: [1, 2],
1038
+ fc: 12
1039
+ }, {
1040
+ lngs: ['jv'],
1041
+ nr: [0, 1],
1042
+ fc: 13
1043
+ }, {
1044
+ lngs: ['kw'],
1045
+ nr: [1, 2, 3, 4],
1046
+ fc: 14
1047
+ }, {
1048
+ lngs: ['lt'],
1049
+ nr: [1, 2, 10],
1050
+ fc: 15
1051
+ }, {
1052
+ lngs: ['lv'],
1053
+ nr: [1, 2, 0],
1054
+ fc: 16
1055
+ }, {
1056
+ lngs: ['mk'],
1057
+ nr: [1, 2],
1058
+ fc: 17
1059
+ }, {
1060
+ lngs: ['mnk'],
1061
+ nr: [0, 1, 2],
1062
+ fc: 18
1063
+ }, {
1064
+ lngs: ['mt'],
1065
+ nr: [1, 2, 11, 20],
1066
+ fc: 19
1067
+ }, {
1068
+ lngs: ['or'],
1069
+ nr: [2, 1],
1070
+ fc: 2
1071
+ }, {
1072
+ lngs: ['ro'],
1073
+ nr: [1, 2, 20],
1074
+ fc: 20
1075
+ }, {
1076
+ lngs: ['sl'],
1077
+ nr: [5, 1, 2, 3],
1078
+ fc: 21
1079
+ }, {
1080
+ lngs: ['he', 'iw'],
1081
+ nr: [1, 2, 20, 21],
1082
+ fc: 22
1083
+ }];
1084
+ let _rulesPluralsTypes = {
1085
+ 1: n => Number(n > 1),
1086
+ 2: n => Number(n != 1),
1087
+ 3: n => 0,
1088
+ 4: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
1089
+ 5: n => Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5),
1090
+ 6: n => Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2),
1091
+ 7: n => Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
1092
+ 8: n => Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3),
1093
+ 9: n => Number(n >= 2),
1094
+ 10: n => Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4),
1095
+ 11: n => Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3),
1096
+ 12: n => Number(n % 10 != 1 || n % 100 == 11),
1097
+ 13: n => Number(n !== 0),
1098
+ 14: n => Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3),
1099
+ 15: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
1100
+ 16: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2),
1101
+ 17: n => Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1),
1102
+ 18: n => Number(n == 0 ? 0 : n == 1 ? 1 : 2),
1103
+ 19: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3),
1104
+ 20: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2),
1105
+ 21: n => Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0),
1106
+ 22: n => Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3)
1107
+ };
1108
+ const nonIntlVersions = ['v1', 'v2', 'v3'];
1109
+ const intlVersions = ['v4'];
1110
+ const suffixesOrder = {
1111
+ zero: 0,
1112
+ one: 1,
1113
+ two: 2,
1114
+ few: 3,
1115
+ many: 4,
1116
+ other: 5
1117
+ };
1118
+ const createRules = () => {
1119
+ const rules = {};
1120
+ sets.forEach(set => {
1121
+ set.lngs.forEach(l => {
1122
+ rules[l] = {
1123
+ numbers: set.nr,
1124
+ plurals: _rulesPluralsTypes[set.fc]
1125
+ };
1126
+ });
1127
+ });
1128
+ return rules;
1129
+ };
1130
+ class PluralResolver {
1131
+ constructor(languageUtils) {
1132
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1133
+ this.languageUtils = languageUtils;
1134
+ this.options = options;
1135
+ this.logger = baseLogger.create('pluralResolver');
1136
+ if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
1137
+ this.options.compatibilityJSON = 'v3';
1138
+ this.logger.error('Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.');
1139
+ }
1140
+ this.rules = createRules();
1141
+ this.pluralRulesCache = {};
1142
+ }
1143
+ addRule(lng, obj) {
1144
+ this.rules[lng] = obj;
1145
+ }
1146
+ clearCache() {
1147
+ this.pluralRulesCache = {};
1148
+ }
1149
+ getRule(code) {
1150
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1151
+ if (this.shouldUseIntlApi()) {
1152
+ try {
1153
+ const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
1154
+ const type = options.ordinal ? 'ordinal' : 'cardinal';
1155
+ const cacheKey = JSON.stringify({
1156
+ cleanedCode,
1157
+ type
1158
+ });
1159
+ if (cacheKey in this.pluralRulesCache) {
1160
+ return this.pluralRulesCache[cacheKey];
1161
+ }
1162
+ const rule = new Intl.PluralRules(cleanedCode, {
1163
+ type
1164
+ });
1165
+ this.pluralRulesCache[cacheKey] = rule;
1166
+ return rule;
1167
+ } catch (err) {
1168
+ return;
1169
+ }
1170
+ }
1171
+ return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
1172
+ }
1173
+ needsPlural(code) {
1174
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1175
+ const rule = this.getRule(code, options);
1176
+ if (this.shouldUseIntlApi()) {
1177
+ return rule && rule.resolvedOptions().pluralCategories.length > 1;
1178
+ }
1179
+ return rule && rule.numbers.length > 1;
1180
+ }
1181
+ getPluralFormsOfKey(code, key) {
1182
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1183
+ return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
1184
+ }
1185
+ getSuffixes(code) {
1186
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1187
+ const rule = this.getRule(code, options);
1188
+ if (!rule) {
1189
+ return [];
1190
+ }
1191
+ if (this.shouldUseIntlApi()) {
1192
+ return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
1193
+ }
1194
+ return rule.numbers.map(number => this.getSuffix(code, number, options));
1195
+ }
1196
+ getSuffix(code, count) {
1197
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1198
+ const rule = this.getRule(code, options);
1199
+ if (rule) {
1200
+ if (this.shouldUseIntlApi()) {
1201
+ return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
1202
+ }
1203
+ return this.getSuffixRetroCompatible(rule, count);
1204
+ }
1205
+ this.logger.warn(`no plural rule found for: ${code}`);
1206
+ return '';
1207
+ }
1208
+ getSuffixRetroCompatible(rule, count) {
1209
+ const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
1210
+ let suffix = rule.numbers[idx];
1211
+ if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1212
+ if (suffix === 2) {
1213
+ suffix = 'plural';
1214
+ } else if (suffix === 1) {
1215
+ suffix = '';
1216
+ }
1217
+ }
1218
+ const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();
1219
+ if (this.options.compatibilityJSON === 'v1') {
1220
+ if (suffix === 1) return '';
1221
+ if (typeof suffix === 'number') return `_plural_${suffix.toString()}`;
1222
+ return returnSuffix();
1223
+ } else if (this.options.compatibilityJSON === 'v2') {
1224
+ return returnSuffix();
1225
+ } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1226
+ return returnSuffix();
1227
+ }
1228
+ return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
1229
+ }
1230
+ shouldUseIntlApi() {
1231
+ return !nonIntlVersions.includes(this.options.compatibilityJSON);
1232
+ }
1233
+ }
1234
+
1235
+ const deepFindWithDefaults = function (data, defaultData, key) {
1236
+ let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
1237
+ let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1238
+ let path = getPathWithDefaults(data, defaultData, key);
1239
+ if (!path && ignoreJSONStructure && isString(key)) {
1240
+ path = deepFind(data, key, keySeparator);
1241
+ if (path === undefined) path = deepFind(defaultData, key, keySeparator);
1242
+ }
1243
+ return path;
1244
+ };
1245
+ const regexSafe = val => val.replace(/\$/g, '$$$$');
1246
+ class Interpolator {
1247
+ constructor() {
1248
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1249
+ this.logger = baseLogger.create('interpolator');
1250
+ this.options = options;
1251
+ this.format = options.interpolation && options.interpolation.format || (value => value);
1252
+ this.init(options);
1253
+ }
1254
+ init() {
1255
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1256
+ if (!options.interpolation) options.interpolation = {
1257
+ escapeValue: true
1258
+ };
1259
+ const {
1260
+ escape: escape$1,
1261
+ escapeValue,
1262
+ useRawValueToEscape,
1263
+ prefix,
1264
+ prefixEscaped,
1265
+ suffix,
1266
+ suffixEscaped,
1267
+ formatSeparator,
1268
+ unescapeSuffix,
1269
+ unescapePrefix,
1270
+ nestingPrefix,
1271
+ nestingPrefixEscaped,
1272
+ nestingSuffix,
1273
+ nestingSuffixEscaped,
1274
+ nestingOptionsSeparator,
1275
+ maxReplaces,
1276
+ alwaysFormat
1277
+ } = options.interpolation;
1278
+ this.escape = escape$1 !== undefined ? escape$1 : escape;
1279
+ this.escapeValue = escapeValue !== undefined ? escapeValue : true;
1280
+ this.useRawValueToEscape = useRawValueToEscape !== undefined ? useRawValueToEscape : false;
1281
+ this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || '{{';
1282
+ this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || '}}';
1283
+ this.formatSeparator = formatSeparator || ',';
1284
+ this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix || '-';
1285
+ this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix || '';
1286
+ this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape('$t(');
1287
+ this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(')');
1288
+ this.nestingOptionsSeparator = nestingOptionsSeparator || ',';
1289
+ this.maxReplaces = maxReplaces || 1000;
1290
+ this.alwaysFormat = alwaysFormat !== undefined ? alwaysFormat : false;
1291
+ this.resetRegExp();
1292
+ }
1293
+ reset() {
1294
+ if (this.options) this.init(this.options);
1295
+ }
1296
+ resetRegExp() {
1297
+ const getOrResetRegExp = (existingRegExp, pattern) => {
1298
+ if (existingRegExp && existingRegExp.source === pattern) {
1299
+ existingRegExp.lastIndex = 0;
1300
+ return existingRegExp;
1301
+ }
1302
+ return new RegExp(pattern, 'g');
1303
+ };
1304
+ this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
1305
+ this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
1306
+ this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
1307
+ }
1308
+ interpolate(str, data, lng, options) {
1309
+ let match;
1310
+ let value;
1311
+ let replaces;
1312
+ const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1313
+ const handleFormat = key => {
1314
+ if (key.indexOf(this.formatSeparator) < 0) {
1315
+ const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
1316
+ return this.alwaysFormat ? this.format(path, undefined, lng, {
1317
+ ...options,
1318
+ ...data,
1319
+ interpolationkey: key
1320
+ }) : path;
1321
+ }
1322
+ const p = key.split(this.formatSeparator);
1323
+ const k = p.shift().trim();
1324
+ const f = p.join(this.formatSeparator).trim();
1325
+ return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
1326
+ ...options,
1327
+ ...data,
1328
+ interpolationkey: k
1329
+ });
1330
+ };
1331
+ this.resetRegExp();
1332
+ const missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
1333
+ const skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1334
+ const todos = [{
1335
+ regex: this.regexpUnescape,
1336
+ safeValue: val => regexSafe(val)
1337
+ }, {
1338
+ regex: this.regexp,
1339
+ safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
1340
+ }];
1341
+ todos.forEach(todo => {
1342
+ replaces = 0;
1343
+ while (match = todo.regex.exec(str)) {
1344
+ const matchedVar = match[1].trim();
1345
+ value = handleFormat(matchedVar);
1346
+ if (value === undefined) {
1347
+ if (typeof missingInterpolationHandler === 'function') {
1348
+ const temp = missingInterpolationHandler(str, match, options);
1349
+ value = isString(temp) ? temp : '';
1350
+ } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
1351
+ value = '';
1352
+ } else if (skipOnVariables) {
1353
+ value = match[0];
1354
+ continue;
1355
+ } else {
1356
+ this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1357
+ value = '';
1358
+ }
1359
+ } else if (!isString(value) && !this.useRawValueToEscape) {
1360
+ value = makeString(value);
1361
+ }
1362
+ const safeValue = todo.safeValue(value);
1363
+ str = str.replace(match[0], safeValue);
1364
+ if (skipOnVariables) {
1365
+ todo.regex.lastIndex += value.length;
1366
+ todo.regex.lastIndex -= match[0].length;
1367
+ } else {
1368
+ todo.regex.lastIndex = 0;
1369
+ }
1370
+ replaces++;
1371
+ if (replaces >= this.maxReplaces) {
1372
+ break;
1373
+ }
1374
+ }
1375
+ });
1376
+ return str;
1377
+ }
1378
+ nest(str, fc) {
1379
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1380
+ let match;
1381
+ let value;
1382
+ let clonedOptions;
1383
+ const handleHasOptions = (key, inheritedOptions) => {
1384
+ const sep = this.nestingOptionsSeparator;
1385
+ if (key.indexOf(sep) < 0) return key;
1386
+ const c = key.split(new RegExp(`${sep}[ ]*{`));
1387
+ let optionsString = `{${c[1]}`;
1388
+ key = c[0];
1389
+ optionsString = this.interpolate(optionsString, clonedOptions);
1390
+ const matchedSingleQuotes = optionsString.match(/'/g);
1391
+ const matchedDoubleQuotes = optionsString.match(/"/g);
1392
+ if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1393
+ optionsString = optionsString.replace(/'/g, '"');
1394
+ }
1395
+ try {
1396
+ clonedOptions = JSON.parse(optionsString);
1397
+ if (inheritedOptions) clonedOptions = {
1398
+ ...inheritedOptions,
1399
+ ...clonedOptions
1400
+ };
1401
+ } catch (e) {
1402
+ this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
1403
+ return `${key}${sep}${optionsString}`;
1404
+ }
1405
+ if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
1406
+ return key;
1407
+ };
1408
+ while (match = this.nestingRegexp.exec(str)) {
1409
+ let formatters = [];
1410
+ clonedOptions = {
1411
+ ...options
1412
+ };
1413
+ clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1414
+ clonedOptions.applyPostProcessor = false;
1415
+ delete clonedOptions.defaultValue;
1416
+ let doReduce = false;
1417
+ if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
1418
+ const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
1419
+ match[1] = r.shift();
1420
+ formatters = r;
1421
+ doReduce = true;
1422
+ }
1423
+ value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1424
+ if (value && match[0] === str && !isString(value)) return value;
1425
+ if (!isString(value)) value = makeString(value);
1426
+ if (!value) {
1427
+ this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1428
+ value = '';
1429
+ }
1430
+ if (doReduce) {
1431
+ value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1432
+ ...options,
1433
+ interpolationkey: match[1].trim()
1434
+ }), value.trim());
1435
+ }
1436
+ str = str.replace(match[0], value);
1437
+ this.regexp.lastIndex = 0;
1438
+ }
1439
+ return str;
1440
+ }
1441
+ }
1442
+
1443
+ const parseFormatStr = formatStr => {
1444
+ let formatName = formatStr.toLowerCase().trim();
1445
+ const formatOptions = {};
1446
+ if (formatStr.indexOf('(') > -1) {
1447
+ const p = formatStr.split('(');
1448
+ formatName = p[0].toLowerCase().trim();
1449
+ const optStr = p[1].substring(0, p[1].length - 1);
1450
+ if (formatName === 'currency' && optStr.indexOf(':') < 0) {
1451
+ if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1452
+ } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
1453
+ if (!formatOptions.range) formatOptions.range = optStr.trim();
1454
+ } else {
1455
+ const opts = optStr.split(';');
1456
+ opts.forEach(opt => {
1457
+ if (opt) {
1458
+ const [key, ...rest] = opt.split(':');
1459
+ const val = rest.join(':').trim().replace(/^'+|'+$/g, '');
1460
+ const trimmedKey = key.trim();
1461
+ if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
1462
+ if (val === 'false') formatOptions[trimmedKey] = false;
1463
+ if (val === 'true') formatOptions[trimmedKey] = true;
1464
+ if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
1465
+ }
1466
+ });
1467
+ }
1468
+ }
1469
+ return {
1470
+ formatName,
1471
+ formatOptions
1472
+ };
1473
+ };
1474
+ const createCachedFormatter = fn => {
1475
+ const cache = {};
1476
+ return (val, lng, options) => {
1477
+ let optForCache = options;
1478
+ if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
1479
+ optForCache = {
1480
+ ...optForCache,
1481
+ [options.interpolationkey]: undefined
1482
+ };
1483
+ }
1484
+ const key = lng + JSON.stringify(optForCache);
1485
+ let formatter = cache[key];
1486
+ if (!formatter) {
1487
+ formatter = fn(getCleanedCode(lng), options);
1488
+ cache[key] = formatter;
1489
+ }
1490
+ return formatter(val);
1491
+ };
1492
+ };
1493
+ class Formatter {
1494
+ constructor() {
1495
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1496
+ this.logger = baseLogger.create('formatter');
1497
+ this.options = options;
1498
+ this.formats = {
1499
+ number: createCachedFormatter((lng, opt) => val => new Intl.NumberFormat(lng, {
1500
+ ...opt
1501
+ }).format(val)),
1502
+ currency: createCachedFormatter((lng, opt) => val => new Intl.NumberFormat(lng, {
1503
+ ...opt,
1504
+ style: 'currency'
1505
+ }).format(val)),
1506
+ datetime: createCachedFormatter((lng, opt) => val => new Intl.DateTimeFormat(lng, {
1507
+ ...opt
1508
+ }).format(val)),
1509
+ relativetime: createCachedFormatter((lng, opt) => val => new Intl.RelativeTimeFormat(lng, {
1510
+ ...opt
1511
+ }).format(val, opt.range || 'day')),
1512
+ list: createCachedFormatter((lng, opt) => val => new Intl.ListFormat(lng, {
1513
+ ...opt
1514
+ }).format(val))
1515
+ };
1516
+ this.init(options);
1517
+ }
1518
+ init(services) {
1519
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1520
+ interpolation: {}
1521
+ };
1522
+ this.formatSeparator = options.interpolation.formatSeparator || ',';
1523
+ }
1524
+ add(name, fc) {
1525
+ this.formats[name.toLowerCase().trim()] = fc;
1526
+ }
1527
+ addCached(name, fc) {
1528
+ this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1529
+ }
1530
+ format(value, format, lng) {
1531
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1532
+ const formats = format.split(this.formatSeparator);
1533
+ if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
1534
+ const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
1535
+ formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
1536
+ }
1537
+ const result = formats.reduce((mem, f) => {
1538
+ const {
1539
+ formatName,
1540
+ formatOptions
1541
+ } = parseFormatStr(f);
1542
+ if (this.formats[formatName]) {
1543
+ let formatted = mem;
1544
+ try {
1545
+ const valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
1546
+ const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1547
+ formatted = this.formats[formatName](mem, l, {
1548
+ ...formatOptions,
1549
+ ...options,
1550
+ ...valOptions
1551
+ });
1552
+ } catch (error) {
1553
+ this.logger.warn(error);
1554
+ }
1555
+ return formatted;
1556
+ } else {
1557
+ this.logger.warn(`there was no format function for ${formatName}`);
1558
+ }
1559
+ return mem;
1560
+ }, value);
1561
+ return result;
1562
+ }
1563
+ }
1564
+
1565
+ const removePending = (q, name) => {
1566
+ if (q.pending[name] !== undefined) {
1567
+ delete q.pending[name];
1568
+ q.pendingCount--;
1569
+ }
1570
+ };
1571
+ class Connector extends EventEmitter {
1572
+ constructor(backend, store, services) {
1573
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1574
+ super();
1575
+ this.backend = backend;
1576
+ this.store = store;
1577
+ this.services = services;
1578
+ this.languageUtils = services.languageUtils;
1579
+ this.options = options;
1580
+ this.logger = baseLogger.create('backendConnector');
1581
+ this.waitingReads = [];
1582
+ this.maxParallelReads = options.maxParallelReads || 10;
1583
+ this.readingCalls = 0;
1584
+ this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
1585
+ this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1586
+ this.state = {};
1587
+ this.queue = [];
1588
+ if (this.backend && this.backend.init) {
1589
+ this.backend.init(services, options.backend, options);
1590
+ }
1591
+ }
1592
+ queueLoad(languages, namespaces, options, callback) {
1593
+ const toLoad = {};
1594
+ const pending = {};
1595
+ const toLoadLanguages = {};
1596
+ const toLoadNamespaces = {};
1597
+ languages.forEach(lng => {
1598
+ let hasAllNamespaces = true;
1599
+ namespaces.forEach(ns => {
1600
+ const name = `${lng}|${ns}`;
1601
+ if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
1602
+ this.state[name] = 2;
1603
+ } else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
1604
+ if (pending[name] === undefined) pending[name] = true;
1605
+ } else {
1606
+ this.state[name] = 1;
1607
+ hasAllNamespaces = false;
1608
+ if (pending[name] === undefined) pending[name] = true;
1609
+ if (toLoad[name] === undefined) toLoad[name] = true;
1610
+ if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
1611
+ }
1612
+ });
1613
+ if (!hasAllNamespaces) toLoadLanguages[lng] = true;
1614
+ });
1615
+ if (Object.keys(toLoad).length || Object.keys(pending).length) {
1616
+ this.queue.push({
1617
+ pending,
1618
+ pendingCount: Object.keys(pending).length,
1619
+ loaded: {},
1620
+ errors: [],
1621
+ callback
1622
+ });
1623
+ }
1624
+ return {
1625
+ toLoad: Object.keys(toLoad),
1626
+ pending: Object.keys(pending),
1627
+ toLoadLanguages: Object.keys(toLoadLanguages),
1628
+ toLoadNamespaces: Object.keys(toLoadNamespaces)
1629
+ };
1630
+ }
1631
+ loaded(name, err, data) {
1632
+ const s = name.split('|');
1633
+ const lng = s[0];
1634
+ const ns = s[1];
1635
+ if (err) this.emit('failedLoading', lng, ns, err);
1636
+ if (!err && data) {
1637
+ this.store.addResourceBundle(lng, ns, data, undefined, undefined, {
1638
+ skipCopy: true
1639
+ });
1640
+ }
1641
+ this.state[name] = err ? -1 : 2;
1642
+ if (err && data) this.state[name] = 0;
1643
+ const loaded = {};
1644
+ this.queue.forEach(q => {
1645
+ pushPath(q.loaded, [lng], ns);
1646
+ removePending(q, name);
1647
+ if (err) q.errors.push(err);
1648
+ if (q.pendingCount === 0 && !q.done) {
1649
+ Object.keys(q.loaded).forEach(l => {
1650
+ if (!loaded[l]) loaded[l] = {};
1651
+ const loadedKeys = q.loaded[l];
1652
+ if (loadedKeys.length) {
1653
+ loadedKeys.forEach(n => {
1654
+ if (loaded[l][n] === undefined) loaded[l][n] = true;
1655
+ });
1656
+ }
1657
+ });
1658
+ q.done = true;
1659
+ if (q.errors.length) {
1660
+ q.callback(q.errors);
1661
+ } else {
1662
+ q.callback();
1663
+ }
1664
+ }
1665
+ });
1666
+ this.emit('loaded', loaded);
1667
+ this.queue = this.queue.filter(q => !q.done);
1668
+ }
1669
+ read(lng, ns, fcName) {
1670
+ let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1671
+ let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
1672
+ let callback = arguments.length > 5 ? arguments[5] : undefined;
1673
+ if (!lng.length) return callback(null, {});
1674
+ if (this.readingCalls >= this.maxParallelReads) {
1675
+ this.waitingReads.push({
1676
+ lng,
1677
+ ns,
1678
+ fcName,
1679
+ tried,
1680
+ wait,
1681
+ callback
1682
+ });
1683
+ return;
1684
+ }
1685
+ this.readingCalls++;
1686
+ const resolver = (err, data) => {
1687
+ this.readingCalls--;
1688
+ if (this.waitingReads.length > 0) {
1689
+ const next = this.waitingReads.shift();
1690
+ this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
1691
+ }
1692
+ if (err && data && tried < this.maxRetries) {
1693
+ setTimeout(() => {
1694
+ this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
1695
+ }, wait);
1696
+ return;
1697
+ }
1698
+ callback(err, data);
1699
+ };
1700
+ const fc = this.backend[fcName].bind(this.backend);
1701
+ if (fc.length === 2) {
1702
+ try {
1703
+ const r = fc(lng, ns);
1704
+ if (r && typeof r.then === 'function') {
1705
+ r.then(data => resolver(null, data)).catch(resolver);
1706
+ } else {
1707
+ resolver(null, r);
1708
+ }
1709
+ } catch (err) {
1710
+ resolver(err);
1711
+ }
1712
+ return;
1713
+ }
1714
+ return fc(lng, ns, resolver);
1715
+ }
1716
+ prepareLoading(languages, namespaces) {
1717
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1718
+ let callback = arguments.length > 3 ? arguments[3] : undefined;
1719
+ if (!this.backend) {
1720
+ this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1721
+ return callback && callback();
1722
+ }
1723
+ if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
1724
+ if (isString(namespaces)) namespaces = [namespaces];
1725
+ const toLoad = this.queueLoad(languages, namespaces, options, callback);
1726
+ if (!toLoad.toLoad.length) {
1727
+ if (!toLoad.pending.length) callback();
1728
+ return null;
1729
+ }
1730
+ toLoad.toLoad.forEach(name => {
1731
+ this.loadOne(name);
1732
+ });
1733
+ }
1734
+ load(languages, namespaces, callback) {
1735
+ this.prepareLoading(languages, namespaces, {}, callback);
1736
+ }
1737
+ reload(languages, namespaces, callback) {
1738
+ this.prepareLoading(languages, namespaces, {
1739
+ reload: true
1740
+ }, callback);
1741
+ }
1742
+ loadOne(name) {
1743
+ let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1744
+ const s = name.split('|');
1745
+ const lng = s[0];
1746
+ const ns = s[1];
1747
+ this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
1748
+ if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
1749
+ if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
1750
+ this.loaded(name, err, data);
1751
+ });
1752
+ }
1753
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
1754
+ let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1755
+ let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
1756
+ if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
1757
+ 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!!!');
1758
+ return;
1759
+ }
1760
+ if (key === undefined || key === null || key === '') return;
1761
+ if (this.backend && this.backend.create) {
1762
+ const opts = {
1763
+ ...options,
1764
+ isUpdate
1765
+ };
1766
+ const fc = this.backend.create.bind(this.backend);
1767
+ if (fc.length < 6) {
1768
+ try {
1769
+ let r;
1770
+ if (fc.length === 5) {
1771
+ r = fc(languages, namespace, key, fallbackValue, opts);
1772
+ } else {
1773
+ r = fc(languages, namespace, key, fallbackValue);
1774
+ }
1775
+ if (r && typeof r.then === 'function') {
1776
+ r.then(data => clb(null, data)).catch(clb);
1777
+ } else {
1778
+ clb(null, r);
1779
+ }
1780
+ } catch (err) {
1781
+ clb(err);
1782
+ }
1783
+ } else {
1784
+ fc(languages, namespace, key, fallbackValue, clb, opts);
1785
+ }
1786
+ }
1787
+ if (!languages || !languages[0]) return;
1788
+ this.store.addResource(languages[0], namespace, key, fallbackValue);
1789
+ }
1790
+ }
1791
+
1792
+ const get = () => ({
1793
+ debug: false,
1794
+ initImmediate: true,
1795
+ ns: ['translation'],
1796
+ defaultNS: ['translation'],
1797
+ fallbackLng: ['dev'],
1798
+ fallbackNS: false,
1799
+ supportedLngs: false,
1800
+ nonExplicitSupportedLngs: false,
1801
+ load: 'all',
1802
+ preload: false,
1803
+ simplifyPluralSuffix: true,
1804
+ keySeparator: '.',
1805
+ nsSeparator: ':',
1806
+ pluralSeparator: '_',
1807
+ contextSeparator: '_',
1808
+ partialBundledLanguages: false,
1809
+ saveMissing: false,
1810
+ updateMissing: false,
1811
+ saveMissingTo: 'fallback',
1812
+ saveMissingPlurals: true,
1813
+ missingKeyHandler: false,
1814
+ missingInterpolationHandler: false,
1815
+ postProcess: false,
1816
+ postProcessPassResolved: false,
1817
+ returnNull: false,
1818
+ returnEmptyString: true,
1819
+ returnObjects: false,
1820
+ joinArrays: false,
1821
+ returnedObjectHandler: false,
1822
+ parseMissingKeyHandler: false,
1823
+ appendNamespaceToMissingKey: false,
1824
+ appendNamespaceToCIMode: false,
1825
+ overloadTranslationOptionHandler: args => {
1826
+ let ret = {};
1827
+ if (typeof args[1] === 'object') ret = args[1];
1828
+ if (isString(args[1])) ret.defaultValue = args[1];
1829
+ if (isString(args[2])) ret.tDescription = args[2];
1830
+ if (typeof args[2] === 'object' || typeof args[3] === 'object') {
1831
+ const options = args[3] || args[2];
1832
+ Object.keys(options).forEach(key => {
1833
+ ret[key] = options[key];
1834
+ });
1835
+ }
1836
+ return ret;
1837
+ },
1838
+ interpolation: {
1839
+ escapeValue: true,
1840
+ format: value => value,
1841
+ prefix: '{{',
1842
+ suffix: '}}',
1843
+ formatSeparator: ',',
1844
+ unescapePrefix: '-',
1845
+ nestingPrefix: '$t(',
1846
+ nestingSuffix: ')',
1847
+ nestingOptionsSeparator: ',',
1848
+ maxReplaces: 1000,
1849
+ skipOnVariables: true
1850
+ }
1851
+ });
1852
+ const transformOptions = options => {
1853
+ if (isString(options.ns)) options.ns = [options.ns];
1854
+ if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1855
+ if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1856
+ if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
1857
+ options.supportedLngs = options.supportedLngs.concat(['cimode']);
1858
+ }
1859
+ return options;
1860
+ };
1861
+
1862
+ const noop = () => {};
1863
+ const bindMemberFunctions = inst => {
1864
+ const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
1865
+ mems.forEach(mem => {
1866
+ if (typeof inst[mem] === 'function') {
1867
+ inst[mem] = inst[mem].bind(inst);
1868
+ }
1869
+ });
1870
+ };
1871
+ class I18n extends EventEmitter {
1872
+ constructor() {
1873
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1874
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
1875
+ super();
1876
+ this.options = transformOptions(options);
1877
+ this.services = {};
1878
+ this.logger = baseLogger;
1879
+ this.modules = {
1880
+ external: []
1881
+ };
1882
+ bindMemberFunctions(this);
1883
+ if (callback && !this.isInitialized && !options.isClone) {
1884
+ if (!this.options.initImmediate) {
1885
+ this.init(options, callback);
1886
+ return this;
1887
+ }
1888
+ setTimeout(() => {
1889
+ this.init(options, callback);
1890
+ }, 0);
1891
+ }
1892
+ }
1893
+ init() {
1894
+ var _this = this;
1895
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1896
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
1897
+ this.isInitializing = true;
1898
+ if (typeof options === 'function') {
1899
+ callback = options;
1900
+ options = {};
1901
+ }
1902
+ if (!options.defaultNS && options.defaultNS !== false && options.ns) {
1903
+ if (isString(options.ns)) {
1904
+ options.defaultNS = options.ns;
1905
+ } else if (options.ns.indexOf('translation') < 0) {
1906
+ options.defaultNS = options.ns[0];
1907
+ }
1908
+ }
1909
+ const defOpts = get();
1910
+ this.options = {
1911
+ ...defOpts,
1912
+ ...this.options,
1913
+ ...transformOptions(options)
1914
+ };
1915
+ if (this.options.compatibilityAPI !== 'v1') {
1916
+ this.options.interpolation = {
1917
+ ...defOpts.interpolation,
1918
+ ...this.options.interpolation
1919
+ };
1920
+ }
1921
+ if (options.keySeparator !== undefined) {
1922
+ this.options.userDefinedKeySeparator = options.keySeparator;
1923
+ }
1924
+ if (options.nsSeparator !== undefined) {
1925
+ this.options.userDefinedNsSeparator = options.nsSeparator;
1926
+ }
1927
+ const createClassOnDemand = ClassOrObject => {
1928
+ if (!ClassOrObject) return null;
1929
+ if (typeof ClassOrObject === 'function') return new ClassOrObject();
1930
+ return ClassOrObject;
1931
+ };
1932
+ if (!this.options.isClone) {
1933
+ if (this.modules.logger) {
1934
+ baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1935
+ } else {
1936
+ baseLogger.init(null, this.options);
1937
+ }
1938
+ let formatter;
1939
+ if (this.modules.formatter) {
1940
+ formatter = this.modules.formatter;
1941
+ } else if (typeof Intl !== 'undefined') {
1942
+ formatter = Formatter;
1943
+ }
1944
+ const lu = new LanguageUtil(this.options);
1945
+ this.store = new ResourceStore(this.options.resources, this.options);
1946
+ const s = this.services;
1947
+ s.logger = baseLogger;
1948
+ s.resourceStore = this.store;
1949
+ s.languageUtils = lu;
1950
+ s.pluralResolver = new PluralResolver(lu, {
1951
+ prepend: this.options.pluralSeparator,
1952
+ compatibilityJSON: this.options.compatibilityJSON,
1953
+ simplifyPluralSuffix: this.options.simplifyPluralSuffix
1954
+ });
1955
+ if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1956
+ s.formatter = createClassOnDemand(formatter);
1957
+ s.formatter.init(s, this.options);
1958
+ this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1959
+ }
1960
+ s.interpolator = new Interpolator(this.options);
1961
+ s.utils = {
1962
+ hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1963
+ };
1964
+ s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1965
+ s.backendConnector.on('*', function (event) {
1966
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1967
+ args[_key - 1] = arguments[_key];
1968
+ }
1969
+ _this.emit(event, ...args);
1970
+ });
1971
+ if (this.modules.languageDetector) {
1972
+ s.languageDetector = createClassOnDemand(this.modules.languageDetector);
1973
+ if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
1974
+ }
1975
+ if (this.modules.i18nFormat) {
1976
+ s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
1977
+ if (s.i18nFormat.init) s.i18nFormat.init(this);
1978
+ }
1979
+ this.translator = new Translator(this.services, this.options);
1980
+ this.translator.on('*', function (event) {
1981
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1982
+ args[_key2 - 1] = arguments[_key2];
1983
+ }
1984
+ _this.emit(event, ...args);
1985
+ });
1986
+ this.modules.external.forEach(m => {
1987
+ if (m.init) m.init(this);
1988
+ });
1989
+ }
1990
+ this.format = this.options.interpolation.format;
1991
+ if (!callback) callback = noop;
1992
+ if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1993
+ const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1994
+ if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
1995
+ }
1996
+ if (!this.services.languageDetector && !this.options.lng) {
1997
+ this.logger.warn('init: no languageDetector is used and no lng is defined');
1998
+ }
1999
+ const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
2000
+ storeApi.forEach(fcName => {
2001
+ this[fcName] = function () {
2002
+ return _this.store[fcName](...arguments);
2003
+ };
2004
+ });
2005
+ const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
2006
+ storeApiChained.forEach(fcName => {
2007
+ this[fcName] = function () {
2008
+ _this.store[fcName](...arguments);
2009
+ return _this;
2010
+ };
2011
+ });
2012
+ const deferred = defer();
2013
+ const load = () => {
2014
+ const finish = (err, t) => {
2015
+ this.isInitializing = false;
2016
+ if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
2017
+ this.isInitialized = true;
2018
+ if (!this.options.isClone) this.logger.log('initialized', this.options);
2019
+ this.emit('initialized', this.options);
2020
+ deferred.resolve(t);
2021
+ callback(err, t);
2022
+ };
2023
+ if (this.languages && this.options.compatibilityAPI !== 'v1' && !this.isInitialized) return finish(null, this.t.bind(this));
2024
+ this.changeLanguage(this.options.lng, finish);
2025
+ };
2026
+ if (this.options.resources || !this.options.initImmediate) {
2027
+ load();
2028
+ } else {
2029
+ setTimeout(load, 0);
2030
+ }
2031
+ return deferred;
2032
+ }
2033
+ loadResources(language) {
2034
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2035
+ let usedCallback = callback;
2036
+ const usedLng = isString(language) ? language : this.language;
2037
+ if (typeof language === 'function') usedCallback = language;
2038
+ if (!this.options.resources || this.options.partialBundledLanguages) {
2039
+ if (usedLng && usedLng.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
2040
+ const toLoad = [];
2041
+ const append = lng => {
2042
+ if (!lng) return;
2043
+ if (lng === 'cimode') return;
2044
+ const lngs = this.services.languageUtils.toResolveHierarchy(lng);
2045
+ lngs.forEach(l => {
2046
+ if (l === 'cimode') return;
2047
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
2048
+ });
2049
+ };
2050
+ if (!usedLng) {
2051
+ const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
2052
+ fallbacks.forEach(l => append(l));
2053
+ } else {
2054
+ append(usedLng);
2055
+ }
2056
+ if (this.options.preload) {
2057
+ this.options.preload.forEach(l => append(l));
2058
+ }
2059
+ this.services.backendConnector.load(toLoad, this.options.ns, e => {
2060
+ if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
2061
+ usedCallback(e);
2062
+ });
2063
+ } else {
2064
+ usedCallback(null);
2065
+ }
2066
+ }
2067
+ reloadResources(lngs, ns, callback) {
2068
+ const deferred = defer();
2069
+ if (typeof lngs === 'function') {
2070
+ callback = lngs;
2071
+ lngs = undefined;
2072
+ }
2073
+ if (typeof ns === 'function') {
2074
+ callback = ns;
2075
+ ns = undefined;
2076
+ }
2077
+ if (!lngs) lngs = this.languages;
2078
+ if (!ns) ns = this.options.ns;
2079
+ if (!callback) callback = noop;
2080
+ this.services.backendConnector.reload(lngs, ns, err => {
2081
+ deferred.resolve();
2082
+ callback(err);
2083
+ });
2084
+ return deferred;
2085
+ }
2086
+ use(module) {
2087
+ if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
2088
+ if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
2089
+ if (module.type === 'backend') {
2090
+ this.modules.backend = module;
2091
+ }
2092
+ if (module.type === 'logger' || module.log && module.warn && module.error) {
2093
+ this.modules.logger = module;
2094
+ }
2095
+ if (module.type === 'languageDetector') {
2096
+ this.modules.languageDetector = module;
2097
+ }
2098
+ if (module.type === 'i18nFormat') {
2099
+ this.modules.i18nFormat = module;
2100
+ }
2101
+ if (module.type === 'postProcessor') {
2102
+ postProcessor.addPostProcessor(module);
2103
+ }
2104
+ if (module.type === 'formatter') {
2105
+ this.modules.formatter = module;
2106
+ }
2107
+ if (module.type === '3rdParty') {
2108
+ this.modules.external.push(module);
2109
+ }
2110
+ return this;
2111
+ }
2112
+ setResolvedLanguage(l) {
2113
+ if (!l || !this.languages) return;
2114
+ if (['cimode', 'dev'].indexOf(l) > -1) return;
2115
+ for (let li = 0; li < this.languages.length; li++) {
2116
+ const lngInLngs = this.languages[li];
2117
+ if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
2118
+ if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
2119
+ this.resolvedLanguage = lngInLngs;
2120
+ break;
2121
+ }
2122
+ }
2123
+ }
2124
+ changeLanguage(lng, callback) {
2125
+ var _this2 = this;
2126
+ this.isLanguageChangingTo = lng;
2127
+ const deferred = defer();
2128
+ this.emit('languageChanging', lng);
2129
+ const setLngProps = l => {
2130
+ this.language = l;
2131
+ this.languages = this.services.languageUtils.toResolveHierarchy(l);
2132
+ this.resolvedLanguage = undefined;
2133
+ this.setResolvedLanguage(l);
2134
+ };
2135
+ const done = (err, l) => {
2136
+ if (l) {
2137
+ setLngProps(l);
2138
+ this.translator.changeLanguage(l);
2139
+ this.isLanguageChangingTo = undefined;
2140
+ this.emit('languageChanged', l);
2141
+ this.logger.log('languageChanged', l);
2142
+ } else {
2143
+ this.isLanguageChangingTo = undefined;
2144
+ }
2145
+ deferred.resolve(function () {
2146
+ return _this2.t(...arguments);
2147
+ });
2148
+ if (callback) callback(err, function () {
2149
+ return _this2.t(...arguments);
2150
+ });
2151
+ };
2152
+ const setLng = lngs => {
2153
+ if (!lng && !lngs && this.services.languageDetector) lngs = [];
2154
+ const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
2155
+ if (l) {
2156
+ if (!this.language) {
2157
+ setLngProps(l);
2158
+ }
2159
+ if (!this.translator.language) this.translator.changeLanguage(l);
2160
+ if (this.services.languageDetector && this.services.languageDetector.cacheUserLanguage) this.services.languageDetector.cacheUserLanguage(l);
2161
+ }
2162
+ this.loadResources(l, err => {
2163
+ done(err, l);
2164
+ });
2165
+ };
2166
+ if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
2167
+ setLng(this.services.languageDetector.detect());
2168
+ } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
2169
+ if (this.services.languageDetector.detect.length === 0) {
2170
+ this.services.languageDetector.detect().then(setLng);
2171
+ } else {
2172
+ this.services.languageDetector.detect(setLng);
2173
+ }
2174
+ } else {
2175
+ setLng(lng);
2176
+ }
2177
+ return deferred;
2178
+ }
2179
+ getFixedT(lng, ns, keyPrefix) {
2180
+ var _this3 = this;
2181
+ const fixedT = function (key, opts) {
2182
+ let options;
2183
+ if (typeof opts !== 'object') {
2184
+ for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2185
+ rest[_key3 - 2] = arguments[_key3];
2186
+ }
2187
+ options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2188
+ } else {
2189
+ options = {
2190
+ ...opts
2191
+ };
2192
+ }
2193
+ options.lng = options.lng || fixedT.lng;
2194
+ options.lngs = options.lngs || fixedT.lngs;
2195
+ options.ns = options.ns || fixedT.ns;
2196
+ if (options.keyPrefix !== '') options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
2197
+ const keySeparator = _this3.options.keySeparator || '.';
2198
+ let resultKey;
2199
+ if (options.keyPrefix && Array.isArray(key)) {
2200
+ resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
2201
+ } else {
2202
+ resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
2203
+ }
2204
+ return _this3.t(resultKey, options);
2205
+ };
2206
+ if (isString(lng)) {
2207
+ fixedT.lng = lng;
2208
+ } else {
2209
+ fixedT.lngs = lng;
2210
+ }
2211
+ fixedT.ns = ns;
2212
+ fixedT.keyPrefix = keyPrefix;
2213
+ return fixedT;
2214
+ }
2215
+ t() {
2216
+ return this.translator && this.translator.translate(...arguments);
2217
+ }
2218
+ exists() {
2219
+ return this.translator && this.translator.exists(...arguments);
2220
+ }
2221
+ setDefaultNamespace(ns) {
2222
+ this.options.defaultNS = ns;
2223
+ }
2224
+ hasLoadedNamespace(ns) {
2225
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2226
+ if (!this.isInitialized) {
2227
+ this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2228
+ return false;
2229
+ }
2230
+ if (!this.languages || !this.languages.length) {
2231
+ this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
2232
+ return false;
2233
+ }
2234
+ const lng = options.lng || this.resolvedLanguage || this.languages[0];
2235
+ const fallbackLng = this.options ? this.options.fallbackLng : false;
2236
+ const lastLng = this.languages[this.languages.length - 1];
2237
+ if (lng.toLowerCase() === 'cimode') return true;
2238
+ const loadNotPending = (l, n) => {
2239
+ const loadState = this.services.backendConnector.state[`${l}|${n}`];
2240
+ return loadState === -1 || loadState === 0 || loadState === 2;
2241
+ };
2242
+ if (options.precheck) {
2243
+ const preResult = options.precheck(this, loadNotPending);
2244
+ if (preResult !== undefined) return preResult;
2245
+ }
2246
+ if (this.hasResourceBundle(lng, ns)) return true;
2247
+ if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
2248
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2249
+ return false;
2250
+ }
2251
+ loadNamespaces(ns, callback) {
2252
+ const deferred = defer();
2253
+ if (!this.options.ns) {
2254
+ if (callback) callback();
2255
+ return Promise.resolve();
2256
+ }
2257
+ if (isString(ns)) ns = [ns];
2258
+ ns.forEach(n => {
2259
+ if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
2260
+ });
2261
+ this.loadResources(err => {
2262
+ deferred.resolve();
2263
+ if (callback) callback(err);
2264
+ });
2265
+ return deferred;
2266
+ }
2267
+ loadLanguages(lngs, callback) {
2268
+ const deferred = defer();
2269
+ if (isString(lngs)) lngs = [lngs];
2270
+ const preloaded = this.options.preload || [];
2271
+ const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
2272
+ if (!newLngs.length) {
2273
+ if (callback) callback();
2274
+ return Promise.resolve();
2275
+ }
2276
+ this.options.preload = preloaded.concat(newLngs);
2277
+ this.loadResources(err => {
2278
+ deferred.resolve();
2279
+ if (callback) callback(err);
2280
+ });
2281
+ return deferred;
2282
+ }
2283
+ dir(lng) {
2284
+ if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
2285
+ if (!lng) return 'rtl';
2286
+ 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'];
2287
+ const languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
2288
+ return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2289
+ }
2290
+ static createInstance() {
2291
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2292
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
2293
+ return new I18n(options, callback);
2294
+ }
2295
+ cloneInstance() {
2296
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2297
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2298
+ const forkResourceStore = options.forkResourceStore;
2299
+ if (forkResourceStore) delete options.forkResourceStore;
2300
+ const mergedOptions = {
2301
+ ...this.options,
2302
+ ...options,
2303
+ ...{
2304
+ isClone: true
2305
+ }
2306
+ };
2307
+ const clone = new I18n(mergedOptions);
2308
+ if (options.debug !== undefined || options.prefix !== undefined) {
2309
+ clone.logger = clone.logger.clone(options);
2310
+ }
2311
+ const membersToCopy = ['store', 'services', 'language'];
2312
+ membersToCopy.forEach(m => {
2313
+ clone[m] = this[m];
2314
+ });
2315
+ clone.services = {
2316
+ ...this.services
2317
+ };
2318
+ clone.services.utils = {
2319
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2320
+ };
2321
+ if (forkResourceStore) {
2322
+ clone.store = new ResourceStore(this.store.data, mergedOptions);
2323
+ clone.services.resourceStore = clone.store;
2324
+ }
2325
+ clone.translator = new Translator(clone.services, mergedOptions);
2326
+ clone.translator.on('*', function (event) {
2327
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
2328
+ args[_key4 - 1] = arguments[_key4];
2329
+ }
2330
+ clone.emit(event, ...args);
2331
+ });
2332
+ clone.init(mergedOptions, callback);
2333
+ clone.translator.options = mergedOptions;
2334
+ clone.translator.backendConnector.services.utils = {
2335
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2336
+ };
2337
+ return clone;
2338
+ }
2339
+ toJSON() {
2340
+ return {
2341
+ options: this.options,
2342
+ store: this.store,
2343
+ language: this.language,
2344
+ languages: this.languages,
2345
+ resolvedLanguage: this.resolvedLanguage
2346
+ };
2347
+ }
2348
+ }
2349
+ const instance = I18n.createInstance();
2350
+ instance.createInstance = I18n.createInstance;
2351
+
2352
+ const DEFAULT_LANG = "nl";
2353
+ function getComponentClosestLanguage(element) {
2354
+ const closestLangElement = element.closest("[lang]");
2355
+ if (closestLangElement instanceof HTMLElement) {
2356
+ return closestLangElement.lang || DEFAULT_LANG;
2357
+ }
2358
+ if (element.parentNode instanceof ShadowRoot && element.parentNode.host instanceof HTMLElement) {
2359
+ return getComponentClosestLanguage(element.parentNode.host);
2360
+ }
2361
+ if (element.parentElement instanceof HTMLElement) {
2362
+ return getComponentClosestLanguage(element.parentElement);
2363
+ }
2364
+ return DEFAULT_LANG;
2365
+ }
2366
+ function i18n(getElement, resources) {
2367
+ const element = getElement();
2368
+ const i18NextInstance = instance.createInstance();
2369
+ i18NextInstance.init({
2370
+ fallbackLng: DEFAULT_LANG,
2371
+ resources,
2372
+ defaultNS: element.tagName.toLowerCase(),
2373
+ });
2374
+ let detectedLanguage = false;
2375
+ return (key, variables) => {
2376
+ if (!detectedLanguage) {
2377
+ detectedLanguage = true;
2378
+ const language = getComponentClosestLanguage(element);
2379
+ i18NextInstance.changeLanguage(language);
2380
+ }
2381
+ return i18NextInstance.t(key, variables);
2382
+ };
2383
+ }
2384
+
2385
+ exports.i18n = i18n;
2386
+
2387
+ //# sourceMappingURL=i18n-012dfc26.js.map