use-intl 2.17.4-alpha.1 → 2.17.5-alpha.1

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 (484) hide show
  1. package/dist/_virtual/use-intl.esm.js +102 -0
  2. package/dist/_virtual/use-intl.esm.js.map +1 -0
  3. package/dist/core/AbstractIntlMessages.d.ts +9 -10
  4. package/dist/core/DateTimeFormatOptions.d.ts +73 -75
  5. package/dist/core/Formats.d.ts +8 -11
  6. package/dist/core/IntlConfig.d.ts +54 -60
  7. package/dist/core/IntlError.d.ts +13 -15
  8. package/dist/core/NumberFormatOptions.d.ts +2 -2
  9. package/dist/core/TimeZone.d.ts +2 -3
  10. package/dist/core/TranslationValues.d.ts +5 -7
  11. package/dist/core/convertFormatsToIntlMessageFormat.d.ts +11 -16
  12. package/dist/core/createBaseTranslator.d.ts +26 -32
  13. package/dist/core/createFormatter.d.ts +19 -21
  14. package/dist/core/createIntl.d.ts +7 -15
  15. package/dist/core/createTranslator.d.ts +48 -57
  16. package/dist/core/createTranslatorImpl.d.ts +14 -25
  17. package/dist/core/defaults.d.ts +11 -14
  18. package/dist/core/index.d.ts +9 -17
  19. package/dist/core/resolveNamespace.d.ts +5 -7
  20. package/dist/core/use-intl.esm.js +33 -0
  21. package/dist/core/use-intl.esm.js.map +1 -0
  22. package/dist/core/use-intl.esm10.js +32 -0
  23. package/dist/core/use-intl.esm10.js.map +1 -0
  24. package/dist/core/use-intl.esm2.js +138 -0
  25. package/dist/core/use-intl.esm2.js.map +1 -0
  26. package/dist/core/use-intl.esm3.js +14 -0
  27. package/dist/core/use-intl.esm3.js.map +1 -0
  28. package/dist/core/use-intl.esm4.js +37 -0
  29. package/dist/core/use-intl.esm4.js.map +1 -0
  30. package/dist/core/use-intl.esm5.js +15 -0
  31. package/dist/core/use-intl.esm5.js.map +1 -0
  32. package/dist/core/use-intl.esm6.js +53 -0
  33. package/dist/core/use-intl.esm6.js.map +1 -0
  34. package/dist/core/use-intl.esm7.js +28 -0
  35. package/dist/core/use-intl.esm7.js.map +1 -0
  36. package/dist/core/use-intl.esm8.js +10 -0
  37. package/dist/core/use-intl.esm8.js.map +1 -0
  38. package/dist/core/use-intl.esm9.js +191 -0
  39. package/dist/core/use-intl.esm9.js.map +1 -0
  40. package/dist/core/utils/MessageKeys.d.ts +5 -7
  41. package/dist/core/utils/NamespaceKeys.d.ts +5 -7
  42. package/dist/core/utils/NestedKeyOf.d.ts +4 -5
  43. package/dist/core/utils/NestedValueOf.d.ts +2 -3
  44. package/dist/core/validateMessages.d.ts +3 -6
  45. package/dist/index.d.ts +2 -25
  46. package/dist/index.js +8 -2
  47. package/dist/react/IntlContext.d.ts +4 -13
  48. package/dist/react/IntlProvider.d.ts +7 -16
  49. package/dist/react/getInitializedConfig.d.ts +13 -24
  50. package/dist/react/index.d.ts +8 -21
  51. package/dist/react/use-intl.esm.js +16 -0
  52. package/dist/react/use-intl.esm.js.map +1 -0
  53. package/dist/react/use-intl.esm10.js +6 -0
  54. package/dist/react/use-intl.esm10.js.map +1 -0
  55. package/dist/react/use-intl.esm11.js +13 -0
  56. package/dist/react/use-intl.esm11.js.map +1 -0
  57. package/dist/react/use-intl.esm12.js +43 -0
  58. package/dist/react/use-intl.esm12.js.map +1 -0
  59. package/dist/react/use-intl.esm2.js +8 -0
  60. package/dist/react/use-intl.esm2.js.map +1 -0
  61. package/dist/react/use-intl.esm3.js +26 -0
  62. package/dist/react/use-intl.esm3.js.map +1 -0
  63. package/dist/react/use-intl.esm4.js +8 -0
  64. package/dist/react/use-intl.esm4.js.map +1 -0
  65. package/dist/react/{useNow.d.mts → use-intl.esm5.js} +42 -21
  66. package/dist/react/use-intl.esm5.js.map +1 -0
  67. package/dist/react/use-intl.esm6.js +24 -0
  68. package/dist/react/use-intl.esm6.js.map +1 -0
  69. package/dist/react/use-intl.esm7.js +30 -0
  70. package/dist/react/use-intl.esm7.js.map +1 -0
  71. package/dist/react/use-intl.esm8.js +8 -0
  72. package/dist/react/use-intl.esm8.js.map +1 -0
  73. package/dist/react/use-intl.esm9.js +29 -0
  74. package/dist/react/use-intl.esm9.js.map +1 -0
  75. package/dist/react/useFormatter.d.ts +6 -12
  76. package/dist/react/useIntl.d.ts +6 -12
  77. package/dist/react/useIntlContext.d.ts +1 -13
  78. package/dist/react/useLocale.d.ts +1 -3
  79. package/dist/react/useMessages.d.ts +1 -5
  80. package/dist/react/useNow.d.ts +23 -24
  81. package/dist/react/useTimeZone.d.ts +1 -5
  82. package/dist/react/useTranslations.d.ts +44 -50
  83. package/dist/react/useTranslationsImpl.d.ts +8 -16
  84. package/dist/src/core/AbstractIntlMessages.d.ts +1 -2
  85. package/dist/src/core/AbstractIntlMessages.js +1 -1
  86. package/dist/src/core/AbstractIntlMessages.js.map +1 -1
  87. package/dist/src/core/DateTimeFormatOptions.d.ts +2 -4
  88. package/dist/src/core/DateTimeFormatOptions.js +2 -1
  89. package/dist/src/core/DateTimeFormatOptions.js.map +1 -1
  90. package/dist/src/core/Formats.d.ts +3 -6
  91. package/dist/src/core/Formats.js +1 -1
  92. package/dist/src/core/Formats.js.map +1 -1
  93. package/dist/src/core/IntlConfig.d.ts +6 -12
  94. package/dist/src/core/IntlConfig.js +1 -1
  95. package/dist/src/core/IntlConfig.js.map +1 -1
  96. package/dist/src/core/IntlError.d.ts +2 -4
  97. package/dist/src/core/IntlError.js +22 -1
  98. package/dist/src/core/IntlError.js.map +1 -1
  99. package/dist/src/core/NumberFormatOptions.d.ts +2 -2
  100. package/dist/src/core/NumberFormatOptions.js +1 -1
  101. package/dist/src/core/NumberFormatOptions.js.map +1 -1
  102. package/dist/src/core/TimeZone.d.ts +1 -2
  103. package/dist/src/core/TimeZone.js +1 -1
  104. package/dist/src/core/TimeZone.js.map +1 -1
  105. package/dist/src/core/TranslationValues.d.ts +3 -5
  106. package/dist/src/core/TranslationValues.js +1 -1
  107. package/dist/src/core/TranslationValues.js.map +1 -1
  108. package/dist/src/core/convertFormatsToIntlMessageFormat.d.ts +4 -9
  109. package/dist/src/core/convertFormatsToIntlMessageFormat.js +30 -1
  110. package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +1 -1
  111. package/dist/src/core/createBaseTranslator.d.ts +11 -17
  112. package/dist/src/core/createBaseTranslator.js +205 -1
  113. package/dist/src/core/createBaseTranslator.js.map +1 -1
  114. package/dist/src/core/createFormatter.d.ts +7 -9
  115. package/dist/src/core/createFormatter.js +128 -1
  116. package/dist/src/core/createFormatter.js.map +1 -1
  117. package/dist/src/core/createIntl.d.ts +4 -12
  118. package/dist/src/core/createIntl.js +10 -1
  119. package/dist/src/core/createIntl.js.map +1 -1
  120. package/dist/src/core/createTranslator.d.ts +9 -18
  121. package/dist/src/core/createTranslator.js +23 -1
  122. package/dist/src/core/createTranslator.js.map +1 -1
  123. package/dist/src/core/createTranslatorImpl.d.ts +9 -20
  124. package/dist/src/core/createTranslatorImpl.js +42 -1
  125. package/dist/src/core/createTranslatorImpl.js.map +1 -1
  126. package/dist/src/core/defaults.d.ts +3 -6
  127. package/dist/src/core/defaults.js +10 -1
  128. package/dist/src/core/defaults.js.map +1 -1
  129. package/dist/src/core/index.d.ts +9 -17
  130. package/dist/src/core/index.js +5 -1
  131. package/dist/src/core/index.js.map +1 -1
  132. package/dist/src/core/resolveNamespace.d.ts +1 -3
  133. package/dist/src/core/resolveNamespace.js +9 -1
  134. package/dist/src/core/resolveNamespace.js.map +1 -1
  135. package/dist/src/core/utils/MessageKeys.d.ts +2 -4
  136. package/dist/src/core/utils/MessageKeys.js +1 -1
  137. package/dist/src/core/utils/MessageKeys.js.map +1 -1
  138. package/dist/src/core/utils/NamespaceKeys.d.ts +2 -4
  139. package/dist/src/core/utils/NamespaceKeys.js +1 -1
  140. package/dist/src/core/utils/NamespaceKeys.js.map +1 -1
  141. package/dist/src/core/utils/NestedKeyOf.d.ts +1 -2
  142. package/dist/src/core/utils/NestedKeyOf.js +1 -1
  143. package/dist/src/core/utils/NestedKeyOf.js.map +1 -1
  144. package/dist/src/core/utils/NestedValueOf.d.ts +1 -2
  145. package/dist/src/core/utils/NestedValueOf.js +1 -1
  146. package/dist/src/core/utils/NestedValueOf.js.map +1 -1
  147. package/dist/src/core/validateMessages.d.ts +3 -6
  148. package/dist/src/core/validateMessages.js +25 -3
  149. package/dist/src/core/validateMessages.js.map +1 -1
  150. package/dist/src/index.d.ts +2 -25
  151. package/dist/src/index.js +2 -1
  152. package/dist/src/index.js.map +1 -1
  153. package/dist/src/react/IntlContext.d.ts +4 -13
  154. package/dist/src/react/IntlContext.js +3 -1
  155. package/dist/src/react/IntlContext.js.map +1 -1
  156. package/dist/src/react/IntlProvider.d.ts +3 -12
  157. package/dist/src/react/IntlProvider.js +6 -1
  158. package/dist/src/react/IntlProvider.js.map +1 -1
  159. package/dist/src/react/getInitializedConfig.d.ts +5 -16
  160. package/dist/src/react/getInitializedConfig.js +20 -1
  161. package/dist/src/react/getInitializedConfig.js.map +1 -1
  162. package/dist/src/react/index.d.ts +8 -21
  163. package/dist/src/react/index.js +9 -1
  164. package/dist/src/react/index.js.map +1 -1
  165. package/dist/src/react/useFormatter.d.ts +3 -9
  166. package/dist/src/react/useFormatter.js +13 -1
  167. package/dist/src/react/useFormatter.js.map +1 -1
  168. package/dist/src/react/useIntl.d.ts +3 -9
  169. package/dist/src/react/useIntl.js +19 -1
  170. package/dist/src/react/useIntl.js.map +1 -1
  171. package/dist/src/react/useIntlContext.d.ts +1 -13
  172. package/dist/src/react/useIntlContext.js +11 -1
  173. package/dist/src/react/useIntlContext.js.map +1 -1
  174. package/dist/src/react/useLocale.d.ts +1 -3
  175. package/dist/src/react/useLocale.js +4 -1
  176. package/dist/src/react/useLocale.js.map +1 -1
  177. package/dist/src/react/useMessages.d.ts +1 -5
  178. package/dist/src/react/useMessages.js +4 -1
  179. package/dist/src/react/useMessages.js.map +1 -1
  180. package/dist/src/react/useNow.d.ts +2 -3
  181. package/dist/src/react/useNow.js +39 -1
  182. package/dist/src/react/useNow.js.map +1 -1
  183. package/dist/src/react/useTimeZone.d.ts +1 -5
  184. package/dist/src/react/useTimeZone.js +4 -1
  185. package/dist/src/react/useTimeZone.js.map +1 -1
  186. package/dist/src/react/useTranslations.d.ts +7 -13
  187. package/dist/src/react/useTranslations.js +20 -1
  188. package/dist/src/react/useTranslations.js.map +1 -1
  189. package/dist/src/react/useTranslationsImpl.d.ts +6 -14
  190. package/dist/src/react/useTranslationsImpl.js +34 -1
  191. package/dist/src/react/useTranslationsImpl.js.map +1 -1
  192. package/dist/use-intl.cjs.development.js +821 -0
  193. package/dist/use-intl.cjs.development.js.map +1 -0
  194. package/dist/use-intl.cjs.production.min.js +2 -0
  195. package/dist/use-intl.cjs.production.min.js.map +1 -0
  196. package/dist/use-intl.esm.js +13 -0
  197. package/dist/use-intl.esm.js.map +1 -0
  198. package/package.json +20 -5
  199. package/dist/core/AbstractIntlMessages.d.mts +0 -10
  200. package/dist/core/AbstractIntlMessages.js +0 -2
  201. package/dist/core/AbstractIntlMessages.js.map +0 -1
  202. package/dist/core/AbstractIntlMessages.mjs +0 -1
  203. package/dist/core/AbstractIntlMessages.mjs.map +0 -1
  204. package/dist/core/DateTimeFormatOptions.d.mts +0 -75
  205. package/dist/core/DateTimeFormatOptions.js +0 -2
  206. package/dist/core/DateTimeFormatOptions.js.map +0 -1
  207. package/dist/core/DateTimeFormatOptions.mjs +0 -1
  208. package/dist/core/DateTimeFormatOptions.mjs.map +0 -1
  209. package/dist/core/Formats.d.mts +0 -11
  210. package/dist/core/Formats.js +0 -2
  211. package/dist/core/Formats.js.map +0 -1
  212. package/dist/core/Formats.mjs +0 -1
  213. package/dist/core/Formats.mjs.map +0 -1
  214. package/dist/core/IntlConfig.d.mts +0 -60
  215. package/dist/core/IntlConfig.js +0 -2
  216. package/dist/core/IntlConfig.js.map +0 -1
  217. package/dist/core/IntlConfig.mjs +0 -1
  218. package/dist/core/IntlConfig.mjs.map +0 -1
  219. package/dist/core/IntlError.d.mts +0 -15
  220. package/dist/core/IntlError.js +0 -2
  221. package/dist/core/IntlError.js.map +0 -1
  222. package/dist/core/IntlError.mjs +0 -2
  223. package/dist/core/IntlError.mjs.map +0 -1
  224. package/dist/core/NumberFormatOptions.d.mts +0 -2
  225. package/dist/core/NumberFormatOptions.js +0 -2
  226. package/dist/core/NumberFormatOptions.js.map +0 -1
  227. package/dist/core/NumberFormatOptions.mjs +0 -2
  228. package/dist/core/NumberFormatOptions.mjs.map +0 -1
  229. package/dist/core/TimeZone.d.mts +0 -3
  230. package/dist/core/TimeZone.js +0 -2
  231. package/dist/core/TimeZone.js.map +0 -1
  232. package/dist/core/TimeZone.mjs +0 -1
  233. package/dist/core/TimeZone.mjs.map +0 -1
  234. package/dist/core/TranslationValues.d.mts +0 -7
  235. package/dist/core/TranslationValues.js +0 -2
  236. package/dist/core/TranslationValues.js.map +0 -1
  237. package/dist/core/TranslationValues.mjs +0 -1
  238. package/dist/core/TranslationValues.mjs.map +0 -1
  239. package/dist/core/convertFormatsToIntlMessageFormat.d.mts +0 -16
  240. package/dist/core/convertFormatsToIntlMessageFormat.js +0 -2
  241. package/dist/core/convertFormatsToIntlMessageFormat.js.map +0 -1
  242. package/dist/core/convertFormatsToIntlMessageFormat.mjs +0 -2
  243. package/dist/core/convertFormatsToIntlMessageFormat.mjs.map +0 -1
  244. package/dist/core/createBaseTranslator.d.mts +0 -32
  245. package/dist/core/createBaseTranslator.js +0 -2
  246. package/dist/core/createBaseTranslator.js.map +0 -1
  247. package/dist/core/createBaseTranslator.mjs +0 -2
  248. package/dist/core/createBaseTranslator.mjs.map +0 -1
  249. package/dist/core/createFormatter.d.mts +0 -21
  250. package/dist/core/createFormatter.js +0 -2
  251. package/dist/core/createFormatter.js.map +0 -1
  252. package/dist/core/createFormatter.mjs +0 -2
  253. package/dist/core/createFormatter.mjs.map +0 -1
  254. package/dist/core/createIntl.d.mts +0 -15
  255. package/dist/core/createIntl.js +0 -2
  256. package/dist/core/createIntl.js.map +0 -1
  257. package/dist/core/createIntl.mjs +0 -2
  258. package/dist/core/createIntl.mjs.map +0 -1
  259. package/dist/core/createTranslator.d.mts +0 -57
  260. package/dist/core/createTranslator.js +0 -2
  261. package/dist/core/createTranslator.js.map +0 -1
  262. package/dist/core/createTranslator.mjs +0 -2
  263. package/dist/core/createTranslator.mjs.map +0 -1
  264. package/dist/core/createTranslatorImpl.d.mts +0 -25
  265. package/dist/core/createTranslatorImpl.js +0 -2
  266. package/dist/core/createTranslatorImpl.js.map +0 -1
  267. package/dist/core/createTranslatorImpl.mjs +0 -2
  268. package/dist/core/createTranslatorImpl.mjs.map +0 -1
  269. package/dist/core/defaults.d.mts +0 -14
  270. package/dist/core/defaults.js +0 -2
  271. package/dist/core/defaults.js.map +0 -1
  272. package/dist/core/defaults.mjs +0 -2
  273. package/dist/core/defaults.mjs.map +0 -1
  274. package/dist/core/index.d.mts +0 -17
  275. package/dist/core/index.js +0 -2
  276. package/dist/core/index.js.map +0 -1
  277. package/dist/core/index.mjs +0 -2
  278. package/dist/core/index.mjs.map +0 -1
  279. package/dist/core/resolveNamespace.d.mts +0 -7
  280. package/dist/core/resolveNamespace.js +0 -2
  281. package/dist/core/resolveNamespace.js.map +0 -1
  282. package/dist/core/resolveNamespace.mjs +0 -2
  283. package/dist/core/resolveNamespace.mjs.map +0 -1
  284. package/dist/core/utils/MessageKeys.d.mts +0 -7
  285. package/dist/core/utils/MessageKeys.js +0 -2
  286. package/dist/core/utils/MessageKeys.js.map +0 -1
  287. package/dist/core/utils/MessageKeys.mjs +0 -1
  288. package/dist/core/utils/MessageKeys.mjs.map +0 -1
  289. package/dist/core/utils/NamespaceKeys.d.mts +0 -7
  290. package/dist/core/utils/NamespaceKeys.js +0 -2
  291. package/dist/core/utils/NamespaceKeys.js.map +0 -1
  292. package/dist/core/utils/NamespaceKeys.mjs +0 -1
  293. package/dist/core/utils/NamespaceKeys.mjs.map +0 -1
  294. package/dist/core/utils/NestedKeyOf.d.mts +0 -5
  295. package/dist/core/utils/NestedKeyOf.js +0 -2
  296. package/dist/core/utils/NestedKeyOf.js.map +0 -1
  297. package/dist/core/utils/NestedKeyOf.mjs +0 -1
  298. package/dist/core/utils/NestedKeyOf.mjs.map +0 -1
  299. package/dist/core/utils/NestedValueOf.d.mts +0 -3
  300. package/dist/core/utils/NestedValueOf.js +0 -2
  301. package/dist/core/utils/NestedValueOf.js.map +0 -1
  302. package/dist/core/utils/NestedValueOf.mjs +0 -1
  303. package/dist/core/utils/NestedValueOf.mjs.map +0 -1
  304. package/dist/core/validateMessages.d.mts +0 -6
  305. package/dist/core/validateMessages.js +0 -34
  306. package/dist/core/validateMessages.js.map +0 -1
  307. package/dist/core/validateMessages.mjs +0 -34
  308. package/dist/core/validateMessages.mjs.map +0 -1
  309. package/dist/index.d.mts +0 -25
  310. package/dist/index.js.map +0 -1
  311. package/dist/index.mjs +0 -2
  312. package/dist/index.mjs.map +0 -1
  313. package/dist/react/IntlContext.d.mts +0 -13
  314. package/dist/react/IntlContext.js +0 -2
  315. package/dist/react/IntlContext.js.map +0 -1
  316. package/dist/react/IntlContext.mjs +0 -2
  317. package/dist/react/IntlContext.mjs.map +0 -1
  318. package/dist/react/IntlProvider.d.mts +0 -16
  319. package/dist/react/IntlProvider.js +0 -2
  320. package/dist/react/IntlProvider.js.map +0 -1
  321. package/dist/react/IntlProvider.mjs +0 -2
  322. package/dist/react/IntlProvider.mjs.map +0 -1
  323. package/dist/react/getInitializedConfig.d.mts +0 -24
  324. package/dist/react/getInitializedConfig.js +0 -2
  325. package/dist/react/getInitializedConfig.js.map +0 -1
  326. package/dist/react/getInitializedConfig.mjs +0 -2
  327. package/dist/react/getInitializedConfig.mjs.map +0 -1
  328. package/dist/react/index.d.mts +0 -21
  329. package/dist/react/index.js +0 -2
  330. package/dist/react/index.js.map +0 -1
  331. package/dist/react/index.mjs +0 -2
  332. package/dist/react/index.mjs.map +0 -1
  333. package/dist/react/useFormatter.d.mts +0 -12
  334. package/dist/react/useFormatter.js +0 -2
  335. package/dist/react/useFormatter.js.map +0 -1
  336. package/dist/react/useFormatter.mjs +0 -2
  337. package/dist/react/useFormatter.mjs.map +0 -1
  338. package/dist/react/useIntl.d.mts +0 -12
  339. package/dist/react/useIntl.js +0 -2
  340. package/dist/react/useIntl.js.map +0 -1
  341. package/dist/react/useIntl.mjs +0 -2
  342. package/dist/react/useIntl.mjs.map +0 -1
  343. package/dist/react/useIntlContext.d.mts +0 -13
  344. package/dist/react/useIntlContext.js +0 -2
  345. package/dist/react/useIntlContext.js.map +0 -1
  346. package/dist/react/useIntlContext.mjs +0 -2
  347. package/dist/react/useIntlContext.mjs.map +0 -1
  348. package/dist/react/useLocale.d.mts +0 -3
  349. package/dist/react/useLocale.js +0 -2
  350. package/dist/react/useLocale.js.map +0 -1
  351. package/dist/react/useLocale.mjs +0 -2
  352. package/dist/react/useLocale.mjs.map +0 -1
  353. package/dist/react/useMessages.d.mts +0 -5
  354. package/dist/react/useMessages.js +0 -2
  355. package/dist/react/useMessages.js.map +0 -1
  356. package/dist/react/useMessages.mjs +0 -2
  357. package/dist/react/useMessages.mjs.map +0 -1
  358. package/dist/react/useNow.js +0 -2
  359. package/dist/react/useNow.js.map +0 -1
  360. package/dist/react/useNow.mjs +0 -2
  361. package/dist/react/useNow.mjs.map +0 -1
  362. package/dist/react/useTimeZone.d.mts +0 -5
  363. package/dist/react/useTimeZone.js +0 -2
  364. package/dist/react/useTimeZone.js.map +0 -1
  365. package/dist/react/useTimeZone.mjs +0 -2
  366. package/dist/react/useTimeZone.mjs.map +0 -1
  367. package/dist/react/useTranslations.d.mts +0 -50
  368. package/dist/react/useTranslations.js +0 -2
  369. package/dist/react/useTranslations.js.map +0 -1
  370. package/dist/react/useTranslations.mjs +0 -2
  371. package/dist/react/useTranslations.mjs.map +0 -1
  372. package/dist/react/useTranslationsImpl.d.mts +0 -16
  373. package/dist/react/useTranslationsImpl.js +0 -2
  374. package/dist/react/useTranslationsImpl.js.map +0 -1
  375. package/dist/react/useTranslationsImpl.mjs +0 -2
  376. package/dist/react/useTranslationsImpl.mjs.map +0 -1
  377. package/dist/src/core/AbstractIntlMessages.d.mts +0 -10
  378. package/dist/src/core/AbstractIntlMessages.mjs +0 -1
  379. package/dist/src/core/AbstractIntlMessages.mjs.map +0 -1
  380. package/dist/src/core/DateTimeFormatOptions.d.mts +0 -75
  381. package/dist/src/core/DateTimeFormatOptions.mjs +0 -1
  382. package/dist/src/core/DateTimeFormatOptions.mjs.map +0 -1
  383. package/dist/src/core/Formats.d.mts +0 -11
  384. package/dist/src/core/Formats.mjs +0 -1
  385. package/dist/src/core/Formats.mjs.map +0 -1
  386. package/dist/src/core/IntlConfig.d.mts +0 -60
  387. package/dist/src/core/IntlConfig.mjs +0 -1
  388. package/dist/src/core/IntlConfig.mjs.map +0 -1
  389. package/dist/src/core/IntlError.d.mts +0 -15
  390. package/dist/src/core/IntlError.mjs +0 -2
  391. package/dist/src/core/IntlError.mjs.map +0 -1
  392. package/dist/src/core/NumberFormatOptions.d.mts +0 -2
  393. package/dist/src/core/NumberFormatOptions.mjs +0 -2
  394. package/dist/src/core/NumberFormatOptions.mjs.map +0 -1
  395. package/dist/src/core/TimeZone.d.mts +0 -3
  396. package/dist/src/core/TimeZone.mjs +0 -1
  397. package/dist/src/core/TimeZone.mjs.map +0 -1
  398. package/dist/src/core/TranslationValues.d.mts +0 -7
  399. package/dist/src/core/TranslationValues.mjs +0 -1
  400. package/dist/src/core/TranslationValues.mjs.map +0 -1
  401. package/dist/src/core/convertFormatsToIntlMessageFormat.d.mts +0 -16
  402. package/dist/src/core/convertFormatsToIntlMessageFormat.mjs +0 -2
  403. package/dist/src/core/convertFormatsToIntlMessageFormat.mjs.map +0 -1
  404. package/dist/src/core/createBaseTranslator.d.mts +0 -32
  405. package/dist/src/core/createBaseTranslator.mjs +0 -2
  406. package/dist/src/core/createBaseTranslator.mjs.map +0 -1
  407. package/dist/src/core/createFormatter.d.mts +0 -21
  408. package/dist/src/core/createFormatter.mjs +0 -2
  409. package/dist/src/core/createFormatter.mjs.map +0 -1
  410. package/dist/src/core/createIntl.d.mts +0 -15
  411. package/dist/src/core/createIntl.mjs +0 -2
  412. package/dist/src/core/createIntl.mjs.map +0 -1
  413. package/dist/src/core/createTranslator.d.mts +0 -57
  414. package/dist/src/core/createTranslator.mjs +0 -2
  415. package/dist/src/core/createTranslator.mjs.map +0 -1
  416. package/dist/src/core/createTranslatorImpl.d.mts +0 -25
  417. package/dist/src/core/createTranslatorImpl.mjs +0 -2
  418. package/dist/src/core/createTranslatorImpl.mjs.map +0 -1
  419. package/dist/src/core/defaults.d.mts +0 -14
  420. package/dist/src/core/defaults.mjs +0 -2
  421. package/dist/src/core/defaults.mjs.map +0 -1
  422. package/dist/src/core/index.d.mts +0 -17
  423. package/dist/src/core/index.mjs +0 -2
  424. package/dist/src/core/index.mjs.map +0 -1
  425. package/dist/src/core/resolveNamespace.d.mts +0 -7
  426. package/dist/src/core/resolveNamespace.mjs +0 -2
  427. package/dist/src/core/resolveNamespace.mjs.map +0 -1
  428. package/dist/src/core/utils/MessageKeys.d.mts +0 -7
  429. package/dist/src/core/utils/MessageKeys.mjs +0 -1
  430. package/dist/src/core/utils/MessageKeys.mjs.map +0 -1
  431. package/dist/src/core/utils/NamespaceKeys.d.mts +0 -7
  432. package/dist/src/core/utils/NamespaceKeys.mjs +0 -1
  433. package/dist/src/core/utils/NamespaceKeys.mjs.map +0 -1
  434. package/dist/src/core/utils/NestedKeyOf.d.mts +0 -5
  435. package/dist/src/core/utils/NestedKeyOf.mjs +0 -1
  436. package/dist/src/core/utils/NestedKeyOf.mjs.map +0 -1
  437. package/dist/src/core/utils/NestedValueOf.d.mts +0 -3
  438. package/dist/src/core/utils/NestedValueOf.mjs +0 -1
  439. package/dist/src/core/utils/NestedValueOf.mjs.map +0 -1
  440. package/dist/src/core/validateMessages.d.mts +0 -6
  441. package/dist/src/core/validateMessages.mjs +0 -34
  442. package/dist/src/core/validateMessages.mjs.map +0 -1
  443. package/dist/src/index.d.mts +0 -25
  444. package/dist/src/index.mjs +0 -2
  445. package/dist/src/index.mjs.map +0 -1
  446. package/dist/src/react/IntlContext.d.mts +0 -13
  447. package/dist/src/react/IntlContext.mjs +0 -2
  448. package/dist/src/react/IntlContext.mjs.map +0 -1
  449. package/dist/src/react/IntlProvider.d.mts +0 -16
  450. package/dist/src/react/IntlProvider.mjs +0 -2
  451. package/dist/src/react/IntlProvider.mjs.map +0 -1
  452. package/dist/src/react/getInitializedConfig.d.mts +0 -24
  453. package/dist/src/react/getInitializedConfig.mjs +0 -2
  454. package/dist/src/react/getInitializedConfig.mjs.map +0 -1
  455. package/dist/src/react/index.d.mts +0 -21
  456. package/dist/src/react/index.mjs +0 -2
  457. package/dist/src/react/index.mjs.map +0 -1
  458. package/dist/src/react/useFormatter.d.mts +0 -12
  459. package/dist/src/react/useFormatter.mjs +0 -2
  460. package/dist/src/react/useFormatter.mjs.map +0 -1
  461. package/dist/src/react/useIntl.d.mts +0 -12
  462. package/dist/src/react/useIntl.mjs +0 -2
  463. package/dist/src/react/useIntl.mjs.map +0 -1
  464. package/dist/src/react/useIntlContext.d.mts +0 -13
  465. package/dist/src/react/useIntlContext.mjs +0 -2
  466. package/dist/src/react/useIntlContext.mjs.map +0 -1
  467. package/dist/src/react/useLocale.d.mts +0 -3
  468. package/dist/src/react/useLocale.mjs +0 -2
  469. package/dist/src/react/useLocale.mjs.map +0 -1
  470. package/dist/src/react/useMessages.d.mts +0 -5
  471. package/dist/src/react/useMessages.mjs +0 -2
  472. package/dist/src/react/useMessages.mjs.map +0 -1
  473. package/dist/src/react/useNow.d.mts +0 -24
  474. package/dist/src/react/useNow.mjs +0 -2
  475. package/dist/src/react/useNow.mjs.map +0 -1
  476. package/dist/src/react/useTimeZone.d.mts +0 -5
  477. package/dist/src/react/useTimeZone.mjs +0 -2
  478. package/dist/src/react/useTimeZone.mjs.map +0 -1
  479. package/dist/src/react/useTranslations.d.mts +0 -50
  480. package/dist/src/react/useTranslations.mjs +0 -2
  481. package/dist/src/react/useTranslations.mjs.map +0 -1
  482. package/dist/src/react/useTranslationsImpl.d.mts +0 -16
  483. package/dist/src/react/useTranslationsImpl.mjs +0 -2
  484. package/dist/src/react/useTranslationsImpl.mjs.map +0 -1
