@everymatrix/casino-engagement-suite-luckywheel-list 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/casino-engagement-suite-luckywheel-list/casino-engagement-suite-luckywheel-list.esm.js +1 -0
  2. package/dist/casino-engagement-suite-luckywheel-list/index.esm.js +1 -0
  3. package/dist/casino-engagement-suite-luckywheel-list/p-c227cdc7.js +2 -0
  4. package/dist/casino-engagement-suite-luckywheel-list/p-d1ea0bae.entry.js +1 -0
  5. package/dist/casino-engagement-suite-luckywheel-list/p-e1255160.js +1 -0
  6. package/dist/casino-engagement-suite-luckywheel-list/p-f007d81f.js +1 -0
  7. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  8. package/dist/cjs/casino-engagement-suite-luckywheel-list-726f2e8f.js +2574 -0
  9. package/dist/cjs/casino-engagement-suite-luckywheel-list.cjs.js +25 -0
  10. package/dist/cjs/casino-engagement-suite-luckywheel-list_2.cjs.entry.js +73 -0
  11. package/dist/cjs/index-3815b8e0.js +1333 -0
  12. package/dist/cjs/index.cjs.js +10 -0
  13. package/dist/cjs/loader.cjs.js +15 -0
  14. package/dist/collection/collection-manifest.json +19 -0
  15. package/dist/collection/components/casino-engagement-suite-luckywheel-list/casino-engagement-suite-luckywheel-list.css +454 -0
  16. package/dist/collection/components/casino-engagement-suite-luckywheel-list/casino-engagement-suite-luckywheel-list.js +467 -0
  17. package/dist/collection/components/casino-engagement-suite-luckywheel-list/index.js +1 -0
  18. package/dist/collection/index.js +1 -0
  19. package/dist/collection/models/luckywheel.js +14 -0
  20. package/dist/collection/renders/LuckyWheelsHistory.js +52 -0
  21. package/dist/collection/utils/locale.utils.js +46 -0
  22. package/dist/collection/utils/utils.js +3 -0
  23. package/dist/esm/app-globals-0f993ce5.js +3 -0
  24. package/dist/esm/casino-engagement-suite-luckywheel-list-864bcb68.js +2572 -0
  25. package/dist/esm/casino-engagement-suite-luckywheel-list.js +20 -0
  26. package/dist/esm/casino-engagement-suite-luckywheel-list_2.entry.js +68 -0
  27. package/dist/esm/index-68de30f0.js +1305 -0
  28. package/dist/esm/index.js +2 -0
  29. package/dist/esm/loader.js +11 -0
  30. package/dist/index.cjs.js +1 -0
  31. package/dist/index.js +1 -0
  32. package/dist/stencil.config.dev.js +14 -0
  33. package/dist/stencil.config.js +17 -0
  34. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/casino-engagement-suite-luckywheel-list/.stencil/packages/stencil/casino-engagement-suite-luckywheel-list/stencil.config.d.ts +2 -0
  35. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/casino-engagement-suite-luckywheel-list/.stencil/packages/stencil/casino-engagement-suite-luckywheel-list/stencil.config.dev.d.ts +2 -0
  36. package/dist/types/components/casino-engagement-suite-luckywheel-list/casino-engagement-suite-luckywheel-list.d.ts +84 -0
  37. package/dist/types/components/casino-engagement-suite-luckywheel-list/index.d.ts +1 -0
  38. package/dist/types/components.d.ts +119 -0
  39. package/dist/types/index.d.ts +1 -0
  40. package/dist/types/models/luckywheel.d.ts +41 -0
  41. package/dist/types/renders/LuckyWheelsHistory.d.ts +6 -0
  42. package/dist/types/stencil-public-runtime.d.ts +1680 -0
  43. package/dist/types/utils/locale.utils.d.ts +2 -0
  44. package/dist/types/utils/utils.d.ts +1 -0
  45. package/loader/cdn.js +1 -0
  46. package/loader/index.cjs.js +1 -0
  47. package/loader/index.d.ts +24 -0
  48. package/loader/index.es2017.js +1 -0
  49. package/loader/index.js +2 -0
  50. package/loader/package.json +11 -0
  51. package/package.json +26 -0
