@watermarkinsights/ripple 3.0.1-0 → 3.0.2-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/dist/{ripple/functions-316c1b23.js → cjs/functions-e3f5ae65.js} +188 -2391
  2. package/dist/cjs/global-1e540de6.js +38 -0
  3. package/dist/cjs/http-service-9e8c4dd5.js +57 -0
  4. package/dist/cjs/index-d930307d.js +1392 -0
  5. package/dist/cjs/index.cjs.js +2 -0
  6. package/dist/cjs/interfaces-30a74c1f.js +35 -0
  7. package/dist/cjs/loader.cjs.js +22 -0
  8. package/dist/cjs/priv-chart-popover.cjs.entry.js +89 -0
  9. package/dist/cjs/priv-datepicker.cjs.entry.js +672 -0
  10. package/dist/cjs/priv-navigator-button.cjs.entry.js +29 -0
  11. package/dist/cjs/priv-navigator-item.cjs.entry.js +34 -0
  12. package/dist/cjs/ripple.cjs.js +20 -0
  13. package/dist/cjs/wm-action-menu_2.cjs.entry.js +318 -0
  14. package/dist/cjs/wm-button.cjs.entry.js +152 -0
  15. package/dist/cjs/wm-chart-slice.cjs.entry.js +22 -0
  16. package/dist/cjs/wm-chart.cjs.entry.js +508 -0
  17. package/dist/cjs/wm-datepicker.cjs.entry.js +257 -0
  18. package/dist/cjs/wm-input.cjs.entry.js +110 -0
  19. package/dist/cjs/wm-modal-footer.cjs.entry.js +43 -0
  20. package/dist/cjs/wm-modal-header.cjs.entry.js +45 -0
  21. package/dist/cjs/wm-modal.cjs.entry.js +149 -0
  22. package/dist/cjs/wm-navigator.cjs.entry.js +279 -0
  23. package/dist/cjs/wm-network-uploader.cjs.entry.js +431 -0
  24. package/dist/cjs/wm-option_2.cjs.entry.js +483 -0
  25. package/dist/cjs/wm-pagination.cjs.entry.js +176 -0
  26. package/dist/cjs/wm-search.cjs.entry.js +231 -0
  27. package/dist/cjs/wm-snackbar.cjs.entry.js +160 -0
  28. package/dist/cjs/wm-tab-item_3.cjs.entry.js +316 -0
  29. package/dist/cjs/wm-tag-input.cjs.entry.js +538 -0
  30. package/dist/cjs/wm-timepicker.cjs.entry.js +386 -0
  31. package/dist/cjs/wm-toggletip.cjs.entry.js +128 -0
  32. package/dist/cjs/wm-uploader.cjs.entry.js +342 -0
  33. package/dist/cjs/wm-wrapper.cjs.entry.js +21 -0
  34. package/dist/collection/collection-manifest.json +131 -0
  35. package/dist/{ripple/ripple.css → collection/components/wm-action-menu/wm-action-menu.css} +80 -42
  36. package/dist/collection/components/wm-action-menu/wm-action-menu.js +392 -0
  37. package/dist/collection/components/wm-button/wm-button.css +572 -0
  38. package/dist/collection/components/wm-button/wm-button.js +365 -0
  39. package/dist/collection/components/wm-chart/priv-chart-popover/priv-chart-popover.css +132 -0
  40. package/dist/collection/components/wm-chart/priv-chart-popover/priv-chart-popover.js +232 -0
  41. package/dist/collection/components/wm-chart/wm-chart-slice.js +64 -0
  42. package/dist/collection/components/wm-chart/wm-chart.css +337 -0
  43. package/dist/collection/components/wm-chart/wm-chart.js +710 -0
  44. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.css +374 -0
  45. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +1003 -0
  46. package/dist/collection/components/wm-datepicker/wm-datepicker.css +211 -0
  47. package/dist/collection/components/wm-datepicker/wm-datepicker.js +439 -0
  48. package/dist/collection/components/wm-input/wm-input.css +220 -0
  49. package/dist/collection/components/wm-input/wm-input.js +302 -0
  50. package/dist/collection/components/wm-menuitem/wm-menuitem.css +118 -0
  51. package/dist/collection/components/wm-menuitem/wm-menuitem.js +411 -0
  52. package/dist/collection/components/wm-modal/wm-modal-footer.css +84 -0
  53. package/dist/collection/components/wm-modal/wm-modal-footer.js +159 -0
  54. package/dist/collection/components/wm-modal/wm-modal-header.css +78 -0
  55. package/dist/collection/components/wm-modal/wm-modal-header.js +109 -0
  56. package/dist/collection/components/wm-modal/wm-modal.css +155 -0
  57. package/dist/collection/components/wm-modal/wm-modal.js +356 -0
  58. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.css +94 -0
  59. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +97 -0
  60. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.css +67 -0
  61. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +114 -0
  62. package/dist/collection/components/wm-navigator/wm-navigator.css +137 -0
  63. package/dist/collection/components/wm-navigator/wm-navigator.js +468 -0
  64. package/dist/collection/components/wm-option/wm-option.css +162 -0
  65. package/dist/collection/components/wm-option/wm-option.js +394 -0
  66. package/dist/collection/components/wm-pagination/wm-pagination.css +217 -0
  67. package/dist/collection/components/wm-pagination/wm-pagination.js +348 -0
  68. package/dist/collection/components/wm-search/wm-search.css +155 -0
  69. package/dist/collection/components/wm-search/wm-search.js +439 -0
  70. package/dist/collection/components/wm-select/wm-select.css +315 -0
  71. package/dist/collection/components/wm-select/wm-select.js +676 -0
  72. package/dist/collection/components/wm-snackbar/wm-snackbar.css +331 -0
  73. package/dist/collection/components/wm-snackbar/wm-snackbar.js +240 -0
  74. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.css +104 -0
  75. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +202 -0
  76. package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.css +73 -0
  77. package/dist/{ripple/wm-tab-list.entry.js → collection/components/wm-tabs/wm-tab-list/wm-tab-list.js} +131 -17
  78. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.css +57 -0
  79. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +104 -0
  80. package/dist/collection/components/wm-tag-input/wm-tag-input.css +431 -0
  81. package/dist/collection/components/wm-tag-input/wm-tag-input.js +754 -0
  82. package/dist/collection/components/wm-timepicker/wm-timepicker.css +370 -0
  83. package/dist/collection/components/wm-timepicker/wm-timepicker.js +567 -0
  84. package/dist/collection/components/wm-toggletip/wm-toggletip.css +350 -0
  85. package/dist/collection/components/wm-toggletip/wm-toggletip.js +217 -0
  86. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.css +642 -0
  87. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +753 -0
  88. package/dist/collection/components/wm-uploader/wm-uploader.css +666 -0
  89. package/dist/collection/components/wm-uploader/wm-uploader.js +673 -0
  90. package/dist/collection/components/wm-wrapper/wm-wrapper.js +27 -0
  91. package/dist/collection/dev/scripts.js +20 -0
  92. package/dist/collection/global/__mocks__/functions.js +5 -0
  93. package/dist/collection/global/functions.js +420 -0
  94. package/dist/{ripple/app-globals-b5693c90.js → collection/global/global.js} +3 -8
  95. package/dist/{ripple/interfaces-50753346.js → collection/global/interfaces.js} +4 -6
  96. package/dist/collection/global/services/__mocks__/http-service.js +130 -0
  97. package/dist/collection/global/services/http-service.js +50 -0
  98. package/dist/collection/lang/lang.js +5 -0
  99. package/dist/collection/lang/piglatin.js +93 -0
  100. package/dist/esm/functions-0deb7f8e.js +6117 -0
  101. package/dist/esm/global-d6b49e98.js +36 -0
  102. package/dist/{ripple → esm}/http-service-5d037e16.js +0 -0
  103. package/dist/esm/index-5a842e48.js +1363 -0
  104. package/dist/esm/index.js +1 -0
  105. package/dist/esm/interfaces-61c6305b.js +32 -0
  106. package/dist/esm/loader.js +18 -0
  107. package/dist/esm/polyfills/core-js.js +11 -0
  108. package/dist/esm/polyfills/css-shim.js +1 -0
  109. package/dist/esm/polyfills/dom.js +79 -0
  110. package/dist/esm/polyfills/es5-html-element.js +1 -0
  111. package/dist/esm/polyfills/index.js +34 -0
  112. package/dist/esm/polyfills/system.js +6 -0
  113. package/dist/{ripple → esm}/priv-chart-popover.entry.js +2 -2
  114. package/dist/{ripple → esm}/priv-datepicker.entry.js +3 -3
  115. package/dist/{ripple → esm}/priv-navigator-button.entry.js +1 -1
  116. package/dist/{ripple → esm}/priv-navigator-item.entry.js +1 -1
  117. package/dist/esm/ripple.js +18 -0
  118. package/dist/{ripple/wm-action-menu.entry.js → esm/wm-action-menu_2.entry.js} +114 -3
  119. package/dist/{ripple → esm}/wm-button.entry.js +3 -3
  120. package/dist/{ripple → esm}/wm-chart-slice.entry.js +1 -1
  121. package/dist/{ripple → esm}/wm-chart.entry.js +2 -2
  122. package/dist/{ripple → esm}/wm-datepicker.entry.js +27 -32
  123. package/dist/{ripple → esm}/wm-input.entry.js +2 -2
  124. package/dist/{ripple → esm}/wm-modal-footer.entry.js +2 -2
  125. package/dist/{ripple → esm}/wm-modal-header.entry.js +2 -2
  126. package/dist/{ripple → esm}/wm-modal.entry.js +2 -2
  127. package/dist/{ripple → esm}/wm-navigator.entry.js +3 -3
  128. package/dist/{ripple → esm}/wm-network-uploader.entry.js +2 -2
  129. package/dist/{ripple/wm-select.entry.js → esm/wm-option_2.entry.js} +119 -3
  130. package/dist/{ripple → esm}/wm-pagination.entry.js +2 -2
  131. package/dist/{ripple → esm}/wm-search.entry.js +2 -2
  132. package/dist/{ripple → esm}/wm-snackbar.entry.js +2 -2
  133. package/dist/esm/wm-tab-item_3.entry.js +310 -0
  134. package/dist/{ripple → esm}/wm-tag-input.entry.js +2 -2
  135. package/dist/{ripple → esm}/wm-timepicker.entry.js +2 -2
  136. package/dist/{ripple → esm}/wm-toggletip.entry.js +2 -2
  137. package/dist/{ripple → esm}/wm-uploader.entry.js +2 -2
  138. package/dist/{ripple → esm}/wm-wrapper.entry.js +1 -1
  139. package/dist/index.cjs.js +1 -0
  140. package/dist/index.js +1 -0
  141. package/dist/loader/cdn.js +3 -0
  142. package/dist/loader/index.cjs.js +3 -0
  143. package/dist/loader/index.d.ts +13 -0
  144. package/dist/loader/index.es2017.js +3 -0
  145. package/dist/loader/index.js +4 -0
  146. package/dist/loader/package.json +10 -0
  147. package/dist/ripple/index.esm.js +0 -1
  148. package/dist/ripple/p-103f8cae.entry.js +1 -0
  149. package/dist/ripple/p-129d94fa.entry.js +1 -0
  150. package/dist/ripple/p-139fe143.entry.js +1 -0
  151. package/dist/ripple/p-16367805.entry.js +1 -0
  152. package/dist/ripple/p-1d334060.entry.js +1 -0
  153. package/dist/ripple/p-2562f330.entry.js +1 -0
  154. package/dist/ripple/p-278b26ef.entry.js +1 -0
  155. package/dist/ripple/p-2c21bb72.entry.js +1 -0
  156. package/dist/ripple/p-2f5fda71.entry.js +1 -0
  157. package/dist/ripple/p-3e6f04d5.entry.js +1 -0
  158. package/dist/ripple/p-7185de7f.entry.js +1 -0
  159. package/dist/ripple/p-770d0798.entry.js +1 -0
  160. package/dist/ripple/p-846b4c5f.entry.js +1 -0
  161. package/dist/ripple/p-888bec42.js +1 -0
  162. package/dist/ripple/p-90779d53.entry.js +1 -0
  163. package/dist/ripple/p-934543f2.js +1 -0
  164. package/dist/ripple/p-9a087fee.entry.js +1 -0
  165. package/dist/ripple/p-a6d6eae7.js +1 -0
  166. package/dist/ripple/p-a942ad10.entry.js +1 -0
  167. package/dist/ripple/p-bfb4652d.entry.js +1 -0
  168. package/dist/ripple/p-c0fe5201.entry.js +1 -0
  169. package/dist/ripple/p-c2e27acc.entry.js +1 -0
  170. package/dist/ripple/p-c2edda64.entry.js +1 -0
  171. package/dist/ripple/p-d1fdcbcf.entry.js +1 -0
  172. package/dist/ripple/p-d40b6afb.entry.js +1 -0
  173. package/dist/ripple/p-da73db1c.entry.js +1 -0
  174. package/dist/ripple/p-e3843249.js +1 -0
  175. package/dist/ripple/p-ea5cd8b8.js +16 -0
  176. package/dist/ripple/p-ed0f43f4.entry.js +1 -0
  177. package/dist/ripple/p-ffafd363.entry.js +1 -0
  178. package/dist/ripple/ripple.esm.js +1 -125
  179. package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +43 -0
  180. package/dist/types/components/wm-button/wm-button.d.ts +36 -0
  181. package/dist/types/components/wm-chart/priv-chart-popover/priv-chart-popover.d.ts +23 -0
  182. package/dist/types/components/wm-chart/wm-chart-slice.d.ts +8 -0
  183. package/dist/types/components/wm-chart/wm-chart.d.ts +77 -0
  184. package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +75 -0
  185. package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +39 -0
  186. package/dist/types/components/wm-input/wm-input.d.ts +30 -0
  187. package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +30 -0
  188. package/dist/types/components/wm-modal/wm-modal-footer.d.ts +15 -0
  189. package/dist/types/components/wm-modal/wm-modal-header.d.ts +12 -0
  190. package/dist/types/components/wm-modal/wm-modal.d.ts +34 -0
  191. package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -0
  192. package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -0
  193. package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -0
  194. package/dist/types/components/wm-option/wm-option.d.ts +28 -0
  195. package/dist/types/components/wm-pagination/wm-pagination.d.ts +31 -0
  196. package/dist/types/components/wm-search/wm-search.d.ts +78 -0
  197. package/dist/types/components/wm-select/wm-select.d.ts +63 -0
  198. package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +32 -0
  199. package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +35 -0
  200. package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +50 -0
  201. package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -0
  202. package/dist/types/components/wm-tag-input/{wm-tag-input.d.ts~ds312_tagInputMaxTags → wm-tag-input.d.ts} +1 -1
  203. package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +59 -0
  204. package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +25 -0
  205. package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -0
  206. package/dist/types/components/wm-uploader/wm-uploader.d.ts +75 -0
  207. package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -0
  208. package/dist/types/{components.d.ts~ds312_tagInputMaxTags → components.d.ts} +0 -0
  209. package/dist/types/global/__mocks__/functions.d.ts +5 -0
  210. package/dist/types/global/global.d.ts +1 -0
  211. package/dist/types/global/interfaces.d.ts +33 -0
  212. package/dist/types/global/services/__mocks__/http-service.d.ts +6 -0
  213. package/dist/types/global/services/http-service.d.ts +4 -0
  214. package/dist/types/lang/lang.d.ts +5 -0
  215. package/dist/types/{stencil-public-runtime.d.ts~ds312_tagInputMaxTags → stencil-public-runtime.d.ts} +190 -182
  216. package/package.json +1 -1
  217. package/dist/ripple/css-shim-bbdf0cc6.js +0 -4
  218. package/dist/ripple/dom-1f98a75f.js +0 -73
  219. package/dist/ripple/index-20b65f86.js +0 -2938
  220. package/dist/ripple/shadow-css-67b66845.js +0 -389
  221. package/dist/ripple/wm-menuitem.entry.js +0 -114
  222. package/dist/ripple/wm-option.entry.js +0 -119
  223. package/dist/ripple/wm-tab-item.entry.js +0 -78
  224. package/dist/ripple/wm-tab-panel.entry.js +0 -38
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  const en = {
2
4
  "chart.clickToSeeDetails": [
3
5
  {
@@ -2656,128 +2658,6 @@ var __assign = function() {
2656
2658
  return __assign.apply(this, arguments);
2657
2659
  };
2658
2660
 
2659
- function __rest(s, e) {
2660
- var t = {};
2661
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2662
- t[p] = s[p];
2663
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
2664
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2665
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2666
- t[p[i]] = s[p[i]];
2667
- }
2668
- return t;
2669
- }
2670
-
2671
- function __decorate(decorators, target, key, desc) {
2672
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2673
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2674
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2675
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2676
- }
2677
-
2678
- function __param(paramIndex, decorator) {
2679
- return function (target, key) { decorator(target, key, paramIndex); }
2680
- }
2681
-
2682
- function __metadata(metadataKey, metadataValue) {
2683
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
2684
- }
2685
-
2686
- function __awaiter(thisArg, _arguments, P, generator) {
2687
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2688
- return new (P || (P = Promise))(function (resolve, reject) {
2689
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2690
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2691
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2692
- step((generator = generator.apply(thisArg, _arguments || [])).next());
2693
- });
2694
- }
2695
-
2696
- function __generator(thisArg, body) {
2697
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
2698
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
2699
- function verb(n) { return function (v) { return step([n, v]); }; }
2700
- function step(op) {
2701
- if (f) throw new TypeError("Generator is already executing.");
2702
- while (_) try {
2703
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
2704
- if (y = 0, t) op = [op[0] & 2, t.value];
2705
- switch (op[0]) {
2706
- case 0: case 1: t = op; break;
2707
- case 4: _.label++; return { value: op[1], done: false };
2708
- case 5: _.label++; y = op[1]; op = [0]; continue;
2709
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
2710
- default:
2711
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
2712
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
2713
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
2714
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
2715
- if (t[2]) _.ops.pop();
2716
- _.trys.pop(); continue;
2717
- }
2718
- op = body.call(thisArg, _);
2719
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
2720
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
2721
- }
2722
- }
2723
-
2724
- var __createBinding = Object.create ? (function(o, m, k, k2) {
2725
- if (k2 === undefined) k2 = k;
2726
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
2727
- }) : (function(o, m, k, k2) {
2728
- if (k2 === undefined) k2 = k;
2729
- o[k2] = m[k];
2730
- });
2731
-
2732
- function __exportStar(m, o) {
2733
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
2734
- }
2735
-
2736
- function __values(o) {
2737
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
2738
- if (m) return m.call(o);
2739
- if (o && typeof o.length === "number") return {
2740
- next: function () {
2741
- if (o && i >= o.length) o = void 0;
2742
- return { value: o && o[i++], done: !o };
2743
- }
2744
- };
2745
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
2746
- }
2747
-
2748
- function __read(o, n) {
2749
- var m = typeof Symbol === "function" && o[Symbol.iterator];
2750
- if (!m) return o;
2751
- var i = m.call(o), r, ar = [], e;
2752
- try {
2753
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
2754
- }
2755
- catch (error) { e = { error: error }; }
2756
- finally {
2757
- try {
2758
- if (r && !r.done && (m = i["return"])) m.call(i);
2759
- }
2760
- finally { if (e) throw e.error; }
2761
- }
2762
- return ar;
2763
- }
2764
-
2765
- /** @deprecated */
2766
- function __spread() {
2767
- for (var ar = [], i = 0; i < arguments.length; i++)
2768
- ar = ar.concat(__read(arguments[i]));
2769
- return ar;
2770
- }
2771
-
2772
- /** @deprecated */
2773
- function __spreadArrays() {
2774
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
2775
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
2776
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
2777
- r[k] = a[j];
2778
- return r;
2779
- }
2780
-
2781
2661
  function __spreadArray(to, from, pack) {
2782
2662
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
2783
2663
  if (ar || !(i in from)) {
@@ -2786,72 +2666,6 @@ function __spreadArray(to, from, pack) {
2786
2666
  }
2787
2667
  }
2788
2668
  return to.concat(ar || Array.prototype.slice.call(from));
2789
- }
2790
-
2791
- function __await(v) {
2792
- return this instanceof __await ? (this.v = v, this) : new __await(v);
2793
- }
2794
-
2795
- function __asyncGenerator(thisArg, _arguments, generator) {
2796
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2797
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
2798
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
2799
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
2800
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
2801
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
2802
- function fulfill(value) { resume("next", value); }
2803
- function reject(value) { resume("throw", value); }
2804
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
2805
- }
2806
-
2807
- function __asyncDelegator(o) {
2808
- var i, p;
2809
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
2810
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
2811
- }
2812
-
2813
- function __asyncValues(o) {
2814
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2815
- var m = o[Symbol.asyncIterator], i;
2816
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
2817
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
2818
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
2819
- }
2820
-
2821
- function __makeTemplateObject(cooked, raw) {
2822
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
2823
- return cooked;
2824
- };
2825
-
2826
- var __setModuleDefault = Object.create ? (function(o, v) {
2827
- Object.defineProperty(o, "default", { enumerable: true, value: v });
2828
- }) : function(o, v) {
2829
- o["default"] = v;
2830
- };
2831
-
2832
- function __importStar(mod) {
2833
- if (mod && mod.__esModule) return mod;
2834
- var result = {};
2835
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2836
- __setModuleDefault(result, mod);
2837
- return result;
2838
- }
2839
-
2840
- function __importDefault(mod) {
2841
- return (mod && mod.__esModule) ? mod : { default: mod };
2842
- }
2843
-
2844
- function __classPrivateFieldGet(receiver, state, kind, f) {
2845
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2846
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
2847
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2848
- }
2849
-
2850
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
2851
- if (kind === "m") throw new TypeError("Private method is not writable");
2852
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2853
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
2854
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
2855
2669
  }
2856
2670
 
2857
2671
  var ErrorKind;
@@ -2999,23 +2813,9 @@ function isNumberSkeleton(el) {
2999
2813
  function isDateTimeSkeleton(el) {
3000
2814
  return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.dateTime);
3001
2815
  }
3002
- function createLiteralElement(value) {
3003
- return {
3004
- type: TYPE.literal,
3005
- value: value,
3006
- };
3007
- }
3008
- function createNumberElement(value, style) {
3009
- return {
3010
- type: TYPE.number,
3011
- value: value,
3012
- style: style,
3013
- };
3014
- }
3015
2816
 
3016
2817
  // @generated from regex-gen.ts
3017
2818
  var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
3018
- var WHITE_SPACE_REGEX$1 = /[\t-\r \x85\u200E\u200F\u2028\u2029]/;
3019
2819
 
3020
2820
  /**
3021
2821
  * https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
@@ -4227,8 +4027,7 @@ var Parser = /** @class */ (function () {
4227
4027
  Parser.prototype.tryParseDecimalInteger = function (expectNumberError, invalidNumberError) {
4228
4028
  var sign = 1;
4229
4029
  var startingPosition = this.clonePosition();
4230
- if (this.bumpIf('+')) {
4231
- }
4030
+ if (this.bumpIf('+')) ;
4232
4031
  else if (this.bumpIf('-')) {
4233
4032
  sign = -1;
4234
4033
  }
@@ -4875,7 +4674,7 @@ function isFormatXMLElementFn(el) {
4875
4674
  return typeof el === 'function';
4876
4675
  }
4877
4676
  // TODO(skeleton): add skeleton support
4878
- function formatToParts$1(els, locales, formatters, formats, values, currentPluralValue,
4677
+ function formatToParts(els, locales, formatters, formats, values, currentPluralValue,
4879
4678
  // For debugging
4880
4679
  originalMessage) {
4881
4680
  // Hot path for straight simple msg translations
@@ -4984,7 +4783,7 @@ originalMessage) {
4984
4783
  if (!isFormatXMLElementFn(formatFn)) {
4985
4784
  throw new InvalidValueTypeError(value_1, 'function', originalMessage);
4986
4785
  }
4987
- var parts = formatToParts$1(children, locales, formatters, formats, values, currentPluralValue);
4786
+ var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue);
4988
4787
  var chunks = formatFn(parts.map(function (p) { return p.value; }));
4989
4788
  if (!Array.isArray(chunks)) {
4990
4789
  chunks = [chunks];
@@ -5001,7 +4800,7 @@ originalMessage) {
5001
4800
  if (!opt) {
5002
4801
  throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
5003
4802
  }
5004
- result.push.apply(result, formatToParts$1(opt.value, locales, formatters, formats, values));
4803
+ result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
5005
4804
  continue;
5006
4805
  }
5007
4806
  if (isPluralElement(el)) {
@@ -5018,7 +4817,7 @@ originalMessage) {
5018
4817
  if (!opt) {
5019
4818
  throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
5020
4819
  }
5021
- result.push.apply(result, formatToParts$1(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
4820
+ result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
5022
4821
  continue;
5023
4822
  }
5024
4823
  }
@@ -5137,7 +4936,7 @@ var IntlMessageFormat = /** @class */ (function () {
5137
4936
  return result;
5138
4937
  };
5139
4938
  this.formatToParts = function (values) {
5140
- return formatToParts$1(_this.ast, _this.locales, _this.formatters, _this.formats, values, undefined, _this.message);
4939
+ return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, undefined, _this.message);
5141
4940
  };
5142
4941
  this.resolvedOptions = function () { return ({
5143
4942
  locale: Intl.NumberFormat.supportedLocalesOf(_this.locales)[0],
@@ -5245,12 +5044,6 @@ var IntlMessageFormat = /** @class */ (function () {
5245
5044
  return IntlMessageFormat;
5246
5045
  }());
5247
5046
 
5248
- /*
5249
- Copyright (c) 2014, Yahoo! Inc. All rights reserved.
5250
- Copyrights licensed under the New BSD License.
5251
- See the accompanying LICENSE file for terms.
5252
- */
5253
-
5254
5047
  var IntlErrorCode;
5255
5048
  (function (IntlErrorCode) {
5256
5049
  IntlErrorCode["FORMAT_ERROR"] = "FORMAT_ERROR";
@@ -5324,9 +5117,6 @@ function filterProps(props, whitelist, defaults) {
5324
5117
  }, {});
5325
5118
  }
5326
5119
  var defaultErrorHandler = function (error) {
5327
- if ("development" !== 'production') {
5328
- console.error(error);
5329
- }
5330
5120
  };
5331
5121
  var DEFAULT_INTL_CONFIG = {
5332
5122
  formats: {},
@@ -5462,2199 +5252,195 @@ function getNamedFormat(formats, type, name, onError) {
5462
5252
  }
5463
5253
 
5464
5254
  /**
5465
- * http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
5466
- * @param locales
5255
+ * Cannot do Math.log(x) / Math.log(10) bc if IEEE floating point issue
5256
+ * @param x number
5467
5257
  */
5468
- function CanonicalizeLocaleList(locales) {
5469
- // TODO
5470
- return Intl.getCanonicalLocales(locales);
5258
+ function invariant(condition, message, Err) {
5259
+ if (Err === void 0) { Err = Error; }
5260
+ if (!condition) {
5261
+ throw new Err(message);
5262
+ }
5471
5263
  }
5472
5264
 
5473
- /**
5474
- * https://tc39.es/ecma402/#sec-canonicalizetimezonename
5475
- * @param tz
5476
- */
5477
- function CanonicalizeTimeZoneName(tz, _a) {
5478
- var tzData = _a.tzData, uppercaseLinks = _a.uppercaseLinks;
5479
- var uppercasedTz = tz.toUpperCase();
5480
- var uppercasedZones = Object.keys(tzData).reduce(function (all, z) {
5481
- all[z.toUpperCase()] = z;
5265
+ function setTimeZoneInOptions(opts, timeZone) {
5266
+ return Object.keys(opts).reduce(function (all, k) {
5267
+ all[k] = __assign({ timeZone: timeZone }, opts[k]);
5482
5268
  return all;
5483
5269
  }, {});
5484
- var ianaTimeZone = uppercaseLinks[uppercasedTz] || uppercasedZones[uppercasedTz];
5485
- if (ianaTimeZone === 'Etc/UTC' || ianaTimeZone === 'Etc/GMT') {
5486
- return 'UTC';
5487
- }
5488
- return ianaTimeZone;
5489
5270
  }
5490
-
5491
- /**
5492
- * https://tc39.es/ecma262/#sec-tostring
5493
- */
5494
- function ToString(o) {
5495
- // Only symbol is irregular...
5496
- if (typeof o === 'symbol') {
5497
- throw TypeError('Cannot convert a Symbol value to a string');
5498
- }
5499
- return String(o);
5271
+ function deepMergeOptions(opts1, opts2) {
5272
+ var keys = Object.keys(__assign(__assign({}, opts1), opts2));
5273
+ return keys.reduce(function (all, k) {
5274
+ all[k] = __assign(__assign({}, (opts1[k] || {})), (opts2[k] || {}));
5275
+ return all;
5276
+ }, {});
5500
5277
  }
5501
- /**
5502
- * https://tc39.es/ecma262/#sec-tonumber
5503
- * @param val
5504
- */
5505
- function ToNumber(val) {
5506
- if (val === undefined) {
5507
- return NaN;
5278
+ function deepMergeFormatsAndSetTimeZone(f1, timeZone) {
5279
+ if (!timeZone) {
5280
+ return f1;
5508
5281
  }
5509
- if (val === null) {
5510
- return +0;
5282
+ var mfFormats = IntlMessageFormat.formats;
5283
+ return __assign(__assign(__assign({}, mfFormats), f1), { date: deepMergeOptions(setTimeZoneInOptions(mfFormats.date, timeZone), setTimeZoneInOptions(f1.date || {}, timeZone)), time: deepMergeOptions(setTimeZoneInOptions(mfFormats.time, timeZone), setTimeZoneInOptions(f1.time || {}, timeZone)) });
5284
+ }
5285
+ function formatMessage(_a, state, messageDescriptor, values, opts) {
5286
+ var locale = _a.locale, formats = _a.formats, messages = _a.messages, defaultLocale = _a.defaultLocale, defaultFormats = _a.defaultFormats, onError = _a.onError, timeZone = _a.timeZone, defaultRichTextElements = _a.defaultRichTextElements;
5287
+ if (messageDescriptor === void 0) { messageDescriptor = { id: '' }; }
5288
+ var msgId = messageDescriptor.id, defaultMessage = messageDescriptor.defaultMessage;
5289
+ // `id` is a required field of a Message Descriptor.
5290
+ invariant(!!msgId, "[@formatjs/intl] An `id` must be provided to format a message. You can either:\n1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.io/docs/tooling/babel-plugin)\nor [@formatjs/ts-transformer](https://formatjs.io/docs/tooling/ts-transformer) OR\n2. Configure your `eslint` config to include [eslint-plugin-formatjs](https://formatjs.io/docs/tooling/linter#enforce-id)\nto autofix this issue");
5291
+ var id = String(msgId);
5292
+ var message =
5293
+ // In case messages is Object.create(null)
5294
+ // e.g import('foo.json') from webpack)
5295
+ // See https://github.com/formatjs/formatjs/issues/1914
5296
+ messages &&
5297
+ Object.prototype.hasOwnProperty.call(messages, id) &&
5298
+ messages[id];
5299
+ // IMPORTANT: Hot path if `message` is AST with a single literal node
5300
+ if (Array.isArray(message) &&
5301
+ message.length === 1 &&
5302
+ message[0].type === TYPE.literal) {
5303
+ return message[0].value;
5511
5304
  }
5512
- if (typeof val === 'boolean') {
5513
- return val ? 1 : +0;
5305
+ // IMPORTANT: Hot path straight lookup for performance
5306
+ if (!values &&
5307
+ message &&
5308
+ typeof message === 'string' &&
5309
+ !defaultRichTextElements) {
5310
+ return message.replace(/'\{(.*?)\}'/gi, "{$1}");
5514
5311
  }
5515
- if (typeof val === 'number') {
5516
- return val;
5312
+ values = __assign(__assign({}, defaultRichTextElements), (values || {}));
5313
+ formats = deepMergeFormatsAndSetTimeZone(formats, timeZone);
5314
+ defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone);
5315
+ if (!message) {
5316
+ if (!defaultMessage ||
5317
+ (locale && locale.toLowerCase() !== defaultLocale.toLowerCase())) {
5318
+ // This prevents warnings from littering the console in development
5319
+ // when no `messages` are passed into the <IntlProvider> for the
5320
+ // default locale.
5321
+ onError(new MissingTranslationError(messageDescriptor, locale));
5322
+ }
5323
+ if (defaultMessage) {
5324
+ try {
5325
+ var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts);
5326
+ return formatter.format(values);
5327
+ }
5328
+ catch (e) {
5329
+ onError(new MessageFormatError("Error formatting default message for: \"" + id + "\", rendering default message verbatim", locale, messageDescriptor, e));
5330
+ return typeof defaultMessage === 'string' ? defaultMessage : id;
5331
+ }
5332
+ }
5333
+ return id;
5517
5334
  }
5518
- if (typeof val === 'symbol' || typeof val === 'bigint') {
5519
- throw new TypeError('Cannot convert symbol/bigint to number');
5335
+ // We have the translated message
5336
+ try {
5337
+ var formatter = state.getMessageFormat(message, locale, formats, __assign({ formatters: state }, (opts || {})));
5338
+ return formatter.format(values);
5520
5339
  }
5521
- return Number(val);
5522
- }
5523
- /**
5524
- * https://tc39.es/ecma262/#sec-tointeger
5525
- * @param n
5526
- */
5527
- function ToInteger(n) {
5528
- var number = ToNumber(n);
5529
- if (isNaN(number) || SameValue(number, -0)) {
5530
- return 0;
5340
+ catch (e) {
5341
+ onError(new MessageFormatError("Error formatting message: \"" + id + "\", using " + (defaultMessage ? 'default message' : 'id') + " as fallback.", locale, messageDescriptor, e));
5531
5342
  }
5532
- if (isFinite(number)) {
5533
- return number;
5343
+ if (defaultMessage) {
5344
+ try {
5345
+ var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts);
5346
+ return formatter.format(values);
5347
+ }
5348
+ catch (e) {
5349
+ onError(new MessageFormatError("Error formatting the default message for: \"" + id + "\", rendering message verbatim", locale, messageDescriptor, e));
5350
+ }
5534
5351
  }
5535
- var integer = Math.floor(Math.abs(number));
5536
- if (number < 0) {
5537
- integer = -integer;
5352
+ if (typeof message === 'string') {
5353
+ return message;
5538
5354
  }
5539
- if (SameValue(integer, -0)) {
5540
- return 0;
5355
+ if (typeof defaultMessage === 'string') {
5356
+ return defaultMessage;
5541
5357
  }
5542
- return integer;
5358
+ return id;
5543
5359
  }
5544
- /**
5545
- * https://tc39.es/ecma262/#sec-timeclip
5546
- * @param time
5547
- */
5548
- function TimeClip(time) {
5549
- if (!isFinite(time)) {
5550
- return NaN;
5551
- }
5552
- if (Math.abs(time) > 8.64 * 1e15) {
5553
- return NaN;
5360
+
5361
+ var DATE_TIME_FORMAT_OPTIONS = [
5362
+ 'localeMatcher',
5363
+ 'formatMatcher',
5364
+ 'timeZone',
5365
+ 'hour12',
5366
+ 'weekday',
5367
+ 'era',
5368
+ 'year',
5369
+ 'month',
5370
+ 'day',
5371
+ 'hour',
5372
+ 'minute',
5373
+ 'second',
5374
+ 'timeZoneName',
5375
+ 'hourCycle',
5376
+ 'dateStyle',
5377
+ 'timeStyle',
5378
+ 'calendar',
5379
+ // 'dayPeriod',
5380
+ 'numberingSystem',
5381
+ ];
5382
+ function getFormatter$2(_a, type, getDateTimeFormat, options) {
5383
+ var locale = _a.locale, formats = _a.formats, onError = _a.onError, timeZone = _a.timeZone;
5384
+ if (options === void 0) { options = {}; }
5385
+ var format = options.format;
5386
+ var defaults = __assign(__assign({}, (timeZone && { timeZone: timeZone })), (format && getNamedFormat(formats, type, format, onError)));
5387
+ var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS,
5388
+ // @ts-expect-error es2020 has a lot stuff from es2021 bleed in
5389
+ defaults);
5390
+ if (type === 'time' &&
5391
+ !filteredOptions.hour &&
5392
+ !filteredOptions.minute &&
5393
+ !filteredOptions.second &&
5394
+ !filteredOptions.timeStyle &&
5395
+ !filteredOptions.dateStyle) {
5396
+ // Add default formatting options if hour, minute, or second isn't defined.
5397
+ filteredOptions = __assign(__assign({}, filteredOptions), { hour: 'numeric', minute: 'numeric' });
5554
5398
  }
5555
- return ToInteger(time);
5399
+ return getDateTimeFormat(locale, filteredOptions);
5556
5400
  }
5557
- /**
5558
- * https://tc39.es/ecma262/#sec-toobject
5559
- * @param arg
5560
- */
5561
- function ToObject(arg) {
5562
- if (arg == null) {
5563
- throw new TypeError('undefined/null cannot be converted to object');
5401
+ function formatDate(config, getDateTimeFormat) {
5402
+ var _a = [];
5403
+ for (var _i = 2; _i < arguments.length; _i++) {
5404
+ _a[_i - 2] = arguments[_i];
5564
5405
  }
5565
- return Object(arg);
5566
- }
5567
- /**
5568
- * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-samevalue
5569
- * @param x
5570
- * @param y
5571
- */
5572
- function SameValue(x, y) {
5573
- if (Object.is) {
5574
- return Object.is(x, y);
5406
+ var value = _a[0], _b = _a[1], options = _b === void 0 ? {} : _b;
5407
+ var date = typeof value === 'string' ? new Date(value || 0) : value;
5408
+ try {
5409
+ return getFormatter$2(config, 'date', getDateTimeFormat, options).format(date);
5575
5410
  }
5576
- // SameValue algorithm
5577
- if (x === y) {
5578
- // Steps 1-5, 7-10
5579
- // Steps 6.b-6.e: +0 != -0
5580
- return x !== 0 || 1 / x === 1 / y;
5411
+ catch (e) {
5412
+ config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting date.', e));
5581
5413
  }
5582
- // Step 6.a: NaN == NaN
5583
- return x !== x && y !== y;
5584
- }
5585
- /**
5586
- * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-arraycreate
5587
- * @param len
5588
- */
5589
- function ArrayCreate(len) {
5590
- return new Array(len);
5591
- }
5592
- /**
5593
- * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-hasownproperty
5594
- * @param o
5595
- * @param prop
5596
- */
5597
- function HasOwnProperty(o, prop) {
5598
- return Object.prototype.hasOwnProperty.call(o, prop);
5414
+ return String(date);
5599
5415
  }
5600
- /**
5601
- * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-type
5602
- * @param x
5603
- */
5604
- function Type(x) {
5605
- if (x === null) {
5606
- return 'Null';
5607
- }
5608
- if (typeof x === 'undefined') {
5609
- return 'Undefined';
5610
- }
5611
- if (typeof x === 'function' || typeof x === 'object') {
5612
- return 'Object';
5416
+ function formatTime(config, getDateTimeFormat) {
5417
+ var _a = [];
5418
+ for (var _i = 2; _i < arguments.length; _i++) {
5419
+ _a[_i - 2] = arguments[_i];
5613
5420
  }
5614
- if (typeof x === 'number') {
5615
- return 'Number';
5421
+ var value = _a[0], _b = _a[1], options = _b === void 0 ? {} : _b;
5422
+ var date = typeof value === 'string' ? new Date(value || 0) : value;
5423
+ try {
5424
+ return getFormatter$2(config, 'time', getDateTimeFormat, options).format(date);
5616
5425
  }
5617
- if (typeof x === 'boolean') {
5618
- return 'Boolean';
5426
+ catch (e) {
5427
+ config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting time.', e));
5619
5428
  }
5620
- if (typeof x === 'string') {
5621
- return 'String';
5429
+ return String(date);
5430
+ }
5431
+ function formatDateTimeRange(config, getDateTimeFormat) {
5432
+ var _a = [];
5433
+ for (var _i = 2; _i < arguments.length; _i++) {
5434
+ _a[_i - 2] = arguments[_i];
5622
5435
  }
5623
- if (typeof x === 'symbol') {
5624
- return 'Symbol';
5436
+ var from = _a[0], to = _a[1], _b = _a[2], options = _b === void 0 ? {} : _b;
5437
+ var timeZone = config.timeZone, locale = config.locale, onError = config.onError;
5438
+ var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, timeZone ? { timeZone: timeZone } : {});
5439
+ try {
5440
+ return getDateTimeFormat(locale, filteredOptions).formatRange(from, to);
5625
5441
  }
5626
- if (typeof x === 'bigint') {
5627
- return 'BigInt';
5628
- }
5629
- }
5630
- var MS_PER_DAY = 86400000;
5631
- /**
5632
- * https://www.ecma-international.org/ecma-262/11.0/index.html#eqn-modulo
5633
- * @param x
5634
- * @param y
5635
- * @return k of the same sign as y
5636
- */
5637
- function mod(x, y) {
5638
- return x - Math.floor(x / y) * y;
5639
- }
5640
- /**
5641
- * https://tc39.es/ecma262/#eqn-Day
5642
- * @param t
5643
- */
5644
- function Day(t) {
5645
- return Math.floor(t / MS_PER_DAY);
5646
- }
5647
- /**
5648
- * https://tc39.es/ecma262/#sec-week-day
5649
- * @param t
5650
- */
5651
- function WeekDay(t) {
5652
- return mod(Day(t) + 4, 7);
5653
- }
5654
- /**
5655
- * https://tc39.es/ecma262/#sec-year-number
5656
- * @param y
5657
- */
5658
- function DayFromYear(y) {
5659
- return Date.UTC(y, 0) / MS_PER_DAY;
5660
- }
5661
- /**
5662
- * https://tc39.es/ecma262/#sec-year-number
5663
- * @param y
5664
- */
5665
- function TimeFromYear(y) {
5666
- return Date.UTC(y, 0);
5667
- }
5668
- /**
5669
- * https://tc39.es/ecma262/#sec-year-number
5670
- * @param t
5671
- */
5672
- function YearFromTime(t) {
5673
- return new Date(t).getUTCFullYear();
5674
- }
5675
- function DaysInYear(y) {
5676
- if (y % 4 !== 0) {
5677
- return 365;
5678
- }
5679
- if (y % 100 !== 0) {
5680
- return 366;
5681
- }
5682
- if (y % 400 !== 0) {
5683
- return 365;
5684
- }
5685
- return 366;
5686
- }
5687
- function DayWithinYear(t) {
5688
- return Day(t) - DayFromYear(YearFromTime(t));
5689
- }
5690
- function InLeapYear(t) {
5691
- return DaysInYear(YearFromTime(t)) === 365 ? 0 : 1;
5692
- }
5693
- /**
5694
- * https://tc39.es/ecma262/#sec-month-number
5695
- * @param t
5696
- */
5697
- function MonthFromTime(t) {
5698
- var dwy = DayWithinYear(t);
5699
- var leap = InLeapYear(t);
5700
- if (dwy >= 0 && dwy < 31) {
5701
- return 0;
5702
- }
5703
- if (dwy < 59 + leap) {
5704
- return 1;
5705
- }
5706
- if (dwy < 90 + leap) {
5707
- return 2;
5708
- }
5709
- if (dwy < 120 + leap) {
5710
- return 3;
5711
- }
5712
- if (dwy < 151 + leap) {
5713
- return 4;
5714
- }
5715
- if (dwy < 181 + leap) {
5716
- return 5;
5717
- }
5718
- if (dwy < 212 + leap) {
5719
- return 6;
5720
- }
5721
- if (dwy < 243 + leap) {
5722
- return 7;
5723
- }
5724
- if (dwy < 273 + leap) {
5725
- return 8;
5726
- }
5727
- if (dwy < 304 + leap) {
5728
- return 9;
5729
- }
5730
- if (dwy < 334 + leap) {
5731
- return 10;
5732
- }
5733
- if (dwy < 365 + leap) {
5734
- return 11;
5735
- }
5736
- throw new Error('Invalid time');
5737
- }
5738
- function DateFromTime(t) {
5739
- var dwy = DayWithinYear(t);
5740
- var mft = MonthFromTime(t);
5741
- var leap = InLeapYear(t);
5742
- if (mft === 0) {
5743
- return dwy + 1;
5744
- }
5745
- if (mft === 1) {
5746
- return dwy - 30;
5747
- }
5748
- if (mft === 2) {
5749
- return dwy - 58 - leap;
5750
- }
5751
- if (mft === 3) {
5752
- return dwy - 89 - leap;
5753
- }
5754
- if (mft === 4) {
5755
- return dwy - 119 - leap;
5756
- }
5757
- if (mft === 5) {
5758
- return dwy - 150 - leap;
5759
- }
5760
- if (mft === 6) {
5761
- return dwy - 180 - leap;
5762
- }
5763
- if (mft === 7) {
5764
- return dwy - 211 - leap;
5765
- }
5766
- if (mft === 8) {
5767
- return dwy - 242 - leap;
5768
- }
5769
- if (mft === 9) {
5770
- return dwy - 272 - leap;
5771
- }
5772
- if (mft === 10) {
5773
- return dwy - 303 - leap;
5774
- }
5775
- if (mft === 11) {
5776
- return dwy - 333 - leap;
5777
- }
5778
- throw new Error('Invalid time');
5779
- }
5780
- var HOURS_PER_DAY = 24;
5781
- var MINUTES_PER_HOUR = 60;
5782
- var SECONDS_PER_MINUTE = 60;
5783
- var MS_PER_SECOND = 1e3;
5784
- var MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE;
5785
- var MS_PER_HOUR = MS_PER_MINUTE * MINUTES_PER_HOUR;
5786
- function HourFromTime(t) {
5787
- return mod(Math.floor(t / MS_PER_HOUR), HOURS_PER_DAY);
5788
- }
5789
- function MinFromTime(t) {
5790
- return mod(Math.floor(t / MS_PER_MINUTE), MINUTES_PER_HOUR);
5791
- }
5792
- function SecFromTime(t) {
5793
- return mod(Math.floor(t / MS_PER_SECOND), SECONDS_PER_MINUTE);
5794
- }
5795
- function IsCallable(fn) {
5796
- return typeof fn === 'function';
5797
- }
5798
- /**
5799
- * The abstract operation OrdinaryHasInstance implements
5800
- * the default algorithm for determining if an object O
5801
- * inherits from the instance object inheritance path
5802
- * provided by constructor C.
5803
- * @param C class
5804
- * @param O object
5805
- * @param internalSlots internalSlots
5806
- */
5807
- function OrdinaryHasInstance(C, O, internalSlots) {
5808
- if (!IsCallable(C)) {
5809
- return false;
5810
- }
5811
- if (internalSlots === null || internalSlots === void 0 ? void 0 : internalSlots.boundTargetFunction) {
5812
- var BC = internalSlots === null || internalSlots === void 0 ? void 0 : internalSlots.boundTargetFunction;
5813
- return O instanceof BC;
5814
- }
5815
- if (typeof O !== 'object') {
5816
- return false;
5817
- }
5818
- var P = C.prototype;
5819
- if (typeof P !== 'object') {
5820
- throw new TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.');
5821
- }
5822
- return Object.prototype.isPrototypeOf.call(P, O);
5823
- }
5824
- function msFromTime(t) {
5825
- return mod(t, MS_PER_SECOND);
5826
- }
5827
-
5828
- /**
5829
- * https://tc39.es/ecma402/#sec-coerceoptionstoobject
5830
- * @param options
5831
- * @returns
5832
- */
5833
- function CoerceOptionsToObject(options) {
5834
- if (typeof options === 'undefined') {
5835
- return Object.create(null);
5836
- }
5837
- return ToObject(options);
5838
- }
5839
-
5840
- function DefaultNumberOption(val, min, max, fallback) {
5841
- if (val !== undefined) {
5842
- val = Number(val);
5843
- if (isNaN(val) || val < min || val > max) {
5844
- throw new RangeError(val + " is outside of range [" + min + ", " + max + "]");
5845
- }
5846
- return Math.floor(val);
5847
- }
5848
- return fallback;
5849
- }
5850
-
5851
- /**
5852
- * https://tc39.es/ecma402/#sec-getnumberoption
5853
- * @param options
5854
- * @param property
5855
- * @param min
5856
- * @param max
5857
- * @param fallback
5858
- */
5859
- function GetNumberOption(options, property, minimum, maximum, fallback) {
5860
- var val = options[property];
5861
- // @ts-expect-error
5862
- return DefaultNumberOption(val, minimum, maximum, fallback);
5863
- }
5864
-
5865
- /**
5866
- * https://tc39.es/ecma402/#sec-getoption
5867
- * @param opts
5868
- * @param prop
5869
- * @param type
5870
- * @param values
5871
- * @param fallback
5872
- */
5873
- function GetOption(opts, prop, type, values, fallback) {
5874
- if (typeof opts !== 'object') {
5875
- throw new TypeError('Options must be an object');
5876
- }
5877
- var value = opts[prop];
5878
- if (value !== undefined) {
5879
- if (type !== 'boolean' && type !== 'string') {
5880
- throw new TypeError('invalid type');
5881
- }
5882
- if (type === 'boolean') {
5883
- value = Boolean(value);
5884
- }
5885
- if (type === 'string') {
5886
- value = ToString(value);
5887
- }
5888
- if (values !== undefined && !values.filter(function (val) { return val == value; }).length) {
5889
- throw new RangeError(value + " is not within " + values.join(', '));
5890
- }
5891
- return value;
5892
- }
5893
- return fallback;
5894
- }
5895
-
5896
- /**
5897
- * https://tc39.es/ecma402/#sec-getoptionsobject
5898
- * @param options
5899
- * @returns
5900
- */
5901
- function GetOptionsObject(options) {
5902
- if (typeof options === 'undefined') {
5903
- return Object.create(null);
5904
- }
5905
- if (typeof options === 'object') {
5906
- return options;
5907
- }
5908
- throw new TypeError('Options must be an object');
5909
- }
5910
-
5911
- /**
5912
- * https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
5913
- */
5914
- var SANCTIONED_UNITS = [
5915
- 'angle-degree',
5916
- 'area-acre',
5917
- 'area-hectare',
5918
- 'concentr-percent',
5919
- 'digital-bit',
5920
- 'digital-byte',
5921
- 'digital-gigabit',
5922
- 'digital-gigabyte',
5923
- 'digital-kilobit',
5924
- 'digital-kilobyte',
5925
- 'digital-megabit',
5926
- 'digital-megabyte',
5927
- 'digital-petabyte',
5928
- 'digital-terabit',
5929
- 'digital-terabyte',
5930
- 'duration-day',
5931
- 'duration-hour',
5932
- 'duration-millisecond',
5933
- 'duration-minute',
5934
- 'duration-month',
5935
- 'duration-second',
5936
- 'duration-week',
5937
- 'duration-year',
5938
- 'length-centimeter',
5939
- 'length-foot',
5940
- 'length-inch',
5941
- 'length-kilometer',
5942
- 'length-meter',
5943
- 'length-mile-scandinavian',
5944
- 'length-mile',
5945
- 'length-millimeter',
5946
- 'length-yard',
5947
- 'mass-gram',
5948
- 'mass-kilogram',
5949
- 'mass-ounce',
5950
- 'mass-pound',
5951
- 'mass-stone',
5952
- 'temperature-celsius',
5953
- 'temperature-fahrenheit',
5954
- 'volume-fluid-ounce',
5955
- 'volume-gallon',
5956
- 'volume-liter',
5957
- 'volume-milliliter',
5958
- ];
5959
- // In CLDR, the unit name always follows the form `namespace-unit` pattern.
5960
- // For example: `digital-bit` instead of `bit`. This function removes the namespace prefix.
5961
- function removeUnitNamespace(unit) {
5962
- return unit.slice(unit.indexOf('-') + 1);
5963
- }
5964
- /**
5965
- * https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
5966
- */
5967
- var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace);
5968
- /**
5969
- * https://tc39.es/ecma402/#sec-issanctionedsimpleunitidentifier
5970
- */
5971
- function IsSanctionedSimpleUnitIdentifier(unitIdentifier) {
5972
- return SIMPLE_UNITS.indexOf(unitIdentifier) > -1;
5973
- }
5974
-
5975
- /**
5976
- * https://tc39.es/ecma402/#sec-isvalidtimezonename
5977
- * @param tz
5978
- * @param implDetails implementation details
5979
- */
5980
- function IsValidTimeZoneName(tz, _a) {
5981
- var tzData = _a.tzData, uppercaseLinks = _a.uppercaseLinks;
5982
- var uppercasedTz = tz.toUpperCase();
5983
- var zoneNames = new Set();
5984
- var linkNames = new Set();
5985
- Object.keys(tzData)
5986
- .map(function (z) { return z.toUpperCase(); })
5987
- .forEach(function (z) { return zoneNames.add(z); });
5988
- Object.keys(uppercaseLinks).forEach(function (linkName) {
5989
- linkNames.add(linkName.toUpperCase());
5990
- zoneNames.add(uppercaseLinks[linkName].toUpperCase());
5991
- });
5992
- return zoneNames.has(uppercasedTz) || linkNames.has(uppercasedTz);
5993
- }
5994
-
5995
- /**
5996
- * This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
5997
- * @param str string to convert
5998
- */
5999
- function toUpperCase(str) {
6000
- return str.replace(/([a-z])/g, function (_, c) { return c.toUpperCase(); });
6001
- }
6002
- var NOT_A_Z_REGEX = /[^A-Z]/;
6003
- /**
6004
- * https://tc39.es/ecma402/#sec-iswellformedcurrencycode
6005
- */
6006
- function IsWellFormedCurrencyCode(currency) {
6007
- currency = toUpperCase(currency);
6008
- if (currency.length !== 3) {
6009
- return false;
6010
- }
6011
- if (NOT_A_Z_REGEX.test(currency)) {
6012
- return false;
6013
- }
6014
- return true;
6015
- }
6016
-
6017
- /**
6018
- * This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
6019
- * @param str string to convert
6020
- */
6021
- function toLowerCase(str) {
6022
- return str.replace(/([A-Z])/g, function (_, c) { return c.toLowerCase(); });
6023
- }
6024
- /**
6025
- * https://tc39.es/ecma402/#sec-iswellformedunitidentifier
6026
- * @param unit
6027
- */
6028
- function IsWellFormedUnitIdentifier(unit) {
6029
- unit = toLowerCase(unit);
6030
- if (IsSanctionedSimpleUnitIdentifier(unit)) {
6031
- return true;
6032
- }
6033
- var units = unit.split('-per-');
6034
- if (units.length !== 2) {
6035
- return false;
6036
- }
6037
- var numerator = units[0], denominator = units[1];
6038
- if (!IsSanctionedSimpleUnitIdentifier(numerator) ||
6039
- !IsSanctionedSimpleUnitIdentifier(denominator)) {
6040
- return false;
6041
- }
6042
- return true;
6043
- }
6044
-
6045
- /**
6046
- * Cannot do Math.log(x) / Math.log(10) bc if IEEE floating point issue
6047
- * @param x number
6048
- */
6049
- function getMagnitude(x) {
6050
- // Cannot count string length via Number.toString because it may use scientific notation
6051
- // for very small or very large numbers.
6052
- return Math.floor(Math.log(x) * Math.LOG10E);
6053
- }
6054
- function repeat(s, times) {
6055
- if (typeof s.repeat === 'function') {
6056
- return s.repeat(times);
6057
- }
6058
- var arr = new Array(times);
6059
- for (var i = 0; i < arr.length; i++) {
6060
- arr[i] = s;
6061
- }
6062
- return arr.join('');
6063
- }
6064
- function setInternalSlot(map, pl, field, value) {
6065
- if (!map.get(pl)) {
6066
- map.set(pl, Object.create(null));
6067
- }
6068
- var slots = map.get(pl);
6069
- slots[field] = value;
6070
- }
6071
- function setMultiInternalSlots(map, pl, props) {
6072
- for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
6073
- var k = _a[_i];
6074
- setInternalSlot(map, pl, k, props[k]);
6075
- }
6076
- }
6077
- function getInternalSlot(map, pl, field) {
6078
- return getMultiInternalSlots(map, pl, field)[field];
6079
- }
6080
- function getMultiInternalSlots(map, pl) {
6081
- var fields = [];
6082
- for (var _i = 2; _i < arguments.length; _i++) {
6083
- fields[_i - 2] = arguments[_i];
6084
- }
6085
- var slots = map.get(pl);
6086
- if (!slots) {
6087
- throw new TypeError(pl + " InternalSlot has not been initialized");
6088
- }
6089
- return fields.reduce(function (all, f) {
6090
- all[f] = slots[f];
6091
- return all;
6092
- }, Object.create(null));
6093
- }
6094
- function isLiteralPart(patternPart) {
6095
- return patternPart.type === 'literal';
6096
- }
6097
- /*
6098
- 17 ECMAScript Standard Built-in Objects:
6099
- Every built-in Function object, including constructors, that is not
6100
- identified as an anonymous function has a name property whose value
6101
- is a String.
6102
-
6103
- Unless otherwise specified, the name property of a built-in Function
6104
- object, if it exists, has the attributes { [[Writable]]: false,
6105
- [[Enumerable]]: false, [[Configurable]]: true }.
6106
- */
6107
- function defineProperty(target, name, _a) {
6108
- var value = _a.value;
6109
- Object.defineProperty(target, name, {
6110
- configurable: true,
6111
- enumerable: false,
6112
- writable: true,
6113
- value: value,
6114
- });
6115
- }
6116
- var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
6117
- function invariant(condition, message, Err) {
6118
- if (Err === void 0) { Err = Error; }
6119
- if (!condition) {
6120
- throw new Err(message);
6121
- }
6122
- }
6123
-
6124
- /**
6125
- * The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
6126
- * number of the given magnitude (power of ten of the most significant digit) according to the
6127
- * locale and the desired notation (scientific, engineering, or compact).
6128
- */
6129
- function ComputeExponentForMagnitude(numberFormat, magnitude, _a) {
6130
- var getInternalSlots = _a.getInternalSlots;
6131
- var internalSlots = getInternalSlots(numberFormat);
6132
- var notation = internalSlots.notation, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
6133
- switch (notation) {
6134
- case 'standard':
6135
- return 0;
6136
- case 'scientific':
6137
- return magnitude;
6138
- case 'engineering':
6139
- return Math.floor(magnitude / 3) * 3;
6140
- default: {
6141
- // Let exponent be an implementation- and locale-dependent (ILD) integer by which to scale a
6142
- // number of the given magnitude in compact notation for the current locale.
6143
- var compactDisplay = internalSlots.compactDisplay, style = internalSlots.style, currencyDisplay = internalSlots.currencyDisplay;
6144
- var thresholdMap = void 0;
6145
- if (style === 'currency' && currencyDisplay !== 'name') {
6146
- var currency = dataLocaleData.numbers.currency[numberingSystem] ||
6147
- dataLocaleData.numbers.currency[dataLocaleData.numbers.nu[0]];
6148
- thresholdMap = currency.short;
6149
- }
6150
- else {
6151
- var decimal = dataLocaleData.numbers.decimal[numberingSystem] ||
6152
- dataLocaleData.numbers.decimal[dataLocaleData.numbers.nu[0]];
6153
- thresholdMap = compactDisplay === 'long' ? decimal.long : decimal.short;
6154
- }
6155
- if (!thresholdMap) {
6156
- return 0;
6157
- }
6158
- var num = String(Math.pow(10, magnitude));
6159
- var thresholds = Object.keys(thresholdMap); // TODO: this can be pre-processed
6160
- if (num < thresholds[0]) {
6161
- return 0;
6162
- }
6163
- if (num > thresholds[thresholds.length - 1]) {
6164
- return thresholds[thresholds.length - 1].length - 1;
6165
- }
6166
- var i = thresholds.indexOf(num);
6167
- if (i === -1) {
6168
- return 0;
6169
- }
6170
- // See https://unicode.org/reports/tr35/tr35-numbers.html#Compact_Number_Formats
6171
- // Special handling if the pattern is precisely `0`.
6172
- var magnitudeKey = thresholds[i];
6173
- // TODO: do we need to handle plural here?
6174
- var compactPattern = thresholdMap[magnitudeKey].other;
6175
- if (compactPattern === '0') {
6176
- return 0;
6177
- }
6178
- // Example: in zh-TW, `10000000` maps to `0000萬`. So we need to return 8 - 4 = 4 here.
6179
- return (magnitudeKey.length -
6180
- thresholdMap[magnitudeKey].other.match(/0+/)[0].length);
6181
- }
6182
- }
6183
- }
6184
-
6185
- function ToRawPrecision(x, minPrecision, maxPrecision) {
6186
- var p = maxPrecision;
6187
- var m;
6188
- var e;
6189
- var xFinal;
6190
- if (x === 0) {
6191
- m = repeat('0', p);
6192
- e = 0;
6193
- xFinal = 0;
6194
- }
6195
- else {
6196
- var xToString = x.toString();
6197
- // If xToString is formatted as scientific notation, the number is either very small or very
6198
- // large. If the precision of the formatted string is lower that requested max precision, we
6199
- // should still infer them from the formatted string, otherwise the formatted result might have
6200
- // precision loss (e.g. 1e41 will not have 0 in every trailing digits).
6201
- var xToStringExponentIndex = xToString.indexOf('e');
6202
- var _a = xToString.split('e'), xToStringMantissa = _a[0], xToStringExponent = _a[1];
6203
- var xToStringMantissaWithoutDecimalPoint = xToStringMantissa.replace('.', '');
6204
- if (xToStringExponentIndex >= 0 &&
6205
- xToStringMantissaWithoutDecimalPoint.length <= p) {
6206
- e = +xToStringExponent;
6207
- m =
6208
- xToStringMantissaWithoutDecimalPoint +
6209
- repeat('0', p - xToStringMantissaWithoutDecimalPoint.length);
6210
- xFinal = x;
6211
- }
6212
- else {
6213
- e = getMagnitude(x);
6214
- var decimalPlaceOffset = e - p + 1;
6215
- // n is the integer containing the required precision digits. To derive the formatted string,
6216
- // we will adjust its decimal place in the logic below.
6217
- var n = Math.round(adjustDecimalPlace(x, decimalPlaceOffset));
6218
- // The rounding caused the change of magnitude, so we should increment `e` by 1.
6219
- if (adjustDecimalPlace(n, p - 1) >= 10) {
6220
- e = e + 1;
6221
- // Divide n by 10 to swallow one precision.
6222
- n = Math.floor(n / 10);
6223
- }
6224
- m = n.toString();
6225
- // Equivalent of n * 10 ** (e - p + 1)
6226
- xFinal = adjustDecimalPlace(n, p - 1 - e);
6227
- }
6228
- }
6229
- var int;
6230
- if (e >= p - 1) {
6231
- m = m + repeat('0', e - p + 1);
6232
- int = e + 1;
6233
- }
6234
- else if (e >= 0) {
6235
- m = m.slice(0, e + 1) + "." + m.slice(e + 1);
6236
- int = e + 1;
6237
- }
6238
- else {
6239
- m = "0." + repeat('0', -e - 1) + m;
6240
- int = 1;
6241
- }
6242
- if (m.indexOf('.') >= 0 && maxPrecision > minPrecision) {
6243
- var cut = maxPrecision - minPrecision;
6244
- while (cut > 0 && m[m.length - 1] === '0') {
6245
- m = m.slice(0, -1);
6246
- cut--;
6247
- }
6248
- if (m[m.length - 1] === '.') {
6249
- m = m.slice(0, -1);
6250
- }
6251
- }
6252
- return { formattedString: m, roundedNumber: xFinal, integerDigitsCount: int };
6253
- // x / (10 ** magnitude), but try to preserve as much floating point precision as possible.
6254
- function adjustDecimalPlace(x, magnitude) {
6255
- return magnitude < 0 ? x * Math.pow(10, -magnitude) : x / Math.pow(10, magnitude);
6256
- }
6257
- }
6258
-
6259
- /**
6260
- * TODO: dedup with intl-pluralrules and support BigInt
6261
- * https://tc39.es/ecma402/#sec-torawfixed
6262
- * @param x a finite non-negative Number or BigInt
6263
- * @param minFraction and integer between 0 and 20
6264
- * @param maxFraction and integer between 0 and 20
6265
- */
6266
- function ToRawFixed(x, minFraction, maxFraction) {
6267
- var f = maxFraction;
6268
- var n = Math.round(x * Math.pow(10, f));
6269
- var xFinal = n / Math.pow(10, f);
6270
- // n is a positive integer, but it is possible to be greater than 1e21.
6271
- // In such case we will go the slow path.
6272
- // See also: https://tc39.es/ecma262/#sec-numeric-types-number-tostring
6273
- var m;
6274
- if (n < 1e21) {
6275
- m = n.toString();
6276
- }
6277
- else {
6278
- m = n.toString();
6279
- var _a = m.split('e'), mantissa = _a[0], exponent = _a[1];
6280
- m = mantissa.replace('.', '');
6281
- m = m + repeat('0', Math.max(+exponent - m.length + 1, 0));
6282
- }
6283
- var int;
6284
- if (f !== 0) {
6285
- var k = m.length;
6286
- if (k <= f) {
6287
- var z = repeat('0', f + 1 - k);
6288
- m = z + m;
6289
- k = f + 1;
6290
- }
6291
- var a = m.slice(0, k - f);
6292
- var b = m.slice(k - f);
6293
- m = a + "." + b;
6294
- int = a.length;
6295
- }
6296
- else {
6297
- int = m.length;
6298
- }
6299
- var cut = maxFraction - minFraction;
6300
- while (cut > 0 && m[m.length - 1] === '0') {
6301
- m = m.slice(0, -1);
6302
- cut--;
6303
- }
6304
- if (m[m.length - 1] === '.') {
6305
- m = m.slice(0, -1);
6306
- }
6307
- return { formattedString: m, roundedNumber: xFinal, integerDigitsCount: int };
6308
- }
6309
-
6310
- /**
6311
- * https://tc39.es/ecma402/#sec-formatnumberstring
6312
- */
6313
- function FormatNumericToString(intlObject, x) {
6314
- var isNegative = x < 0 || SameValue(x, -0);
6315
- if (isNegative) {
6316
- x = -x;
6317
- }
6318
- var result;
6319
- var rourndingType = intlObject.roundingType;
6320
- switch (rourndingType) {
6321
- case 'significantDigits':
6322
- result = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits);
6323
- break;
6324
- case 'fractionDigits':
6325
- result = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits);
6326
- break;
6327
- default:
6328
- result = ToRawPrecision(x, 1, 2);
6329
- if (result.integerDigitsCount > 1) {
6330
- result = ToRawFixed(x, 0, 0);
6331
- }
6332
- break;
6333
- }
6334
- x = result.roundedNumber;
6335
- var string = result.formattedString;
6336
- var int = result.integerDigitsCount;
6337
- var minInteger = intlObject.minimumIntegerDigits;
6338
- if (int < minInteger) {
6339
- var forwardZeros = repeat('0', minInteger - int);
6340
- string = forwardZeros + string;
6341
- }
6342
- if (isNegative) {
6343
- x = -x;
6344
- }
6345
- return { roundedNumber: x, formattedString: string };
6346
- }
6347
-
6348
- /**
6349
- * The abstract operation ComputeExponent computes an exponent (power of ten) by which to scale x
6350
- * according to the number formatting settings. It handles cases such as 999 rounding up to 1000,
6351
- * requiring a different exponent.
6352
- *
6353
- * NOT IN SPEC: it returns [exponent, magnitude].
6354
- */
6355
- function ComputeExponent(numberFormat, x, _a) {
6356
- var getInternalSlots = _a.getInternalSlots;
6357
- if (x === 0) {
6358
- return [0, 0];
6359
- }
6360
- if (x < 0) {
6361
- x = -x;
6362
- }
6363
- var magnitude = getMagnitude(x);
6364
- var exponent = ComputeExponentForMagnitude(numberFormat, magnitude, {
6365
- getInternalSlots: getInternalSlots,
6366
- });
6367
- // Preserve more precision by doing multiplication when exponent is negative.
6368
- x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
6369
- var formatNumberResult = FormatNumericToString(getInternalSlots(numberFormat), x);
6370
- if (formatNumberResult.roundedNumber === 0) {
6371
- return [exponent, magnitude];
6372
- }
6373
- var newMagnitude = getMagnitude(formatNumberResult.roundedNumber);
6374
- if (newMagnitude === magnitude - exponent) {
6375
- return [exponent, magnitude];
6376
- }
6377
- return [
6378
- ComputeExponentForMagnitude(numberFormat, magnitude + 1, {
6379
- getInternalSlots: getInternalSlots,
6380
- }),
6381
- magnitude + 1,
6382
- ];
6383
- }
6384
-
6385
- /**
6386
- * https://tc39.es/ecma402/#sec-currencydigits
6387
- */
6388
- function CurrencyDigits(c, _a) {
6389
- var currencyDigitsData = _a.currencyDigitsData;
6390
- return HasOwnProperty(currencyDigitsData, c)
6391
- ? currencyDigitsData[c]
6392
- : 2;
6393
- }
6394
-
6395
- var digitMapping = { "adlm": ["𞥐", "𞥑", "𞥒", "𞥓", "𞥔", "𞥕", "𞥖", "𞥗", "𞥘", "𞥙"], "ahom": ["𑜰", "𑜱", "𑜲", "𑜳", "𑜴", "𑜵", "𑜶", "𑜷", "𑜸", "𑜹"], "arab": ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"], "arabext": ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"], "bali": ["᭐", "᭑", "᭒", "᭓", "᭔", "᭕", "᭖", "᭗", "᭘", "᭙"], "beng": ["০", "১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯"], "bhks": ["𑱐", "𑱑", "𑱒", "𑱓", "𑱔", "𑱕", "𑱖", "𑱗", "𑱘", "𑱙"], "brah": ["𑁦", "𑁧", "𑁨", "𑁩", "𑁪", "𑁫", "𑁬", "𑁭", "𑁮", "𑁯"], "cakm": ["𑄶", "𑄷", "𑄸", "𑄹", "𑄺", "𑄻", "𑄼", "𑄽", "𑄾", "𑄿"], "cham": ["꩐", "꩑", "꩒", "꩓", "꩔", "꩕", "꩖", "꩗", "꩘", "꩙"], "deva": ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"], "diak": ["𑥐", "𑥑", "𑥒", "𑥓", "𑥔", "𑥕", "𑥖", "𑥗", "𑥘", "𑥙"], "fullwide": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], "gong": ["𑶠", "𑶡", "𑶢", "𑶣", "𑶤", "𑶥", "𑶦", "𑶧", "𑶨", "𑶩"], "gonm": ["𑵐", "𑵑", "𑵒", "𑵓", "𑵔", "𑵕", "𑵖", "𑵗", "𑵘", "𑵙"], "gujr": ["૦", "૧", "૨", "૩", "૪", "૫", "૬", "૭", "૮", "૯"], "guru": ["੦", "੧", "੨", "੩", "੪", "੫", "੬", "੭", "੮", "੯"], "hanidec": ["〇", "一", "二", "三", "四", "五", "六", "七", "八", "九"], "hmng": ["𖭐", "𖭑", "𖭒", "𖭓", "𖭔", "𖭕", "𖭖", "𖭗", "𖭘", "𖭙"], "hmnp": ["𞅀", "𞅁", "𞅂", "𞅃", "𞅄", "𞅅", "𞅆", "𞅇", "𞅈", "𞅉"], "java": ["꧐", "꧑", "꧒", "꧓", "꧔", "꧕", "꧖", "꧗", "꧘", "꧙"], "kali": ["꤀", "꤁", "꤂", "꤃", "꤄", "꤅", "꤆", "꤇", "꤈", "꤉"], "khmr": ["០", "១", "២", "៣", "៤", "៥", "៦", "៧", "៨", "៩"], "knda": ["೦", "೧", "೨", "೩", "೪", "೫", "೬", "೭", "೮", "೯"], "lana": ["᪀", "᪁", "᪂", "᪃", "᪄", "᪅", "᪆", "᪇", "᪈", "᪉"], "lanatham": ["᪐", "᪑", "᪒", "᪓", "᪔", "᪕", "᪖", "᪗", "᪘", "᪙"], "laoo": ["໐", "໑", "໒", "໓", "໔", "໕", "໖", "໗", "໘", "໙"], "lepc": ["᪐", "᪑", "᪒", "᪓", "᪔", "᪕", "᪖", "᪗", "᪘", "᪙"], "limb": ["᥆", "᥇", "᥈", "᥉", "᥊", "᥋", "᥌", "᥍", "᥎", "᥏"], "mathbold": ["𝟎", "𝟏", "𝟐", "𝟑", "𝟒", "𝟓", "𝟔", "𝟕", "𝟖", "𝟗"], "mathdbl": ["𝟘", "𝟙", "𝟚", "𝟛", "𝟜", "𝟝", "𝟞", "𝟟", "𝟠", "𝟡"], "mathmono": ["𝟶", "𝟷", "𝟸", "𝟹", "𝟺", "𝟻", "𝟼", "𝟽", "𝟾", "𝟿"], "mathsanb": ["𝟬", "𝟭", "𝟮", "𝟯", "𝟰", "𝟱", "𝟲", "𝟳", "𝟴", "𝟵"], "mathsans": ["𝟢", "𝟣", "𝟤", "𝟥", "𝟦", "𝟧", "𝟨", "𝟩", "𝟪", "𝟫"], "mlym": ["൦", "൧", "൨", "൩", "൪", "൫", "൬", "൭", "൮", "൯"], "modi": ["𑙐", "𑙑", "𑙒", "𑙓", "𑙔", "𑙕", "𑙖", "𑙗", "𑙘", "𑙙"], "mong": ["᠐", "᠑", "᠒", "᠓", "᠔", "᠕", "᠖", "᠗", "᠘", "᠙"], "mroo": ["𖩠", "𖩡", "𖩢", "𖩣", "𖩤", "𖩥", "𖩦", "𖩧", "𖩨", "𖩩"], "mtei": ["꯰", "꯱", "꯲", "꯳", "꯴", "꯵", "꯶", "꯷", "꯸", "꯹"], "mymr": ["၀", "၁", "၂", "၃", "၄", "၅", "၆", "၇", "၈", "၉"], "mymrshan": ["႐", "႑", "႒", "႓", "႔", "႕", "႖", "႗", "႘", "႙"], "mymrtlng": ["꧰", "꧱", "꧲", "꧳", "꧴", "꧵", "꧶", "꧷", "꧸", "꧹"], "newa": ["𑑐", "𑑑", "𑑒", "𑑓", "𑑔", "𑑕", "𑑖", "𑑗", "𑑘", "𑑙"], "nkoo": ["߀", "߁", "߂", "߃", "߄", "߅", "߆", "߇", "߈", "߉"], "olck": ["᱐", "᱑", "᱒", "᱓", "᱔", "᱕", "᱖", "᱗", "᱘", "᱙"], "orya": ["୦", "୧", "୨", "୩", "୪", "୫", "୬", "୭", "୮", "୯"], "osma": ["𐒠", "𐒡", "𐒢", "𐒣", "𐒤", "𐒥", "𐒦", "𐒧", "𐒨", "𐒩"], "rohg": ["𐴰", "𐴱", "𐴲", "𐴳", "𐴴", "𐴵", "𐴶", "𐴷", "𐴸", "𐴹"], "saur": ["꣐", "꣑", "꣒", "꣓", "꣔", "꣕", "꣖", "꣗", "꣘", "꣙"], "segment": ["🯰", "🯱", "🯲", "🯳", "🯴", "🯵", "🯶", "🯷", "🯸", "🯹"], "shrd": ["𑇐", "𑇑", "𑇒", "𑇓", "𑇔", "𑇕", "𑇖", "𑇗", "𑇘", "𑇙"], "sind": ["𑋰", "𑋱", "𑋲", "𑋳", "𑋴", "𑋵", "𑋶", "𑋷", "𑋸", "𑋹"], "sinh": ["෦", "෧", "෨", "෩", "෪", "෫", "෬", "෭", "෮", "෯"], "sora": ["𑃰", "𑃱", "𑃲", "𑃳", "𑃴", "𑃵", "𑃶", "𑃷", "𑃸", "𑃹"], "sund": ["᮰", "᮱", "᮲", "᮳", "᮴", "᮵", "᮶", "᮷", "᮸", "᮹"], "takr": ["𑛀", "𑛁", "𑛂", "𑛃", "𑛄", "𑛅", "𑛆", "𑛇", "𑛈", "𑛉"], "talu": ["᧐", "᧑", "᧒", "᧓", "᧔", "᧕", "᧖", "᧗", "᧘", "᧙"], "tamldec": ["௦", "௧", "௨", "௩", "௪", "௫", "௬", "௭", "௮", "௯"], "telu": ["౦", "౧", "౨", "౩", "౪", "౫", "౬", "౭", "౮", "౯"], "thai": ["๐", "๑", "๒", "๓", "๔", "๕", "๖", "๗", "๘", "๙"], "tibt": ["༠", "༡", "༢", "༣", "༤", "༥", "༦", "༧", "༨", "༩"], "tirh": ["𑓐", "𑓑", "𑓒", "𑓓", "𑓔", "𑓕", "𑓖", "𑓗", "𑓘", "𑓙"], "vaii": ["ᘠ", "ᘡ", "ᘢ", "ᘣ", "ᘤ", "ᘥ", "ᘦ", "ᘧ", "ᘨ", "ᘩ"], "wara": ["𑣠", "𑣡", "𑣢", "𑣣", "𑣤", "𑣥", "𑣦", "𑣧", "𑣨", "𑣩"], "wcho": ["𞋰", "𞋱", "𞋲", "𞋳", "𞋴", "𞋵", "𞋶", "𞋷", "𞋸", "𞋹"] };
6396
-
6397
- // @generated from regex-gen.ts
6398
- var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20BF\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC1\uFDFC\uFDFD\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDE8\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEE0-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF73\uDF80-\uDFD8\uDFE0-\uDFEB]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDD78\uDD7A-\uDDCB\uDDCD-\uDE53\uDE60-\uDE6D\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6\uDF00-\uDF92\uDF94-\uDFCA]/;
6399
-
6400
- // This is from: unicode-12.1.0/General_Category/Symbol/regex.js
6401
- // IE11 does not support unicode flag, otherwise this is just /\p{S}/u.
6402
- // /^\p{S}/u
6403
- var CARET_S_UNICODE_REGEX = new RegExp("^" + S_UNICODE_REGEX.source);
6404
- // /\p{S}$/u
6405
- var S_DOLLAR_UNICODE_REGEX = new RegExp(S_UNICODE_REGEX.source + "$");
6406
- var CLDR_NUMBER_PATTERN = /[#0](?:[\.,][#0]+)*/g;
6407
- function formatToParts(numberResult, data, pl, options) {
6408
- var sign = numberResult.sign, exponent = numberResult.exponent, magnitude = numberResult.magnitude;
6409
- var notation = options.notation, style = options.style, numberingSystem = options.numberingSystem;
6410
- var defaultNumberingSystem = data.numbers.nu[0];
6411
- // #region Part 1: partition and interpolate the CLDR number pattern.
6412
- // ----------------------------------------------------------
6413
- var compactNumberPattern = null;
6414
- if (notation === 'compact' && magnitude) {
6415
- compactNumberPattern = getCompactDisplayPattern(numberResult, pl, data, style, options.compactDisplay, options.currencyDisplay, numberingSystem);
6416
- }
6417
- // This is used multiple times
6418
- var nonNameCurrencyPart;
6419
- if (style === 'currency' && options.currencyDisplay !== 'name') {
6420
- var byCurrencyDisplay = data.currencies[options.currency];
6421
- if (byCurrencyDisplay) {
6422
- switch (options.currencyDisplay) {
6423
- case 'code':
6424
- nonNameCurrencyPart = options.currency;
6425
- break;
6426
- case 'symbol':
6427
- nonNameCurrencyPart = byCurrencyDisplay.symbol;
6428
- break;
6429
- default:
6430
- nonNameCurrencyPart = byCurrencyDisplay.narrow;
6431
- break;
6432
- }
6433
- }
6434
- else {
6435
- // Fallback for unknown currency
6436
- nonNameCurrencyPart = options.currency;
6437
- }
6438
- }
6439
- var numberPattern;
6440
- if (!compactNumberPattern) {
6441
- // Note: if the style is unit, or is currency and the currency display is name,
6442
- // its unit parts will be interpolated in part 2. So here we can fallback to decimal.
6443
- if (style === 'decimal' ||
6444
- style === 'unit' ||
6445
- (style === 'currency' && options.currencyDisplay === 'name')) {
6446
- // Shortcut for decimal
6447
- var decimalData = data.numbers.decimal[numberingSystem] ||
6448
- data.numbers.decimal[defaultNumberingSystem];
6449
- numberPattern = getPatternForSign(decimalData.standard, sign);
6450
- }
6451
- else if (style === 'currency') {
6452
- var currencyData = data.numbers.currency[numberingSystem] ||
6453
- data.numbers.currency[defaultNumberingSystem];
6454
- // We replace number pattern part with `0` for easier postprocessing.
6455
- numberPattern = getPatternForSign(currencyData[options.currencySign], sign);
6456
- }
6457
- else {
6458
- // percent
6459
- var percentPattern = data.numbers.percent[numberingSystem] ||
6460
- data.numbers.percent[defaultNumberingSystem];
6461
- numberPattern = getPatternForSign(percentPattern, sign);
6462
- }
6463
- }
6464
- else {
6465
- numberPattern = compactNumberPattern;
6466
- }
6467
- // Extract the decimal number pattern string. It looks like "#,##0,00", which will later be
6468
- // used to infer decimal group sizes.
6469
- var decimalNumberPattern = CLDR_NUMBER_PATTERN.exec(numberPattern)[0];
6470
- // Now we start to substitute patterns
6471
- // 1. replace strings like `0` and `#,##0.00` with `{0}`
6472
- // 2. unquote characters (invariant: the quoted characters does not contain the special tokens)
6473
- numberPattern = numberPattern
6474
- .replace(CLDR_NUMBER_PATTERN, '{0}')
6475
- .replace(/'(.)'/g, '$1');
6476
- // Handle currency spacing (both compact and non-compact).
6477
- if (style === 'currency' && options.currencyDisplay !== 'name') {
6478
- var currencyData = data.numbers.currency[numberingSystem] ||
6479
- data.numbers.currency[defaultNumberingSystem];
6480
- // See `currencySpacing` substitution rule in TR-35.
6481
- // Here we always assume the currencyMatch is "[:^S:]" and surroundingMatch is "[:digit:]".
6482
- //
6483
- // Example 1: for pattern "#,##0.00¤" with symbol "US$", we replace "¤" with the symbol,
6484
- // but insert an extra non-break space before the symbol, because "[:^S:]" matches "U" in
6485
- // "US$" and "[:digit:]" matches the latn numbering system digits.
6486
- //
6487
- // Example 2: for pattern "¤#,##0.00" with symbol "US$", there is no spacing between symbol
6488
- // and number, because `$` does not match "[:^S:]".
6489
- //
6490
- // Implementation note: here we do the best effort to infer the insertion.
6491
- // We also assume that `beforeInsertBetween` and `afterInsertBetween` will never be `;`.
6492
- var afterCurrency = currencyData.currencySpacing.afterInsertBetween;
6493
- if (afterCurrency && !S_DOLLAR_UNICODE_REGEX.test(nonNameCurrencyPart)) {
6494
- numberPattern = numberPattern.replace('¤{0}', "\u00A4" + afterCurrency + "{0}");
6495
- }
6496
- var beforeCurrency = currencyData.currencySpacing.beforeInsertBetween;
6497
- if (beforeCurrency && !CARET_S_UNICODE_REGEX.test(nonNameCurrencyPart)) {
6498
- numberPattern = numberPattern.replace('{0}¤', "{0}" + beforeCurrency + "\u00A4");
6499
- }
6500
- }
6501
- // The following tokens are special: `{0}`, `¤`, `%`, `-`, `+`, `{c:...}.
6502
- var numberPatternParts = numberPattern.split(/({c:[^}]+}|\{0\}|[¤%\-\+])/g);
6503
- var numberParts = [];
6504
- var symbols = data.numbers.symbols[numberingSystem] ||
6505
- data.numbers.symbols[defaultNumberingSystem];
6506
- for (var _i = 0, numberPatternParts_1 = numberPatternParts; _i < numberPatternParts_1.length; _i++) {
6507
- var part = numberPatternParts_1[_i];
6508
- if (!part) {
6509
- continue;
6510
- }
6511
- switch (part) {
6512
- case '{0}': {
6513
- // We only need to handle scientific and engineering notation here.
6514
- numberParts.push.apply(numberParts, paritionNumberIntoParts(symbols, numberResult, notation, exponent, numberingSystem,
6515
- // If compact number pattern exists, do not insert group separators.
6516
- !compactNumberPattern && options.useGrouping, decimalNumberPattern));
6517
- break;
6518
- }
6519
- case '-':
6520
- numberParts.push({ type: 'minusSign', value: symbols.minusSign });
6521
- break;
6522
- case '+':
6523
- numberParts.push({ type: 'plusSign', value: symbols.plusSign });
6524
- break;
6525
- case '%':
6526
- numberParts.push({ type: 'percentSign', value: symbols.percentSign });
6527
- break;
6528
- case '¤':
6529
- // Computed above when handling currency spacing.
6530
- numberParts.push({ type: 'currency', value: nonNameCurrencyPart });
6531
- break;
6532
- default:
6533
- if (/^\{c:/.test(part)) {
6534
- numberParts.push({
6535
- type: 'compact',
6536
- value: part.substring(3, part.length - 1),
6537
- });
6538
- }
6539
- else {
6540
- // literal
6541
- numberParts.push({ type: 'literal', value: part });
6542
- }
6543
- break;
6544
- }
6545
- }
6546
- // #endregion
6547
- // #region Part 2: interpolate unit pattern if necessary.
6548
- // ----------------------------------------------
6549
- switch (style) {
6550
- case 'currency': {
6551
- // `currencyDisplay: 'name'` has similar pattern handling as units.
6552
- if (options.currencyDisplay === 'name') {
6553
- var unitPattern = (data.numbers.currency[numberingSystem] ||
6554
- data.numbers.currency[defaultNumberingSystem]).unitPattern;
6555
- // Select plural
6556
- var unitName = void 0;
6557
- var currencyNameData = data.currencies[options.currency];
6558
- if (currencyNameData) {
6559
- unitName = selectPlural(pl, numberResult.roundedNumber * Math.pow(10, exponent), currencyNameData.displayName);
6560
- }
6561
- else {
6562
- // Fallback for unknown currency
6563
- unitName = options.currency;
6564
- }
6565
- // Do {0} and {1} substitution
6566
- var unitPatternParts = unitPattern.split(/(\{[01]\})/g);
6567
- var result = [];
6568
- for (var _a = 0, unitPatternParts_1 = unitPatternParts; _a < unitPatternParts_1.length; _a++) {
6569
- var part = unitPatternParts_1[_a];
6570
- switch (part) {
6571
- case '{0}':
6572
- result.push.apply(result, numberParts);
6573
- break;
6574
- case '{1}':
6575
- result.push({ type: 'currency', value: unitName });
6576
- break;
6577
- default:
6578
- if (part) {
6579
- result.push({ type: 'literal', value: part });
6580
- }
6581
- break;
6582
- }
6583
- }
6584
- return result;
6585
- }
6586
- else {
6587
- return numberParts;
6588
- }
6589
- }
6590
- case 'unit': {
6591
- var unit = options.unit, unitDisplay = options.unitDisplay;
6592
- var unitData = data.units.simple[unit];
6593
- var unitPattern = void 0;
6594
- if (unitData) {
6595
- // Simple unit pattern
6596
- unitPattern = selectPlural(pl, numberResult.roundedNumber * Math.pow(10, exponent), data.units.simple[unit][unitDisplay]);
6597
- }
6598
- else {
6599
- // See: http://unicode.org/reports/tr35/tr35-general.html#perUnitPatterns
6600
- // If cannot find unit in the simple pattern, it must be "per" compound pattern.
6601
- // Implementation note: we are not following TR-35 here because we need to format to parts!
6602
- var _b = unit.split('-per-'), numeratorUnit = _b[0], denominatorUnit = _b[1];
6603
- unitData = data.units.simple[numeratorUnit];
6604
- var numeratorUnitPattern = selectPlural(pl, numberResult.roundedNumber * Math.pow(10, exponent), data.units.simple[numeratorUnit][unitDisplay]);
6605
- var perUnitPattern = data.units.simple[denominatorUnit].perUnit[unitDisplay];
6606
- if (perUnitPattern) {
6607
- // perUnitPattern exists, combine it with numeratorUnitPattern
6608
- unitPattern = perUnitPattern.replace('{0}', numeratorUnitPattern);
6609
- }
6610
- else {
6611
- // get compoundUnit pattern (e.g. "{0} per {1}"), repalce {0} with numerator pattern and {1} with
6612
- // the denominator pattern in singular form.
6613
- var perPattern = data.units.compound.per[unitDisplay];
6614
- var denominatorPattern = selectPlural(pl, 1, data.units.simple[denominatorUnit][unitDisplay]);
6615
- unitPattern = unitPattern = perPattern
6616
- .replace('{0}', numeratorUnitPattern)
6617
- .replace('{1}', denominatorPattern.replace('{0}', ''));
6618
- }
6619
- }
6620
- var result = [];
6621
- // We need spacing around "{0}" because they are not treated as "unit" parts, but "literal".
6622
- for (var _c = 0, _d = unitPattern.split(/(\s*\{0\}\s*)/); _c < _d.length; _c++) {
6623
- var part = _d[_c];
6624
- var interpolateMatch = /^(\s*)\{0\}(\s*)$/.exec(part);
6625
- if (interpolateMatch) {
6626
- // Space before "{0}"
6627
- if (interpolateMatch[1]) {
6628
- result.push({ type: 'literal', value: interpolateMatch[1] });
6629
- }
6630
- // "{0}" itself
6631
- result.push.apply(result, numberParts);
6632
- // Space after "{0}"
6633
- if (interpolateMatch[2]) {
6634
- result.push({ type: 'literal', value: interpolateMatch[2] });
6635
- }
6636
- }
6637
- else if (part) {
6638
- result.push({ type: 'unit', value: part });
6639
- }
6640
- }
6641
- return result;
6642
- }
6643
- default:
6644
- return numberParts;
6645
- }
6646
- // #endregion
6647
- }
6648
- // A subset of https://tc39.es/ecma402/#sec-partitionnotationsubpattern
6649
- // Plus the exponent parts handling.
6650
- function paritionNumberIntoParts(symbols, numberResult, notation, exponent, numberingSystem, useGrouping,
6651
- /**
6652
- * This is the decimal number pattern without signs or symbols.
6653
- * It is used to infer the group size when `useGrouping` is true.
6654
- *
6655
- * A typical value looks like "#,##0.00" (primary group size is 3).
6656
- * Some locales like Hindi has secondary group size of 2 (e.g. "#,##,##0.00").
6657
- */
6658
- decimalNumberPattern) {
6659
- var result = [];
6660
- // eslint-disable-next-line prefer-const
6661
- var n = numberResult.formattedString, x = numberResult.roundedNumber;
6662
- if (isNaN(x)) {
6663
- return [{ type: 'nan', value: n }];
6664
- }
6665
- else if (!isFinite(x)) {
6666
- return [{ type: 'infinity', value: n }];
6667
- }
6668
- var digitReplacementTable = digitMapping[numberingSystem];
6669
- if (digitReplacementTable) {
6670
- n = n.replace(/\d/g, function (digit) { return digitReplacementTable[+digit] || digit; });
6671
- }
6672
- // TODO: Else use an implementation dependent algorithm to map n to the appropriate
6673
- // representation of n in the given numbering system.
6674
- var decimalSepIndex = n.indexOf('.');
6675
- var integer;
6676
- var fraction;
6677
- if (decimalSepIndex > 0) {
6678
- integer = n.slice(0, decimalSepIndex);
6679
- fraction = n.slice(decimalSepIndex + 1);
6680
- }
6681
- else {
6682
- integer = n;
6683
- }
6684
- // #region Grouping integer digits
6685
- // The weird compact and x >= 10000 check is to ensure consistency with Node.js and Chrome.
6686
- // Note that `de` does not have compact form for thousands, but Node.js does not insert grouping separator
6687
- // unless the rounded number is greater than 10000:
6688
- // NumberFormat('de', {notation: 'compact', compactDisplay: 'short'}).format(1234) //=> "1234"
6689
- // NumberFormat('de').format(1234) //=> "1.234"
6690
- if (useGrouping && (notation !== 'compact' || x >= 10000)) {
6691
- var groupSepSymbol = symbols.group;
6692
- var groups = [];
6693
- // > There may be two different grouping sizes: The primary grouping size used for the least
6694
- // > significant integer group, and the secondary grouping size used for more significant groups.
6695
- // > If a pattern contains multiple grouping separators, the interval between the last one and the
6696
- // > end of the integer defines the primary grouping size, and the interval between the last two
6697
- // > defines the secondary grouping size. All others are ignored.
6698
- var integerNumberPattern = decimalNumberPattern.split('.')[0];
6699
- var patternGroups = integerNumberPattern.split(',');
6700
- var primaryGroupingSize = 3;
6701
- var secondaryGroupingSize = 3;
6702
- if (patternGroups.length > 1) {
6703
- primaryGroupingSize = patternGroups[patternGroups.length - 1].length;
6704
- }
6705
- if (patternGroups.length > 2) {
6706
- secondaryGroupingSize = patternGroups[patternGroups.length - 2].length;
6707
- }
6708
- var i = integer.length - primaryGroupingSize;
6709
- if (i > 0) {
6710
- // Slice the least significant integer group
6711
- groups.push(integer.slice(i, i + primaryGroupingSize));
6712
- // Then iteratively push the more signicant groups
6713
- // TODO: handle surrogate pairs in some numbering system digits
6714
- for (i -= secondaryGroupingSize; i > 0; i -= secondaryGroupingSize) {
6715
- groups.push(integer.slice(i, i + secondaryGroupingSize));
6716
- }
6717
- groups.push(integer.slice(0, i + secondaryGroupingSize));
6718
- }
6719
- else {
6720
- groups.push(integer);
6721
- }
6722
- while (groups.length > 0) {
6723
- var integerGroup = groups.pop();
6724
- result.push({ type: 'integer', value: integerGroup });
6725
- if (groups.length > 0) {
6726
- result.push({ type: 'group', value: groupSepSymbol });
6727
- }
6728
- }
6729
- }
6730
- else {
6731
- result.push({ type: 'integer', value: integer });
6732
- }
6733
- // #endregion
6734
- if (fraction !== undefined) {
6735
- result.push({ type: 'decimal', value: symbols.decimal }, { type: 'fraction', value: fraction });
6736
- }
6737
- if ((notation === 'scientific' || notation === 'engineering') &&
6738
- isFinite(x)) {
6739
- result.push({ type: 'exponentSeparator', value: symbols.exponential });
6740
- if (exponent < 0) {
6741
- result.push({ type: 'exponentMinusSign', value: symbols.minusSign });
6742
- exponent = -exponent;
6743
- }
6744
- var exponentResult = ToRawFixed(exponent, 0, 0);
6745
- result.push({
6746
- type: 'exponentInteger',
6747
- value: exponentResult.formattedString,
6748
- });
6749
- }
6750
- return result;
6751
- }
6752
- function getPatternForSign(pattern, sign) {
6753
- if (pattern.indexOf(';') < 0) {
6754
- pattern = pattern + ";-" + pattern;
6755
- }
6756
- var _a = pattern.split(';'), zeroPattern = _a[0], negativePattern = _a[1];
6757
- switch (sign) {
6758
- case 0:
6759
- return zeroPattern;
6760
- case -1:
6761
- return negativePattern;
6762
- default:
6763
- return negativePattern.indexOf('-') >= 0
6764
- ? negativePattern.replace(/-/g, '+')
6765
- : "+" + zeroPattern;
6766
- }
6767
- }
6768
- // Find the CLDR pattern for compact notation based on the magnitude of data and style.
6769
- //
6770
- // Example return value: "¤ {c:laki}000;¤{c:laki} -0" (`sw` locale):
6771
- // - Notice the `{c:...}` token that wraps the compact literal.
6772
- // - The consecutive zeros are normalized to single zero to match CLDR_NUMBER_PATTERN.
6773
- //
6774
- // Returning null means the compact display pattern cannot be found.
6775
- function getCompactDisplayPattern(numberResult, pl, data, style, compactDisplay, currencyDisplay, numberingSystem) {
6776
- var _a;
6777
- var roundedNumber = numberResult.roundedNumber, sign = numberResult.sign, magnitude = numberResult.magnitude;
6778
- var magnitudeKey = String(Math.pow(10, magnitude));
6779
- var defaultNumberingSystem = data.numbers.nu[0];
6780
- var pattern;
6781
- if (style === 'currency' && currencyDisplay !== 'name') {
6782
- var byNumberingSystem = data.numbers.currency;
6783
- var currencyData = byNumberingSystem[numberingSystem] ||
6784
- byNumberingSystem[defaultNumberingSystem];
6785
- // NOTE: compact notation ignores currencySign!
6786
- var compactPluralRules = (_a = currencyData.short) === null || _a === void 0 ? void 0 : _a[magnitudeKey];
6787
- if (!compactPluralRules) {
6788
- return null;
6789
- }
6790
- pattern = selectPlural(pl, roundedNumber, compactPluralRules);
6791
- }
6792
- else {
6793
- var byNumberingSystem = data.numbers.decimal;
6794
- var byCompactDisplay = byNumberingSystem[numberingSystem] ||
6795
- byNumberingSystem[defaultNumberingSystem];
6796
- var compactPlaralRule = byCompactDisplay[compactDisplay][magnitudeKey];
6797
- if (!compactPlaralRule) {
6798
- return null;
6799
- }
6800
- pattern = selectPlural(pl, roundedNumber, compactPlaralRule);
6801
- }
6802
- // See https://unicode.org/reports/tr35/tr35-numbers.html#Compact_Number_Formats
6803
- // > If the value is precisely “0”, either explicit or defaulted, then the normal number format
6804
- // > pattern for that sort of object is supplied.
6805
- if (pattern === '0') {
6806
- return null;
6807
- }
6808
- pattern = getPatternForSign(pattern, sign)
6809
- // Extract compact literal from the pattern
6810
- .replace(/([^\s;\-\+\d¤]+)/g, '{c:$1}')
6811
- // We replace one or more zeros with a single zero so it matches `CLDR_NUMBER_PATTERN`.
6812
- .replace(/0+/, '0');
6813
- return pattern;
6814
- }
6815
- function selectPlural(pl, x, rules) {
6816
- return rules[pl.select(x)] || rules.other;
6817
- }
6818
-
6819
- /**
6820
- * https://tc39.es/ecma402/#sec-formatnumberstring
6821
- */
6822
- function PartitionNumberPattern(numberFormat, x, _a) {
6823
- var _b;
6824
- var getInternalSlots = _a.getInternalSlots;
6825
- var internalSlots = getInternalSlots(numberFormat);
6826
- var pl = internalSlots.pl, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
6827
- var symbols = dataLocaleData.numbers.symbols[numberingSystem] ||
6828
- dataLocaleData.numbers.symbols[dataLocaleData.numbers.nu[0]];
6829
- var magnitude = 0;
6830
- var exponent = 0;
6831
- var n;
6832
- if (isNaN(x)) {
6833
- n = symbols.nan;
6834
- }
6835
- else if (!isFinite(x)) {
6836
- n = symbols.infinity;
6837
- }
6838
- else {
6839
- if (internalSlots.style === 'percent') {
6840
- x *= 100;
6841
- }
6842
- ;
6843
- _b = ComputeExponent(numberFormat, x, {
6844
- getInternalSlots: getInternalSlots,
6845
- }), exponent = _b[0], magnitude = _b[1];
6846
- // Preserve more precision by doing multiplication when exponent is negative.
6847
- x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
6848
- var formatNumberResult = FormatNumericToString(internalSlots, x);
6849
- n = formatNumberResult.formattedString;
6850
- x = formatNumberResult.roundedNumber;
6851
- }
6852
- // Based on https://tc39.es/ecma402/#sec-getnumberformatpattern
6853
- // We need to do this before `x` is rounded.
6854
- var sign;
6855
- var signDisplay = internalSlots.signDisplay;
6856
- switch (signDisplay) {
6857
- case 'never':
6858
- sign = 0;
6859
- break;
6860
- case 'auto':
6861
- if (SameValue(x, 0) || x > 0 || isNaN(x)) {
6862
- sign = 0;
6863
- }
6864
- else {
6865
- sign = -1;
6866
- }
6867
- break;
6868
- case 'always':
6869
- if (SameValue(x, 0) || x > 0 || isNaN(x)) {
6870
- sign = 1;
6871
- }
6872
- else {
6873
- sign = -1;
6874
- }
6875
- break;
6876
- default:
6877
- // x === 0 -> x is 0 or x is -0
6878
- if (x === 0 || isNaN(x)) {
6879
- sign = 0;
6880
- }
6881
- else if (x > 0) {
6882
- sign = 1;
6883
- }
6884
- else {
6885
- sign = -1;
6886
- }
6887
- }
6888
- return formatToParts({ roundedNumber: x, formattedString: n, exponent: exponent, magnitude: magnitude, sign: sign }, internalSlots.dataLocaleData, pl, internalSlots);
6889
- }
6890
-
6891
- function FormatNumericToParts(nf, x, implDetails) {
6892
- var parts = PartitionNumberPattern(nf, x, implDetails);
6893
- var result = ArrayCreate(0);
6894
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
6895
- var part = parts_1[_i];
6896
- result.push({
6897
- type: part.type,
6898
- value: part.value,
6899
- });
6900
- }
6901
- return result;
6902
- }
6903
-
6904
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6905
-
6906
- function getDefaultExportFromCjs (x) {
6907
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
6908
- }
6909
-
6910
- function createCommonjsModule(fn, basedir, module) {
6911
- return module = {
6912
- path: basedir,
6913
- exports: {},
6914
- require: function (path, base) {
6915
- return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
6916
- }
6917
- }, fn(module, module.exports), module.exports;
6918
- }
6919
-
6920
- function getDefaultExportFromNamespaceIfPresent (n) {
6921
- return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
6922
- }
6923
-
6924
- function getDefaultExportFromNamespaceIfNotNamed (n) {
6925
- return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
6926
- }
6927
-
6928
- function getAugmentedNamespace(n) {
6929
- if (n.__esModule) return n;
6930
- var a = Object.defineProperty({}, '__esModule', {value: true});
6931
- Object.keys(n).forEach(function (k) {
6932
- var d = Object.getOwnPropertyDescriptor(n, k);
6933
- Object.defineProperty(a, k, d.get ? d : {
6934
- enumerable: true,
6935
- get: function () {
6936
- return n[k];
6937
- }
6938
- });
6939
- });
6940
- return a;
6941
- }
6942
-
6943
- function commonjsRequire () {
6944
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
6945
- }
6946
-
6947
- var utils = createCommonjsModule(function (module, exports) {
6948
- "use strict";
6949
- Object.defineProperty(exports, "__esModule", { value: true });
6950
- exports.invariant = exports.UNICODE_EXTENSION_SEQUENCE_REGEX = void 0;
6951
- exports.UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
6952
- function invariant(condition, message, Err) {
6953
- if (Err === void 0) { Err = Error; }
6954
- if (!condition) {
6955
- throw new Err(message);
6956
- }
6957
- }
6958
- exports.invariant = invariant;
6959
- });
6960
-
6961
- const utils$1 = /*@__PURE__*/getDefaultExportFromCjs(utils);
6962
-
6963
- var BestAvailableLocale_1 = createCommonjsModule(function (module, exports) {
6964
- "use strict";
6965
- Object.defineProperty(exports, "__esModule", { value: true });
6966
- exports.BestAvailableLocale = void 0;
6967
- /**
6968
- * https://tc39.es/ecma402/#sec-bestavailablelocale
6969
- * @param availableLocales
6970
- * @param locale
6971
- */
6972
- function BestAvailableLocale(availableLocales, locale) {
6973
- var candidate = locale;
6974
- while (true) {
6975
- if (availableLocales.has(candidate)) {
6976
- return candidate;
6977
- }
6978
- var pos = candidate.lastIndexOf('-');
6979
- if (!~pos) {
6980
- return undefined;
6981
- }
6982
- if (pos >= 2 && candidate[pos - 2] === '-') {
6983
- pos -= 2;
6984
- }
6985
- candidate = candidate.slice(0, pos);
6986
- }
6987
- }
6988
- exports.BestAvailableLocale = BestAvailableLocale;
6989
- });
6990
-
6991
- const BestAvailableLocale = /*@__PURE__*/getDefaultExportFromCjs(BestAvailableLocale_1);
6992
-
6993
- var LookupMatcher_1 = createCommonjsModule(function (module, exports) {
6994
- "use strict";
6995
- Object.defineProperty(exports, "__esModule", { value: true });
6996
- exports.LookupMatcher = void 0;
6997
-
6998
-
6999
- /**
7000
- * https://tc39.es/ecma402/#sec-lookupmatcher
7001
- * @param availableLocales
7002
- * @param requestedLocales
7003
- * @param getDefaultLocale
7004
- */
7005
- function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
7006
- var result = { locale: '' };
7007
- for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
7008
- var locale = requestedLocales_1[_i];
7009
- var noExtensionLocale = locale.replace(utils.UNICODE_EXTENSION_SEQUENCE_REGEX, '');
7010
- var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
7011
- if (availableLocale) {
7012
- result.locale = availableLocale;
7013
- if (locale !== noExtensionLocale) {
7014
- result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
7015
- }
7016
- return result;
7017
- }
7018
- }
7019
- result.locale = getDefaultLocale();
7020
- return result;
7021
- }
7022
- exports.LookupMatcher = LookupMatcher;
7023
- });
7024
-
7025
- const LookupMatcher = /*@__PURE__*/getDefaultExportFromCjs(LookupMatcher_1);
7026
-
7027
- var BestFitMatcher_1 = createCommonjsModule(function (module, exports) {
7028
- "use strict";
7029
- Object.defineProperty(exports, "__esModule", { value: true });
7030
- exports.BestFitMatcher = void 0;
7031
-
7032
-
7033
- /**
7034
- * https://tc39.es/ecma402/#sec-bestfitmatcher
7035
- * @param availableLocales
7036
- * @param requestedLocales
7037
- * @param getDefaultLocale
7038
- */
7039
- function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
7040
- var minimizedAvailableLocaleMap = Array.from(availableLocales).reduce(function (all, l) {
7041
- all[l] = l;
7042
- return all;
7043
- }, {});
7044
- var minimizedAvailableLocales = new Set();
7045
- availableLocales.forEach(function (locale) {
7046
- var minimizedLocale = new Intl.Locale(locale)
7047
- .minimize()
7048
- .toString();
7049
- minimizedAvailableLocaleMap[minimizedLocale] = locale;
7050
- minimizedAvailableLocales.add(minimizedLocale);
7051
- });
7052
- var foundLocale;
7053
- for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
7054
- var l = requestedLocales_1[_i];
7055
- if (foundLocale) {
7056
- break;
7057
- }
7058
- var noExtensionLocale = l.replace(utils.UNICODE_EXTENSION_SEQUENCE_REGEX, '');
7059
- if (availableLocales.has(noExtensionLocale)) {
7060
- foundLocale = noExtensionLocale;
7061
- break;
7062
- }
7063
- if (minimizedAvailableLocales.has(noExtensionLocale)) {
7064
- foundLocale = noExtensionLocale;
7065
- break;
7066
- }
7067
- var locale = new Intl.Locale(noExtensionLocale);
7068
- var maximizedRequestedLocale = locale.maximize().toString();
7069
- var minimizedRequestedLocale = locale.minimize().toString();
7070
- // Check minimized locale
7071
- if (minimizedAvailableLocales.has(minimizedRequestedLocale)) {
7072
- foundLocale = minimizedRequestedLocale;
7073
- break;
7074
- }
7075
- // Lookup algo on maximized locale
7076
- foundLocale = BestAvailableLocale_1.BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale);
7077
- }
7078
- return {
7079
- locale: (foundLocale && minimizedAvailableLocaleMap[foundLocale]) ||
7080
- getDefaultLocale(),
7081
- };
7082
- }
7083
- exports.BestFitMatcher = BestFitMatcher;
7084
- });
7085
-
7086
- const BestFitMatcher = /*@__PURE__*/getDefaultExportFromCjs(BestFitMatcher_1);
7087
-
7088
- var UnicodeExtensionValue_1 = createCommonjsModule(function (module, exports) {
7089
- "use strict";
7090
- Object.defineProperty(exports, "__esModule", { value: true });
7091
- exports.UnicodeExtensionValue = void 0;
7092
-
7093
- /**
7094
- * https://tc39.es/ecma402/#sec-unicodeextensionvalue
7095
- * @param extension
7096
- * @param key
7097
- */
7098
- function UnicodeExtensionValue(extension, key) {
7099
- utils.invariant(key.length === 2, 'key must have 2 elements');
7100
- var size = extension.length;
7101
- var searchValue = "-" + key + "-";
7102
- var pos = extension.indexOf(searchValue);
7103
- if (pos !== -1) {
7104
- var start = pos + 4;
7105
- var end = start;
7106
- var k = start;
7107
- var done = false;
7108
- while (!done) {
7109
- var e = extension.indexOf('-', k);
7110
- var len = void 0;
7111
- if (e === -1) {
7112
- len = size - k;
7113
- }
7114
- else {
7115
- len = e - k;
7116
- }
7117
- if (len === 2) {
7118
- done = true;
7119
- }
7120
- else if (e === -1) {
7121
- end = size;
7122
- done = true;
7123
- }
7124
- else {
7125
- end = e;
7126
- k = e + 1;
7127
- }
7128
- }
7129
- return extension.slice(start, end);
7130
- }
7131
- searchValue = "-" + key;
7132
- pos = extension.indexOf(searchValue);
7133
- if (pos !== -1 && pos + 3 === size) {
7134
- return '';
7135
- }
7136
- return undefined;
7137
- }
7138
- exports.UnicodeExtensionValue = UnicodeExtensionValue;
7139
- });
7140
-
7141
- const UnicodeExtensionValue = /*@__PURE__*/getDefaultExportFromCjs(UnicodeExtensionValue_1);
7142
-
7143
- var ResolveLocale_1 = createCommonjsModule(function (module, exports) {
7144
- "use strict";
7145
- Object.defineProperty(exports, "__esModule", { value: true });
7146
- exports.ResolveLocale = void 0;
7147
-
7148
-
7149
-
7150
-
7151
- /**
7152
- * https://tc39.es/ecma402/#sec-resolvelocale
7153
- */
7154
- function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
7155
- var matcher = options.localeMatcher;
7156
- var r;
7157
- if (matcher === 'lookup') {
7158
- r = LookupMatcher_1.LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
7159
- }
7160
- else {
7161
- r = BestFitMatcher_1.BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
7162
- }
7163
- var foundLocale = r.locale;
7164
- var result = { locale: '', dataLocale: foundLocale };
7165
- var supportedExtension = '-u';
7166
- for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
7167
- var key = relevantExtensionKeys_1[_i];
7168
- utils.invariant(foundLocale in localeData, "Missing locale data for " + foundLocale);
7169
- var foundLocaleData = localeData[foundLocale];
7170
- utils.invariant(typeof foundLocaleData === 'object' && foundLocaleData !== null, "locale data " + key + " must be an object");
7171
- var keyLocaleData = foundLocaleData[key];
7172
- utils.invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
7173
- var value = keyLocaleData[0];
7174
- utils.invariant(typeof value === 'string' || value === null, "value must be string or null but got " + typeof value + " in key " + key);
7175
- var supportedExtensionAddition = '';
7176
- if (r.extension) {
7177
- var requestedValue = UnicodeExtensionValue_1.UnicodeExtensionValue(r.extension, key);
7178
- if (requestedValue !== undefined) {
7179
- if (requestedValue !== '') {
7180
- if (~keyLocaleData.indexOf(requestedValue)) {
7181
- value = requestedValue;
7182
- supportedExtensionAddition = "-" + key + "-" + value;
7183
- }
7184
- }
7185
- else if (~requestedValue.indexOf('true')) {
7186
- value = 'true';
7187
- supportedExtensionAddition = "-" + key;
7188
- }
7189
- }
7190
- }
7191
- if (key in options) {
7192
- var optionsValue = options[key];
7193
- utils.invariant(typeof optionsValue === 'string' ||
7194
- typeof optionsValue === 'undefined' ||
7195
- optionsValue === null, 'optionsValue must be String, Undefined or Null');
7196
- if (~keyLocaleData.indexOf(optionsValue)) {
7197
- if (optionsValue !== value) {
7198
- value = optionsValue;
7199
- supportedExtensionAddition = '';
7200
- }
7201
- }
7202
- }
7203
- result[key] = value;
7204
- supportedExtension += supportedExtensionAddition;
7205
- }
7206
- if (supportedExtension.length > 2) {
7207
- var privateIndex = foundLocale.indexOf('-x-');
7208
- if (privateIndex === -1) {
7209
- foundLocale = foundLocale + supportedExtension;
7210
- }
7211
- else {
7212
- var preExtension = foundLocale.slice(0, privateIndex);
7213
- var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
7214
- foundLocale = preExtension + supportedExtension + postExtension;
7215
- }
7216
- foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
7217
- }
7218
- result.locale = foundLocale;
7219
- return result;
7220
- }
7221
- exports.ResolveLocale = ResolveLocale;
7222
- });
7223
-
7224
- const ResolveLocale = /*@__PURE__*/getDefaultExportFromCjs(ResolveLocale_1);
7225
-
7226
- var LookupSupportedLocales_1 = createCommonjsModule(function (module, exports) {
7227
- "use strict";
7228
- Object.defineProperty(exports, "__esModule", { value: true });
7229
- exports.LookupSupportedLocales = void 0;
7230
-
7231
-
7232
- /**
7233
- * https://tc39.es/ecma402/#sec-lookupsupportedlocales
7234
- * @param availableLocales
7235
- * @param requestedLocales
7236
- */
7237
- function LookupSupportedLocales(availableLocales, requestedLocales) {
7238
- var subset = [];
7239
- for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
7240
- var locale = requestedLocales_1[_i];
7241
- var noExtensionLocale = locale.replace(utils.UNICODE_EXTENSION_SEQUENCE_REGEX, '');
7242
- var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
7243
- if (availableLocale) {
7244
- subset.push(availableLocale);
7245
- }
7246
- }
7247
- return subset;
7248
- }
7249
- exports.LookupSupportedLocales = LookupSupportedLocales;
7250
- });
7251
-
7252
- const LookupSupportedLocales = /*@__PURE__*/getDefaultExportFromCjs(LookupSupportedLocales_1);
7253
-
7254
- var intlLocalematcher = createCommonjsModule(function (module, exports) {
7255
- "use strict";
7256
- Object.defineProperty(exports, "__esModule", { value: true });
7257
- exports.ResolveLocale = exports.LookupSupportedLocales = exports.match = void 0;
7258
-
7259
- function match(requestedLocales, availableLocales, defaultLocale, opts) {
7260
- var locales = availableLocales.reduce(function (all, l) {
7261
- all.add(l);
7262
- return all;
7263
- }, new Set());
7264
- return ResolveLocale_1.ResolveLocale(locales, requestedLocales, {
7265
- localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || 'best fit',
7266
- }, [], {}, function () { return defaultLocale; }).locale;
7267
- }
7268
- exports.match = match;
7269
-
7270
- Object.defineProperty(exports, "LookupSupportedLocales", { enumerable: true, get: function () { return LookupSupportedLocales_1.LookupSupportedLocales; } });
7271
- var ResolveLocale_2 = ResolveLocale_1;
7272
- Object.defineProperty(exports, "ResolveLocale", { enumerable: true, get: function () { return ResolveLocale_2.ResolveLocale; } });
7273
- });
7274
-
7275
- const index = /*@__PURE__*/getDefaultExportFromCjs(intlLocalematcher);
7276
-
7277
- /**
7278
- * https://tc39.es/ecma402/#sec-setnumberformatunitoptions
7279
- */
7280
- function SetNumberFormatUnitOptions(nf, options, _a) {
7281
- if (options === void 0) { options = Object.create(null); }
7282
- var getInternalSlots = _a.getInternalSlots;
7283
- var internalSlots = getInternalSlots(nf);
7284
- var style = GetOption(options, 'style', 'string', ['decimal', 'percent', 'currency', 'unit'], 'decimal');
7285
- internalSlots.style = style;
7286
- var currency = GetOption(options, 'currency', 'string', undefined, undefined);
7287
- if (currency !== undefined && !IsWellFormedCurrencyCode(currency)) {
7288
- throw RangeError('Malformed currency code');
7289
- }
7290
- if (style === 'currency' && currency === undefined) {
7291
- throw TypeError('currency cannot be undefined');
7292
- }
7293
- var currencyDisplay = GetOption(options, 'currencyDisplay', 'string', ['code', 'symbol', 'narrowSymbol', 'name'], 'symbol');
7294
- var currencySign = GetOption(options, 'currencySign', 'string', ['standard', 'accounting'], 'standard');
7295
- var unit = GetOption(options, 'unit', 'string', undefined, undefined);
7296
- if (unit !== undefined && !IsWellFormedUnitIdentifier(unit)) {
7297
- throw RangeError('Invalid unit argument for Intl.NumberFormat()');
7298
- }
7299
- if (style === 'unit' && unit === undefined) {
7300
- throw TypeError('unit cannot be undefined');
7301
- }
7302
- var unitDisplay = GetOption(options, 'unitDisplay', 'string', ['short', 'narrow', 'long'], 'short');
7303
- if (style === 'currency') {
7304
- internalSlots.currency = currency.toUpperCase();
7305
- internalSlots.currencyDisplay = currencyDisplay;
7306
- internalSlots.currencySign = currencySign;
7307
- }
7308
- if (style === 'unit') {
7309
- internalSlots.unit = unit;
7310
- internalSlots.unitDisplay = unitDisplay;
7311
- }
7312
- }
7313
-
7314
- /**
7315
- * https://tc39.es/ecma402/#sec-setnfdigitoptions
7316
- */
7317
- function SetNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mxfdDefault, notation) {
7318
- var mnid = GetNumberOption(opts, 'minimumIntegerDigits', 1, 21, 1);
7319
- var mnfd = opts.minimumFractionDigits;
7320
- var mxfd = opts.maximumFractionDigits;
7321
- var mnsd = opts.minimumSignificantDigits;
7322
- var mxsd = opts.maximumSignificantDigits;
7323
- internalSlots.minimumIntegerDigits = mnid;
7324
- if (mnsd !== undefined || mxsd !== undefined) {
7325
- internalSlots.roundingType = 'significantDigits';
7326
- mnsd = DefaultNumberOption(mnsd, 1, 21, 1);
7327
- mxsd = DefaultNumberOption(mxsd, mnsd, 21, 21);
7328
- internalSlots.minimumSignificantDigits = mnsd;
7329
- internalSlots.maximumSignificantDigits = mxsd;
7330
- }
7331
- else if (mnfd !== undefined || mxfd !== undefined) {
7332
- internalSlots.roundingType = 'fractionDigits';
7333
- mnfd = DefaultNumberOption(mnfd, 0, 20, mnfdDefault);
7334
- var mxfdActualDefault = Math.max(mnfd, mxfdDefault);
7335
- mxfd = DefaultNumberOption(mxfd, mnfd, 20, mxfdActualDefault);
7336
- internalSlots.minimumFractionDigits = mnfd;
7337
- internalSlots.maximumFractionDigits = mxfd;
7338
- }
7339
- else if (notation === 'compact') {
7340
- internalSlots.roundingType = 'compactRounding';
7341
- }
7342
- else {
7343
- internalSlots.roundingType = 'fractionDigits';
7344
- internalSlots.minimumFractionDigits = mnfdDefault;
7345
- internalSlots.maximumFractionDigits = mxfdDefault;
7346
- }
7347
- }
7348
-
7349
- /**
7350
- * https://tc39.es/ecma402/#sec-initializenumberformat
7351
- */
7352
- function InitializeNumberFormat(nf, locales, opts, _a) {
7353
- var getInternalSlots = _a.getInternalSlots, localeData = _a.localeData, availableLocales = _a.availableLocales, numberingSystemNames = _a.numberingSystemNames, getDefaultLocale = _a.getDefaultLocale, currencyDigitsData = _a.currencyDigitsData;
7354
- // @ts-ignore
7355
- var requestedLocales = CanonicalizeLocaleList(locales);
7356
- var options = CoerceOptionsToObject(opts);
7357
- var opt = Object.create(null);
7358
- var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
7359
- opt.localeMatcher = matcher;
7360
- var numberingSystem = GetOption(options, 'numberingSystem', 'string', undefined, undefined);
7361
- if (numberingSystem !== undefined &&
7362
- numberingSystemNames.indexOf(numberingSystem) < 0) {
7363
- // 8.a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal,
7364
- // throw a RangeError exception.
7365
- throw RangeError("Invalid numberingSystems: " + numberingSystem);
7366
- }
7367
- opt.nu = numberingSystem;
7368
- var r = intlLocalematcher.ResolveLocale(availableLocales, requestedLocales, opt,
7369
- // [[RelevantExtensionKeys]] slot, which is a constant
7370
- ['nu'], localeData, getDefaultLocale);
7371
- var dataLocaleData = localeData[r.dataLocale];
7372
- invariant(!!dataLocaleData, "Missing locale data for " + r.dataLocale);
7373
- var internalSlots = getInternalSlots(nf);
7374
- internalSlots.locale = r.locale;
7375
- internalSlots.dataLocale = r.dataLocale;
7376
- internalSlots.numberingSystem = r.nu;
7377
- internalSlots.dataLocaleData = dataLocaleData;
7378
- SetNumberFormatUnitOptions(nf, options, { getInternalSlots: getInternalSlots });
7379
- var style = internalSlots.style;
7380
- var mnfdDefault;
7381
- var mxfdDefault;
7382
- if (style === 'currency') {
7383
- var currency = internalSlots.currency;
7384
- var cDigits = CurrencyDigits(currency, { currencyDigitsData: currencyDigitsData });
7385
- mnfdDefault = cDigits;
7386
- mxfdDefault = cDigits;
7387
- }
7388
- else {
7389
- mnfdDefault = 0;
7390
- mxfdDefault = style === 'percent' ? 0 : 3;
7391
- }
7392
- var notation = GetOption(options, 'notation', 'string', ['standard', 'scientific', 'engineering', 'compact'], 'standard');
7393
- internalSlots.notation = notation;
7394
- SetNumberFormatDigitOptions(internalSlots, options, mnfdDefault, mxfdDefault, notation);
7395
- var compactDisplay = GetOption(options, 'compactDisplay', 'string', ['short', 'long'], 'short');
7396
- if (notation === 'compact') {
7397
- internalSlots.compactDisplay = compactDisplay;
7398
- }
7399
- var useGrouping = GetOption(options, 'useGrouping', 'boolean', undefined, true);
7400
- internalSlots.useGrouping = useGrouping;
7401
- var signDisplay = GetOption(options, 'signDisplay', 'string', ['auto', 'never', 'always', 'exceptZero'], 'auto');
7402
- internalSlots.signDisplay = signDisplay;
7403
- return nf;
7404
- }
7405
-
7406
- /**
7407
- * https://tc39.es/ecma402/#sec-partitionpattern
7408
- * @param pattern
7409
- */
7410
- function PartitionPattern(pattern) {
7411
- var result = [];
7412
- var beginIndex = pattern.indexOf('{');
7413
- var endIndex = 0;
7414
- var nextIndex = 0;
7415
- var length = pattern.length;
7416
- while (beginIndex < pattern.length && beginIndex > -1) {
7417
- endIndex = pattern.indexOf('}', beginIndex);
7418
- invariant(endIndex > beginIndex, "Invalid pattern " + pattern);
7419
- if (beginIndex > nextIndex) {
7420
- result.push({
7421
- type: 'literal',
7422
- value: pattern.substring(nextIndex, beginIndex),
7423
- });
7424
- }
7425
- result.push({
7426
- type: pattern.substring(beginIndex + 1, endIndex),
7427
- value: undefined,
7428
- });
7429
- nextIndex = endIndex + 1;
7430
- beginIndex = pattern.indexOf('{', nextIndex);
7431
- }
7432
- if (nextIndex < length) {
7433
- result.push({
7434
- type: 'literal',
7435
- value: pattern.substring(nextIndex, length),
7436
- });
7437
- }
7438
- return result;
7439
- }
7440
-
7441
- /**
7442
- * https://tc39.es/ecma402/#sec-supportedlocales
7443
- * @param availableLocales
7444
- * @param requestedLocales
7445
- * @param options
7446
- */
7447
- function SupportedLocales(availableLocales, requestedLocales, options) {
7448
- var matcher = 'best fit';
7449
- if (options !== undefined) {
7450
- options = ToObject(options);
7451
- matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
7452
- }
7453
- if (matcher === 'best fit') {
7454
- return intlLocalematcher.LookupSupportedLocales(availableLocales, requestedLocales);
7455
- }
7456
- return intlLocalematcher.LookupSupportedLocales(availableLocales, requestedLocales);
7457
- }
7458
-
7459
- var MissingLocaleDataError = /** @class */ (function (_super) {
7460
- __extends(MissingLocaleDataError, _super);
7461
- function MissingLocaleDataError() {
7462
- var _this = _super !== null && _super.apply(this, arguments) || this;
7463
- _this.type = 'MISSING_LOCALE_DATA';
7464
- return _this;
7465
- }
7466
- return MissingLocaleDataError;
7467
- }(Error));
7468
- function isMissingLocaleDataError(e) {
7469
- return e.type === 'MISSING_LOCALE_DATA';
7470
- }
7471
-
7472
- var RangePatternType;
7473
- (function (RangePatternType) {
7474
- RangePatternType["startRange"] = "startRange";
7475
- RangePatternType["shared"] = "shared";
7476
- RangePatternType["endRange"] = "endRange";
7477
- })(RangePatternType || (RangePatternType = {}));
7478
-
7479
- function setTimeZoneInOptions(opts, timeZone) {
7480
- return Object.keys(opts).reduce(function (all, k) {
7481
- all[k] = __assign({ timeZone: timeZone }, opts[k]);
7482
- return all;
7483
- }, {});
7484
- }
7485
- function deepMergeOptions(opts1, opts2) {
7486
- var keys = Object.keys(__assign(__assign({}, opts1), opts2));
7487
- return keys.reduce(function (all, k) {
7488
- all[k] = __assign(__assign({}, (opts1[k] || {})), (opts2[k] || {}));
7489
- return all;
7490
- }, {});
7491
- }
7492
- function deepMergeFormatsAndSetTimeZone(f1, timeZone) {
7493
- if (!timeZone) {
7494
- return f1;
7495
- }
7496
- var mfFormats = IntlMessageFormat.formats;
7497
- return __assign(__assign(__assign({}, mfFormats), f1), { date: deepMergeOptions(setTimeZoneInOptions(mfFormats.date, timeZone), setTimeZoneInOptions(f1.date || {}, timeZone)), time: deepMergeOptions(setTimeZoneInOptions(mfFormats.time, timeZone), setTimeZoneInOptions(f1.time || {}, timeZone)) });
7498
- }
7499
- function formatMessage(_a, state, messageDescriptor, values, opts) {
7500
- var locale = _a.locale, formats = _a.formats, messages = _a.messages, defaultLocale = _a.defaultLocale, defaultFormats = _a.defaultFormats, onError = _a.onError, timeZone = _a.timeZone, defaultRichTextElements = _a.defaultRichTextElements;
7501
- if (messageDescriptor === void 0) { messageDescriptor = { id: '' }; }
7502
- var msgId = messageDescriptor.id, defaultMessage = messageDescriptor.defaultMessage;
7503
- // `id` is a required field of a Message Descriptor.
7504
- invariant(!!msgId, "[@formatjs/intl] An `id` must be provided to format a message. You can either:\n1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.io/docs/tooling/babel-plugin)\nor [@formatjs/ts-transformer](https://formatjs.io/docs/tooling/ts-transformer) OR\n2. Configure your `eslint` config to include [eslint-plugin-formatjs](https://formatjs.io/docs/tooling/linter#enforce-id)\nto autofix this issue");
7505
- var id = String(msgId);
7506
- var message =
7507
- // In case messages is Object.create(null)
7508
- // e.g import('foo.json') from webpack)
7509
- // See https://github.com/formatjs/formatjs/issues/1914
7510
- messages &&
7511
- Object.prototype.hasOwnProperty.call(messages, id) &&
7512
- messages[id];
7513
- // IMPORTANT: Hot path if `message` is AST with a single literal node
7514
- if (Array.isArray(message) &&
7515
- message.length === 1 &&
7516
- message[0].type === TYPE.literal) {
7517
- return message[0].value;
7518
- }
7519
- // IMPORTANT: Hot path straight lookup for performance
7520
- if (!values &&
7521
- message &&
7522
- typeof message === 'string' &&
7523
- !defaultRichTextElements) {
7524
- return message.replace(/'\{(.*?)\}'/gi, "{$1}");
7525
- }
7526
- values = __assign(__assign({}, defaultRichTextElements), (values || {}));
7527
- formats = deepMergeFormatsAndSetTimeZone(formats, timeZone);
7528
- defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone);
7529
- if (!message) {
7530
- if (!defaultMessage ||
7531
- (locale && locale.toLowerCase() !== defaultLocale.toLowerCase())) {
7532
- // This prevents warnings from littering the console in development
7533
- // when no `messages` are passed into the <IntlProvider> for the
7534
- // default locale.
7535
- onError(new MissingTranslationError(messageDescriptor, locale));
7536
- }
7537
- if (defaultMessage) {
7538
- try {
7539
- var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts);
7540
- return formatter.format(values);
7541
- }
7542
- catch (e) {
7543
- onError(new MessageFormatError("Error formatting default message for: \"" + id + "\", rendering default message verbatim", locale, messageDescriptor, e));
7544
- return typeof defaultMessage === 'string' ? defaultMessage : id;
7545
- }
7546
- }
7547
- return id;
7548
- }
7549
- // We have the translated message
7550
- try {
7551
- var formatter = state.getMessageFormat(message, locale, formats, __assign({ formatters: state }, (opts || {})));
7552
- return formatter.format(values);
7553
- }
7554
- catch (e) {
7555
- onError(new MessageFormatError("Error formatting message: \"" + id + "\", using " + (defaultMessage ? 'default message' : 'id') + " as fallback.", locale, messageDescriptor, e));
7556
- }
7557
- if (defaultMessage) {
7558
- try {
7559
- var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts);
7560
- return formatter.format(values);
7561
- }
7562
- catch (e) {
7563
- onError(new MessageFormatError("Error formatting the default message for: \"" + id + "\", rendering message verbatim", locale, messageDescriptor, e));
7564
- }
7565
- }
7566
- if (typeof message === 'string') {
7567
- return message;
7568
- }
7569
- if (typeof defaultMessage === 'string') {
7570
- return defaultMessage;
7571
- }
7572
- return id;
7573
- }
7574
-
7575
- var DATE_TIME_FORMAT_OPTIONS = [
7576
- 'localeMatcher',
7577
- 'formatMatcher',
7578
- 'timeZone',
7579
- 'hour12',
7580
- 'weekday',
7581
- 'era',
7582
- 'year',
7583
- 'month',
7584
- 'day',
7585
- 'hour',
7586
- 'minute',
7587
- 'second',
7588
- 'timeZoneName',
7589
- 'hourCycle',
7590
- 'dateStyle',
7591
- 'timeStyle',
7592
- 'calendar',
7593
- // 'dayPeriod',
7594
- 'numberingSystem',
7595
- ];
7596
- function getFormatter$2(_a, type, getDateTimeFormat, options) {
7597
- var locale = _a.locale, formats = _a.formats, onError = _a.onError, timeZone = _a.timeZone;
7598
- if (options === void 0) { options = {}; }
7599
- var format = options.format;
7600
- var defaults = __assign(__assign({}, (timeZone && { timeZone: timeZone })), (format && getNamedFormat(formats, type, format, onError)));
7601
- var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS,
7602
- // @ts-expect-error es2020 has a lot stuff from es2021 bleed in
7603
- defaults);
7604
- if (type === 'time' &&
7605
- !filteredOptions.hour &&
7606
- !filteredOptions.minute &&
7607
- !filteredOptions.second &&
7608
- !filteredOptions.timeStyle &&
7609
- !filteredOptions.dateStyle) {
7610
- // Add default formatting options if hour, minute, or second isn't defined.
7611
- filteredOptions = __assign(__assign({}, filteredOptions), { hour: 'numeric', minute: 'numeric' });
7612
- }
7613
- return getDateTimeFormat(locale, filteredOptions);
7614
- }
7615
- function formatDate(config, getDateTimeFormat) {
7616
- var _a = [];
7617
- for (var _i = 2; _i < arguments.length; _i++) {
7618
- _a[_i - 2] = arguments[_i];
7619
- }
7620
- var value = _a[0], _b = _a[1], options = _b === void 0 ? {} : _b;
7621
- var date = typeof value === 'string' ? new Date(value || 0) : value;
7622
- try {
7623
- return getFormatter$2(config, 'date', getDateTimeFormat, options).format(date);
7624
- }
7625
- catch (e) {
7626
- config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting date.', e));
7627
- }
7628
- return String(date);
7629
- }
7630
- function formatTime(config, getDateTimeFormat) {
7631
- var _a = [];
7632
- for (var _i = 2; _i < arguments.length; _i++) {
7633
- _a[_i - 2] = arguments[_i];
7634
- }
7635
- var value = _a[0], _b = _a[1], options = _b === void 0 ? {} : _b;
7636
- var date = typeof value === 'string' ? new Date(value || 0) : value;
7637
- try {
7638
- return getFormatter$2(config, 'time', getDateTimeFormat, options).format(date);
7639
- }
7640
- catch (e) {
7641
- config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting time.', e));
7642
- }
7643
- return String(date);
7644
- }
7645
- function formatDateTimeRange(config, getDateTimeFormat) {
7646
- var _a = [];
7647
- for (var _i = 2; _i < arguments.length; _i++) {
7648
- _a[_i - 2] = arguments[_i];
7649
- }
7650
- var from = _a[0], to = _a[1], _b = _a[2], options = _b === void 0 ? {} : _b;
7651
- var timeZone = config.timeZone, locale = config.locale, onError = config.onError;
7652
- var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, timeZone ? { timeZone: timeZone } : {});
7653
- try {
7654
- return getDateTimeFormat(locale, filteredOptions).formatRange(from, to);
7655
- }
7656
- catch (e) {
7657
- onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting date time range.', e));
5442
+ catch (e) {
5443
+ onError(new IntlError(IntlErrorCode.FORMAT_ERROR, 'Error formatting date time range.', e));
7658
5444
  }
7659
5445
  return String(from);
7660
5446
  }
@@ -7911,13 +5697,6 @@ function createIntl(config, cache) {
7911
5697
  return __assign(__assign({}, resolvedConfig), { formatters: formatters, formatNumber: formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat), formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat), formatRelativeTime: formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat), formatDate: formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateToParts: formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTime: formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateTimeRange: formatDateTimeRange.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTimeToParts: formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatPlural: formatPlural.bind(null, resolvedConfig, formatters.getPluralRules), formatMessage: formatMessage.bind(null, resolvedConfig, formatters), formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat), formatListToParts: formatListToParts.bind(null, resolvedConfig, formatters.getListFormat), formatDisplayName: formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames) });
7912
5698
  }
7913
5699
 
7914
- function defineMessages(msgs) {
7915
- return msgs;
7916
- }
7917
- function defineMessage(msg) {
7918
- return msg;
7919
- }
7920
-
7921
5700
  const DEFAULT_LANGUAGE = "en";
7922
5701
  function getBrowserLang() {
7923
5702
  const langAttr = document.documentElement.getAttribute("lang");
@@ -8337,4 +6116,22 @@ export function getNextKeyboardFocusableElement(element: HTMLElement) {
8337
6116
  }
8338
6117
  */
8339
6118
 
8340
- export { shouldOpenUp as a, getTextDir as b, checkForActiveElInShadow as c, debounce as d, getPosition as e, findParentWithScrollbar as f, generateId as g, isRelatedTarget as h, intl as i, checkForFocusableElInShadow as j, getFirstFocusableDescendant as k, snakeCaseToCamelCase as l, getNewIndexToFocus as m, hasValidType as n, shouldOpenDown as o, shouldShiftLeft as p, hasRoomRight as q, adjustTooltipPosition as r, shouldShiftRight as s };
6119
+ exports.adjustTooltipPosition = adjustTooltipPosition;
6120
+ exports.checkForActiveElInShadow = checkForActiveElInShadow;
6121
+ exports.checkForFocusableElInShadow = checkForFocusableElInShadow;
6122
+ exports.debounce = debounce;
6123
+ exports.findParentWithScrollbar = findParentWithScrollbar;
6124
+ exports.generateId = generateId;
6125
+ exports.getFirstFocusableDescendant = getFirstFocusableDescendant;
6126
+ exports.getNewIndexToFocus = getNewIndexToFocus;
6127
+ exports.getPosition = getPosition;
6128
+ exports.getTextDir = getTextDir;
6129
+ exports.hasRoomRight = hasRoomRight;
6130
+ exports.hasValidType = hasValidType;
6131
+ exports.intl = intl;
6132
+ exports.isRelatedTarget = isRelatedTarget;
6133
+ exports.shouldOpenDown = shouldOpenDown;
6134
+ exports.shouldOpenUp = shouldOpenUp;
6135
+ exports.shouldShiftLeft = shouldShiftLeft;
6136
+ exports.shouldShiftRight = shouldShiftRight;
6137
+ exports.snakeCaseToCamelCase = snakeCaseToCamelCase;