@@ -1,2 +1,206 @@
1
- "use strict";var b=Object.create;var M=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var F=(r,e)=>{for(var s in e)M(r,s,{get:e[s],enumerable:!0})},R=(r,e,s,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of D(e))!K.call(r,t)&&t!==s&&M(r,t,{get:()=>e[t],enumerable:!(a=x(e,t))||a.enumerable});return r};var v=(r,e,s)=>(s=r!=null?b(G(r)):{},R(e||!r||!r.__esModule?M(s,"default",{value:r,enumerable:!0}):s,r)),C=r=>R(M({},"__esModule",{value:!0}),r);var U={};F(U,{default:()=>_,getMessagesOrError:()=>j});module.exports=C(U);var w=v(require("intl-messageformat")),p=require("react"),f=v(require("./IntlError")),O=v(require("./convertFormatsToIntlMessageFormat")),V=require("./defaults");function T(r,e,s){if(!r)throw new Error(process.env.NODE_ENV!=="production"?`No messages available at \`${s}\`.`:void 0);let a=r;return e.split(".").forEach(t=>{const u=a[t];if(t==null||u==null)throw new Error(process.env.NODE_ENV!=="production"?`Could not resolve \`${e}\` in ${s?`\`${s}\``:"messages"}.`:void 0);a=u}),a}function P(r){if(Object.keys(r).length===0)return;const e={};return Object.keys(r).forEach(s=>{let a=0;const t=r[s];let u;typeof t=="function"?u=i=>{const E=t(i);return(0,p.isValidElement)(E)?(0,p.cloneElement)(E,{key:s+a++}):E}:u=t,e[s]=u}),e}function j({messages:r,namespace:e,onError:s=V.defaultOnError}){try{if(!r)throw new Error(process.env.NODE_ENV!=="production"?"No messages were configured on the provider.":void 0);const a=e?T(r,e):r;if(!a)throw new Error(process.env.NODE_ENV!=="production"?`No messages for namespace \`${e}\` found.`:void 0);return a}catch(a){const t=new f.default(f.IntlErrorCode.MISSING_MESSAGE,a.message);return s(t),t}}function _({cachedFormatsByLocale:r,defaultTranslationValues:e,formats:s,getMessageFallback:a=V.defaultGetMessageFallback,locale:t,messagesOrError:u,namespace:i,onError:E,timeZone:$}){function c(n,l,d){const g=new f.default(l,d);return E(g),a({error:g,key:n,namespace:i})}function y(n,l,d){if(u instanceof f.default)return a({error:u,key:n,namespace:i});const g=u;let m;try{m=T(g,n,i)}catch(o){return c(n,f.IntlErrorCode.MISSING_MESSAGE,o.message)}function A(o){return o.filter(N=>N!=null).join(".")}const S=A([i,n,String(m)]);let I;if(r?.[t]?.[S])I=r?.[t][S];else{if(typeof m=="object"){let o,N;return Array.isArray(m)?(o=f.IntlErrorCode.INVALID_MESSAGE,process.env.NODE_ENV!=="production"&&(N=`Message at \`${A([i,n])}\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`)):(o=f.IntlErrorCode.INSUFFICIENT_PATH,process.env.NODE_ENV!=="production"&&(N=`Message at \`${A([i,n])}\` resolved to an object, but only strings are supported. Use a \`.\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`)),c(n,o,N)}try{I=new w.default(m,t,(0,O.default)({...s,...d},$))}catch(o){return c(n,f.IntlErrorCode.INVALID_MESSAGE,o.message)}r&&(r[t]||(r[t]={}),r[t][S]=I)}try{const o=I.format(P({...e,...l}));if(o==null)throw new Error(process.env.NODE_ENV!=="production"?`Unable to format \`${n}\` in ${i?`namespace \`${i}\``:"messages"}`:void 0);return(0,p.isValidElement)(o)||Array.isArray(o)||typeof o=="string"?o:String(o)}catch(o){return c(n,f.IntlErrorCode.FORMATTING_ERROR,o.message)}}function h(n,l,d){const g=y(n,l,d);return typeof g!="string"?c(n,f.IntlErrorCode.INVALID_MESSAGE,process.env.NODE_ENV!=="production"?`The message \`${n}\` in ${i?`namespace \`${i}\``:"messages"} didn't resolve to a string. If you want to format rich text, use \`t.rich\` instead.`:void 0):g}return h.rich=y,h.raw=n=>{if(u instanceof f.default)return a({error:u,key:n,namespace:i});const l=u;try{return T(l,n,i)}catch(d){return c(n,f.IntlErrorCode.MISSING_MESSAGE,d.message)}},h}0&&(module.exports={getMessagesOrError});
1
+ // eslint-disable-next-line import/no-named-as-default -- False positive
2
+ import IntlMessageFormat from 'intl-messageformat';
3
+ import { cloneElement, isValidElement } from 'react';
4
+ import IntlError, { IntlErrorCode } from './IntlError';
5
+ import convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';
6
+ import { defaultGetMessageFallback, defaultOnError } from './defaults';
7
+ function resolvePath(messages, key, namespace) {
8
+ if (!messages) {
9
+ throw new Error(process.env.NODE_ENV !== 'production'
10
+ ? `No messages available at \`${namespace}\`.`
11
+ : undefined);
12
+ }
13
+ let message = messages;
14
+ key.split('.').forEach((part) => {
15
+ const next = message[part];
16
+ if (part == null || next == null) {
17
+ throw new Error(process.env.NODE_ENV !== 'production'
18
+ ? `Could not resolve \`${key}\` in ${namespace ? `\`${namespace}\`` : 'messages'}.`
19
+ : undefined);
20
+ }
21
+ message = next;
22
+ });
23
+ return message;
24
+ }
25
+ function prepareTranslationValues(values) {
26
+ if (Object.keys(values).length === 0)
27
+ return undefined;
28
+ // Workaround for https://github.com/formatjs/formatjs/issues/1467
29
+ const transformedValues = {};
30
+ Object.keys(values).forEach((key) => {
31
+ let index = 0;
32
+ const value = values[key];
33
+ let transformed;
34
+ if (typeof value === 'function') {
35
+ transformed = (chunks) => {
36
+ const result = value(chunks);
37
+ return isValidElement(result)
38
+ ? cloneElement(result, { key: key + index++ })
39
+ : result;
40
+ };
41
+ }
42
+ else {
43
+ transformed = value;
44
+ }
45
+ transformedValues[key] = transformed;
46
+ });
47
+ return transformedValues;
48
+ }
49
+ export function getMessagesOrError({ messages, namespace, onError = defaultOnError }) {
50
+ try {
51
+ if (!messages) {
52
+ throw new Error(process.env.NODE_ENV !== 'production'
53
+ ? `No messages were configured on the provider.`
54
+ : undefined);
55
+ }
56
+ const retrievedMessages = namespace
57
+ ? resolvePath(messages, namespace)
58
+ : messages;
59
+ if (!retrievedMessages) {
60
+ throw new Error(process.env.NODE_ENV !== 'production'
61
+ ? `No messages for namespace \`${namespace}\` found.`
62
+ : undefined);
63
+ }
64
+ return retrievedMessages;
65
+ }
66
+ catch (error) {
67
+ const intlError = new IntlError(IntlErrorCode.MISSING_MESSAGE, error.message);
68
+ onError(intlError);
69
+ return intlError;
70
+ }
71
+ }
72
+ export default function createBaseTranslator({ cachedFormatsByLocale, defaultTranslationValues, formats: globalFormats, getMessageFallback = defaultGetMessageFallback, locale, messagesOrError, namespace, onError, timeZone }) {
73
+ function getFallbackFromErrorAndNotify(key, code, message) {
74
+ const error = new IntlError(code, message);
75
+ onError(error);
76
+ return getMessageFallback({ error, key, namespace });
77
+ }
78
+ function translateBaseFn(
79
+ /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
80
+ key,
81
+ /** Key value pairs for values to interpolate into the message. */
82
+ values,
83
+ /** Provide custom formats for numbers, dates and times. */
84
+ formats) {
85
+ if (messagesOrError instanceof IntlError) {
86
+ // We have already warned about this during render
87
+ return getMessageFallback({
88
+ error: messagesOrError,
89
+ key,
90
+ namespace
91
+ });
92
+ }
93
+ const messages = messagesOrError;
94
+ let message;
95
+ try {
96
+ message = resolvePath(messages, key, namespace);
97
+ }
98
+ catch (error) {
99
+ return getFallbackFromErrorAndNotify(key, IntlErrorCode.MISSING_MESSAGE, error.message);
100
+ }
101
+ function joinPath(parts) {
102
+ return parts.filter((part) => part != null).join('.');
103
+ }
104
+ const cacheKey = joinPath([namespace, key, String(message)]);
105
+ let messageFormat;
106
+ if (cachedFormatsByLocale?.[locale]?.[cacheKey]) {
107
+ messageFormat = cachedFormatsByLocale?.[locale][cacheKey];
108
+ }
109
+ else {
110
+ if (typeof message === 'object') {
111
+ let code, errorMessage;
112
+ if (Array.isArray(message)) {
113
+ code = IntlErrorCode.INVALID_MESSAGE;
114
+ if (process.env.NODE_ENV !== 'production') {
115
+ errorMessage = `Message at \`${joinPath([
116
+ namespace,
117
+ key
118
+ ])}\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`;
119
+ }
120
+ }
121
+ else {
122
+ code = IntlErrorCode.INSUFFICIENT_PATH;
123
+ if (process.env.NODE_ENV !== 'production') {
124
+ errorMessage = `Message at \`${joinPath([
125
+ namespace,
126
+ key
127
+ ])}\` resolved to an object, but only strings are supported. Use a \`.\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`;
128
+ }
129
+ }
130
+ return getFallbackFromErrorAndNotify(key, code, errorMessage);
131
+ }
132
+ try {
133
+ messageFormat = new IntlMessageFormat(message, locale, convertFormatsToIntlMessageFormat({ ...globalFormats, ...formats }, timeZone));
134
+ }
135
+ catch (error) {
136
+ return getFallbackFromErrorAndNotify(key, IntlErrorCode.INVALID_MESSAGE, error.message);
137
+ }
138
+ if (cachedFormatsByLocale) {
139
+ if (!cachedFormatsByLocale[locale]) {
140
+ cachedFormatsByLocale[locale] = {};
141
+ }
142
+ cachedFormatsByLocale[locale][cacheKey] = messageFormat;
143
+ }
144
+ }
145
+ try {
146
+ const formattedMessage = messageFormat.format(
147
+ // @ts-ignore `intl-messageformat` expects a different format
148
+ // for rich text elements since a recent minor update. This
149
+ // needs to be evaluated in detail, possibly also in regards
150
+ // to be able to format to parts.
151
+ prepareTranslationValues({ ...defaultTranslationValues, ...values }));
152
+ if (formattedMessage == null) {
153
+ throw new Error(process.env.NODE_ENV !== 'production'
154
+ ? `Unable to format \`${key}\` in ${namespace ? `namespace \`${namespace}\`` : 'messages'}`
155
+ : undefined);
156
+ }
157
+ // Limit the function signature to return strings or React elements
158
+ return isValidElement(formattedMessage) ||
159
+ // Arrays of React elements
160
+ Array.isArray(formattedMessage) ||
161
+ typeof formattedMessage === 'string'
162
+ ? formattedMessage
163
+ : String(formattedMessage);
164
+ }
165
+ catch (error) {
166
+ return getFallbackFromErrorAndNotify(key, IntlErrorCode.FORMATTING_ERROR, error.message);
167
+ }
168
+ }
169
+ function translateFn(
170
+ /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
171
+ key,
172
+ /** Key value pairs for values to interpolate into the message. */
173
+ values,
174
+ /** Provide custom formats for numbers, dates and times. */
175
+ formats) {
176
+ const result = translateBaseFn(key, values, formats);
177
+ if (typeof result !== 'string') {
178
+ return getFallbackFromErrorAndNotify(key, IntlErrorCode.INVALID_MESSAGE, process.env.NODE_ENV !== 'production'
179
+ ? `The message \`${key}\` in ${namespace ? `namespace \`${namespace}\`` : 'messages'} didn't resolve to a string. If you want to format rich text, use \`t.rich\` instead.`
180
+ : undefined);
181
+ }
182
+ return result;
183
+ }
184
+ translateFn.rich = translateBaseFn;
185
+ translateFn.raw = (
186
+ /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
187
+ key) => {
188
+ if (messagesOrError instanceof IntlError) {
189
+ // We have already warned about this during render
190
+ return getMessageFallback({
191
+ error: messagesOrError,
192
+ key,
193
+ namespace
194
+ });
195
+ }
196
+ const messages = messagesOrError;
197
+ try {
198
+ return resolvePath(messages, key, namespace);
199
+ }
200
+ catch (error) {
201
+ return getFallbackFromErrorAndNotify(key, IntlErrorCode.MISSING_MESSAGE, error.message);
202
+ }
203
+ };
204
+ return translateFn;
205
+ }
2
206
  //# sourceMappingURL=createBaseTranslator.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/createBaseTranslator.tsx"],"sourcesContent":["// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray\n} from 'react';\nimport AbstractIntlMessages from './AbstractIntlMessages';\nimport Formats from './Formats';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: AbstractIntlMessages | undefined,\n key: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages available at \\`${namespace}\\`.`\n : undefined\n );\n }\n\n let message = messages;\n\n key.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Could not resolve \\`${key}\\` in ${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }.`\n : undefined\n );\n }\n\n message = next;\n });\n\n return message;\n}\n\nfunction prepareTranslationValues(values: RichTranslationValues) {\n if (Object.keys(values).length === 0) return undefined;\n\n // Workaround for https://github.com/formatjs/formatjs/issues/1467\n const transformedValues: RichTranslationValues = {};\n Object.keys(values).forEach((key) => {\n let index = 0;\n const value = values[key];\n\n let transformed;\n if (typeof value === 'function') {\n transformed = (chunks: ReactNode) => {\n const result = value(chunks);\n\n return isValidElement(result)\n ? cloneElement(result, {key: key + index++})\n : result;\n };\n } else {\n transformed = value;\n }\n\n transformedValues[key] = transformed;\n });\n\n return transformedValues;\n}\n\nexport function getMessagesOrError<Messages extends AbstractIntlMessages>({\n messages,\n namespace,\n onError = defaultOnError\n}: {\n messages: Messages;\n namespace?: string;\n onError?(error: IntlError): void;\n}) {\n try {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages were configured on the provider.`\n : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(messages, namespace)\n : messages;\n\n if (!retrievedMessages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages for namespace \\`${namespace}\\` found.`\n : undefined\n );\n }\n\n return retrievedMessages;\n } catch (error) {\n const intlError = new IntlError(\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n onError(intlError);\n return intlError;\n }\n}\n\nexport type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {\n cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;\n defaultTranslationValues?: RichTranslationValues;\n namespace?: string;\n messagesOrError: Messages | IntlError;\n};\n\nexport default function createBaseTranslator<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>({\n cachedFormatsByLocale,\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback = defaultGetMessageFallback,\n locale,\n messagesOrError,\n namespace,\n onError,\n timeZone\n}: CreateBaseTranslatorProps<Messages>) {\n function getFallbackFromErrorAndNotify(\n key: string,\n code: IntlErrorCode,\n message?: string\n ) {\n const error = new IntlError(code, message);\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n function translateBaseFn(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string,\n /** Key value pairs for values to interpolate into the message. */\n values?: RichTranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n let message;\n try {\n message = resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n\n function joinPath(parts: Array<string | undefined>) {\n return parts.filter((part) => part != null).join('.');\n }\n\n const cacheKey = joinPath([namespace, key, String(message)]);\n\n let messageFormat;\n if (cachedFormatsByLocale?.[locale]?.[cacheKey]) {\n messageFormat = cachedFormatsByLocale?.[locale][cacheKey];\n } else {\n if (typeof message === 'object') {\n let code, errorMessage;\n if (Array.isArray(message)) {\n code = IntlErrorCode.INVALID_MESSAGE;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`;\n }\n } else {\n code = IntlErrorCode.INSUFFICIENT_PATH;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an object, but only strings are supported. Use a \\`.\\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`;\n }\n }\n\n return getFallbackFromErrorAndNotify(key, code, errorMessage);\n }\n\n try {\n messageFormat = new IntlMessageFormat(\n message,\n locale,\n convertFormatsToIntlMessageFormat(\n {...globalFormats, ...formats},\n timeZone\n )\n );\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n (error as Error).message\n );\n }\n\n if (cachedFormatsByLocale) {\n if (!cachedFormatsByLocale[locale]) {\n cachedFormatsByLocale[locale] = {};\n }\n cachedFormatsByLocale[locale][cacheKey] = messageFormat;\n }\n }\n\n try {\n const formattedMessage = messageFormat.format(\n // @ts-ignore `intl-messageformat` expects a different format\n // for rich text elements since a recent minor update. This\n // needs to be evaluated in detail, possibly also in regards\n // to be able to format to parts.\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Unable to format \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n }`\n : undefined\n );\n }\n\n // Limit the function signature to return strings or React elements\n return isValidElement(formattedMessage) ||\n // Arrays of React elements\n Array.isArray(formattedMessage) ||\n typeof formattedMessage === 'string'\n ? formattedMessage\n : String(formattedMessage);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.FORMATTING_ERROR,\n (error as Error).message\n );\n }\n }\n\n function translateFn<\n TargetKey extends MessageKeys<\n NestedValueOf<Messages, NestedKey>,\n NestedKeyOf<NestedValueOf<Messages, NestedKey>>\n >\n >(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: TargetKey,\n /** Key value pairs for values to interpolate into the message. */\n values?: TranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string {\n const result = translateBaseFn(key, values, formats);\n\n if (typeof result !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n process.env.NODE_ENV !== 'production'\n ? `The message \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n } didn't resolve to a string. If you want to format rich text, use \\`t.rich\\` instead.`\n : undefined\n );\n }\n\n return result;\n }\n\n translateFn.rich = translateBaseFn;\n\n translateFn.raw = (\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string\n ): any => {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n try {\n return resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n };\n\n return translateFn;\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,uBAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAA8B,iCAC9BC,EAMO,iBAIPC,EAAuC,0BAEvCC,EAA8C,kDAC9CC,EAAwD,sBAKxD,SAASC,EACPC,EACAC,EACAC,EACA,CACA,GAAI,CAACF,EACH,MAAM,IAAI,MACR,QAAQ,IAAI,WAAa,aACrB,8BAA8BE,CAAS,MACvC,MACN,EAGF,IAAIC,EAAUH,EAEd,OAAAC,EAAI,MAAM,GAAG,EAAE,QAASG,GAAS,CAC/B,MAAMC,EAAQF,EAAgBC,CAAI,EAElC,GAAIA,GAAQ,MAAQC,GAAQ,KAC1B,MAAM,IAAI,MACR,QAAQ,IAAI,WA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ACLzB,EACA,gBAAc,gBACbe,EAAgB,OACnB,CACF,CAEIG,IACGA,EAAsBI,CAAM,IAC/BJ,EAAsBI,CAAM,EAAI,CAAC,GAEnCJ,EAAsBI,CAAM,EAAES,CAAQ,EAAIC,EAE9C,CAEA,GAAI,CACF,MAAMI,EAAmBJ,EAAc,OAKrC3B,EAAyB,CAAC,GAAGc,EAA0B,GAAGb,CAAM,CAAC,CACnE,EAEA,GAAI8B,GAAoB,KACtB,MAAM,IAAI,MACR,QAAQ,IAAI,WAAa,aACrB,sBAAsBpC,CAAG,SACvBC,EAAY,eAAeA,CAAS,KAAO,UAC7C,GACA,MACN,EAIF,SAAO,kBAAemC,CAAgB,GAEpC,MAAM,QAAQA,CAAgB,GAC9B,OAAOA,GAAqB,SAC1BA,EACA,OAAOA,CAAgB,CAC7B,OAASrB,EAAO,CACd,OAAOU,EACLzB,EACA,gBAAc,iBACbe,EAAgB,OACnB,CACF,CACF,CAEA,SAASsB,EAOPrC,EAEAM,EAEAsB,EACQ,CACR,MAAMhB,EAASe,EAAgB3B,EAAKM,EAAQsB,CAAO,EAEnD,OAAI,OAAOhB,GAAW,SACba,EACLzB,EACA,gBAAc,gBACd,QAAQ,IAAI,WAAa,aACrB,iBAAiBA,CAAG,SAClBC,EAAY,eAAeA,CAAS,KAAO,UAC7C,wFACA,MACN,EAGKW,CACT,CAEA,OAAAyB,EAAY,KAAOV,EAEnBU,EAAY,IAEVrC,GACQ,CACR,GAAIuB,aAA2B,EAAAN,QAE7B,OAAOI,EAAmB,CACxB,MAAOE,EACP,IAAAvB,EACA,UAAAC,CACF,CAAC,EAEH,MAAMF,EAAWwB,EAEjB,GAAI,CACF,OAAOzB,EAAYC,EAAUC,EAAKC,CAAS,CAC7C,OAASc,EAAO,CACd,OAAOU,EACLzB,EACA,gBAAc,gBACbe,EAAgB,OACnB,CACF,CACF,EAEOsB,CACT","names":["createBaseTranslator_exports","__export","createBaseTranslator","getMessagesOrError","__toCommonJS","import_intl_messageformat","import_react","import_IntlError","import_convertFormatsToIntlMessageFormat","import_defaults","resolvePath","messages","key","namespace","message","part","next","prepareTranslationValues","values","transformedValues","index","value","transformed","chunks","result","onError","retrievedMessages","error","intlError","IntlError","cachedFormatsByLocale","defaultTranslationValues","globalFormats","getMessageFallback","locale","messagesOrError","timeZone","getFallbackFromErrorAndNotify","code","translateBaseFn","formats","joinPath","parts","cacheKey","messageFormat","errorMessage","IntlMessageFormat","convertFormatsToIntlMessageFormat","formattedMessage","translateFn"]}
1
+ {"version":3,"file":"createBaseTranslator.js","sourceRoot":"","sources":["../../../src/core/createBaseTranslator.tsx"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,YAAY,EACZ,cAAc,EAIf,MAAM,OAAO,CAAC;AAIf,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAErD,OAAO,iCAAiC,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAC,yBAAyB,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAKrE,SAAS,WAAW,CAClB,QAA0C,EAC1C,GAAW,EACX,SAAkB;IAElB,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;YACnC,CAAC,CAAC,8BAA8B,SAAS,KAAK;YAC9C,CAAC,CAAC,SAAS,CACd,CAAC;KACH;IAED,IAAI,OAAO,GAAG,QAAQ,CAAC;IAEvB,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC9B,MAAM,IAAI,GAAI,OAAe,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;YAChC,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;gBACnC,CAAC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AAI;YACF,OAAO,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;SAC9C;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,6BAA6B,CAClC,GAAG,EACH,aAAa,CAAC,eAAe,EAC5B,KAAe,CAAC,OAAO,CACzB,CAAC;SACH;IACH,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -1,9 +1,8 @@
1
- import DateTimeFormatOptions from './DateTimeFormatOptions.js';
2
- import Formats from './Formats.js';
3
- import IntlError from './IntlError.js';
4
- import { NumberFormatOptions } from '@formatjs/ecma402-abstract/types/number';
5
- import TimeZone from './TimeZone.js';
6
-
1
+ import DateTimeFormatOptions from './DateTimeFormatOptions';
2
+ import Formats from './Formats';
3
+ import IntlError from './IntlError';
4
+ import NumberFormatOptions from './NumberFormatOptions';
5
+ import TimeZone from './TimeZone';
7
6
  type Props = {
8
7
  locale: string;
9
8
  timeZone?: TimeZone;
@@ -11,11 +10,10 @@ type Props = {
11
10
  formats?: Partial<Formats>;
12
11
  now?: Date;
13
12
  };
14
- declare function createFormatter({ formats, locale, now: globalNow, onError, timeZone }: Props): {
13
+ export default function createFormatter({ formats, locale, now: globalNow, onError, timeZone }: Props): {
15
14
  dateTime: (value: Date | number, formatOrOptions?: string | DateTimeFormatOptions) => string;
16
15
  number: (value: number | bigint, formatOrOptions?: string | NumberFormatOptions) => string;
17
16
  relativeTime: (date: number | Date, now?: number | Date) => string;
18
17
  list: (value: Iterable<string>, formatOrOptions?: string | Intl.ListFormatOptions) => string;
19
18
  };
20
-
21
- export { createFormatter as default };
19
+ export {};
@@ -1,2 +1,129 @@
1
- "use strict";var y=Object.create;var p=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var G=(t,r)=>{for(var e in r)p(t,e,{get:r[e],enumerable:!0})},F=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of A(r))!_.call(t,m)&&m!==e&&p(t,m,{get:()=>r[m],enumerable:!(a=V(r,m))||a.enumerable});return t};var P=(t,r,e)=>(e=t!=null?y(S(t)):{},F(r||!t||!t.__esModule?p(e,"default",{value:t,enumerable:!0}):e,t)),U=t=>F(p({},"__esModule",{value:!0}),t);var Z={};G(Z,{default:()=>E});module.exports=U(Z);var s=P(require("./IntlError")),D=require("./defaults");const g=60,T=g*60,c=T*24,O=c*7,h=c*(365/12),b=c*365;function Y(t){const r=Math.abs(t);let e,a;return r<g?(a="second",e=Math.round(t)):r<T?(a="minute",e=Math.round(t/g)):r<c?(a="hour",e=Math.round(t/T)):r<O?(a="day",e=Math.round(t/c)):r<h?(a="week",e=Math.round(t/O)):r<b?(a="month",e=Math.round(t/h)):(a="year",e=Math.round(t/b)),{value:e,unit:a}}function E({formats:t,locale:r,now:e,onError:a=D.defaultOnError,timeZone:m}){function R(o,i){let n;if(typeof i=="string"){const f=i;if(n=o?.[f],!n){const u=new s.default(s.IntlErrorCode.MISSING_FORMAT,process.env.NODE_ENV!=="production"?`Format \`${f}\` is not available. You can configure it on the provider or provide custom options.`:void 0);throw a(u),u}}else n=i;return n}function d(o,i,n,f){let u;try{u=R(n,i)}catch{return String(o)}try{return f(u)}catch(l){return a(new s.default(s.IntlErrorCode.FORMATTING_ERROR,l.message)),String(o)}}function I(o,i){return d(o,i,t?.dateTime,n=>(m&&!n?.timeZone&&(n={...n,timeZone:m}),new Intl.DateTimeFormat(r,n).format(o)))}function w(o,i){return d(o,i,t?.number,n=>new Intl.NumberFormat(r,n).format(o))}function M(o,i){try{if(!i)if(e)i=e;else throw new Error(process.env.NODE_ENV!=="production"?"The `now` parameter wasn't provided and there was no global fallback configured on the provider.":void 0);const n=o instanceof Date?o:new Date(o),f=i instanceof Date?i:new Date(i),u=(n.getTime()-f.getTime())/1e3,{unit:l,value:v}=Y(u);return new Intl.RelativeTimeFormat(r,{numeric:"auto"}).format(v,l)}catch(n){return a(new s.default(s.IntlErrorCode.FORMATTING_ERROR,n.message)),String(o)}}function N(o,i){return d(o,i,t?.list,n=>new Intl.ListFormat(r,n).format(o))}return{dateTime:I,number:w,relativeTime:M,list:N}}
1
+ import IntlError, { IntlErrorCode } from './IntlError';
2
+ import { defaultOnError } from './defaults';
3
+ const MINUTE = 60;
4
+ const HOUR = MINUTE * 60;
5
+ const DAY = HOUR * 24;
6
+ const WEEK = DAY * 7;
7
+ const MONTH = DAY * (365 / 12); // Approximation
8
+ const YEAR = DAY * 365;
9
+ function getRelativeTimeFormatConfig(seconds) {
10
+ const absValue = Math.abs(seconds);
11
+ let value, unit;
12
+ // We have to round the resulting values, as `Intl.RelativeTimeFormat`
13
+ // will include fractions like '2.1 hours ago'.
14
+ if (absValue < MINUTE) {
15
+ unit = 'second';
16
+ value = Math.round(seconds);
17
+ }
18
+ else if (absValue < HOUR) {
19
+ unit = 'minute';
20
+ value = Math.round(seconds / MINUTE);
21
+ }
22
+ else if (absValue < DAY) {
23
+ unit = 'hour';
24
+ value = Math.round(seconds / HOUR);
25
+ }
26
+ else if (absValue < WEEK) {
27
+ unit = 'day';
28
+ value = Math.round(seconds / DAY);
29
+ }
30
+ else if (absValue < MONTH) {
31
+ unit = 'week';
32
+ value = Math.round(seconds / WEEK);
33
+ }
34
+ else if (absValue < YEAR) {
35
+ unit = 'month';
36
+ value = Math.round(seconds / MONTH);
37
+ }
38
+ else {
39
+ unit = 'year';
40
+ value = Math.round(seconds / YEAR);
41
+ }
42
+ return { value, unit };
43
+ }
44
+ export default function createFormatter({ formats, locale, now: globalNow, onError = defaultOnError, timeZone }) {
45
+ function resolveFormatOrOptions(typeFormats, formatOrOptions) {
46
+ let options;
47
+ if (typeof formatOrOptions === 'string') {
48
+ const formatName = formatOrOptions;
49
+ options = typeFormats?.[formatName];
50
+ if (!options) {
51
+ const error = new IntlError(IntlErrorCode.MISSING_FORMAT, process.env.NODE_ENV !== 'production'
52
+ ? `Format \`${formatName}\` is not available. You can configure it on the provider or provide custom options.`
53
+ : undefined);
54
+ onError(error);
55
+ throw error;
56
+ }
57
+ }
58
+ else {
59
+ options = formatOrOptions;
60
+ }
61
+ return options;
62
+ }
63
+ function getFormattedValue(value, formatOrOptions, typeFormats, formatter) {
64
+ let options;
65
+ try {
66
+ options = resolveFormatOrOptions(typeFormats, formatOrOptions);
67
+ }
68
+ catch (error) {
69
+ return String(value);
70
+ }
71
+ try {
72
+ return formatter(options);
73
+ }
74
+ catch (error) {
75
+ onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message));
76
+ return String(value);
77
+ }
78
+ }
79
+ function dateTime(
80
+ /** If a number is supplied, this is interpreted as a UTC timestamp. */
81
+ value,
82
+ /** If a time zone is supplied, the `value` is converted to that time zone.
83
+ * Otherwise the user time zone will be used. */
84
+ formatOrOptions) {
85
+ return getFormattedValue(value, formatOrOptions, formats?.dateTime, (options) => {
86
+ if (timeZone && !options?.timeZone) {
87
+ options = { ...options, timeZone };
88
+ }
89
+ return new Intl.DateTimeFormat(locale, options).format(value);
90
+ });
91
+ }
92
+ function number(value, formatOrOptions) {
93
+ return getFormattedValue(value, formatOrOptions, formats?.number, (options) => new Intl.NumberFormat(locale, options).format(value));
94
+ }
95
+ function relativeTime(
96
+ /** The date time that needs to be formatted. */
97
+ date,
98
+ /** The reference point in time to which `date` will be formatted in relation to. */
99
+ now) {
100
+ try {
101
+ if (!now) {
102
+ if (globalNow) {
103
+ now = globalNow;
104
+ }
105
+ else {
106
+ throw new Error(process.env.NODE_ENV !== 'production'
107
+ ? `The \`now\` parameter wasn't provided and there was no global fallback configured on the provider.`
108
+ : undefined);
109
+ }
110
+ }
111
+ const dateDate = date instanceof Date ? date : new Date(date);
112
+ const nowDate = now instanceof Date ? now : new Date(now);
113
+ const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;
114
+ const { unit, value } = getRelativeTimeFormatConfig(seconds);
115
+ return new Intl.RelativeTimeFormat(locale, {
116
+ numeric: 'auto'
117
+ }).format(value, unit);
118
+ }
119
+ catch (error) {
120
+ onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message));
121
+ return String(date);
122
+ }
123
+ }
124
+ function list(value, formatOrOptions) {
125
+ return getFormattedValue(value, formatOrOptions, formats?.list, (options) => new Intl.ListFormat(locale, options).format(value));
126
+ }
127
+ return { dateTime, number, relativeTime, list };
128
+ }
2
129
  //# sourceMappingURL=createFormatter.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/createFormatter.tsx"],"sourcesContent":["import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport TimeZone from './TimeZone';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: TimeZone;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createFormatter({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function number(\n value: number | bigint,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n function list(\n value: Iterable<string>,\n formatOrOptions?: string | Intl.ListFormatOptions\n ) {\n return getFormattedValue(value, formatOrOptions, formats?.list, (options) =>\n new Intl.ListFormat(locale, options).format(value)\n );\n }\n\n return {dateTime, number, relativeTime, list};\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAEA,IAAAI,EAAuC,0BAGvCC,EAA6B,sBAE7B,MAAMC,EAAS,GACTC,EAAOD,EAAS,GAChBE,EAAMD,EAAO,GACbE,EAAOD,EAAM,EACbE,EAAQF,GAAO,IAAM,IACrBG,EAAOH,EAAM,IAEnB,SAASI,EAA4BC,EAAiB,CACpD,MAAMC,EAAW,KAAK,IAAID,CAAO,EACjC,IAAIE,EAAOC,EAKX,OAAIF,EAAWR,GACbU,EAAO,SACPD,EAAQ,KAAK,MAAMF,CAAO,GACjBC,EAAWP,GACpBS,EAAO,SACPD,EAAQ,KAAK,MAAMF,EAAUP,CAAM,GAC1BQ,EAAWN,GACpBQ,EAAO,OACPD,EAAQ,KAAK,MAAMF,EAAUN,CAAI,GACxBO,EAAWL,GACpBO,EAAO,MACPD,EAAQ,KAAK,MAAMF,EAAUL,CAAG,GACvBM,EAAWJ,GACpBM,EAAO,OACPD,EAAQ,KAAK,MAAMF,EAAUJ,CAAI,GACxBK,EAAWH,GACpBK,EAAO,QACPD,EAAQ,KAAK,MAAMF,EAAUH,CAAK,IAEl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AAI,CAACA,EACH,GAAIhB,EACFgB,EAAMhB,MAEN,OAAM,IAAI,MACR,QAAQ,IAAI,WAAa,aACrB,mGACA,MACN,EAIJ,MAAMiB,EAAWF,aAAgB,KAAOA,EAAO,IAAI,KAAKA,CAAI,EACtDG,EAAUF,aAAe,KAAOA,EAAM,IAAI,KAAKA,CAAG,EAElDtB,GAAWuB,EAAS,QAAQ,EAAIC,EAAQ,QAAQ,GAAK,IACrD,CAAC,KAAArB,EAAM,MAAAD,CAAK,EAAIH,EAA4BC,CAAO,EAEzD,OAAO,IAAI,KAAK,mBAAmBK,EAAQ,CACzC,QAAS,MACX,CAAC,EAAE,OAAOH,EAAOC,CAAI,CACvB,OAASW,EAAO,CACd,OAAAP,EACE,IAAI,EAAAQ,QAAU,gBAAc,iBAAmBD,EAAgB,OAAO,CACxE,EACO,OAAOO,CAAI,CACpB,CACF,CAEA,SAASI,EACPvB,EACAS,EACA,CACA,OAAOK,EAAkBd,EAAOS,EAAiBP,GAAS,KAAOQ,GAC/D,IAAI,KAAK,WAAWP,EAAQO,CAAO,EAAE,OAAOV,CAAK,CACnD,CACF,CAEA,MAAO,CAAC,SAAAgB,EAAU,OAAAC,EAAQ,aAAAC,EAAc,KAAAK,CAAI,CAC9C","names":["createFormatter_exports","__export","createFormatter","__toCommonJS","import_IntlError","import_defaults","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","value","unit","formats","locale","globalNow","onError","timeZone","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","error","IntlError","getFormattedValue","formatter","dateTime","number","relativeTime","date","now","dateDate","nowDate","list"]}
