@unidy.io/sdk 1.1.9 → 1.1.10

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 (518) hide show
  1. package/dist/cjs/app-globals-Pb3mNuRv.js +10 -0
  2. package/dist/cjs/app-globals-Pb3mNuRv.js.map +1 -0
  3. package/dist/cjs/{auth-B83pzi0f.js → auth-ChsE2RD7.js} +45 -13
  4. package/dist/cjs/auth-ChsE2RD7.js.map +1 -0
  5. package/dist/cjs/{auth-store-DPHWWmXf.js → auth-store-BO38Txmj.js} +8 -4
  6. package/dist/cjs/auth-store-BO38Txmj.js.map +1 -0
  7. package/dist/cjs/{component-utils-BpMyeVQo.js → component-utils-bu3SY4dE.js} +9 -2
  8. package/dist/cjs/component-utils-bu3SY4dE.js.map +1 -0
  9. package/dist/cjs/{flash-store-BuIBuQDx.js → flash-store-D5vGuIFc.js} +3 -3
  10. package/dist/cjs/{flash-store-BuIBuQDx.js.map → flash-store-D5vGuIFc.js.map} +1 -1
  11. package/dist/cjs/{i18n-BoDZ8kd2.js → i18n-B2T1e9Mf.js} +432 -596
  12. package/dist/cjs/i18n-B2T1e9Mf.js.map +1 -0
  13. package/dist/cjs/{index-B_N5xKgH.js → index-BzhKFIXk.js} +3416 -735
  14. package/dist/cjs/index-BzhKFIXk.js.map +1 -0
  15. package/dist/cjs/{index-R2MKLaem.js → index-DmDGhWTM.js} +1621 -550
  16. package/dist/cjs/index-DmDGhWTM.js.map +1 -0
  17. package/dist/cjs/{index-DLz3FT7T.js → index-DxENvy7x.js} +92 -23
  18. package/dist/cjs/index-DxENvy7x.js.map +1 -0
  19. package/dist/cjs/index.cjs.js +13 -13
  20. package/dist/cjs/loader.cjs.js +3 -3
  21. package/dist/cjs/{newsletter-helpers-D-V_8kiN.js → newsletter-helpers-B5P7q8Xk.js} +8 -8
  22. package/dist/cjs/{newsletter-helpers-D-V_8kiN.js.map → newsletter-helpers-B5P7q8Xk.js.map} +1 -1
  23. package/dist/cjs/{newsletter-store-BzytX7Qh.js → newsletter-store-f5zhJljn.js} +3 -3
  24. package/dist/cjs/{newsletter-store-BzytX7Qh.js.map → newsletter-store-f5zhJljn.js.map} +1 -1
  25. package/dist/cjs/{pagination-store-BEiW3MQd.js → pagination-store-DjGYEIqm.js} +3 -3
  26. package/dist/cjs/{pagination-store-BEiW3MQd.js.map → pagination-store-DjGYEIqm.js.map} +1 -1
  27. package/dist/cjs/{profile-helpers-B2h2III_.js → profile-helpers-BcLjojeG.js} +4 -4
  28. package/dist/cjs/{profile-helpers-B2h2III_.js.map → profile-helpers-BcLjojeG.js.map} +1 -1
  29. package/dist/cjs/{profile-store-P_BcYkef.js → profile-store-BWJ9qAcg.js} +3 -3
  30. package/dist/cjs/{profile-store-P_BcYkef.js.map → profile-store-BWJ9qAcg.js.map} +1 -1
  31. package/dist/cjs/sdk.cjs.js +31 -4
  32. package/dist/cjs/sdk.cjs.js.map +1 -1
  33. package/dist/cjs/u-conditional-render.cjs.entry.js +12 -12
  34. package/dist/cjs/u-config.cjs.entry.js +18 -14
  35. package/dist/cjs/u-config.entry.cjs.js.map +1 -1
  36. package/dist/cjs/u-email-field.cjs.entry.js +7 -7
  37. package/dist/cjs/u-error-message.cjs.entry.js +7 -7
  38. package/dist/cjs/u-error-message.entry.cjs.js.map +1 -1
  39. package/dist/cjs/u-field.u-raw-field.entry.cjs.js.map +1 -1
  40. package/dist/cjs/u-field_2.cjs.entry.js +17 -21
  41. package/dist/cjs/u-flash-message.cjs.entry.js +4 -4
  42. package/dist/cjs/u-full-profile.cjs.entry.js +6 -6
  43. package/dist/cjs/u-full-profile.entry.cjs.js.map +1 -1
  44. package/dist/cjs/u-logout-button.u-signed-in.entry.cjs.js.map +1 -1
  45. package/dist/cjs/u-logout-button_2.cjs.entry.js +16 -14
  46. package/dist/cjs/u-magic-code-field.cjs.entry.js +11 -11
  47. package/dist/cjs/u-magic-code-field.entry.cjs.js.map +1 -1
  48. package/dist/cjs/u-missing-field.cjs.entry.js +4 -4
  49. package/dist/cjs/u-missing-field.entry.cjs.js.map +1 -1
  50. package/dist/cjs/u-missing-fields-submit-button.cjs.entry.js +9 -9
  51. package/dist/cjs/u-missing-fields-submit-button.entry.cjs.js.map +1 -1
  52. package/dist/cjs/u-newsletter-checkbox.cjs.entry.js +12 -12
  53. package/dist/cjs/u-newsletter-logout-button.cjs.entry.js +19 -14
  54. package/dist/cjs/u-newsletter-logout-button.entry.cjs.js.map +1 -1
  55. package/dist/cjs/u-newsletter-preference-checkbox.cjs.entry.js +13 -13
  56. package/dist/cjs/u-newsletter-preference-checkbox.entry.cjs.js.map +1 -1
  57. package/dist/cjs/u-newsletter-resend-doi-button.cjs.entry.js +13 -13
  58. package/dist/cjs/u-newsletter-root.cjs.entry.js +12 -12
  59. package/dist/cjs/u-newsletter-toggle-subscription-button.cjs.entry.js +13 -13
  60. package/dist/cjs/u-pagination-button.cjs.entry.js +1 -1
  61. package/dist/cjs/u-pagination-button.entry.cjs.js.map +1 -1
  62. package/dist/cjs/u-pagination-page.cjs.entry.js +1 -1
  63. package/dist/cjs/u-pagination-page.entry.cjs.js.map +1 -1
  64. package/dist/cjs/u-passkey.cjs.entry.js +10 -10
  65. package/dist/cjs/u-passkey.entry.cjs.js.map +1 -1
  66. package/dist/cjs/u-password-field.cjs.entry.js +5 -5
  67. package/dist/cjs/u-profile.u-submit-button.entry.cjs.js.map +1 -1
  68. package/dist/cjs/u-profile_2.cjs.entry.js +17 -15
  69. package/dist/cjs/u-registration-button.cjs.entry.js +5 -5
  70. package/dist/cjs/u-registration-button.entry.cjs.js.map +1 -1
  71. package/dist/cjs/u-reset-password-button.cjs.entry.js +10 -10
  72. package/dist/cjs/u-send-magic-code-button.cjs.entry.js +10 -10
  73. package/dist/cjs/u-send-magic-code-button.entry.cjs.js.map +1 -1
  74. package/dist/cjs/u-signin-root.cjs.entry.js +6 -6
  75. package/dist/cjs/u-signin-step.cjs.entry.js +10 -10
  76. package/dist/cjs/u-signin-step.entry.cjs.js.map +1 -1
  77. package/dist/cjs/u-signin-strategy.cjs.entry.js +4 -4
  78. package/dist/cjs/u-social-login-button.cjs.entry.js +11 -11
  79. package/dist/cjs/u-social-login-button.entry.cjs.js.map +1 -1
  80. package/dist/cjs/u-spinner.cjs.entry.js +2 -2
  81. package/dist/cjs/u-spinner.entry.cjs.js.map +1 -1
  82. package/dist/cjs/u-ticketable-list.cjs.entry.js +13 -13
  83. package/dist/cjs/{unidy-store-7AbWnZ6g.js → unidy-store-zhdhlK0a.js} +3 -3
  84. package/dist/cjs/{unidy-store-7AbWnZ6g.js.map → unidy-store-zhdhlK0a.js.map} +1 -1
  85. package/dist/collection/api/client.js.map +1 -1
  86. package/dist/collection/api/index.js +2 -2
  87. package/dist/collection/api/index.js.map +1 -1
  88. package/dist/collection/auth/api/auth.js +12 -2
  89. package/dist/collection/auth/api/auth.js.map +1 -1
  90. package/dist/collection/auth/auth-helpers.js +18 -1
  91. package/dist/collection/auth/auth-helpers.js.map +1 -1
  92. package/dist/collection/auth/auth.js +17 -2
  93. package/dist/collection/auth/auth.js.map +1 -1
  94. package/dist/collection/auth/components/logout-button/logout-button.js +5 -3
  95. package/dist/collection/auth/components/logout-button/logout-button.js.map +1 -1
  96. package/dist/collection/auth/components/magic-code-field/magic-code-field.css +1 -1
  97. package/dist/collection/auth/components/magic-code-field/magic-code-field.js +1 -1
  98. package/dist/collection/auth/components/magic-code-field/magic-code-field.js.map +1 -1
  99. package/dist/collection/auth/components/missing-field/missing-field.js.map +1 -1
  100. package/dist/collection/auth/components/missing-fields-submit-button/missing-fields-submit-button.js +3 -3
  101. package/dist/collection/auth/components/missing-fields-submit-button/missing-fields-submit-button.js.map +1 -1
  102. package/dist/collection/auth/components/passkey/passkey.js +2 -2
  103. package/dist/collection/auth/components/passkey/passkey.js.map +1 -1
  104. package/dist/collection/auth/components/password-field/password-field.js +1 -1
  105. package/dist/collection/auth/components/registration/registration-button.js +2 -2
  106. package/dist/collection/auth/components/registration/registration-button.js.map +1 -1
  107. package/dist/collection/auth/components/send-magic-code-button/send-magic-code-button.js +1 -1
  108. package/dist/collection/auth/components/send-magic-code-button/send-magic-code-button.js.map +1 -1
  109. package/dist/collection/auth/components/signed-in/signed-in.js.map +1 -1
  110. package/dist/collection/auth/components/signin-step/signin-step.js +1 -1
  111. package/dist/collection/auth/components/signin-step/signin-step.js.map +1 -1
  112. package/dist/collection/auth/components/social-logins/social-login-button.css +1 -1
  113. package/dist/collection/auth/components/social-logins/social-login-button.js +4 -4
  114. package/dist/collection/auth/components/social-logins/social-login-button.js.map +1 -1
  115. package/dist/collection/auth/index.js +1 -2
  116. package/dist/collection/auth/index.js.map +1 -1
  117. package/dist/collection/auth/store/auth-store.js +4 -0
  118. package/dist/collection/auth/store/auth-store.js.map +1 -1
  119. package/dist/collection/globalScript.js +1 -1
  120. package/dist/collection/globalScript.js.map +1 -1
  121. package/dist/collection/i18n.js +1 -1
  122. package/dist/collection/i18n.js.map +1 -1
  123. package/dist/collection/index.js +1 -1
  124. package/dist/collection/index.js.map +1 -1
  125. package/dist/collection/logger.js.map +1 -1
  126. package/dist/collection/newsletter/api/newsletters.js +1 -1
  127. package/dist/collection/newsletter/api/newsletters.js.map +1 -1
  128. package/dist/collection/newsletter/components/logout-button/logout-button.js +10 -5
  129. package/dist/collection/newsletter/components/logout-button/logout-button.js.map +1 -1
  130. package/dist/collection/newsletter/components/preference-checkbox/preference-checkbox.js +2 -3
  131. package/dist/collection/newsletter/components/preference-checkbox/preference-checkbox.js.map +1 -1
  132. package/dist/collection/newsletter/components/resend-doi-button/resend-doi-button.css +1 -1
  133. package/dist/collection/newsletter/components/toggle-subscription-button/toggle-subscription-button.css +1 -1
  134. package/dist/collection/profile/components/field/field.css +1 -1
  135. package/dist/collection/profile/components/field/field.js +1 -5
  136. package/dist/collection/profile/components/field/field.js.map +1 -1
  137. package/dist/collection/profile/components/full-profile/full-profile.css +1 -1
  138. package/dist/collection/profile/components/raw-field/raw-field.js +5 -5
  139. package/dist/collection/profile/components/raw-field/raw-field.js.map +1 -1
  140. package/dist/collection/profile/index.js +1 -2
  141. package/dist/collection/profile/index.js.map +1 -1
  142. package/dist/collection/profile/profile-helpers.js +1 -1
  143. package/dist/collection/profile/profile-helpers.js.map +1 -1
  144. package/dist/collection/shared/component-utils.js +7 -0
  145. package/dist/collection/shared/component-utils.js.map +1 -1
  146. package/dist/collection/shared/components/config/config.js +28 -4
  147. package/dist/collection/shared/components/config/config.js.map +1 -1
  148. package/dist/collection/shared/components/email-field/email-field.css +1 -1
  149. package/dist/collection/shared/components/error-message/error-message.js.map +1 -1
  150. package/dist/collection/shared/components/flash-message/flash-message.css +1 -1
  151. package/dist/collection/shared/components/spinner/spinner.css +1 -1
  152. package/dist/collection/shared/components/spinner/spinner.js +1 -1
  153. package/dist/collection/shared/components/spinner/spinner.js.map +1 -1
  154. package/dist/collection/shared/components/submit-button/submit-button.css +1 -1
  155. package/dist/collection/shared/components/submit-button/submit-button.js +2 -0
  156. package/dist/collection/shared/components/submit-button/submit-button.js.map +1 -1
  157. package/dist/collection/ticketable/api/get-with-schema.js.map +1 -1
  158. package/dist/collection/ticketable/api/schemas.js +1 -1
  159. package/dist/collection/ticketable/api/schemas.js.map +1 -1
  160. package/dist/collection/ticketable/api/subscriptions.js +2 -2
  161. package/dist/collection/ticketable/api/subscriptions.js.map +1 -1
  162. package/dist/collection/ticketable/api/tickets.js +2 -2
  163. package/dist/collection/ticketable/api/tickets.js.map +1 -1
  164. package/dist/collection/ticketable/components/pagination/pagination-button.js +1 -1
  165. package/dist/collection/ticketable/components/pagination/pagination-button.js.map +1 -1
  166. package/dist/collection/ticketable/components/pagination/pagination-page.js +1 -1
  167. package/dist/collection/ticketable/components/pagination/pagination-page.js.map +1 -1
  168. package/dist/collection/ticketable/index.js +1 -1
  169. package/dist/collection/ticketable/index.js.map +1 -1
  170. package/dist/components/auth-store.js +4 -0
  171. package/dist/components/auth-store.js.map +1 -1
  172. package/dist/components/auth.js +36 -4
  173. package/dist/components/auth.js.map +1 -1
  174. package/dist/components/component-utils.js +7 -0
  175. package/dist/components/component-utils.js.map +1 -1
  176. package/dist/components/exports.js +260 -104
  177. package/dist/components/exports.js.map +1 -1
  178. package/dist/components/field.js +4 -14
  179. package/dist/components/field.js.map +1 -1
  180. package/dist/components/i18n.js +429 -593
  181. package/dist/components/i18n.js.map +1 -1
  182. package/dist/components/index.js +424 -397
  183. package/dist/components/index.js.map +1 -1
  184. package/dist/components/index2.js +1562 -491
  185. package/dist/components/index2.js.map +1 -1
  186. package/dist/components/index3.js +90 -21
  187. package/dist/components/index3.js.map +1 -1
  188. package/dist/components/logger.js.map +1 -1
  189. package/dist/components/profile-helpers.js +1 -1
  190. package/dist/components/profile-helpers.js.map +1 -1
  191. package/dist/components/profile-store.js +1 -1
  192. package/dist/components/profile.js +3 -3
  193. package/dist/components/raw-field.js +11 -11
  194. package/dist/components/raw-field.js.map +1 -1
  195. package/dist/components/spinner.js +1 -1
  196. package/dist/components/spinner.js.map +1 -1
  197. package/dist/components/submit-button.js +3 -1
  198. package/dist/components/submit-button.js.map +1 -1
  199. package/dist/components/u-conditional-render.js +1 -1
  200. package/dist/components/u-config.js +10 -5
  201. package/dist/components/u-config.js.map +1 -1
  202. package/dist/components/u-email-field.js +1 -1
  203. package/dist/components/u-error-message.js.map +1 -1
  204. package/dist/components/u-flash-message.js +1 -1
  205. package/dist/components/u-full-profile.js +1 -1
  206. package/dist/components/u-full-profile.js.map +1 -1
  207. package/dist/components/u-logout-button.js +5 -3
  208. package/dist/components/u-logout-button.js.map +1 -1
  209. package/dist/components/u-magic-code-field.js +2 -2
  210. package/dist/components/u-magic-code-field.js.map +1 -1
  211. package/dist/components/u-missing-field.js +4 -10
  212. package/dist/components/u-missing-field.js.map +1 -1
  213. package/dist/components/u-missing-fields-submit-button.js +3 -3
  214. package/dist/components/u-missing-fields-submit-button.js.map +1 -1
  215. package/dist/components/u-newsletter-logout-button.js +9 -4
  216. package/dist/components/u-newsletter-logout-button.js.map +1 -1
  217. package/dist/components/u-newsletter-preference-checkbox.js +1 -1
  218. package/dist/components/u-newsletter-preference-checkbox.js.map +1 -1
  219. package/dist/components/u-newsletter-resend-doi-button.js +1 -1
  220. package/dist/components/u-newsletter-toggle-subscription-button.js +1 -1
  221. package/dist/components/u-pagination-button.js.map +1 -1
  222. package/dist/components/u-pagination-page.js.map +1 -1
  223. package/dist/components/u-passkey.js +1 -1
  224. package/dist/components/u-passkey.js.map +1 -1
  225. package/dist/components/u-registration-button.js +2 -2
  226. package/dist/components/u-registration-button.js.map +1 -1
  227. package/dist/components/u-send-magic-code-button.js +1 -1
  228. package/dist/components/u-send-magic-code-button.js.map +1 -1
  229. package/dist/components/u-signed-in.js.map +1 -1
  230. package/dist/components/u-signin-step.js +1 -1
  231. package/dist/components/u-signin-step.js.map +1 -1
  232. package/dist/components/u-social-login-button.js +8 -8
  233. package/dist/components/u-social-login-button.js.map +1 -1
  234. package/dist/components/u-ticketable-list.js +1 -1
  235. package/dist/esm/app-globals-BHWOrMsm.js +8 -0
  236. package/dist/esm/app-globals-BHWOrMsm.js.map +1 -0
  237. package/dist/esm/{auth-B0RIcDM-.js → auth-CAHM6e4m.js} +45 -13
  238. package/dist/esm/auth-CAHM6e4m.js.map +1 -0
  239. package/dist/esm/{auth-store-BGMYm_jK.js → auth-store-ItTnEMlF.js} +8 -4
  240. package/dist/esm/auth-store-ItTnEMlF.js.map +1 -0
  241. package/dist/esm/{component-utils-D1lzXl_Z.js → component-utils-BGq0leDV.js} +9 -2
  242. package/dist/esm/component-utils-BGq0leDV.js.map +1 -0
  243. package/dist/esm/{flash-store-CEvWSG0c.js → flash-store-CMXH65i_.js} +3 -3
  244. package/dist/esm/{flash-store-CEvWSG0c.js.map → flash-store-CMXH65i_.js.map} +1 -1
  245. package/dist/esm/{i18n-CLdWzy5J.js → i18n-OKf8uE5j.js} +432 -596
  246. package/dist/esm/i18n-OKf8uE5j.js.map +1 -0
  247. package/dist/esm/{index-Ci3aTmzp.js → index-COQ27Nb6.js} +3411 -734
  248. package/dist/esm/index-COQ27Nb6.js.map +1 -0
  249. package/dist/esm/{index-Bjp1XO-f.js → index-DVkRTYPC.js} +92 -23
  250. package/dist/esm/index-DVkRTYPC.js.map +1 -0
  251. package/dist/esm/{index-DSDkaHWI.js → index-Du3hUdhU.js} +1622 -551
  252. package/dist/esm/index-Du3hUdhU.js.map +1 -0
  253. package/dist/esm/index.js +11 -11
  254. package/dist/esm/loader.js +4 -4
  255. package/dist/esm/{newsletter-helpers-CONtbKYi.js → newsletter-helpers-ChXON0f4.js} +8 -8
  256. package/dist/esm/{newsletter-helpers-CONtbKYi.js.map → newsletter-helpers-ChXON0f4.js.map} +1 -1
  257. package/dist/esm/{newsletter-store-DBL1A203.js → newsletter-store-CIsyE51r.js} +3 -3
  258. package/dist/esm/{newsletter-store-DBL1A203.js.map → newsletter-store-CIsyE51r.js.map} +1 -1
  259. package/dist/esm/{pagination-store-DzdJOp-n.js → pagination-store-B9lk_lqK.js} +3 -3
  260. package/dist/esm/{pagination-store-DzdJOp-n.js.map → pagination-store-B9lk_lqK.js.map} +1 -1
  261. package/dist/esm/{profile-helpers-CglNd6Nw.js → profile-helpers-Beduxnin.js} +4 -4
  262. package/dist/esm/{profile-helpers-CglNd6Nw.js.map → profile-helpers-Beduxnin.js.map} +1 -1
  263. package/dist/esm/{profile-store-RmZB2PTc.js → profile-store-CsSDT9Tb.js} +4 -4
  264. package/dist/esm/{profile-store-RmZB2PTc.js.map → profile-store-CsSDT9Tb.js.map} +1 -1
  265. package/dist/esm/sdk.js +32 -5
  266. package/dist/esm/sdk.js.map +1 -1
  267. package/dist/esm/u-conditional-render.entry.js +12 -12
  268. package/dist/esm/u-config.entry.js +18 -14
  269. package/dist/esm/u-config.entry.js.map +1 -1
  270. package/dist/esm/u-email-field.entry.js +7 -7
  271. package/dist/esm/u-error-message.entry.js +7 -7
  272. package/dist/esm/u-error-message.entry.js.map +1 -1
  273. package/dist/esm/u-field.u-raw-field.entry.js.map +1 -1
  274. package/dist/esm/u-field_2.entry.js +17 -21
  275. package/dist/esm/u-flash-message.entry.js +4 -4
  276. package/dist/esm/u-full-profile.entry.js +6 -6
  277. package/dist/esm/u-full-profile.entry.js.map +1 -1
  278. package/dist/esm/u-logout-button.u-signed-in.entry.js.map +1 -1
  279. package/dist/esm/u-logout-button_2.entry.js +16 -14
  280. package/dist/esm/u-magic-code-field.entry.js +11 -11
  281. package/dist/esm/u-magic-code-field.entry.js.map +1 -1
  282. package/dist/esm/u-missing-field.entry.js +4 -4
  283. package/dist/esm/u-missing-field.entry.js.map +1 -1
  284. package/dist/esm/u-missing-fields-submit-button.entry.js +9 -9
  285. package/dist/esm/u-missing-fields-submit-button.entry.js.map +1 -1
  286. package/dist/esm/u-newsletter-checkbox.entry.js +12 -12
  287. package/dist/esm/u-newsletter-logout-button.entry.js +19 -14
  288. package/dist/esm/u-newsletter-logout-button.entry.js.map +1 -1
  289. package/dist/esm/u-newsletter-preference-checkbox.entry.js +13 -13
  290. package/dist/esm/u-newsletter-preference-checkbox.entry.js.map +1 -1
  291. package/dist/esm/u-newsletter-resend-doi-button.entry.js +13 -13
  292. package/dist/esm/u-newsletter-root.entry.js +12 -12
  293. package/dist/esm/u-newsletter-toggle-subscription-button.entry.js +13 -13
  294. package/dist/esm/u-pagination-button.entry.js +1 -1
  295. package/dist/esm/u-pagination-button.entry.js.map +1 -1
  296. package/dist/esm/u-pagination-page.entry.js +1 -1
  297. package/dist/esm/u-pagination-page.entry.js.map +1 -1
  298. package/dist/esm/u-passkey.entry.js +10 -10
  299. package/dist/esm/u-passkey.entry.js.map +1 -1
  300. package/dist/esm/u-password-field.entry.js +5 -5
  301. package/dist/esm/u-profile.u-submit-button.entry.js.map +1 -1
  302. package/dist/esm/u-profile_2.entry.js +17 -15
  303. package/dist/esm/u-registration-button.entry.js +5 -5
  304. package/dist/esm/u-registration-button.entry.js.map +1 -1
  305. package/dist/esm/u-reset-password-button.entry.js +10 -10
  306. package/dist/esm/u-send-magic-code-button.entry.js +10 -10
  307. package/dist/esm/u-send-magic-code-button.entry.js.map +1 -1
  308. package/dist/esm/u-signin-root.entry.js +6 -6
  309. package/dist/esm/u-signin-step.entry.js +10 -10
  310. package/dist/esm/u-signin-step.entry.js.map +1 -1
  311. package/dist/esm/u-signin-strategy.entry.js +4 -4
  312. package/dist/esm/u-social-login-button.entry.js +11 -11
  313. package/dist/esm/u-social-login-button.entry.js.map +1 -1
  314. package/dist/esm/u-spinner.entry.js +2 -2
  315. package/dist/esm/u-spinner.entry.js.map +1 -1
  316. package/dist/esm/u-ticketable-list.entry.js +13 -13
  317. package/dist/esm/{unidy-store-BldTAtO0.js → unidy-store-CAcMVdD8.js} +3 -3
  318. package/dist/esm/{unidy-store-BldTAtO0.js.map → unidy-store-CAcMVdD8.js.map} +1 -1
  319. package/dist/sdk/index.esm.js +1 -1
  320. package/dist/sdk/{p-93200fb4.entry.js → p-1bad3fd0.entry.js} +2 -2
  321. package/dist/sdk/{p-22e4d08b.entry.js → p-1d6982cd.entry.js} +2 -2
  322. package/dist/sdk/p-23d8e922.entry.js +2 -0
  323. package/dist/sdk/p-2855d3bb.entry.js +2 -0
  324. package/dist/sdk/p-2855d3bb.entry.js.map +1 -0
  325. package/dist/sdk/{p-339f32c1.entry.js → p-288f37c3.entry.js} +2 -2
  326. package/dist/sdk/{p-339f32c1.entry.js.map → p-288f37c3.entry.js.map} +1 -1
  327. package/dist/sdk/p-32842e98.entry.js +2 -0
  328. package/dist/sdk/p-32842e98.entry.js.map +1 -0
  329. package/dist/sdk/p-34af7470.entry.js +2 -0
  330. package/dist/sdk/p-39126514.entry.js +2 -0
  331. package/dist/sdk/{p-2af8b45f.entry.js.map → p-39126514.entry.js.map} +1 -1
  332. package/dist/sdk/{p-ad796888.entry.js → p-438f62e5.entry.js} +2 -2
  333. package/dist/sdk/{p-ad796888.entry.js.map → p-438f62e5.entry.js.map} +1 -1
  334. package/dist/sdk/{p-bb603b00.entry.js → p-46013b2f.entry.js} +2 -2
  335. package/dist/sdk/{p-08ff2de2.entry.js → p-46cdb255.entry.js} +2 -2
  336. package/dist/sdk/{p-a5db968f.entry.js → p-4d9bde6e.entry.js} +2 -2
  337. package/dist/sdk/{p-b0917777.entry.js → p-5c40c6ea.entry.js} +2 -2
  338. package/dist/sdk/p-5c8b31bd.entry.js +2 -0
  339. package/dist/sdk/p-5c8b31bd.entry.js.map +1 -0
  340. package/dist/sdk/{p-c31dbbb4.entry.js → p-69172b22.entry.js} +2 -2
  341. package/dist/sdk/p-69172b22.entry.js.map +1 -0
  342. package/dist/sdk/p-7381aca7.entry.js +2 -0
  343. package/dist/sdk/{p-6893d167.entry.js.map → p-7381aca7.entry.js.map} +1 -1
  344. package/dist/sdk/{p-D1lzXl_Z.js → p-BGq0leDV.js} +1 -1
  345. package/dist/sdk/p-BGq0leDV.js.map +1 -0
  346. package/dist/sdk/p-BR6L248H.js +2 -0
  347. package/dist/sdk/p-BR6L248H.js.map +1 -0
  348. package/dist/sdk/p-BhrvnKAS.js +2 -0
  349. package/dist/sdk/{p-Ce8zGAi1.js.map → p-BhrvnKAS.js.map} +1 -1
  350. package/dist/sdk/p-CMw6v6sC.js +2 -0
  351. package/dist/sdk/p-CMw6v6sC.js.map +1 -0
  352. package/dist/sdk/p-COQ27Nb6.js +14 -0
  353. package/dist/sdk/p-COQ27Nb6.js.map +1 -0
  354. package/dist/sdk/p-CSLU6kes.js +2 -0
  355. package/dist/sdk/{p-CPPYdoIv.js.map → p-CSLU6kes.js.map} +1 -1
  356. package/dist/sdk/p-Cai8JwlG.js +2 -0
  357. package/dist/sdk/p-Cai8JwlG.js.map +1 -0
  358. package/dist/sdk/{p-DYtgart8.js → p-CpJghKnM.js} +2 -2
  359. package/dist/sdk/{p-DYtgart8.js.map → p-CpJghKnM.js.map} +1 -1
  360. package/dist/sdk/p-DAn4FkxC.js +2 -0
  361. package/dist/sdk/{p-C0feI0p8.js.map → p-DAn4FkxC.js.map} +1 -1
  362. package/dist/sdk/p-FFRhPCmc.js +2 -0
  363. package/dist/sdk/{p-DA84OuuU.js.map → p-FFRhPCmc.js.map} +1 -1
  364. package/dist/sdk/p-Jrp0G45B.js +2 -0
  365. package/dist/sdk/{p-BlOjABPD.js.map → p-Jrp0G45B.js.map} +1 -1
  366. package/dist/sdk/p-MA26cw6g.js +2 -0
  367. package/dist/sdk/p-MA26cw6g.js.map +1 -0
  368. package/dist/sdk/p-P0eZf5rH.js +2 -0
  369. package/dist/sdk/p-P0eZf5rH.js.map +1 -0
  370. package/dist/sdk/{p-S3-2d2Qd.js → p-PSIHL0wP.js} +2 -2
  371. package/dist/sdk/{p-S3-2d2Qd.js.map → p-PSIHL0wP.js.map} +1 -1
  372. package/dist/sdk/p-a341c7f6.entry.js +2 -0
  373. package/dist/sdk/p-a341c7f6.entry.js.map +1 -0
  374. package/dist/sdk/p-a38cd448.entry.js +2 -0
  375. package/dist/sdk/{p-593c6dde.entry.js.map → p-a38cd448.entry.js.map} +1 -1
  376. package/dist/sdk/{p-87d10077.entry.js → p-a45ef398.entry.js} +2 -2
  377. package/dist/sdk/{p-87d10077.entry.js.map → p-a45ef398.entry.js.map} +1 -1
  378. package/dist/sdk/p-b5a6ad01.entry.js +2 -0
  379. package/dist/sdk/p-b5a6ad01.entry.js.map +1 -0
  380. package/dist/sdk/{p-9f59909b.entry.js → p-b93bf91d.entry.js} +2 -2
  381. package/dist/sdk/{p-9f59909b.entry.js.map → p-b93bf91d.entry.js.map} +1 -1
  382. package/dist/sdk/{p-09cd77e6.entry.js → p-baf5dcb7.entry.js} +2 -2
  383. package/dist/sdk/p-c07a43e2.entry.js +2 -0
  384. package/dist/sdk/p-c07a43e2.entry.js.map +1 -0
  385. package/dist/sdk/p-c98ad60d.entry.js +2 -0
  386. package/dist/sdk/p-c98ad60d.entry.js.map +1 -0
  387. package/dist/sdk/{p-f5615938.entry.js → p-d0c0fb6b.entry.js} +2 -2
  388. package/dist/sdk/p-d47aaf26.entry.js +2 -0
  389. package/dist/sdk/p-d47aaf26.entry.js.map +1 -0
  390. package/dist/sdk/p-e5ef30ef.entry.js +2 -0
  391. package/dist/sdk/p-eb348798.entry.js +2 -0
  392. package/dist/sdk/{p-73c2ec89.entry.js.map → p-eb348798.entry.js.map} +1 -1
  393. package/dist/sdk/p-f82f500d.entry.js +2 -0
  394. package/dist/sdk/p-f82f500d.entry.js.map +1 -0
  395. package/dist/sdk/p-f88ed6e8.entry.js +2 -0
  396. package/dist/sdk/p-f88ed6e8.entry.js.map +1 -0
  397. package/dist/sdk/{p-afc65acd.entry.js → p-f9affafe.entry.js} +2 -2
  398. package/dist/sdk/p-jyF1XwDG.js +2 -0
  399. package/dist/sdk/p-jyF1XwDG.js.map +1 -0
  400. package/dist/sdk/sdk.esm.js +1 -1
  401. package/dist/sdk/sdk.esm.js.map +1 -1
  402. package/dist/sdk/u-config.entry.esm.js.map +1 -1
  403. package/dist/sdk/u-error-message.entry.esm.js.map +1 -1
  404. package/dist/sdk/u-field.u-raw-field.entry.esm.js.map +1 -1
  405. package/dist/sdk/u-full-profile.entry.esm.js.map +1 -1
  406. package/dist/sdk/u-logout-button.u-signed-in.entry.esm.js.map +1 -1
  407. package/dist/sdk/u-magic-code-field.entry.esm.js.map +1 -1
  408. package/dist/sdk/u-missing-field.entry.esm.js.map +1 -1
  409. package/dist/sdk/u-missing-fields-submit-button.entry.esm.js.map +1 -1
  410. package/dist/sdk/u-newsletter-logout-button.entry.esm.js.map +1 -1
  411. package/dist/sdk/u-newsletter-preference-checkbox.entry.esm.js.map +1 -1
  412. package/dist/sdk/u-pagination-button.entry.esm.js.map +1 -1
  413. package/dist/sdk/u-pagination-page.entry.esm.js.map +1 -1
  414. package/dist/sdk/u-passkey.entry.esm.js.map +1 -1
  415. package/dist/sdk/u-profile.u-submit-button.entry.esm.js.map +1 -1
  416. package/dist/sdk/u-registration-button.entry.esm.js.map +1 -1
  417. package/dist/sdk/u-send-magic-code-button.entry.esm.js.map +1 -1
  418. package/dist/sdk/u-signin-step.entry.esm.js.map +1 -1
  419. package/dist/sdk/u-social-login-button.entry.esm.js.map +1 -1
  420. package/dist/sdk/u-spinner.entry.esm.js.map +1 -1
  421. package/dist/types/api/index.d.ts +2 -2
  422. package/dist/types/auth/api/auth.d.ts +3 -1
  423. package/dist/types/auth/auth-helpers.d.ts +1 -0
  424. package/dist/types/auth/auth.d.ts +9 -1
  425. package/dist/types/auth/components/logout-button/logout-button.d.ts +1 -1
  426. package/dist/types/auth/index.d.ts +3 -4
  427. package/dist/types/auth/store/auth-store.d.ts +2 -0
  428. package/dist/types/components.d.ts +8 -0
  429. package/dist/types/index.d.ts +2 -2
  430. package/dist/types/logger.d.ts +1 -1
  431. package/dist/types/newsletter/api/newsletters.d.ts +1 -1
  432. package/dist/types/newsletter/components/logout-button/logout-button.d.ts +2 -0
  433. package/dist/types/profile/components/field/field.d.ts +0 -1
  434. package/dist/types/profile/components/raw-field/raw-field.d.ts +2 -2
  435. package/dist/types/profile/index.d.ts +2 -3
  436. package/dist/types/shared/component-utils.d.ts +7 -0
  437. package/dist/types/shared/components/config/config.d.ts +1 -0
  438. package/dist/types/ticketable/api/get-with-schema.d.ts +1 -1
  439. package/dist/types/ticketable/index.d.ts +1 -1
  440. package/package.json +23 -18
  441. package/dist/cjs/app-globals-DSKjcXX_.js +0 -10
  442. package/dist/cjs/app-globals-DSKjcXX_.js.map +0 -1
  443. package/dist/cjs/auth-B83pzi0f.js.map +0 -1
  444. package/dist/cjs/auth-store-DPHWWmXf.js.map +0 -1
  445. package/dist/cjs/component-utils-BpMyeVQo.js.map +0 -1
  446. package/dist/cjs/i18n-BoDZ8kd2.js.map +0 -1
  447. package/dist/cjs/index-B_N5xKgH.js.map +0 -1
  448. package/dist/cjs/index-DLz3FT7T.js.map +0 -1
  449. package/dist/cjs/index-R2MKLaem.js.map +0 -1
  450. package/dist/esm/app-globals-CPU9ZcqZ.js +0 -8
  451. package/dist/esm/app-globals-CPU9ZcqZ.js.map +0 -1
  452. package/dist/esm/auth-B0RIcDM-.js.map +0 -1
  453. package/dist/esm/auth-store-BGMYm_jK.js.map +0 -1
  454. package/dist/esm/component-utils-D1lzXl_Z.js.map +0 -1
  455. package/dist/esm/i18n-CLdWzy5J.js.map +0 -1
  456. package/dist/esm/index-Bjp1XO-f.js.map +0 -1
  457. package/dist/esm/index-Ci3aTmzp.js.map +0 -1
  458. package/dist/esm/index-DSDkaHWI.js.map +0 -1
  459. package/dist/sdk/p-1176c407.entry.js +0 -2
  460. package/dist/sdk/p-1176c407.entry.js.map +0 -1
  461. package/dist/sdk/p-2a65bcbb.entry.js +0 -2
  462. package/dist/sdk/p-2a65bcbb.entry.js.map +0 -1
  463. package/dist/sdk/p-2af8b45f.entry.js +0 -2
  464. package/dist/sdk/p-56abb377.entry.js +0 -2
  465. package/dist/sdk/p-56abb377.entry.js.map +0 -1
  466. package/dist/sdk/p-593c6dde.entry.js +0 -2
  467. package/dist/sdk/p-5b627aea.entry.js +0 -2
  468. package/dist/sdk/p-5b627aea.entry.js.map +0 -1
  469. package/dist/sdk/p-628ccd68.entry.js +0 -2
  470. package/dist/sdk/p-675eb13d.entry.js +0 -2
  471. package/dist/sdk/p-675eb13d.entry.js.map +0 -1
  472. package/dist/sdk/p-6893d167.entry.js +0 -2
  473. package/dist/sdk/p-6a642433.entry.js +0 -2
  474. package/dist/sdk/p-73c2ec89.entry.js +0 -2
  475. package/dist/sdk/p-91bb8b59.entry.js +0 -2
  476. package/dist/sdk/p-91bb8b59.entry.js.map +0 -1
  477. package/dist/sdk/p-BZ1kW_eK.js +0 -2
  478. package/dist/sdk/p-BZ1kW_eK.js.map +0 -1
  479. package/dist/sdk/p-BlAULXyw.js +0 -2
  480. package/dist/sdk/p-BlAULXyw.js.map +0 -1
  481. package/dist/sdk/p-BlOjABPD.js +0 -2
  482. package/dist/sdk/p-C0feI0p8.js +0 -2
  483. package/dist/sdk/p-C3fhudPT.js +0 -2
  484. package/dist/sdk/p-C3fhudPT.js.map +0 -1
  485. package/dist/sdk/p-CFiZLMAA.js +0 -2
  486. package/dist/sdk/p-CFiZLMAA.js.map +0 -1
  487. package/dist/sdk/p-CPPYdoIv.js +0 -2
  488. package/dist/sdk/p-CbRhHGU5.js +0 -2
  489. package/dist/sdk/p-CbRhHGU5.js.map +0 -1
  490. package/dist/sdk/p-Ce8zGAi1.js +0 -2
  491. package/dist/sdk/p-Ci3aTmzp.js +0 -3
  492. package/dist/sdk/p-Ci3aTmzp.js.map +0 -1
  493. package/dist/sdk/p-D1lzXl_Z.js.map +0 -1
  494. package/dist/sdk/p-DA84OuuU.js +0 -2
  495. package/dist/sdk/p-DdUvQelg.js +0 -2
  496. package/dist/sdk/p-DdUvQelg.js.map +0 -1
  497. package/dist/sdk/p-b0728464.entry.js +0 -2
  498. package/dist/sdk/p-b0728464.entry.js.map +0 -1
  499. package/dist/sdk/p-c197fdb3.entry.js +0 -2
  500. package/dist/sdk/p-c197fdb3.entry.js.map +0 -1
  501. package/dist/sdk/p-c31dbbb4.entry.js.map +0 -1
  502. package/dist/sdk/p-c5bffd90.entry.js +0 -2
  503. package/dist/sdk/p-f0598e42.entry.js +0 -2
  504. package/dist/sdk/p-f0598e42.entry.js.map +0 -1
  505. package/dist/sdk/p-ffac964c.entry.js +0 -2
  506. package/dist/sdk/p-ffac964c.entry.js.map +0 -1
  507. /package/dist/sdk/{p-93200fb4.entry.js.map → p-1bad3fd0.entry.js.map} +0 -0
  508. /package/dist/sdk/{p-22e4d08b.entry.js.map → p-1d6982cd.entry.js.map} +0 -0
  509. /package/dist/sdk/{p-6a642433.entry.js.map → p-23d8e922.entry.js.map} +0 -0
  510. /package/dist/sdk/{p-c5bffd90.entry.js.map → p-34af7470.entry.js.map} +0 -0
  511. /package/dist/sdk/{p-bb603b00.entry.js.map → p-46013b2f.entry.js.map} +0 -0
  512. /package/dist/sdk/{p-08ff2de2.entry.js.map → p-46cdb255.entry.js.map} +0 -0
  513. /package/dist/sdk/{p-a5db968f.entry.js.map → p-4d9bde6e.entry.js.map} +0 -0
  514. /package/dist/sdk/{p-b0917777.entry.js.map → p-5c40c6ea.entry.js.map} +0 -0
  515. /package/dist/sdk/{p-09cd77e6.entry.js.map → p-baf5dcb7.entry.js.map} +0 -0
  516. /package/dist/sdk/{p-f5615938.entry.js.map → p-d0c0fb6b.entry.js.map} +0 -0
  517. /package/dist/sdk/{p-628ccd68.entry.js.map → p-e5ef30ef.entry.js.map} +0 -0
  518. /package/dist/sdk/{p-afc65acd.entry.js.map → p-f9affafe.entry.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { Build } from '@stencil/core/internal/client';
2
- import { o as onChange, u as unidyState } from './unidy-store.js';
3
2
  import { i as i18nLogger } from './logger.js';
3
+ import { o as onChange, u as unidyState } from './unidy-store.js';
4
4
 
5
5
  const isString = obj => typeof obj === 'string';
6
6
  const defer = () => {
@@ -62,7 +62,7 @@ const setPath = (object, path, newValue) => {
62
62
  e = `${p[p.length - 1]}.${e}`;
63
63
  p = p.slice(0, p.length - 1);
64
64
  last = getLastOfPath(object, p, Object);
65
- if (last && last.obj && typeof last.obj[`${last.k}.${e}`] !== 'undefined') {
65
+ if (last?.obj && typeof last.obj[`${last.k}.${e}`] !== 'undefined') {
66
66
  last.obj = undefined;
67
67
  }
68
68
  }
@@ -82,6 +82,7 @@ const getPath = (object, path) => {
82
82
  k
83
83
  } = getLastOfPath(object, path);
84
84
  if (!obj) return undefined;
85
+ if (!Object.prototype.hasOwnProperty.call(obj, k)) return undefined;
85
86
  return obj[k];
86
87
  };
87
88
  const getPathWithDefaults = (data, defaultData, key) => {
@@ -159,10 +160,12 @@ const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
159
160
  }
160
161
  return matched;
161
162
  };
162
- const deepFind = function (obj, path) {
163
- let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
163
+ const deepFind = (obj, path, keySeparator = '.') => {
164
164
  if (!obj) return undefined;
165
- if (obj[path]) return obj[path];
165
+ if (obj[path]) {
166
+ if (!Object.prototype.hasOwnProperty.call(obj, path)) return undefined;
167
+ return obj[path];
168
+ }
166
169
  const tokens = path.split(keySeparator);
167
170
  let current = obj;
168
171
  for (let i = 0; i < tokens.length;) {
@@ -189,7 +192,7 @@ const deepFind = function (obj, path) {
189
192
  }
190
193
  return current;
191
194
  };
192
- const getCleanedCode = code => code && code.replace('_', '-');
195
+ const getCleanedCode = code => code?.replace('_', '-');
193
196
 
194
197
  const consoleLogger = {
195
198
  type: 'logger',
@@ -203,43 +206,29 @@ const consoleLogger = {
203
206
  this.output('error', args);
204
207
  },
205
208
  output(type, args) {
206
- if (console && console[type]) console[type].apply(console, args);
209
+ console?.[type]?.apply?.(console, args);
207
210
  }
208
211
  };
209
212
  class Logger {
210
- constructor(concreteLogger) {
211
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
213
+ constructor(concreteLogger, options = {}) {
212
214
  this.init(concreteLogger, options);
213
215
  }
214
- init(concreteLogger) {
215
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
216
+ init(concreteLogger, options = {}) {
216
217
  this.prefix = options.prefix || 'i18next:';
217
218
  this.logger = concreteLogger || consoleLogger;
218
219
  this.options = options;
219
220
  this.debug = options.debug;
220
221
  }
221
- log() {
222
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
223
- args[_key] = arguments[_key];
224
- }
222
+ log(...args) {
225
223
  return this.forward(args, 'log', '', true);
226
224
  }
227
- warn() {
228
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
229
- args[_key2] = arguments[_key2];
230
- }
225
+ warn(...args) {
231
226
  return this.forward(args, 'warn', '', true);
232
227
  }
233
- error() {
234
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
235
- args[_key3] = arguments[_key3];
236
- }
228
+ error(...args) {
237
229
  return this.forward(args, 'error', '');
238
230
  }
239
- deprecate() {
240
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
241
- args[_key4] = arguments[_key4];
242
- }
231
+ deprecate(...args) {
243
232
  return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
244
233
  }
245
234
  forward(args, lvl, prefix, debugOnly) {
@@ -283,14 +272,10 @@ class EventEmitter {
283
272
  }
284
273
  this.observers[event].delete(listener);
285
274
  }
286
- emit(event) {
287
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
288
- args[_key - 1] = arguments[_key];
289
- }
275
+ emit(event, ...args) {
290
276
  if (this.observers[event]) {
291
277
  const cloned = Array.from(this.observers[event].entries());
292
- cloned.forEach(_ref => {
293
- let [observer, numTimesAdded] = _ref;
278
+ cloned.forEach(([observer, numTimesAdded]) => {
294
279
  for (let i = 0; i < numTimesAdded; i++) {
295
280
  observer(...args);
296
281
  }
@@ -298,8 +283,7 @@ class EventEmitter {
298
283
  }
299
284
  if (this.observers['*']) {
300
285
  const cloned = Array.from(this.observers['*'].entries());
301
- cloned.forEach(_ref2 => {
302
- let [observer, numTimesAdded] = _ref2;
286
+ cloned.forEach(([observer, numTimesAdded]) => {
303
287
  for (let i = 0; i < numTimesAdded; i++) {
304
288
  observer.apply(observer, [event, ...args]);
305
289
  }
@@ -309,11 +293,10 @@ class EventEmitter {
309
293
  }
310
294
 
311
295
  class ResourceStore extends EventEmitter {
312
- constructor(data) {
313
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
314
- ns: ['translation'],
315
- defaultNS: 'translation'
316
- };
296
+ constructor(data, options = {
297
+ ns: ['translation'],
298
+ defaultNS: 'translation'
299
+ }) {
317
300
  super();
318
301
  this.data = data || {};
319
302
  this.options = options;
@@ -335,8 +318,7 @@ class ResourceStore extends EventEmitter {
335
318
  this.options.ns.splice(index, 1);
336
319
  }
337
320
  }
338
- getResource(lng, ns, key) {
339
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
321
+ getResource(lng, ns, key, options = {}) {
340
322
  const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
341
323
  const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
342
324
  let path;
@@ -361,12 +343,11 @@ class ResourceStore extends EventEmitter {
361
343
  key = path.slice(2).join('.');
362
344
  }
363
345
  if (result || !ignoreJSONStructure || !isString(key)) return result;
364
- return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
346
+ return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
365
347
  }
366
- addResource(lng, ns, key, value) {
367
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
368
- silent: false
369
- };
348
+ addResource(lng, ns, key, value, options = {
349
+ silent: false
350
+ }) {
370
351
  const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
371
352
  let path = [lng, ns];
372
353
  if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
@@ -379,10 +360,9 @@ class ResourceStore extends EventEmitter {
379
360
  setPath(this.data, path, value);
380
361
  if (!options.silent) this.emit('added', lng, ns, key, value);
381
362
  }
382
- addResources(lng, ns, resources) {
383
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
384
- silent: false
385
- };
363
+ addResources(lng, ns, resources, options = {
364
+ silent: false
365
+ }) {
386
366
  for (const m in resources) {
387
367
  if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
388
368
  silent: true
@@ -390,11 +370,10 @@ class ResourceStore extends EventEmitter {
390
370
  }
391
371
  if (!options.silent) this.emit('added', lng, ns, resources);
392
372
  }
393
- addResourceBundle(lng, ns, resources, deep, overwrite) {
394
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
395
- silent: false,
396
- skipCopy: false
397
- };
373
+ addResourceBundle(lng, ns, resources, deep, overwrite, options = {
374
+ silent: false,
375
+ skipCopy: false
376
+ }) {
398
377
  let path = [lng, ns];
399
378
  if (lng.indexOf('.') > -1) {
400
379
  path = lng.split('.');
@@ -428,10 +407,6 @@ class ResourceStore extends EventEmitter {
428
407
  }
429
408
  getResourceBundle(lng, ns) {
430
409
  if (!ns) ns = this.options.defaultNS;
431
- if (this.options.compatibilityAPI === 'v1') return {
432
- ...{},
433
- ...this.getResource(lng, ns)
434
- };
435
410
  return this.getResource(lng, ns);
436
411
  }
437
412
  getDataByLanguage(lng) {
@@ -454,16 +429,37 @@ var postProcessor = {
454
429
  },
455
430
  handle(processors, value, key, options, translator) {
456
431
  processors.forEach(processor => {
457
- if (this.processors[processor]) value = this.processors[processor].process(value, key, options, translator);
432
+ value = this.processors[processor]?.process(value, key, options, translator) ?? value;
458
433
  });
459
434
  return value;
460
435
  }
461
436
  };
462
437
 
438
+ const PATH_KEY = Symbol('i18next/PATH_KEY');
439
+ function createProxy() {
440
+ const state = [];
441
+ const handler = Object.create(null);
442
+ let proxy;
443
+ handler.get = (target, key) => {
444
+ proxy?.revoke?.();
445
+ if (key === PATH_KEY) return state;
446
+ state.push(key);
447
+ proxy = Proxy.revocable(target, handler);
448
+ return proxy.proxy;
449
+ };
450
+ return Proxy.revocable(Object.create(null), handler).proxy;
451
+ }
452
+ function keysFromSelector(selector, opts) {
453
+ const {
454
+ [PATH_KEY]: path
455
+ } = selector(createProxy());
456
+ return path.join(opts?.keySeparator ?? '.');
457
+ }
458
+
463
459
  const checkedLoadedFor = {};
460
+ const shouldHandleAsObject = res => !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
464
461
  class Translator extends EventEmitter {
465
- constructor(services) {
466
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
462
+ constructor(services, options = {}) {
467
463
  super();
468
464
  copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
469
465
  this.options = options;
@@ -475,23 +471,28 @@ class Translator extends EventEmitter {
475
471
  changeLanguage(lng) {
476
472
  if (lng) this.language = lng;
477
473
  }
478
- exists(key) {
479
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
480
- interpolation: {}
474
+ exists(key, o = {
475
+ interpolation: {}
476
+ }) {
477
+ const opt = {
478
+ ...o
481
479
  };
482
- if (key === undefined || key === null) {
480
+ if (key == null) return false;
481
+ const resolved = this.resolve(key, opt);
482
+ if (resolved?.res === undefined) return false;
483
+ const isObject = shouldHandleAsObject(resolved.res);
484
+ if (opt.returnObjects === false && isObject) {
483
485
  return false;
484
486
  }
485
- const resolved = this.resolve(key, options);
486
- return resolved && resolved.res !== undefined;
487
+ return true;
487
488
  }
488
- extractFromKey(key, options) {
489
- let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
489
+ extractFromKey(key, opt) {
490
+ let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
490
491
  if (nsSeparator === undefined) nsSeparator = ':';
491
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
492
- let namespaces = options.ns || this.options.defaultNS || [];
492
+ const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
493
+ let namespaces = opt.ns || this.options.defaultNS || [];
493
494
  const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
494
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
495
+ const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
495
496
  if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
496
497
  const m = key.match(this.interpolator.nestingRegexp);
497
498
  if (m && m.length > 0) {
@@ -509,28 +510,36 @@ class Translator extends EventEmitter {
509
510
  namespaces: isString(namespaces) ? [namespaces] : namespaces
510
511
  };
511
512
  }
512
- translate(keys, options, lastKey) {
513
- if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
514
- options = this.options.overloadTranslationOptionHandler(arguments);
513
+ translate(keys, o, lastKey) {
514
+ let opt = typeof o === 'object' ? {
515
+ ...o
516
+ } : o;
517
+ if (typeof opt !== 'object' && this.options.overloadTranslationOptionHandler) {
518
+ opt = this.options.overloadTranslationOptionHandler(arguments);
515
519
  }
516
- if (typeof options === 'object') options = {
517
- ...options
520
+ if (typeof opt === 'object') opt = {
521
+ ...opt
518
522
  };
519
- if (!options) options = {};
520
- if (keys === undefined || keys === null) return '';
523
+ if (!opt) opt = {};
524
+ if (keys == null) return '';
525
+ if (typeof keys === 'function') keys = keysFromSelector(keys, {
526
+ ...this.options,
527
+ ...opt
528
+ });
521
529
  if (!Array.isArray(keys)) keys = [String(keys)];
522
- const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
523
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
530
+ const returnDetails = opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
531
+ const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
524
532
  const {
525
533
  key,
526
534
  namespaces
527
- } = this.extractFromKey(keys[keys.length - 1], options);
535
+ } = this.extractFromKey(keys[keys.length - 1], opt);
528
536
  const namespace = namespaces[namespaces.length - 1];
529
- const lng = options.lng || this.language;
530
- const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
531
- if (lng && lng.toLowerCase() === 'cimode') {
537
+ let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
538
+ if (nsSeparator === undefined) nsSeparator = ':';
539
+ const lng = opt.lng || this.language;
540
+ const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
541
+ if (lng?.toLowerCase() === 'cimode') {
532
542
  if (appendNamespaceToCIMode) {
533
- const nsSeparator = options.nsSeparator || this.options.nsSeparator;
534
543
  if (returnDetails) {
535
544
  return {
536
545
  res: `${namespace}${nsSeparator}${key}`,
@@ -538,7 +547,7 @@ class Translator extends EventEmitter {
538
547
  exactUsedKey: key,
539
548
  usedLng: lng,
540
549
  usedNS: namespace,
541
- usedParams: this.getUsedParamsDetails(options)
550
+ usedParams: this.getUsedParamsDetails(opt)
542
551
  };
543
552
  }
544
553
  return `${namespace}${nsSeparator}${key}`;
@@ -550,69 +559,84 @@ class Translator extends EventEmitter {
550
559
  exactUsedKey: key,
551
560
  usedLng: lng,
552
561
  usedNS: namespace,
553
- usedParams: this.getUsedParamsDetails(options)
562
+ usedParams: this.getUsedParamsDetails(opt)
554
563
  };
555
564
  }
556
565
  return key;
557
566
  }
558
- const resolved = this.resolve(keys, options);
559
- let res = resolved && resolved.res;
560
- const resUsedKey = resolved && resolved.usedKey || key;
561
- const resExactUsedKey = resolved && resolved.exactUsedKey || key;
562
- const resType = Object.prototype.toString.apply(res);
567
+ const resolved = this.resolve(keys, opt);
568
+ let res = resolved?.res;
569
+ const resUsedKey = resolved?.usedKey || key;
570
+ const resExactUsedKey = resolved?.exactUsedKey || key;
563
571
  const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
564
- const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
572
+ const joinArrays = opt.joinArrays !== undefined ? opt.joinArrays : this.options.joinArrays;
565
573
  const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
566
- const handleAsObject = !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
567
- if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(res))) {
568
- if (!options.returnObjects && !this.options.returnObjects) {
574
+ const needsPluralHandling = opt.count !== undefined && !isString(opt.count);
575
+ const hasDefaultValue = Translator.hasDefaultValue(opt);
576
+ const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : '';
577
+ const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
578
+ ordinal: false
579
+ }) : '';
580
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
581
+ const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
582
+ let resForObjHndl = res;
583
+ if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
584
+ resForObjHndl = defaultValue;
585
+ }
586
+ const handleAsObject = shouldHandleAsObject(resForObjHndl);
587
+ const resType = Object.prototype.toString.apply(resForObjHndl);
588
+ if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
589
+ if (!opt.returnObjects && !this.options.returnObjects) {
569
590
  if (!this.options.returnedObjectHandler) {
570
591
  this.logger.warn('accessing an object - but returnObjects options is not enabled!');
571
592
  }
572
- const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {
573
- ...options,
593
+ const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
594
+ ...opt,
574
595
  ns: namespaces
575
596
  }) : `key '${key} (${this.language})' returned an object instead of string.`;
576
597
  if (returnDetails) {
577
598
  resolved.res = r;
578
- resolved.usedParams = this.getUsedParamsDetails(options);
599
+ resolved.usedParams = this.getUsedParamsDetails(opt);
579
600
  return resolved;
580
601
  }
581
602
  return r;
582
603
  }
583
604
  if (keySeparator) {
584
- const resTypeIsArray = Array.isArray(res);
605
+ const resTypeIsArray = Array.isArray(resForObjHndl);
585
606
  const copy = resTypeIsArray ? [] : {};
586
607
  const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
587
- for (const m in res) {
588
- if (Object.prototype.hasOwnProperty.call(res, m)) {
608
+ for (const m in resForObjHndl) {
609
+ if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
589
610
  const deepKey = `${newKeyToUse}${keySeparator}${m}`;
590
- copy[m] = this.translate(deepKey, {
591
- ...options,
592
- ...{
593
- joinArrays: false,
594
- ns: namespaces
595
- }
596
- });
597
- if (copy[m] === deepKey) copy[m] = res[m];
611
+ if (hasDefaultValue && !res) {
612
+ copy[m] = this.translate(deepKey, {
613
+ ...opt,
614
+ defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : undefined,
615
+ ...{
616
+ joinArrays: false,
617
+ ns: namespaces
618
+ }
619
+ });
620
+ } else {
621
+ copy[m] = this.translate(deepKey, {
622
+ ...opt,
623
+ ...{
624
+ joinArrays: false,
625
+ ns: namespaces
626
+ }
627
+ });
628
+ }
629
+ if (copy[m] === deepKey) copy[m] = resForObjHndl[m];
598
630
  }
599
631
  }
600
632
  res = copy;
601
633
  }
602
634
  } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
603
635
  res = res.join(joinArrays);
604
- if (res) res = this.extendTranslation(res, keys, options, lastKey);
636
+ if (res) res = this.extendTranslation(res, keys, opt, lastKey);
605
637
  } else {
606
638
  let usedDefault = false;
607
639
  let usedKey = false;
608
- const needsPluralHandling = options.count !== undefined && !isString(options.count);
609
- const hasDefaultValue = Translator.hasDefaultValue(options);
610
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
611
- const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
612
- ordinal: false
613
- }) : '';
614
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
615
- const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
616
640
  if (!this.isValidLookup(res) && hasDefaultValue) {
617
641
  usedDefault = true;
618
642
  res = defaultValue;
@@ -621,47 +645,47 @@ class Translator extends EventEmitter {
621
645
  usedKey = true;
622
646
  res = key;
623
647
  }
624
- const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
648
+ const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
625
649
  const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
626
650
  const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
627
651
  if (usedKey || usedDefault || updateMissing) {
628
652
  this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
629
653
  if (keySeparator) {
630
654
  const fk = this.resolve(key, {
631
- ...options,
655
+ ...opt,
632
656
  keySeparator: false
633
657
  });
634
658
  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.');
635
659
  }
636
660
  let lngs = [];
637
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
661
+ const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
638
662
  if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
639
663
  for (let i = 0; i < fallbackLngs.length; i++) {
640
664
  lngs.push(fallbackLngs[i]);
641
665
  }
642
666
  } else if (this.options.saveMissingTo === 'all') {
643
- lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
667
+ lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
644
668
  } else {
645
- lngs.push(options.lng || this.language);
669
+ lngs.push(opt.lng || this.language);
646
670
  }
647
671
  const send = (l, k, specificDefaultValue) => {
648
672
  const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
649
673
  if (this.options.missingKeyHandler) {
650
- this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
651
- } else if (this.backendConnector && this.backendConnector.saveMissing) {
652
- this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
674
+ this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
675
+ } else if (this.backendConnector?.saveMissing) {
676
+ this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
653
677
  }
654
678
  this.emit('missingKey', l, namespace, k, res);
655
679
  };
656
680
  if (this.options.saveMissing) {
657
681
  if (this.options.saveMissingPlurals && needsPluralHandling) {
658
682
  lngs.forEach(language => {
659
- const suffixes = this.pluralResolver.getSuffixes(language, options);
660
- if (needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
683
+ const suffixes = this.pluralResolver.getSuffixes(language, opt);
684
+ if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
661
685
  suffixes.push(`${this.options.pluralSeparator}zero`);
662
686
  }
663
687
  suffixes.forEach(suffix => {
664
- send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
688
+ send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
665
689
  });
666
690
  });
667
691
  } else {
@@ -669,87 +693,80 @@ class Translator extends EventEmitter {
669
693
  }
670
694
  }
671
695
  }
672
- res = this.extendTranslation(res, keys, options, resolved, lastKey);
673
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
696
+ res = this.extendTranslation(res, keys, opt, resolved, lastKey);
697
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
698
+ res = `${namespace}${nsSeparator}${key}`;
699
+ }
674
700
  if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
675
- if (this.options.compatibilityAPI !== 'v1') {
676
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
677
- } else {
678
- res = this.options.parseMissingKeyHandler(res);
679
- }
701
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : undefined, opt);
680
702
  }
681
703
  }
682
704
  if (returnDetails) {
683
705
  resolved.res = res;
684
- resolved.usedParams = this.getUsedParamsDetails(options);
706
+ resolved.usedParams = this.getUsedParamsDetails(opt);
685
707
  return resolved;
686
708
  }
687
709
  return res;
688
710
  }
689
- extendTranslation(res, key, options, resolved, lastKey) {
690
- var _this = this;
691
- if (this.i18nFormat && this.i18nFormat.parse) {
711
+ extendTranslation(res, key, opt, resolved, lastKey) {
712
+ if (this.i18nFormat?.parse) {
692
713
  res = this.i18nFormat.parse(res, {
693
714
  ...this.options.interpolation.defaultVariables,
694
- ...options
695
- }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
715
+ ...opt
716
+ }, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
696
717
  resolved
697
718
  });
698
- } else if (!options.skipInterpolation) {
699
- if (options.interpolation) this.interpolator.init({
700
- ...options,
719
+ } else if (!opt.skipInterpolation) {
720
+ if (opt.interpolation) this.interpolator.init({
721
+ ...opt,
701
722
  ...{
702
723
  interpolation: {
703
724
  ...this.options.interpolation,
704
- ...options.interpolation
725
+ ...opt.interpolation
705
726
  }
706
727
  }
707
728
  });
708
- const skipOnVariables = isString(res) && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
729
+ const skipOnVariables = isString(res) && (opt?.interpolation?.skipOnVariables !== undefined ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
709
730
  let nestBef;
710
731
  if (skipOnVariables) {
711
732
  const nb = res.match(this.interpolator.nestingRegexp);
712
733
  nestBef = nb && nb.length;
713
734
  }
714
- let data = options.replace && !isString(options.replace) ? options.replace : options;
735
+ let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
715
736
  if (this.options.interpolation.defaultVariables) data = {
716
737
  ...this.options.interpolation.defaultVariables,
717
738
  ...data
718
739
  };
719
- res = this.interpolator.interpolate(res, data, options.lng || this.language || resolved.usedLng, options);
740
+ res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
720
741
  if (skipOnVariables) {
721
742
  const na = res.match(this.interpolator.nestingRegexp);
722
743
  const nestAft = na && na.length;
723
- if (nestBef < nestAft) options.nest = false;
744
+ if (nestBef < nestAft) opt.nest = false;
724
745
  }
725
- if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = this.language || resolved.usedLng;
726
- if (options.nest !== false) res = this.interpolator.nest(res, function () {
727
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
728
- args[_key] = arguments[_key];
729
- }
730
- if (lastKey && lastKey[0] === args[0] && !options.context) {
731
- _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
746
+ if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
747
+ if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
748
+ if (lastKey?.[0] === args[0] && !opt.context) {
749
+ this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
732
750
  return null;
733
751
  }
734
- return _this.translate(...args, key);
735
- }, options);
736
- if (options.interpolation) this.interpolator.reset();
752
+ return this.translate(...args, key);
753
+ }, opt);
754
+ if (opt.interpolation) this.interpolator.reset();
737
755
  }
738
- const postProcess = options.postProcess || this.options.postProcess;
756
+ const postProcess = opt.postProcess || this.options.postProcess;
739
757
  const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
740
- if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
758
+ if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
741
759
  res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
742
760
  i18nResolved: {
743
761
  ...resolved,
744
- usedParams: this.getUsedParamsDetails(options)
762
+ usedParams: this.getUsedParamsDetails(opt)
745
763
  },
746
- ...options
747
- } : options, this);
764
+ ...opt
765
+ } : opt, this);
748
766
  }
749
767
  return res;
750
768
  }
751
- resolve(keys) {
752
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
769
+ resolve(keys, opt = {}) {
753
770
  let found;
754
771
  let usedKey;
755
772
  let exactUsedKey;
@@ -758,19 +775,19 @@ class Translator extends EventEmitter {
758
775
  if (isString(keys)) keys = [keys];
759
776
  keys.forEach(k => {
760
777
  if (this.isValidLookup(found)) return;
761
- const extracted = this.extractFromKey(k, options);
778
+ const extracted = this.extractFromKey(k, opt);
762
779
  const key = extracted.key;
763
780
  usedKey = key;
764
781
  let namespaces = extracted.namespaces;
765
782
  if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
766
- const needsPluralHandling = options.count !== undefined && !isString(options.count);
767
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
768
- const needsContextHandling = options.context !== undefined && (isString(options.context) || typeof options.context === 'number') && options.context !== '';
769
- const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
783
+ const needsPluralHandling = opt.count !== undefined && !isString(opt.count);
784
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
785
+ const needsContextHandling = opt.context !== undefined && (isString(opt.context) || typeof opt.context === 'number') && opt.context !== '';
786
+ const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
770
787
  namespaces.forEach(ns => {
771
788
  if (this.isValidLookup(found)) return;
772
789
  usedNS = ns;
773
- if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(usedNS)) {
790
+ if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
774
791
  checkedLoadedFor[`${codes[0]}-${ns}`] = true;
775
792
  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!!!');
776
793
  }
@@ -778,30 +795,30 @@ class Translator extends EventEmitter {
778
795
  if (this.isValidLookup(found)) return;
779
796
  usedLng = code;
780
797
  const finalKeys = [key];
781
- if (this.i18nFormat && this.i18nFormat.addLookupKeys) {
782
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
798
+ if (this.i18nFormat?.addLookupKeys) {
799
+ this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
783
800
  } else {
784
801
  let pluralSuffix;
785
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
802
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
786
803
  const zeroSuffix = `${this.options.pluralSeparator}zero`;
787
804
  const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
788
805
  if (needsPluralHandling) {
789
- finalKeys.push(key + pluralSuffix);
790
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
806
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
791
807
  finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
792
808
  }
809
+ finalKeys.push(key + pluralSuffix);
793
810
  if (needsZeroSuffixLookup) {
794
811
  finalKeys.push(key + zeroSuffix);
795
812
  }
796
813
  }
797
814
  if (needsContextHandling) {
798
- const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
815
+ const contextKey = `${key}${this.options.contextSeparator || '_'}${opt.context}`;
799
816
  finalKeys.push(contextKey);
800
817
  if (needsPluralHandling) {
801
- finalKeys.push(contextKey + pluralSuffix);
802
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
818
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
803
819
  finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
804
820
  }
821
+ finalKeys.push(contextKey + pluralSuffix);
805
822
  if (needsZeroSuffixLookup) {
806
823
  finalKeys.push(contextKey + zeroSuffix);
807
824
  }
@@ -812,7 +829,7 @@ class Translator extends EventEmitter {
812
829
  while (possibleKey = finalKeys.pop()) {
813
830
  if (!this.isValidLookup(found)) {
814
831
  exactUsedKey = possibleKey;
815
- found = this.getResource(code, ns, possibleKey, options);
832
+ found = this.getResource(code, ns, possibleKey, opt);
816
833
  }
817
834
  }
818
835
  });
@@ -829,13 +846,11 @@ class Translator extends EventEmitter {
829
846
  isValidLookup(res) {
830
847
  return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
831
848
  }
832
- getResource(code, ns, key) {
833
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
834
- if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
849
+ getResource(code, ns, key, options = {}) {
850
+ if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
835
851
  return this.resourceStore.getResource(code, ns, key, options);
836
852
  }
837
- getUsedParamsDetails() {
838
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
853
+ getUsedParamsDetails(options = {}) {
839
854
  const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
840
855
  const useOptionsReplaceForData = options.replace && !isString(options.replace);
841
856
  let data = useOptionsReplaceForData ? options.replace : options;
@@ -869,7 +884,6 @@ class Translator extends EventEmitter {
869
884
  }
870
885
  }
871
886
 
872
- const capitalize = string => string.charAt(0).toUpperCase() + string.slice(1);
873
887
  class LanguageUtil {
874
888
  constructor(options) {
875
889
  this.options = options;
@@ -893,31 +907,18 @@ class LanguageUtil {
893
907
  }
894
908
  formatLanguageCode(code) {
895
909
  if (isString(code) && code.indexOf('-') > -1) {
896
- if (typeof Intl !== 'undefined' && typeof Intl.getCanonicalLocales !== 'undefined') {
897
- try {
898
- let formattedCode = Intl.getCanonicalLocales(code)[0];
899
- if (formattedCode && this.options.lowerCaseLng) {
900
- formattedCode = formattedCode.toLowerCase();
901
- }
902
- if (formattedCode) return formattedCode;
903
- } catch (e) {}
910
+ let formattedCode;
911
+ try {
912
+ formattedCode = Intl.getCanonicalLocales(code)[0];
913
+ } catch (e) {}
914
+ if (formattedCode && this.options.lowerCaseLng) {
915
+ formattedCode = formattedCode.toLowerCase();
904
916
  }
905
- const specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
906
- let p = code.split('-');
917
+ if (formattedCode) return formattedCode;
907
918
  if (this.options.lowerCaseLng) {
908
- p = p.map(part => part.toLowerCase());
909
- } else if (p.length === 2) {
910
- p[0] = p[0].toLowerCase();
911
- p[1] = p[1].toUpperCase();
912
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
913
- } else if (p.length === 3) {
914
- p[0] = p[0].toLowerCase();
915
- if (p[1].length === 2) p[1] = p[1].toUpperCase();
916
- if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
917
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
918
- if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
919
+ return code.toLowerCase();
919
920
  }
920
- return p.join('-');
921
+ return code;
921
922
  }
922
923
  return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
923
924
  }
@@ -938,6 +939,8 @@ class LanguageUtil {
938
939
  if (!found && this.options.supportedLngs) {
939
940
  codes.forEach(code => {
940
941
  if (found) return;
942
+ const lngScOnly = this.getScriptPartFromCode(code);
943
+ if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
941
944
  const lngOnly = this.getLanguagePartFromCode(code);
942
945
  if (this.isSupportedCode(lngOnly)) return found = lngOnly;
943
946
  found = this.options.supportedLngs.find(supportedLng => {
@@ -965,7 +968,7 @@ class LanguageUtil {
965
968
  return found || [];
966
969
  }
967
970
  toResolveHierarchy(code, fallbackCode) {
968
- const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
971
+ const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
969
972
  const codes = [];
970
973
  const addCode = c => {
971
974
  if (!c) return;
@@ -989,125 +992,6 @@ class LanguageUtil {
989
992
  }
990
993
  }
991
994
 
992
- let sets = [{
993
- lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
994
- nr: [1, 2],
995
- fc: 1
996
- }, {
997
- 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'],
998
- nr: [1, 2],
999
- fc: 2
1000
- }, {
1001
- lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
1002
- nr: [1],
1003
- fc: 3
1004
- }, {
1005
- lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
1006
- nr: [1, 2, 5],
1007
- fc: 4
1008
- }, {
1009
- lngs: ['ar'],
1010
- nr: [0, 1, 2, 3, 11, 100],
1011
- fc: 5
1012
- }, {
1013
- lngs: ['cs', 'sk'],
1014
- nr: [1, 2, 5],
1015
- fc: 6
1016
- }, {
1017
- lngs: ['csb', 'pl'],
1018
- nr: [1, 2, 5],
1019
- fc: 7
1020
- }, {
1021
- lngs: ['cy'],
1022
- nr: [1, 2, 3, 8],
1023
- fc: 8
1024
- }, {
1025
- lngs: ['fr'],
1026
- nr: [1, 2],
1027
- fc: 9
1028
- }, {
1029
- lngs: ['ga'],
1030
- nr: [1, 2, 3, 7, 11],
1031
- fc: 10
1032
- }, {
1033
- lngs: ['gd'],
1034
- nr: [1, 2, 3, 20],
1035
- fc: 11
1036
- }, {
1037
- lngs: ['is'],
1038
- nr: [1, 2],
1039
- fc: 12
1040
- }, {
1041
- lngs: ['jv'],
1042
- nr: [0, 1],
1043
- fc: 13
1044
- }, {
1045
- lngs: ['kw'],
1046
- nr: [1, 2, 3, 4],
1047
- fc: 14
1048
- }, {
1049
- lngs: ['lt'],
1050
- nr: [1, 2, 10],
1051
- fc: 15
1052
- }, {
1053
- lngs: ['lv'],
1054
- nr: [1, 2, 0],
1055
- fc: 16
1056
- }, {
1057
- lngs: ['mk'],
1058
- nr: [1, 2],
1059
- fc: 17
1060
- }, {
1061
- lngs: ['mnk'],
1062
- nr: [0, 1, 2],
1063
- fc: 18
1064
- }, {
1065
- lngs: ['mt'],
1066
- nr: [1, 2, 11, 20],
1067
- fc: 19
1068
- }, {
1069
- lngs: ['or'],
1070
- nr: [2, 1],
1071
- fc: 2
1072
- }, {
1073
- lngs: ['ro'],
1074
- nr: [1, 2, 20],
1075
- fc: 20
1076
- }, {
1077
- lngs: ['sl'],
1078
- nr: [5, 1, 2, 3],
1079
- fc: 21
1080
- }, {
1081
- lngs: ['he', 'iw'],
1082
- nr: [1, 2, 20, 21],
1083
- fc: 22
1084
- }];
1085
- let _rulesPluralsTypes = {
1086
- 1: n => Number(n > 1),
1087
- 2: n => Number(n != 1),
1088
- 3: n => 0,
1089
- 4: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
1090
- 5: n => Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5),
1091
- 6: n => Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2),
1092
- 7: n => Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
1093
- 8: n => Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3),
1094
- 9: n => Number(n >= 2),
1095
- 10: n => Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4),
1096
- 11: n => Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3),
1097
- 12: n => Number(n % 10 != 1 || n % 100 == 11),
1098
- 13: n => Number(n !== 0),
1099
- 14: n => Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3),
1100
- 15: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
1101
- 16: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2),
1102
- 17: n => Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1),
1103
- 18: n => Number(n == 0 ? 0 : n == 1 ? 1 : 2),
1104
- 19: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3),
1105
- 20: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2),
1106
- 21: n => Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0),
1107
- 22: n => Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3)
1108
- };
1109
- const nonIntlVersions = ['v1', 'v2', 'v3'];
1110
- const intlVersions = ['v4'];
1111
995
  const suffixesOrder = {
1112
996
  zero: 0,
1113
997
  one: 1,
@@ -1116,129 +1000,74 @@ const suffixesOrder = {
1116
1000
  many: 4,
1117
1001
  other: 5
1118
1002
  };
1119
- const createRules = () => {
1120
- const rules = {};
1121
- sets.forEach(set => {
1122
- set.lngs.forEach(l => {
1123
- rules[l] = {
1124
- numbers: set.nr,
1125
- plurals: _rulesPluralsTypes[set.fc]
1126
- };
1127
- });
1128
- });
1129
- return rules;
1003
+ const dummyRule = {
1004
+ select: count => count === 1 ? 'one' : 'other',
1005
+ resolvedOptions: () => ({
1006
+ pluralCategories: ['one', 'other']
1007
+ })
1130
1008
  };
1131
1009
  class PluralResolver {
1132
- constructor(languageUtils) {
1133
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1010
+ constructor(languageUtils, options = {}) {
1134
1011
  this.languageUtils = languageUtils;
1135
1012
  this.options = options;
1136
1013
  this.logger = baseLogger.create('pluralResolver');
1137
- if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
1138
- this.options.compatibilityJSON = 'v3';
1139
- 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.');
1140
- }
1141
- this.rules = createRules();
1142
1014
  this.pluralRulesCache = {};
1143
1015
  }
1144
- addRule(lng, obj) {
1145
- this.rules[lng] = obj;
1146
- }
1147
1016
  clearCache() {
1148
1017
  this.pluralRulesCache = {};
1149
1018
  }
1150
- getRule(code) {
1151
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1152
- if (this.shouldUseIntlApi()) {
1153
- const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
1154
- const type = options.ordinal ? 'ordinal' : 'cardinal';
1155
- const cacheKey = JSON.stringify({
1156
- cleanedCode,
1019
+ getRule(code, options = {}) {
1020
+ const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
1021
+ const type = options.ordinal ? 'ordinal' : 'cardinal';
1022
+ const cacheKey = JSON.stringify({
1023
+ cleanedCode,
1024
+ type
1025
+ });
1026
+ if (cacheKey in this.pluralRulesCache) {
1027
+ return this.pluralRulesCache[cacheKey];
1028
+ }
1029
+ let rule;
1030
+ try {
1031
+ rule = new Intl.PluralRules(cleanedCode, {
1157
1032
  type
1158
1033
  });
1159
- if (cacheKey in this.pluralRulesCache) {
1160
- return this.pluralRulesCache[cacheKey];
1034
+ } catch (err) {
1035
+ if (!Intl) {
1036
+ this.logger.error('No Intl support, please use an Intl polyfill!');
1037
+ return dummyRule;
1161
1038
  }
1162
- let rule;
1163
- try {
1164
- rule = new Intl.PluralRules(cleanedCode, {
1165
- type
1166
- });
1167
- } catch (err) {
1168
- if (!code.match(/-|_/)) return;
1169
- const lngPart = this.languageUtils.getLanguagePartFromCode(code);
1170
- rule = this.getRule(lngPart, options);
1171
- }
1172
- this.pluralRulesCache[cacheKey] = rule;
1173
- return rule;
1039
+ if (!code.match(/-|_/)) return dummyRule;
1040
+ const lngPart = this.languageUtils.getLanguagePartFromCode(code);
1041
+ rule = this.getRule(lngPart, options);
1174
1042
  }
1175
- return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
1043
+ this.pluralRulesCache[cacheKey] = rule;
1044
+ return rule;
1176
1045
  }
1177
- needsPlural(code) {
1178
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1179
- const rule = this.getRule(code, options);
1180
- if (this.shouldUseIntlApi()) {
1181
- return rule && rule.resolvedOptions().pluralCategories.length > 1;
1182
- }
1183
- return rule && rule.numbers.length > 1;
1046
+ needsPlural(code, options = {}) {
1047
+ let rule = this.getRule(code, options);
1048
+ if (!rule) rule = this.getRule('dev', options);
1049
+ return rule?.resolvedOptions().pluralCategories.length > 1;
1184
1050
  }
1185
- getPluralFormsOfKey(code, key) {
1186
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1051
+ getPluralFormsOfKey(code, key, options = {}) {
1187
1052
  return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
1188
1053
  }
1189
- getSuffixes(code) {
1190
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1191
- const rule = this.getRule(code, options);
1192
- if (!rule) {
1193
- return [];
1194
- }
1195
- if (this.shouldUseIntlApi()) {
1196
- return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
1197
- }
1198
- return rule.numbers.map(number => this.getSuffix(code, number, options));
1054
+ getSuffixes(code, options = {}) {
1055
+ let rule = this.getRule(code, options);
1056
+ if (!rule) rule = this.getRule('dev', options);
1057
+ if (!rule) return [];
1058
+ return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
1199
1059
  }
1200
- getSuffix(code, count) {
1201
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1060
+ getSuffix(code, count, options = {}) {
1202
1061
  const rule = this.getRule(code, options);
1203
1062
  if (rule) {
1204
- if (this.shouldUseIntlApi()) {
1205
- return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
1206
- }
1207
- return this.getSuffixRetroCompatible(rule, count);
1063
+ return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
1208
1064
  }
1209
1065
  this.logger.warn(`no plural rule found for: ${code}`);
1210
- return '';
1211
- }
1212
- getSuffixRetroCompatible(rule, count) {
1213
- const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
1214
- let suffix = rule.numbers[idx];
1215
- if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1216
- if (suffix === 2) {
1217
- suffix = 'plural';
1218
- } else if (suffix === 1) {
1219
- suffix = '';
1220
- }
1221
- }
1222
- const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();
1223
- if (this.options.compatibilityJSON === 'v1') {
1224
- if (suffix === 1) return '';
1225
- if (typeof suffix === 'number') return `_plural_${suffix.toString()}`;
1226
- return returnSuffix();
1227
- } else if (this.options.compatibilityJSON === 'v2') {
1228
- return returnSuffix();
1229
- } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1230
- return returnSuffix();
1231
- }
1232
- return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
1233
- }
1234
- shouldUseIntlApi() {
1235
- return !nonIntlVersions.includes(this.options.compatibilityJSON);
1066
+ return this.getSuffix('dev', count, options);
1236
1067
  }
1237
1068
  }
1238
1069
 
1239
- const deepFindWithDefaults = function (data, defaultData, key) {
1240
- let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
1241
- let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1070
+ const deepFindWithDefaults = (data, defaultData, key, keySeparator = '.', ignoreJSONStructure = true) => {
1242
1071
  let path = getPathWithDefaults(data, defaultData, key);
1243
1072
  if (!path && ignoreJSONStructure && isString(key)) {
1244
1073
  path = deepFind(data, key, keySeparator);
@@ -1248,15 +1077,13 @@ const deepFindWithDefaults = function (data, defaultData, key) {
1248
1077
  };
1249
1078
  const regexSafe = val => val.replace(/\$/g, '$$$$');
1250
1079
  class Interpolator {
1251
- constructor() {
1252
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1080
+ constructor(options = {}) {
1253
1081
  this.logger = baseLogger.create('interpolator');
1254
1082
  this.options = options;
1255
- this.format = options.interpolation && options.interpolation.format || (value => value);
1083
+ this.format = options?.interpolation?.format || (value => value);
1256
1084
  this.init(options);
1257
1085
  }
1258
- init() {
1259
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1086
+ init(options = {}) {
1260
1087
  if (!options.interpolation) options.interpolation = {
1261
1088
  escapeValue: true
1262
1089
  };
@@ -1299,7 +1126,7 @@ class Interpolator {
1299
1126
  }
1300
1127
  resetRegExp() {
1301
1128
  const getOrResetRegExp = (existingRegExp, pattern) => {
1302
- if (existingRegExp && existingRegExp.source === pattern) {
1129
+ if (existingRegExp?.source === pattern) {
1303
1130
  existingRegExp.lastIndex = 0;
1304
1131
  return existingRegExp;
1305
1132
  }
@@ -1307,7 +1134,7 @@ class Interpolator {
1307
1134
  };
1308
1135
  this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
1309
1136
  this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
1310
- this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
1137
+ this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
1311
1138
  }
1312
1139
  interpolate(str, data, lng, options) {
1313
1140
  let match;
@@ -1333,8 +1160,8 @@ class Interpolator {
1333
1160
  });
1334
1161
  };
1335
1162
  this.resetRegExp();
1336
- const missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
1337
- const skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1163
+ const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
1164
+ const skipOnVariables = options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1338
1165
  const todos = [{
1339
1166
  regex: this.regexpUnescape,
1340
1167
  safeValue: val => regexSafe(val)
@@ -1379,8 +1206,7 @@ class Interpolator {
1379
1206
  });
1380
1207
  return str;
1381
1208
  }
1382
- nest(str, fc) {
1383
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1209
+ nest(str, fc, options = {}) {
1384
1210
  let match;
1385
1211
  let value;
1386
1212
  let clonedOptions;
@@ -1393,7 +1219,7 @@ class Interpolator {
1393
1219
  optionsString = this.interpolate(optionsString, clonedOptions);
1394
1220
  const matchedSingleQuotes = optionsString.match(/'/g);
1395
1221
  const matchedDoubleQuotes = optionsString.match(/"/g);
1396
- if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1222
+ if ((matchedSingleQuotes?.length ?? 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1397
1223
  optionsString = optionsString.replace(/'/g, '"');
1398
1224
  }
1399
1225
  try {
@@ -1417,12 +1243,10 @@ class Interpolator {
1417
1243
  clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1418
1244
  clonedOptions.applyPostProcessor = false;
1419
1245
  delete clonedOptions.defaultValue;
1420
- let doReduce = false;
1421
- if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
1422
- const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
1423
- match[1] = r.shift();
1424
- formatters = r;
1425
- doReduce = true;
1246
+ const keyEndIndex = /{.*}/.test(match[1]) ? match[1].lastIndexOf('}') + 1 : match[1].indexOf(this.formatSeparator);
1247
+ if (keyEndIndex !== -1) {
1248
+ formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map(elem => elem.trim()).filter(Boolean);
1249
+ match[1] = match[1].slice(0, keyEndIndex);
1426
1250
  }
1427
1251
  value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1428
1252
  if (value && match[0] === str && !isString(value)) return value;
@@ -1431,7 +1255,7 @@ class Interpolator {
1431
1255
  this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1432
1256
  value = '';
1433
1257
  }
1434
- if (doReduce) {
1258
+ if (formatters.length) {
1435
1259
  value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1436
1260
  ...options,
1437
1261
  interpolationkey: match[1].trim()
@@ -1477,68 +1301,68 @@ const parseFormatStr = formatStr => {
1477
1301
  };
1478
1302
  const createCachedFormatter = fn => {
1479
1303
  const cache = {};
1480
- return (val, lng, options) => {
1481
- let optForCache = options;
1482
- if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
1304
+ return (v, l, o) => {
1305
+ let optForCache = o;
1306
+ if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
1483
1307
  optForCache = {
1484
1308
  ...optForCache,
1485
- [options.interpolationkey]: undefined
1309
+ [o.interpolationkey]: undefined
1486
1310
  };
1487
1311
  }
1488
- const key = lng + JSON.stringify(optForCache);
1489
- let formatter = cache[key];
1490
- if (!formatter) {
1491
- formatter = fn(getCleanedCode(lng), options);
1492
- cache[key] = formatter;
1312
+ const key = l + JSON.stringify(optForCache);
1313
+ let frm = cache[key];
1314
+ if (!frm) {
1315
+ frm = fn(getCleanedCode(l), o);
1316
+ cache[key] = frm;
1493
1317
  }
1494
- return formatter(val);
1318
+ return frm(v);
1495
1319
  };
1496
1320
  };
1321
+ const createNonCachedFormatter = fn => (v, l, o) => fn(getCleanedCode(l), o)(v);
1497
1322
  class Formatter {
1498
- constructor() {
1499
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1323
+ constructor(options = {}) {
1500
1324
  this.logger = baseLogger.create('formatter');
1501
1325
  this.options = options;
1326
+ this.init(options);
1327
+ }
1328
+ init(services, options = {
1329
+ interpolation: {}
1330
+ }) {
1331
+ this.formatSeparator = options.interpolation.formatSeparator || ',';
1332
+ const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
1502
1333
  this.formats = {
1503
- number: createCachedFormatter((lng, opt) => {
1334
+ number: cf((lng, opt) => {
1504
1335
  const formatter = new Intl.NumberFormat(lng, {
1505
1336
  ...opt
1506
1337
  });
1507
1338
  return val => formatter.format(val);
1508
1339
  }),
1509
- currency: createCachedFormatter((lng, opt) => {
1340
+ currency: cf((lng, opt) => {
1510
1341
  const formatter = new Intl.NumberFormat(lng, {
1511
1342
  ...opt,
1512
1343
  style: 'currency'
1513
1344
  });
1514
1345
  return val => formatter.format(val);
1515
1346
  }),
1516
- datetime: createCachedFormatter((lng, opt) => {
1347
+ datetime: cf((lng, opt) => {
1517
1348
  const formatter = new Intl.DateTimeFormat(lng, {
1518
1349
  ...opt
1519
1350
  });
1520
1351
  return val => formatter.format(val);
1521
1352
  }),
1522
- relativetime: createCachedFormatter((lng, opt) => {
1353
+ relativetime: cf((lng, opt) => {
1523
1354
  const formatter = new Intl.RelativeTimeFormat(lng, {
1524
1355
  ...opt
1525
1356
  });
1526
1357
  return val => formatter.format(val, opt.range || 'day');
1527
1358
  }),
1528
- list: createCachedFormatter((lng, opt) => {
1359
+ list: cf((lng, opt) => {
1529
1360
  const formatter = new Intl.ListFormat(lng, {
1530
1361
  ...opt
1531
1362
  });
1532
1363
  return val => formatter.format(val);
1533
1364
  })
1534
1365
  };
1535
- this.init(options);
1536
- }
1537
- init(services) {
1538
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1539
- interpolation: {}
1540
- };
1541
- this.formatSeparator = options.interpolation.formatSeparator || ',';
1542
1366
  }
1543
1367
  add(name, fc) {
1544
1368
  this.formats[name.toLowerCase().trim()] = fc;
@@ -1546,8 +1370,7 @@ class Formatter {
1546
1370
  addCached(name, fc) {
1547
1371
  this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1548
1372
  }
1549
- format(value, format, lng) {
1550
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1373
+ format(value, format, lng, options = {}) {
1551
1374
  const formats = format.split(this.formatSeparator);
1552
1375
  if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
1553
1376
  const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
@@ -1561,7 +1384,7 @@ class Formatter {
1561
1384
  if (this.formats[formatName]) {
1562
1385
  let formatted = mem;
1563
1386
  try {
1564
- const valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
1387
+ const valOptions = options?.formatParams?.[options.interpolationkey] || {};
1565
1388
  const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1566
1389
  formatted = this.formats[formatName](mem, l, {
1567
1390
  ...formatOptions,
@@ -1588,8 +1411,7 @@ const removePending = (q, name) => {
1588
1411
  }
1589
1412
  };
1590
1413
  class Connector extends EventEmitter {
1591
- constructor(backend, store, services) {
1592
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1414
+ constructor(backend, store, services, options = {}) {
1593
1415
  super();
1594
1416
  this.backend = backend;
1595
1417
  this.store = store;
@@ -1604,9 +1426,7 @@ class Connector extends EventEmitter {
1604
1426
  this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1605
1427
  this.state = {};
1606
1428
  this.queue = [];
1607
- if (this.backend && this.backend.init) {
1608
- this.backend.init(services, options.backend, options);
1609
- }
1429
+ this.backend?.init?.(services, options.backend, options);
1610
1430
  }
1611
1431
  queueLoad(languages, namespaces, options, callback) {
1612
1432
  const toLoad = {};
@@ -1685,10 +1505,7 @@ class Connector extends EventEmitter {
1685
1505
  this.emit('loaded', loaded);
1686
1506
  this.queue = this.queue.filter(q => !q.done);
1687
1507
  }
1688
- read(lng, ns, fcName) {
1689
- let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1690
- let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
1691
- let callback = arguments.length > 5 ? arguments[5] : undefined;
1508
+ read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
1692
1509
  if (!lng.length) return callback(null, {});
1693
1510
  if (this.readingCalls >= this.maxParallelReads) {
1694
1511
  this.waitingReads.push({
@@ -1732,9 +1549,7 @@ class Connector extends EventEmitter {
1732
1549
  }
1733
1550
  return fc(lng, ns, resolver);
1734
1551
  }
1735
- prepareLoading(languages, namespaces) {
1736
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1737
- let callback = arguments.length > 3 ? arguments[3] : undefined;
1552
+ prepareLoading(languages, namespaces, options = {}, callback) {
1738
1553
  if (!this.backend) {
1739
1554
  this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1740
1555
  return callback && callback();
@@ -1758,8 +1573,7 @@ class Connector extends EventEmitter {
1758
1573
  reload: true
1759
1574
  }, callback);
1760
1575
  }
1761
- loadOne(name) {
1762
- let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1576
+ loadOne(name, prefix = '') {
1763
1577
  const s = name.split('|');
1764
1578
  const lng = s[0];
1765
1579
  const ns = s[1];
@@ -1769,15 +1583,13 @@ class Connector extends EventEmitter {
1769
1583
  this.loaded(name, err, data);
1770
1584
  });
1771
1585
  }
1772
- saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
1773
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1774
- let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
1775
- if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
1586
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {}) {
1587
+ if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
1776
1588
  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!!!');
1777
1589
  return;
1778
1590
  }
1779
1591
  if (key === undefined || key === null || key === '') return;
1780
- if (this.backend && this.backend.create) {
1592
+ if (this.backend?.create) {
1781
1593
  const opts = {
1782
1594
  ...options,
1783
1595
  isUpdate
@@ -1810,7 +1622,7 @@ class Connector extends EventEmitter {
1810
1622
 
1811
1623
  const get = () => ({
1812
1624
  debug: false,
1813
- initImmediate: true,
1625
+ initAsync: true,
1814
1626
  ns: ['translation'],
1815
1627
  defaultNS: ['translation'],
1816
1628
  fallbackLng: ['dev'],
@@ -1866,15 +1678,17 @@ const get = () => ({
1866
1678
  nestingOptionsSeparator: ',',
1867
1679
  maxReplaces: 1000,
1868
1680
  skipOnVariables: true
1869
- }
1681
+ },
1682
+ cacheInBuiltFormats: true
1870
1683
  });
1871
1684
  const transformOptions = options => {
1872
1685
  if (isString(options.ns)) options.ns = [options.ns];
1873
1686
  if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1874
1687
  if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1875
- if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
1688
+ if (options.supportedLngs?.indexOf?.('cimode') < 0) {
1876
1689
  options.supportedLngs = options.supportedLngs.concat(['cimode']);
1877
1690
  }
1691
+ if (typeof options.initImmediate === 'boolean') options.initAsync = options.initImmediate;
1878
1692
  return options;
1879
1693
  };
1880
1694
 
@@ -1888,9 +1702,7 @@ const bindMemberFunctions = inst => {
1888
1702
  });
1889
1703
  };
1890
1704
  class I18n extends EventEmitter {
1891
- constructor() {
1892
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1893
- let callback = arguments.length > 1 ? arguments[1] : undefined;
1705
+ constructor(options = {}, callback) {
1894
1706
  super();
1895
1707
  this.options = transformOptions(options);
1896
1708
  this.services = {};
@@ -1900,7 +1712,7 @@ class I18n extends EventEmitter {
1900
1712
  };
1901
1713
  bindMemberFunctions(this);
1902
1714
  if (callback && !this.isInitialized && !options.isClone) {
1903
- if (!this.options.initImmediate) {
1715
+ if (!this.options.initAsync) {
1904
1716
  this.init(options, callback);
1905
1717
  return this;
1906
1718
  }
@@ -1909,16 +1721,13 @@ class I18n extends EventEmitter {
1909
1721
  }, 0);
1910
1722
  }
1911
1723
  }
1912
- init() {
1913
- var _this = this;
1914
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1915
- let callback = arguments.length > 1 ? arguments[1] : undefined;
1724
+ init(options = {}, callback) {
1916
1725
  this.isInitializing = true;
1917
1726
  if (typeof options === 'function') {
1918
1727
  callback = options;
1919
1728
  options = {};
1920
1729
  }
1921
- if (!options.defaultNS && options.defaultNS !== false && options.ns) {
1730
+ if (options.defaultNS == null && options.ns) {
1922
1731
  if (isString(options.ns)) {
1923
1732
  options.defaultNS = options.ns;
1924
1733
  } else if (options.ns.indexOf('translation') < 0) {
@@ -1931,18 +1740,19 @@ class I18n extends EventEmitter {
1931
1740
  ...this.options,
1932
1741
  ...transformOptions(options)
1933
1742
  };
1934
- if (this.options.compatibilityAPI !== 'v1') {
1935
- this.options.interpolation = {
1936
- ...defOpts.interpolation,
1937
- ...this.options.interpolation
1938
- };
1939
- }
1743
+ this.options.interpolation = {
1744
+ ...defOpts.interpolation,
1745
+ ...this.options.interpolation
1746
+ };
1940
1747
  if (options.keySeparator !== undefined) {
1941
1748
  this.options.userDefinedKeySeparator = options.keySeparator;
1942
1749
  }
1943
1750
  if (options.nsSeparator !== undefined) {
1944
1751
  this.options.userDefinedNsSeparator = options.nsSeparator;
1945
1752
  }
1753
+ if (typeof this.options.overloadTranslationOptionHandler !== 'function') {
1754
+ this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
1755
+ }
1946
1756
  const createClassOnDemand = ClassOrObject => {
1947
1757
  if (!ClassOrObject) return null;
1948
1758
  if (typeof ClassOrObject === 'function') return new ClassOrObject();
@@ -1957,7 +1767,7 @@ class I18n extends EventEmitter {
1957
1767
  let formatter;
1958
1768
  if (this.modules.formatter) {
1959
1769
  formatter = this.modules.formatter;
1960
- } else if (typeof Intl !== 'undefined') {
1770
+ } else {
1961
1771
  formatter = Formatter;
1962
1772
  }
1963
1773
  const lu = new LanguageUtil(this.options);
@@ -1968,12 +1778,15 @@ class I18n extends EventEmitter {
1968
1778
  s.languageUtils = lu;
1969
1779
  s.pluralResolver = new PluralResolver(lu, {
1970
1780
  prepend: this.options.pluralSeparator,
1971
- compatibilityJSON: this.options.compatibilityJSON,
1972
1781
  simplifyPluralSuffix: this.options.simplifyPluralSuffix
1973
1782
  });
1783
+ const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
1784
+ if (usingLegacyFormatFunction) {
1785
+ this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
1786
+ }
1974
1787
  if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1975
1788
  s.formatter = createClassOnDemand(formatter);
1976
- s.formatter.init(s, this.options);
1789
+ if (s.formatter.init) s.formatter.init(s, this.options);
1977
1790
  this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1978
1791
  }
1979
1792
  s.interpolator = new Interpolator(this.options);
@@ -1981,11 +1794,8 @@ class I18n extends EventEmitter {
1981
1794
  hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1982
1795
  };
1983
1796
  s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1984
- s.backendConnector.on('*', function (event) {
1985
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1986
- args[_key - 1] = arguments[_key];
1987
- }
1988
- _this.emit(event, ...args);
1797
+ s.backendConnector.on('*', (event, ...args) => {
1798
+ this.emit(event, ...args);
1989
1799
  });
1990
1800
  if (this.modules.languageDetector) {
1991
1801
  s.languageDetector = createClassOnDemand(this.modules.languageDetector);
@@ -1996,11 +1806,8 @@ class I18n extends EventEmitter {
1996
1806
  if (s.i18nFormat.init) s.i18nFormat.init(this);
1997
1807
  }
1998
1808
  this.translator = new Translator(this.services, this.options);
1999
- this.translator.on('*', function (event) {
2000
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2001
- args[_key2 - 1] = arguments[_key2];
2002
- }
2003
- _this.emit(event, ...args);
1809
+ this.translator.on('*', (event, ...args) => {
1810
+ this.emit(event, ...args);
2004
1811
  });
2005
1812
  this.modules.external.forEach(m => {
2006
1813
  if (m.init) m.init(this);
@@ -2017,15 +1824,13 @@ class I18n extends EventEmitter {
2017
1824
  }
2018
1825
  const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
2019
1826
  storeApi.forEach(fcName => {
2020
- this[fcName] = function () {
2021
- return _this.store[fcName](...arguments);
2022
- };
1827
+ this[fcName] = (...args) => this.store[fcName](...args);
2023
1828
  });
2024
1829
  const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
2025
1830
  storeApiChained.forEach(fcName => {
2026
- this[fcName] = function () {
2027
- _this.store[fcName](...arguments);
2028
- return _this;
1831
+ this[fcName] = (...args) => {
1832
+ this.store[fcName](...args);
1833
+ return this;
2029
1834
  };
2030
1835
  });
2031
1836
  const deferred = defer();
@@ -2039,23 +1844,22 @@ class I18n extends EventEmitter {
2039
1844
  deferred.resolve(t);
2040
1845
  callback(err, t);
2041
1846
  };
2042
- if (this.languages && this.options.compatibilityAPI !== 'v1' && !this.isInitialized) return finish(null, this.t.bind(this));
1847
+ if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
2043
1848
  this.changeLanguage(this.options.lng, finish);
2044
1849
  };
2045
- if (this.options.resources || !this.options.initImmediate) {
1850
+ if (this.options.resources || !this.options.initAsync) {
2046
1851
  load();
2047
1852
  } else {
2048
1853
  setTimeout(load, 0);
2049
1854
  }
2050
1855
  return deferred;
2051
1856
  }
2052
- loadResources(language) {
2053
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
1857
+ loadResources(language, callback = noop) {
2054
1858
  let usedCallback = callback;
2055
1859
  const usedLng = isString(language) ? language : this.language;
2056
1860
  if (typeof language === 'function') usedCallback = language;
2057
1861
  if (!this.options.resources || this.options.partialBundledLanguages) {
2058
- if (usedLng && usedLng.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
1862
+ if (usedLng?.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
2059
1863
  const toLoad = [];
2060
1864
  const append = lng => {
2061
1865
  if (!lng) return;
@@ -2072,9 +1876,7 @@ class I18n extends EventEmitter {
2072
1876
  } else {
2073
1877
  append(usedLng);
2074
1878
  }
2075
- if (this.options.preload) {
2076
- this.options.preload.forEach(l => append(l));
2077
- }
1879
+ this.options.preload?.forEach?.(l => append(l));
2078
1880
  this.services.backendConnector.load(toLoad, this.options.ns, e => {
2079
1881
  if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
2080
1882
  usedCallback(e);
@@ -2139,9 +1941,12 @@ class I18n extends EventEmitter {
2139
1941
  break;
2140
1942
  }
2141
1943
  }
1944
+ if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
1945
+ this.resolvedLanguage = l;
1946
+ this.languages.unshift(l);
1947
+ }
2142
1948
  }
2143
1949
  changeLanguage(lng, callback) {
2144
- var _this2 = this;
2145
1950
  this.isLanguageChangingTo = lng;
2146
1951
  const deferred = defer();
2147
1952
  this.emit('languageChanging', lng);
@@ -2153,30 +1958,29 @@ class I18n extends EventEmitter {
2153
1958
  };
2154
1959
  const done = (err, l) => {
2155
1960
  if (l) {
2156
- setLngProps(l);
2157
- this.translator.changeLanguage(l);
2158
- this.isLanguageChangingTo = undefined;
2159
- this.emit('languageChanged', l);
2160
- this.logger.log('languageChanged', l);
1961
+ if (this.isLanguageChangingTo === lng) {
1962
+ setLngProps(l);
1963
+ this.translator.changeLanguage(l);
1964
+ this.isLanguageChangingTo = undefined;
1965
+ this.emit('languageChanged', l);
1966
+ this.logger.log('languageChanged', l);
1967
+ }
2161
1968
  } else {
2162
1969
  this.isLanguageChangingTo = undefined;
2163
1970
  }
2164
- deferred.resolve(function () {
2165
- return _this2.t(...arguments);
2166
- });
2167
- if (callback) callback(err, function () {
2168
- return _this2.t(...arguments);
2169
- });
1971
+ deferred.resolve((...args) => this.t(...args));
1972
+ if (callback) callback(err, (...args) => this.t(...args));
2170
1973
  };
2171
1974
  const setLng = lngs => {
2172
1975
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
2173
- const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
1976
+ const fl = isString(lngs) ? lngs : lngs && lngs[0];
1977
+ const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
2174
1978
  if (l) {
2175
1979
  if (!this.language) {
2176
1980
  setLngProps(l);
2177
1981
  }
2178
1982
  if (!this.translator.language) this.translator.changeLanguage(l);
2179
- if (this.services.languageDetector && this.services.languageDetector.cacheUserLanguage) this.services.languageDetector.cacheUserLanguage(l);
1983
+ this.services.languageDetector?.cacheUserLanguage?.(l);
2180
1984
  }
2181
1985
  this.loadResources(l, err => {
2182
1986
  done(err, l);
@@ -2196,31 +2000,37 @@ class I18n extends EventEmitter {
2196
2000
  return deferred;
2197
2001
  }
2198
2002
  getFixedT(lng, ns, keyPrefix) {
2199
- var _this3 = this;
2200
- const fixedT = function (key, opts) {
2201
- let options;
2003
+ const fixedT = (key, opts, ...rest) => {
2004
+ let o;
2202
2005
  if (typeof opts !== 'object') {
2203
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2204
- rest[_key3 - 2] = arguments[_key3];
2205
- }
2206
- options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2006
+ o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2207
2007
  } else {
2208
- options = {
2008
+ o = {
2209
2009
  ...opts
2210
2010
  };
2211
2011
  }
2212
- options.lng = options.lng || fixedT.lng;
2213
- options.lngs = options.lngs || fixedT.lngs;
2214
- options.ns = options.ns || fixedT.ns;
2215
- if (options.keyPrefix !== '') options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
2216
- const keySeparator = _this3.options.keySeparator || '.';
2012
+ o.lng = o.lng || fixedT.lng;
2013
+ o.lngs = o.lngs || fixedT.lngs;
2014
+ o.ns = o.ns || fixedT.ns;
2015
+ if (o.keyPrefix !== '') o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
2016
+ const keySeparator = this.options.keySeparator || '.';
2217
2017
  let resultKey;
2218
- if (options.keyPrefix && Array.isArray(key)) {
2219
- resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
2018
+ if (o.keyPrefix && Array.isArray(key)) {
2019
+ resultKey = key.map(k => {
2020
+ if (typeof k === 'function') k = keysFromSelector(k, {
2021
+ ...this.options,
2022
+ ...opts
2023
+ });
2024
+ return `${o.keyPrefix}${keySeparator}${k}`;
2025
+ });
2220
2026
  } else {
2221
- resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
2027
+ if (typeof key === 'function') key = keysFromSelector(key, {
2028
+ ...this.options,
2029
+ ...opts
2030
+ });
2031
+ resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
2222
2032
  }
2223
- return _this3.t(resultKey, options);
2033
+ return this.t(resultKey, o);
2224
2034
  };
2225
2035
  if (isString(lng)) {
2226
2036
  fixedT.lng = lng;
@@ -2231,17 +2041,16 @@ class I18n extends EventEmitter {
2231
2041
  fixedT.keyPrefix = keyPrefix;
2232
2042
  return fixedT;
2233
2043
  }
2234
- t() {
2235
- return this.translator && this.translator.translate(...arguments);
2044
+ t(...args) {
2045
+ return this.translator?.translate(...args);
2236
2046
  }
2237
- exists() {
2238
- return this.translator && this.translator.exists(...arguments);
2047
+ exists(...args) {
2048
+ return this.translator?.exists(...args);
2239
2049
  }
2240
2050
  setDefaultNamespace(ns) {
2241
2051
  this.options.defaultNS = ns;
2242
2052
  }
2243
- hasLoadedNamespace(ns) {
2244
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2053
+ hasLoadedNamespace(ns, options = {}) {
2245
2054
  if (!this.isInitialized) {
2246
2055
  this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2247
2056
  return false;
@@ -2300,20 +2109,26 @@ class I18n extends EventEmitter {
2300
2109
  return deferred;
2301
2110
  }
2302
2111
  dir(lng) {
2303
- if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
2112
+ if (!lng) lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
2304
2113
  if (!lng) return 'rtl';
2114
+ try {
2115
+ const l = new Intl.Locale(lng);
2116
+ if (l && l.getTextInfo) {
2117
+ const ti = l.getTextInfo();
2118
+ if (ti && ti.direction) return ti.direction;
2119
+ }
2120
+ } catch (e) {}
2305
2121
  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'];
2306
- const languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
2122
+ const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
2123
+ if (lng.toLowerCase().indexOf('-latn') > 1) return 'ltr';
2307
2124
  return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2308
2125
  }
2309
- static createInstance() {
2310
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2311
- let callback = arguments.length > 1 ? arguments[1] : undefined;
2312
- return new I18n(options, callback);
2126
+ static createInstance(options = {}, callback) {
2127
+ const instance = new I18n(options, callback);
2128
+ instance.createInstance = I18n.createInstance;
2129
+ return instance;
2313
2130
  }
2314
- cloneInstance() {
2315
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2316
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2131
+ cloneInstance(options = {}, callback = noop) {
2317
2132
  const forkResourceStore = options.forkResourceStore;
2318
2133
  if (forkResourceStore) delete options.forkResourceStore;
2319
2134
  const mergedOptions = {
@@ -2338,14 +2153,36 @@ class I18n extends EventEmitter {
2338
2153
  hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2339
2154
  };
2340
2155
  if (forkResourceStore) {
2341
- clone.store = new ResourceStore(this.store.data, mergedOptions);
2156
+ const clonedData = Object.keys(this.store.data).reduce((prev, l) => {
2157
+ prev[l] = {
2158
+ ...this.store.data[l]
2159
+ };
2160
+ prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
2161
+ acc[n] = {
2162
+ ...prev[l][n]
2163
+ };
2164
+ return acc;
2165
+ }, prev[l]);
2166
+ return prev;
2167
+ }, {});
2168
+ clone.store = new ResourceStore(clonedData, mergedOptions);
2342
2169
  clone.services.resourceStore = clone.store;
2343
2170
  }
2171
+ if (options.interpolation) {
2172
+ const defOpts = get();
2173
+ const mergedInterpolation = {
2174
+ ...defOpts.interpolation,
2175
+ ...this.options.interpolation,
2176
+ ...options.interpolation
2177
+ };
2178
+ const mergedForInterpolator = {
2179
+ ...mergedOptions,
2180
+ interpolation: mergedInterpolation
2181
+ };
2182
+ clone.services.interpolator = new Interpolator(mergedForInterpolator);
2183
+ }
2344
2184
  clone.translator = new Translator(clone.services, mergedOptions);
2345
- clone.translator.on('*', function (event) {
2346
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
2347
- args[_key4 - 1] = arguments[_key4];
2348
- }
2185
+ clone.translator.on('*', (event, ...args) => {
2349
2186
  clone.emit(event, ...args);
2350
2187
  });
2351
2188
  clone.init(mergedOptions, callback);
@@ -2366,7 +2203,6 @@ class I18n extends EventEmitter {
2366
2203
  }
2367
2204
  }
2368
2205
  const instance = I18n.createInstance();
2369
- instance.createInstance = I18n.createInstance;
2370
2206
 
2371
2207
  const auth$5 = {
2372
2208
  email: {