@everymatrix/player-elevate-card 1.31.2

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 (115) hide show
  1. package/dist/cjs/general-styling-wrapper_5.cjs.entry.js +3162 -0
  2. package/dist/cjs/index-234565f1.js +1645 -0
  3. package/dist/cjs/index.cjs.js +2 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/player-elevate-card.cjs.js +19 -0
  6. package/dist/collection/collection-manifest.json +22 -0
  7. package/dist/collection/components/player-elevate-card/player-elevate-card-items.js +43 -0
  8. package/dist/collection/components/player-elevate-card/player-elevate-card.css +65 -0
  9. package/dist/collection/components/player-elevate-card/player-elevate-card.js +282 -0
  10. package/dist/collection/components/player-elevate-card-data/player-elevate-card-data.css +189 -0
  11. package/dist/collection/components/player-elevate-card-data/player-elevate-card-data.js +208 -0
  12. package/dist/collection/components/player-elevate-loyaltycard/player-elevate-loyaltycard.css +68 -0
  13. package/dist/collection/components/player-elevate-loyaltycard/player-elevate-loyaltycard.js +287 -0
  14. package/dist/collection/components/player-elevate-pointcard/player-elevate-pointcard.css +70 -0
  15. package/dist/collection/components/player-elevate-pointcard/player-elevate-pointcard.js +323 -0
  16. package/dist/collection/components/static/button-default.svg +42 -0
  17. package/dist/collection/components/static/button-disabled.svg +4 -0
  18. package/dist/collection/components/static/button-hover.svg +4 -0
  19. package/dist/collection/components/static/button-level.svg +27 -0
  20. package/dist/collection/components/static/button-pressed.svg +18 -0
  21. package/dist/collection/components/static/button-redeem.svg +36 -0
  22. package/dist/collection/components/static/card-ground-over.png +0 -0
  23. package/dist/collection/components/static/card-ground-over.svg +903 -0
  24. package/dist/collection/components/static/card-ground.png +0 -0
  25. package/dist/collection/components/static/card-ground.svg +34 -0
  26. package/dist/collection/components/static/info.svg +4 -0
  27. package/dist/collection/components/static/level-badge.png +0 -0
  28. package/dist/collection/components/static/level-percent.svg +80 -0
  29. package/dist/collection/components/static/tips-info.svg +21 -0
  30. package/dist/collection/components/static/user.svg +3 -0
  31. package/dist/collection/index.js +1 -0
  32. package/dist/collection/models/player-elevate.js +1 -0
  33. package/dist/collection/utils/locale.utils.js +144 -0
  34. package/dist/collection/utils/utils.js +47 -0
  35. package/dist/components/general-styling-wrapper.js +6 -0
  36. package/dist/components/general-styling-wrapper2.js +103 -0
  37. package/dist/components/index.d.ts +26 -0
  38. package/dist/components/index.js +1 -0
  39. package/dist/components/player-elevate-card-data.d.ts +11 -0
  40. package/dist/components/player-elevate-card-data.js +6 -0
  41. package/dist/components/player-elevate-card-data2.js +624 -0
  42. package/dist/components/player-elevate-card-items.js +2250 -0
  43. package/dist/components/player-elevate-card.d.ts +11 -0
  44. package/dist/components/player-elevate-card.js +118 -0
  45. package/dist/components/player-elevate-loyaltycard.d.ts +11 -0
  46. package/dist/components/player-elevate-loyaltycard.js +124 -0
  47. package/dist/components/player-elevate-pointcard.d.ts +11 -0
  48. package/dist/components/player-elevate-pointcard.js +127 -0
  49. package/dist/components/static/button-default.svg +42 -0
  50. package/dist/components/static/button-disabled.svg +4 -0
  51. package/dist/components/static/button-hover.svg +4 -0
  52. package/dist/components/static/button-level.svg +27 -0
  53. package/dist/components/static/button-pressed.svg +18 -0
  54. package/dist/components/static/button-redeem.svg +36 -0
  55. package/dist/components/static/card-ground-over.png +0 -0
  56. package/dist/components/static/card-ground-over.svg +903 -0
  57. package/dist/components/static/card-ground.png +0 -0
  58. package/dist/components/static/card-ground.svg +34 -0
  59. package/dist/components/static/info.svg +4 -0
  60. package/dist/components/static/level-badge.png +0 -0
  61. package/dist/components/static/level-percent.svg +80 -0
  62. package/dist/components/static/tips-info.svg +21 -0
  63. package/dist/components/static/user.svg +3 -0
  64. package/dist/esm/general-styling-wrapper_5.entry.js +3154 -0
  65. package/dist/esm/index-747197fd.js +1616 -0
  66. package/dist/esm/index.js +1 -0
  67. package/dist/esm/loader.js +17 -0
  68. package/dist/esm/player-elevate-card.js +17 -0
  69. package/dist/esm/polyfills/core-js.js +11 -0
  70. package/dist/esm/polyfills/css-shim.js +1 -0
  71. package/dist/esm/polyfills/dom.js +79 -0
  72. package/dist/esm/polyfills/es5-html-element.js +1 -0
  73. package/dist/esm/polyfills/index.js +34 -0
  74. package/dist/esm/polyfills/system.js +6 -0
  75. package/dist/index.cjs.js +1 -0
  76. package/dist/index.js +1 -0
  77. package/dist/player-elevate-card/index.esm.js +0 -0
  78. package/dist/player-elevate-card/p-56620f7c.entry.js +1 -0
  79. package/dist/player-elevate-card/p-afe7b72e.js +1 -0
  80. package/dist/player-elevate-card/player-elevate-card.esm.js +1 -0
  81. package/dist/static/button-default.svg +42 -0
  82. package/dist/static/button-disabled.svg +4 -0
  83. package/dist/static/button-hover.svg +4 -0
  84. package/dist/static/button-level.svg +27 -0
  85. package/dist/static/button-pressed.svg +18 -0
  86. package/dist/static/button-redeem.svg +36 -0
  87. package/dist/static/card-ground-over.png +0 -0
  88. package/dist/static/card-ground-over.svg +903 -0
  89. package/dist/static/card-ground.png +0 -0
  90. package/dist/static/card-ground.svg +34 -0
  91. package/dist/static/info.svg +4 -0
  92. package/dist/static/level-badge.png +0 -0
  93. package/dist/static/level-percent.svg +80 -0
  94. package/dist/static/tips-info.svg +21 -0
  95. package/dist/static/user.svg +3 -0
  96. package/dist/stencil.config.js +32 -0
  97. package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/emfe-widgets/widgets-stencil/packages/player-elevate-card/.stencil/packages/player-elevate-card/stencil.config.d.ts +2 -0
  98. package/dist/types/components/player-elevate-card/player-elevate-card-items.d.ts +19 -0
  99. package/dist/types/components/player-elevate-card/player-elevate-card.d.ts +53 -0
  100. package/dist/types/components/player-elevate-card-data/player-elevate-card-data.d.ts +22 -0
  101. package/dist/types/components/player-elevate-loyaltycard/player-elevate-loyaltycard.d.ts +53 -0
  102. package/dist/types/components/player-elevate-pointcard/player-elevate-pointcard.d.ts +66 -0
  103. package/dist/types/components.d.ts +335 -0
  104. package/dist/types/index.d.ts +1 -0
  105. package/dist/types/models/player-elevate.d.ts +40 -0
  106. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  107. package/dist/types/utils/locale.utils.d.ts +15 -0
  108. package/dist/types/utils/utils.d.ts +1 -0
  109. package/loader/cdn.js +3 -0
  110. package/loader/index.cjs.js +3 -0
  111. package/loader/index.d.ts +12 -0
  112. package/loader/index.es2017.js +3 -0
  113. package/loader/index.js +4 -0
  114. package/loader/package.json +10 -0
  115. package/package.json +24 -0