1
+ {"version":3,"file":"createFormatter.js","sourceRoot":"","sources":["../../../src/core/createFormatter.tsx"],"names":[],"mappings":"AAEA,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAGrD,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,MAAM,MAAM,GAAG,EA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AAM,QAAQ,GAAG,IAAI,YAAY,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9D,MAAM,OAAO,GAAG,GAAG,YAAY,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;YAE1D,MAAM,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;YAChE,MAAM,EAAC,IAAI,EAAE,KAAK,EAAC,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAC;YAE3D,OAAO,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE;gBACzC,OAAO,EAAE,MAAM;aAChB,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SACxB;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CACL,IAAI,SAAS,CAAC,aAAa,CAAC,gBAAgB,EAAG,KAAe,CAAC,OAAO,CAAC,CACxE,CAAC;YACF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;SACrB;IACH,CAAC;IAED,SAAS,IAAI,CACX,KAAuB,EACvB,eAAiD;QAEjD,OAAO,iBAAiB,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAC1E,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACnD,CAAC;IACJ,CAAC;IAED,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAC,CAAC;AAChD,CAAC"}
@@ -1,15 +1,7 @@
1
- import * as _formatjs_ecma402_abstract_types_number from '@formatjs/ecma402-abstract/types/number';
2
- import DateTimeFormatOptions from './DateTimeFormatOptions.js';
3
- import createFormatter from './createFormatter.js';
4
- import './TimeZone.js';
5
- import './Formats.js';
6
- import './IntlError.js';
7
-
1
+ import createFormatter from './createFormatter';
8
2
  /** @deprecated Switch to `createFormatter` */