@@ -0,0 +1,2574 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-3815b8e0.js');
4
+
5
+ const DEFAULT_LANGUAGE = 'en';
6
+ const SUPPORTED_LANGUAGES = ['en'];
7
+ const TRANSLATIONS = {
8
+ en: {
9
+ luckywheels: 'LuckyWheels',
10
+ join: 'Join',
11
+ unjoin: 'Unjoin',
12
+ new: 'new',
13
+ noluckywheels: 'No Unlocked LuckyWheel',
14
+ tryOtherGames: 'Try winning LuckyWheel as rewards or launching other booster games',
15
+ tooltip: 'LuckyWheels where your real money bets contribute towards the level progress to achieve the level reward',
16
+ history: 'History',
17
+ rewards: 'Rewards',
18
+ issued: 'Issued',
19
+ time: 'Time',
20
+ loading: 'Loading...',
21
+ noHistory: 'No LuckyWheels’ history available (last 30 days)',
22
+ freeSpins: 'Free Spins',
23
+ luckyWheel: 'LuckyWheel',
24
+ leaderboard: 'Leaderboard',
25
+ mission: 'Mission',
26
+ canceled: 'The luckywheel has been canceled.',
27
+ support: 'Please, contact support.'
28
+ }
29
+ };
30
+ const translate = (key, customLang) => {
31
+ const lang = customLang;
32
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
33
+ };
34
+ const getTranslations = (url) => {
35
+ // fetch url, get the data, replace the TRANSLATIONS content
36
+ return new Promise((resolve, reject) => {
37
+ fetch(url)
38
+ .then((res) => res.json())
39
+ .then((data) => {
40
+ Object.keys(data).forEach((item) => {
41
+ for (let key in data[item]) {
42
+ TRANSLATIONS[item][key] = data[item][key];
43
+ }
44
+ });
45
+ resolve(TRANSLATIONS);
46
+ }).catch(err => {
47
+ reject(err);
48
+ });
49
+ });
50
+ };
51
+
52
+ var GeneralAnimationLoadingCczQRHih = {};
53
+
54
+ (function (exports) {
55
+ var V=Object.defineProperty,z=Object.defineProperties;var F=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var x=(e,t,n)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))G.call(t,n)&&x(e,n,t[n]);if(N)for(var n of N(t))q.call(t,n)&&x(e,n,t[n]);return e},M=(e,t)=>z(e,F(t));var $=(e,t,n)=>x(e,typeof t!="symbol"?t+"":t,n);var T=(e,t,n)=>new Promise((s,l)=>{var i=o=>{try{u(n.next(o));}catch(r){l(r);}},c=o=>{try{u(n.throw(o));}catch(r){l(r);}},u=o=>o.done?s(o.value):Promise.resolve(o.value).then(i,c);u((n=n.apply(e,t)).next());});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function _(){}function H(e){return e()}function B(){return Object.create(null)}function b(e){e.forEach(H);}function I(e){return typeof e=="function"}function K(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function Q(e){return Object.keys(e).length===0}function W(e,t){e.appendChild(t);}function X(e,t,n){const s=Y(e);if(!s.getElementById(t)){const l=L("style");l.id=t,l.textContent=n,Z(s,l);}}function Y(e){if(!e)return document;const t=e.getRootNode?e.getRootNode():e.ownerDocument;return t&&t.host?t:e.ownerDocument}function Z(e,t){return W(e.head||e,t),t.sheet}function U(e,t,n){e.insertBefore(t,n||null);}function C(e){e.parentNode&&e.parentNode.removeChild(e);}function L(e){return document.createElement(e)}function tt(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n);}function et(e){return Array.from(e.childNodes)}function nt(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||"default"]=!0;}),t}let j;function g(e){j=e;}const h=[],k=[];let p=[];const R=[],it=Promise.resolve();let v=!1;function st(){v||(v=!0,it.then(y));}function E(e){p.push(e);}const w=new Set;let a=0;function y(){if(a!==0)return;const e=j;do{try{for(;a<h.length;){const t=h[a];a++,g(t),rt(t.$$);}}catch(t){throw h.length=0,a=0,t}for(g(null),h.length=0,a=0;k.length;)k.pop()();for(let t=0;t<p.length;t+=1){const n=p[t];w.has(n)||(w.add(n),n());}p.length=0;}while(h.length);for(;R.length;)R.pop()();v=!1,w.clear(),g(e);}function rt(e){if(e.fragment!==null){e.update(),b(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(E);}}function lt(e){const t=[],n=[];p.forEach(s=>e.indexOf(s)===-1?t.push(s):n.push(s)),n.forEach(s=>s()),p=t;}const ct=new Set;function ot(e,t){e&&e.i&&(ct.delete(e),e.i(t));}function ut(e,t,n){const{fragment:s,after_update:l}=e.$$;s&&s.m(t,n),E(()=>{const i=e.$$.on_mount.map(H).filter(I);e.$$.on_destroy?e.$$.on_destroy.push(...i):b(i),e.$$.on_mount=[];}),l.forEach(E);}function dt(e,t){const n=e.$$;n.fragment!==null&&(lt(n.after_update),b(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[]);}function $t(e,t){e.$$.dirty[0]===-1&&(h.push(e),st(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31;}function ft(e,t,n,s,l,i,c=null,u=[-1]){const o=j;g(e);const r=e.$$={fragment:null,ctx:[],props:i,update:_,not_equal:l,bound:B(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(o?o.$$.context:[])),callbacks:B(),dirty:u,skip_bound:!1,root:t.target||o.$$.root};c&&c(r.root);let f=!1;if(r.ctx=n?n(e,t.props||{},(d,O,...S)=>{const A=S.length?S[0]:O;return r.ctx&&l(r.ctx[d],r.ctx[d]=A)&&(!r.skip_bound&&r.bound[d]&&r.bound[d](A),f&&$t(e,d)),O}):[],r.update(),f=!0,b(r.before_update),r.fragment=s?s(r.ctx):!1,t.target){if(t.hydrate){const d=et(t.target);r.fragment&&r.fragment.l(d),d.forEach(C);}else r.fragment&&r.fragment.c();t.intro&&ot(e.$$.fragment),ut(e,t.target,t.anchor),y();}g(o);}let D;typeof HTMLElement=="function"&&(D=class extends HTMLElement{constructor(t,n,s){super();$(this,"$$ctor");$(this,"$$s");$(this,"$$c");$(this,"$$cn",!1);$(this,"$$d",{});$(this,"$$r",!1);$(this,"$$p_d",{});$(this,"$$l",{});$(this,"$$l_u",new Map);this.$$ctor=t,this.$$s=n,s&&this.attachShadow({mode:"open"});}addEventListener(t,n,s){if(this.$$l[t]=this.$$l[t]||[],this.$$l[t].push(n),this.$$c){const l=this.$$c.$on(t,n);this.$$l_u.set(n,l);}super.addEventListener(t,n,s);}removeEventListener(t,n,s){if(super.removeEventListener(t,n,s),this.$$c){const l=this.$$l_u.get(n);l&&(l(),this.$$l_u.delete(n));}}connectedCallback(){return T(this,null,function*(){if(this.$$cn=!0,!this.$$c){let t=function(i){return ()=>{let c;return {c:function(){c=L("slot"),i!=="default"&&tt(c,"name",i);},m:function(r,f){U(r,c,f);},d:function(r){r&&C(c);}}}};if(yield Promise.resolve(),!this.$$cn||this.$$c)return;const n={},s=nt(this);for(const i of this.$$s)i in s&&(n[i]=[t(i)]);for(const i of this.attributes){const c=this.$$g_p(i.name);c in this.$$d||(this.$$d[c]=m(c,i.value,this.$$p_d,"toProp"));}for(const i in this.$$p_d)!(i in this.$$d)&&this[i]!==void 0&&(this.$$d[i]=this[i],delete this[i]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:M(P({},this.$$d),{$$slots:n,$$scope:{ctx:[]}})});const l=()=>{this.$$r=!0;for(const i in this.$$p_d)if(this.$$d[i]=this.$$c.$$.ctx[this.$$c.$$.props[i]],this.$$p_d[i].reflect){const c=m(i,this.$$d[i],this.$$p_d,"toAttribute");c==null?this.removeAttribute(this.$$p_d[i].attribute||i):this.setAttribute(this.$$p_d[i].attribute||i,c);}this.$$r=!1;};this.$$c.$$.after_update.push(l),l();for(const i in this.$$l)for(const c of this.$$l[i]){const u=this.$$c.$on(i,c);this.$$l_u.set(c,u);}this.$$l={};}})}attributeChangedCallback(t,n,s){var l;this.$$r||(t=this.$$g_p(t),this.$$d[t]=m(t,s,this.$$p_d,"toProp"),(l=this.$$c)==null||l.$set({[t]:this.$$d[t]}));}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0);});}$$g_p(t){return Object.keys(this.$$p_d).find(n=>this.$$p_d[n].attribute===t||!this.$$p_d[n].attribute&&n.toLowerCase()===t)||t}});function m(e,t,n,s){var i;const l=(i=n[e])==null?void 0:i.type;if(t=l==="Boolean"&&typeof t!="boolean"?t!=null:t,!s||!n[e])return t;if(s==="toAttribute")switch(l){case"Object":case"Array":return t==null?null:JSON.stringify(t);case"Boolean":return t?"":null;case"Number":return t==null?null:t;default:return t}else switch(l){case"Object":case"Array":return t&&JSON.parse(t);case"Boolean":return t;case"Number":return t!=null?+t:t;default:return t}}function at(e,t,n,s,l,i){let c=class extends D{constructor(){super(e,n,l),this.$$p_d=t;}static get observedAttributes(){return Object.keys(t).map(u=>(t[u].attribute||u).toLowerCase())}};return Object.keys(t).forEach(u=>{Object.defineProperty(c.prototype,u,{get(){return this.$$c&&u in this.$$c?this.$$c[u]:this.$$d[u]},set(o){var r;o=m(u,o,t),this.$$d[u]=o,(r=this.$$c)==null||r.$set({[u]:o});}});}),s.forEach(u=>{Object.defineProperty(c.prototype,u,{get(){var o;return (o=this.$$c)==null?void 0:o[u]}});}),e.element=c,c}class ht{constructor(){$(this,"$$");$(this,"$$set");}$destroy(){dt(this,1),this.$destroy=_;}$on(t,n){if(!I(n))return _;const s=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return s.push(n),()=>{const l=s.indexOf(n);l!==-1&&s.splice(l,1);}}$set(t){this.$$set&&!Q(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1);}}const _t="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(_t);function pt(e){X(e,"svelte-gnt082",".LoaderContainer{display:flex;justify-content:center}.lds-ellipsis{display:inline-block;position:relative;width:80px;height:80px}.lds-ellipsis div{position:absolute;top:33px;width:13px;height:13px;border-radius:50%;background:#d1d1d1;animation-timing-function:cubic-bezier(0, 1, 1, 0)}.lds-ellipsis div:nth-child(1){left:8px;animation:lds-ellipsis1 0.6s infinite}.lds-ellipsis div:nth-child(2){left:8px;animation:lds-ellipsis2 0.6s infinite}.lds-ellipsis div:nth-child(3){left:32px;animation:lds-ellipsis2 0.6s infinite}.lds-ellipsis div:nth-child(4){left:56px;animation:lds-ellipsis3 0.6s infinite}@keyframes lds-ellipsis1{0%{transform:scale(0)}100%{transform:scale(1)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}100%{transform:scale(0)}}@keyframes lds-ellipsis2{0%{transform:translate(0, 0)}100%{transform:translate(24px, 0)}}");}function gt(e){let t;return {c(){t=L("div"),t.innerHTML='<section class="LoaderContainer" part="LoaderContainer"><div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div></section>';},m(n,s){U(n,t,s),e[3](t);},p:_,i:_,o:_,d(n){n&&C(t),e[3](null);}}}function mt(e,t,n){let{clientstyling:s=""}=t,{clientstylingurl:l=""}=t,i;const c=()=>{let r=document.createElement("style");r.innerHTML=s,i.appendChild(r);},u=()=>{let r=new URL(l),f=document.createElement("style");fetch(r.href).then(d=>d.text()).then(d=>{f.innerHTML=d,setTimeout(()=>{i.appendChild(f);},1),setTimeout(()=>{},500);});};function o(r){k[r?"unshift":"push"](()=>{i=r,n(0,i);});}return e.$$set=r=>{"clientstyling"in r&&n(1,s=r.clientstyling),"clientstylingurl"in r&&n(2,l=r.clientstylingurl);},e.$$.update=()=>{e.$$.dirty&3&&s&&i&&c(),e.$$.dirty&5&&l&&i&&u();},[i,s,l,o]}class J extends ht{constructor(t){super(),ft(this,t,mt,gt,K,{clientstyling:1,clientstylingurl:2},pt);}get clientstyling(){return this.$$.ctx[1]}set clientstyling(t){this.$$set({clientstyling:t}),y();}get clientstylingurl(){return this.$$.ctx[2]}set clientstylingurl(t){this.$$set({clientstylingurl:t}),y();}}at(J,{clientstyling:{},clientstylingurl:{}},[],[],!0);exports.default=J;
56
+ }(GeneralAnimationLoadingCczQRHih));
57
+
58
+ if(typeof window!="undefined"){let n=function(t){return function(...i){try{return t.apply(this,i)}catch(e){if(e instanceof DOMException&&e.message.includes("has already been used with this registry")||e.message.includes("Cannot define multiple custom elements with the same tag name"))return !1;throw e}}};customElements.define=n(customElements.define),Promise.resolve().then(()=>GeneralAnimationLoadingCczQRHih).then(({default:t})=>{!customElements.get("general-animation-loading")&&customElements.define("general-animation-loading",t.element);});}
59
+
60
+ var LuckyWheelRewardType;
61
+ (function (LuckyWheelRewardType) {
62
+ LuckyWheelRewardType[LuckyWheelRewardType["FreeSpins"] = 0] = "FreeSpins";
63
+ LuckyWheelRewardType[LuckyWheelRewardType["LuckyWheel"] = 1] = "LuckyWheel";
64
+ LuckyWheelRewardType[LuckyWheelRewardType["Leaderboard"] = 2] = "Leaderboard";
65
+ LuckyWheelRewardType[LuckyWheelRewardType["Challenge"] = 3] = "Challenge";
66
+ LuckyWheelRewardType[LuckyWheelRewardType["Custom"] = 4] = "Custom";
67
+ })(LuckyWheelRewardType || (LuckyWheelRewardType = {}));
68
+ var LuckyWheelHistoryLevelStatus;
69
+ (function (LuckyWheelHistoryLevelStatus) {
70
+ LuckyWheelHistoryLevelStatus[LuckyWheelHistoryLevelStatus["Completed"] = 0] = "Completed";
71
+ LuckyWheelHistoryLevelStatus[LuckyWheelHistoryLevelStatus["Expired"] = 1] = "Expired";
72
+ LuckyWheelHistoryLevelStatus[LuckyWheelHistoryLevelStatus["Forfeited"] = 2] = "Forfeited";
73
+ })(LuckyWheelHistoryLevelStatus || (LuckyWheelHistoryLevelStatus = {}));
74
+
75
+ function _typeof(o) {
76
+ "@babel/helpers - typeof";
77
+
78
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
79
+ return typeof o;
80
+ } : function (o) {
81
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
82
+ }, _typeof(o);
83
+ }
84
+
85
+ function toInteger(dirtyNumber) {
86
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
87
+ return NaN;
88
+ }
89
+ var number = Number(dirtyNumber);
90
+ if (isNaN(number)) {
91
+ return number;
92
+ }
93
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
94
+ }
95
+
96
+ function requiredArgs(required, args) {
97
+ if (args.length < required) {
98
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
99
+ }
100
+ }
101
+
102
+ /**
103
+ * @name toDate
104
+ * @category Common Helpers
105
+ * @summary Convert the given argument to an instance of Date.
106
+ *
107
+ * @description
108
+ * Convert the given argument to an instance of Date.
109
+ *
110
+ * If the argument is an instance of Date, the function returns its clone.
111
+ *
112
+ * If the argument is a number, it is treated as a timestamp.
113
+ *
114
+ * If the argument is none of the above, the function returns Invalid Date.
115
+ *
116
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
117
+ *
118
+ * @param {Date|Number} argument - the value to convert
119
+ * @returns {Date} the parsed date in the local time zone
120
+ * @throws {TypeError} 1 argument required
121
+ *
122
+ * @example
123
+ * // Clone the date:
124
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
125
+ * //=> Tue Feb 11 2014 11:30:30
126
+ *
127
+ * @example
128
+ * // Convert the timestamp to date:
129
+ * const result = toDate(1392098430000)
130
+ * //=> Tue Feb 11 2014 11:30:30
131
+ */
132
+ function toDate(argument) {
133
+ requiredArgs(1, arguments);
134
+ var argStr = Object.prototype.toString.call(argument);
135
+
136
+ // Clone the date
137
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
138
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
139
+ return new Date(argument.getTime());
140
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
141
+ return new Date(argument);
142
+ } else {
143
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
144
+ // eslint-disable-next-line no-console
145
+ 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");
146
+ // eslint-disable-next-line no-console
147
+ console.warn(new Error().stack);
148
+ }
149
+ return new Date(NaN);
150
+ }
151
+ }
152
+
153
+ /**
154
+ * @name addMilliseconds
155
+ * @category Millisecond Helpers
156
+ * @summary Add the specified number of milliseconds to the given date.
157
+ *
158
+ * @description
159
+ * Add the specified number of milliseconds to the given date.
160
+ *
161
+ * @param {Date|Number} date - the date to be changed
162
+ * @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`.
163
+ * @returns {Date} the new date with the milliseconds added
164
+ * @throws {TypeError} 2 arguments required
165
+ *
166
+ * @example
167
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
168
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
169
+ * //=> Thu Jul 10 2014 12:45:30.750
170
+ */
171
+ function addMilliseconds(dirtyDate, dirtyAmount) {
172
+ requiredArgs(2, arguments);
173
+ var timestamp = toDate(dirtyDate).getTime();
174
+ var amount = toInteger(dirtyAmount);
175
+ return new Date(timestamp + amount);
176
+ }
177
+
178
+ var defaultOptions = {};
179
+ function getDefaultOptions() {
180
+ return defaultOptions;
181
+ }
182
+
183
+ /**
184
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
185
+ * They usually appear for dates that denote time before the timezones were introduced
186
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
187
+ * and GMT+01:00:00 after that date)
188
+ *
189
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
190
+ * which would lead to incorrect calculations.
191
+ *
192
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
193
+ */
194
+ function getTimezoneOffsetInMilliseconds(date) {
195
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
196
+ utcDate.setUTCFullYear(date.getFullYear());
197
+ return date.getTime() - utcDate.getTime();
198
+ }
199
+
200
+ /**
201
+ * @name isDate
202
+ * @category Common Helpers
203
+ * @summary Is the given value a date?
204
+ *
205
+ * @description
206
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
207
+ *
208
+ * @param {*} value - the value to check
209
+ * @returns {boolean} true if the given value is a date
210
+ * @throws {TypeError} 1 arguments required
211
+ *
212
+ * @example
213
+ * // For a valid date:
214
+ * const result = isDate(new Date())
215
+ * //=> true
216
+ *
217
+ * @example
218
+ * // For an invalid date:
219
+ * const result = isDate(new Date(NaN))
220
+ * //=> true
221
+ *
222
+ * @example
223
+ * // For some value:
224
+ * const result = isDate('2014-02-31')
225
+ * //=> false
226
+ *
227
+ * @example
228
+ * // For an object:
229
+ * const result = isDate({})
230
+ * //=> false
231
+ */
232
+ function isDate(value) {
233
+ requiredArgs(1, arguments);
234
+ return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
235
+ }
236
+
237
+ /**
238
+ * @name isValid
239
+ * @category Common Helpers
240
+ * @summary Is the given date valid?
241
+ *
242
+ * @description
243
+ * Returns false if argument is Invalid Date and true otherwise.
244
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
245
+ * Invalid Date is a Date, whose time value is NaN.
246
+ *
247
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
248
+ *
249
+ * @param {*} date - the date to check
250
+ * @returns {Boolean} the date is valid
251
+ * @throws {TypeError} 1 argument required
252
+ *
253
+ * @example
254
+ * // For the valid date:
255
+ * const result = isValid(new Date(2014, 1, 31))
256
+ * //=> true
257
+ *
258
+ * @example
259
+ * // For the value, convertable into a date:
260
+ * const result = isValid(1393804800000)
261
+ * //=> true
262
+ *
263
+ * @example
264
+ * // For the invalid date:
265
+ * const result = isValid(new Date(''))
266
+ * //=> false
267
+ */
268
+ function isValid(dirtyDate) {
269
+ requiredArgs(1, arguments);
270
+ if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
271
+ return false;
272
+ }
273
+ var date = toDate(dirtyDate);
274
+ return !isNaN(Number(date));
275
+ }
276
+
277
+ /**
278
+ * @name subMilliseconds
279
+ * @category Millisecond Helpers
280
+ * @summary Subtract the specified number of milliseconds from the given date.
281
+ *
282
+ * @description
283
+ * Subtract the specified number of milliseconds from the given date.
284
+ *
285
+ * @param {Date|Number} date - the date to be changed
286
+ * @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`.
287
+ * @returns {Date} the new date with the milliseconds subtracted
288
+ * @throws {TypeError} 2 arguments required
289
+ *
290
+ * @example
291
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
292
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
293
+ * //=> Thu Jul 10 2014 12:45:29.250
294
+ */
295
+ function subMilliseconds(dirtyDate, dirtyAmount) {
296
+ requiredArgs(2, arguments);
297
+ var amount = toInteger(dirtyAmount);
298
+ return addMilliseconds(dirtyDate, -amount);
299
+ }
300
+
301
+ var MILLISECONDS_IN_DAY = 86400000;
302
+ function getUTCDayOfYear(dirtyDate) {
303
+ requiredArgs(1, arguments);
304
+ var date = toDate(dirtyDate);
305
+ var timestamp = date.getTime();
306
+ date.setUTCMonth(0, 1);
307
+ date.setUTCHours(0, 0, 0, 0);
308
+ var startOfYearTimestamp = date.getTime();
309
+ var difference = timestamp - startOfYearTimestamp;
310
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
311
+ }
312
+
313
+ function startOfUTCISOWeek(dirtyDate) {
314
+ requiredArgs(1, arguments);
315
+ var weekStartsOn = 1;
316
+ var date = toDate(dirtyDate);
317
+ var day = date.getUTCDay();
318
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
319
+ date.setUTCDate(date.getUTCDate() - diff);
320
+ date.setUTCHours(0, 0, 0, 0);
321
+ return date;
322
+ }
323
+
324
+ function getUTCISOWeekYear(dirtyDate) {
325
+ requiredArgs(1, arguments);
326
+ var date = toDate(dirtyDate);
327
+ var year = date.getUTCFullYear();
328
+ var fourthOfJanuaryOfNextYear = new Date(0);
329
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
330
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
331
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
332
+ var fourthOfJanuaryOfThisYear = new Date(0);
333
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
334
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
335
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
336
+ if (date.getTime() >= startOfNextYear.getTime()) {
337
+ return year + 1;
338
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
339
+ return year;
340
+ } else {
341
+ return year - 1;
342
+ }
343
+ }
344
+
345
+ function startOfUTCISOWeekYear(dirtyDate) {
346
+ requiredArgs(1, arguments);
347
+ var year = getUTCISOWeekYear(dirtyDate);
348
+ var fourthOfJanuary = new Date(0);
349
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
350
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
351
+ var date = startOfUTCISOWeek(fourthOfJanuary);
352
+ return date;
353
+ }
354
+
355
+ var MILLISECONDS_IN_WEEK$1 = 604800000;
356
+ function getUTCISOWeek(dirtyDate) {
357
+ requiredArgs(1, arguments);
358
+ var date = toDate(dirtyDate);
359
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
360
+
361
+ // Round the number of days to the nearest integer
362
+ // because the number of milliseconds in a week is not constant
363
+ // (e.g. it's different in the week of the daylight saving time clock shift)
364
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
365
+ }
366
+
367
+ function startOfUTCWeek(dirtyDate, options) {
368
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
369
+ requiredArgs(1, arguments);
370
+ var defaultOptions = getDefaultOptions();
371
+ 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);
372
+
373
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
374
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
375
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
376
+ }
377
+ var date = toDate(dirtyDate);
378
+ var day = date.getUTCDay();
379
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
380
+ date.setUTCDate(date.getUTCDate() - diff);
381
+ date.setUTCHours(0, 0, 0, 0);
382
+ return date;
383
+ }
384
+
385
+ function getUTCWeekYear(dirtyDate, options) {
386
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
387
+ requiredArgs(1, arguments);
388
+ var date = toDate(dirtyDate);
389
+ var year = date.getUTCFullYear();
390
+ var defaultOptions = getDefaultOptions();
391
+ 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);
392
+
393
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
394
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
395
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
396
+ }
397
+ var firstWeekOfNextYear = new Date(0);
398
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
399
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
400
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
401
+ var firstWeekOfThisYear = new Date(0);
402
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
403
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
404
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
405
+ if (date.getTime() >= startOfNextYear.getTime()) {
406
+ return year + 1;
407
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
408
+ return year;
409
+ } else {
410
+ return year - 1;
411
+ }
412
+ }
413
+
414
+ function startOfUTCWeekYear(dirtyDate, options) {
415
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
416
+ requiredArgs(1, arguments);
417
+ var defaultOptions = getDefaultOptions();
418
+ 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);
419
+ var year = getUTCWeekYear(dirtyDate, options);
420
+ var firstWeek = new Date(0);
421
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
422
+ firstWeek.setUTCHours(0, 0, 0, 0);
423
+ var date = startOfUTCWeek(firstWeek, options);
424
+ return date;
425
+ }
426
+
427
+ var MILLISECONDS_IN_WEEK = 604800000;
428
+ function getUTCWeek(dirtyDate, options) {
429
+ requiredArgs(1, arguments);
430
+ var date = toDate(dirtyDate);
431
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
432
+
433
+ // Round the number of days to the nearest integer
434
+ // because the number of milliseconds in a week is not constant
435
+ // (e.g. it's different in the week of the daylight saving time clock shift)
436
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
437
+ }
438
+
439
+ function addLeadingZeros(number, targetLength) {
440
+ var sign = number < 0 ? '-' : '';
441
+ var output = Math.abs(number).toString();
442
+ while (output.length < targetLength) {
443
+ output = '0' + output;
444
+ }
445
+ return sign + output;
446
+ }
447
+
448
+ /*
449
+ * | | Unit | | Unit |
450
+ * |-----|--------------------------------|-----|--------------------------------|
451
+ * | a | AM, PM | A* | |
452
+ * | d | Day of month | D | |
453
+ * | h | Hour [1-12] | H | Hour [0-23] |
454
+ * | m | Minute | M | Month |
455
+ * | s | Second | S | Fraction of second |
456
+ * | y | Year (abs) | Y | |
457
+ *
458
+ * Letters marked by * are not implemented but reserved by Unicode standard.
459
+ */
460
+ var formatters$2 = {
461
+ // Year
462
+ y: function y(date, token) {
463
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
464
+ // | Year | y | yy | yyy | yyyy | yyyyy |
465
+ // |----------|-------|----|-------|-------|-------|
466
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
467
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
468
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
469
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
470
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
471
+
472
+ var signedYear = date.getUTCFullYear();
473
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
474
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
475
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
476
+ },
477
+ // Month
478
+ M: function M(date, token) {
479
+ var month = date.getUTCMonth();
480
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
481
+ },
482
+ // Day of the month
483
+ d: function d(date, token) {
484
+ return addLeadingZeros(date.getUTCDate(), token.length);
485
+ },
486
+ // AM or PM
487
+ a: function a(date, token) {
488
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
489
+ switch (token) {
490
+ case 'a':
491
+ case 'aa':
492
+ return dayPeriodEnumValue.toUpperCase();
493
+ case 'aaa':
494
+ return dayPeriodEnumValue;
495
+ case 'aaaaa':
496
+ return dayPeriodEnumValue[0];
497
+ case 'aaaa':
498
+ default:
499
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
500
+ }
501
+ },
502
+ // Hour [1-12]
503
+ h: function h(date, token) {
504
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
505
+ },
506
+ // Hour [0-23]
507
+ H: function H(date, token) {
508
+ return addLeadingZeros(date.getUTCHours(), token.length);
509
+ },
510
+ // Minute
511
+ m: function m(date, token) {
512
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
513
+ },
514
+ // Second
515
+ s: function s(date, token) {
516
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
517
+ },
518
+ // Fraction of second
519
+ S: function S(date, token) {
520
+ var numberOfDigits = token.length;
521
+ var milliseconds = date.getUTCMilliseconds();
522
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
523
+ return addLeadingZeros(fractionalSeconds, token.length);
524
+ }
525
+ };
526
+ const formatters$3 = formatters$2;
527
+
528
+ var dayPeriodEnum = {
529
+ am: 'am',
530
+ pm: 'pm',
531
+ midnight: 'midnight',
532
+ noon: 'noon',
533
+ morning: 'morning',
534
+ afternoon: 'afternoon',
535
+ evening: 'evening',
536
+ night: 'night'
537
+ };
538
+ /*
539
+ * | | Unit | | Unit |
540
+ * |-----|--------------------------------|-----|--------------------------------|
541
+ * | a | AM, PM | A* | Milliseconds in day |
542
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
543
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
544
+ * | d | Day of month | D | Day of year |
545
+ * | e | Local day of week | E | Day of week |
546
+ * | f | | F* | Day of week in month |
547
+ * | g* | Modified Julian day | G | Era |
548
+ * | h | Hour [1-12] | H | Hour [0-23] |
549
+ * | i! | ISO day of week | I! | ISO week of year |
550
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
551
+ * | k | Hour [1-24] | K | Hour [0-11] |
552
+ * | l* | (deprecated) | L | Stand-alone month |
553
+ * | m | Minute | M | Month |
554
+ * | n | | N | |
555
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
556
+ * | p! | Long localized time | P! | Long localized date |
557
+ * | q | Stand-alone quarter | Q | Quarter |
558
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
559
+ * | s | Second | S | Fraction of second |
560
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
561
+ * | u | Extended year | U* | Cyclic year |
562
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
563
+ * | w | Local week of year | W* | Week of month |
564
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
565
+ * | y | Year (abs) | Y | Local week-numbering year |
566
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
567
+ *
568
+ * Letters marked by * are not implemented but reserved by Unicode standard.
569
+ *
570
+ * Letters marked by ! are non-standard, but implemented by date-fns:
571
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
572
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
573
+ * i.e. 7 for Sunday, 1 for Monday, etc.
574
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
575
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
576
+ * `R` is supposed to be used in conjunction with `I` and `i`
577
+ * for universal ISO week-numbering date, whereas
578
+ * `Y` is supposed to be used in conjunction with `w` and `e`
579
+ * for week-numbering date specific to the locale.
580
+ * - `P` is long localized date format
581
+ * - `p` is long localized time format
582
+ */
583
+
584
+ var formatters = {
585
+ // Era
586
+ G: function G(date, token, localize) {
587
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
588
+ switch (token) {
589
+ // AD, BC
590
+ case 'G':
591
+ case 'GG':
592
+ case 'GGG':
593
+ return localize.era(era, {
594
+ width: 'abbreviated'
595
+ });
596
+ // A, B
597
+ case 'GGGGG':
598
+ return localize.era(era, {
599
+ width: 'narrow'
600
+ });
601
+ // Anno Domini, Before Christ
602
+ case 'GGGG':
603
+ default:
604
+ return localize.era(era, {
605
+ width: 'wide'
606
+ });
607
+ }
608
+ },
609
+ // Year
610
+ y: function y(date, token, localize) {
611
+ // Ordinal number
612
+ if (token === 'yo') {
613
+ var signedYear = date.getUTCFullYear();
614
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
615
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
616
+ return localize.ordinalNumber(year, {
617
+ unit: 'year'
618
+ });
619
+ }
620
+ return formatters$3.y(date, token);
621
+ },
622
+ // Local week-numbering year
623
+ Y: function Y(date, token, localize, options) {
624
+ var signedWeekYear = getUTCWeekYear(date, options);
625
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
626
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
627
+
628
+ // Two digit year
629
+ if (token === 'YY') {
630
+ var twoDigitYear = weekYear % 100;
631
+ return addLeadingZeros(twoDigitYear, 2);
632
+ }
633
+
634
+ // Ordinal number
635
+ if (token === 'Yo') {
636
+ return localize.ordinalNumber(weekYear, {
637
+ unit: 'year'
638
+ });
639
+ }
640
+
641
+ // Padding
642
+ return addLeadingZeros(weekYear, token.length);
643
+ },
644
+ // ISO week-numbering year
645
+ R: function R(date, token) {
646
+ var isoWeekYear = getUTCISOWeekYear(date);
647
+
648
+ // Padding
649
+ return addLeadingZeros(isoWeekYear, token.length);
650
+ },
651
+ // Extended year. This is a single number designating the year of this calendar system.
652
+ // The main difference between `y` and `u` localizers are B.C. years:
653
+ // | Year | `y` | `u` |
654
+ // |------|-----|-----|
655
+ // | AC 1 | 1 | 1 |
656
+ // | BC 1 | 1 | 0 |
657
+ // | BC 2 | 2 | -1 |
658
+ // Also `yy` always returns the last two digits of a year,
659
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
660
+ u: function u(date, token) {
661
+ var year = date.getUTCFullYear();
662
+ return addLeadingZeros(year, token.length);
663
+ },
664
+ // Quarter
665
+ Q: function Q(date, token, localize) {
666
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
667
+ switch (token) {
668
+ // 1, 2, 3, 4
669
+ case 'Q':
670
+ return String(quarter);
671
+ // 01, 02, 03, 04
672
+ case 'QQ':
673
+ return addLeadingZeros(quarter, 2);
674
+ // 1st, 2nd, 3rd, 4th
675
+ case 'Qo':
676
+ return localize.ordinalNumber(quarter, {
677
+ unit: 'quarter'
678
+ });
679
+ // Q1, Q2, Q3, Q4
680
+ case 'QQQ':
681
+ return localize.quarter(quarter, {
682
+ width: 'abbreviated',
683
+ context: 'formatting'
684
+ });
685
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
686
+ case 'QQQQQ':
687
+ return localize.quarter(quarter, {
688
+ width: 'narrow',
689
+ context: 'formatting'
690
+ });
691
+ // 1st quarter, 2nd quarter, ...
692
+ case 'QQQQ':
693
+ default:
694
+ return localize.quarter(quarter, {
695
+ width: 'wide',
696
+ context: 'formatting'
697
+ });
698
+ }
699
+ },
700
+ // Stand-alone quarter
701
+ q: function q(date, token, localize) {
702
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
703
+ switch (token) {
704
+ // 1, 2, 3, 4
705
+ case 'q':
706
+ return String(quarter);
707
+ // 01, 02, 03, 04
708
+ case 'qq':
709
+ return addLeadingZeros(quarter, 2);
710
+ // 1st, 2nd, 3rd, 4th
711
+ case 'qo':
712
+ return localize.ordinalNumber(quarter, {
713
+ unit: 'quarter'
714
+ });
715
+ // Q1, Q2, Q3, Q4
716
+ case 'qqq':
717
+ return localize.quarter(quarter, {
718
+ width: 'abbreviated',
719
+ context: 'standalone'
720
+ });
721
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
722
+ case 'qqqqq':
723
+ return localize.quarter(quarter, {
724
+ width: 'narrow',
725
+ context: 'standalone'
726
+ });
727
+ // 1st quarter, 2nd quarter, ...
728
+ case 'qqqq':
729
+ default:
730
+ return localize.quarter(quarter, {
731
+ width: 'wide',
732
+ context: 'standalone'
733
+ });
734
+ }
735
+ },
736
+ // Month
737
+ M: function M(date, token, localize) {
738
+ var month = date.getUTCMonth();
739
+ switch (token) {
740
+ case 'M':
741
+ case 'MM':
742
+ return formatters$3.M(date, token);
743
+ // 1st, 2nd, ..., 12th
744
+ case 'Mo':
745
+ return localize.ordinalNumber(month + 1, {
746
+ unit: 'month'
747
+ });
748
+ // Jan, Feb, ..., Dec
749
+ case 'MMM':
750
+ return localize.month(month, {
751
+ width: 'abbreviated',
752
+ context: 'formatting'
753
+ });
754
+ // J, F, ..., D
755
+ case 'MMMMM':
756
+ return localize.month(month, {
757
+ width: 'narrow',
758
+ context: 'formatting'
759
+ });
760
+ // January, February, ..., December
761
+ case 'MMMM':
762
+ default:
763
+ return localize.month(month, {
764
+ width: 'wide',
765
+ context: 'formatting'
766
+ });
767
+ }
768
+ },
769
+ // Stand-alone month
770
+ L: function L(date, token, localize) {
771
+ var month = date.getUTCMonth();
772
+ switch (token) {
773
+ // 1, 2, ..., 12
774
+ case 'L':
775
+ return String(month + 1);
776
+ // 01, 02, ..., 12
777
+ case 'LL':
778
+ return addLeadingZeros(month + 1, 2);
779
+ // 1st, 2nd, ..., 12th
780
+ case 'Lo':
781
+ return localize.ordinalNumber(month + 1, {
782
+ unit: 'month'
783
+ });
784
+ // Jan, Feb, ..., Dec
785
+ case 'LLL':
786
+ return localize.month(month, {
787
+ width: 'abbreviated',
788
+ context: 'standalone'
789
+ });
790
+ // J, F, ..., D
791
+ case 'LLLLL':
792
+ return localize.month(month, {
793
+ width: 'narrow',
794
+ context: 'standalone'
795
+ });
796
+ // January, February, ..., December
797
+ case 'LLLL':
798
+ default:
799
+ return localize.month(month, {
800
+ width: 'wide',
801
+ context: 'standalone'
802
+ });
803
+ }
804
+ },
805
+ // Local week of year
806
+ w: function w(date, token, localize, options) {
807
+ var week = getUTCWeek(date, options);
808
+ if (token === 'wo') {
809
+ return localize.ordinalNumber(week, {
810
+ unit: 'week'
811
+ });
812
+ }
813
+ return addLeadingZeros(week, token.length);
814
+ },
815
+ // ISO week of year
816
+ I: function I(date, token, localize) {
817
+ var isoWeek = getUTCISOWeek(date);
818
+ if (token === 'Io') {
819
+ return localize.ordinalNumber(isoWeek, {
820
+ unit: 'week'
821
+ });
822
+ }
823
+ return addLeadingZeros(isoWeek, token.length);
824
+ },
825
+ // Day of the month
826
+ d: function d(date, token, localize) {
827
+ if (token === 'do') {
828
+ return localize.ordinalNumber(date.getUTCDate(), {
829
+ unit: 'date'
830
+ });
831
+ }
832
+ return formatters$3.d(date, token);
833
+ },
834
+ // Day of year
835
+ D: function D(date, token, localize) {
836
+ var dayOfYear = getUTCDayOfYear(date);
837
+ if (token === 'Do') {
838
+ return localize.ordinalNumber(dayOfYear, {
839
+ unit: 'dayOfYear'
840
+ });
841
+ }
842
+ return addLeadingZeros(dayOfYear, token.length);
843
+ },
844
+ // Day of week
845
+ E: function E(date, token, localize) {
846
+ var dayOfWeek = date.getUTCDay();
847
+ switch (token) {
848
+ // Tue
849
+ case 'E':
850
+ case 'EE':
851
+ case 'EEE':
852
+ return localize.day(dayOfWeek, {
853
+ width: 'abbreviated',
854
+ context: 'formatting'
855
+ });
856
+ // T
857
+ case 'EEEEE':
858
+ return localize.day(dayOfWeek, {
859
+ width: 'narrow',
860
+ context: 'formatting'
861
+ });
862
+ // Tu
863
+ case 'EEEEEE':
864
+ return localize.day(dayOfWeek, {
865
+ width: 'short',
866
+ context: 'formatting'
867
+ });
868
+ // Tuesday
869
+ case 'EEEE':
870
+ default:
871
+ return localize.day(dayOfWeek, {
872
+ width: 'wide',
873
+ context: 'formatting'
874
+ });
875
+ }
876
+ },
877
+ // Local day of week
878
+ e: function e(date, token, localize, options) {
879
+ var dayOfWeek = date.getUTCDay();
880
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
881
+ switch (token) {
882
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
883
+ case 'e':
884
+ return String(localDayOfWeek);
885
+ // Padded numerical value
886
+ case 'ee':
887
+ return addLeadingZeros(localDayOfWeek, 2);
888
+ // 1st, 2nd, ..., 7th
889
+ case 'eo':
890
+ return localize.ordinalNumber(localDayOfWeek, {
891
+ unit: 'day'
892
+ });
893
+ case 'eee':
894
+ return localize.day(dayOfWeek, {
895
+ width: 'abbreviated',
896
+ context: 'formatting'
897
+ });
898
+ // T
899
+ case 'eeeee':
900
+ return localize.day(dayOfWeek, {
901
+ width: 'narrow',
902
+ context: 'formatting'
903
+ });
904
+ // Tu
905
+ case 'eeeeee':
906
+ return localize.day(dayOfWeek, {
907
+ width: 'short',
908
+ context: 'formatting'
909
+ });
910
+ // Tuesday
911
+ case 'eeee':
912
+ default:
913
+ return localize.day(dayOfWeek, {
914
+ width: 'wide',
915
+ context: 'formatting'
916
+ });
917
+ }
918
+ },
919
+ // Stand-alone local day of week
920
+ c: function c(date, token, localize, options) {
921
+ var dayOfWeek = date.getUTCDay();
922
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
923
+ switch (token) {
924
+ // Numerical value (same as in `e`)
925
+ case 'c':
926
+ return String(localDayOfWeek);
927
+ // Padded numerical value
928
+ case 'cc':
929
+ return addLeadingZeros(localDayOfWeek, token.length);
930
+ // 1st, 2nd, ..., 7th
931
+ case 'co':
932
+ return localize.ordinalNumber(localDayOfWeek, {
933
+ unit: 'day'
934
+ });
935
+ case 'ccc':
936
+ return localize.day(dayOfWeek, {
937
+ width: 'abbreviated',
938
+ context: 'standalone'
939
+ });
940
+ // T
941
+ case 'ccccc':
942
+ return localize.day(dayOfWeek, {
943
+ width: 'narrow',
944
+ context: 'standalone'
945
+ });
946
+ // Tu
947
+ case 'cccccc':
948
+ return localize.day(dayOfWeek, {
949
+ width: 'short',
950
+ context: 'standalone'
951
+ });
952
+ // Tuesday
953
+ case 'cccc':
954
+ default:
955
+ return localize.day(dayOfWeek, {
956
+ width: 'wide',
957
+ context: 'standalone'
958
+ });
959
+ }
960
+ },
961
+ // ISO day of week
962
+ i: function i(date, token, localize) {
963
+ var dayOfWeek = date.getUTCDay();
964
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
965
+ switch (token) {
966
+ // 2
967
+ case 'i':
968
+ return String(isoDayOfWeek);
969
+ // 02
970
+ case 'ii':
971
+ return addLeadingZeros(isoDayOfWeek, token.length);
972
+ // 2nd
973
+ case 'io':
974
+ return localize.ordinalNumber(isoDayOfWeek, {
975
+ unit: 'day'
976
+ });
977
+ // Tue
978
+ case 'iii':
979
+ return localize.day(dayOfWeek, {
980
+ width: 'abbreviated',
981
+ context: 'formatting'
982
+ });
983
+ // T
984
+ case 'iiiii':
985
+ return localize.day(dayOfWeek, {
986
+ width: 'narrow',
987
+ context: 'formatting'
988
+ });
989
+ // Tu
990
+ case 'iiiiii':
991
+ return localize.day(dayOfWeek, {
992
+ width: 'short',
993
+ context: 'formatting'
994
+ });
995
+ // Tuesday
996
+ case 'iiii':
997
+ default:
998
+ return localize.day(dayOfWeek, {
999
+ width: 'wide',
1000
+ context: 'formatting'
1001
+ });
1002
+ }
1003
+ },
1004
+ // AM or PM
1005
+ a: function a(date, token, localize) {
1006
+ var hours = date.getUTCHours();
1007
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1008
+ switch (token) {
1009
+ case 'a':
1010
+ case 'aa':
1011
+ return localize.dayPeriod(dayPeriodEnumValue, {
1012
+ width: 'abbreviated',
1013
+ context: 'formatting'
1014
+ });
1015
+ case 'aaa':
1016
+ return localize.dayPeriod(dayPeriodEnumValue, {
1017
+ width: 'abbreviated',
1018
+ context: 'formatting'
1019
+ }).toLowerCase();
1020
+ case 'aaaaa':
1021
+ return localize.dayPeriod(dayPeriodEnumValue, {
1022
+ width: 'narrow',
1023
+ context: 'formatting'
1024
+ });
1025
+ case 'aaaa':
1026
+ default:
1027
+ return localize.dayPeriod(dayPeriodEnumValue, {
1028
+ width: 'wide',
1029
+ context: 'formatting'
1030
+ });
1031
+ }
1032
+ },
1033
+ // AM, PM, midnight, noon
1034
+ b: function b(date, token, localize) {
1035
+ var hours = date.getUTCHours();
1036
+ var dayPeriodEnumValue;
1037
+ if (hours === 12) {
1038
+ dayPeriodEnumValue = dayPeriodEnum.noon;
1039
+ } else if (hours === 0) {
1040
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
1041
+ } else {
1042
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1043
+ }
1044
+ switch (token) {
1045
+ case 'b':
1046
+ case 'bb':
1047
+ return localize.dayPeriod(dayPeriodEnumValue, {
1048
+ width: 'abbreviated',
1049
+ context: 'formatting'
1050
+ });
1051
+ case 'bbb':
1052
+ return localize.dayPeriod(dayPeriodEnumValue, {
1053
+ width: 'abbreviated',
1054
+ context: 'formatting'
1055
+ }).toLowerCase();
1056
+ case 'bbbbb':
1057
+ return localize.dayPeriod(dayPeriodEnumValue, {
1058
+ width: 'narrow',
1059
+ context: 'formatting'
1060
+ });
1061
+ case 'bbbb':
1062
+ default:
1063
+ return localize.dayPeriod(dayPeriodEnumValue, {
1064
+ width: 'wide',
1065
+ context: 'formatting'
1066
+ });
1067
+ }
1068
+ },
1069
+ // in the morning, in the afternoon, in the evening, at night
1070
+ B: function B(date, token, localize) {
1071
+ var hours = date.getUTCHours();
1072
+ var dayPeriodEnumValue;
1073
+ if (hours >= 17) {
1074
+ dayPeriodEnumValue = dayPeriodEnum.evening;
1075
+ } else if (hours >= 12) {
1076
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
1077
+ } else if (hours >= 4) {
1078
+ dayPeriodEnumValue = dayPeriodEnum.morning;
1079
+ } else {
1080
+ dayPeriodEnumValue = dayPeriodEnum.night;
1081
+ }
1082
+ switch (token) {
1083
+ case 'B':
1084
+ case 'BB':
1085
+ case 'BBB':
1086
+ return localize.dayPeriod(dayPeriodEnumValue, {
1087
+ width: 'abbreviated',
1088
+ context: 'formatting'
1089
+ });
1090
+ case 'BBBBB':
1091
+ return localize.dayPeriod(dayPeriodEnumValue, {
1092
+ width: 'narrow',
1093
+ context: 'formatting'
1094
+ });
1095
+ case 'BBBB':
1096
+ default:
1097
+ return localize.dayPeriod(dayPeriodEnumValue, {
1098
+ width: 'wide',
1099
+ context: 'formatting'
1100
+ });
1101
+ }
1102
+ },
1103
+ // Hour [1-12]
1104
+ h: function h(date, token, localize) {
1105
+ if (token === 'ho') {
1106
+ var hours = date.getUTCHours() % 12;
1107
+ if (hours === 0) hours = 12;
1108
+ return localize.ordinalNumber(hours, {
1109
+ unit: 'hour'
1110
+ });
1111
+ }
1112
+ return formatters$3.h(date, token);
1113
+ },
1114
+ // Hour [0-23]
1115
+ H: function H(date, token, localize) {
1116
+ if (token === 'Ho') {
1117
+ return localize.ordinalNumber(date.getUTCHours(), {
1118
+ unit: 'hour'
1119
+ });
1120
+ }
1121
+ return formatters$3.H(date, token);
1122
+ },
1123
+ // Hour [0-11]
1124
+ K: function K(date, token, localize) {
1125
+ var hours = date.getUTCHours() % 12;
1126
+ if (token === 'Ko') {
1127
+ return localize.ordinalNumber(hours, {
1128
+ unit: 'hour'
1129
+ });
1130
+ }
1131
+ return addLeadingZeros(hours, token.length);
1132
+ },
1133
+ // Hour [1-24]
1134
+ k: function k(date, token, localize) {
1135
+ var hours = date.getUTCHours();
1136
+ if (hours === 0) hours = 24;
1137
+ if (token === 'ko') {
1138
+ return localize.ordinalNumber(hours, {
1139
+ unit: 'hour'
1140
+ });
1141
+ }
1142
+ return addLeadingZeros(hours, token.length);
1143
+ },
1144
+ // Minute
1145
+ m: function m(date, token, localize) {
1146
+ if (token === 'mo') {
1147
+ return localize.ordinalNumber(date.getUTCMinutes(), {
1148
+ unit: 'minute'
1149
+ });
1150
+ }
1151
+ return formatters$3.m(date, token);
1152
+ },
1153
+ // Second
1154
+ s: function s(date, token, localize) {
1155
+ if (token === 'so') {
1156
+ return localize.ordinalNumber(date.getUTCSeconds(), {
1157
+ unit: 'second'
1158
+ });
1159
+ }
1160
+ return formatters$3.s(date, token);
1161
+ },
1162
+ // Fraction of second
1163
+ S: function S(date, token) {
1164
+ return formatters$3.S(date, token);
1165
+ },
1166
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1167
+ X: function X(date, token, _localize, options) {
1168
+ var originalDate = options._originalDate || date;
1169
+ var timezoneOffset = originalDate.getTimezoneOffset();
1170
+ if (timezoneOffset === 0) {
1171
+ return 'Z';
1172
+ }
1173
+ switch (token) {
1174
+ // Hours and optional minutes
1175
+ case 'X':
1176
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1177
+
1178
+ // Hours, minutes and optional seconds without `:` delimiter
1179
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1180
+ // so this token always has the same output as `XX`
1181
+ case 'XXXX':
1182
+ case 'XX':
1183
+ // Hours and minutes without `:` delimiter
1184
+ return formatTimezone(timezoneOffset);
1185
+
1186
+ // Hours, minutes and optional seconds with `:` delimiter
1187
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1188
+ // so this token always has the same output as `XXX`
1189
+ case 'XXXXX':
1190
+ case 'XXX': // Hours and minutes with `:` delimiter
1191
+ default:
1192
+ return formatTimezone(timezoneOffset, ':');
1193
+ }
1194
+ },
1195
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1196
+ x: function x(date, token, _localize, options) {
1197
+ var originalDate = options._originalDate || date;
1198
+ var timezoneOffset = originalDate.getTimezoneOffset();
1199
+ switch (token) {
1200
+ // Hours and optional minutes
1201
+ case 'x':
1202
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1203
+
1204
+ // Hours, minutes and optional seconds without `:` delimiter
1205
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1206
+ // so this token always has the same output as `xx`
1207
+ case 'xxxx':
1208
+ case 'xx':
1209
+ // Hours and minutes without `:` delimiter
1210
+ return formatTimezone(timezoneOffset);
1211
+
1212
+ // Hours, minutes and optional seconds with `:` delimiter
1213
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1214
+ // so this token always has the same output as `xxx`
1215
+ case 'xxxxx':
1216
+ case 'xxx': // Hours and minutes with `:` delimiter
1217
+ default:
1218
+ return formatTimezone(timezoneOffset, ':');
1219
+ }
1220
+ },
1221
+ // Timezone (GMT)
1222
+ O: function O(date, token, _localize, options) {
1223
+ var originalDate = options._originalDate || date;
1224
+ var timezoneOffset = originalDate.getTimezoneOffset();
1225
+ switch (token) {
1226
+ // Short
1227
+ case 'O':
1228
+ case 'OO':
1229
+ case 'OOO':
1230
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1231
+ // Long
1232
+ case 'OOOO':
1233
+ default:
1234
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1235
+ }
1236
+ },
1237
+ // Timezone (specific non-location)
1238
+ z: function z(date, token, _localize, options) {
1239
+ var originalDate = options._originalDate || date;
1240
+ var timezoneOffset = originalDate.getTimezoneOffset();
1241
+ switch (token) {
1242
+ // Short
1243
+ case 'z':
1244
+ case 'zz':
1245
+ case 'zzz':
1246
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1247
+ // Long
1248
+ case 'zzzz':
1249
+ default:
1250
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1251
+ }
1252
+ },
1253
+ // Seconds timestamp
1254
+ t: function t(date, token, _localize, options) {
1255
+ var originalDate = options._originalDate || date;
1256
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
1257
+ return addLeadingZeros(timestamp, token.length);
1258
+ },
1259
+ // Milliseconds timestamp
1260
+ T: function T(date, token, _localize, options) {
1261
+ var originalDate = options._originalDate || date;
1262
+ var timestamp = originalDate.getTime();
1263
+ return addLeadingZeros(timestamp, token.length);
1264
+ }
1265
+ };
1266
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1267
+ var sign = offset > 0 ? '-' : '+';
1268
+ var absOffset = Math.abs(offset);
1269
+ var hours = Math.floor(absOffset / 60);
1270
+ var minutes = absOffset % 60;
1271
+ if (minutes === 0) {
1272
+ return sign + String(hours);
1273
+ }
1274
+ var delimiter = dirtyDelimiter || '';
1275
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1276
+ }
1277
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1278
+ if (offset % 60 === 0) {
1279
+ var sign = offset > 0 ? '-' : '+';
1280
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1281
+ }
1282
+ return formatTimezone(offset, dirtyDelimiter);
1283
+ }
1284
+ function formatTimezone(offset, dirtyDelimiter) {
1285
+ var delimiter = dirtyDelimiter || '';
1286
+ var sign = offset > 0 ? '-' : '+';
1287
+ var absOffset = Math.abs(offset);
1288
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1289
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1290
+ return sign + hours + delimiter + minutes;
1291
+ }
1292
+ const formatters$1 = formatters;
1293
+
1294
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1295
+ switch (pattern) {
1296
+ case 'P':
1297
+ return formatLong.date({
1298
+ width: 'short'
1299
+ });
1300
+ case 'PP':
1301
+ return formatLong.date({
1302
+ width: 'medium'
1303
+ });
1304
+ case 'PPP':
1305
+ return formatLong.date({
1306
+ width: 'long'
1307
+ });
1308
+ case 'PPPP':
1309
+ default:
1310
+ return formatLong.date({
1311
+ width: 'full'
1312
+ });
1313
+ }
1314
+ };
1315
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1316
+ switch (pattern) {
1317
+ case 'p':
1318
+ return formatLong.time({
1319
+ width: 'short'
1320
+ });
1321
+ case 'pp':
1322
+ return formatLong.time({
1323
+ width: 'medium'
1324
+ });
1325
+ case 'ppp':
1326
+ return formatLong.time({
1327
+ width: 'long'
1328
+ });
1329
+ case 'pppp':
1330
+ default:
1331
+ return formatLong.time({
1332
+ width: 'full'
1333
+ });
1334
+ }
1335
+ };
1336
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1337
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1338
+ var datePattern = matchResult[1];
1339
+ var timePattern = matchResult[2];
1340
+ if (!timePattern) {
1341
+ return dateLongFormatter(pattern, formatLong);
1342
+ }
1343
+ var dateTimeFormat;
1344
+ switch (datePattern) {
1345
+ case 'P':
1346
+ dateTimeFormat = formatLong.dateTime({
1347
+ width: 'short'
1348
+ });
1349
+ break;
1350
+ case 'PP':
1351
+ dateTimeFormat = formatLong.dateTime({
1352
+ width: 'medium'
1353
+ });
1354
+ break;
1355
+ case 'PPP':
1356
+ dateTimeFormat = formatLong.dateTime({
1357
+ width: 'long'
1358
+ });
1359
+ break;
1360
+ case 'PPPP':
1361
+ default:
1362
+ dateTimeFormat = formatLong.dateTime({
1363
+ width: 'full'
1364
+ });
1365
+ break;
1366
+ }
1367
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1368
+ };
1369
+ var longFormatters = {
1370
+ p: timeLongFormatter,
1371
+ P: dateTimeLongFormatter
1372
+ };
1373
+ const longFormatters$1 = longFormatters;
1374
+
1375
+ var protectedDayOfYearTokens = ['D', 'DD'];
1376
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1377
+ function isProtectedDayOfYearToken(token) {
1378
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1379
+ }
1380
+ function isProtectedWeekYearToken(token) {
1381
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1382
+ }
1383
+ function throwProtectedError(token, format, input) {
1384
+ if (token === 'YYYY') {
1385
+ 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"));
1386
+ } else if (token === 'YY') {
1387
+ 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"));
1388
+ } else if (token === 'D') {
1389
+ 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"));
1390
+ } else if (token === 'DD') {
1391
+ 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"));
1392
+ }
1393
+ }
1394
+
1395
+ var formatDistanceLocale = {
1396
+ lessThanXSeconds: {
1397
+ one: 'less than a second',
1398
+ other: 'less than {{count}} seconds'
1399
+ },
1400
+ xSeconds: {
1401
+ one: '1 second',
1402
+ other: '{{count}} seconds'
1403
+ },
1404
+ halfAMinute: 'half a minute',
1405
+ lessThanXMinutes: {
1406
+ one: 'less than a minute',
1407
+ other: 'less than {{count}} minutes'
1408
+ },
1409
+ xMinutes: {
1410
+ one: '1 minute',
1411
+ other: '{{count}} minutes'
1412
+ },
1413
+ aboutXHours: {
1414
+ one: 'about 1 hour',
1415
+ other: 'about {{count}} hours'
1416
+ },
1417
+ xHours: {
1418
+ one: '1 hour',
1419
+ other: '{{count}} hours'
1420
+ },
1421
+ xDays: {
1422
+ one: '1 day',
1423
+ other: '{{count}} days'
1424
+ },
1425
+ aboutXWeeks: {
1426
+ one: 'about 1 week',
1427
+ other: 'about {{count}} weeks'
1428
+ },
1429
+ xWeeks: {
1430
+ one: '1 week',
1431
+ other: '{{count}} weeks'
1432
+ },
1433
+ aboutXMonths: {
1434
+ one: 'about 1 month',
1435
+ other: 'about {{count}} months'
1436
+ },
1437
+ xMonths: {
1438
+ one: '1 month',
1439
+ other: '{{count}} months'
1440
+ },
1441
+ aboutXYears: {
1442
+ one: 'about 1 year',
1443
+ other: 'about {{count}} years'
1444
+ },
1445
+ xYears: {
1446
+ one: '1 year',
1447
+ other: '{{count}} years'
1448
+ },
1449
+ overXYears: {
1450
+ one: 'over 1 year',
1451
+ other: 'over {{count}} years'
1452
+ },
1453
+ almostXYears: {
1454
+ one: 'almost 1 year',
1455
+ other: 'almost {{count}} years'
1456
+ }
1457
+ };
1458
+ var formatDistance = function formatDistance(token, count, options) {
1459
+ var result;
1460
+ var tokenValue = formatDistanceLocale[token];
1461
+ if (typeof tokenValue === 'string') {
1462
+ result = tokenValue;
1463
+ } else if (count === 1) {
1464
+ result = tokenValue.one;
1465
+ } else {
1466
+ result = tokenValue.other.replace('{{count}}', count.toString());
1467
+ }
1468
+ if (options !== null && options !== void 0 && options.addSuffix) {
1469
+ if (options.comparison && options.comparison > 0) {
1470
+ return 'in ' + result;
1471
+ } else {
1472
+ return result + ' ago';
1473
+ }
1474
+ }
1475
+ return result;
1476
+ };
1477
+ const formatDistance$1 = formatDistance;
1478
+
1479
+ function buildFormatLongFn(args) {
1480
+ return function () {
1481
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1482
+ // TODO: Remove String()
1483
+ var width = options.width ? String(options.width) : args.defaultWidth;
1484
+ var format = args.formats[width] || args.formats[args.defaultWidth];
1485
+ return format;
1486
+ };
1487
+ }
1488
+
1489
+ var dateFormats = {
1490
+ full: 'EEEE, MMMM do, y',
1491
+ long: 'MMMM do, y',
1492
+ medium: 'MMM d, y',
1493
+ short: 'MM/dd/yyyy'
1494
+ };
1495
+ var timeFormats = {
1496
+ full: 'h:mm:ss a zzzz',
1497
+ long: 'h:mm:ss a z',
1498
+ medium: 'h:mm:ss a',
1499
+ short: 'h:mm a'
1500
+ };
1501
+ var dateTimeFormats = {
1502
+ full: "{{date}} 'at' {{time}}",
1503
+ long: "{{date}} 'at' {{time}}",
1504
+ medium: '{{date}}, {{time}}',
1505
+ short: '{{date}}, {{time}}'
1506
+ };
1507
+ var formatLong = {
1508
+ date: buildFormatLongFn({
1509
+ formats: dateFormats,
1510
+ defaultWidth: 'full'
1511
+ }),
1512
+ time: buildFormatLongFn({
1513
+ formats: timeFormats,
1514
+ defaultWidth: 'full'
1515
+ }),
1516
+ dateTime: buildFormatLongFn({
1517
+ formats: dateTimeFormats,
1518
+ defaultWidth: 'full'
1519
+ })
1520
+ };
1521
+ const formatLong$1 = formatLong;
1522
+
1523
+ var formatRelativeLocale = {
1524
+ lastWeek: "'last' eeee 'at' p",
1525
+ yesterday: "'yesterday at' p",
1526
+ today: "'today at' p",
1527
+ tomorrow: "'tomorrow at' p",
1528
+ nextWeek: "eeee 'at' p",
1529
+ other: 'P'
1530
+ };
1531
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1532
+ return formatRelativeLocale[token];
1533
+ };
1534
+ const formatRelative$1 = formatRelative;
1535
+
1536
+ function buildLocalizeFn(args) {
1537
+ return function (dirtyIndex, options) {
1538
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1539
+ var valuesArray;
1540
+ if (context === 'formatting' && args.formattingValues) {
1541
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1542
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1543
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1544
+ } else {
1545
+ var _defaultWidth = args.defaultWidth;
1546
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1547
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
1548
+ }
1549
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1550
+ // @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!
1551
+ return valuesArray[index];
1552
+ };
1553
+ }
1554
+
1555
+ var eraValues = {
1556
+ narrow: ['B', 'A'],
1557
+ abbreviated: ['BC', 'AD'],
1558
+ wide: ['Before Christ', 'Anno Domini']
1559
+ };
1560
+ var quarterValues = {
1561
+ narrow: ['1', '2', '3', '4'],
1562
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1563
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1564
+ };
1565
+
1566
+ // Note: in English, the names of days of the week and months are capitalized.
1567
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1568
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1569
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1570
+ var monthValues = {
1571
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1572
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1573
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1574
+ };
1575
+ var dayValues = {
1576
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1577
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1578
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1579
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1580
+ };
1581
+ var dayPeriodValues = {
1582
+ narrow: {
1583
+ am: 'a',
1584
+ pm: 'p',
1585
+ midnight: 'mi',
1586
+ noon: 'n',
1587
+ morning: 'morning',
1588
+ afternoon: 'afternoon',
1589
+ evening: 'evening',
1590
+ night: 'night'
1591
+ },
1592
+ abbreviated: {
1593
+ am: 'AM',
1594
+ pm: 'PM',
1595
+ midnight: 'midnight',
1596
+ noon: 'noon',
1597
+ morning: 'morning',
1598
+ afternoon: 'afternoon',
1599
+ evening: 'evening',
1600
+ night: 'night'
1601
+ },
1602
+ wide: {
1603
+ am: 'a.m.',
1604
+ pm: 'p.m.',
1605
+ midnight: 'midnight',
1606
+ noon: 'noon',
1607
+ morning: 'morning',
1608
+ afternoon: 'afternoon',
1609
+ evening: 'evening',
1610
+ night: 'night'
1611
+ }
1612
+ };
1613
+ var formattingDayPeriodValues = {
1614
+ narrow: {
1615
+ am: 'a',
1616
+ pm: 'p',
1617
+ midnight: 'mi',
1618
+ noon: 'n',
1619
+ morning: 'in the morning',
1620
+ afternoon: 'in the afternoon',
1621
+ evening: 'in the evening',
1622
+ night: 'at night'
1623
+ },
1624
+ abbreviated: {
1625
+ am: 'AM',
1626
+ pm: 'PM',
1627
+ midnight: 'midnight',
1628
+ noon: 'noon',
1629
+ morning: 'in the morning',
1630
+ afternoon: 'in the afternoon',
1631
+ evening: 'in the evening',
1632
+ night: 'at night'
1633
+ },
1634
+ wide: {
1635
+ am: 'a.m.',
1636
+ pm: 'p.m.',
1637
+ midnight: 'midnight',
1638
+ noon: 'noon',
1639
+ morning: 'in the morning',
1640
+ afternoon: 'in the afternoon',
1641
+ evening: 'in the evening',
1642
+ night: 'at night'
1643
+ }
1644
+ };
1645
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1646
+ var number = Number(dirtyNumber);
1647
+
1648
+ // If ordinal numbers depend on context, for example,
1649
+ // if they are different for different grammatical genders,
1650
+ // use `options.unit`.
1651
+ //
1652
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1653
+ // 'day', 'hour', 'minute', 'second'.
1654
+
1655
+ var rem100 = number % 100;
1656
+ if (rem100 > 20 || rem100 < 10) {
1657
+ switch (rem100 % 10) {
1658
+ case 1:
1659
+ return number + 'st';
1660
+ case 2:
1661
+ return number + 'nd';
1662
+ case 3:
1663
+ return number + 'rd';
1664
+ }
1665
+ }
1666
+ return number + 'th';
1667
+ };
1668
+ var localize = {
1669
+ ordinalNumber: ordinalNumber,
1670
+ era: buildLocalizeFn({
1671
+ values: eraValues,
1672
+ defaultWidth: 'wide'
1673
+ }),
1674
+ quarter: buildLocalizeFn({
1675
+ values: quarterValues,
1676
+ defaultWidth: 'wide',
1677
+ argumentCallback: function argumentCallback(quarter) {
1678
+ return quarter - 1;
1679
+ }
1680
+ }),
1681
+ month: buildLocalizeFn({
1682
+ values: monthValues,
1683
+ defaultWidth: 'wide'
1684
+ }),
1685
+ day: buildLocalizeFn({
1686
+ values: dayValues,
1687
+ defaultWidth: 'wide'
1688
+ }),
1689
+ dayPeriod: buildLocalizeFn({
1690
+ values: dayPeriodValues,
1691
+ defaultWidth: 'wide',
1692
+ formattingValues: formattingDayPeriodValues,
1693
+ defaultFormattingWidth: 'wide'
1694
+ })
1695
+ };
1696
+ const localize$1 = localize;
1697
+
1698
+ function buildMatchFn(args) {
1699
+ return function (string) {
1700
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1701
+ var width = options.width;
1702
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1703
+ var matchResult = string.match(matchPattern);
1704
+ if (!matchResult) {
1705
+ return null;
1706
+ }
1707
+ var matchedString = matchResult[0];
1708
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1709
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1710
+ return pattern.test(matchedString);
1711
+ }) : findKey(parsePatterns, function (pattern) {
1712
+ return pattern.test(matchedString);
1713
+ });
1714
+ var value;
1715
+ value = args.valueCallback ? args.valueCallback(key) : key;
1716
+ value = options.valueCallback ? options.valueCallback(value) : value;
1717
+ var rest = string.slice(matchedString.length);
1718
+ return {
1719
+ value: value,
1720
+ rest: rest
1721
+ };
1722
+ };
1723
+ }
1724
+ function findKey(object, predicate) {
1725
+ for (var key in object) {
1726
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
1727
+ return key;
1728
+ }
1729
+ }
1730
+ return undefined;
1731
+ }
1732
+ function findIndex(array, predicate) {
1733
+ for (var key = 0; key < array.length; key++) {
1734
+ if (predicate(array[key])) {
1735
+ return key;
1736
+ }
1737
+ }
1738
+ return undefined;
1739
+ }
1740
+
1741
+ function buildMatchPatternFn(args) {
1742
+ return function (string) {
1743
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1744
+ var matchResult = string.match(args.matchPattern);
1745
+ if (!matchResult) return null;
1746
+ var matchedString = matchResult[0];
1747
+ var parseResult = string.match(args.parsePattern);
1748
+ if (!parseResult) return null;
1749
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1750
+ value = options.valueCallback ? options.valueCallback(value) : value;
1751
+ var rest = string.slice(matchedString.length);
1752
+ return {
1753
+ value: value,
1754
+ rest: rest
1755
+ };
1756
+ };
1757
+ }
1758
+
1759
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1760
+ var parseOrdinalNumberPattern = /\d+/i;
1761
+ var matchEraPatterns = {
1762
+ narrow: /^(b|a)/i,
1763
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1764
+ wide: /^(before christ|before common era|anno domini|common era)/i
1765
+ };
1766
+ var parseEraPatterns = {
1767
+ any: [/^b/i, /^(a|c)/i]
1768
+ };
1769
+ var matchQuarterPatterns = {
1770
+ narrow: /^[1234]/i,
1771
+ abbreviated: /^q[1234]/i,
1772
+ wide: /^[1234](th|st|nd|rd)? quarter/i
1773
+ };
1774
+ var parseQuarterPatterns = {
1775
+ any: [/1/i, /2/i, /3/i, /4/i]
1776
+ };
1777
+ var matchMonthPatterns = {
1778
+ narrow: /^[jfmasond]/i,
1779
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1780
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1781
+ };
1782
+ var parseMonthPatterns = {
1783
+ 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],
1784
+ 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]
1785
+ };
1786
+ var matchDayPatterns = {
1787
+ narrow: /^[smtwf]/i,
1788
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
1789
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1790
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1791
+ };
1792
+ var parseDayPatterns = {
1793
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1794
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1795
+ };
1796
+ var matchDayPeriodPatterns = {
1797
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1798
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1799
+ };
1800
+ var parseDayPeriodPatterns = {
1801
+ any: {
1802
+ am: /^a/i,
1803
+ pm: /^p/i,
1804
+ midnight: /^mi/i,
1805
+ noon: /^no/i,
1806
+ morning: /morning/i,
1807
+ afternoon: /afternoon/i,
1808
+ evening: /evening/i,
1809
+ night: /night/i
1810
+ }
1811
+ };
1812
+ var match = {
1813
+ ordinalNumber: buildMatchPatternFn({
1814
+ matchPattern: matchOrdinalNumberPattern,
1815
+ parsePattern: parseOrdinalNumberPattern,
1816
+ valueCallback: function valueCallback(value) {
1817
+ return parseInt(value, 10);
1818
+ }
1819
+ }),
1820
+ era: buildMatchFn({
1821
+ matchPatterns: matchEraPatterns,
1822
+ defaultMatchWidth: 'wide',
1823
+ parsePatterns: parseEraPatterns,
1824
+ defaultParseWidth: 'any'
1825
+ }),
1826
+ quarter: buildMatchFn({
1827
+ matchPatterns: matchQuarterPatterns,
1828
+ defaultMatchWidth: 'wide',
1829
+ parsePatterns: parseQuarterPatterns,
1830
+ defaultParseWidth: 'any',
1831
+ valueCallback: function valueCallback(index) {
1832
+ return index + 1;
1833
+ }
1834
+ }),
1835
+ month: buildMatchFn({
1836
+ matchPatterns: matchMonthPatterns,
1837
+ defaultMatchWidth: 'wide',
1838
+ parsePatterns: parseMonthPatterns,
1839
+ defaultParseWidth: 'any'
1840
+ }),
1841
+ day: buildMatchFn({
1842
+ matchPatterns: matchDayPatterns,
1843
+ defaultMatchWidth: 'wide',
1844
+ parsePatterns: parseDayPatterns,
1845
+ defaultParseWidth: 'any'
1846
+ }),
1847
+ dayPeriod: buildMatchFn({
1848
+ matchPatterns: matchDayPeriodPatterns,
1849
+ defaultMatchWidth: 'any',
1850
+ parsePatterns: parseDayPeriodPatterns,
1851
+ defaultParseWidth: 'any'
1852
+ })
1853
+ };
1854
+ const match$1 = match;
1855
+
1856
+ /**
1857
+ * @type {Locale}
1858
+ * @category Locales
1859
+ * @summary English locale (United States).
1860
+ * @language English
1861
+ * @iso-639-2 eng
1862
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1863
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1864
+ */
1865
+ var locale = {
1866
+ code: 'en-US',
1867
+ formatDistance: formatDistance$1,
1868
+ formatLong: formatLong$1,
1869
+ formatRelative: formatRelative$1,
1870
+ localize: localize$1,
1871
+ match: match$1,
1872
+ options: {
1873
+ weekStartsOn: 0 /* Sunday */,
1874
+ firstWeekContainsDate: 1
1875
+ }
1876
+ };
1877
+ const defaultLocale = locale;
1878
+
1879
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
1880
+ // (one of the certain letters followed by `o`)
1881
+ // - (\w)\1* matches any sequences of the same letter
1882
+ // - '' matches two quote characters in a row
1883
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
1884
+ // except a single quote symbol, which ends the sequence.
1885
+ // Two quote characters do not end the sequence.
1886
+ // If there is no matching single quote
1887
+ // then the sequence will continue until the end of the string.
1888
+ // - . matches any single character unmatched by previous parts of the RegExps
1889
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
1890
+
1891
+ // This RegExp catches symbols escaped by quotes, and also
1892
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
1893
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
1894
+ var escapedStringRegExp = /^'([^]*?)'?$/;
1895
+ var doubleQuoteRegExp = /''/g;
1896
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
1897
+
1898
+ /**
1899
+ * @name format
1900
+ * @category Common Helpers
1901
+ * @summary Format the date.
1902
+ *
1903
+ * @description
1904
+ * Return the formatted date string in the given format. The result may vary by locale.
1905
+ *
1906
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
1907
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
1908
+ *
1909
+ * The characters wrapped between two single quotes characters (') are escaped.
1910
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
1911
+ * (see the last example)
1912
+ *
1913
+ * Format of the string is based on Unicode Technical Standard #35:
1914
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
1915
+ * with a few additions (see note 7 below the table).
1916
+ *
1917
+ * Accepted patterns:
1918
+ * | Unit | Pattern | Result examples | Notes |
1919
+ * |---------------------------------|---------|-----------------------------------|-------|
1920
+ * | Era | G..GGG | AD, BC | |
1921
+ * | | GGGG | Anno Domini, Before Christ | 2 |
1922
+ * | | GGGGG | A, B | |
1923
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
1924
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
1925
+ * | | yy | 44, 01, 00, 17 | 5 |
1926
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
1927
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
1928
+ * | | yyyyy | ... | 3,5 |
1929
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
1930
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
1931
+ * | | YY | 44, 01, 00, 17 | 5,8 |
1932
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
1933
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
1934
+ * | | YYYYY | ... | 3,5 |
1935
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
1936
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
1937
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
1938
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
1939
+ * | | RRRRR | ... | 3,5,7 |
1940
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
1941
+ * | | uu | -43, 01, 1900, 2017 | 5 |
1942
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
1943
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
1944
+ * | | uuuuu | ... | 3,5 |
1945
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
1946
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
1947
+ * | | QQ | 01, 02, 03, 04 | |
1948
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
1949
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
1950
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
1951
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
1952
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
1953
+ * | | qq | 01, 02, 03, 04 | |
1954
+ * | | qqq | Q1, Q2, Q3, Q4 | |
1955
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
1956
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
1957
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
1958
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
1959
+ * | | MM | 01, 02, ..., 12 | |
1960
+ * | | MMM | Jan, Feb, ..., Dec | |
1961
+ * | | MMMM | January, February, ..., December | 2 |
1962
+ * | | MMMMM | J, F, ..., D | |
1963
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
1964
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
1965
+ * | | LL | 01, 02, ..., 12 | |
1966
+ * | | LLL | Jan, Feb, ..., Dec | |
1967
+ * | | LLLL | January, February, ..., December | 2 |
1968
+ * | | LLLLL | J, F, ..., D | |
1969
+ * | Local week of year | w | 1, 2, ..., 53 | |
1970
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
1971
+ * | | ww | 01, 02, ..., 53 | |
1972
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
1973
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
1974
+ * | | II | 01, 02, ..., 53 | 7 |
1975
+ * | Day of month | d | 1, 2, ..., 31 | |
1976
+ * | | do | 1st, 2nd, ..., 31st | 7 |
1977
+ * | | dd | 01, 02, ..., 31 | |
1978
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
1979
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
1980
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
1981
+ * | | DDD | 001, 002, ..., 365, 366 | |
1982
+ * | | DDDD | ... | 3 |
1983
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
1984
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
1985
+ * | | EEEEE | M, T, W, T, F, S, S | |
1986
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
1987
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
1988
+ * | | io | 1st, 2nd, ..., 7th | 7 |
1989
+ * | | ii | 01, 02, ..., 07 | 7 |
1990
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
1991
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
1992
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
1993
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
1994
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
1995
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
1996
+ * | | ee | 02, 03, ..., 01 | |
1997
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
1998
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
1999
+ * | | eeeee | M, T, W, T, F, S, S | |
2000
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2001
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2002
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
2003
+ * | | cc | 02, 03, ..., 01 | |
2004
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
2005
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2006
+ * | | ccccc | M, T, W, T, F, S, S | |
2007
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2008
+ * | AM, PM | a..aa | AM, PM | |
2009
+ * | | aaa | am, pm | |
2010
+ * | | aaaa | a.m., p.m. | 2 |
2011
+ * | | aaaaa | a, p | |
2012
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2013
+ * | | bbb | am, pm, noon, midnight | |
2014
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
2015
+ * | | bbbbb | a, p, n, mi | |
2016
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
2017
+ * | | BBBB | at night, in the morning, ... | 2 |
2018
+ * | | BBBBB | at night, in the morning, ... | |
2019
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2020
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2021
+ * | | hh | 01, 02, ..., 11, 12 | |
2022
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2023
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2024
+ * | | HH | 00, 01, 02, ..., 23 | |
2025
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2026
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2027
+ * | | KK | 01, 02, ..., 11, 00 | |
2028
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2029
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2030
+ * | | kk | 24, 01, 02, ..., 23 | |
2031
+ * | Minute | m | 0, 1, ..., 59 | |
2032
+ * | | mo | 0th, 1st, ..., 59th | 7 |
2033
+ * | | mm | 00, 01, ..., 59 | |
2034
+ * | Second | s | 0, 1, ..., 59 | |
2035
+ * | | so | 0th, 1st, ..., 59th | 7 |
2036
+ * | | ss | 00, 01, ..., 59 | |
2037
+ * | Fraction of second | S | 0, 1, ..., 9 | |
2038
+ * | | SS | 00, 01, ..., 99 | |
2039
+ * | | SSS | 000, 001, ..., 999 | |
2040
+ * | | SSSS | ... | 3 |
2041
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2042
+ * | | XX | -0800, +0530, Z | |
2043
+ * | | XXX | -08:00, +05:30, Z | |
2044
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2045
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2046
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2047
+ * | | xx | -0800, +0530, +0000 | |
2048
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
2049
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
2050
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2051
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2052
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2053
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2054
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2055
+ * | Seconds timestamp | t | 512969520 | 7 |
2056
+ * | | tt | ... | 3,7 |
2057
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
2058
+ * | | TT | ... | 3,7 |
2059
+ * | Long localized date | P | 04/29/1453 | 7 |
2060
+ * | | PP | Apr 29, 1453 | 7 |
2061
+ * | | PPP | April 29th, 1453 | 7 |
2062
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2063
+ * | Long localized time | p | 12:00 AM | 7 |
2064
+ * | | pp | 12:00:00 AM | 7 |
2065
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
2066
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2067
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2068
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2069
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
2070
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2071
+ * Notes:
2072
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2073
+ * are the same as "stand-alone" units, but are different in some languages.
2074
+ * "Formatting" units are declined according to the rules of the language
2075
+ * in the context of a date. "Stand-alone" units are always nominative singular:
2076
+ *
2077
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2078
+ *
2079
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2080
+ *
2081
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2082
+ * the single quote characters (see below).
2083
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2084
+ * the output will be the same as default pattern for this unit, usually
2085
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2086
+ * are marked with "2" in the last column of the table.
2087
+ *
2088
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2089
+ *
2090
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2091
+ *
2092
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2093
+ *
2094
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2095
+ *
2096
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2097
+ *
2098
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2099
+ * The output will be padded with zeros to match the length of the pattern.
2100
+ *
2101
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2102
+ *
2103
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2104
+ * These tokens represent the shortest form of the quarter.
2105
+ *
2106
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
2107
+ *
2108
+ * | Year | `y` | `u` |
2109
+ * |------|-----|-----|
2110
+ * | AC 1 | 1 | 1 |
2111
+ * | BC 1 | 1 | 0 |
2112
+ * | BC 2 | 2 | -1 |
2113
+ *
2114
+ * Also `yy` always returns the last two digits of a year,
2115
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2116
+ *
2117
+ * | Year | `yy` | `uu` |
2118
+ * |------|------|------|
2119
+ * | 1 | 01 | 01 |
2120
+ * | 14 | 14 | 14 |
2121
+ * | 376 | 76 | 376 |
2122
+ * | 1453 | 53 | 1453 |
2123
+ *
2124
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2125
+ * except local week-numbering years are dependent on `options.weekStartsOn`
2126
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2127
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2128
+ *
2129
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2130
+ * so right now these tokens fall back to GMT timezones.
2131
+ *
2132
+ * 7. These patterns are not in the Unicode Technical Standard #35:
2133
+ * - `i`: ISO day of week
2134
+ * - `I`: ISO week of year
2135
+ * - `R`: ISO week-numbering year
2136
+ * - `t`: seconds timestamp
2137
+ * - `T`: milliseconds timestamp
2138
+ * - `o`: ordinal number modifier
2139
+ * - `P`: long localized date
2140
+ * - `p`: long localized time
2141
+ *
2142
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2143
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2144
+ *
2145
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2146
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2147
+ *
2148
+ * @param {Date|Number} date - the original date
2149
+ * @param {String} format - the string of tokens
2150
+ * @param {Object} [options] - an object with options.
2151
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2152
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2153
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2154
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2155
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2156
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2157
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2158
+ * @returns {String} the formatted date string
2159
+ * @throws {TypeError} 2 arguments required
2160
+ * @throws {RangeError} `date` must not be Invalid Date
2161
+ * @throws {RangeError} `options.locale` must contain `localize` property
2162
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
2163
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2164
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2165
+ * @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
2166
+ * @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
2167
+ * @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
2168
+ * @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
2169
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
2170
+ *
2171
+ * @example
2172
+ * // Represent 11 February 2014 in middle-endian format:
2173
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2174
+ * //=> '02/11/2014'
2175
+ *
2176
+ * @example
2177
+ * // Represent 2 July 2014 in Esperanto:
2178
+ * import { eoLocale } from 'date-fns/locale/eo'
2179
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2180
+ * locale: eoLocale
2181
+ * })
2182
+ * //=> '2-a de julio 2014'
2183
+ *
2184
+ * @example
2185
+ * // Escape string by single quote characters:
2186
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2187
+ * //=> "3 o'clock"
2188
+ */
2189
+
2190
+ function format(dirtyDate, dirtyFormatStr, options) {
2191
+ 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;
2192
+ requiredArgs(2, arguments);
2193
+ var formatStr = String(dirtyFormatStr);
2194
+ var defaultOptions = getDefaultOptions();
2195
+ var locale = (_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 : defaultLocale;
2196
+ 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);
2197
+
2198
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2199
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2200
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2201
+ }
2202
+ 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);
2203
+
2204
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2205
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2206
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2207
+ }
2208
+ if (!locale.localize) {
2209
+ throw new RangeError('locale must contain localize property');
2210
+ }
2211
+ if (!locale.formatLong) {
2212
+ throw new RangeError('locale must contain formatLong property');
2213
+ }
2214
+ var originalDate = toDate(dirtyDate);
2215
+ if (!isValid(originalDate)) {
2216
+ throw new RangeError('Invalid time value');
2217
+ }
2218
+
2219
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2220
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2221
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2222
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2223
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
2224
+ var formatterOptions = {
2225
+ firstWeekContainsDate: firstWeekContainsDate,
2226
+ weekStartsOn: weekStartsOn,
2227
+ locale: locale,
2228
+ _originalDate: originalDate
2229
+ };
2230
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2231
+ var firstCharacter = substring[0];
2232
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
2233
+ var longFormatter = longFormatters$1[firstCharacter];
2234
+ return longFormatter(substring, locale.formatLong);
2235
+ }
2236
+ return substring;
2237
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
2238
+ // Replace two single quote characters with one single quote character
2239
+ if (substring === "''") {
2240
+ return "'";
2241
+ }
2242
+ var firstCharacter = substring[0];
2243
+ if (firstCharacter === "'") {
2244
+ return cleanEscapedString(substring);
2245
+ }
2246
+ var formatter = formatters$1[firstCharacter];
2247
+ if (formatter) {
2248
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2249
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2250
+ }
2251
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2252
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2253
+ }
2254
+ return formatter(utcDate, substring, locale.localize, formatterOptions);
2255
+ }
2256
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2257
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2258
+ }
2259
+ return substring;
2260
+ }).join('');
2261
+ return result;
2262
+ }
2263
+ function cleanEscapedString(input) {
2264
+ var matched = input.match(escapedStringRegExp);
2265
+ if (!matched) {
2266
+ return input;
2267
+ }
2268
+ return matched[1].replace(doubleQuoteRegExp, "'");
2269
+ }
2270
+
2271
+ const getHistoryLoaderTemplate = (lang) => {
2272
+ return index.h("div", { class: "HistoryLoader" },
2273
+ index.h("casino-engagement-suite-progress-bar", { indeterminate: true }),
2274
+ index.h("span", null, translate('loading', lang)));
2275
+ };
2276
+ const getRewards = (luckywheel, result) => {
2277
+ var _a, _b, _c, _d;
2278
+ const index$1 = result.wheelOfFortunePartitionIndex || 0;
2279
+ const name = (_b = (_a = luckywheel.program.wheelOfFortune) === null || _a === void 0 ? void 0 : _a.partitions[index$1]) === null || _b === void 0 ? void 0 : _b.name;
2280
+ const displayName = name['en'] || name['*'];
2281
+ const assets = (_d = (_c = luckywheel.program.wheelOfFortune) === null || _c === void 0 ? void 0 : _c.partitions[index$1]) === null || _d === void 0 ? void 0 : _d.image1;
2282
+ const displayAssets = assets['en'] || assets['*'];
2283
+ const programName = luckywheel.program.name['en'] || luckywheel.program.name['*'];
2284
+ return index.h("div", { class: "HistoryRewards" }, displayName ? displayName : displayAssets ? (index.h("img", { src: displayAssets })) : programName);
2285
+ };
2286
+ const getStatus = (state) => {
2287
+ return state === 'fulfilled' ? 'Success' : 'Failed';
2288
+ };
2289
+ const getLuckyWheelsHistoryTemplate = (luckywheels, historyGroups, openedHistoryIds, toggleLuckyWheelHistory, lang) => {
2290
+ if (luckywheels.length === 0) {
2291
+ return index.h("p", { class: "HistoryEmptyMessage" }, translate('noHistory', lang));
2292
+ }
2293
+ return index.h("div", { class: "HistoryList" }, luckywheels.map((luckywheel) => {
2294
+ return index.h("div", { key: luckywheel.program.id, class: `HistoryListItem ${openedHistoryIds.includes(luckywheel.program.id) ? 'Opened' : 'Closed'}` },
2295
+ index.h("header", { class: "HistoryListItemHeader", "data-id": luckywheel.program.id, onClick: toggleLuckyWheelHistory },
2296
+ luckywheel.program.name['en'] || luckywheel.program.name['*'],
2297
+ index.h("button", { class: "EngagementSuiteIconButton ArrowDown" })),
2298
+ index.h("div", { class: "HistoryListItemBody" },
2299
+ index.h("div", { class: "HistoryInfoRow" }, Object.entries(historyGroups).map((histories) => {
2300
+ return histories[0] === luckywheel.program.id && histories[1].map((history) => {
2301
+ return index.h("div", { class: "HistoryInfo" },
2302
+ index.h("div", { class: "HistoryCol Rewards" }, getRewards(luckywheel, history.draw.result)),
2303
+ index.h("div", { class: "HistoryCol Issued" }, getStatus(history.draw.state)),
2304
+ index.h("div", { class: "HistoryCol Time" }, format(new Date(history.draw.time), 'LLL d, yyyy HH:mm:ss')));
2305
+ });
2306
+ }))));
2307
+ }));
2308
+ };
2309
+
2310
+ const casinoEngagementSuiteLuckywheelListCss = ":host{display:block;font-family:inherit}*{box-sizing:border-box;margin:0;padding:0}button{border:none;background:none;cursor:pointer}button:focus{outline:none}.EngagementSuiteIconButton{width:16px;height:16px}.EngagementSuiteIconButton.Help{background:center/100% url(https://static.everymatrix.com/gic/img/engagement-suite/help.svg) no-repeat}.EngagementSuiteIconButton.Close{background:center/100% url(https://static.everymatrix.com/gic/img/engagement-suite/close.svg) no-repeat}.EngagementSuiteIconButton.ArrowDown{background:center/100% url(https://static.everymatrix.com/gic/img/engagement-suite/arrow-down.svg) no-repeat}.LuckyWheelsListPopup{display:flex;height:100%;background-color:var(--emw--color-background, #1e1638);border-radius:var(--emw--border-radius-large, 8px);overflow:hidden;flex-direction:column;position:relative;padding-bottom:20px}.LuckyWheelsListPopupHeader{display:flex;justify-content:space-between;align-items:center;padding:12px 8px 8px}.LuckyWheelsListPopupHeaderName{color:var(--emw--color-secondary, #bbb9c3);font-size:var(--emw--font-size-small, 14px);font-weight:var(--emw--font-weight-medium, 500);line-height:14px}.LuckyWheelsListWrapper{overflow-y:auto;-ms-overflow-style:none;scrollbar-width:none}.LuckyWheelsListWrapper::-webkit-scrollbar{display:none}.LuckyWheelsList{display:flex;flex-direction:column;row-gap:12px;padding:8px 19px 0}.LuckyWheelsRowWrapper{display:flex;justify-content:space-between;min-width:0}.LuckyWheelsCard{padding:15px 15px 19px;border:1px solid var(--emw--button-border-color, #403956);border-radius:var(--emw--border-radius-medium, 6px);position:relative;cursor:pointer}.LuckyWheelsCard.Forfeited{cursor:auto;pointer-events:none}.LuckyWheelsCardHeader{display:flex;justify-content:space-between;gap:24px;margin-bottom:12px;flex:1;min-width:0;align-items:flex-end}.LuckyWheelsName{color:var(--emw--color-typography, #ffffff);font-family:var(--emw--font-family-secondary, \"Montserrat\", sans-serif);line-height:22px;font-weight:var(--emw--font-weight-bold, 700);font-size:var(--emw--font-size-medium-plus, 18px);word-break:break-word;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.LuckyWheelsCounter{display:flex;color:var(--emw--color-secondary, #bbb9c3);font-size:var(--emw--font-size-medium-plus, 18px);align-items:flex-end}.LuckyWheelsHighlightedCounter,.LuckyWheelsEmptyCounter{font-size:var(--emw--font-size-medium-plus, 18px);font-weight:var(--emw--font-weight-extra-bold, 800);margin-right:4px}.LuckyWheelsHighlightedCounter{background:var(--emw--engagement-suite-gradient-golden, linear-gradient(180deg, #ffb801 15.86%, #fef746 31.36%, #fbffe0 36.86%, #fffa60 47.86%, #ff9400 87.36%));-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}.LuckyWheelsEmptyCounter{color:var(--emw--color-gray-150, #8f8b9c)}.LuckyWheelsListEmpty{padding:20px 32px}.LuckyWheelsListEmpty h2{margin:0 0 16px 0;text-align:center;font-weight:var(--emw--font-weight-semibold, 600);font-size:var(--emw--font-size-large, 20px);line-height:24px;font-family:var(--emw--font-family-secondary, \"Montserrat\", sans-serif);color:var(--emw--color-typography, #ffffff)}.LuckyWheelsListEmpty p{font-size:var(--emw--font-size-small, 14px);line-height:17px;color:var(--emw--color-secondary, #bbb9c3)}.LuckyWheelsCountdownWrapper{display:flex;justify-content:space-between;align-items:flex-start}.LuckyWheelsCountdown,.ForfeitedMessage{color:var(--emw--color-secondary, #bbb9c3);font-size:var(--emw--font-size-x-small, 12px);line-height:12px}.ForfeitedMessage{line-height:1.2}.LuckyWheelsBalCounter{display:flex;align-items:flex-end;color:var(--emw--color-secondary, #bbb9c3);font-size:var(--emw--font-size-x-small, 12px)}.LuckyWheelsRemainCounter{color:var(--emw--color-typography, #ffffff);font-weight:var(--emw--font-weight-bold, 700);margin-right:4px}.LuckyWheelLabel{min-width:35px;height:18px;background:var(--emw--engagement-suite-gradient-golden, linear-gradient(180deg, #ffb801 15.86%, #fef746 31.36%, #fbffe0 36.86%, #fffa60 47.86%, #ff9400 87.36%));border-radius:var(--emw--border-radius-x-small, 2px);display:none;position:absolute;top:-11px;right:11px;padding:0 2px;align-items:center;justify-content:center}.LuckyWheelLabel span{display:inline-block;text-transform:uppercase;font-size:var(--emw--font-size-2x-small, 10px);line-height:10px;font-weight:var(--emw--font-weight-bold, 700);font-family:var(--emw--font-family-secondary, \"Montserrat\", sans-serif);color:var(--emw--color-background, #1e1638)}.ShowLuckyWheelLabel{display:inline-flex}.EngagementSuiteTooltipBackdrop{padding:48px 30px 0;position:absolute;width:100%;height:100%;inset:0;background-color:rgba(0, 0, 0, 0.5)}.EngagementSuiteTooltipBackdrop .EngagementSuiteTooltip{border:1px solid var(--emw--button-border-color, #403956);background-color:var(--emw--color-background, #1e1638);border-radius:var(--emw--border-radius-large, 8px);padding:32px;font-size:var(--emw--font-size-small, 14px);line-height:17px;color:var(--emw--color-secondary, #bbb9c3);position:relative}.EngagementSuiteTooltipBackdrop .EngagementSuiteTooltip .EngagementSuiteIconButton{top:12px;right:12px;position:absolute}.LuckyWheelsEmptyNumber .LuckyWheelsName,.LuckyWheelsEmptyNumber .LuckyWheelsCountdown,.LuckyWheelsEmptyNumber .LuckyWheelsRemainCounter{color:var(--emw--color-gray-150, #8f8b9c)}.LuckyWheelsListPopup.Tablet .LuckyWheelsListPopupHeader,.LuckyWheelsListPopup.Desktop .LuckyWheelsListPopupHeader{padding-top:16px}.LuckyWheelsListPopup.Tablet .LuckyWheelsListPopupHeaderName,.LuckyWheelsListPopup.Desktop .LuckyWheelsListPopupHeaderName{font-size:var(--emw--font-size-medium, 16px);line-height:16px}.LuckyWheelsListPopup.Tablet .EngagementSuiteIconButton,.LuckyWheelsListPopup.Desktop .EngagementSuiteIconButton{width:24px;height:24px}.LuckyWheelsListPopup.Tablet .LuckyWheelsList,.LuckyWheelsListPopup.Desktop .LuckyWheelsList{padding:20px 24px 0;row-gap:20px}.LuckyWheelsListPopup.Tablet .LuckyWheelCardHeader,.LuckyWheelsListPopup.Desktop .LuckyWheelCardHeader{margin-bottom:16px}.LuckyWheelsListPopup.Tablet .LuckyWheelsName,.LuckyWheelsListPopup.Desktop .LuckyWheelsName{line-height:27px;font-size:var(--emw--font-size-large, 22px)}.LuckyWheelsListPopup.Tablet .LuckyWheelsCountdown,.LuckyWheelsListPopup.Desktop .LuckyWheelsCountdown{font-size:var(--emw--font-size-small, 14px);line-height:14px}.LuckyWheelsListPopup.Tablet .EngagementSuiteTooltipBackdrop,.LuckyWheelsListPopup.Desktop .EngagementSuiteTooltipBackdrop{padding:90px 75px 0}.LuckyWheelsListPopup.Tablet .EngagementSuiteTooltip,.LuckyWheelsListPopup.Desktop .EngagementSuiteTooltip{padding:60px 65px;font-size:var(--emw--font-size-medium, 16px);line-height:20px}.LuckyWheelsListPopup.Tablet .EngagementSuiteTooltip .EngagementSuiteIconButton,.LuckyWheelsListPopup.Desktop .EngagementSuiteTooltip .EngagementSuiteIconButton{top:24px;right:24px}.LuckyWheelsListPopup.Tablet .EngagementSuiteTabsWrapper .EngagementSuiteTabs .EngagementSuiteTab,.LuckyWheelsListPopup.Desktop .EngagementSuiteTabsWrapper .EngagementSuiteTabs .EngagementSuiteTab{font-size:var(--emw--font-size-medium, 16px)}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryCols,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryCols{font-size:var(--emw--font-size-medium, 16px)}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryCols .Rewards,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryCols .Rewards{flex-basis:140px}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryCols .Issued,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryCols .Issued{flex-basis:100px}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryListItem .HistoryListItemHeader,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryListItem .HistoryListItemHeader{font-size:var(--emw--font-size-large, 22px)}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryListItem .HistoryInfo,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryListItem .HistoryInfo{font-size:var(--emw--font-size-medium, 16px)}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryListItem .HistoryInfo .Rewards,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryListItem .HistoryInfo .Rewards{flex-basis:140px}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryListItem .HistoryInfo .Issued,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryListItem .HistoryInfo .Issued{flex-basis:100px}.EngagementSuiteTabsWrapper{padding:0 24px;margin:8px 0}.EngagementSuiteTabsWrapper .EngagementSuiteTabs{display:flex;position:relative;border-bottom:2px solid var(--emw--color-secondary, #666178)}.EngagementSuiteTabsWrapper .EngagementSuiteTabs .EngagementSuiteTab{padding:9px 16px 7px;font-weight:var(--emw--font-weight-medium, 500);font-size:var(--emw--font-size-x-small, 12px);line-height:15px;color:var(--emw--color-gray-300, #666178);cursor:pointer}.EngagementSuiteTabsWrapper .EngagementSuiteTabs .EngagementSuiteTab.Active{color:var(--emw--color-typography, #fff);border-bottom:2px solid var(--emw--color-typography, #fff);margin-bottom:-2px}.HistoryWrapper{padding:0 24px;display:flex;flex-direction:column;height:100%;overflow:hidden}.HistoryWrapper .HistoryEmptyMessage{margin-top:8px;font-size:var(--emw--font-size-small, 14px);color:var(--emw--color-secondary, #bbb9c3);line-height:30px}.HistoryWrapper .HistoryCols{padding:12px 10px;position:relative;display:flex;border-bottom:1px solid var(--emw--color-secondary, #666178);font-size:var(--emw--font-size-x-small, 12px)}.HistoryWrapper .HistoryCols .HistoryColName{color:var(--emw--color-secondary, #bbb9c3)}.HistoryWrapper .HistoryCols .Rewards{flex-basis:80px}.HistoryWrapper .HistoryCols .Issued{flex-basis:80px}.HistoryWrapper .HistoryLoader{display:flex;flex-direction:column;justify-content:center;align-items:center;height:inherit;font-size:var(--emw--font-size-medium, 16px);color:var(--emw--color-gray-150, #8f8b9c)}.HistoryWrapper .HistoryLoader casino-engagement-suite-progress-bar{margin-bottom:8px;width:100px}.HistoryWrapper .HistoryListItem{margin-top:8px}.HistoryWrapper .HistoryListItem.Opened .EngagementSuiteIconButton.ArrowDown{transform:rotate(180deg)}.HistoryWrapper .HistoryListItem.Opened .HistoryListItemBody{padding-bottom:8px;grid-template-rows:1fr;border-bottom:1px solid var(--emw--color-secondary, #666178)}.HistoryWrapper .HistoryListItem .HistoryListItemHeader{padding:16px 0;display:flex;justify-content:space-between;align-items:center;color:var(--emw--color-typography, #ffffff);font-size:var(--emw--font-size-medium, 14px)}.HistoryWrapper .HistoryListItem .EngagementSuiteIconButton.ArrowDown{transition:transform 0.3s ease-out;width:24px;height:24px}.HistoryWrapper .HistoryListItem .HistoryListItemBody{position:relative;display:grid;grid-template-rows:0fr;transition:grid-template-rows 0.3s ease-out}.HistoryWrapper .HistoryListItem .HistoryListItemBody>div{overflow:hidden}.HistoryWrapper .HistoryListItem .HistoryListItemCard{padding:12px 5px}.HistoryWrapper .HistoryListItem .HistoryInfoRow{display:flex;gap:10px;flex-direction:column}.HistoryWrapper .HistoryListItem .HistoryInfo{display:flex;padding:10px;font-size:var(--emw--font-size-x-small, 12px);color:var(--emw--color-secondary, #bbb9c3)}.HistoryWrapper .HistoryListItem .HistoryInfo .HistoryCol{text-overflow:ellipsis;overflow:hidden}.HistoryWrapper .HistoryListItem .HistoryInfo .Rewards{color:var(--emw--color-typography, #ffffff);flex-basis:80px;font-weight:600}.HistoryWrapper .HistoryListItem .HistoryInfo .Issued{flex-basis:80px}";
2311
+ const CasinoEngagementSuiteLuckywheelListStyle0 = casinoEngagementSuiteLuckywheelListCss;
2312
+
2313
+ const CasinoEngagementSuiteLuckyWheelList = class {
2314
+ constructor(hostRef) {
2315
+ index.registerInstance(this, hostRef);
2316
+ this.close = index.createEvent(this, "close", 7);
2317
+ this.setClientStyling = () => {
2318
+ let sheet = document.createElement('style');
2319
+ sheet.innerHTML = this.clientStyling;
2320
+ this.host.prepend(sheet);
2321
+ };
2322
+ this.setClientStylingURL = () => {
2323
+ let url = new URL(this.clientStylingUrl);
2324
+ let cssFile = document.createElement('style');
2325
+ fetch(url.href)
2326
+ .then((res) => res.text())
2327
+ .then((data) => {
2328
+ cssFile.innerHTML = data;
2329
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
2330
+ })
2331
+ .catch((err) => {
2332
+ console.log('Error ', err);
2333
+ });
2334
+ };
2335
+ this.handleCloseClick = () => {
2336
+ this.close.emit();
2337
+ this.tooltip = false;
2338
+ };
2339
+ this.handleLuckyWheelClick = (ev) => {
2340
+ const id = ev.currentTarget.getAttribute('data-id');
2341
+ const index = ev.currentTarget.getAttribute('data-index');
2342
+ window.postMessage({ type: 'LuckyWheelClick', id, index });
2343
+ };
2344
+ this.showTooltip = () => {
2345
+ this.tooltip = true;
2346
+ };
2347
+ this.hideTooltip = () => {
2348
+ this.tooltip = false;
2349
+ };
2350
+ this.handleTabChange = (e) => {
2351
+ this.activeTab = +(e.target.getAttribute('data-index'));
2352
+ if (this.activeTab === 2) {
2353
+ if (!this.historyLoaded) {
2354
+ this.sendHistoryRequest();
2355
+ }
2356
+ }
2357
+ };
2358
+ this.toggleLuckyWheelHistory = (ev) => {
2359
+ const id = ev.currentTarget.getAttribute('data-id');
2360
+ const index = this.openedHistoryIds.findIndex(historyId => historyId === id);
2361
+ if (index > -1) {
2362
+ this.openedHistoryIds = this.openedHistoryIds.filter((historyId) => historyId !== id);
2363
+ }
2364
+ else {
2365
+ this.openedHistoryIds.push(id);
2366
+ }
2367
+ this.openedHistoryIds = [...this.openedHistoryIds];
2368
+ };
2369
+ this.clientStyling = '';
2370
+ this.clientStylingUrl = '';
2371
+ this.language = 'en';
2372
+ this.device = 'Mobile';
2373
+ this.luckywheels = [];
2374
+ this.endpoint = undefined;
2375
+ this.session = undefined;
2376
+ this.translationUrl = '';
2377
+ this.tooltip = false;
2378
+ this.timers = {};
2379
+ this.limitStylingAppends = false;
2380
+ this.activeTab = 1;
2381
+ this.historyLoading = false;
2382
+ this.luckywheelHistory = {};
2383
+ this.openedHistoryIds = [];
2384
+ this.historyLoaded = false;
2385
+ this.isLoading = false;
2386
+ }
2387
+ handleEvent(e) {
2388
+ const { type } = e === null || e === void 0 ? void 0 : e.data;
2389
+ if (type === 'BarLuckyWheelsClick') {
2390
+ this.activeTab = 1;
2391
+ this.openedHistoryIds = [];
2392
+ }
2393
+ }
2394
+ luckywheelsPropHandler(value) {
2395
+ if (!this.interval && value.length) {
2396
+ this.updateTimers();
2397
+ this.startCountdown();
2398
+ }
2399
+ if (this.interval && !value.length) {
2400
+ clearInterval(this.interval);
2401
+ }
2402
+ }
2403
+ componentWillLoad() {
2404
+ const promises = [];
2405
+ this.luckywheels = [];
2406
+ if (this.endpoint) {
2407
+ const consentsPromise = this.getLuckyWheels();
2408
+ promises.push(consentsPromise);
2409
+ }
2410
+ if (this.translationUrl) {
2411
+ const translationPromise = getTranslations(this.translationUrl);
2412
+ promises.push(translationPromise);
2413
+ }
2414
+ return Promise.all(promises);
2415
+ }
2416
+ getLuckyWheels() {
2417
+ let url = new URL(this.endpoint + `/v1/wof/lotteries`);
2418
+ let reqHeaders = new Headers();
2419
+ url.searchParams.append('language', this.language);
2420
+ if (this.session) {
2421
+ reqHeaders.append('X-SessionId', this.session);
2422
+ }
2423
+ let requestOptions = {
2424
+ method: 'GET',
2425
+ headers: reqHeaders,
2426
+ };
2427
+ this.isLoading = true;
2428
+ fetch(url.href, requestOptions).then((res) => res.json()).then((res) => {
2429
+ this.luckywheels = res.items;
2430
+ }).catch((err) => {
2431
+ throw new Error(err);
2432
+ }).finally(() => {
2433
+ this.isLoading = false;
2434
+ });
2435
+ }
2436
+ getLuckyWheelsHistory(luckywheelId) {
2437
+ let url = new URL(this.endpoint + `/v1/wof/outcome/${luckywheelId}`);
2438
+ let reqHeaders = new Headers();
2439
+ url.searchParams.append('language', this.language);
2440
+ if (this.session) {
2441
+ reqHeaders.append('X-SessionId', this.session);
2442
+ }
2443
+ let requestOptions = {
2444
+ method: 'GET',
2445
+ headers: reqHeaders,
2446
+ };
2447
+ return fetch(url.href, requestOptions).then((res) => res.json());
2448
+ }
2449
+ componentDidRender() {
2450
+ if (!this.limitStylingAppends && this.host) {
2451
+ if (this.clientStyling)
2452
+ this.setClientStyling();
2453
+ if (this.clientStylingUrl)
2454
+ this.setClientStylingURL();
2455
+ this.limitStylingAppends = true;
2456
+ }
2457
+ }
2458
+ disconnectedCallback() {
2459
+ this.interval && clearInterval(this.interval);
2460
+ }
2461
+ startCountdown() {
2462
+ this.interval = setInterval(() => {
2463
+ this.updateTimers();
2464
+ }, 1000);
2465
+ }
2466
+ updateTimers() {
2467
+ const now = new Date().getTime();
2468
+ this.timers = this.luckywheels.reduce((acc, luckywheel) => {
2469
+ var _a;
2470
+ const expirationDate = new Date((_a = luckywheel.current) === null || _a === void 0 ? void 0 : _a.endTime).getTime();
2471
+ const diff = expirationDate - now;
2472
+ let countdown = '00h:00m:00s';
2473
+ if (diff < 1) {
2474
+ this.removeLuckyWheel(luckywheel.program.id);
2475
+ }
2476
+ else {
2477
+ const { days, hours, minutes, seconds } = {
2478
+ days: String(Math.floor(diff / (1000 * 60 * 60 * 24))).padStart(2, '0'),
2479
+ hours: String(Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, '0'),
2480
+ minutes: String(Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0'),
2481
+ seconds: String(Math.floor((diff % (1000 * 60)) / 1000)).padStart(2, '0')
2482
+ };
2483
+ countdown = days === '00'
2484
+ ? `${hours}h:${minutes}m:${seconds}s`
2485
+ : `${days}d:${hours}h:${minutes}m`;
2486
+ }
2487
+ return Object.assign(Object.assign({}, acc), { [luckywheel.program.id]: countdown });
2488
+ }, {});
2489
+ }
2490
+ removeLuckyWheel(id) {
2491
+ this.luckywheels = this.luckywheels.filter((luckywheel) => luckywheel.program.id !== id);
2492
+ window.postMessage({ type: 'LuckyWheelHasExpired', id });
2493
+ }
2494
+ async sendHistoryRequest() {
2495
+ this.historyLoading = true;
2496
+ if (!this.luckywheels.length) {
2497
+ return;
2498
+ }
2499
+ const promises = [];
2500
+ this.luckywheels.forEach(async (luckywheel) => {
2501
+ promises.push(this.getLuckyWheelsHistory(luckywheel.program.id).then(res => {
2502
+ this.luckywheelHistory[luckywheel.program.id] = res.items;
2503
+ }));
2504
+ });
2505
+ await Promise.all(promises);
2506
+ this.historyLoading = false;
2507
+ this.historyLoaded = true;
2508
+ }
2509
+ getLuckyWheelClasses(luckyWheel) {
2510
+ return {
2511
+ LuckyWheelsCard: true,
2512
+ LuckyWheelsEmptyNumber: luckyWheel.current.remainingTimes === 0
2513
+ };
2514
+ }
2515
+ getLuckyWheelName(luckywheel) {
2516
+ var _a, _b;
2517
+ return ((_a = luckywheel.program) === null || _a === void 0 ? void 0 : _a.name['en']) || ((_b = luckywheel.program) === null || _b === void 0 ? void 0 : _b.name['*']);
2518
+ }
2519
+ getLuckyWheelHeaderTemplate(luckywheel) {
2520
+ var _a, _b;
2521
+ return (index.h("div", { class: "LuckyWheelsCardHeader" }, index.h("div", { class: `LuckyWheelsName` }, this.getLuckyWheelName(luckywheel)), (index.h("div", { class: "LuckyWheelsCounter" }, index.h("div", { class: `${((_a = luckywheel.current) === null || _a === void 0 ? void 0 : _a.remainingTimes) ? 'LuckyWheelsHighlightedCounter' : 'LuckyWheelsEmptyCounter'}` }, (_b = luckywheel.current) === null || _b === void 0 ? void 0 : _b.remainingTimes)))));
2522
+ }
2523
+ getLuckyWheelTemplate(luckywheel, index$1) {
2524
+ const countdown = this.timers[luckywheel.program.id];
2525
+ //TODO: canceled status
2526
+ const isCanceled = luckywheel.current.remainingTimes === 0;
2527
+ return (index.h("div", { class: this.getLuckyWheelClasses(luckywheel), onClick: this.handleLuckyWheelClick, key: luckywheel.program.id, "data-id": luckywheel.program.id, "data-index": index$1 }, this.getLuckyWheelHeaderTemplate(luckywheel), isCanceled ? (index.h("div", { class: "ForfeitedMessage" }, index.h("div", null, translate('canceled', this.language)), index.h("div", null, translate('support', this.language)))) : (index.h("div", { class: "LuckyWheelsCountdownWrapper" }, index.h("span", { class: "LuckyWheelsCountdown" }, countdown)))));
2528
+ }
2529
+ getHeaderTemplate() {
2530
+ return index.h("header", { class: "LuckyWheelsListPopupHeader" }, index.h("button", { onClick: this.showTooltip, class: "EngagementSuiteIconButton Help" }), index.h("div", { class: "LuckyWheelsListPopupHeaderName" }, translate('luckyWheel', this.language)), index.h("button", { class: "EngagementSuiteIconButton Close", onClick: this.handleCloseClick }));
2531
+ }
2532
+ getListTemplate() {
2533
+ if (this.isLoading) {
2534
+ return index.h("general-animation-loading", null);
2535
+ }
2536
+ if (this.luckywheels.length) {
2537
+ return index.h("div", { class: "LuckyWheelsListWrapper" }, index.h("div", { class: "LuckyWheelsList" }, this.luckywheels.map((luckywheel, index) => this.getLuckyWheelTemplate(luckywheel, index))));
2538
+ }
2539
+ else {
2540
+ return index.h("div", { class: "LuckyWheelsListEmpty" }, index.h("h2", null, translate('noluckywheels', this.language)), index.h("p", null, translate('tryOtherGames', this.language)));
2541
+ }
2542
+ }
2543
+ getTooltipTemplate() {
2544
+ if (this.tooltip) {
2545
+ return index.h("div", { class: "EngagementSuiteTooltipBackdrop" }, index.h("div", { class: "EngagementSuiteTooltip" }, index.h("button", { class: "EngagementSuiteIconButton Close", onClick: this.hideTooltip }), translate('tooltip', this.language)));
2546
+ }
2547
+ else {
2548
+ return '';
2549
+ }
2550
+ }
2551
+ getTabsTemplate() {
2552
+ return index.h("div", { class: "EngagementSuiteTabsWrapper" }, index.h("div", { class: "EngagementSuiteTabs" }, index.h("div", { "data-index": "1", onClick: this.handleTabChange, class: `EngagementSuiteTab ${this.activeTab === 1 ? 'Active' : ''}` }, translate('luckywheels', this.language)), index.h("div", { "data-index": "2", onClick: this.handleTabChange, class: `EngagementSuiteTab ${this.activeTab === 2 ? 'Active' : ''}` }, translate('history', this.language))));
2553
+ }
2554
+ getHistoryTabTemplate() {
2555
+ return index.h("div", { class: "HistoryWrapper" }, index.h("div", { class: "HistoryCols" }, index.h("div", { class: "HistoryColName Rewards" }, translate('rewards', this.language)), index.h("div", { class: "HistoryColName Issued" }, translate('issued', this.language)), index.h("div", { class: "HistoryColName Time" }, translate('time', this.language))), this.historyLoading
2556
+ ? getHistoryLoaderTemplate(this.language)
2557
+ : getLuckyWheelsHistoryTemplate(this.luckywheels, this.luckywheelHistory, this.openedHistoryIds, this.toggleLuckyWheelHistory, this.language));
2558
+ }
2559
+ getTabsContentTemplate() {
2560
+ return this.activeTab === 1
2561
+ ? this.getListTemplate()
2562
+ : this.getHistoryTabTemplate();
2563
+ }
2564
+ render() {
2565
+ return index.h("div", { key: 'bec9d35e1b9362a5098ab53c9fddb620b407b17e', class: `LuckyWheelsListPopup ${this.device}` }, this.getHeaderTemplate(), this.getTabsTemplate(), this.getTabsContentTemplate(), this.getTooltipTemplate());
2566
+ }
2567
+ get host() { return index.getElement(this); }
2568
+ static get watchers() { return {
2569
+ "luckywheels": ["luckywheelsPropHandler"]
2570
+ }; }
2571
+ };
2572
+ CasinoEngagementSuiteLuckyWheelList.style = CasinoEngagementSuiteLuckywheelListStyle0;
2573
+
2574
+ exports.CasinoEngagementSuiteLuckyWheelList = CasinoEngagementSuiteLuckyWheelList;