@@ -0,0 +1,3154 @@
1
+ import { r as registerInstance, h, g as getElement, a as getAssetPath, F as Fragment, c as createEvent } from './index-747197fd.js';
2
+
3
+ const mergeTranslations = (url, target) => {
4
+ return new Promise((resolve) => {
5
+ fetch(url)
6
+ .then((res) => res.json())
7
+ .then((data) => {
8
+ Object.keys(data).forEach((item) => {
9
+ target[item] = target[item] ? target[item] : {};
10
+ for (let key in data[item]) {
11
+ target[item][key] = data[item][key];
12
+ }
13
+ });
14
+ resolve(true);
15
+ });
16
+ });
17
+ };
18
+
19
+ const generalStylingWrapperCss = ":host{display:block}";
20
+
21
+ const GeneralStylingWrapper = class {
22
+ constructor(hostRef) {
23
+ registerInstance(this, hostRef);
24
+ /**
25
+ * Client custom styling via inline styles
26
+ */
27
+ this.clientStyling = '';
28
+ /**
29
+ * Client custom styling via url
30
+ */
31
+ this.clientStylingUrl = '';
32
+ /**
33
+ * Translation via url
34
+ */
35
+ this.translationUrl = '';
36
+ this.stylingAppends = false;
37
+ this.setClientStyling = () => {
38
+ let sheet = document.createElement('style');
39
+ sheet.innerHTML = this.clientStyling;
40
+ this.el.prepend(sheet);
41
+ };
42
+ this.setClientStylingURL = () => {
43
+ let url = new URL(this.clientStylingUrl);
44
+ let cssFile = document.createElement('style');
45
+ fetch(url.href)
46
+ .then((res) => res.text())
47
+ .then((data) => {
48
+ cssFile.innerHTML = data;
49
+ setTimeout(() => {
50
+ this.el.prepend(cssFile);
51
+ }, 1);
52
+ })
53
+ .catch((err) => {
54
+ console.log('error ', err);
55
+ });
56
+ };
57
+ }
58
+ componentDidRender() {
59
+ // start custom styling area
60
+ if (!this.stylingAppends) {
61
+ if (this.clientStyling)
62
+ this.setClientStyling();
63
+ if (this.clientStylingUrl)
64
+ this.setClientStylingURL();
65
+ this.stylingAppends = true;
66
+ }
67
+ // end custom styling area
68
+ }
69
+ async componentWillLoad() {
70
+ const promises = [];
71
+ if (this.translationUrl) {
72
+ const translationPromise = mergeTranslations(this.translationUrl, this.targetTranslations);
73
+ promises.push(translationPromise);
74
+ }
75
+ return await Promise.all(promises);
76
+ }
77
+ render() {
78
+ return (h("div", { class: "StyleShell" }, h("slot", { name: "mainContent" })));
79
+ }
80
+ get el() { return getElement(this); }
81
+ };
82
+ GeneralStylingWrapper.style = generalStylingWrapperCss;
83
+
84
+ const LoyaltyProgress = `<svg width="100%" height="28" fill="none" xmlns="http://www.w3.org/2000/svg">
85
+ <rect y="12" width="100%" id="total_level" height="5" rx="2.5" fill="white" fill-opacity="0.5"/>
86
+ <rect y="12" id="current_level" width="64" height="5" rx="2.5" fill="white"/>
87
+ <g filter="url(#filter_current_level)">
88
+ <circle id="circle_current_level" cx="74.5" cy="14.5" r="6.5" fill="white"/>
89
+ </g>
90
+ <g filter="url(#filter_heart_ball)">
91
+ <g filter="url(#filter_ball)">
92
+ <circle cx="169" cy="14" r="10" id="lock" fill="url(#paint0_linear_ball)"/>
93
+ </g>
94
+ <g filter="url(#filter_heart)">
95
+ <svg x="0" y="4" id="lock_box">
96
+ <path d="M10.217 6.42442c-0.713,-0.574,-1.304,-1.083,-1.928,-1.622c-0.348,-0.299,-0.707,-0.611,-1.101,-0.943l-0.013,-0.01c0,0,-0.023,-0.017,-0.04,-0.027l-0.167,-0.095l-0.15,0.12c0,0,-0.015,0.012,-0.024,0.02c-0.391,0.33,-0.749,0.64,-1.094,0.939c-0.622,0.539,-1.211,1.048,-1.924,1.624c-1.816,1.463,-3.598,3.263,-3.033,5.506c0.404,1.601,2.104,2.905,3.789,2.905c0.211,0,0.423,-0.02,0.626,-0.061c0.286,-0.058,0.572,-0.145,0.864,-0.265c-0.079,0.962,-0.413,1.864,-0.881,2.369l-0.423,0.459h0.633c0.633,0,1.018,-0.007,1.356,-0.013c0.248,-0.004,0.462,-0.008,0.72,-0.008c0.335,0,0.709,0.006,1.215,0.021l0.686,0.02l-0.474,-0.483c-0.504,-0.514,-0.847,-1.403,-0.923,-2.385c0.311,0.132,0.616,0.227,0.916,0.287c0.204,0.039,0.411,0.059,0.623,0.059c1.687,0,3.386,-1.304,3.789,-2.909c0.56,-2.243,-1.224,-4.041,-3.042,-5.504v-0.004z" fill="#933CBF"/>
97
+ <path d="M9.727,6.98459c-1.004,-0.83,-1.741,-1.515,-2.723,-2.365c-0.002,0,-0.004,-0.004,-0.007,-0.006c-0.002,0,-0.004,0.004,-0.006,0.006c-0.98,0.85,-1.715,1.537,-2.721,2.367c-1.455,1.202,-3.126,2.821,-2.638,4.81c0.37,1.511,2.091,2.751,3.665,2.43c0.389,-0.08,0.75,-0.224,1.094,-0.402c0,0.116,-0.004,0.233,-0.012,0.353c-0.064,0.991,-0.398,1.892,-0.86,2.401c1.481,0,1.481,-0.043,2.961,0c-0.481,-0.503,-0.834,-1.382,-0.9,-2.401c-0.008,-0.127,-0.012,-0.253,-0.012,-0.378c0.357,0.19,0.733,0.342,1.14,0.425c1.574,0.319,3.292,-0.922,3.661,-2.433c0.486,-1.992,-1.189,-3.609,-2.644,
98
+ -4.809l0.002,0.002z" fill="url(#paint1_linear_lock)"/>
99
+ <path d="M9.255,7.551c-0.844,-0.716,-1.462,-1.309,-2.286,-2.045c-0.002,0,-0.004,-0.004,-0.006,-0.006c0,0,-0.004,0.004,-0.006,0.006c-0.824,0.736,-1.44,1.329,-2.284,2.047c-0.919,0.782,-1.94,1.769,-2.214,2.943c-0.115,0.021,-0.914,0.044,-0.914,0.044l0.887,0.083c-0.039,0.206,-0.055,0.418,-0.041,0.638c0.087,-1.371,1.25,-2.507,2.282,-3.384c0.844,-0.718,1.462,-1.313,2.284,-2.047c0.002,-0.002,0.004,-0.004,0.006,-0.006c0.002,0,0.004,0.004,0.006,0.004c0.824,0.734,1.442,1.329,2.286,2.045c1.034,0.879,2.198,2.013,2.286,3.386c0.093,-1.517,-1.173,-2.761,-2.286,-3.708z" fill="#9040C9"/>
100
+ </svg>
101
+ </g>
102
+ </g>
103
+ <g filter="url(#filter_lock)">
104
+ <svg x="100%" y="9" id="heart_box">
105
+ <path d="M7,6c-0.19,-0.002,-0.377,0.052,-0.534,0.154c-0.158,0.103,-0.278,0.25,-0.346,0.42c-0.069,0.171,-0.081,0.357,-0.035,0.535c0.046,0.177,0.147,0.337,0.29,0.457v0.834c0,0.159,0.066,0.312,0.183,0.424c0.117,0.113,0.276,0.176,0.442,0.176c0.166,0,0.325,-0.063,0.442,-0.176c0.117,-0.112,0.183,-0.265,0.183,-0.424v-0.834c0.143,-0.12,0.244,-0.28,0.29,-0.457c0.046,-0.178,0.034,-0.364,-0.035,-0.535c-0.068,-0.17,-0.188,-0.317,-0.346,-0.42c-0.157,-0.102,-0.344,-0.156,-0.534,-0.154zm3.125,-2.4v-1.2c0,-0.796,-0.329,-1.559,-0.915,-2.121c-0.586,-0.563,-1.381,-0.879,-2.21,-0.879c-0.829,0,-1.624,0.316,-2.21,0.879c-0.586,0.562,-0.915,1.325,-0.915,2.121v1.2c-0.497,0,-0.974,0.19,-1.326,0.527c-0.351,0.338,-0.549,0.796,-0.549,1.273v4.2c0,0.477,0.198,0.935,0.549,1.273c0.352,0.337,0.829,0.527,1.326,0.527h6.25c0.497,0,0.974,-0.19,1.326,-0.527c0.351,-0.338,0.549,-0.796,0.549,-1.273v-4.2c0,-0.477,-0.198,-0.935,-0.549,-1.273c-0.352,-0.337,-0.829,-0.527,-1.326,-0.527zm-5,-1.2c0,-0.477,0.198,-0.935,0.549,-1.273c0.352,-0.337,0.829,-0.527,1.326,-0.527c0.497,0,0.974,0.19,1.326,0.527c0.351,0.338,0.549,0.796,0.549,1.273v1.2h-3.75v-1.2zm5.625,7.2c0,0.159,-0.066,0.312,-0.183,0.424c-0.117,0.113,-0.276,0.176,-0.442,0.176h-6.25c-0.166,0,-0.325,-0.063,-0.442,-0.176c-0.117,-0.112,-0.183,-0.265,-0.183,-0.424v-4.2c0,-0.159,0.066,-0.312,0.183,-0.424c0.117,-0.113,0.276,-0.176,0.442,-0.176h6.25c0.166,0,0.325,0.063,0.442,0.176c0.117,0.112,0.183,0.265,0.183,0.424v4.2z" fill="white"/>
106
+ </svg>
107
+ </g>
108
+ <defs>
109
+ <filter id="filter_current_level" x="64" y="4" width="21" height="21" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
110
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
111
+ <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
112
+ <feGaussianBlur stdDeviation="2" result="effect1_foregroundBlur_305_23"/>
113
+ </filter>
114
+ <filter id="filter_heart_ball" x="155" y="0" width="28" height="28" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
115
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
116
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
117
+ <feOffset/>
118
+ <feGaussianBlur stdDeviation="2"/>
119
+ <feComposite in2="hardAlpha" operator="out"/>
120
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
121
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_305_23"/>
122
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_305_23" result="shape"/>
123
+ </filter>
124
+ <filter id="filter_ball" x="159" y="4" width="20" height="21" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
125
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
126
+ <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
127
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
128
+ <feOffset dy="1"/>
129
+ <feGaussianBlur stdDeviation="1"/>
130
+ <feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
131
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.55 0"/>
132
+ <feBlend mode="normal" in2="shape" result="effect1_innerShadow_305_23"/>
133
+ </filter>
134
+ <filter id="filter_heart" x="161.636" y="5.72727" width="14.7271" height="15.6364" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
135
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
136
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
137
+ <feOffset/>
138
+ <feGaussianBlur stdDeviation="0.5"/>
139
+ <feComposite in2="hardAlpha" operator="out"/>
140
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
141
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_305_23"/>
142
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_305_23" result="shape"/>
143
+ </filter>
144
+ <filter id="filter_lock" x="50" y="7" width="12" height="14" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
145
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
146
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
147
+ <feOffset/>
148
+ <feGaussianBlur stdDeviation="0.5"/>
149
+ <feComposite in2="hardAlpha" operator="out"/>
150
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
151
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_305_23"/>
152
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_305_23" result="shape"/>
153
+ </filter>
154
+ <linearGradient id="paint0_linear_ball" x1="163" y1="6" x2="174.2" y2="22.6" gradientUnits="userSpaceOnUse">
155
+ <stop stop-color="#946AD7"/>
156
+ <stop offset="1" stop-color="#EFABEB"/>
157
+ </linearGradient>
158
+ <linearGradient id="paint1_linear_lock" x1="100%" y1="18.4056" x2="169.002" y2="10.2845" gradientUnits="userSpaceOnUse">
159
+ <stop stop-color="#814FD6"/>
160
+ <stop offset="1" stop-color="#D679D8"/>
161
+ </linearGradient>
162
+ </defs>
163
+ </svg>
164
+ `;
165
+
166
+ const DEFAULT_LANGUAGE = 'en';
167
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
168
+ const TRANSLATIONS = {
169
+ en: {
170
+ redeem: 'Redeem',
171
+ expireOn: 'Expire on ',
172
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
173
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
174
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
175
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
176
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
177
+ spendablePoints: 'Spendable Points:',
178
+ details: 'Details',
179
+ earningRules: 'Earning Rules',
180
+ xp: 'XP',
181
+ sp: 'Coins',
182
+ termAndConditions: 'Term & Conditions',
183
+ },
184
+ 'zh-hk': {
185
+ redeem: '兑奖',
186
+ expireOn: 'Expire on ',
187
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
188
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
189
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
190
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
191
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
192
+ spendablePoints: 'Spendable Points:',
193
+ details: '明细',
194
+ earningRules: 'Earning Rules',
195
+ xp: 'XP',
196
+ sp: 'Coins',
197
+ termAndConditions: 'Term & Conditions',
198
+ },
199
+ de: {
200
+ redeem: 'Redeem',
201
+ expireOn: 'Expire on ',
202
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
203
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
204
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
205
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
206
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
207
+ spendablePoints: 'Spendable Points:',
208
+ details: 'Details',
209
+ earningRules: 'Earning Rules',
210
+ xp: 'XP',
211
+ sp: 'Coins',
212
+ termAndConditions: 'Term & Conditions',
213
+ },
214
+ it: {
215
+ redeem: 'Redeem',
216
+ expireOn: 'Expire on ',
217
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
218
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
219
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
220
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
221
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
222
+ spendablePoints: 'Spendable Points:',
223
+ details: 'Details',
224
+ earningRules: 'Earning Rules',
225
+ xp: 'XP',
226
+ sp: 'Coins',
227
+ termAndConditions: 'Term & Conditions',
228
+ },
229
+ fr: {
230
+ redeem: 'Redeem',
231
+ expireOn: 'Expire on ',
232
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
233
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
234
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
235
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
236
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
237
+ spendablePoints: 'Spendable Points:',
238
+ details: 'Details',
239
+ earningRules: 'Earning Rules',
240
+ xp: 'XP',
241
+ sp: 'Coins',
242
+ termAndConditions: 'Term & Conditions',
243
+ },
244
+ es: {
245
+ redeem: 'Redeem'
246
+ },
247
+ tr: {
248
+ redeem: 'Redeem'
249
+ },
250
+ ru: {
251
+ redeem: 'Redeem'
252
+ },
253
+ ro: {
254
+ redeem: 'Redeem'
255
+ },
256
+ hr: {
257
+ redeem: 'Otkupiti',
258
+ expireOn: 'Istječe',
259
+ pointsToBeExpired: '${expirationPoints} bodova ističe za ${expireDay} dana',
260
+ tipsForNextLevel: 'Trebate ${pointsToReach} da dosegnete razinu ${levelName}',
261
+ spendablePoints: 'Bodovi za potrošit:',
262
+ details: 'Detalji',
263
+ xp: 'XP',
264
+ },
265
+ hu: {
266
+ redeem: 'Redeem'
267
+ },
268
+ pl: {
269
+ redeem: 'Redeem'
270
+ },
271
+ pt: {
272
+ redeem: 'Redeem'
273
+ },
274
+ sl: {
275
+ redeem: 'Redeem'
276
+ },
277
+ sr: {
278
+ redeem: 'Redeem'
279
+ }
280
+ };
281
+ const translate = (key, customLang) => {
282
+ const lang = customLang;
283
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
284
+ };
285
+ const translateWithParams = (key, params) => {
286
+ const lang = params['lang'];
287
+ let templateString = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
288
+ if (!params) {
289
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
290
+ }
291
+ Object.keys(params).forEach((paramName) => {
292
+ templateString = templateString.replace(new RegExp('\\$\{' + paramName + '\}', 'gm'), params[paramName]);
293
+ });
294
+ return templateString;
295
+ };
296
+
297
+ function _typeof(o) {
298
+ "@babel/helpers - typeof";
299
+
300
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
301
+ return typeof o;
302
+ } : function (o) {
303
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
304
+ }, _typeof(o);
305
+ }
306
+
307
+ function requiredArgs(required, args) {
308
+ if (args.length < required) {
309
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
310
+ }
311
+ }
312
+
313
+ /**
314
+ * @name isDate
315
+ * @category Common Helpers
316
+ * @summary Is the given value a date?
317
+ *
318
+ * @description
319
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
320
+ *
321
+ * @param {*} value - the value to check
322
+ * @returns {boolean} true if the given value is a date
323
+ * @throws {TypeError} 1 arguments required
324
+ *
325
+ * @example
326
+ * // For a valid date:
327
+ * const result = isDate(new Date())
328
+ * //=> true
329
+ *
330
+ * @example
331
+ * // For an invalid date:
332
+ * const result = isDate(new Date(NaN))
333
+ * //=> true
334
+ *
335
+ * @example
336
+ * // For some value:
337
+ * const result = isDate('2014-02-31')
338
+ * //=> false
339
+ *
340
+ * @example
341
+ * // For an object:
342
+ * const result = isDate({})
343
+ * //=> false
344
+ */
345
+ function isDate(value) {
346
+ requiredArgs(1, arguments);
347
+ return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
348
+ }
349
+
350
+ /**
351
+ * @name toDate
352
+ * @category Common Helpers
353
+ * @summary Convert the given argument to an instance of Date.
354
+ *
355
+ * @description
356
+ * Convert the given argument to an instance of Date.
357
+ *
358
+ * If the argument is an instance of Date, the function returns its clone.
359
+ *
360
+ * If the argument is a number, it is treated as a timestamp.
361
+ *
362
+ * If the argument is none of the above, the function returns Invalid Date.
363
+ *
364
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
365
+ *
366
+ * @param {Date|Number} argument - the value to convert
367
+ * @returns {Date} the parsed date in the local time zone
368
+ * @throws {TypeError} 1 argument required
369
+ *
370
+ * @example
371
+ * // Clone the date:
372
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
373
+ * //=> Tue Feb 11 2014 11:30:30
374
+ *
375
+ * @example
376
+ * // Convert the timestamp to date:
377
+ * const result = toDate(1392098430000)
378
+ * //=> Tue Feb 11 2014 11:30:30
379
+ */
380
+ function toDate(argument) {
381
+ requiredArgs(1, arguments);
382
+ var argStr = Object.prototype.toString.call(argument);
383
+
384
+ // Clone the date
385
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
386
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
387
+ return new Date(argument.getTime());
388
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
389
+ return new Date(argument);
390
+ } else {
391
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
392
+ // eslint-disable-next-line no-console
393
+ console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
394
+ // eslint-disable-next-line no-console
395
+ console.warn(new Error().stack);
396
+ }
397
+ return new Date(NaN);
398
+ }
399
+ }
400
+
401
+ /**
402
+ * @name isValid
403
+ * @category Common Helpers
404
+ * @summary Is the given date valid?
405
+ *
406
+ * @description
407
+ * Returns false if argument is Invalid Date and true otherwise.
408
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
409
+ * Invalid Date is a Date, whose time value is NaN.
410
+ *
411
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
412
+ *
413
+ * @param {*} date - the date to check
414
+ * @returns {Boolean} the date is valid
415
+ * @throws {TypeError} 1 argument required
416
+ *
417
+ * @example
418
+ * // For the valid date:
419
+ * const result = isValid(new Date(2014, 1, 31))
420
+ * //=> true
421
+ *
422
+ * @example
423
+ * // For the value, convertable into a date:
424
+ * const result = isValid(1393804800000)
425
+ * //=> true
426
+ *
427
+ * @example
428
+ * // For the invalid date:
429
+ * const result = isValid(new Date(''))
430
+ * //=> false
431
+ */
432
+ function isValid(dirtyDate) {
433
+ requiredArgs(1, arguments);
434
+ if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
435
+ return false;
436
+ }
437
+ var date = toDate(dirtyDate);
438
+ return !isNaN(Number(date));
439
+ }
440
+
441
+ function toInteger(dirtyNumber) {
442
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
443
+ return NaN;
444
+ }
445
+ var number = Number(dirtyNumber);
446
+ if (isNaN(number)) {
447
+ return number;
448
+ }
449
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
450
+ }
451
+
452
+ /**
453
+ * @name addMilliseconds
454
+ * @category Millisecond Helpers
455
+ * @summary Add the specified number of milliseconds to the given date.
456
+ *
457
+ * @description
458
+ * Add the specified number of milliseconds to the given date.
459
+ *
460
+ * @param {Date|Number} date - the date to be changed
461
+ * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
462
+ * @returns {Date} the new date with the milliseconds added
463
+ * @throws {TypeError} 2 arguments required
464
+ *
465
+ * @example
466
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
467
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
468
+ * //=> Thu Jul 10 2014 12:45:30.750
469
+ */
470
+ function addMilliseconds(dirtyDate, dirtyAmount) {
471
+ requiredArgs(2, arguments);
472
+ var timestamp = toDate(dirtyDate).getTime();
473
+ var amount = toInteger(dirtyAmount);
474
+ return new Date(timestamp + amount);
475
+ }
476
+
477
+ /**
478
+ * @name subMilliseconds
479
+ * @category Millisecond Helpers
480
+ * @summary Subtract the specified number of milliseconds from the given date.
481
+ *
482
+ * @description
483
+ * Subtract the specified number of milliseconds from the given date.
484
+ *
485
+ * @param {Date|Number} date - the date to be changed
486
+ * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
487
+ * @returns {Date} the new date with the milliseconds subtracted
488
+ * @throws {TypeError} 2 arguments required
489
+ *
490
+ * @example
491
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
492
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
493
+ * //=> Thu Jul 10 2014 12:45:29.250
494
+ */
495
+ function subMilliseconds(dirtyDate, dirtyAmount) {
496
+ requiredArgs(2, arguments);
497
+ var amount = toInteger(dirtyAmount);
498
+ return addMilliseconds(dirtyDate, -amount);
499
+ }
500
+
501
+ var MILLISECONDS_IN_DAY$1 = 86400000;
502
+ function getUTCDayOfYear(dirtyDate) {
503
+ requiredArgs(1, arguments);
504
+ var date = toDate(dirtyDate);
505
+ var timestamp = date.getTime();
506
+ date.setUTCMonth(0, 1);
507
+ date.setUTCHours(0, 0, 0, 0);
508
+ var startOfYearTimestamp = date.getTime();
509
+ var difference = timestamp - startOfYearTimestamp;
510
+ return Math.floor(difference / MILLISECONDS_IN_DAY$1) + 1;
511
+ }
512
+
513
+ function startOfUTCISOWeek(dirtyDate) {
514
+ requiredArgs(1, arguments);
515
+ var weekStartsOn = 1;
516
+ var date = toDate(dirtyDate);
517
+ var day = date.getUTCDay();
518
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
519
+ date.setUTCDate(date.getUTCDate() - diff);
520
+ date.setUTCHours(0, 0, 0, 0);
521
+ return date;
522
+ }
523
+
524
+ function getUTCISOWeekYear(dirtyDate) {
525
+ requiredArgs(1, arguments);
526
+ var date = toDate(dirtyDate);
527
+ var year = date.getUTCFullYear();
528
+ var fourthOfJanuaryOfNextYear = new Date(0);
529
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
530
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
531
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
532
+ var fourthOfJanuaryOfThisYear = new Date(0);
533
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
534
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
535
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
536
+ if (date.getTime() >= startOfNextYear.getTime()) {
537
+ return year + 1;
538
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
539
+ return year;
540
+ } else {
541
+ return year - 1;
542
+ }
543
+ }
544
+
545
+ function startOfUTCISOWeekYear(dirtyDate) {
546
+ requiredArgs(1, arguments);
547
+ var year = getUTCISOWeekYear(dirtyDate);
548
+ var fourthOfJanuary = new Date(0);
549
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
550
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
551
+ var date = startOfUTCISOWeek(fourthOfJanuary);
552
+ return date;
553
+ }
554
+
555
+ var MILLISECONDS_IN_WEEK$1 = 604800000;
556
+ function getUTCISOWeek(dirtyDate) {
557
+ requiredArgs(1, arguments);
558
+ var date = toDate(dirtyDate);
559
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
560
+
561
+ // Round the number of days to the nearest integer
562
+ // because the number of milliseconds in a week is not constant
563
+ // (e.g. it's different in the week of the daylight saving time clock shift)
564
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
565
+ }
566
+
567
+ var defaultOptions = {};
568
+ function getDefaultOptions() {
569
+ return defaultOptions;
570
+ }
571
+
572
+ function startOfUTCWeek(dirtyDate, options) {
573
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
574
+ requiredArgs(1, arguments);
575
+ var defaultOptions = getDefaultOptions();
576
+ var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
577
+
578
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
579
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
580
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
581
+ }
582
+ var date = toDate(dirtyDate);
583
+ var day = date.getUTCDay();
584
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
585
+ date.setUTCDate(date.getUTCDate() - diff);
586
+ date.setUTCHours(0, 0, 0, 0);
587
+ return date;
588
+ }
589
+
590
+ function getUTCWeekYear(dirtyDate, options) {
591
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
592
+ requiredArgs(1, arguments);
593
+ var date = toDate(dirtyDate);
594
+ var year = date.getUTCFullYear();
595
+ var defaultOptions = getDefaultOptions();
596
+ var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
597
+
598
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
599
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
600
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
601
+ }
602
+ var firstWeekOfNextYear = new Date(0);
603
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
604
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
605
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
606
+ var firstWeekOfThisYear = new Date(0);
607
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
608
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
609
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
610
+ if (date.getTime() >= startOfNextYear.getTime()) {
611
+ return year + 1;
612
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
613
+ return year;
614
+ } else {
615
+ return year - 1;
616
+ }
617
+ }
618
+
619
+ function startOfUTCWeekYear(dirtyDate, options) {
620
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
621
+ requiredArgs(1, arguments);
622
+ var defaultOptions = getDefaultOptions();
623
+ var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
624
+ var year = getUTCWeekYear(dirtyDate, options);
625
+ var firstWeek = new Date(0);
626
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
627
+ firstWeek.setUTCHours(0, 0, 0, 0);
628
+ var date = startOfUTCWeek(firstWeek, options);
629
+ return date;
630
+ }
631
+
632
+ var MILLISECONDS_IN_WEEK = 604800000;
633
+ function getUTCWeek(dirtyDate, options) {
634
+ requiredArgs(1, arguments);
635
+ var date = toDate(dirtyDate);
636
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
637
+
638
+ // Round the number of days to the nearest integer
639
+ // because the number of milliseconds in a week is not constant
640
+ // (e.g. it's different in the week of the daylight saving time clock shift)
641
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
642
+ }
643
+
644
+ function addLeadingZeros(number, targetLength) {
645
+ var sign = number < 0 ? '-' : '';
646
+ var output = Math.abs(number).toString();
647
+ while (output.length < targetLength) {
648
+ output = '0' + output;
649
+ }
650
+ return sign + output;
651
+ }
652
+
653
+ /*
654
+ * | | Unit | | Unit |
655
+ * |-----|--------------------------------|-----|--------------------------------|
656
+ * | a | AM, PM | A* | |
657
+ * | d | Day of month | D | |
658
+ * | h | Hour [1-12] | H | Hour [0-23] |
659
+ * | m | Minute | M | Month |
660
+ * | s | Second | S | Fraction of second |
661
+ * | y | Year (abs) | Y | |
662
+ *
663
+ * Letters marked by * are not implemented but reserved by Unicode standard.
664
+ */
665
+ var formatters$1 = {
666
+ // Year
667
+ y: function y(date, token) {
668
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
669
+ // | Year | y | yy | yyy | yyyy | yyyyy |
670
+ // |----------|-------|----|-------|-------|-------|
671
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
672
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
673
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
674
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
675
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
676
+
677
+ var signedYear = date.getUTCFullYear();
678
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
679
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
680
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
681
+ },
682
+ // Month
683
+ M: function M(date, token) {
684
+ var month = date.getUTCMonth();
685
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
686
+ },
687
+ // Day of the month
688
+ d: function d(date, token) {
689
+ return addLeadingZeros(date.getUTCDate(), token.length);
690
+ },
691
+ // AM or PM
692
+ a: function a(date, token) {
693
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
694
+ switch (token) {
695
+ case 'a':
696
+ case 'aa':
697
+ return dayPeriodEnumValue.toUpperCase();
698
+ case 'aaa':
699
+ return dayPeriodEnumValue;
700
+ case 'aaaaa':
701
+ return dayPeriodEnumValue[0];
702
+ case 'aaaa':
703
+ default:
704
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
705
+ }
706
+ },
707
+ // Hour [1-12]
708
+ h: function h(date, token) {
709
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
710
+ },
711
+ // Hour [0-23]
712
+ H: function H(date, token) {
713
+ return addLeadingZeros(date.getUTCHours(), token.length);
714
+ },
715
+ // Minute
716
+ m: function m(date, token) {
717
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
718
+ },
719
+ // Second
720
+ s: function s(date, token) {
721
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
722
+ },
723
+ // Fraction of second
724
+ S: function S(date, token) {
725
+ var numberOfDigits = token.length;
726
+ var milliseconds = date.getUTCMilliseconds();
727
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
728
+ return addLeadingZeros(fractionalSeconds, token.length);
729
+ }
730
+ };
731
+
732
+ var dayPeriodEnum = {
733
+ am: 'am',
734
+ pm: 'pm',
735
+ midnight: 'midnight',
736
+ noon: 'noon',
737
+ morning: 'morning',
738
+ afternoon: 'afternoon',
739
+ evening: 'evening',
740
+ night: 'night'
741
+ };
742
+ /*
743
+ * | | Unit | | Unit |
744
+ * |-----|--------------------------------|-----|--------------------------------|
745
+ * | a | AM, PM | A* | Milliseconds in day |
746
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
747
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
748
+ * | d | Day of month | D | Day of year |
749
+ * | e | Local day of week | E | Day of week |
750
+ * | f | | F* | Day of week in month |
751
+ * | g* | Modified Julian day | G | Era |
752
+ * | h | Hour [1-12] | H | Hour [0-23] |
753
+ * | i! | ISO day of week | I! | ISO week of year |
754
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
755
+ * | k | Hour [1-24] | K | Hour [0-11] |
756
+ * | l* | (deprecated) | L | Stand-alone month |
757
+ * | m | Minute | M | Month |
758
+ * | n | | N | |
759
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
760
+ * | p! | Long localized time | P! | Long localized date |
761
+ * | q | Stand-alone quarter | Q | Quarter |
762
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
763
+ * | s | Second | S | Fraction of second |
764
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
765
+ * | u | Extended year | U* | Cyclic year |
766
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
767
+ * | w | Local week of year | W* | Week of month |
768
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
769
+ * | y | Year (abs) | Y | Local week-numbering year |
770
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
771
+ *
772
+ * Letters marked by * are not implemented but reserved by Unicode standard.
773
+ *
774
+ * Letters marked by ! are non-standard, but implemented by date-fns:
775
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
776
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
777
+ * i.e. 7 for Sunday, 1 for Monday, etc.
778
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
779
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
780
+ * `R` is supposed to be used in conjunction with `I` and `i`
781
+ * for universal ISO week-numbering date, whereas
782
+ * `Y` is supposed to be used in conjunction with `w` and `e`
783
+ * for week-numbering date specific to the locale.
784
+ * - `P` is long localized date format
785
+ * - `p` is long localized time format
786
+ */
787
+
788
+ var formatters = {
789
+ // Era
790
+ G: function G(date, token, localize) {
791
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
792
+ switch (token) {
793
+ // AD, BC
794
+ case 'G':
795
+ case 'GG':
796
+ case 'GGG':
797
+ return localize.era(era, {
798
+ width: 'abbreviated'
799
+ });
800
+ // A, B
801
+ case 'GGGGG':
802
+ return localize.era(era, {
803
+ width: 'narrow'
804
+ });
805
+ // Anno Domini, Before Christ
806
+ case 'GGGG':
807
+ default:
808
+ return localize.era(era, {
809
+ width: 'wide'
810
+ });
811
+ }
812
+ },
813
+ // Year
814
+ y: function y(date, token, localize) {
815
+ // Ordinal number
816
+ if (token === 'yo') {
817
+ var signedYear = date.getUTCFullYear();
818
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
819
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
820
+ return localize.ordinalNumber(year, {
821
+ unit: 'year'
822
+ });
823
+ }
824
+ return formatters$1.y(date, token);
825
+ },
826
+ // Local week-numbering year
827
+ Y: function Y(date, token, localize, options) {
828
+ var signedWeekYear = getUTCWeekYear(date, options);
829
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
830
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
831
+
832
+ // Two digit year
833
+ if (token === 'YY') {
834
+ var twoDigitYear = weekYear % 100;
835
+ return addLeadingZeros(twoDigitYear, 2);
836
+ }
837
+
838
+ // Ordinal number
839
+ if (token === 'Yo') {
840
+ return localize.ordinalNumber(weekYear, {
841
+ unit: 'year'
842
+ });
843
+ }
844
+
845
+ // Padding
846
+ return addLeadingZeros(weekYear, token.length);
847
+ },
848
+ // ISO week-numbering year
849
+ R: function R(date, token) {
850
+ var isoWeekYear = getUTCISOWeekYear(date);
851
+
852
+ // Padding
853
+ return addLeadingZeros(isoWeekYear, token.length);
854
+ },
855
+ // Extended year. This is a single number designating the year of this calendar system.
856
+ // The main difference between `y` and `u` localizers are B.C. years:
857
+ // | Year | `y` | `u` |
858
+ // |------|-----|-----|
859
+ // | AC 1 | 1 | 1 |
860
+ // | BC 1 | 1 | 0 |
861
+ // | BC 2 | 2 | -1 |
862
+ // Also `yy` always returns the last two digits of a year,
863
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
864
+ u: function u(date, token) {
865
+ var year = date.getUTCFullYear();
866
+ return addLeadingZeros(year, token.length);
867
+ },
868
+ // Quarter
869
+ Q: function Q(date, token, localize) {
870
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
871
+ switch (token) {
872
+ // 1, 2, 3, 4
873
+ case 'Q':
874
+ return String(quarter);
875
+ // 01, 02, 03, 04
876
+ case 'QQ':
877
+ return addLeadingZeros(quarter, 2);
878
+ // 1st, 2nd, 3rd, 4th
879
+ case 'Qo':
880
+ return localize.ordinalNumber(quarter, {
881
+ unit: 'quarter'
882
+ });
883
+ // Q1, Q2, Q3, Q4
884
+ case 'QQQ':
885
+ return localize.quarter(quarter, {
886
+ width: 'abbreviated',
887
+ context: 'formatting'
888
+ });
889
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
890
+ case 'QQQQQ':
891
+ return localize.quarter(quarter, {
892
+ width: 'narrow',
893
+ context: 'formatting'
894
+ });
895
+ // 1st quarter, 2nd quarter, ...
896
+ case 'QQQQ':
897
+ default:
898
+ return localize.quarter(quarter, {
899
+ width: 'wide',
900
+ context: 'formatting'
901
+ });
902
+ }
903
+ },
904
+ // Stand-alone quarter
905
+ q: function q(date, token, localize) {
906
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
907
+ switch (token) {
908
+ // 1, 2, 3, 4
909
+ case 'q':
910
+ return String(quarter);
911
+ // 01, 02, 03, 04
912
+ case 'qq':
913
+ return addLeadingZeros(quarter, 2);
914
+ // 1st, 2nd, 3rd, 4th
915
+ case 'qo':
916
+ return localize.ordinalNumber(quarter, {
917
+ unit: 'quarter'
918
+ });
919
+ // Q1, Q2, Q3, Q4
920
+ case 'qqq':
921
+ return localize.quarter(quarter, {
922
+ width: 'abbreviated',
923
+ context: 'standalone'
924
+ });
925
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
926
+ case 'qqqqq':
927
+ return localize.quarter(quarter, {
928
+ width: 'narrow',
929
+ context: 'standalone'
930
+ });
931
+ // 1st quarter, 2nd quarter, ...
932
+ case 'qqqq':
933
+ default:
934
+ return localize.quarter(quarter, {
935
+ width: 'wide',
936
+ context: 'standalone'
937
+ });
938
+ }
939
+ },
940
+ // Month
941
+ M: function M(date, token, localize) {
942
+ var month = date.getUTCMonth();
943
+ switch (token) {
944
+ case 'M':
945
+ case 'MM':
946
+ return formatters$1.M(date, token);
947
+ // 1st, 2nd, ..., 12th
948
+ case 'Mo':
949
+ return localize.ordinalNumber(month + 1, {
950
+ unit: 'month'
951
+ });
952
+ // Jan, Feb, ..., Dec
953
+ case 'MMM':
954
+ return localize.month(month, {
955
+ width: 'abbreviated',
956
+ context: 'formatting'
957
+ });
958
+ // J, F, ..., D
959
+ case 'MMMMM':
960
+ return localize.month(month, {
961
+ width: 'narrow',
962
+ context: 'formatting'
963
+ });
964
+ // January, February, ..., December
965
+ case 'MMMM':
966
+ default:
967
+ return localize.month(month, {
968
+ width: 'wide',
969
+ context: 'formatting'
970
+ });
971
+ }
972
+ },
973
+ // Stand-alone month
974
+ L: function L(date, token, localize) {
975
+ var month = date.getUTCMonth();
976
+ switch (token) {
977
+ // 1, 2, ..., 12
978
+ case 'L':
979
+ return String(month + 1);
980
+ // 01, 02, ..., 12
981
+ case 'LL':
982
+ return addLeadingZeros(month + 1, 2);
983
+ // 1st, 2nd, ..., 12th
984
+ case 'Lo':
985
+ return localize.ordinalNumber(month + 1, {
986
+ unit: 'month'
987
+ });
988
+ // Jan, Feb, ..., Dec
989
+ case 'LLL':
990
+ return localize.month(month, {
991
+ width: 'abbreviated',
992
+ context: 'standalone'
993
+ });
994
+ // J, F, ..., D
995
+ case 'LLLLL':
996
+ return localize.month(month, {
997
+ width: 'narrow',
998
+ context: 'standalone'
999
+ });
1000
+ // January, February, ..., December
1001
+ case 'LLLL':
1002
+ default:
1003
+ return localize.month(month, {
1004
+ width: 'wide',
1005
+ context: 'standalone'
1006
+ });
1007
+ }
1008
+ },
1009
+ // Local week of year
1010
+ w: function w(date, token, localize, options) {
1011
+ var week = getUTCWeek(date, options);
1012
+ if (token === 'wo') {
1013
+ return localize.ordinalNumber(week, {
1014
+ unit: 'week'
1015
+ });
1016
+ }
1017
+ return addLeadingZeros(week, token.length);
1018
+ },
1019
+ // ISO week of year
1020
+ I: function I(date, token, localize) {
1021
+ var isoWeek = getUTCISOWeek(date);
1022
+ if (token === 'Io') {
1023
+ return localize.ordinalNumber(isoWeek, {
1024
+ unit: 'week'
1025
+ });
1026
+ }
1027
+ return addLeadingZeros(isoWeek, token.length);
1028
+ },
1029
+ // Day of the month
1030
+ d: function d(date, token, localize) {
1031
+ if (token === 'do') {
1032
+ return localize.ordinalNumber(date.getUTCDate(), {
1033
+ unit: 'date'
1034
+ });
1035
+ }
1036
+ return formatters$1.d(date, token);
1037
+ },
1038
+ // Day of year
1039
+ D: function D(date, token, localize) {
1040
+ var dayOfYear = getUTCDayOfYear(date);
1041
+ if (token === 'Do') {
1042
+ return localize.ordinalNumber(dayOfYear, {
1043
+ unit: 'dayOfYear'
1044
+ });
1045
+ }
1046
+ return addLeadingZeros(dayOfYear, token.length);
1047
+ },
1048
+ // Day of week
1049
+ E: function E(date, token, localize) {
1050
+ var dayOfWeek = date.getUTCDay();
1051
+ switch (token) {
1052
+ // Tue
1053
+ case 'E':
1054
+ case 'EE':
1055
+ case 'EEE':
1056
+ return localize.day(dayOfWeek, {
1057
+ width: 'abbreviated',
1058
+ context: 'formatting'
1059
+ });
1060
+ // T
1061
+ case 'EEEEE':
1062
+ return localize.day(dayOfWeek, {
1063
+ width: 'narrow',
1064
+ context: 'formatting'
1065
+ });
1066
+ // Tu
1067
+ case 'EEEEEE':
1068
+ return localize.day(dayOfWeek, {
1069
+ width: 'short',
1070
+ context: 'formatting'
1071
+ });
1072
+ // Tuesday
1073
+ case 'EEEE':
1074
+ default:
1075
+ return localize.day(dayOfWeek, {
1076
+ width: 'wide',
1077
+ context: 'formatting'
1078
+ });
1079
+ }
1080
+ },
1081
+ // Local day of week
1082
+ e: function e(date, token, localize, options) {
1083
+ var dayOfWeek = date.getUTCDay();
1084
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1085
+ switch (token) {
1086
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
1087
+ case 'e':
1088
+ return String(localDayOfWeek);
1089
+ // Padded numerical value
1090
+ case 'ee':
1091
+ return addLeadingZeros(localDayOfWeek, 2);
1092
+ // 1st, 2nd, ..., 7th
1093
+ case 'eo':
1094
+ return localize.ordinalNumber(localDayOfWeek, {
1095
+ unit: 'day'
1096
+ });
1097
+ case 'eee':
1098
+ return localize.day(dayOfWeek, {
1099
+ width: 'abbreviated',
1100
+ context: 'formatting'
1101
+ });
1102
+ // T
1103
+ case 'eeeee':
1104
+ return localize.day(dayOfWeek, {
1105
+ width: 'narrow',
1106
+ context: 'formatting'
1107
+ });
1108
+ // Tu
1109
+ case 'eeeeee':
1110
+ return localize.day(dayOfWeek, {
1111
+ width: 'short',
1112
+ context: 'formatting'
1113
+ });
1114
+ // Tuesday
1115
+ case 'eeee':
1116
+ default:
1117
+ return localize.day(dayOfWeek, {
1118
+ width: 'wide',
1119
+ context: 'formatting'
1120
+ });
1121
+ }
1122
+ },
1123
+ // Stand-alone local day of week
1124
+ c: function c(date, token, localize, options) {
1125
+ var dayOfWeek = date.getUTCDay();
1126
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1127
+ switch (token) {
1128
+ // Numerical value (same as in `e`)
1129
+ case 'c':
1130
+ return String(localDayOfWeek);
1131
+ // Padded numerical value
1132
+ case 'cc':
1133
+ return addLeadingZeros(localDayOfWeek, token.length);
1134
+ // 1st, 2nd, ..., 7th
1135
+ case 'co':
1136
+ return localize.ordinalNumber(localDayOfWeek, {
1137
+ unit: 'day'
1138
+ });
1139
+ case 'ccc':
1140
+ return localize.day(dayOfWeek, {
1141
+ width: 'abbreviated',
1142
+ context: 'standalone'
1143
+ });
1144
+ // T
1145
+ case 'ccccc':
1146
+ return localize.day(dayOfWeek, {
1147
+ width: 'narrow',
1148
+ context: 'standalone'
1149
+ });
1150
+ // Tu
1151
+ case 'cccccc':
1152
+ return localize.day(dayOfWeek, {
1153
+ width: 'short',
1154
+ context: 'standalone'
1155
+ });
1156
+ // Tuesday
1157
+ case 'cccc':
1158
+ default:
1159
+ return localize.day(dayOfWeek, {
1160
+ width: 'wide',
1161
+ context: 'standalone'
1162
+ });
1163
+ }
1164
+ },
1165
+ // ISO day of week
1166
+ i: function i(date, token, localize) {
1167
+ var dayOfWeek = date.getUTCDay();
1168
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
1169
+ switch (token) {
1170
+ // 2
1171
+ case 'i':
1172
+ return String(isoDayOfWeek);
1173
+ // 02
1174
+ case 'ii':
1175
+ return addLeadingZeros(isoDayOfWeek, token.length);
1176
+ // 2nd
1177
+ case 'io':
1178
+ return localize.ordinalNumber(isoDayOfWeek, {
1179
+ unit: 'day'
1180
+ });
1181
+ // Tue
1182
+ case 'iii':
1183
+ return localize.day(dayOfWeek, {
1184
+ width: 'abbreviated',
1185
+ context: 'formatting'
1186
+ });
1187
+ // T
1188
+ case 'iiiii':
1189
+ return localize.day(dayOfWeek, {
1190
+ width: 'narrow',
1191
+ context: 'formatting'
1192
+ });
1193
+ // Tu
1194
+ case 'iiiiii':
1195
+ return localize.day(dayOfWeek, {
1196
+ width: 'short',
1197
+ context: 'formatting'
1198
+ });
1199
+ // Tuesday
1200
+ case 'iiii':
1201
+ default:
1202
+ return localize.day(dayOfWeek, {
1203
+ width: 'wide',
1204
+ context: 'formatting'
1205
+ });
1206
+ }
1207
+ },
1208
+ // AM or PM
1209
+ a: function a(date, token, localize) {
1210
+ var hours = date.getUTCHours();
1211
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1212
+ switch (token) {
1213
+ case 'a':
1214
+ case 'aa':
1215
+ return localize.dayPeriod(dayPeriodEnumValue, {
1216
+ width: 'abbreviated',
1217
+ context: 'formatting'
1218
+ });
1219
+ case 'aaa':
1220
+ return localize.dayPeriod(dayPeriodEnumValue, {
1221
+ width: 'abbreviated',
1222
+ context: 'formatting'
1223
+ }).toLowerCase();
1224
+ case 'aaaaa':
1225
+ return localize.dayPeriod(dayPeriodEnumValue, {
1226
+ width: 'narrow',
1227
+ context: 'formatting'
1228
+ });
1229
+ case 'aaaa':
1230
+ default:
1231
+ return localize.dayPeriod(dayPeriodEnumValue, {
1232
+ width: 'wide',
1233
+ context: 'formatting'
1234
+ });
1235
+ }
1236
+ },
1237
+ // AM, PM, midnight, noon
1238
+ b: function b(date, token, localize) {
1239
+ var hours = date.getUTCHours();
1240
+ var dayPeriodEnumValue;
1241
+ if (hours === 12) {
1242
+ dayPeriodEnumValue = dayPeriodEnum.noon;
1243
+ } else if (hours === 0) {
1244
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
1245
+ } else {
1246
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1247
+ }
1248
+ switch (token) {
1249
+ case 'b':
1250
+ case 'bb':
1251
+ return localize.dayPeriod(dayPeriodEnumValue, {
1252
+ width: 'abbreviated',
1253
+ context: 'formatting'
1254
+ });
1255
+ case 'bbb':
1256
+ return localize.dayPeriod(dayPeriodEnumValue, {
1257
+ width: 'abbreviated',
1258
+ context: 'formatting'
1259
+ }).toLowerCase();
1260
+ case 'bbbbb':
1261
+ return localize.dayPeriod(dayPeriodEnumValue, {
1262
+ width: 'narrow',
1263
+ context: 'formatting'
1264
+ });
1265
+ case 'bbbb':
1266
+ default:
1267
+ return localize.dayPeriod(dayPeriodEnumValue, {
1268
+ width: 'wide',
1269
+ context: 'formatting'
1270
+ });
1271
+ }
1272
+ },
1273
+ // in the morning, in the afternoon, in the evening, at night
1274
+ B: function B(date, token, localize) {
1275
+ var hours = date.getUTCHours();
1276
+ var dayPeriodEnumValue;
1277
+ if (hours >= 17) {
1278
+ dayPeriodEnumValue = dayPeriodEnum.evening;
1279
+ } else if (hours >= 12) {
1280
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
1281
+ } else if (hours >= 4) {
1282
+ dayPeriodEnumValue = dayPeriodEnum.morning;
1283
+ } else {
1284
+ dayPeriodEnumValue = dayPeriodEnum.night;
1285
+ }
1286
+ switch (token) {
1287
+ case 'B':
1288
+ case 'BB':
1289
+ case 'BBB':
1290
+ return localize.dayPeriod(dayPeriodEnumValue, {
1291
+ width: 'abbreviated',
1292
+ context: 'formatting'
1293
+ });
1294
+ case 'BBBBB':
1295
+ return localize.dayPeriod(dayPeriodEnumValue, {
1296
+ width: 'narrow',
1297
+ context: 'formatting'
1298
+ });
1299
+ case 'BBBB':
1300
+ default:
1301
+ return localize.dayPeriod(dayPeriodEnumValue, {
1302
+ width: 'wide',
1303
+ context: 'formatting'
1304
+ });
1305
+ }
1306
+ },
1307
+ // Hour [1-12]
1308
+ h: function h(date, token, localize) {
1309
+ if (token === 'ho') {
1310
+ var hours = date.getUTCHours() % 12;
1311
+ if (hours === 0) hours = 12;
1312
+ return localize.ordinalNumber(hours, {
1313
+ unit: 'hour'
1314
+ });
1315
+ }
1316
+ return formatters$1.h(date, token);
1317
+ },
1318
+ // Hour [0-23]
1319
+ H: function H(date, token, localize) {
1320
+ if (token === 'Ho') {
1321
+ return localize.ordinalNumber(date.getUTCHours(), {
1322
+ unit: 'hour'
1323
+ });
1324
+ }
1325
+ return formatters$1.H(date, token);
1326
+ },
1327
+ // Hour [0-11]
1328
+ K: function K(date, token, localize) {
1329
+ var hours = date.getUTCHours() % 12;
1330
+ if (token === 'Ko') {
1331
+ return localize.ordinalNumber(hours, {
1332
+ unit: 'hour'
1333
+ });
1334
+ }
1335
+ return addLeadingZeros(hours, token.length);
1336
+ },
1337
+ // Hour [1-24]
1338
+ k: function k(date, token, localize) {
1339
+ var hours = date.getUTCHours();
1340
+ if (hours === 0) hours = 24;
1341
+ if (token === 'ko') {
1342
+ return localize.ordinalNumber(hours, {
1343
+ unit: 'hour'
1344
+ });
1345
+ }
1346
+ return addLeadingZeros(hours, token.length);
1347
+ },
1348
+ // Minute
1349
+ m: function m(date, token, localize) {
1350
+ if (token === 'mo') {
1351
+ return localize.ordinalNumber(date.getUTCMinutes(), {
1352
+ unit: 'minute'
1353
+ });
1354
+ }
1355
+ return formatters$1.m(date, token);
1356
+ },
1357
+ // Second
1358
+ s: function s(date, token, localize) {
1359
+ if (token === 'so') {
1360
+ return localize.ordinalNumber(date.getUTCSeconds(), {
1361
+ unit: 'second'
1362
+ });
1363
+ }
1364
+ return formatters$1.s(date, token);
1365
+ },
1366
+ // Fraction of second
1367
+ S: function S(date, token) {
1368
+ return formatters$1.S(date, token);
1369
+ },
1370
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1371
+ X: function X(date, token, _localize, options) {
1372
+ var originalDate = options._originalDate || date;
1373
+ var timezoneOffset = originalDate.getTimezoneOffset();
1374
+ if (timezoneOffset === 0) {
1375
+ return 'Z';
1376
+ }
1377
+ switch (token) {
1378
+ // Hours and optional minutes
1379
+ case 'X':
1380
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1381
+
1382
+ // Hours, minutes and optional seconds without `:` delimiter
1383
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1384
+ // so this token always has the same output as `XX`
1385
+ case 'XXXX':
1386
+ case 'XX':
1387
+ // Hours and minutes without `:` delimiter
1388
+ return formatTimezone(timezoneOffset);
1389
+
1390
+ // Hours, minutes and optional seconds with `:` delimiter
1391
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1392
+ // so this token always has the same output as `XXX`
1393
+ case 'XXXXX':
1394
+ case 'XXX': // Hours and minutes with `:` delimiter
1395
+ default:
1396
+ return formatTimezone(timezoneOffset, ':');
1397
+ }
1398
+ },
1399
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1400
+ x: function x(date, token, _localize, options) {
1401
+ var originalDate = options._originalDate || date;
1402
+ var timezoneOffset = originalDate.getTimezoneOffset();
1403
+ switch (token) {
1404
+ // Hours and optional minutes
1405
+ case 'x':
1406
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1407
+
1408
+ // Hours, minutes and optional seconds without `:` delimiter
1409
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1410
+ // so this token always has the same output as `xx`
1411
+ case 'xxxx':
1412
+ case 'xx':
1413
+ // Hours and minutes without `:` delimiter
1414
+ return formatTimezone(timezoneOffset);
1415
+
1416
+ // Hours, minutes and optional seconds with `:` delimiter
1417
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1418
+ // so this token always has the same output as `xxx`
1419
+ case 'xxxxx':
1420
+ case 'xxx': // Hours and minutes with `:` delimiter
1421
+ default:
1422
+ return formatTimezone(timezoneOffset, ':');
1423
+ }
1424
+ },
1425
+ // Timezone (GMT)
1426
+ O: function O(date, token, _localize, options) {
1427
+ var originalDate = options._originalDate || date;
1428
+ var timezoneOffset = originalDate.getTimezoneOffset();
1429
+ switch (token) {
1430
+ // Short
1431
+ case 'O':
1432
+ case 'OO':
1433
+ case 'OOO':
1434
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1435
+ // Long
1436
+ case 'OOOO':
1437
+ default:
1438
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1439
+ }
1440
+ },
1441
+ // Timezone (specific non-location)
1442
+ z: function z(date, token, _localize, options) {
1443
+ var originalDate = options._originalDate || date;
1444
+ var timezoneOffset = originalDate.getTimezoneOffset();
1445
+ switch (token) {
1446
+ // Short
1447
+ case 'z':
1448
+ case 'zz':
1449
+ case 'zzz':
1450
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1451
+ // Long
1452
+ case 'zzzz':
1453
+ default:
1454
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1455
+ }
1456
+ },
1457
+ // Seconds timestamp
1458
+ t: function t(date, token, _localize, options) {
1459
+ var originalDate = options._originalDate || date;
1460
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
1461
+ return addLeadingZeros(timestamp, token.length);
1462
+ },
1463
+ // Milliseconds timestamp
1464
+ T: function T(date, token, _localize, options) {
1465
+ var originalDate = options._originalDate || date;
1466
+ var timestamp = originalDate.getTime();
1467
+ return addLeadingZeros(timestamp, token.length);
1468
+ }
1469
+ };
1470
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1471
+ var sign = offset > 0 ? '-' : '+';
1472
+ var absOffset = Math.abs(offset);
1473
+ var hours = Math.floor(absOffset / 60);
1474
+ var minutes = absOffset % 60;
1475
+ if (minutes === 0) {
1476
+ return sign + String(hours);
1477
+ }
1478
+ var delimiter = dirtyDelimiter || '';
1479
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1480
+ }
1481
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1482
+ if (offset % 60 === 0) {
1483
+ var sign = offset > 0 ? '-' : '+';
1484
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1485
+ }
1486
+ return formatTimezone(offset, dirtyDelimiter);
1487
+ }
1488
+ function formatTimezone(offset, dirtyDelimiter) {
1489
+ var delimiter = dirtyDelimiter || '';
1490
+ var sign = offset > 0 ? '-' : '+';
1491
+ var absOffset = Math.abs(offset);
1492
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1493
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1494
+ return sign + hours + delimiter + minutes;
1495
+ }
1496
+
1497
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1498
+ switch (pattern) {
1499
+ case 'P':
1500
+ return formatLong.date({
1501
+ width: 'short'
1502
+ });
1503
+ case 'PP':
1504
+ return formatLong.date({
1505
+ width: 'medium'
1506
+ });
1507
+ case 'PPP':
1508
+ return formatLong.date({
1509
+ width: 'long'
1510
+ });
1511
+ case 'PPPP':
1512
+ default:
1513
+ return formatLong.date({
1514
+ width: 'full'
1515
+ });
1516
+ }
1517
+ };
1518
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1519
+ switch (pattern) {
1520
+ case 'p':
1521
+ return formatLong.time({
1522
+ width: 'short'
1523
+ });
1524
+ case 'pp':
1525
+ return formatLong.time({
1526
+ width: 'medium'
1527
+ });
1528
+ case 'ppp':
1529
+ return formatLong.time({
1530
+ width: 'long'
1531
+ });
1532
+ case 'pppp':
1533
+ default:
1534
+ return formatLong.time({
1535
+ width: 'full'
1536
+ });
1537
+ }
1538
+ };
1539
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1540
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1541
+ var datePattern = matchResult[1];
1542
+ var timePattern = matchResult[2];
1543
+ if (!timePattern) {
1544
+ return dateLongFormatter(pattern, formatLong);
1545
+ }
1546
+ var dateTimeFormat;
1547
+ switch (datePattern) {
1548
+ case 'P':
1549
+ dateTimeFormat = formatLong.dateTime({
1550
+ width: 'short'
1551
+ });
1552
+ break;
1553
+ case 'PP':
1554
+ dateTimeFormat = formatLong.dateTime({
1555
+ width: 'medium'
1556
+ });
1557
+ break;
1558
+ case 'PPP':
1559
+ dateTimeFormat = formatLong.dateTime({
1560
+ width: 'long'
1561
+ });
1562
+ break;
1563
+ case 'PPPP':
1564
+ default:
1565
+ dateTimeFormat = formatLong.dateTime({
1566
+ width: 'full'
1567
+ });
1568
+ break;
1569
+ }
1570
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1571
+ };
1572
+ var longFormatters = {
1573
+ p: timeLongFormatter,
1574
+ P: dateTimeLongFormatter
1575
+ };
1576
+
1577
+ /**
1578
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
1579
+ * They usually appear for dates that denote time before the timezones were introduced
1580
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
1581
+ * and GMT+01:00:00 after that date)
1582
+ *
1583
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
1584
+ * which would lead to incorrect calculations.
1585
+ *
1586
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
1587
+ */
1588
+ function getTimezoneOffsetInMilliseconds(date) {
1589
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
1590
+ utcDate.setUTCFullYear(date.getFullYear());
1591
+ return date.getTime() - utcDate.getTime();
1592
+ }
1593
+
1594
+ var protectedDayOfYearTokens = ['D', 'DD'];
1595
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1596
+ function isProtectedDayOfYearToken(token) {
1597
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1598
+ }
1599
+ function isProtectedWeekYearToken(token) {
1600
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1601
+ }
1602
+ function throwProtectedError(token, format, input) {
1603
+ if (token === 'YYYY') {
1604
+ throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1605
+ } else if (token === 'YY') {
1606
+ throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1607
+ } else if (token === 'D') {
1608
+ throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1609
+ } else if (token === 'DD') {
1610
+ throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1611
+ }
1612
+ }
1613
+
1614
+ var formatDistanceLocale = {
1615
+ lessThanXSeconds: {
1616
+ one: 'less than a second',
1617
+ other: 'less than {{count}} seconds'
1618
+ },
1619
+ xSeconds: {
1620
+ one: '1 second',
1621
+ other: '{{count}} seconds'
1622
+ },
1623
+ halfAMinute: 'half a minute',
1624
+ lessThanXMinutes: {
1625
+ one: 'less than a minute',
1626
+ other: 'less than {{count}} minutes'
1627
+ },
1628
+ xMinutes: {
1629
+ one: '1 minute',
1630
+ other: '{{count}} minutes'
1631
+ },
1632
+ aboutXHours: {
1633
+ one: 'about 1 hour',
1634
+ other: 'about {{count}} hours'
1635
+ },
1636
+ xHours: {
1637
+ one: '1 hour',
1638
+ other: '{{count}} hours'
1639
+ },
1640
+ xDays: {
1641
+ one: '1 day',
1642
+ other: '{{count}} days'
1643
+ },
1644
+ aboutXWeeks: {
1645
+ one: 'about 1 week',
1646
+ other: 'about {{count}} weeks'
1647
+ },
1648
+ xWeeks: {
1649
+ one: '1 week',
1650
+ other: '{{count}} weeks'
1651
+ },
1652
+ aboutXMonths: {
1653
+ one: 'about 1 month',
1654
+ other: 'about {{count}} months'
1655
+ },
1656
+ xMonths: {
1657
+ one: '1 month',
1658
+ other: '{{count}} months'
1659
+ },
1660
+ aboutXYears: {
1661
+ one: 'about 1 year',
1662
+ other: 'about {{count}} years'
1663
+ },
1664
+ xYears: {
1665
+ one: '1 year',
1666
+ other: '{{count}} years'
1667
+ },
1668
+ overXYears: {
1669
+ one: 'over 1 year',
1670
+ other: 'over {{count}} years'
1671
+ },
1672
+ almostXYears: {
1673
+ one: 'almost 1 year',
1674
+ other: 'almost {{count}} years'
1675
+ }
1676
+ };
1677
+ var formatDistance = function formatDistance(token, count, options) {
1678
+ var result;
1679
+ var tokenValue = formatDistanceLocale[token];
1680
+ if (typeof tokenValue === 'string') {
1681
+ result = tokenValue;
1682
+ } else if (count === 1) {
1683
+ result = tokenValue.one;
1684
+ } else {
1685
+ result = tokenValue.other.replace('{{count}}', count.toString());
1686
+ }
1687
+ if (options !== null && options !== void 0 && options.addSuffix) {
1688
+ if (options.comparison && options.comparison > 0) {
1689
+ return 'in ' + result;
1690
+ } else {
1691
+ return result + ' ago';
1692
+ }
1693
+ }
1694
+ return result;
1695
+ };
1696
+
1697
+ function buildFormatLongFn(args) {
1698
+ return function () {
1699
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1700
+ // TODO: Remove String()
1701
+ var width = options.width ? String(options.width) : args.defaultWidth;
1702
+ var format = args.formats[width] || args.formats[args.defaultWidth];
1703
+ return format;
1704
+ };
1705
+ }
1706
+
1707
+ var dateFormats = {
1708
+ full: 'EEEE, MMMM do, y',
1709
+ long: 'MMMM do, y',
1710
+ medium: 'MMM d, y',
1711
+ short: 'MM/dd/yyyy'
1712
+ };
1713
+ var timeFormats = {
1714
+ full: 'h:mm:ss a zzzz',
1715
+ long: 'h:mm:ss a z',
1716
+ medium: 'h:mm:ss a',
1717
+ short: 'h:mm a'
1718
+ };
1719
+ var dateTimeFormats = {
1720
+ full: "{{date}} 'at' {{time}}",
1721
+ long: "{{date}} 'at' {{time}}",
1722
+ medium: '{{date}}, {{time}}',
1723
+ short: '{{date}}, {{time}}'
1724
+ };
1725
+ var formatLong = {
1726
+ date: buildFormatLongFn({
1727
+ formats: dateFormats,
1728
+ defaultWidth: 'full'
1729
+ }),
1730
+ time: buildFormatLongFn({
1731
+ formats: timeFormats,
1732
+ defaultWidth: 'full'
1733
+ }),
1734
+ dateTime: buildFormatLongFn({
1735
+ formats: dateTimeFormats,
1736
+ defaultWidth: 'full'
1737
+ })
1738
+ };
1739
+
1740
+ var formatRelativeLocale = {
1741
+ lastWeek: "'last' eeee 'at' p",
1742
+ yesterday: "'yesterday at' p",
1743
+ today: "'today at' p",
1744
+ tomorrow: "'tomorrow at' p",
1745
+ nextWeek: "eeee 'at' p",
1746
+ other: 'P'
1747
+ };
1748
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1749
+ return formatRelativeLocale[token];
1750
+ };
1751
+
1752
+ function buildLocalizeFn(args) {
1753
+ return function (dirtyIndex, options) {
1754
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1755
+ var valuesArray;
1756
+ if (context === 'formatting' && args.formattingValues) {
1757
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1758
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1759
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1760
+ } else {
1761
+ var _defaultWidth = args.defaultWidth;
1762
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1763
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
1764
+ }
1765
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1766
+ // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
1767
+ return valuesArray[index];
1768
+ };
1769
+ }
1770
+
1771
+ var eraValues = {
1772
+ narrow: ['B', 'A'],
1773
+ abbreviated: ['BC', 'AD'],
1774
+ wide: ['Before Christ', 'Anno Domini']
1775
+ };
1776
+ var quarterValues = {
1777
+ narrow: ['1', '2', '3', '4'],
1778
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1779
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1780
+ };
1781
+
1782
+ // Note: in English, the names of days of the week and months are capitalized.
1783
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1784
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1785
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1786
+ var monthValues = {
1787
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1788
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1789
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1790
+ };
1791
+ var dayValues = {
1792
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1793
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1794
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1795
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1796
+ };
1797
+ var dayPeriodValues = {
1798
+ narrow: {
1799
+ am: 'a',
1800
+ pm: 'p',
1801
+ midnight: 'mi',
1802
+ noon: 'n',
1803
+ morning: 'morning',
1804
+ afternoon: 'afternoon',
1805
+ evening: 'evening',
1806
+ night: 'night'
1807
+ },
1808
+ abbreviated: {
1809
+ am: 'AM',
1810
+ pm: 'PM',
1811
+ midnight: 'midnight',
1812
+ noon: 'noon',
1813
+ morning: 'morning',
1814
+ afternoon: 'afternoon',
1815
+ evening: 'evening',
1816
+ night: 'night'
1817
+ },
1818
+ wide: {
1819
+ am: 'a.m.',
1820
+ pm: 'p.m.',
1821
+ midnight: 'midnight',
1822
+ noon: 'noon',
1823
+ morning: 'morning',
1824
+ afternoon: 'afternoon',
1825
+ evening: 'evening',
1826
+ night: 'night'
1827
+ }
1828
+ };
1829
+ var formattingDayPeriodValues = {
1830
+ narrow: {
1831
+ am: 'a',
1832
+ pm: 'p',
1833
+ midnight: 'mi',
1834
+ noon: 'n',
1835
+ morning: 'in the morning',
1836
+ afternoon: 'in the afternoon',
1837
+ evening: 'in the evening',
1838
+ night: 'at night'
1839
+ },
1840
+ abbreviated: {
1841
+ am: 'AM',
1842
+ pm: 'PM',
1843
+ midnight: 'midnight',
1844
+ noon: 'noon',
1845
+ morning: 'in the morning',
1846
+ afternoon: 'in the afternoon',
1847
+ evening: 'in the evening',
1848
+ night: 'at night'
1849
+ },
1850
+ wide: {
1851
+ am: 'a.m.',
1852
+ pm: 'p.m.',
1853
+ midnight: 'midnight',
1854
+ noon: 'noon',
1855
+ morning: 'in the morning',
1856
+ afternoon: 'in the afternoon',
1857
+ evening: 'in the evening',
1858
+ night: 'at night'
1859
+ }
1860
+ };
1861
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1862
+ var number = Number(dirtyNumber);
1863
+
1864
+ // If ordinal numbers depend on context, for example,
1865
+ // if they are different for different grammatical genders,
1866
+ // use `options.unit`.
1867
+ //
1868
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1869
+ // 'day', 'hour', 'minute', 'second'.
1870
+
1871
+ var rem100 = number % 100;
1872
+ if (rem100 > 20 || rem100 < 10) {
1873
+ switch (rem100 % 10) {
1874
+ case 1:
1875
+ return number + 'st';
1876
+ case 2:
1877
+ return number + 'nd';
1878
+ case 3:
1879
+ return number + 'rd';
1880
+ }
1881
+ }
1882
+ return number + 'th';
1883
+ };
1884
+ var localize = {
1885
+ ordinalNumber: ordinalNumber,
1886
+ era: buildLocalizeFn({
1887
+ values: eraValues,
1888
+ defaultWidth: 'wide'
1889
+ }),
1890
+ quarter: buildLocalizeFn({
1891
+ values: quarterValues,
1892
+ defaultWidth: 'wide',
1893
+ argumentCallback: function argumentCallback(quarter) {
1894
+ return quarter - 1;
1895
+ }
1896
+ }),
1897
+ month: buildLocalizeFn({
1898
+ values: monthValues,
1899
+ defaultWidth: 'wide'
1900
+ }),
1901
+ day: buildLocalizeFn({
1902
+ values: dayValues,
1903
+ defaultWidth: 'wide'
1904
+ }),
1905
+ dayPeriod: buildLocalizeFn({
1906
+ values: dayPeriodValues,
1907
+ defaultWidth: 'wide',
1908
+ formattingValues: formattingDayPeriodValues,
1909
+ defaultFormattingWidth: 'wide'
1910
+ })
1911
+ };
1912
+
1913
+ function buildMatchFn(args) {
1914
+ return function (string) {
1915
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1916
+ var width = options.width;
1917
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1918
+ var matchResult = string.match(matchPattern);
1919
+ if (!matchResult) {
1920
+ return null;
1921
+ }
1922
+ var matchedString = matchResult[0];
1923
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1924
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1925
+ return pattern.test(matchedString);
1926
+ }) : findKey(parsePatterns, function (pattern) {
1927
+ return pattern.test(matchedString);
1928
+ });
1929
+ var value;
1930
+ value = args.valueCallback ? args.valueCallback(key) : key;
1931
+ value = options.valueCallback ? options.valueCallback(value) : value;
1932
+ var rest = string.slice(matchedString.length);
1933
+ return {
1934
+ value: value,
1935
+ rest: rest
1936
+ };
1937
+ };
1938
+ }
1939
+ function findKey(object, predicate) {
1940
+ for (var key in object) {
1941
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
1942
+ return key;
1943
+ }
1944
+ }
1945
+ return undefined;
1946
+ }
1947
+ function findIndex(array, predicate) {
1948
+ for (var key = 0; key < array.length; key++) {
1949
+ if (predicate(array[key])) {
1950
+ return key;
1951
+ }
1952
+ }
1953
+ return undefined;
1954
+ }
1955
+
1956
+ function buildMatchPatternFn(args) {
1957
+ return function (string) {
1958
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1959
+ var matchResult = string.match(args.matchPattern);
1960
+ if (!matchResult) return null;
1961
+ var matchedString = matchResult[0];
1962
+ var parseResult = string.match(args.parsePattern);
1963
+ if (!parseResult) return null;
1964
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1965
+ value = options.valueCallback ? options.valueCallback(value) : value;
1966
+ var rest = string.slice(matchedString.length);
1967
+ return {
1968
+ value: value,
1969
+ rest: rest
1970
+ };
1971
+ };
1972
+ }
1973
+
1974
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1975
+ var parseOrdinalNumberPattern = /\d+/i;
1976
+ var matchEraPatterns = {
1977
+ narrow: /^(b|a)/i,
1978
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1979
+ wide: /^(before christ|before common era|anno domini|common era)/i
1980
+ };
1981
+ var parseEraPatterns = {
1982
+ any: [/^b/i, /^(a|c)/i]
1983
+ };
1984
+ var matchQuarterPatterns = {
1985
+ narrow: /^[1234]/i,
1986
+ abbreviated: /^q[1234]/i,
1987
+ wide: /^[1234](th|st|nd|rd)? quarter/i
1988
+ };
1989
+ var parseQuarterPatterns = {
1990
+ any: [/1/i, /2/i, /3/i, /4/i]
1991
+ };
1992
+ var matchMonthPatterns = {
1993
+ narrow: /^[jfmasond]/i,
1994
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1995
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1996
+ };
1997
+ var parseMonthPatterns = {
1998
+ narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
1999
+ any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
2000
+ };
2001
+ var matchDayPatterns = {
2002
+ narrow: /^[smtwf]/i,
2003
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
2004
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
2005
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
2006
+ };
2007
+ var parseDayPatterns = {
2008
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
2009
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
2010
+ };
2011
+ var matchDayPeriodPatterns = {
2012
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
2013
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
2014
+ };
2015
+ var parseDayPeriodPatterns = {
2016
+ any: {
2017
+ am: /^a/i,
2018
+ pm: /^p/i,
2019
+ midnight: /^mi/i,
2020
+ noon: /^no/i,
2021
+ morning: /morning/i,
2022
+ afternoon: /afternoon/i,
2023
+ evening: /evening/i,
2024
+ night: /night/i
2025
+ }
2026
+ };
2027
+ var match = {
2028
+ ordinalNumber: buildMatchPatternFn({
2029
+ matchPattern: matchOrdinalNumberPattern,
2030
+ parsePattern: parseOrdinalNumberPattern,
2031
+ valueCallback: function valueCallback(value) {
2032
+ return parseInt(value, 10);
2033
+ }
2034
+ }),
2035
+ era: buildMatchFn({
2036
+ matchPatterns: matchEraPatterns,
2037
+ defaultMatchWidth: 'wide',
2038
+ parsePatterns: parseEraPatterns,
2039
+ defaultParseWidth: 'any'
2040
+ }),
2041
+ quarter: buildMatchFn({
2042
+ matchPatterns: matchQuarterPatterns,
2043
+ defaultMatchWidth: 'wide',
2044
+ parsePatterns: parseQuarterPatterns,
2045
+ defaultParseWidth: 'any',
2046
+ valueCallback: function valueCallback(index) {
2047
+ return index + 1;
2048
+ }
2049
+ }),
2050
+ month: buildMatchFn({
2051
+ matchPatterns: matchMonthPatterns,
2052
+ defaultMatchWidth: 'wide',
2053
+ parsePatterns: parseMonthPatterns,
2054
+ defaultParseWidth: 'any'
2055
+ }),
2056
+ day: buildMatchFn({
2057
+ matchPatterns: matchDayPatterns,
2058
+ defaultMatchWidth: 'wide',
2059
+ parsePatterns: parseDayPatterns,
2060
+ defaultParseWidth: 'any'
2061
+ }),
2062
+ dayPeriod: buildMatchFn({
2063
+ matchPatterns: matchDayPeriodPatterns,
2064
+ defaultMatchWidth: 'any',
2065
+ parsePatterns: parseDayPeriodPatterns,
2066
+ defaultParseWidth: 'any'
2067
+ })
2068
+ };
2069
+
2070
+ /**
2071
+ * @type {Locale}
2072
+ * @category Locales
2073
+ * @summary English locale (United States).
2074
+ * @language English
2075
+ * @iso-639-2 eng
2076
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
2077
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
2078
+ */
2079
+ var locale = {
2080
+ code: 'en-US',
2081
+ formatDistance: formatDistance,
2082
+ formatLong: formatLong,
2083
+ formatRelative: formatRelative,
2084
+ localize: localize,
2085
+ match: match,
2086
+ options: {
2087
+ weekStartsOn: 0 /* Sunday */,
2088
+ firstWeekContainsDate: 1
2089
+ }
2090
+ };
2091
+
2092
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
2093
+ // (one of the certain letters followed by `o`)
2094
+ // - (\w)\1* matches any sequences of the same letter
2095
+ // - '' matches two quote characters in a row
2096
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
2097
+ // except a single quote symbol, which ends the sequence.
2098
+ // Two quote characters do not end the sequence.
2099
+ // If there is no matching single quote
2100
+ // then the sequence will continue until the end of the string.
2101
+ // - . matches any single character unmatched by previous parts of the RegExps
2102
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2103
+
2104
+ // This RegExp catches symbols escaped by quotes, and also
2105
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2106
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2107
+ var escapedStringRegExp = /^'([^]*?)'?$/;
2108
+ var doubleQuoteRegExp = /''/g;
2109
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2110
+
2111
+ /**
2112
+ * @name format
2113
+ * @category Common Helpers
2114
+ * @summary Format the date.
2115
+ *
2116
+ * @description
2117
+ * Return the formatted date string in the given format. The result may vary by locale.
2118
+ *
2119
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2120
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2121
+ *
2122
+ * The characters wrapped between two single quotes characters (') are escaped.
2123
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
2124
+ * (see the last example)
2125
+ *
2126
+ * Format of the string is based on Unicode Technical Standard #35:
2127
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2128
+ * with a few additions (see note 7 below the table).
2129
+ *
2130
+ * Accepted patterns:
2131
+ * | Unit | Pattern | Result examples | Notes |
2132
+ * |---------------------------------|---------|-----------------------------------|-------|
2133
+ * | Era | G..GGG | AD, BC | |
2134
+ * | | GGGG | Anno Domini, Before Christ | 2 |
2135
+ * | | GGGGG | A, B | |
2136
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
2137
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
2138
+ * | | yy | 44, 01, 00, 17 | 5 |
2139
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
2140
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
2141
+ * | | yyyyy | ... | 3,5 |
2142
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
2143
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
2144
+ * | | YY | 44, 01, 00, 17 | 5,8 |
2145
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
2146
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
2147
+ * | | YYYYY | ... | 3,5 |
2148
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
2149
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
2150
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
2151
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
2152
+ * | | RRRRR | ... | 3,5,7 |
2153
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
2154
+ * | | uu | -43, 01, 1900, 2017 | 5 |
2155
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
2156
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
2157
+ * | | uuuuu | ... | 3,5 |
2158
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
2159
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
2160
+ * | | QQ | 01, 02, 03, 04 | |
2161
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
2162
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
2163
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
2164
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
2165
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
2166
+ * | | qq | 01, 02, 03, 04 | |
2167
+ * | | qqq | Q1, Q2, Q3, Q4 | |
2168
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
2169
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
2170
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
2171
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
2172
+ * | | MM | 01, 02, ..., 12 | |
2173
+ * | | MMM | Jan, Feb, ..., Dec | |
2174
+ * | | MMMM | January, February, ..., December | 2 |
2175
+ * | | MMMMM | J, F, ..., D | |
2176
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
2177
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
2178
+ * | | LL | 01, 02, ..., 12 | |
2179
+ * | | LLL | Jan, Feb, ..., Dec | |
2180
+ * | | LLLL | January, February, ..., December | 2 |
2181
+ * | | LLLLL | J, F, ..., D | |
2182
+ * | Local week of year | w | 1, 2, ..., 53 | |
2183
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
2184
+ * | | ww | 01, 02, ..., 53 | |
2185
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
2186
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
2187
+ * | | II | 01, 02, ..., 53 | 7 |
2188
+ * | Day of month | d | 1, 2, ..., 31 | |
2189
+ * | | do | 1st, 2nd, ..., 31st | 7 |
2190
+ * | | dd | 01, 02, ..., 31 | |
2191
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
2192
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
2193
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
2194
+ * | | DDD | 001, 002, ..., 365, 366 | |
2195
+ * | | DDDD | ... | 3 |
2196
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2197
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2198
+ * | | EEEEE | M, T, W, T, F, S, S | |
2199
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
2200
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2201
+ * | | io | 1st, 2nd, ..., 7th | 7 |
2202
+ * | | ii | 01, 02, ..., 07 | 7 |
2203
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2204
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2205
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
2206
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2207
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2208
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
2209
+ * | | ee | 02, 03, ..., 01 | |
2210
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
2211
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2212
+ * | | eeeee | M, T, W, T, F, S, S | |
2213
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2214
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2215
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
2216
+ * | | cc | 02, 03, ..., 01 | |
2217
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
2218
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2219
+ * | | ccccc | M, T, W, T, F, S, S | |
2220
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2221
+ * | AM, PM | a..aa | AM, PM | |
2222
+ * | | aaa | am, pm | |
2223
+ * | | aaaa | a.m., p.m. | 2 |
2224
+ * | | aaaaa | a, p | |
2225
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2226
+ * | | bbb | am, pm, noon, midnight | |
2227
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
2228
+ * | | bbbbb | a, p, n, mi | |
2229
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
2230
+ * | | BBBB | at night, in the morning, ... | 2 |
2231
+ * | | BBBBB | at night, in the morning, ... | |
2232
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2233
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2234
+ * | | hh | 01, 02, ..., 11, 12 | |
2235
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2236
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2237
+ * | | HH | 00, 01, 02, ..., 23 | |
2238
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2239
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2240
+ * | | KK | 01, 02, ..., 11, 00 | |
2241
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2242
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2243
+ * | | kk | 24, 01, 02, ..., 23 | |
2244
+ * | Minute | m | 0, 1, ..., 59 | |
2245
+ * | | mo | 0th, 1st, ..., 59th | 7 |
2246
+ * | | mm | 00, 01, ..., 59 | |
2247
+ * | Second | s | 0, 1, ..., 59 | |
2248
+ * | | so | 0th, 1st, ..., 59th | 7 |
2249
+ * | | ss | 00, 01, ..., 59 | |
2250
+ * | Fraction of second | S | 0, 1, ..., 9 | |
2251
+ * | | SS | 00, 01, ..., 99 | |
2252
+ * | | SSS | 000, 001, ..., 999 | |
2253
+ * | | SSSS | ... | 3 |
2254
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2255
+ * | | XX | -0800, +0530, Z | |
2256
+ * | | XXX | -08:00, +05:30, Z | |
2257
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2258
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2259
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2260
+ * | | xx | -0800, +0530, +0000 | |
2261
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
2262
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
2263
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2264
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2265
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2266
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2267
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2268
+ * | Seconds timestamp | t | 512969520 | 7 |
2269
+ * | | tt | ... | 3,7 |
2270
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
2271
+ * | | TT | ... | 3,7 |
2272
+ * | Long localized date | P | 04/29/1453 | 7 |
2273
+ * | | PP | Apr 29, 1453 | 7 |
2274
+ * | | PPP | April 29th, 1453 | 7 |
2275
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2276
+ * | Long localized time | p | 12:00 AM | 7 |
2277
+ * | | pp | 12:00:00 AM | 7 |
2278
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
2279
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2280
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2281
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2282
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
2283
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2284
+ * Notes:
2285
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2286
+ * are the same as "stand-alone" units, but are different in some languages.
2287
+ * "Formatting" units are declined according to the rules of the language
2288
+ * in the context of a date. "Stand-alone" units are always nominative singular:
2289
+ *
2290
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2291
+ *
2292
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2293
+ *
2294
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2295
+ * the single quote characters (see below).
2296
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2297
+ * the output will be the same as default pattern for this unit, usually
2298
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2299
+ * are marked with "2" in the last column of the table.
2300
+ *
2301
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2302
+ *
2303
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2304
+ *
2305
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2306
+ *
2307
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2308
+ *
2309
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2310
+ *
2311
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2312
+ * The output will be padded with zeros to match the length of the pattern.
2313
+ *
2314
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2315
+ *
2316
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2317
+ * These tokens represent the shortest form of the quarter.
2318
+ *
2319
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
2320
+ *
2321
+ * | Year | `y` | `u` |
2322
+ * |------|-----|-----|
2323
+ * | AC 1 | 1 | 1 |
2324
+ * | BC 1 | 1 | 0 |
2325
+ * | BC 2 | 2 | -1 |
2326
+ *
2327
+ * Also `yy` always returns the last two digits of a year,
2328
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2329
+ *
2330
+ * | Year | `yy` | `uu` |
2331
+ * |------|------|------|
2332
+ * | 1 | 01 | 01 |
2333
+ * | 14 | 14 | 14 |
2334
+ * | 376 | 76 | 376 |
2335
+ * | 1453 | 53 | 1453 |
2336
+ *
2337
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2338
+ * except local week-numbering years are dependent on `options.weekStartsOn`
2339
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2340
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2341
+ *
2342
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2343
+ * so right now these tokens fall back to GMT timezones.
2344
+ *
2345
+ * 7. These patterns are not in the Unicode Technical Standard #35:
2346
+ * - `i`: ISO day of week
2347
+ * - `I`: ISO week of year
2348
+ * - `R`: ISO week-numbering year
2349
+ * - `t`: seconds timestamp
2350
+ * - `T`: milliseconds timestamp
2351
+ * - `o`: ordinal number modifier
2352
+ * - `P`: long localized date
2353
+ * - `p`: long localized time
2354
+ *
2355
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2356
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2357
+ *
2358
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2359
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2360
+ *
2361
+ * @param {Date|Number} date - the original date
2362
+ * @param {String} format - the string of tokens
2363
+ * @param {Object} [options] - an object with options.
2364
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2365
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2366
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2367
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2368
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2369
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2370
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2371
+ * @returns {String} the formatted date string
2372
+ * @throws {TypeError} 2 arguments required
2373
+ * @throws {RangeError} `date` must not be Invalid Date
2374
+ * @throws {RangeError} `options.locale` must contain `localize` property
2375
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
2376
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2377
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2378
+ * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2379
+ * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2380
+ * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2381
+ * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2382
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
2383
+ *
2384
+ * @example
2385
+ * // Represent 11 February 2014 in middle-endian format:
2386
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2387
+ * //=> '02/11/2014'
2388
+ *
2389
+ * @example
2390
+ * // Represent 2 July 2014 in Esperanto:
2391
+ * import { eoLocale } from 'date-fns/locale/eo'
2392
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2393
+ * locale: eoLocale
2394
+ * })
2395
+ * //=> '2-a de julio 2014'
2396
+ *
2397
+ * @example
2398
+ * // Escape string by single quote characters:
2399
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2400
+ * //=> "3 o'clock"
2401
+ */
2402
+
2403
+ function format(dirtyDate, dirtyFormatStr, options) {
2404
+ var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;
2405
+ requiredArgs(2, arguments);
2406
+ var formatStr = String(dirtyFormatStr);
2407
+ var defaultOptions = getDefaultOptions();
2408
+ var locale$1 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : locale;
2409
+ var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1);
2410
+
2411
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2412
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2413
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2414
+ }
2415
+ var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0);
2416
+
2417
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2418
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2419
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2420
+ }
2421
+ if (!locale$1.localize) {
2422
+ throw new RangeError('locale must contain localize property');
2423
+ }
2424
+ if (!locale$1.formatLong) {
2425
+ throw new RangeError('locale must contain formatLong property');
2426
+ }
2427
+ var originalDate = toDate(dirtyDate);
2428
+ if (!isValid(originalDate)) {
2429
+ throw new RangeError('Invalid time value');
2430
+ }
2431
+
2432
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2433
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2434
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2435
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2436
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
2437
+ var formatterOptions = {
2438
+ firstWeekContainsDate: firstWeekContainsDate,
2439
+ weekStartsOn: weekStartsOn,
2440
+ locale: locale$1,
2441
+ _originalDate: originalDate
2442
+ };
2443
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2444
+ var firstCharacter = substring[0];
2445
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
2446
+ var longFormatter = longFormatters[firstCharacter];
2447
+ return longFormatter(substring, locale$1.formatLong);
2448
+ }
2449
+ return substring;
2450
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
2451
+ // Replace two single quote characters with one single quote character
2452
+ if (substring === "''") {
2453
+ return "'";
2454
+ }
2455
+ var firstCharacter = substring[0];
2456
+ if (firstCharacter === "'") {
2457
+ return cleanEscapedString(substring);
2458
+ }
2459
+ var formatter = formatters[firstCharacter];
2460
+ if (formatter) {
2461
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2462
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2463
+ }
2464
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2465
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2466
+ }
2467
+ return formatter(utcDate, substring, locale$1.localize, formatterOptions);
2468
+ }
2469
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2470
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2471
+ }
2472
+ return substring;
2473
+ }).join('');
2474
+ return result;
2475
+ }
2476
+ function cleanEscapedString(input) {
2477
+ var matched = input.match(escapedStringRegExp);
2478
+ if (!matched) {
2479
+ return input;
2480
+ }
2481
+ return matched[1].replace(doubleQuoteRegExp, "'");
2482
+ }
2483
+
2484
+ const TipsInfo = `<svg width="126" height="92" viewBox="0 0 126 92" fill="none" xmlns="http://www.w3.org/2000/svg">
2485
+ <g filter="url(#filter0_d_242_4231)">
2486
+ <rect x="24" y="20" width="78" height="36" rx="4" fill="white"/>
2487
+ <path d="M24 24C24 21.7909 25.7909 20 28 20H64V56H28C25.7909 56 24 54.2091 24 52V24Z" fill="#464646"/>
2488
+ <path d="M51 56H37L43.2474 63.1399C43.6458 63.5952 44.3542 63.5952 44.7526 63.1399L51 56Z" fill="#464646"/>
2489
+ <circle cx="44" cy="38" r="7" fill="white"/>
2490
+ <path d="M43.9405 34C44.5456 34 45.0362 34.4906 45.0362 35.0957C45.0362 35.7009 44.5456 36.1915 43.9405 36.1915C43.3353 36.1915 42.8447 35.7009 42.8447 35.0957C42.8447 34.4906 43.3353 34 43.9405 34Z" fill="#464646"/>
2491
+ <path d="M45.8801 41.3737C45.8801 41.7617 45.5626 42.0791 45.1746 42.0791H44.3233H43.551H42.7055C42.3175 42.0791 42 41.7617 42 41.3737V41.3575C42 40.9695 42.3175 40.6521 42.7055 40.6521H42.8455V37.8714H42.3528C42.1588 37.8714 42 37.7127 42 37.5187V37.4936C42 37.2996 42.1588 37.1409 42.3528 37.1409H43.551H44.031H44.3233C44.7113 37.1409 45.0287 37.4583 45.0287 37.8463V40.6521H45.1746C45.5626 40.6521 45.8801 40.9696 45.8801 41.3576V41.3737Z" fill="#464646"/>
2492
+ </g>
2493
+ <defs>
2494
+ <filter id="filter0_d_242_4231" x="0" y="0" width="126" height="91.4814" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
2495
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
2496
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
2497
+ <feOffset dy="4"/>
2498
+ <feGaussianBlur stdDeviation="12"/>
2499
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
2500
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_242_4231"/>
2501
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_242_4231" result="shape"/>
2502
+ </filter>
2503
+ </defs>
2504
+ </svg>
2505
+ `;
2506
+
2507
+ const PlayerLoyaltyProcess = () => (h("span", { class: "LevelProgress", id: 'LevelProgress', innerHTML: LoyaltyProgress }));
2508
+ const PlayerPoints = ({ loyaltyPoints, spendablePoints, pointExpireString, language, }) => (h("div", { class: "PointsInfo" },
2509
+ loyaltyPoints &&
2510
+ h("div", { class: 'Points' },
2511
+ loyaltyPoints,
2512
+ " ",
2513
+ h("sub", { class: "XP" }, translate('xp', language))),
2514
+ spendablePoints &&
2515
+ h("div", { class: 'Points' },
2516
+ spendablePoints,
2517
+ " ",
2518
+ h("sub", { class: "XP" }, translate('sp', language))),
2519
+ pointExpireString && (h("div", { class: 'ExpirationPoints' },
2520
+ pointExpireString,
2521
+ " "))));
2522
+ const PlayerElevateCardRedeem = ({ language, onRedeemClick }) => (h("div", { class: "CardCell Redeem" },
2523
+ h("div", { class: "RedeemButton", onClick: () => {
2524
+ onRedeemClick();
2525
+ } },
2526
+ h("span", null, translate('redeem', language)))));
2527
+ const PlayerNameDiv = (props) => (h("div", { class: 'CardCell PlayerName Txt' }, props.playerName));
2528
+ const PlayerElevateLoyaltyLevel = (props) => (h("div", { class: 'CardCell ElevateLevel' },
2529
+ h("span", { class: "LevelName", title: props.level }, props.level),
2530
+ props.expireTime && (h("div", { class: "CardCell ExpirationDate Txt" },
2531
+ translate('expireOn', props.language),
2532
+ h("span", { class: "ExpireTime" }, format(new Date(props.expireTime), props.dateFormat || 'yyyy-MM-dd')),
2533
+ !props.hideInfo && (h("span", { class: "fa Info", style: { 'background': `url(${getAssetPath('../static/info.svg')})` } },
2534
+ h("span", { class: "InfoTips", innerHTML: TipsInfo })))))));
2535
+ const PlayerAvatar = (props) => {
2536
+ const badge = props.loyaltyIconUrl
2537
+ ? h("img", { class: "Badge", src: props.loyaltyIconUrl })
2538
+ : props.hideIfNull ? '' : h("div", { class: "Badge" });
2539
+ const avatarSrc = props.playerAvatarUrl || getAssetPath('../static/user.svg');
2540
+ return h("div", { class: "PlayerAvatar", style: { 'position': `${props.onlyBadge ? '' : 'relative'}` } },
2541
+ !props.onlyBadge && h("img", { class: "Avatar", src: avatarSrc }),
2542
+ badge);
2543
+ };
2544
+
2545
+ const playerElevateCardCss = "@container (max-width: 270px) {\n .Card .Inner {\n flex-direction: column;\n }\n .Card .Inner .Content {\n padding: 9px;\n }\n\n .Inner .Row .ExpirationPoints {\n order: 1;\n }\n}\n.Card .PlayerImg {\n order: 0;\n}\n.Card .ExpirationPoints {\n order: 3;\n}\n.Card .LevelInfo {\n order: 2;\n}\n.Card .Inner .Row .PlayerImg {\n flex-direction: column;\n}\n.Card .Inner .Row .PointsInfo {\n width: 100%;\n text-align: center;\n display: flex;\n flex-direction: column;\n max-height: 50%;\n}\n.Card .Inner .PlayerAvatar .Badge {\n background-size: contain;\n background-repeat: no-repeat;\n position: absolute;\n right: 5px;\n bottom: -5px;\n width: 40%;\n height: 40%;\n overflow: visible;\n}\n.Card .Inner .Row .ExpirationPoints {\n text-align: left;\n color: var(--emfe-w-color-red, red);\n}\n.Card .Inner .Row .Points {\n text-wrap: nowrap;\n}\n.Card .Inner .LevelInfo .ElevateLevel {\n flex-direction: column;\n}\n.Card .Inner .LevelInfo .ElevateLevel .LevelName {\n width: calc(100% - 20px);\n text-align: left;\n font-size: 13px;\n padding-left: 20px;\n margin: 10px 0;\n}\n.Card .Inner .LevelInfo .ElevateLevel .ExpirationDate {\n text-align: center;\n font-size: smaller;\n}\n.Card .Inner .LevelInfo .ElevateLevel .ExpireTime {\n margin-left: 5px;\n}";
2546
+
2547
+ const PlayerElevateCard = class {
2548
+ constructor(hostRef) {
2549
+ registerInstance(this, hostRef);
2550
+ /**
2551
+ * The style that widget shows,available value: Dark, Light
2552
+ * Default: Dark
2553
+ */
2554
+ this.theme = 'Dark';
2555
+ /**
2556
+ * Widget Language to show
2557
+ */
2558
+ this.language = 'en';
2559
+ /**
2560
+ * datePattern
2561
+ */
2562
+ this.dateFormat = 'yyyy-MM-dd';
2563
+ /**
2564
+ * Client custom styling via inline styles
2565
+ */
2566
+ this.clientStyling = '';
2567
+ /**
2568
+ * Client custom styling via url
2569
+ */
2570
+ this.clientStylingUrl = '';
2571
+ /**
2572
+ * Translation via url
2573
+ */
2574
+ this.translationUrl = '';
2575
+ this.playerLevelFlag = 0;
2576
+ }
2577
+ playerElevateLeveLoadedHandler(event) {
2578
+ if (!event.detail) {
2579
+ return;
2580
+ }
2581
+ if (event.detail['elevateLevelWalletTotal']) {
2582
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
2583
+ }
2584
+ if (event.detail['elevateLevel']) {
2585
+ this.playerElevateLevel = event.detail['elevateLevel'];
2586
+ }
2587
+ if (event.detail['pointExpireString']) {
2588
+ this.pointExpireString = event.detail.xpExpireString;
2589
+ }
2590
+ if (event.detail.calculatedLevelFlag) {
2591
+ this.playerLevelFlag = event.detail.calculatedLevelFlag;
2592
+ }
2593
+ }
2594
+ onRedeemClick() {
2595
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
2596
+ }
2597
+ componentWillLoad() {
2598
+ this.paramProxy = {
2599
+ endpoint: this.endpoint,
2600
+ session: this.session,
2601
+ language: this.language,
2602
+ calculateLevelFlag: true,
2603
+ };
2604
+ }
2605
+ render() {
2606
+ const backgroundOuterImagePath = getAssetPath('../static/card-ground.svg');
2607
+ const backgroundInnerImagePath = getAssetPath('../static/card-ground-over.svg');
2608
+ return (h("div", { class: `ElevateCardWrapper ${this.theme}` }, h("div", { class: "Card Outer", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl }), h("player-elevate-card-data", { params: this.paramProxy }), h("div", { class: "OuterCover Inner", style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, this.playerElevateLevel && (h(Fragment, null, h("div", { class: 'Content Row' }, h("div", { class: "PlayerImg" }, h(PlayerAvatar, { playerAvatarUrl: this.playerAvatarUrl, loyaltyIconUrl: this.playerElevateLevel.presentation.asset }), h(PlayerPoints, { loyaltyPoints: this.playerElevateLevel.loyaltyPoints, language: this.language })), this.pointExpireString && (h("div", { class: 'PointsInfo ExpirationPoints' }, this.pointExpireString, " ")), h("div", { class: `LevelInfo Level${this.playerLevelFlag} ${this.playerElevateLevel.presentation.displayName}` }, h(PlayerNameDiv, { playerName: this.playerName }), h(PlayerElevateLoyaltyLevel, { hideInfo: true, level: this.playerElevateLevel.name, expireTime: this.playerElevateLevel.expireTime, dateFormat: this.dateFormat }), h(PlayerLoyaltyProcess, null), h(PlayerElevateCardRedeem, { onRedeemClick: this.onRedeemClick, language: this.language })))))))));
2609
+ }
2610
+ static get assetsDirs() { return ["../static"]; }
2611
+ };
2612
+ PlayerElevateCard.style = playerElevateCardCss;
2613
+
2614
+ /**
2615
+ * @name startOfDay
2616
+ * @category Day Helpers
2617
+ * @summary Return the start of a day for the given date.
2618
+ *
2619
+ * @description
2620
+ * Return the start of a day for the given date.
2621
+ * The result will be in the local timezone.
2622
+ *
2623
+ * @param {Date|Number} date - the original date
2624
+ * @returns {Date} the start of a day
2625
+ * @throws {TypeError} 1 argument required
2626
+ *
2627
+ * @example
2628
+ * // The start of a day for 2 September 2014 11:55:00:
2629
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
2630
+ * //=> Tue Sep 02 2014 00:00:00
2631
+ */
2632
+ function startOfDay(dirtyDate) {
2633
+ requiredArgs(1, arguments);
2634
+ var date = toDate(dirtyDate);
2635
+ date.setHours(0, 0, 0, 0);
2636
+ return date;
2637
+ }
2638
+
2639
+ var MILLISECONDS_IN_DAY = 86400000;
2640
+
2641
+ /**
2642
+ * @name differenceInCalendarDays
2643
+ * @category Day Helpers
2644
+ * @summary Get the number of calendar days between the given dates.
2645
+ *
2646
+ * @description
2647
+ * Get the number of calendar days between the given dates. This means that the times are removed
2648
+ * from the dates and then the difference in days is calculated.
2649
+ *
2650
+ * @param {Date|Number} dateLeft - the later date
2651
+ * @param {Date|Number} dateRight - the earlier date
2652
+ * @returns {Number} the number of calendar days
2653
+ * @throws {TypeError} 2 arguments required
2654
+ *
2655
+ * @example
2656
+ * // How many calendar days are between
2657
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
2658
+ * const result = differenceInCalendarDays(
2659
+ * new Date(2012, 6, 2, 0, 0),
2660
+ * new Date(2011, 6, 2, 23, 0)
2661
+ * )
2662
+ * //=> 366
2663
+ * // How many calendar days are between
2664
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
2665
+ * const result = differenceInCalendarDays(
2666
+ * new Date(2011, 6, 3, 0, 1),
2667
+ * new Date(2011, 6, 2, 23, 59)
2668
+ * )
2669
+ * //=> 1
2670
+ */
2671
+ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
2672
+ requiredArgs(2, arguments);
2673
+ var startOfDayLeft = startOfDay(dirtyDateLeft);
2674
+ var startOfDayRight = startOfDay(dirtyDateRight);
2675
+ var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);
2676
+ var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight);
2677
+
2678
+ // Round the number of days to the nearest integer
2679
+ // because the number of milliseconds in a day is not constant
2680
+ // (e.g. it's different in the day of the daylight saving time clock shift)
2681
+ return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
2682
+ }
2683
+
2684
+ /**
2685
+ * Days in 1 week.
2686
+ *
2687
+ * @name daysInWeek
2688
+ * @constant
2689
+ * @type {number}
2690
+ * @default
2691
+ */
2692
+
2693
+ /**
2694
+ * Milliseconds in 1 hour
2695
+ *
2696
+ * @name millisecondsInHour
2697
+ * @constant
2698
+ * @type {number}
2699
+ * @default
2700
+ */
2701
+ var millisecondsInHour = 3600000;
2702
+
2703
+ /**
2704
+ * @name differenceInMilliseconds
2705
+ * @category Millisecond Helpers
2706
+ * @summary Get the number of milliseconds between the given dates.
2707
+ *
2708
+ * @description
2709
+ * Get the number of milliseconds between the given dates.
2710
+ *
2711
+ * @param {Date|Number} dateLeft - the later date
2712
+ * @param {Date|Number} dateRight - the earlier date
2713
+ * @returns {Number} the number of milliseconds
2714
+ * @throws {TypeError} 2 arguments required
2715
+ *
2716
+ * @example
2717
+ * // How many milliseconds are between
2718
+ * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
2719
+ * const result = differenceInMilliseconds(
2720
+ * new Date(2014, 6, 2, 12, 30, 21, 700),
2721
+ * new Date(2014, 6, 2, 12, 30, 20, 600)
2722
+ * )
2723
+ * //=> 1100
2724
+ */
2725
+ function differenceInMilliseconds(dateLeft, dateRight) {
2726
+ requiredArgs(2, arguments);
2727
+ return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
2728
+ }
2729
+
2730
+ var roundingMap = {
2731
+ ceil: Math.ceil,
2732
+ round: Math.round,
2733
+ floor: Math.floor,
2734
+ trunc: function trunc(value) {
2735
+ return value < 0 ? Math.ceil(value) : Math.floor(value);
2736
+ } // Math.trunc is not supported by IE
2737
+ };
2738
+
2739
+ var defaultRoundingMethod = 'trunc';
2740
+ function getRoundingMethod(method) {
2741
+ return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
2742
+ }
2743
+
2744
+ /**
2745
+ * @name differenceInHours
2746
+ * @category Hour Helpers
2747
+ * @summary Get the number of hours between the given dates.
2748
+ *
2749
+ * @description
2750
+ * Get the number of hours between the given dates.
2751
+ *
2752
+ * @param {Date|Number} dateLeft - the later date
2753
+ * @param {Date|Number} dateRight - the earlier date
2754
+ * @param {Object} [options] - an object with options.
2755
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
2756
+ * @returns {Number} the number of hours
2757
+ * @throws {TypeError} 2 arguments required
2758
+ *
2759
+ * @example
2760
+ * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
2761
+ * const result = differenceInHours(
2762
+ * new Date(2014, 6, 2, 19, 0),
2763
+ * new Date(2014, 6, 2, 6, 50)
2764
+ * )
2765
+ * //=> 12
2766
+ */
2767
+ function differenceInHours(dateLeft, dateRight, options) {
2768
+ requiredArgs(2, arguments);
2769
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;
2770
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
2771
+ }
2772
+
2773
+ /**
2774
+ * @name isBefore
2775
+ * @category Common Helpers
2776
+ * @summary Is the first date before the second one?
2777
+ *
2778
+ * @description
2779
+ * Is the first date before the second one?
2780
+ *
2781
+ * @param {Date|Number} date - the date that should be before the other one to return true
2782
+ * @param {Date|Number} dateToCompare - the date to compare with
2783
+ * @returns {Boolean} the first date is before the second date
2784
+ * @throws {TypeError} 2 arguments required
2785
+ *
2786
+ * @example
2787
+ * // Is 10 July 1989 before 11 February 1987?
2788
+ * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
2789
+ * //=> false
2790
+ */
2791
+ function isBefore(dirtyDate, dirtyDateToCompare) {
2792
+ requiredArgs(2, arguments);
2793
+ var date = toDate(dirtyDate);
2794
+ var dateToCompare = toDate(dirtyDateToCompare);
2795
+ return date.getTime() < dateToCompare.getTime();
2796
+ }
2797
+
2798
+ function updateProgressSvg(progressElementRef, percent) {
2799
+ const svgElement = progressElementRef.querySelector('#total_level');
2800
+ const endLockWidth = 15;
2801
+ const barWidth = svgElement.getBBox().width;
2802
+ const widthOnBar = percent * barWidth - endLockWidth < 0 ? 0 : percent * barWidth - endLockWidth;
2803
+ //update bar's width, widthOnBar
2804
+ const levelBar = progressElementRef.querySelector('#current_level');
2805
+ //update filters, x = widthOnBar
2806
+ const levelFilter = progressElementRef.querySelector('#filter_current_level');
2807
+ //update circle, widthOnBar+10
2808
+ const levelCircle = progressElementRef.querySelector('#circle_current_level');
2809
+ svgElement.setAttribute('viewbox', `0 0 ${widthOnBar} 28`);
2810
+ levelBar.setAttribute('width', `${widthOnBar}`);
2811
+ levelCircle.setAttribute('cx', `${widthOnBar + 3}`);
2812
+ levelFilter.setAttribute('x', `${widthOnBar - 4}`);
2813
+ //update lock location
2814
+ const endLockElement = progressElementRef.querySelector('#lock');
2815
+ // wrapper of endLock, include ball and heatfilter1_d_305_23
2816
+ const filter1 = progressElementRef.querySelector('#filter_heart_ball');
2817
+ // ball in endlockfilter2_i_305_23
2818
+ const filter2 = progressElementRef.querySelector('#filter_ball');
2819
+ // heart in endlockfilter3_d_305_23
2820
+ const filter3 = progressElementRef.querySelector('#filter_heart');
2821
+ //wrapper of lockfilter4_d_305_23
2822
+ const filterLock = progressElementRef.querySelector('#filter_lock');
2823
+ // shadow of ball paint0_linear_305_23
2824
+ const paint0 = progressElementRef.querySelector('#paint0_linear_ball');
2825
+ //paint in lockpaint1_linear_305_23
2826
+ const paint1 = progressElementRef.querySelector('#paint1_linear_lock');
2827
+ // box of lock and heart, for move position dynamically
2828
+ const lockBox = progressElementRef.querySelector('#lock_box');
2829
+ const heartBox = progressElementRef.querySelector('#heart_box');
2830
+ const rightPaddingOfLockWidth = 10, cxOfEndLockEle = barWidth - rightPaddingOfLockWidth;
2831
+ //set cx of lockElement
2832
+ endLockElement.setAttribute('cx', `${cxOfEndLockEle}`);
2833
+ //set cx of sub Elements
2834
+ paint1.setAttribute('x1', `${cxOfEndLockEle}`);
2835
+ paint1.setAttribute('x2', `${cxOfEndLockEle}`);
2836
+ paint0.setAttribute('x1', `${cxOfEndLockEle - 6}`);
2837
+ paint0.setAttribute('x2', `${cxOfEndLockEle - 6 + 11.2}`);
2838
+ filterLock.setAttribute('x', `${cxOfEndLockEle - 6}`);
2839
+ filter3.setAttribute('x', `${cxOfEndLockEle - 6 - 2}`);
2840
+ filter2.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2}`);
2841
+ filter1.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2 - 4}`);
2842
+ lockBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
2843
+ heartBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
2844
+ }
2845
+
2846
+ const playerElevateCardDataCss = ":host {\n display: block;\n width: 360px;\n height: 230px;\n}\n\n.ElevateCardWrapper {\n contain: layout inline-size;\n width: 100%;\n height: fit-content;\n min-height: 218px;\n}\n\n.Outer {\n container-type: inline-size;\n font-size: 12px;\n background-size: cover;\n background-repeat: no-repeat;\n line-height: initial;\n width: 100%;\n height: 100%;\n}\n\n.Dark {\n color: var(--emfe-w-color-gray150, #efefef);\n}\n\n.Light {\n color: var(--emfe-w-color-black, #0e0e0e);\n}\n\n@container (min-width: 381px) {\n .Outer {\n background-size: cover;\n }\n .Outer .OuterCover {\n min-height: 190px;\n }\n}\n@container (min-width: 260px) {\n .Outer {\n background-size: contain;\n }\n}\n.OuterCover {\n width: 100%;\n height: 100%;\n content: \"\";\n background-repeat: no-repeat;\n background-size: cover;\n border-radius: 15px;\n}\n\n.Inner {\n display: flex;\n flex-direction: column;\n min-height: 158px;\n}\n.Inner .Content {\n padding: 15px;\n flex-wrap: wrap;\n gap: 8px;\n}\n.Inner .Row {\n display: flex;\n flex-direction: row;\n}\n.Inner .CardCell {\n display: flex;\n}\n.Inner .LevelInfo {\n display: flex;\n flex-direction: column;\n}\n.Inner .LevelInfo .ElevateLevel .LevelName {\n height: 28px;\n border-radius: 5px;\n line-height: 28px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.Inner .LevelInfo.Level0 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level0button-shadow, rgba(191, 84, 6, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level0-bg0, #E2792C) 0%, var(--emfe-w-elevate-color-level0-bg1, rgba(242, 151, 99, 0)) 100%);\n}\n.Inner .LevelInfo.Level1 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level1button-shadow, rgba(151, 151, 151, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level1-bg0, #BEBFED) 0%, var(--emfe-w-elevate-color-level1-bg1, rgba(216, 217, 233, 0)) 100%);\n}\n.Inner .LevelInfo.Level2 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level2button-shadow, rgba(191, 120, 6, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level2-bg0, #FCC410) 0%, var(--emfe-w-elevate-color-level2-bg1, rgba(255, 189, 43, 0)) 100%);\n}\n.Inner .LevelInfo.Level3 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level3button-shadow, rgba(65, 6, 191, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level3-bg0, #B1A2DB) 0%, var(--emfe-w-elevate-color-level3-bg1, rgba(203, 202, 245, 0)) 100%);\n}\n.Inner .LevelInfo.Level4 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level4button-shadow, rgba(65, 6, 191, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level4-bg0, #B1A2DB) 0%, var(--emfe-w-elevate-color-level4-bg1, rgba(203, 202, 245, 0)) 100%);\n}\n.Inner .LevelInfo .ElevateLevel {\n display: flex;\n}\n.Inner .LevelInfo {\n flex: 1;\n flex-grow: 1;\n min-width: 150px;\n}\n.Inner .PlayerImg {\n width: 29%;\n margin: auto;\n max-width: 100px;\n min-width: 30px;\n order: 0;\n}\n.Inner .PlayerAvatar {\n max-width: 100px;\n flex-basis: 100px;\n height: auto;\n margin: auto;\n padding-top: 10px;\n}\n.Inner .PlayerAvatar .Avatar, .Inner .PlayerAvatar .Badge {\n width: 100%;\n height: 100%;\n}\n.Inner .PlayerAvatar .Avatar {\n border-radius: 50%;\n background-size: contain;\n background-repeat: no-repeat;\n}\n.Inner .ElevateLevel .ExpirationDate {\n max-width: 138px;\n min-width: 118px;\n}\n.Inner .PlayerName, .Inner .RedeemButton, .Inner .ElevateLevel {\n text-transform: capitalize;\n width: 100%;\n}\n.Inner .PlayerName {\n font-size: 16px;\n}\n.Inner .Row .PointsInfo {\n display: table;\n font-weight: 600;\n}\n.Inner .Row .Redeem {\n justify-content: flex-end;\n margin-left: auto;\n}\n.Inner .Row .Redeem:hover {\n color: var(--emfe-w-elevate-color-redeem-hover, #00ABA4);\n cursor: pointer;\n}\n.Inner .Row .RedeemButton:hover span {\n color: var(emfe-w-elevate-color-redeem-text-hover, #f1f1f1);\n font-weight: bold;\n}\n.Inner .Row .RedeemButton {\n width: 95px;\n height: 35px;\n display: flex;\n align-items: center;\n border-radius: 10px;\n background: var(--emfe-w-elevate-color-redeem-bg, linear-gradient(0deg, #26CC37, #26CC37)), linear-gradient(117.99deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.89%), linear-gradient(283.85deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.47%), linear-gradient(268.18deg, rgba(255, 255, 255, 0.6) -17.36%, rgba(239, 239, 239, 0) 15.78%);\n box-shadow: 0px 4px 4px 0px #00000040;\n}\n.Inner .Row .RedeemButton span {\n color: var(--emfe-w-color-white, #fff);\n line-height: 18px;\n font-size: 15px;\n text-align: center;\n width: 100%;\n}\n.Inner .Row .Points {\n font-size: large;\n vertical-align: middle;\n}\n.Inner .Row .Points .XP {\n font-size: x-small;\n}\n.Inner .Row .ExpirationPoints {\n font-size: small;\n text-align: right;\n font-weight: bold;\n color: var(--emfe-w-color-red, #9e595f);\n}";
2847
+
2848
+ const PlayerElevateCardData = class {
2849
+ constructor(hostRef) {
2850
+ registerInstance(this, hostRef);
2851
+ this.playerElevateLeveLoaded = createEvent(this, "playerElevateLeveLoaded", 7);
2852
+ }
2853
+ handleWindowResizs() {
2854
+ this.initLevelProgressbar();
2855
+ }
2856
+ onRedeemClick() {
2857
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
2858
+ }
2859
+ loadLevels() {
2860
+ let url = new URL(`${this.params.endpoint}/v1/elevate/levels?language=${this.params.language}`);
2861
+ return new Promise((resolve, reject) => {
2862
+ return fetch(url.href, {
2863
+ method: 'GET',
2864
+ })
2865
+ .then((res) => res.json())
2866
+ .then((res) => {
2867
+ this.levels = res.data;
2868
+ resolve(true);
2869
+ })
2870
+ .catch((err) => {
2871
+ reject(err);
2872
+ });
2873
+ });
2874
+ }
2875
+ calcuatePointsToBeExpired(walletTotalInfo) {
2876
+ let pointExpireInfoAsString = '';
2877
+ if (!walletTotalInfo || !walletTotalInfo.aboutToExpire ||
2878
+ walletTotalInfo.aboutToExpire.length == 0 ||
2879
+ walletTotalInfo.aboutToExpire[0].points <= 0) {
2880
+ return pointExpireInfoAsString;
2881
+ }
2882
+ walletTotalInfo.aboutToExpire.sort((expire1, expire2) => {
2883
+ return isBefore(new Date(expire1.expireTime), new Date(expire2.expireTime))
2884
+ ? -1
2885
+ : 1;
2886
+ });
2887
+ const aboutToExpire = walletTotalInfo.aboutToExpire[0];
2888
+ const daysToExpried = differenceInCalendarDays(new Date(aboutToExpire.expireTime), new Date());
2889
+ let hoursToExpired = 0, expiredTranslationKey = daysToExpried === 0 ? 'pointsToBeExpiredDay' : 'pointsToBeExpired';
2890
+ if (daysToExpried == 0) {
2891
+ hoursToExpired = differenceInHours(new Date(aboutToExpire.expireTime), new Date());
2892
+ expiredTranslationKey = hoursToExpired > 1 ? 'pointsToBeExpiredHours' : 'pointsToBeExpiredHour';
2893
+ }
2894
+ pointExpireInfoAsString = translateWithParams(expiredTranslationKey, {
2895
+ expirationPoints: aboutToExpire.points,
2896
+ expireDay: daysToExpried,
2897
+ });
2898
+ return pointExpireInfoAsString;
2899
+ }
2900
+ loadPlayerLevelInfo() {
2901
+ let url = new URL(`${this.params.endpoint}/v1/elevate/playerInfo?language=${this.params.language}`);
2902
+ return new Promise((resolve, reject) => {
2903
+ return fetch(url.href, {
2904
+ method: 'GET',
2905
+ headers: {
2906
+ 'X-Sessionid': this.params.session,
2907
+ 'Content-Type': 'application/json',
2908
+ },
2909
+ })
2910
+ .then((res) => res.json())
2911
+ .then((res) => {
2912
+ var _a, _b, _c;
2913
+ if (!res.success) {
2914
+ console.error('Exception when fetch user elevateinfo, ', res.errorCode, res.errorMessage);
2915
+ reject(true);
2916
+ return;
2917
+ }
2918
+ let playerElevateInfo = res.data;
2919
+ this.playerElevateLevel = playerElevateInfo.level;
2920
+ this.playerElevateLevel.name = this.playerElevateLevel.presentation.displayName || this.playerElevateLevel.name;
2921
+ this.playerElevateLevel.spendablePoints = ((_a = playerElevateInfo.spendableWallet) === null || _a === void 0 ? void 0 : _a.total.points) || 0;
2922
+ this.playerElevateLeveLoaded.emit({ elevateLevel: this.playerElevateLevel });
2923
+ const spendableTotal = (_b = res.data.spendableWallet) === null || _b === void 0 ? void 0 : _b.total;
2924
+ const loyaltyWalletTotal = (_c = res.data.loyaltyWallet) === null || _c === void 0 ? void 0 : _c.total;
2925
+ this.playerElevateLeveLoaded.emit({
2926
+ elevateLevelWalletTotal: spendableTotal,
2927
+ loyaltyWalletTotal
2928
+ });
2929
+ let spExpireInfoAsString = this.calcuatePointsToBeExpired(spendableTotal);
2930
+ let xpExpireInfoAsString = this.calcuatePointsToBeExpired(loyaltyWalletTotal);
2931
+ if (spExpireInfoAsString || xpExpireInfoAsString) {
2932
+ this.playerElevateLeveLoaded.emit({
2933
+ pointExpireString: spExpireInfoAsString,
2934
+ xpExpireString: xpExpireInfoAsString
2935
+ });
2936
+ }
2937
+ resolve(this.playerElevateLevel);
2938
+ })
2939
+ .catch((err) => {
2940
+ console.log('error ', err);
2941
+ reject(true);
2942
+ });
2943
+ });
2944
+ }
2945
+ setLoyaltyProgress(percent) {
2946
+ updateProgressSvg(this.loyaltyProgressEle, percent);
2947
+ }
2948
+ initLevelProgressbar() {
2949
+ setTimeout(() => {
2950
+ this.loyaltyProgressEle =
2951
+ this.elevateCardRef.parentElement.querySelector('#LevelProgress');
2952
+ if (!this.loyaltyProgressEle) {
2953
+ return;
2954
+ }
2955
+ this.setLoyaltyProgress(!this.playerElevateLevel.nextLevel
2956
+ ? 1
2957
+ : (this.playerElevateLevel.loyaltyPoints -
2958
+ this.playerElevateLevel.entryPoints) /
2959
+ (this.playerElevateLevel.nextLevel.entryPoints -
2960
+ this.playerElevateLevel.loyaltyPoints));
2961
+ this.params['playerElevateLevel'] = this.playerElevateLevel;
2962
+ }, 80);
2963
+ }
2964
+ componentWillRender() { }
2965
+ componentDidRender() {
2966
+ this.initLevelProgressbar();
2967
+ }
2968
+ componentWillLoad() {
2969
+ if (!this.params.endpoint || !this.params.session) {
2970
+ return;
2971
+ }
2972
+ const promises = [];
2973
+ promises.push(this.loadPlayerLevelInfo());
2974
+ if (this.params.calculateLevelFlag) {
2975
+ promises.push(this.loadLevels());
2976
+ }
2977
+ Promise.all(promises).then((res) => {
2978
+ console.log('elevate-init', res);
2979
+ this.initLevelProgressbar();
2980
+ if (!this.levels) {
2981
+ return;
2982
+ }
2983
+ this.levels.sort((level1, level2) => {
2984
+ return level1.firstEntryPoints > level2.firstEntryPoints ? 1 : -1;
2985
+ });
2986
+ const playerPoints = this.playerElevateLevel.loyaltyPoints;
2987
+ let playerLevelNumber = 0;
2988
+ this.levels.forEach((elevateLevel, idx) => {
2989
+ if (playerPoints > elevateLevel.firstEntryPoints) {
2990
+ playerLevelNumber = idx;
2991
+ }
2992
+ });
2993
+ this.playerElevateLeveLoaded.emit({
2994
+ calculatedLevelFlag: playerLevelNumber,
2995
+ });
2996
+ });
2997
+ }
2998
+ get elevateCardRef() { return getElement(this); }
2999
+ };
3000
+ PlayerElevateCardData.style = playerElevateCardDataCss;
3001
+
3002
+ const playerElevateLoyaltycardCss = ":host{display:block}@media screen and (min-width: 501px){.LoyaltyCard .Inner .LevelInfo .ElevateLevel{flex-wrap:nowrap}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{padding-top:11px;margin-left:5px}}@media screen and (max-width: 500px){.LoyaltyCard .Inner .LevelInfo .ElevateLevel{flex-wrap:wrap}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{padding-top:0px;margin-left:0px}}.LoyaltyCard .Inner .LevelProgress{margin-left:0px}.LoyaltyCard .Inner .Row .PointsInfo{width:100%}.LoyaltyCard .Inner .Row .PointsInfo.ExpirationPoints{text-align:left;color:var(--emfe-w-color-red-50, red)}.LoyaltyCard .Inner .PlayerAvatar .Avatar{display:none}.LoyaltyCard .Inner .PlayerAvatar .Badge{border-radius:50%;background-size:contain;width:100%;height:100%}.LoyaltyCard .Inner .LevelInfo .ElevateLevel{display:flex;flex:1;align-items:center}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{position:relative;padding-left:5px}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate .ExpireTime{margin-left:5px}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .LevelName{padding-left:0;font-size:var(--emfe-w-elevate-fontsize-2xlarge, 21px);position:relative;width:auto;color:var(--emfe-w-elevate-color-levelname, #FFBD2B);font-weight:bold}.LoyaltyCard .NextLevelTip{text-align:right;font-size:11px;color:var(--emfe-w-color-black, #000);opacity:0.8;font-weight:bold}";
3003
+
3004
+ const PlayerElevateLoyaltycard = class {
3005
+ constructor(hostRef) {
3006
+ registerInstance(this, hostRef);
3007
+ /**
3008
+ * The style that widget shows,available value: Dark, Light
3009
+ * Default: Dark
3010
+ */
3011
+ this.theme = 'Dark';
3012
+ /**
3013
+ * Widget Language to show
3014
+ */
3015
+ this.language = 'en';
3016
+ /**
3017
+ * datePattern
3018
+ */
3019
+ this.dateFormat = 'yyyy-MM-dd';
3020
+ /**
3021
+ * Client custom styling via inline styles
3022
+ */
3023
+ this.clientStyling = '';
3024
+ /**
3025
+ * Client custom styling via url
3026
+ */
3027
+ this.clientStylingUrl = '';
3028
+ /**
3029
+ * Translation via url
3030
+ */
3031
+ this.translationUrl = '';
3032
+ }
3033
+ playerElevateLeveLoadedHandler(event) {
3034
+ if (!event.detail) {
3035
+ return;
3036
+ }
3037
+ if (event.detail['elevateLevelWalletTotal']) {
3038
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
3039
+ }
3040
+ if (event.detail['elevateLevel']) {
3041
+ this.playerElevateLevel = event.detail['elevateLevel'];
3042
+ }
3043
+ if (event.detail['pointExpireString']) {
3044
+ this.pointExpireString = event.detail.xpExpireString;
3045
+ }
3046
+ }
3047
+ onRedeemClick() {
3048
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
3049
+ }
3050
+ componentWillLoad() {
3051
+ this.paramsProxy = {
3052
+ endpoint: this.endpoint,
3053
+ session: this.session,
3054
+ language: this.language,
3055
+ };
3056
+ }
3057
+ getNextLevelTips() {
3058
+ var _a;
3059
+ //need xx to reach Diamond
3060
+ let nextLevel = (_a = this.playerElevateLevel) === null || _a === void 0 ? void 0 : _a.nextLevel;
3061
+ if (this.playerElevateLevel && nextLevel) {
3062
+ const pointsToReach = (nextLevel.entryPoints - this.playerElevateLevel.loyaltyPoints).toFixed(2);
3063
+ return translateWithParams('tipsForNextLevel', {
3064
+ pointsToReach,
3065
+ levelName: nextLevel.name,
3066
+ });
3067
+ }
3068
+ return '';
3069
+ }
3070
+ render() {
3071
+ const backgroundOuterImagePath = getAssetPath('../static/card-ground.svg');
3072
+ const backgroundInnerImagePath = getAssetPath('../static/card-ground-over.svg');
3073
+ return (h("div", { class: `ElevateCardWrapper ${this.theme}` }, h("div", { class: "LoyaltyCard Outer", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl }), h("player-elevate-card-data", { params: this.paramsProxy }), h("div", { class: 'OuterCover Inner', style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, h("div", { class: 'Content Row' }, this.playerElevateLevel && (h(Fragment, null, h("div", { class: "PlayerImg" }, h(PlayerAvatar, { onlyBadge: true, loyaltyIconUrl: this.playerElevateLevel.presentation.asset })), h("div", { class: `LevelInfo ${this.playerElevateLevel.name}` }, h(PlayerElevateLoyaltyLevel, { hideInfo: true, level: this.playerElevateLevel.name, expireTime: this.playerElevateLevel.expireTime, dateFormat: this.dateFormat }), h(PlayerPoints, { loyaltyPoints: this.playerElevateLevel.loyaltyPoints, language: this.language }), this.pointExpireString && (h("div", { class: 'PointsInfo ExpirationPoints' }, this.pointExpireString, " ")), h(PlayerLoyaltyProcess, null), h("div", { class: "NextLevelTip" }, this.getNextLevelTips())))))))));
3074
+ }
3075
+ };
3076
+ PlayerElevateLoyaltycard.style = playerElevateLoyaltycardCss;
3077
+
3078
+ const playerElevatePointcardCss = ":host{display:block}.PointsCard .Inner .Row .ExpirationPoints{text-align:left}.PointsCard .Inner .PlayerAvatar .Avatar{display:none}.PointsCard .Inner .PlayerAvatar .Badge{border-radius:50%;background-size:contain;width:100%;height:100%;position:inherit}.PointsCard .Inner .PointsTxt{display:flex;flex-direction:row;justify-content:space-between}.PointsCard .Inner .DetailButton{background:linear-gradient(283.85deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.47%), linear-gradient(117.99deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.89%), linear-gradient(268.18deg, rgba(255, 255, 255, 0.6) -17.36%, rgba(239, 239, 239, 0) 15.78%), linear-gradient(0deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6));border-radius:5px;box-shadow:0px 4px 4px 0px rgba(0, 0, 0, 0.25);border:2px solid;font-size:11px;width:108px;padding:4px;cursor:pointer;margin-top:5px;height:16px;min-width:45px;text-align:center}.PointsCard .Inner .DetailButton span{color:var(--emfe-w-color-gray-150, #6D6D6D)}.PointsCard .Inner .DetailButton span{display:inline-block;vertical-align:middle}.PointsCard .Inner .DetailButton:hover span{color:var(--emfe-w-color-gray-150, #6D6D6D)}.PointsCard .Inner .LevelInfo{gap:15px;width:70%}.PointsCard .Inner .LevelInfo .PointsTxt{font-size:15px}.PointsCard .Inner .LevelInfo .PointsTxt.Label{display:none}.PointsCard .Inner .LevelInfo .PointsTxt.SPPoints{padding-top:15px}.PointsCard .Inner .LevelInfo .PointsTxt .TC{font-size:x-small;color:var(--emw--color-gray-300, #58586B);display:flex;align-content:center;height:100%;flex-wrap:wrap;text-decoration:underline;cursor:pointer;display:none}";
3079
+
3080
+ const PlayerElevatePointcard = class {
3081
+ constructor(hostRef) {
3082
+ registerInstance(this, hostRef);
3083
+ /**
3084
+ * The style that widget shows,available value: Dark, Light
3085
+ * Default: Dark
3086
+ */
3087
+ this.theme = 'Dark';
3088
+ /**
3089
+ * Widget Language to show
3090
+ */
3091
+ this.language = 'en';
3092
+ /**
3093
+ * Check if the card used in points details widget, default: 'earningRule'
3094
+ * value: 'details'/'earningRule'
3095
+ * It effected the button in card
3096
+ * 'earningRule': button text, 'earning rules', post 'BEEPointRulesClicked' when clicked
3097
+ * 'details': button text, 'details', post 'BEEDetailsClicked' when clicked
3098
+ */
3099
+ this.buttonType = 'earningRule';
3100
+ /**
3101
+ * datePattern
3102
+ */
3103
+ this.dateFormat = 'yyyy-MM-dd';
3104
+ /**
3105
+ * Client custom styling via inline styles
3106
+ */
3107
+ this.clientStyling = '';
3108
+ /**
3109
+ * Client custom styling via url
3110
+ */
3111
+ this.clientStylingUrl = '';
3112
+ /**
3113
+ * Translation via url
3114
+ */
3115
+ this.translationUrl = '';
3116
+ this.isPointDetailCard = this.buttonType === 'earningRule';
3117
+ }
3118
+ playerElevateLeveLoadedHandler(event) {
3119
+ if (!event.detail) {
3120
+ return;
3121
+ }
3122
+ if (event.detail['elevateLevelWalletTotal']) {
3123
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
3124
+ this.elevateSPTotal = event.detail['loyaltyWalletTotal'];
3125
+ }
3126
+ if (event.detail['elevateLevel']) {
3127
+ this.playerElevateLevel = event.detail['elevateLevel'];
3128
+ }
3129
+ if (event.detail['pointExpireString']) {
3130
+ this.pointExpireString = event.detail.pointExpireString;
3131
+ }
3132
+ }
3133
+ onDetailsClick() {
3134
+ window.postMessage({ type: this.isPointDetailCard ? 'BEEPointRulesClicked' : 'BEEDetailsClicked',
3135
+ path: this.isPointDetailCard ? 'player-elevate-level' : 'player-elevate-point-details' }, window.location.href);
3136
+ }
3137
+ componentWillLoad() {
3138
+ this.paramProxy = {
3139
+ endpoint: this.endpoint,
3140
+ session: this.session,
3141
+ language: this.language,
3142
+ };
3143
+ }
3144
+ render() {
3145
+ const backgroundOuterImagePath = getAssetPath('../static/card-ground.svg');
3146
+ const backgroundInnerImagePath = getAssetPath('../static/card-ground-over.svg');
3147
+ return (h("div", { class: `ElevateCardWrapper ${this.theme}` }, h("div", { class: "PointsCard Outer ", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl }), h("player-elevate-card-data", { params: this.paramProxy }), h("div", { class: 'OuterCover Inner', style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, h("div", { class: 'Content Row' }, this.playerElevateLevel && (h(Fragment, null, h("div", { class: "PlayerImg" }, h(PlayerAvatar, { onlyBadge: true, loyaltyIconUrl: this.playerElevateLevel.presentation.asset })), h("div", { class: `LevelInfo ${this.playerElevateLevel.name}` }, h("div", { class: "PointsTxt Label" }, this.cardTitle ? this.cardTitle : translate('spendablePoints')), h("div", { class: 'PointsTxt SPPoints' }, h(PlayerPoints, { spendablePoints: this.playerElevateLevel.spendablePoints, language: this.language }), h("a", { class: "TC", onClick: () => {
3148
+ this.onDetailsClick();
3149
+ } }, translate('termAndConditions', this.language))), this.pointExpireString && (h("div", { class: 'ExpirationPoints' }, this.pointExpireString, " "))))))))));
3150
+ }
3151
+ };
3152
+ PlayerElevatePointcard.style = playerElevatePointcardCss;
3153
+
3154
+ export { GeneralStylingWrapper as general_styling_wrapper, PlayerElevateCard as player_elevate_card, PlayerElevateCardData as player_elevate_card_data, PlayerElevateLoyaltycard as player_elevate_loyaltycard, PlayerElevatePointcard as player_elevate_pointcard };