9
- declare function createIntl(...args: Parameters<typeof createFormatter>): {
10
- formatDateTime: (value: number | Date, formatOrOptions?: string | DateTimeFormatOptions | undefined) => string;
11
- formatNumber: (value: number | bigint, formatOrOptions?: string | _formatjs_ecma402_abstract_types_number.NumberFormatOptions | undefined) => string;
3
+ export default function createIntl(...args: Parameters<typeof createFormatter>): {
4
+ formatDateTime: (value: number | Date, formatOrOptions?: string | import("./DateTimeFormatOptions").default | undefined) => string;
5
+ formatNumber: (value: number | bigint, formatOrOptions?: string | import("@formatjs/ecma402-abstract/types/number").NumberFormatOptions | undefined) => string;
12
6
  formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
13
7
  };
14
-
15
- export { createIntl as default };
@@ -1,2 +1,11 @@
1
- "use strict";var c=Object.create;var m=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var b=(e,t)=>{for(var r in t)m(e,r,{get:t[r],enumerable:!0})},f=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of l(t))!p.call(e,a)&&a!==r&&m(e,a,{get:()=>t[a],enumerable:!(o=u(t,a))||o.enumerable});return e};var d=(e,t,r)=>(r=e!=null?c(T(e)):{},f(t||!e||!e.__esModule?m(r,"default",{value:e,enumerable:!0}):r,e)),s=e=>f(m({},"__esModule",{value:!0}),e);var v={};b(v,{default:()=>n});module.exports=s(v);var i=d(require("./createFormatter"));function n(...e){const t=(0,i.default)(...e);return{formatDateTime:t.dateTime,formatNumber:t.number,formatRelativeTime:t.relativeTime}}
1
+ import createFormatter from './createFormatter';
2
+ /** @deprecated Switch to `createFormatter` */
3
+ export default function createIntl(...args) {
4
+ const formatter = createFormatter(...args);
5
+ return {
6
+ formatDateTime: formatter.dateTime,
7
+ formatNumber: formatter.number,
8
+ formatRelativeTime: formatter.relativeTime
9
+ };
10
+ }
2
11
  //# sourceMappingURL=createIntl.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/createIntl.tsx"],"sourcesContent":["import createFormatter from './createFormatter';\n\n/** @deprecated Switch to `createFormatter` */\nexport default function createIntl(\n ...args: Parameters<typeof createFormatter>\n) {\n const formatter = createFormatter(...args);\n return {\n formatDateTime: formatter.dateTime,\n formatNumber: formatter.number,\n formatRelativeTime: formatter.relativeTime\n };\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,gCAGb,SAARF,KACFG,EACH,CACA,MAAMC,KAAY,EAAAC,SAAgB,GAAGF,CAAI,EACzC,MAAO,CACL,eAAgBC,EAAU,SAC1B,aAAcA,EAAU,OACxB,mBAAoBA,EAAU,YAChC,CACF","names":["createIntl_exports","__export","createIntl","__toCommonJS","import_createFormatter","args","formatter","createFormatter"]}
