Browse Source

making assets more internal to make offline work easier

Stephen Searles 1 year ago
parent
commit
f753f94390
6 changed files with 14621 additions and 3 deletions
  1. 1
    1
      assets/assets.go
  2. 73
    0
      assets/bindata.go
  3. 4
    0
      assets/css/font-awesome.min.css
  4. 4463
    0
      assets/js/moment.js
  5. 10078
    0
      assets/js/vue.js
  6. 2
    2
      templates.go

+ 1
- 1
assets/assets.go View File

@@ -1,2 +1,2 @@
1
-//go:generate go-bindata -pkg assets simplemde/dist/... simplemde/debug/...
1
+//go:generate go-bindata -pkg assets simplemde/dist/... simplemde/debug/... js/... css/...
2 2
 package assets

+ 73
- 0
assets/bindata.go
File diff suppressed because it is too large
View File


+ 4
- 0
assets/css/font-awesome.min.css
File diff suppressed because it is too large
View File


+ 4463
- 0
assets/js/moment.js View File

@@ -0,0 +1,4463 @@
1
+//! moment.js
2
+//! version : 2.18.1
3
+//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
4
+//! license : MIT
5
+//! momentjs.com
6
+
7
+;(function (global, factory) {
8
+    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
9
+    typeof define === 'function' && define.amd ? define(factory) :
10
+    global.moment = factory()
11
+}(this, (function () { 'use strict';
12
+
13
+var hookCallback;
14
+
15
+function hooks () {
16
+    return hookCallback.apply(null, arguments);
17
+}
18
+
19
+// This is done to register the method called with moment()
20
+// without creating circular dependencies.
21
+function setHookCallback (callback) {
22
+    hookCallback = callback;
23
+}
24
+
25
+function isArray(input) {
26
+    return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
27
+}
28
+
29
+function isObject(input) {
30
+    // IE8 will treat undefined and null as object if it wasn't for
31
+    // input != null
32
+    return input != null && Object.prototype.toString.call(input) === '[object Object]';
33
+}
34
+
35
+function isObjectEmpty(obj) {
36
+    var k;
37
+    for (k in obj) {
38
+        // even if its not own property I'd still call it non-empty
39
+        return false;
40
+    }
41
+    return true;
42
+}
43
+
44
+function isUndefined(input) {
45
+    return input === void 0;
46
+}
47
+
48
+function isNumber(input) {
49
+    return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
50
+}
51
+
52
+function isDate(input) {
53
+    return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
54
+}
55
+
56
+function map(arr, fn) {
57
+    var res = [], i;
58
+    for (i = 0; i < arr.length; ++i) {
59
+        res.push(fn(arr[i], i));
60
+    }
61
+    return res;
62
+}
63
+
64
+function hasOwnProp(a, b) {
65
+    return Object.prototype.hasOwnProperty.call(a, b);
66
+}
67
+
68
+function extend(a, b) {
69
+    for (var i in b) {
70
+        if (hasOwnProp(b, i)) {
71
+            a[i] = b[i];
72
+        }
73
+    }
74
+
75
+    if (hasOwnProp(b, 'toString')) {
76
+        a.toString = b.toString;
77
+    }
78
+
79
+    if (hasOwnProp(b, 'valueOf')) {
80
+        a.valueOf = b.valueOf;
81
+    }
82
+
83
+    return a;
84
+}
85
+
86
+function createUTC (input, format, locale, strict) {
87
+    return createLocalOrUTC(input, format, locale, strict, true).utc();
88
+}
89
+
90
+function defaultParsingFlags() {
91
+    // We need to deep clone this object.
92
+    return {
93
+        empty           : false,
94
+        unusedTokens    : [],
95
+        unusedInput     : [],
96
+        overflow        : -2,
97
+        charsLeftOver   : 0,
98
+        nullInput       : false,
99
+        invalidMonth    : null,
100
+        invalidFormat   : false,
101
+        userInvalidated : false,
102
+        iso             : false,
103
+        parsedDateParts : [],
104
+        meridiem        : null,
105
+        rfc2822         : false,
106
+        weekdayMismatch : false
107
+    };
108
+}
109
+
110
+function getParsingFlags(m) {
111
+    if (m._pf == null) {
112
+        m._pf = defaultParsingFlags();
113
+    }
114
+    return m._pf;
115
+}
116
+
117
+var some;
118
+if (Array.prototype.some) {
119
+    some = Array.prototype.some;
120
+} else {
121
+    some = function (fun) {
122
+        var t = Object(this);
123
+        var len = t.length >>> 0;
124
+
125
+        for (var i = 0; i < len; i++) {
126
+            if (i in t && fun.call(this, t[i], i, t)) {
127
+                return true;
128
+            }
129
+        }
130
+
131
+        return false;
132
+    };
133
+}
134
+
135
+var some$1 = some;
136
+
137
+function isValid(m) {
138
+    if (m._isValid == null) {
139
+        var flags = getParsingFlags(m);
140
+        var parsedParts = some$1.call(flags.parsedDateParts, function (i) {
141
+            return i != null;
142
+        });
143
+        var isNowValid = !isNaN(m._d.getTime()) &&
144
+            flags.overflow < 0 &&
145
+            !flags.empty &&
146
+            !flags.invalidMonth &&
147
+            !flags.invalidWeekday &&
148
+            !flags.nullInput &&
149
+            !flags.invalidFormat &&
150
+            !flags.userInvalidated &&
151
+            (!flags.meridiem || (flags.meridiem && parsedParts));
152
+
153
+        if (m._strict) {
154
+            isNowValid = isNowValid &&
155
+                flags.charsLeftOver === 0 &&
156
+                flags.unusedTokens.length === 0 &&
157
+                flags.bigHour === undefined;
158
+        }
159
+
160
+        if (Object.isFrozen == null || !Object.isFrozen(m)) {
161
+            m._isValid = isNowValid;
162
+        }
163
+        else {
164
+            return isNowValid;
165
+        }
166
+    }
167
+    return m._isValid;
168
+}
169
+
170
+function createInvalid (flags) {
171
+    var m = createUTC(NaN);
172
+    if (flags != null) {
173
+        extend(getParsingFlags(m), flags);
174
+    }
175
+    else {
176
+        getParsingFlags(m).userInvalidated = true;
177
+    }
178
+
179
+    return m;
180
+}
181
+
182
+// Plugins that add properties should also add the key here (null value),
183
+// so we can properly clone ourselves.
184
+var momentProperties = hooks.momentProperties = [];
185
+
186
+function copyConfig(to, from) {
187
+    var i, prop, val;
188
+
189
+    if (!isUndefined(from._isAMomentObject)) {
190
+        to._isAMomentObject = from._isAMomentObject;
191
+    }
192
+    if (!isUndefined(from._i)) {
193
+        to._i = from._i;
194
+    }
195
+    if (!isUndefined(from._f)) {
196
+        to._f = from._f;
197
+    }
198
+    if (!isUndefined(from._l)) {
199
+        to._l = from._l;
200
+    }
201
+    if (!isUndefined(from._strict)) {
202
+        to._strict = from._strict;
203
+    }
204
+    if (!isUndefined(from._tzm)) {
205
+        to._tzm = from._tzm;
206
+    }
207
+    if (!isUndefined(from._isUTC)) {
208
+        to._isUTC = from._isUTC;
209
+    }
210
+    if (!isUndefined(from._offset)) {
211
+        to._offset = from._offset;
212
+    }
213
+    if (!isUndefined(from._pf)) {
214
+        to._pf = getParsingFlags(from);
215
+    }
216
+    if (!isUndefined(from._locale)) {
217
+        to._locale = from._locale;
218
+    }
219
+
220
+    if (momentProperties.length > 0) {
221
+        for (i = 0; i < momentProperties.length; i++) {
222
+            prop = momentProperties[i];
223
+            val = from[prop];
224
+            if (!isUndefined(val)) {
225
+                to[prop] = val;
226
+            }
227
+        }
228
+    }
229
+
230
+    return to;
231
+}
232
+
233
+var updateInProgress = false;
234
+
235
+// Moment prototype object
236
+function Moment(config) {
237
+    copyConfig(this, config);
238
+    this._d = new Date(config._d != null ? config._d.getTime() : NaN);
239
+    if (!this.isValid()) {
240
+        this._d = new Date(NaN);
241
+    }
242
+    // Prevent infinite loop in case updateOffset creates new moment
243
+    // objects.
244
+    if (updateInProgress === false) {
245
+        updateInProgress = true;
246
+        hooks.updateOffset(this);
247
+        updateInProgress = false;
248
+    }
249
+}
250
+
251
+function isMoment (obj) {
252
+    return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
253
+}
254
+
255
+function absFloor (number) {
256
+    if (number < 0) {
257
+        // -0 -> 0
258
+        return Math.ceil(number) || 0;
259
+    } else {
260
+        return Math.floor(number);
261
+    }
262
+}
263
+
264
+function toInt(argumentForCoercion) {
265
+    var coercedNumber = +argumentForCoercion,
266
+        value = 0;
267
+
268
+    if (coercedNumber !== 0 && isFinite(coercedNumber)) {
269
+        value = absFloor(coercedNumber);
270
+    }
271
+
272
+    return value;
273
+}
274
+
275
+// compare two arrays, return the number of differences
276
+function compareArrays(array1, array2, dontConvert) {
277
+    var len = Math.min(array1.length, array2.length),
278
+        lengthDiff = Math.abs(array1.length - array2.length),
279
+        diffs = 0,
280
+        i;
281
+    for (i = 0; i < len; i++) {
282
+        if ((dontConvert && array1[i] !== array2[i]) ||
283
+            (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
284
+            diffs++;
285
+        }
286
+    }
287
+    return diffs + lengthDiff;
288
+}
289
+
290
+function warn(msg) {
291
+    if (hooks.suppressDeprecationWarnings === false &&
292
+            (typeof console !==  'undefined') && console.warn) {
293
+        console.warn('Deprecation warning: ' + msg);
294
+    }
295
+}
296
+
297
+function deprecate(msg, fn) {
298
+    var firstTime = true;
299
+
300
+    return extend(function () {
301
+        if (hooks.deprecationHandler != null) {
302
+            hooks.deprecationHandler(null, msg);
303
+        }
304
+        if (firstTime) {
305
+            var args = [];
306
+            var arg;
307
+            for (var i = 0; i < arguments.length; i++) {
308
+                arg = '';
309
+                if (typeof arguments[i] === 'object') {
310
+                    arg += '\n[' + i + '] ';
311
+                    for (var key in arguments[0]) {
312
+                        arg += key + ': ' + arguments[0][key] + ', ';
313
+                    }
314
+                    arg = arg.slice(0, -2); // Remove trailing comma and space
315
+                } else {
316
+                    arg = arguments[i];
317
+                }
318
+                args.push(arg);
319
+            }
320
+            warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
321
+            firstTime = false;
322
+        }
323
+        return fn.apply(this, arguments);
324
+    }, fn);
325
+}
326
+
327
+var deprecations = {};
328
+
329
+function deprecateSimple(name, msg) {
330
+    if (hooks.deprecationHandler != null) {
331
+        hooks.deprecationHandler(name, msg);
332
+    }
333
+    if (!deprecations[name]) {
334
+        warn(msg);
335
+        deprecations[name] = true;
336
+    }
337
+}
338
+
339
+hooks.suppressDeprecationWarnings = false;
340
+hooks.deprecationHandler = null;
341
+
342
+function isFunction(input) {
343
+    return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
344
+}
345
+
346
+function set (config) {
347
+    var prop, i;
348
+    for (i in config) {
349
+        prop = config[i];
350
+        if (isFunction(prop)) {
351
+            this[i] = prop;
352
+        } else {
353
+            this['_' + i] = prop;
354
+        }
355
+    }
356
+    this._config = config;
357
+    // Lenient ordinal parsing accepts just a number in addition to
358
+    // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
359
+    // TODO: Remove "ordinalParse" fallback in next major release.
360
+    this._dayOfMonthOrdinalParseLenient = new RegExp(
361
+        (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
362
+            '|' + (/\d{1,2}/).source);
363
+}
364
+
365
+function mergeConfigs(parentConfig, childConfig) {
366
+    var res = extend({}, parentConfig), prop;
367
+    for (prop in childConfig) {
368
+        if (hasOwnProp(childConfig, prop)) {
369
+            if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
370
+                res[prop] = {};
371
+                extend(res[prop], parentConfig[prop]);
372
+                extend(res[prop], childConfig[prop]);
373
+            } else if (childConfig[prop] != null) {
374
+                res[prop] = childConfig[prop];
375
+            } else {
376
+                delete res[prop];
377
+            }
378
+        }
379
+    }
380
+    for (prop in parentConfig) {
381
+        if (hasOwnProp(parentConfig, prop) &&
382
+                !hasOwnProp(childConfig, prop) &&
383
+                isObject(parentConfig[prop])) {
384
+            // make sure changes to properties don't modify parent config
385
+            res[prop] = extend({}, res[prop]);
386
+        }
387
+    }
388
+    return res;
389
+}
390
+
391
+function Locale(config) {
392
+    if (config != null) {
393
+        this.set(config);
394
+    }
395
+}
396
+
397
+var keys;
398
+
399
+if (Object.keys) {
400
+    keys = Object.keys;
401
+} else {
402
+    keys = function (obj) {
403
+        var i, res = [];
404
+        for (i in obj) {
405
+            if (hasOwnProp(obj, i)) {
406
+                res.push(i);
407
+            }
408
+        }
409
+        return res;
410
+    };
411
+}
412
+
413
+var keys$1 = keys;
414
+
415
+var defaultCalendar = {
416
+    sameDay : '[Today at] LT',
417
+    nextDay : '[Tomorrow at] LT',
418
+    nextWeek : 'dddd [at] LT',
419
+    lastDay : '[Yesterday at] LT',
420
+    lastWeek : '[Last] dddd [at] LT',
421
+    sameElse : 'L'
422
+};
423
+
424
+function calendar (key, mom, now) {
425
+    var output = this._calendar[key] || this._calendar['sameElse'];
426
+    return isFunction(output) ? output.call(mom, now) : output;
427
+}
428
+
429
+var defaultLongDateFormat = {
430
+    LTS  : 'h:mm:ss A',
431
+    LT   : 'h:mm A',
432
+    L    : 'MM/DD/YYYY',
433
+    LL   : 'MMMM D, YYYY',
434
+    LLL  : 'MMMM D, YYYY h:mm A',
435
+    LLLL : 'dddd, MMMM D, YYYY h:mm A'
436
+};
437
+
438
+function longDateFormat (key) {
439
+    var format = this._longDateFormat[key],
440
+        formatUpper = this._longDateFormat[key.toUpperCase()];
441
+
442
+    if (format || !formatUpper) {
443
+        return format;
444
+    }
445
+
446
+    this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
447
+        return val.slice(1);
448
+    });
449
+
450
+    return this._longDateFormat[key];
451
+}
452
+
453
+var defaultInvalidDate = 'Invalid date';
454
+
455
+function invalidDate () {
456
+    return this._invalidDate;
457
+}
458
+
459
+var defaultOrdinal = '%d';
460
+var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
461
+
462
+function ordinal (number) {
463
+    return this._ordinal.replace('%d', number);
464
+}
465
+
466
+var defaultRelativeTime = {
467
+    future : 'in %s',
468
+    past   : '%s ago',
469
+    s  : 'a few seconds',
470
+    ss : '%d seconds',
471
+    m  : 'a minute',
472
+    mm : '%d minutes',
473
+    h  : 'an hour',
474
+    hh : '%d hours',
475
+    d  : 'a day',
476
+    dd : '%d days',
477
+    M  : 'a month',
478
+    MM : '%d months',
479
+    y  : 'a year',
480
+    yy : '%d years'
481
+};
482
+
483
+function relativeTime (number, withoutSuffix, string, isFuture) {
484
+    var output = this._relativeTime[string];
485
+    return (isFunction(output)) ?
486
+        output(number, withoutSuffix, string, isFuture) :
487
+        output.replace(/%d/i, number);
488
+}
489
+
490
+function pastFuture (diff, output) {
491
+    var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
492
+    return isFunction(format) ? format(output) : format.replace(/%s/i, output);
493
+}
494
+
495
+var aliases = {};
496
+
497
+function addUnitAlias (unit, shorthand) {
498
+    var lowerCase = unit.toLowerCase();
499
+    aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
500
+}
501
+
502
+function normalizeUnits(units) {
503
+    return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
504
+}
505
+
506
+function normalizeObjectUnits(inputObject) {
507
+    var normalizedInput = {},
508
+        normalizedProp,
509
+        prop;
510
+
511
+    for (prop in inputObject) {
512
+        if (hasOwnProp(inputObject, prop)) {
513
+            normalizedProp = normalizeUnits(prop);
514
+            if (normalizedProp) {
515
+                normalizedInput[normalizedProp] = inputObject[prop];
516
+            }
517
+        }
518
+    }
519
+
520
+    return normalizedInput;
521
+}
522
+
523
+var priorities = {};
524
+
525
+function addUnitPriority(unit, priority) {
526
+    priorities[unit] = priority;
527
+}
528
+
529
+function getPrioritizedUnits(unitsObj) {
530
+    var units = [];
531
+    for (var u in unitsObj) {
532
+        units.push({unit: u, priority: priorities[u]});
533
+    }
534
+    units.sort(function (a, b) {
535
+        return a.priority - b.priority;
536
+    });
537
+    return units;
538
+}
539
+
540
+function makeGetSet (unit, keepTime) {
541
+    return function (value) {
542
+        if (value != null) {
543
+            set$1(this, unit, value);
544
+            hooks.updateOffset(this, keepTime);
545
+            return this;
546
+        } else {
547
+            return get(this, unit);
548
+        }
549
+    };
550
+}
551
+
552
+function get (mom, unit) {
553
+    return mom.isValid() ?
554
+        mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
555
+}
556
+
557
+function set$1 (mom, unit, value) {
558
+    if (mom.isValid()) {
559
+        mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
560
+    }
561
+}
562
+
563
+// MOMENTS
564
+
565
+function stringGet (units) {
566
+    units = normalizeUnits(units);
567
+    if (isFunction(this[units])) {
568
+        return this[units]();
569
+    }
570
+    return this;
571
+}
572
+
573
+
574
+function stringSet (units, value) {
575
+    if (typeof units === 'object') {
576
+        units = normalizeObjectUnits(units);
577
+        var prioritized = getPrioritizedUnits(units);
578
+        for (var i = 0; i < prioritized.length; i++) {
579
+            this[prioritized[i].unit](units[prioritized[i].unit]);
580
+        }
581
+    } else {
582
+        units = normalizeUnits(units);
583
+        if (isFunction(this[units])) {
584
+            return this[units](value);
585
+        }
586
+    }
587
+    return this;
588
+}
589
+
590
+function zeroFill(number, targetLength, forceSign) {
591
+    var absNumber = '' + Math.abs(number),
592
+        zerosToFill = targetLength - absNumber.length,
593
+        sign = number >= 0;
594
+    return (sign ? (forceSign ? '+' : '') : '-') +
595
+        Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
596
+}
597
+
598
+var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
599
+
600
+var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
601
+
602
+var formatFunctions = {};
603
+
604
+var formatTokenFunctions = {};
605
+
606
+// token:    'M'
607
+// padded:   ['MM', 2]
608
+// ordinal:  'Mo'
609
+// callback: function () { this.month() + 1 }
610
+function addFormatToken (token, padded, ordinal, callback) {
611
+    var func = callback;
612
+    if (typeof callback === 'string') {
613
+        func = function () {
614
+            return this[callback]();
615
+        };
616
+    }
617
+    if (token) {
618
+        formatTokenFunctions[token] = func;
619
+    }
620
+    if (padded) {
621
+        formatTokenFunctions[padded[0]] = function () {
622
+            return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
623
+        };
624
+    }
625
+    if (ordinal) {
626
+        formatTokenFunctions[ordinal] = function () {
627
+            return this.localeData().ordinal(func.apply(this, arguments), token);
628
+        };
629
+    }
630
+}
631
+
632
+function removeFormattingTokens(input) {
633
+    if (input.match(/\[[\s\S]/)) {
634
+        return input.replace(/^\[|\]$/g, '');
635
+    }
636
+    return input.replace(/\\/g, '');
637
+}
638
+
639
+function makeFormatFunction(format) {
640
+    var array = format.match(formattingTokens), i, length;
641
+
642
+    for (i = 0, length = array.length; i < length; i++) {
643
+        if (formatTokenFunctions[array[i]]) {
644
+            array[i] = formatTokenFunctions[array[i]];
645
+        } else {
646
+            array[i] = removeFormattingTokens(array[i]);
647
+        }
648
+    }
649
+
650
+    return function (mom) {
651
+        var output = '', i;
652
+        for (i = 0; i < length; i++) {
653
+            output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
654
+        }
655
+        return output;
656
+    };
657
+}
658
+
659
+// format date using native date object
660
+function formatMoment(m, format) {
661
+    if (!m.isValid()) {
662
+        return m.localeData().invalidDate();
663
+    }
664
+
665
+    format = expandFormat(format, m.localeData());
666
+    formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
667
+
668
+    return formatFunctions[format](m);
669
+}
670
+
671
+function expandFormat(format, locale) {
672
+    var i = 5;
673
+
674
+    function replaceLongDateFormatTokens(input) {
675
+        return locale.longDateFormat(input) || input;
676
+    }
677
+
678
+    localFormattingTokens.lastIndex = 0;
679
+    while (i >= 0 && localFormattingTokens.test(format)) {
680
+        format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
681
+        localFormattingTokens.lastIndex = 0;
682
+        i -= 1;
683
+    }
684
+
685
+    return format;
686
+}
687
+
688
+var match1         = /\d/;            //       0 - 9
689
+var match2         = /\d\d/;          //      00 - 99
690
+var match3         = /\d{3}/;         //     000 - 999
691
+var match4         = /\d{4}/;         //    0000 - 9999
692
+var match6         = /[+-]?\d{6}/;    // -999999 - 999999
693
+var match1to2      = /\d\d?/;         //       0 - 99
694
+var match3to4      = /\d\d\d\d?/;     //     999 - 9999
695
+var match5to6      = /\d\d\d\d\d\d?/; //   99999 - 999999
696
+var match1to3      = /\d{1,3}/;       //       0 - 999
697
+var match1to4      = /\d{1,4}/;       //       0 - 9999
698
+var match1to6      = /[+-]?\d{1,6}/;  // -999999 - 999999
699
+
700
+var matchUnsigned  = /\d+/;           //       0 - inf
701
+var matchSigned    = /[+-]?\d+/;      //    -inf - inf
702
+
703
+var matchOffset    = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
704
+var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z
705
+
706
+var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
707
+
708
+// any word (or two) characters or numbers including two/three word month in arabic.
709
+// includes scottish gaelic two word and hyphenated months
710
+var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
711
+
712
+
713
+var regexes = {};
714
+
715
+function addRegexToken (token, regex, strictRegex) {
716
+    regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
717
+        return (isStrict && strictRegex) ? strictRegex : regex;
718
+    };
719
+}
720
+
721
+function getParseRegexForToken (token, config) {
722
+    if (!hasOwnProp(regexes, token)) {
723
+        return new RegExp(unescapeFormat(token));
724
+    }
725
+
726
+    return regexes[token](config._strict, config._locale);
727
+}
728
+
729
+// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
730
+function unescapeFormat(s) {
731
+    return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
732
+        return p1 || p2 || p3 || p4;
733
+    }));
734
+}
735
+
736
+function regexEscape(s) {
737
+    return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
738
+}
739
+
740
+var tokens = {};
741
+
742
+function addParseToken (token, callback) {
743
+    var i, func = callback;
744
+    if (typeof token === 'string') {
745
+        token = [token];
746
+    }
747
+    if (isNumber(callback)) {
748
+        func = function (input, array) {
749
+            array[callback] = toInt(input);
750
+        };
751
+    }
752
+    for (i = 0; i < token.length; i++) {
753
+        tokens[token[i]] = func;
754
+    }
755
+}
756
+
757
+function addWeekParseToken (token, callback) {
758
+    addParseToken(token, function (input, array, config, token) {
759
+        config._w = config._w || {};
760
+        callback(input, config._w, config, token);
761
+    });
762
+}
763
+
764
+function addTimeToArrayFromToken(token, input, config) {
765
+    if (input != null && hasOwnProp(tokens, token)) {
766
+        tokens[token](input, config._a, config, token);
767
+    }
768
+}
769
+
770
+var YEAR = 0;
771
+var MONTH = 1;
772
+var DATE = 2;
773
+var HOUR = 3;
774
+var MINUTE = 4;
775
+var SECOND = 5;
776
+var MILLISECOND = 6;
777
+var WEEK = 7;
778
+var WEEKDAY = 8;
779
+
780
+var indexOf;
781
+
782
+if (Array.prototype.indexOf) {
783
+    indexOf = Array.prototype.indexOf;
784
+} else {
785
+    indexOf = function (o) {
786
+        // I know
787
+        var i;
788
+        for (i = 0; i < this.length; ++i) {
789
+            if (this[i] === o) {
790
+                return i;
791
+            }
792
+        }
793
+        return -1;
794
+    };
795
+}
796
+
797
+var indexOf$1 = indexOf;
798
+
799
+function daysInMonth(year, month) {
800
+    return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
801
+}
802
+
803
+// FORMATTING
804
+
805
+addFormatToken('M', ['MM', 2], 'Mo', function () {
806
+    return this.month() + 1;
807
+});
808
+
809
+addFormatToken('MMM', 0, 0, function (format) {
810
+    return this.localeData().monthsShort(this, format);
811
+});
812
+
813
+addFormatToken('MMMM', 0, 0, function (format) {
814
+    return this.localeData().months(this, format);
815
+});
816
+
817
+// ALIASES
818
+
819
+addUnitAlias('month', 'M');
820
+
821
+// PRIORITY
822
+
823
+addUnitPriority('month', 8);
824
+
825
+// PARSING
826
+
827
+addRegexToken('M',    match1to2);
828
+addRegexToken('MM',   match1to2, match2);
829
+addRegexToken('MMM',  function (isStrict, locale) {
830
+    return locale.monthsShortRegex(isStrict);
831
+});
832
+addRegexToken('MMMM', function (isStrict, locale) {
833
+    return locale.monthsRegex(isStrict);
834
+});
835
+
836
+addParseToken(['M', 'MM'], function (input, array) {
837
+    array[MONTH] = toInt(input) - 1;
838
+});
839
+
840
+addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
841
+    var month = config._locale.monthsParse(input, token, config._strict);
842
+    // if we didn't find a month name, mark the date as invalid.
843
+    if (month != null) {
844
+        array[MONTH] = month;
845
+    } else {
846
+        getParsingFlags(config).invalidMonth = input;
847
+    }
848
+});
849
+
850
+// LOCALES
851
+
852
+var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
853
+var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
854
+function localeMonths (m, format) {
855
+    if (!m) {
856
+        return isArray(this._months) ? this._months :
857
+            this._months['standalone'];
858
+    }
859
+    return isArray(this._months) ? this._months[m.month()] :
860
+        this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
861
+}
862
+
863
+var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
864
+function localeMonthsShort (m, format) {
865
+    if (!m) {
866
+        return isArray(this._monthsShort) ? this._monthsShort :
867
+            this._monthsShort['standalone'];
868
+    }
869
+    return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
870
+        this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
871
+}
872
+
873
+function handleStrictParse(monthName, format, strict) {
874
+    var i, ii, mom, llc = monthName.toLocaleLowerCase();
875
+    if (!this._monthsParse) {
876
+        // this is not used
877
+        this._monthsParse = [];
878
+        this._longMonthsParse = [];
879
+        this._shortMonthsParse = [];
880
+        for (i = 0; i < 12; ++i) {
881
+            mom = createUTC([2000, i]);
882
+            this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
883
+            this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
884
+        }
885
+    }
886
+
887
+    if (strict) {
888
+        if (format === 'MMM') {
889
+            ii = indexOf$1.call(this._shortMonthsParse, llc);
890
+            return ii !== -1 ? ii : null;
891
+        } else {
892
+            ii = indexOf$1.call(this._longMonthsParse, llc);
893
+            return ii !== -1 ? ii : null;
894
+        }
895
+    } else {
896
+        if (format === 'MMM') {
897
+            ii = indexOf$1.call(this._shortMonthsParse, llc);
898
+            if (ii !== -1) {
899
+                return ii;
900
+            }
901
+            ii = indexOf$1.call(this._longMonthsParse, llc);
902
+            return ii !== -1 ? ii : null;
903
+        } else {
904
+            ii = indexOf$1.call(this._longMonthsParse, llc);
905
+            if (ii !== -1) {
906
+                return ii;
907
+            }
908
+            ii = indexOf$1.call(this._shortMonthsParse, llc);
909
+            return ii !== -1 ? ii : null;
910
+        }
911
+    }
912
+}
913
+
914
+function localeMonthsParse (monthName, format, strict) {
915
+    var i, mom, regex;
916
+
917
+    if (this._monthsParseExact) {
918
+        return handleStrictParse.call(this, monthName, format, strict);
919
+    }
920
+
921
+    if (!this._monthsParse) {
922
+        this._monthsParse = [];
923
+        this._longMonthsParse = [];
924
+        this._shortMonthsParse = [];
925
+    }
926
+
927
+    // TODO: add sorting
928
+    // Sorting makes sure if one month (or abbr) is a prefix of another
929
+    // see sorting in computeMonthsParse
930
+    for (i = 0; i < 12; i++) {
931
+        // make the regex if we don't have it already
932
+        mom = createUTC([2000, i]);
933
+        if (strict && !this._longMonthsParse[i]) {
934
+            this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
935
+            this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
936
+        }
937
+        if (!strict && !this._monthsParse[i]) {
938
+            regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
939
+            this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
940
+        }
941
+        // test the regex
942
+        if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
943
+            return i;
944
+        } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
945
+            return i;
946
+        } else if (!strict && this._monthsParse[i].test(monthName)) {
947
+            return i;
948
+        }
949
+    }
950
+}
951
+
952
+// MOMENTS
953
+
954
+function setMonth (mom, value) {
955
+    var dayOfMonth;
956
+
957
+    if (!mom.isValid()) {
958
+        // No op
959
+        return mom;
960
+    }
961
+
962
+    if (typeof value === 'string') {
963
+        if (/^\d+$/.test(value)) {
964
+            value = toInt(value);
965
+        } else {
966
+            value = mom.localeData().monthsParse(value);
967
+            // TODO: Another silent failure?
968
+            if (!isNumber(value)) {
969
+                return mom;
970
+            }
971
+        }
972
+    }
973
+
974
+    dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
975
+    mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
976
+    return mom;
977
+}
978
+
979
+function getSetMonth (value) {
980
+    if (value != null) {
981
+        setMonth(this, value);
982
+        hooks.updateOffset(this, true);
983
+        return this;
984
+    } else {
985
+        return get(this, 'Month');
986
+    }
987
+}
988
+
989
+function getDaysInMonth () {
990
+    return daysInMonth(this.year(), this.month());
991
+}
992
+
993
+var defaultMonthsShortRegex = matchWord;
994
+function monthsShortRegex (isStrict) {
995
+    if (this._monthsParseExact) {
996
+        if (!hasOwnProp(this, '_monthsRegex')) {
997
+            computeMonthsParse.call(this);
998
+        }
999
+        if (isStrict) {
1000
+            return this._monthsShortStrictRegex;
1001
+        } else {
1002
+            return this._monthsShortRegex;
1003
+        }
1004
+    } else {
1005
+        if (!hasOwnProp(this, '_monthsShortRegex')) {
1006
+            this._monthsShortRegex = defaultMonthsShortRegex;
1007
+        }
1008
+        return this._monthsShortStrictRegex && isStrict ?
1009
+            this._monthsShortStrictRegex : this._monthsShortRegex;
1010
+    }
1011
+}
1012
+
1013
+var defaultMonthsRegex = matchWord;
1014
+function monthsRegex (isStrict) {
1015
+    if (this._monthsParseExact) {
1016
+        if (!hasOwnProp(this, '_monthsRegex')) {
1017
+            computeMonthsParse.call(this);
1018
+        }
1019
+        if (isStrict) {
1020
+            return this._monthsStrictRegex;
1021
+        } else {
1022
+            return this._monthsRegex;
1023
+        }
1024
+    } else {
1025
+        if (!hasOwnProp(this, '_monthsRegex')) {
1026
+            this._monthsRegex = defaultMonthsRegex;
1027
+        }
1028
+        return this._monthsStrictRegex && isStrict ?
1029
+            this._monthsStrictRegex : this._monthsRegex;
1030
+    }
1031
+}
1032
+
1033
+function computeMonthsParse () {
1034
+    function cmpLenRev(a, b) {
1035
+        return b.length - a.length;
1036
+    }
1037
+
1038
+    var shortPieces = [], longPieces = [], mixedPieces = [],
1039
+        i, mom;
1040
+    for (i = 0; i < 12; i++) {
1041
+        // make the regex if we don't have it already
1042
+        mom = createUTC([2000, i]);
1043
+        shortPieces.push(this.monthsShort(mom, ''));
1044
+        longPieces.push(this.months(mom, ''));
1045
+        mixedPieces.push(this.months(mom, ''));
1046
+        mixedPieces.push(this.monthsShort(mom, ''));
1047
+    }
1048
+    // Sorting makes sure if one month (or abbr) is a prefix of another it
1049
+    // will match the longer piece.
1050
+    shortPieces.sort(cmpLenRev);
1051
+    longPieces.sort(cmpLenRev);
1052
+    mixedPieces.sort(cmpLenRev);
1053
+    for (i = 0; i < 12; i++) {
1054
+        shortPieces[i] = regexEscape(shortPieces[i]);
1055
+        longPieces[i] = regexEscape(longPieces[i]);
1056
+    }
1057
+    for (i = 0; i < 24; i++) {
1058
+        mixedPieces[i] = regexEscape(mixedPieces[i]);
1059
+    }
1060
+
1061
+    this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
1062
+    this._monthsShortRegex = this._monthsRegex;
1063
+    this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
1064
+    this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
1065
+}
1066
+
1067
+// FORMATTING
1068
+
1069
+addFormatToken('Y', 0, 0, function () {
1070
+    var y = this.year();
1071
+    return y <= 9999 ? '' + y : '+' + y;
1072
+});
1073
+
1074
+addFormatToken(0, ['YY', 2], 0, function () {
1075
+    return this.year() % 100;
1076
+});
1077
+
1078
+addFormatToken(0, ['YYYY',   4],       0, 'year');
1079
+addFormatToken(0, ['YYYYY',  5],       0, 'year');
1080
+addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
1081
+
1082
+// ALIASES
1083
+
1084
+addUnitAlias('year', 'y');
1085
+
1086
+// PRIORITIES
1087
+
1088
+addUnitPriority('year', 1);
1089
+
1090
+// PARSING
1091
+
1092
+addRegexToken('Y',      matchSigned);
1093
+addRegexToken('YY',     match1to2, match2);
1094
+addRegexToken('YYYY',   match1to4, match4);
1095
+addRegexToken('YYYYY',  match1to6, match6);
1096
+addRegexToken('YYYYYY', match1to6, match6);
1097
+
1098
+addParseToken(['YYYYY', 'YYYYYY'], YEAR);
1099
+addParseToken('YYYY', function (input, array) {
1100
+    array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
1101
+});
1102
+addParseToken('YY', function (input, array) {
1103
+    array[YEAR] = hooks.parseTwoDigitYear(input);
1104
+});
1105
+addParseToken('Y', function (input, array) {
1106
+    array[YEAR] = parseInt(input, 10);
1107
+});
1108
+
1109
+// HELPERS
1110
+
1111
+function daysInYear(year) {
1112
+    return isLeapYear(year) ? 366 : 365;
1113
+}
1114
+
1115
+function isLeapYear(year) {
1116
+    return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
1117
+}
1118
+
1119
+// HOOKS
1120
+
1121
+hooks.parseTwoDigitYear = function (input) {
1122
+    return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
1123
+};
1124
+
1125
+// MOMENTS
1126
+
1127
+var getSetYear = makeGetSet('FullYear', true);
1128
+
1129
+function getIsLeapYear () {
1130
+    return isLeapYear(this.year());
1131
+}
1132
+
1133
+function createDate (y, m, d, h, M, s, ms) {
1134
+    // can't just apply() to create a date:
1135
+    // https://stackoverflow.com/q/181348
1136
+    var date = new Date(y, m, d, h, M, s, ms);
1137
+
1138
+    // the date constructor remaps years 0-99 to 1900-1999
1139
+    if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
1140
+        date.setFullYear(y);
1141
+    }
1142
+    return date;
1143
+}
1144
+
1145
+function createUTCDate (y) {
1146
+    var date = new Date(Date.UTC.apply(null, arguments));
1147
+
1148
+    // the Date.UTC function remaps years 0-99 to 1900-1999
1149
+    if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
1150
+        date.setUTCFullYear(y);
1151
+    }
1152
+    return date;
1153
+}
1154
+
1155
+// start-of-first-week - start-of-year
1156
+function firstWeekOffset(year, dow, doy) {
1157
+    var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
1158
+        fwd = 7 + dow - doy,
1159
+        // first-week day local weekday -- which local weekday is fwd
1160
+        fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
1161
+
1162
+    return -fwdlw + fwd - 1;
1163
+}
1164
+
1165
+// https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
1166
+function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
1167
+    var localWeekday = (7 + weekday - dow) % 7,
1168
+        weekOffset = firstWeekOffset(year, dow, doy),
1169
+        dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
1170
+        resYear, resDayOfYear;
1171
+
1172
+    if (dayOfYear <= 0) {
1173
+        resYear = year - 1;
1174
+        resDayOfYear = daysInYear(resYear) + dayOfYear;
1175
+    } else if (dayOfYear > daysInYear(year)) {
1176
+        resYear = year + 1;
1177
+        resDayOfYear = dayOfYear - daysInYear(year);
1178
+    } else {
1179
+        resYear = year;
1180
+        resDayOfYear = dayOfYear;
1181
+    }
1182
+
1183
+    return {
1184
+        year: resYear,
1185
+        dayOfYear: resDayOfYear
1186
+    };
1187
+}
1188
+
1189
+function weekOfYear(mom, dow, doy) {
1190
+    var weekOffset = firstWeekOffset(mom.year(), dow, doy),
1191
+        week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
1192
+        resWeek, resYear;
1193
+
1194
+    if (week < 1) {
1195
+        resYear = mom.year() - 1;
1196
+        resWeek = week + weeksInYear(resYear, dow, doy);
1197
+    } else if (week > weeksInYear(mom.year(), dow, doy)) {
1198
+        resWeek = week - weeksInYear(mom.year(), dow, doy);
1199
+        resYear = mom.year() + 1;
1200
+    } else {
1201
+        resYear = mom.year();
1202
+        resWeek = week;
1203
+    }
1204
+
1205
+    return {
1206
+        week: resWeek,
1207
+        year: resYear
1208
+    };
1209
+}
1210
+
1211
+function weeksInYear(year, dow, doy) {
1212
+    var weekOffset = firstWeekOffset(year, dow, doy),
1213
+        weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
1214
+    return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
1215
+}
1216
+
1217
+// FORMATTING
1218
+
1219
+addFormatToken('w', ['ww', 2], 'wo', 'week');
1220
+addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
1221
+
1222
+// ALIASES
1223
+
1224
+addUnitAlias('week', 'w');
1225
+addUnitAlias('isoWeek', 'W');
1226
+
1227
+// PRIORITIES
1228
+
1229
+addUnitPriority('week', 5);
1230
+addUnitPriority('isoWeek', 5);
1231
+
1232
+// PARSING
1233
+
1234
+addRegexToken('w',  match1to2);
1235
+addRegexToken('ww', match1to2, match2);
1236
+addRegexToken('W',  match1to2);
1237
+addRegexToken('WW', match1to2, match2);
1238
+
1239
+addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
1240
+    week[token.substr(0, 1)] = toInt(input);
1241
+});
1242
+
1243
+// HELPERS
1244
+
1245
+// LOCALES
1246
+
1247
+function localeWeek (mom) {
1248
+    return weekOfYear(mom, this._week.dow, this._week.doy).week;
1249
+}
1250
+
1251
+var defaultLocaleWeek = {
1252
+    dow : 0, // Sunday is the first day of the week.
1253
+    doy : 6  // The week that contains Jan 1st is the first week of the year.
1254
+};
1255
+
1256
+function localeFirstDayOfWeek () {
1257
+    return this._week.dow;
1258
+}
1259
+
1260
+function localeFirstDayOfYear () {
1261
+    return this._week.doy;
1262
+}
1263
+
1264
+// MOMENTS
1265
+
1266
+function getSetWeek (input) {
1267
+    var week = this.localeData().week(this);
1268
+    return input == null ? week : this.add((input - week) * 7, 'd');
1269
+}
1270
+
1271
+function getSetISOWeek (input) {
1272
+    var week = weekOfYear(this, 1, 4).week;
1273
+    return input == null ? week : this.add((input - week) * 7, 'd');
1274
+}
1275
+
1276
+// FORMATTING
1277
+
1278
+addFormatToken('d', 0, 'do', 'day');
1279
+
1280
+addFormatToken('dd', 0, 0, function (format) {
1281
+    return this.localeData().weekdaysMin(this, format);
1282
+});
1283
+
1284
+addFormatToken('ddd', 0, 0, function (format) {
1285
+    return this.localeData().weekdaysShort(this, format);
1286
+});
1287
+
1288
+addFormatToken('dddd', 0, 0, function (format) {
1289
+    return this.localeData().weekdays(this, format);
1290
+});
1291
+
1292
+addFormatToken('e', 0, 0, 'weekday');
1293
+addFormatToken('E', 0, 0, 'isoWeekday');
1294
+
1295
+// ALIASES
1296
+
1297
+addUnitAlias('day', 'd');
1298
+addUnitAlias('weekday', 'e');
1299
+addUnitAlias('isoWeekday', 'E');
1300
+
1301
+// PRIORITY
1302
+addUnitPriority('day', 11);
1303
+addUnitPriority('weekday', 11);
1304
+addUnitPriority('isoWeekday', 11);
1305
+
1306
+// PARSING
1307
+
1308
+addRegexToken('d',    match1to2);
1309
+addRegexToken('e',    match1to2);
1310
+addRegexToken('E',    match1to2);
1311
+addRegexToken('dd',   function (isStrict, locale) {
1312
+    return locale.weekdaysMinRegex(isStrict);
1313
+});
1314
+addRegexToken('ddd',   function (isStrict, locale) {
1315
+    return locale.weekdaysShortRegex(isStrict);
1316
+});
1317
+addRegexToken('dddd',   function (isStrict, locale) {
1318
+    return locale.weekdaysRegex(isStrict);
1319
+});
1320
+
1321
+addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
1322
+    var weekday = config._locale.weekdaysParse(input, token, config._strict);
1323
+    // if we didn't get a weekday name, mark the date as invalid
1324
+    if (weekday != null) {
1325
+        week.d = weekday;
1326
+    } else {
1327
+        getParsingFlags(config).invalidWeekday = input;
1328
+    }
1329
+});
1330
+
1331
+addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
1332
+    week[token] = toInt(input);
1333
+});
1334
+
1335
+// HELPERS
1336
+
1337
+function parseWeekday(input, locale) {
1338
+    if (typeof input !== 'string') {
1339
+        return input;
1340
+    }
1341
+
1342
+    if (!isNaN(input)) {
1343
+        return parseInt(input, 10);
1344
+    }
1345
+
1346
+    input = locale.weekdaysParse(input);
1347
+    if (typeof input === 'number') {
1348
+        return input;
1349
+    }
1350
+
1351
+    return null;
1352
+}
1353
+
1354
+function parseIsoWeekday(input, locale) {
1355
+    if (typeof input === 'string') {
1356
+        return locale.weekdaysParse(input) % 7 || 7;
1357
+    }
1358
+    return isNaN(input) ? null : input;
1359
+}
1360
+
1361
+// LOCALES
1362
+
1363
+var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
1364
+function localeWeekdays (m, format) {
1365
+    if (!m) {
1366
+        return isArray(this._weekdays) ? this._weekdays :
1367
+            this._weekdays['standalone'];
1368
+    }
1369
+    return isArray(this._weekdays) ? this._weekdays[m.day()] :
1370
+        this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
1371
+}
1372
+
1373
+var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
1374
+function localeWeekdaysShort (m) {
1375
+    return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
1376
+}
1377
+
1378
+var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
1379
+function localeWeekdaysMin (m) {
1380
+    return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
1381
+}
1382
+
1383
+function handleStrictParse$1(weekdayName, format, strict) {
1384
+    var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
1385
+    if (!this._weekdaysParse) {
1386
+        this._weekdaysParse = [];
1387
+        this._shortWeekdaysParse = [];
1388
+        this._minWeekdaysParse = [];
1389
+
1390
+        for (i = 0; i < 7; ++i) {
1391
+            mom = createUTC([2000, 1]).day(i);
1392
+            this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
1393
+            this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
1394
+            this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
1395
+        }
1396
+    }
1397
+
1398
+    if (strict) {
1399
+        if (format === 'dddd') {
1400
+            ii = indexOf$1.call(this._weekdaysParse, llc);
1401
+            return ii !== -1 ? ii : null;
1402
+        } else if (format === 'ddd') {
1403
+            ii = indexOf$1.call(this._shortWeekdaysParse, llc);
1404
+            return ii !== -1 ? ii : null;
1405
+        } else {
1406
+            ii = indexOf$1.call(this._minWeekdaysParse, llc);
1407
+            return ii !== -1 ? ii : null;
1408
+        }
1409
+    } else {
1410
+        if (format === 'dddd') {
1411
+            ii = indexOf$1.call(this._weekdaysParse, llc);
1412
+            if (ii !== -1) {
1413
+                return ii;
1414
+            }
1415
+            ii = indexOf$1.call(this._shortWeekdaysParse, llc);
1416
+            if (ii !== -1) {
1417
+                return ii;
1418
+            }
1419
+            ii = indexOf$1.call(this._minWeekdaysParse, llc);
1420
+            return ii !== -1 ? ii : null;
1421
+        } else if (format === 'ddd') {
1422
+            ii = indexOf$1.call(this._shortWeekdaysParse, llc);
1423
+            if (ii !== -1) {
1424
+                return ii;
1425
+            }
1426
+            ii = indexOf$1.call(this._weekdaysParse, llc);
1427
+            if (ii !== -1) {
1428
+                return ii;
1429
+            }
1430
+            ii = indexOf$1.call(this._minWeekdaysParse, llc);
1431
+            return ii !== -1 ? ii : null;
1432
+        } else {
1433
+            ii = indexOf$1.call(this._minWeekdaysParse, llc);
1434
+            if (ii !== -1) {
1435
+                return ii;
1436
+            }
1437
+            ii = indexOf$1.call(this._weekdaysParse, llc);
1438
+            if (ii !== -1) {
1439
+                return ii;
1440
+            }
1441
+            ii = indexOf$1.call(this._shortWeekdaysParse, llc);
1442
+            return ii !== -1 ? ii : null;
1443
+        }
1444
+    }
1445
+}
1446
+
1447
+function localeWeekdaysParse (weekdayName, format, strict) {
1448
+    var i, mom, regex;
1449
+
1450
+    if (this._weekdaysParseExact) {
1451
+        return handleStrictParse$1.call(this, weekdayName, format, strict);
1452
+    }
1453
+
1454
+    if (!this._weekdaysParse) {
1455
+        this._weekdaysParse = [];
1456
+        this._minWeekdaysParse = [];
1457
+        this._shortWeekdaysParse = [];
1458
+        this._fullWeekdaysParse = [];
1459
+    }
1460
+
1461
+    for (i = 0; i < 7; i++) {
1462
+        // make the regex if we don't have it already
1463
+
1464
+        mom = createUTC([2000, 1]).day(i);
1465
+        if (strict && !this._fullWeekdaysParse[i]) {
1466
+            this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
1467
+            this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
1468
+            this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
1469
+        }
1470
+        if (!this._weekdaysParse[i]) {
1471
+            regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
1472
+            this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
1473
+        }
1474
+        // test the regex
1475
+        if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
1476
+            return i;
1477
+        } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
1478
+            return i;
1479
+        } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
1480
+            return i;
1481
+        } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
1482
+            return i;
1483
+        }
1484
+    }
1485
+}
1486
+
1487
+// MOMENTS
1488
+
1489
+function getSetDayOfWeek (input) {
1490
+    if (!this.isValid()) {
1491
+        return input != null ? this : NaN;
1492
+    }
1493
+    var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
1494
+    if (input != null) {
1495
+        input = parseWeekday(input, this.localeData());
1496
+        return this.add(input - day, 'd');
1497
+    } else {
1498
+        return day;
1499
+    }
1500
+}
1501
+
1502
+function getSetLocaleDayOfWeek (input) {
1503
+    if (!this.isValid()) {
1504
+        return input != null ? this : NaN;
1505
+    }
1506
+    var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
1507
+    return input == null ? weekday : this.add(input - weekday, 'd');
1508
+}
1509
+
1510
+function getSetISODayOfWeek (input) {
1511
+    if (!this.isValid()) {
1512
+        return input != null ? this : NaN;
1513
+    }
1514
+
1515
+    // behaves the same as moment#day except
1516
+    // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
1517
+    // as a setter, sunday should belong to the previous week.
1518
+
1519
+    if (input != null) {
1520
+        var weekday = parseIsoWeekday(input, this.localeData());
1521
+        return this.day(this.day() % 7 ? weekday : weekday - 7);
1522
+    } else {
1523
+        return this.day() || 7;
1524
+    }
1525
+}
1526
+
1527
+var defaultWeekdaysRegex = matchWord;
1528
+function weekdaysRegex (isStrict) {
1529
+    if (this._weekdaysParseExact) {
1530
+        if (!hasOwnProp(this, '_weekdaysRegex')) {
1531
+            computeWeekdaysParse.call(this);
1532
+        }
1533
+        if (isStrict) {
1534
+            return this._weekdaysStrictRegex;
1535
+        } else {
1536
+            return this._weekdaysRegex;
1537
+        }
1538
+    } else {
1539
+        if (!hasOwnProp(this, '_weekdaysRegex')) {
1540
+            this._weekdaysRegex = defaultWeekdaysRegex;
1541
+        }
1542
+        return this._weekdaysStrictRegex && isStrict ?
1543
+            this._weekdaysStrictRegex : this._weekdaysRegex;
1544
+    }
1545
+}
1546
+
1547
+var defaultWeekdaysShortRegex = matchWord;
1548
+function weekdaysShortRegex (isStrict) {
1549
+    if (this._weekdaysParseExact) {
1550
+        if (!hasOwnProp(this, '_weekdaysRegex')) {
1551
+            computeWeekdaysParse.call(this);
1552
+        }
1553
+        if (isStrict) {
1554
+            return this._weekdaysShortStrictRegex;
1555
+        } else {
1556
+            return this._weekdaysShortRegex;
1557
+        }
1558
+    } else {
1559
+        if (!hasOwnProp(this, '_weekdaysShortRegex')) {
1560
+            this._weekdaysShortRegex = defaultWeekdaysShortRegex;
1561
+        }
1562
+        return this._weekdaysShortStrictRegex && isStrict ?
1563
+            this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
1564
+    }
1565
+}
1566
+
1567
+var defaultWeekdaysMinRegex = matchWord;
1568
+function weekdaysMinRegex (isStrict) {
1569
+    if (this._weekdaysParseExact) {
1570
+        if (!hasOwnProp(this, '_weekdaysRegex')) {
1571
+            computeWeekdaysParse.call(this);
1572
+        }
1573
+        if (isStrict) {
1574
+            return this._weekdaysMinStrictRegex;
1575
+        } else {
1576
+            return this._weekdaysMinRegex;
1577
+        }
1578
+    } else {
1579
+        if (!hasOwnProp(this, '_weekdaysMinRegex')) {
1580
+            this._weekdaysMinRegex = defaultWeekdaysMinRegex;
1581
+        }
1582
+        return this._weekdaysMinStrictRegex && isStrict ?
1583
+            this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
1584
+    }
1585
+}
1586
+
1587
+
1588
+function computeWeekdaysParse () {
1589
+    function cmpLenRev(a, b) {
1590
+        return b.length - a.length;
1591
+    }
1592
+
1593
+    var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
1594
+        i, mom, minp, shortp, longp;
1595
+    for (i = 0; i < 7; i++) {
1596
+        // make the regex if we don't have it already
1597
+        mom = createUTC([2000, 1]).day(i);
1598
+        minp = this.weekdaysMin(mom, '');
1599
+        shortp = this.weekdaysShort(mom, '');
1600
+        longp = this.weekdays(mom, '');
1601
+        minPieces.push(minp);
1602
+        shortPieces.push(shortp);
1603
+        longPieces.push(longp);
1604
+        mixedPieces.push(minp);
1605
+        mixedPieces.push(shortp);
1606
+        mixedPieces.push(longp);
1607
+    }
1608
+    // Sorting makes sure if one weekday (or abbr) is a prefix of another it
1609
+    // will match the longer piece.
1610
+    minPieces.sort(cmpLenRev);
1611
+    shortPieces.sort(cmpLenRev);
1612
+    longPieces.sort(cmpLenRev);
1613
+    mixedPieces.sort(cmpLenRev);
1614
+    for (i = 0; i < 7; i++) {
1615
+        shortPieces[i] = regexEscape(shortPieces[i]);
1616
+        longPieces[i] = regexEscape(longPieces[i]);
1617
+        mixedPieces[i] = regexEscape(mixedPieces[i]);
1618
+    }
1619
+
1620
+    this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
1621
+    this._weekdaysShortRegex = this._weekdaysRegex;
1622
+    this._weekdaysMinRegex = this._weekdaysRegex;
1623
+
1624
+    this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
1625
+    this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
1626
+    this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
1627
+}
1628
+
1629
+// FORMATTING
1630
+
1631
+function hFormat() {
1632
+    return this.hours() % 12 || 12;
1633
+}
1634
+
1635
+function kFormat() {
1636
+    return this.hours() || 24;
1637
+}
1638
+
1639
+addFormatToken('H', ['HH', 2], 0, 'hour');
1640
+addFormatToken('h', ['hh', 2], 0, hFormat);
1641
+addFormatToken('k', ['kk', 2], 0, kFormat);
1642
+
1643
+addFormatToken('hmm', 0, 0, function () {
1644
+    return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
1645
+});
1646
+
1647
+addFormatToken('hmmss', 0, 0, function () {
1648
+    return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) +
1649
+        zeroFill(this.seconds(), 2);
1650
+});
1651
+
1652
+addFormatToken('Hmm', 0, 0, function () {
1653
+    return '' + this.hours() + zeroFill(this.minutes(), 2);
1654
+});
1655
+
1656
+addFormatToken('Hmmss', 0, 0, function () {
1657
+    return '' + this.hours() + zeroFill(this.minutes(), 2) +
1658
+        zeroFill(this.seconds(), 2);
1659
+});
1660
+
1661
+function meridiem (token, lowercase) {
1662
+    addFormatToken(token, 0, 0, function () {
1663
+        return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
1664
+    });
1665
+}
1666
+
1667
+meridiem('a', true);
1668
+meridiem('A', false);
1669
+
1670
+// ALIASES
1671
+
1672
+addUnitAlias('hour', 'h');
1673
+
1674
+// PRIORITY
1675
+addUnitPriority('hour', 13);
1676
+
1677
+// PARSING
1678
+
1679
+function matchMeridiem (isStrict, locale) {
1680
+    return locale._meridiemParse;
1681
+}
1682
+
1683
+addRegexToken('a',  matchMeridiem);
1684
+addRegexToken('A',  matchMeridiem);
1685
+addRegexToken('H',  match1to2);
1686
+addRegexToken('h',  match1to2);
1687
+addRegexToken('k',  match1to2);
1688
+addRegexToken('HH', match1to2, match2);
1689
+addRegexToken('hh', match1to2, match2);
1690
+addRegexToken('kk', match1to2, match2);
1691
+
1692
+addRegexToken('hmm', match3to4);
1693
+addRegexToken('hmmss', match5to6);
1694
+addRegexToken('Hmm', match3to4);
1695
+addRegexToken('Hmmss', match5to6);
1696
+
1697
+addParseToken(['H', 'HH'], HOUR);
1698
+addParseToken(['k', 'kk'], function (input, array, config) {
1699
+    var kInput = toInt(input);
1700
+    array[HOUR] = kInput === 24 ? 0 : kInput;
1701
+});
1702
+addParseToken(['a', 'A'], function (input, array, config) {
1703
+    config._isPm = config._locale.isPM(input);
1704
+    config._meridiem = input;
1705
+});
1706
+addParseToken(['h', 'hh'], function (input, array, config) {
1707
+    array[HOUR] = toInt(input);
1708
+    getParsingFlags(config).bigHour = true;
1709
+});
1710
+addParseToken('hmm', function (input, array, config) {
1711
+    var pos = input.length - 2;
1712
+    array[HOUR] = toInt(input.substr(0, pos));
1713
+    array[MINUTE] = toInt(input.substr(pos));
1714
+    getParsingFlags(config).bigHour = true;
1715
+});
1716
+addParseToken('hmmss', function (input, array, config) {
1717
+    var pos1 = input.length - 4;
1718
+    var pos2 = input.length - 2;
1719
+    array[HOUR] = toInt(input.substr(0, pos1));
1720
+    array[MINUTE] = toInt(input.substr(pos1, 2));
1721
+    array[SECOND] = toInt(input.substr(pos2));
1722
+    getParsingFlags(config).bigHour = true;
1723
+});
1724
+addParseToken('Hmm', function (input, array, config) {
1725
+    var pos = input.length - 2;
1726
+    array[HOUR] = toInt(input.substr(0, pos));
1727
+    array[MINUTE] = toInt(input.substr(pos));
1728
+});
1729
+addParseToken('Hmmss', function (input, array, config) {
1730
+    var pos1 = input.length - 4;
1731
+    var pos2 = input.length - 2;
1732
+    array[HOUR] = toInt(input.substr(0, pos1));
1733
+    array[MINUTE] = toInt(input.substr(pos1, 2));
1734
+    array[SECOND] = toInt(input.substr(pos2));
1735
+});
1736
+
1737
+// LOCALES
1738
+
1739
+function localeIsPM (input) {
1740
+    // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
1741
+    // Using charAt should be more compatible.
1742
+    return ((input + '').toLowerCase().charAt(0) === 'p');
1743
+}
1744
+
1745
+var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
1746
+function localeMeridiem (hours, minutes, isLower) {
1747
+    if (hours > 11) {
1748
+        return isLower ? 'pm' : 'PM';
1749
+    } else {
1750
+        return isLower ? 'am' : 'AM';
1751
+    }
1752
+}
1753
+
1754
+
1755
+// MOMENTS
1756
+
1757
+// Setting the hour should keep the time, because the user explicitly
1758
+// specified which hour he wants. So trying to maintain the same hour (in
1759
+// a new timezone) makes sense. Adding/subtracting hours does not follow
1760
+// this rule.
1761
+var getSetHour = makeGetSet('Hours', true);
1762
+
1763
+// months
1764
+// week
1765
+// weekdays
1766
+// meridiem
1767
+var baseConfig = {
1768
+    calendar: defaultCalendar,
1769
+    longDateFormat: defaultLongDateFormat,
1770
+    invalidDate: defaultInvalidDate,
1771
+    ordinal: defaultOrdinal,
1772
+    dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
1773
+    relativeTime: defaultRelativeTime,
1774
+
1775
+    months: defaultLocaleMonths,
1776
+    monthsShort: defaultLocaleMonthsShort,
1777
+
1778
+    week: defaultLocaleWeek,
1779
+
1780
+    weekdays: defaultLocaleWeekdays,
1781
+    weekdaysMin: defaultLocaleWeekdaysMin,
1782
+    weekdaysShort: defaultLocaleWeekdaysShort,
1783
+
1784
+    meridiemParse: defaultLocaleMeridiemParse
1785
+};
1786
+
1787
+// internal storage for locale config files
1788
+var locales = {};
1789
+var localeFamilies = {};
1790
+var globalLocale;
1791
+
1792
+function normalizeLocale(key) {
1793
+    return key ? key.toLowerCase().replace('_', '-') : key;
1794
+}
1795
+
1796
+// pick the locale from the array
1797
+// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
1798
+// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
1799
+function chooseLocale(names) {
1800
+    var i = 0, j, next, locale, split;
1801
+
1802
+    while (i < names.length) {
1803
+        split = normalizeLocale(names[i]).split('-');
1804
+        j = split.length;
1805
+        next = normalizeLocale(names[i + 1]);
1806
+        next = next ? next.split('-') : null;
1807
+        while (j > 0) {
1808
+            locale = loadLocale(split.slice(0, j).join('-'));
1809
+            if (locale) {
1810
+                return locale;
1811
+            }
1812
+            if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
1813
+                //the next array item is better than a shallower substring of this one
1814
+                break;
1815
+            }
1816
+            j--;
1817
+        }
1818
+        i++;
1819
+    }
1820
+    return null;
1821
+}
1822
+
1823
+function loadLocale(name) {
1824
+    var oldLocale = null;
1825
+    // TODO: Find a better way to register and load all the locales in Node
1826
+    if (!locales[name] && (typeof module !== 'undefined') &&
1827
+            module && module.exports) {
1828
+        try {
1829
+            oldLocale = globalLocale._abbr;
1830
+            require('./locale/' + name);
1831
+            // because defineLocale currently also sets the global locale, we
1832
+            // want to undo that for lazy loaded locales
1833
+            getSetGlobalLocale(oldLocale);
1834
+        } catch (e) { }
1835
+    }
1836
+    return locales[name];
1837
+}
1838
+
1839
+// This function will load locale and then set the global locale.  If
1840
+// no arguments are passed in, it will simply return the current global
1841
+// locale key.
1842
+function getSetGlobalLocale (key, values) {
1843
+    var data;
1844
+    if (key) {
1845
+        if (isUndefined(values)) {
1846
+            data = getLocale(key);
1847
+        }
1848
+        else {
1849
+            data = defineLocale(key, values);
1850
+        }
1851
+
1852
+        if (data) {
1853
+            // moment.duration._locale = moment._locale = data;
1854
+            globalLocale = data;
1855
+        }
1856
+    }
1857
+
1858
+    return globalLocale._abbr;
1859
+}
1860
+
1861
+function defineLocale (name, config) {
1862
+    if (config !== null) {
1863
+        var parentConfig = baseConfig;
1864
+        config.abbr = name;
1865
+        if (locales[name] != null) {
1866
+            deprecateSimple('defineLocaleOverride',
1867
+                    'use moment.updateLocale(localeName, config) to change ' +
1868
+                    'an existing locale. moment.defineLocale(localeName, ' +
1869
+                    'config) should only be used for creating a new locale ' +
1870
+                    'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
1871
+            parentConfig = locales[name]._config;
1872
+        } else if (config.parentLocale != null) {
1873
+            if (locales[config.parentLocale] != null) {
1874
+                parentConfig = locales[config.parentLocale]._config;
1875
+            } else {
1876
+                if (!localeFamilies[config.parentLocale]) {
1877
+                    localeFamilies[config.parentLocale] = [];
1878
+                }
1879
+                localeFamilies[config.parentLocale].push({
1880
+                    name: name,
1881
+                    config: config
1882
+                });
1883
+                return null;
1884
+            }
1885
+        }
1886
+        locales[name] = new Locale(mergeConfigs(parentConfig, config));
1887
+
1888
+        if (localeFamilies[name]) {
1889
+            localeFamilies[name].forEach(function (x) {
1890
+                defineLocale(x.name, x.config);
1891
+            });
1892
+        }
1893
+
1894
+        // backwards compat for now: also set the locale
1895
+        // make sure we set the locale AFTER all child locales have been
1896
+        // created, so we won't end up with the child locale set.
1897
+        getSetGlobalLocale(name);
1898
+
1899
+
1900
+        return locales[name];
1901
+    } else {
1902
+        // useful for testing
1903
+        delete locales[name];
1904
+        return null;
1905
+    }
1906
+}
1907
+
1908
+function updateLocale(name, config) {
1909
+    if (config != null) {
1910
+        var locale, parentConfig = baseConfig;
1911
+        // MERGE
1912
+        if (locales[name] != null) {
1913
+            parentConfig = locales[name]._config;
1914
+        }
1915
+        config = mergeConfigs(parentConfig, config);
1916
+        locale = new Locale(config);
1917
+        locale.parentLocale = locales[name];
1918
+        locales[name] = locale;
1919
+
1920
+        // backwards compat for now: also set the locale
1921
+        getSetGlobalLocale(name);
1922
+    } else {
1923
+        // pass null for config to unupdate, useful for tests
1924
+        if (locales[name] != null) {
1925
+            if (locales[name].parentLocale != null) {
1926
+                locales[name] = locales[name].parentLocale;
1927
+            } else if (locales[name] != null) {
1928
+                delete locales[name];
1929
+            }
1930
+        }
1931
+    }
1932
+    return locales[name];
1933
+}
1934
+
1935
+// returns locale data
1936
+function getLocale (key) {
1937
+    var locale;
1938
+
1939
+    if (key && key._locale && key._locale._abbr) {
1940
+        key = key._locale._abbr;
1941
+    }
1942
+
1943
+    if (!key) {
1944
+        return globalLocale;
1945
+    }
1946
+
1947
+    if (!isArray(key)) {
1948
+        //short-circuit everything else
1949
+        locale = loadLocale(key);
1950
+        if (locale) {
1951
+            return locale;
1952
+        }
1953
+        key = [key];
1954
+    }
1955
+
1956
+    return chooseLocale(key);
1957
+}
1958
+
1959
+function listLocales() {
1960
+    return keys$1(locales);
1961
+}
1962
+
1963
+function checkOverflow (m) {
1964
+    var overflow;
1965
+    var a = m._a;
1966
+
1967
+    if (a && getParsingFlags(m).overflow === -2) {
1968
+        overflow =
1969
+            a[MONTH]       < 0 || a[MONTH]       > 11  ? MONTH :
1970
+            a[DATE]        < 1 || a[DATE]        > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
1971
+            a[HOUR]        < 0 || a[HOUR]        > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
1972
+            a[MINUTE]      < 0 || a[MINUTE]      > 59  ? MINUTE :
1973
+            a[SECOND]      < 0 || a[SECOND]      > 59  ? SECOND :
1974
+            a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
1975
+            -1;
1976
+
1977
+        if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
1978
+            overflow = DATE;
1979
+        }
1980
+        if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
1981
+            overflow = WEEK;
1982
+        }
1983
+        if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
1984
+            overflow = WEEKDAY;
1985
+        }
1986
+
1987
+        getParsingFlags(m).overflow = overflow;
1988
+    }
1989
+
1990
+    return m;
1991
+}
1992
+
1993
+// iso 8601 regex
1994
+// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
1995
+var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
1996
+var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
1997
+
1998
+var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
1999
+
2000
+var isoDates = [
2001
+    ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
2002
+    ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
2003
+    ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
2004
+    ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
2005
+    ['YYYY-DDD', /\d{4}-\d{3}/],
2006
+    ['YYYY-MM', /\d{4}-\d\d/, false],
2007
+    ['YYYYYYMMDD', /[+-]\d{10}/],
2008
+    ['YYYYMMDD', /\d{8}/],
2009
+    // YYYYMM is NOT allowed by the standard
2010
+    ['GGGG[W]WWE', /\d{4}W\d{3}/],
2011
+    ['GGGG[W]WW', /\d{4}W\d{2}/, false],
2012
+    ['YYYYDDD', /\d{7}/]
2013
+];
2014
+
2015
+// iso time formats and regexes
2016
+var isoTimes = [
2017
+    ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
2018
+    ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
2019
+    ['HH:mm:ss', /\d\d:\d\d:\d\d/],
2020
+    ['HH:mm', /\d\d:\d\d/],
2021
+    ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
2022
+    ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
2023
+    ['HHmmss', /\d\d\d\d\d\d/],
2024
+    ['HHmm', /\d\d\d\d/],
2025
+    ['HH', /\d\d/]
2026
+];
2027
+
2028
+var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
2029
+
2030
+// date from iso format
2031
+function configFromISO(config) {
2032
+    var i, l,
2033
+        string = config._i,
2034
+        match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
2035
+        allowTime, dateFormat, timeFormat, tzFormat;
2036
+
2037
+    if (match) {
2038
+        getParsingFlags(config).iso = true;
2039
+
2040
+        for (i = 0, l = isoDates.length; i < l; i++) {
2041
+            if (isoDates[i][1].exec(match[1])) {
2042
+                dateFormat = isoDates[i][0];
2043
+                allowTime = isoDates[i][2] !== false;
2044
+                break;
2045
+            }
2046
+        }
2047
+        if (dateFormat == null) {
2048
+            config._isValid = false;
2049
+            return;
2050
+        }
2051
+        if (match[3]) {
2052
+            for (i = 0, l = isoTimes.length; i < l; i++) {
2053
+                if (isoTimes[i][1].exec(match[3])) {
2054
+                    // match[2] should be 'T' or space
2055
+                    timeFormat = (match[2] || ' ') + isoTimes[i][0];
2056
+                    break;
2057
+                }
2058
+            }
2059
+            if (timeFormat == null) {
2060
+                config._isValid = false;
2061
+                return;
2062
+            }
2063
+        }
2064
+        if (!allowTime && timeFormat != null) {
2065
+            config._isValid = false;
2066
+            return;
2067
+        }
2068
+        if (match[4]) {
2069
+            if (tzRegex.exec(match[4])) {
2070
+                tzFormat = 'Z';
2071
+            } else {
2072
+                config._isValid = false;
2073
+                return;
2074
+            }
2075
+        }
2076
+        config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
2077
+        configFromStringAndFormat(config);
2078
+    } else {
2079
+        config._isValid = false;
2080
+    }
2081
+}
2082
+
2083
+// RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
2084
+var basicRfcRegex = /^((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d?\d\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?:\d\d)?\d\d\s)(\d\d:\d\d)(\:\d\d)?(\s(?:UT|GMT|[ECMP][SD]T|[A-IK-Za-ik-z]|[+-]\d{4}))$/;
2085
+
2086
+// date and time from ref 2822 format
2087
+function configFromRFC2822(config) {
2088
+    var string, match, dayFormat,
2089
+        dateFormat, timeFormat, tzFormat;
2090
+    var timezones = {
2091
+        ' GMT': ' +0000',
2092
+        ' EDT': ' -0400',
2093
+        ' EST': ' -0500',
2094
+        ' CDT': ' -0500',
2095
+        ' CST': ' -0600',
2096
+        ' MDT': ' -0600',
2097
+        ' MST': ' -0700',
2098
+        ' PDT': ' -0700',
2099
+        ' PST': ' -0800'
2100
+    };
2101
+    var military = 'YXWVUTSRQPONZABCDEFGHIKLM';
2102
+    var timezone, timezoneIndex;
2103
+
2104
+    string = config._i
2105
+        .replace(/\([^\)]*\)|[\n\t]/g, ' ') // Remove comments and folding whitespace
2106
+        .replace(/(\s\s+)/g, ' ') // Replace multiple-spaces with a single space
2107
+        .replace(/^\s|\s$/g, ''); // Remove leading and trailing spaces
2108
+    match = basicRfcRegex.exec(string);
2109
+
2110
+    if (match) {
2111
+        dayFormat = match[1] ? 'ddd' + ((match[1].length === 5) ? ', ' : ' ') : '';
2112
+        dateFormat = 'D MMM ' + ((match[2].length > 10) ? 'YYYY ' : 'YY ');
2113
+        timeFormat = 'HH:mm' + (match[4] ? ':ss' : '');
2114
+
2115
+        // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
2116
+        if (match[1]) { // day of week given
2117
+            var momentDate = new Date(match[2]);
2118
+            var momentDay = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][momentDate.getDay()];
2119
+
2120
+            if (match[1].substr(0,3) !== momentDay) {
2121
+                getParsingFlags(config).weekdayMismatch = true;
2122
+                config._isValid = false;
2123
+                return;
2124
+            }
2125
+        }
2126
+
2127
+        switch (match[5].length) {
2128
+            case 2: // military
2129
+                if (timezoneIndex === 0) {
2130
+                    timezone = ' +0000';
2131
+                } else {
2132
+                    timezoneIndex = military.indexOf(match[5][1].toUpperCase()) - 12;
2133
+                    timezone = ((timezoneIndex < 0) ? ' -' : ' +') +
2134
+                        (('' + timezoneIndex).replace(/^-?/, '0')).match(/..$/)[0] + '00';
2135
+                }
2136
+                break;
2137
+            case 4: // Zone
2138
+                timezone = timezones[match[5]];
2139
+                break;
2140
+            default: // UT or +/-9999
2141
+                timezone = timezones[' GMT'];
2142
+        }
2143
+        match[5] = timezone;
2144
+        config._i = match.splice(1).join('');
2145
+        tzFormat = ' ZZ';
2146
+        config._f = dayFormat + dateFormat + timeFormat + tzFormat;
2147
+        configFromStringAndFormat(config);
2148
+        getParsingFlags(config).rfc2822 = true;
2149
+    } else {
2150
+        config._isValid = false;
2151
+    }
2152
+}
2153
+
2154
+// date from iso format or fallback
2155
+function configFromString(config) {
2156
+    var matched = aspNetJsonRegex.exec(config._i);
2157
+
2158
+    if (matched !== null) {
2159
+        config._d = new Date(+matched[1]);
2160
+        return;
2161
+    }
2162
+
2163
+    configFromISO(config);
2164
+    if (config._isValid === false) {
2165
+        delete config._isValid;
2166
+    } else {
2167
+        return;
2168
+    }
2169
+
2170
+    configFromRFC2822(config);
2171
+    if (config._isValid === false) {
2172
+        delete config._isValid;
2173
+    } else {
2174
+        return;
2175
+    }
2176
+
2177
+    // Final attempt, use Input Fallback
2178
+    hooks.createFromInputFallback(config);
2179
+}
2180
+
2181
+hooks.createFromInputFallback = deprecate(
2182
+    'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
2183
+    'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
2184
+    'discouraged and will be removed in an upcoming major release. Please refer to ' +
2185
+    'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
2186
+    function (config) {
2187
+        config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
2188
+    }
2189
+);
2190
+
2191
+// Pick the first defined of two or three arguments.
2192
+function defaults(a, b, c) {
2193
+    if (a != null) {
2194
+        return a;
2195
+    }
2196
+    if (b != null) {
2197
+        return b;
2198
+    }
2199
+    return c;
2200
+}
2201
+
2202
+function currentDateArray(config) {
2203
+    // hooks is actually the exported moment object
2204
+    var nowValue = new Date(hooks.now());
2205
+    if (config._useUTC) {
2206
+        return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
2207
+    }
2208
+    return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
2209
+}
2210
+
2211
+// convert an array to a date.
2212
+// the array should mirror the parameters below
2213
+// note: all values past the year are optional and will default to the lowest possible value.
2214
+// [year, month, day , hour, minute, second, millisecond]
2215
+function configFromArray (config) {
2216
+    var i, date, input = [], currentDate, yearToUse;
2217
+
2218
+    if (config._d) {
2219
+        return;
2220
+    }
2221
+
2222
+    currentDate = currentDateArray(config);
2223
+
2224
+    //compute day of the year from weeks and weekdays
2225
+    if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
2226
+        dayOfYearFromWeekInfo(config);
2227
+    }
2228
+
2229
+    //if the day of the year is set, figure out what it is
2230
+    if (config._dayOfYear != null) {
2231
+        yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
2232
+
2233
+        if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
2234
+            getParsingFlags(config)._overflowDayOfYear = true;
2235
+        }
2236
+
2237
+        date = createUTCDate(yearToUse, 0, config._dayOfYear);
2238
+        config._a[MONTH] = date.getUTCMonth();
2239
+        config._a[DATE] = date.getUTCDate();
2240
+    }
2241
+
2242
+    // Default to current date.
2243
+    // * if no year, month, day of month are given, default to today
2244
+    // * if day of month is given, default month and year
2245
+    // * if month is given, default only year
2246
+    // * if year is given, don't default anything
2247
+    for (i = 0; i < 3 && config._a[i] == null; ++i) {
2248
+        config._a[i] = input[i] = currentDate[i];
2249
+    }
2250
+
2251
+    // Zero out whatever was not defaulted, including time
2252
+    for (; i < 7; i++) {
2253
+        config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
2254
+    }
2255
+
2256
+    // Check for 24:00:00.000
2257
+    if (config._a[HOUR] === 24 &&
2258
+            config._a[MINUTE] === 0 &&
2259
+            config._a[SECOND] === 0 &&
2260
+            config._a[MILLISECOND] === 0) {
2261
+        config._nextDay = true;
2262
+        config._a[HOUR] = 0;
2263
+    }
2264
+
2265
+    config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
2266
+    // Apply timezone offset from input. The actual utcOffset can be changed
2267
+    // with parseZone.
2268
+    if (config._tzm != null) {
2269
+        config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
2270
+    }
2271
+
2272
+    if (config._nextDay) {
2273
+        config._a[HOUR] = 24;
2274
+    }
2275
+}
2276
+
2277
+function dayOfYearFromWeekInfo(config) {
2278
+    var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
2279
+
2280
+    w = config._w;
2281
+    if (w.GG != null || w.W != null || w.E != null) {
2282
+        dow = 1;
2283
+        doy = 4;
2284
+
2285
+        // TODO: We need to take the current isoWeekYear, but that depends on
2286
+        // how we interpret now (local, utc, fixed offset). So create
2287
+        // a now version of current config (take local/utc/offset flags, and
2288
+        // create now).
2289
+        weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
2290
+        week = defaults(w.W, 1);
2291
+        weekday = defaults(w.E, 1);
2292
+        if (weekday < 1 || weekday > 7) {
2293
+            weekdayOverflow = true;
2294
+        }
2295
+    } else {
2296
+        dow = config._locale._week.dow;
2297
+        doy = config._locale._week.doy;
2298
+
2299
+        var curWeek = weekOfYear(createLocal(), dow, doy);
2300
+
2301
+        weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
2302
+
2303
+        // Default to current week.
2304
+        week = defaults(w.w, curWeek.week);
2305
+
2306
+        if (w.d != null) {
2307
+            // weekday -- low day numbers are considered next week
2308
+            weekday = w.d;
2309
+            if (weekday < 0 || weekday > 6) {
2310
+                weekdayOverflow = true;
2311
+            }
2312
+        } else if (w.e != null) {
2313
+            // local weekday -- counting starts from begining of week
2314
+            weekday = w.e + dow;
2315
+            if (w.e < 0 || w.e > 6) {
2316
+                weekdayOverflow = true;
2317
+            }
2318
+        } else {
2319
+            // default to begining of week
2320
+            weekday = dow;
2321
+        }
2322
+    }
2323
+    if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
2324
+        getParsingFlags(config)._overflowWeeks = true;
2325
+    } else if (weekdayOverflow != null) {
2326
+        getParsingFlags(config)._overflowWeekday = true;
2327
+    } else {
2328
+        temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
2329
+        config._a[YEAR] = temp.year;
2330
+        config._dayOfYear = temp.dayOfYear;
2331
+    }
2332
+}
2333
+
2334
+// constant that refers to the ISO standard
2335
+hooks.ISO_8601 = function () {};
2336
+
2337
+// constant that refers to the RFC 2822 form
2338
+hooks.RFC_2822 = function () {};
2339
+
2340
+// date from string and format string
2341
+function configFromStringAndFormat(config) {
2342
+    // TODO: Move this to another part of the creation flow to prevent circular deps
2343
+    if (config._f === hooks.ISO_8601) {
2344
+        configFromISO(config);
2345
+        return;
2346
+    }
2347
+    if (config._f === hooks.RFC_2822) {
2348
+        configFromRFC2822(config);
2349
+        return;
2350
+    }
2351
+    config._a = [];
2352
+    getParsingFlags(config).empty = true;
2353
+
2354
+    // This array is used to make a Date, either with `new Date` or `Date.UTC`
2355
+    var string = '' + config._i,
2356
+        i, parsedInput, tokens, token, skipped,
2357
+        stringLength = string.length,
2358
+        totalParsedInputLength = 0;
2359
+
2360
+    tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
2361
+
2362
+    for (i = 0; i < tokens.length; i++) {
2363
+        token = tokens[i];
2364
+        parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
2365
+        // console.log('token', token, 'parsedInput', parsedInput,
2366
+        //         'regex', getParseRegexForToken(token, config));
2367
+        if (parsedInput) {
2368
+            skipped = string.substr(0, string.indexOf(parsedInput));
2369
+            if (skipped.length > 0) {
2370
+                getParsingFlags(config).unusedInput.push(skipped);
2371
+            }
2372
+            string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
2373
+            totalParsedInputLength += parsedInput.length;
2374
+        }
2375
+        // don't parse if it's not a known token
2376
+        if (formatTokenFunctions[token]) {
2377
+            if (parsedInput) {
2378
+                getParsingFlags(config).empty = false;
2379
+            }
2380
+            else {
2381
+                getParsingFlags(config).unusedTokens.push(token);
2382
+            }
2383
+            addTimeToArrayFromToken(token, parsedInput, config);
2384
+        }
2385
+        else if (config._strict && !parsedInput) {
2386
+            getParsingFlags(config).unusedTokens.push(token);
2387
+        }
2388
+    }
2389
+
2390
+    // add remaining unparsed input length to the string
2391
+    getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
2392
+    if (string.length > 0) {
2393
+        getParsingFlags(config).unusedInput.push(string);
2394
+    }
2395
+
2396
+    // clear _12h flag if hour is <= 12
2397
+    if (config._a[HOUR] <= 12 &&
2398
+        getParsingFlags(config).bigHour === true &&
2399
+        config._a[HOUR] > 0) {
2400
+        getParsingFlags(config).bigHour = undefined;
2401
+    }
2402
+
2403
+    getParsingFlags(config).parsedDateParts = config._a.slice(0);
2404
+    getParsingFlags(config).meridiem = config._meridiem;
2405
+    // handle meridiem
2406
+    config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
2407
+
2408
+    configFromArray(config);
2409
+    checkOverflow(config);
2410
+}
2411
+
2412
+
2413
+function meridiemFixWrap (locale, hour, meridiem) {
2414
+    var isPm;
2415
+
2416
+    if (meridiem == null) {
2417
+        // nothing to do
2418
+        return hour;
2419
+    }
2420
+    if (locale.meridiemHour != null) {
2421
+        return locale.meridiemHour(hour, meridiem);
2422
+    } else if (locale.isPM != null) {
2423
+        // Fallback
2424
+        isPm = locale.isPM(meridiem);
2425
+        if (isPm && hour < 12) {
2426
+            hour += 12;
2427
+        }
2428
+        if (!isPm && hour === 12) {
2429
+            hour = 0;
2430
+        }
2431
+        return hour;
2432
+    } else {
2433
+        // this is not supposed to happen
2434
+        return hour;
2435
+    }
2436
+}
2437
+
2438
+// date from string and array of format strings
2439
+function configFromStringAndArray(config) {
2440
+    var tempConfig,
2441
+        bestMoment,
2442
+
2443
+        scoreToBeat,
2444
+        i,
2445
+        currentScore;
2446
+
2447
+    if (config._f.length === 0) {
2448
+        getParsingFlags(config).invalidFormat = true;
2449
+        config._d = new Date(NaN);
2450
+        return;
2451
+    }
2452
+
2453
+    for (i = 0; i < config._f.length; i++) {
2454
+        currentScore = 0;
2455
+        tempConfig = copyConfig({}, config);
2456
+        if (config._useUTC != null) {
2457
+            tempConfig._useUTC = config._useUTC;
2458
+        }
2459
+        tempConfig._f = config._f[i];
2460
+        configFromStringAndFormat(tempConfig);
2461
+
2462
+        if (!isValid(tempConfig)) {
2463
+            continue;
2464
+        }
2465
+
2466
+        // if there is any input that was not parsed add a penalty for that format
2467
+        currentScore += getParsingFlags(tempConfig).charsLeftOver;
2468
+
2469
+        //or tokens
2470
+        currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
2471
+
2472
+        getParsingFlags(tempConfig).score = currentScore;
2473
+
2474
+        if (scoreToBeat == null || currentScore < scoreToBeat) {
2475
+            scoreToBeat = currentScore;
2476
+            bestMoment = tempConfig;
2477
+        }
2478
+    }
2479
+
2480
+    extend(config, bestMoment || tempConfig);
2481
+}
2482
+
2483
+function configFromObject(config) {
2484
+    if (config._d) {
2485
+        return;
2486
+    }
2487
+
2488
+    var i = normalizeObjectUnits(config._i);
2489
+    config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
2490
+        return obj && parseInt(obj, 10);
2491
+    });
2492
+
2493
+    configFromArray(config);
2494
+}
2495
+
2496
+function createFromConfig (config) {
2497
+    var res = new Moment(checkOverflow(prepareConfig(config)));
2498
+    if (res._nextDay) {
2499
+        // Adding is smart enough around DST
2500
+        res.add(1, 'd');
2501
+        res._nextDay = undefined;
2502
+    }
2503
+
2504
+    return res;
2505
+}
2506
+
2507
+function prepareConfig (config) {
2508
+    var input = config._i,
2509
+        format = config._f;
2510
+
2511
+    config._locale = config._locale || getLocale(config._l);
2512
+
2513
+    if (input === null || (format === undefined && input === '')) {
2514
+        return createInvalid({nullInput: true});
2515
+    }
2516
+
2517
+    if (typeof input === 'string') {
2518
+        config._i = input = config._locale.preparse(input);
2519
+    }
2520
+
2521
+    if (isMoment(input)) {
2522
+        return new Moment(checkOverflow(input));
2523
+    } else if (isDate(input)) {
2524
+        config._d = input;
2525
+    } else if (isArray(format)) {
2526
+        configFromStringAndArray(config);
2527
+    } else if (format) {
2528
+        configFromStringAndFormat(config);
2529
+    }  else {
2530
+        configFromInput(config);
2531
+    }
2532
+
2533
+    if (!isValid(config)) {
2534
+        config._d = null;
2535
+    }
2536
+
2537
+    return config;
2538
+}
2539
+
2540
+function configFromInput(config) {
2541
+    var input = config._i;
2542
+    if (isUndefined(input)) {
2543
+        config._d = new Date(hooks.now());
2544
+    } else if (isDate(input)) {
2545
+        config._d = new Date(input.valueOf());
2546
+    } else if (typeof input === 'string') {
2547
+        configFromString(config);
2548
+    } else if (isArray(input)) {
2549
+        config._a = map(input.slice(0), function (obj) {
2550
+            return parseInt(obj, 10);
2551
+        });
2552
+        configFromArray(config);
2553
+    } else if (isObject(input)) {
2554
+        configFromObject(config);
2555
+    } else if (isNumber(input)) {
2556
+        // from milliseconds
2557
+        config._d = new Date(input);
2558
+    } else {
2559
+        hooks.createFromInputFallback(config);
2560
+    }
2561
+}
2562
+
2563
+function createLocalOrUTC (input, format, locale, strict, isUTC) {
2564
+    var c = {};
2565
+
2566
+    if (locale === true || locale === false) {
2567
+        strict = locale;
2568
+        locale = undefined;
2569
+    }
2570
+
2571
+    if ((isObject(input) && isObjectEmpty(input)) ||
2572
+            (isArray(input) && input.length === 0)) {
2573
+        input = undefined;
2574
+    }
2575
+    // object construction must be done this way.
2576
+    // https://github.com/moment/moment/issues/1423
2577
+    c._isAMomentObject = true;
2578
+    c._useUTC = c._isUTC = isUTC;
2579
+    c._l = locale;
2580
+    c._i = input;
2581
+    c._f = format;
2582
+    c._strict = strict;
2583
+
2584
+    return createFromConfig(c);
2585
+}
2586
+
2587
+function createLocal (input, format, locale, strict) {
2588
+    return createLocalOrUTC(input, format, locale, strict, false);
2589
+}
2590
+
2591
+var prototypeMin = deprecate(
2592
+    'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
2593
+    function () {
2594
+        var other = createLocal.apply(null, arguments);
2595
+        if (this.isValid() && other.isValid()) {
2596
+            return other < this ? this : other;
2597
+        } else {
2598
+            return createInvalid();
2599
+        }
2600
+    }
2601
+);
2602
+
2603
+var prototypeMax = deprecate(
2604
+    'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
2605
+    function () {
2606
+        var other = createLocal.apply(null, arguments);
2607
+        if (this.isValid() && other.isValid()) {
2608
+            return other > this ? this : other;
2609
+        } else {
2610
+            return createInvalid();
2611
+        }
2612
+    }
2613
+);
2614
+
2615
+// Pick a moment m from moments so that m[fn](other) is true for all
2616
+// other. This relies on the function fn to be transitive.
2617
+//
2618
+// moments should either be an array of moment objects or an array, whose
2619
+// first element is an array of moment objects.
2620
+function pickBy(fn, moments) {
2621
+    var res, i;
2622
+    if (moments.length === 1 && isArray(moments[0])) {
2623
+        moments = moments[0];
2624
+    }
2625
+    if (!moments.length) {
2626
+        return createLocal();
2627
+    }
2628
+    res = moments[0];
2629
+    for (i = 1; i < moments.length; ++i) {
2630
+        if (!moments[i].isValid() || moments[i][fn](res)) {
2631
+            res = moments[i];
2632
+        }
2633
+    }
2634
+    return res;
2635
+}
2636
+
2637
+// TODO: Use [].sort instead?
2638
+function min () {
2639
+    var args = [].slice.call(arguments, 0);
2640
+
2641
+    return pickBy('isBefore', args);
2642
+}
2643
+
2644
+function max () {
2645
+    var args = [].slice.call(arguments, 0);
2646
+
2647
+    return pickBy('isAfter', args);
2648
+}
2649
+
2650
+var now = function () {
2651
+    return Date.now ? Date.now() : +(new Date());
2652
+};
2653
+
2654