1
+ {"version":3,"file":"createIntl.js","sourceRoot":"","sources":["../../../src/core/createIntl.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,8CAA8C;AAC9C,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,GAAG,IAAwC;IAE3C,MAAM,SAAS,GAAG,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC;IAC3C,OAAO;QACL,cAAc,EAAE,SAAS,CAAC,QAAQ;QAClC,YAAY,EAAE,SAAS,CAAC,MAAM;QAC9B,kBAAkB,EAAE,SAAS,CAAC,YAAY;KAC3C,CAAC;AACJ,CAAC"}
@@ -1,18 +1,11 @@
1
- import Formats from './Formats.js';
2
- import IntlConfig from './IntlConfig.js';
3
- import TranslationValues from './TranslationValues.js';
4
- import { CoreRichTranslationValues } from './createTranslatorImpl.js';
5
- import MessageKeys from './utils/MessageKeys.js';
6
- import NamespaceKeys from './utils/NamespaceKeys.js';
7
- import NestedKeyOf from './utils/NestedKeyOf.js';
8
- import NestedValueOf from './utils/NestedValueOf.js';
9
- import './DateTimeFormatOptions.js';
10
- import './TimeZone.js';
11
- import '@formatjs/ecma402-abstract/types/number';
12
- import './IntlError.js';
13
- import './AbstractIntlMessages.js';
14
- import 'react';
15
-
1
+ import Formats from './Formats';
2
+ import IntlConfig from './IntlConfig';
3
+ import TranslationValues from './TranslationValues';
4
+ import { CoreRichTranslationValues } from './createTranslatorImpl';
5
+ import MessageKeys from './utils/MessageKeys';
6
+ import NamespaceKeys from './utils/NamespaceKeys';
7
+ import NestedKeyOf from './utils/NestedKeyOf';
8
+ import NestedValueOf from './utils/NestedValueOf';
16
9
  /**
17
10
  * Translates messages from the given namespace by using the ICU syntax.
18
11
  * See https://formatjs.io/docs/core-concepts/icu-syntax.
@@ -21,7 +14,7 @@ import 'react';
21
14
  * The namespace can also indicate nesting by using a dot
22
15
  * (e.g. `namespace.Component`).
23
16
  */
24
- declare function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {
17
+ export default function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {
25
18
  messages: NonNullable<IntlConfig<IntlMessages>['messages']>;
26
19
  namespace?: NestedKey;
27
20
  }): {
@@ -53,5 +46,3 @@ declare function createTranslator<NestedKey extends NamespaceKeys<IntlMessages,
53
46
  NestedKey
54
47
  ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
55
48
  };
56
-
57
- export { createTranslator as default };
@@ -1,2 +1,24 @@
1
- "use strict";var K=Object.create;var n=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var i=(e,s)=>{for(var t in s)n(e,t,{get:s[t],enumerable:!0})},d=(e,s,t,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of N(s))!g.call(e,a)&&a!==t&&n(e,a,{get:()=>s[a],enumerable:!(r=m(s,a))||r.enumerable});return e};var u=(e,s,t)=>(t=e!=null?K(f(e)):{},d(s||!e||!e.__esModule?n(t,"default",{value:e,enumerable:!0}):t,e)),M=e=>d(n({},"__esModule",{value:!0}),e);var I={};i(I,{default:()=>y});module.exports=M(I);var o=u(require("./createTranslatorImpl")),l=require("./defaults");function y({getMessageFallback:e=l.defaultGetMessageFallback,messages:s,namespace:t,onError:r=l.defaultOnError,...a}){return(0,o.default)({...a,onError:r,getMessageFallback:e,messages:{"!":s},namespace:t?`!.${t}`:"!"},"!")}
1
+ import createTranslatorImpl from './createTranslatorImpl';
2
+ import { defaultGetMessageFallback, defaultOnError } from './defaults';
3
+ /**
4
+ * Translates messages from the given namespace by using the ICU syntax.
5
+ * See https://formatjs.io/docs/core-concepts/icu-syntax.
6
+ *
7
+ * If no namespace is provided, all available messages are returned.
8
+ * The namespace can also indicate nesting by using a dot
9
+ * (e.g. `namespace.Component`).
10
+ */
11
+ export default function createTranslator({ getMessageFallback = defaultGetMessageFallback, messages, namespace, onError = defaultOnError, ...rest }) {
12
+ // We have to wrap the actual function so the type inference for the optional
13
+ // namespace works correctly. See https://stackoverflow.com/a/71529575/343045
14
+ // The prefix ("!") is arbitrary.
15
+ return createTranslatorImpl({
16
+ ...rest,
17
+ onError,
18
+ getMessageFallback,
19
+ messages: { '!': messages },
20
+ // @ts-ignore
21
+ namespace: namespace ? `!.${namespace}` : '!'
22
+ }, '!');
23
+ }
2
24
  //# sourceMappingURL=createTranslator.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/createTranslator.tsx"],"sourcesContent":["import Formats from './Formats';\nimport IntlConfig from './IntlConfig';\nimport TranslationValues from './TranslationValues';\nimport createTranslatorImpl, {\n CoreRichTranslationValues\n} from './createTranslatorImpl';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function createTranslator<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>({\n getMessageFallback = defaultGetMessageFallback,\n messages,\n namespace,\n onError = defaultOnError,\n ...rest\n}: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {\n messages: NonNullable<IntlConfig<IntlMessages>['messages']>;\n namespace?: NestedKey;\n}): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: CoreRichTranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n // We have to wrap the actual function so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return createTranslatorImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {\n ...rest,\n onError,\n getMessageFallback,\n messages: {'!': messages},\n // @ts-ignore\n namespace: namespace ? `!.${namespace}` : '!'\n },\n '!'\n );\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAAI,EAEO,qCACPC,EAAwD,sBAczC,SAARH,EAKL,CACA,mBAAAI,EAAqB,4BACrB,SAAAC,EACA,UAAAC,EACA,QAAAC,EAAU,iBACV,GAAGC,CACL,EA8DE,CAIA,SAAO,EAAAC,SAIL,CACE,GAAGD,EACH,QAAAD,EACA,mBAAAH,EACA,SAAU,CAAC,IAAKC,CAAQ,EAExB,UAAWC,EAAY,KAAKA,CAAS,GAAK,GAC5C,EACA,GACF,CACF","names":["createTranslator_exports","__export","createTranslator","__toCommonJS","import_createTranslatorImpl","import_defaults","getMessageFallback","messages","namespace","onError","rest","createTranslatorImpl"]}
1
+ {"version":3,"file":"createTranslator.js","sourceRoot":"","sources":["../../../src/core/createTranslator.tsx"],"names":[],"mappings":"AAGA,OAAO,oBAEN,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAC,yBAAyB,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAMrE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAKtC,EACA,kBAAkB,GAAG,yBAAyB,EAC9C,QAAQ,EACR,SAAS,EACT,OAAO,GAAG,cAAc,EACxB,GAAG,IAAI,EAIR;IA4DC,6EAA6E;IAC7E,6EAA6E;IAC7E,iCAAiC;IACjC,OAAO,oBAAoB,CAIzB;QACE,GAAG,IAAI;QACP,OAAO;QACP,kBAAkB;QAClB,QAAQ,EAAE,EAAC,GAAG,EAAE,QAAQ,EAAC;QACzB,aAAa;QACb,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC,CAAC,CAAC,GAAG;KAC9C,EACD,GAAG,CACJ,CAAC;AACJ,CAAC"}