1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
28 |
|
29 | function commonjsRequire() {
|
30 | throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
|
31 | }
|
32 |
|
33 | function createCommonjsModule(fn, module) {
|
34 | return module = {
|
35 | exports: {}
|
36 | }, fn(module, module.exports), module.exports;
|
37 | }
|
38 |
|
39 | var _global = createCommonjsModule(function (module) {
|
40 |
|
41 | var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self
|
42 | : Function('return this')();
|
43 | if (typeof __g == 'number') __g = global;
|
44 | });
|
45 |
|
46 | var _core = createCommonjsModule(function (module) {
|
47 | var core = module.exports = {
|
48 | version: '2.6.9'
|
49 | };
|
50 | if (typeof __e == 'number') __e = core;
|
51 | });
|
52 |
|
53 | var _core_1 = _core.version;
|
54 | var _library = false;
|
55 |
|
56 | var _shared = createCommonjsModule(function (module) {
|
57 | var SHARED = '__core-js_shared__';
|
58 | var store = _global[SHARED] || (_global[SHARED] = {});
|
59 | (module.exports = function (key, value) {
|
60 | return store[key] || (store[key] = value !== undefined ? value : {});
|
61 | })('versions', []).push({
|
62 | version: _core.version,
|
63 | mode: 'global',
|
64 | copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
|
65 | });
|
66 | });
|
67 |
|
68 | var id = 0;
|
69 | var px = Math.random();
|
70 |
|
71 | var _uid = function (key) {
|
72 | return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
|
73 | };
|
74 |
|
75 | var _wks = createCommonjsModule(function (module) {
|
76 | var store = _shared('wks');
|
77 |
|
78 | var Symbol = _global.Symbol;
|
79 | var USE_SYMBOL = typeof Symbol == 'function';
|
80 |
|
81 | var $exports = module.exports = function (name) {
|
82 | return store[name] || (store[name] = USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name));
|
83 | };
|
84 |
|
85 | $exports.store = store;
|
86 | });
|
87 |
|
88 | var f = _wks;
|
89 | var _wksExt = {
|
90 | f: f
|
91 | };
|
92 |
|
93 | var _isObject = function (it) {
|
94 | return typeof it === 'object' ? it !== null : typeof it === 'function';
|
95 | };
|
96 |
|
97 | var _anObject = function (it) {
|
98 | if (!_isObject(it)) throw TypeError(it + ' is not an object!');
|
99 | return it;
|
100 | };
|
101 |
|
102 | var _fails = function (exec) {
|
103 | try {
|
104 | return !!exec();
|
105 | } catch (e) {
|
106 | return true;
|
107 | }
|
108 | };
|
109 |
|
110 | var _descriptors = !_fails(function () {
|
111 | return Object.defineProperty({}, 'a', {
|
112 | get: function () {
|
113 | return 7;
|
114 | }
|
115 | }).a != 7;
|
116 | });
|
117 |
|
118 | var document$1 = _global.document;
|
119 |
|
120 | var is = _isObject(document$1) && _isObject(document$1.createElement);
|
121 |
|
122 | var _domCreate = function (it) {
|
123 | return is ? document$1.createElement(it) : {};
|
124 | };
|
125 |
|
126 | var _ie8DomDefine = !_descriptors && !_fails(function () {
|
127 | return Object.defineProperty(_domCreate('div'), 'a', {
|
128 | get: function () {
|
129 | return 7;
|
130 | }
|
131 | }).a != 7;
|
132 | });
|
133 |
|
134 |
|
135 |
|
136 | var _toPrimitive = function (it, S) {
|
137 | if (!_isObject(it)) return it;
|
138 | var fn, val;
|
139 | if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
|
140 | if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
|
141 | if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
|
142 | throw TypeError("Can't convert object to primitive value");
|
143 | };
|
144 |
|
145 | var dP = Object.defineProperty;
|
146 | var f$1 = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
|
147 | _anObject(O);
|
148 |
|
149 | P = _toPrimitive(P, true);
|
150 |
|
151 | _anObject(Attributes);
|
152 |
|
153 | if (_ie8DomDefine) try {
|
154 | return dP(O, P, Attributes);
|
155 | } catch (e) {
|
156 |
|
157 | }
|
158 | if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
|
159 | if ('value' in Attributes) O[P] = Attributes.value;
|
160 | return O;
|
161 | };
|
162 | var _objectDp = {
|
163 | f: f$1
|
164 | };
|
165 | var defineProperty = _objectDp.f;
|
166 |
|
167 | var _wksDefine = function (name) {
|
168 | var $Symbol = _core.Symbol || (_core.Symbol = _global.Symbol || {});
|
169 | if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, {
|
170 | value: _wksExt.f(name)
|
171 | });
|
172 | };
|
173 |
|
174 | _wksDefine('asyncIterator');
|
175 |
|
176 | var hasOwnProperty = {}.hasOwnProperty;
|
177 |
|
178 | var _has = function (it, key) {
|
179 | return hasOwnProperty.call(it, key);
|
180 | };
|
181 |
|
182 | var _propertyDesc = function (bitmap, value) {
|
183 | return {
|
184 | enumerable: !(bitmap & 1),
|
185 | configurable: !(bitmap & 2),
|
186 | writable: !(bitmap & 4),
|
187 | value: value
|
188 | };
|
189 | };
|
190 |
|
191 | var _hide = _descriptors ? function (object, key, value) {
|
192 | return _objectDp.f(object, key, _propertyDesc(1, value));
|
193 | } : function (object, key, value) {
|
194 | object[key] = value;
|
195 | return object;
|
196 | };
|
197 |
|
198 | var _functionToString = _shared('native-function-to-string', Function.toString);
|
199 |
|
200 | var _redefine = createCommonjsModule(function (module) {
|
201 | var SRC = _uid('src');
|
202 |
|
203 | var TO_STRING = 'toString';
|
204 |
|
205 | var TPL = ('' + _functionToString).split(TO_STRING);
|
206 |
|
207 | _core.inspectSource = function (it) {
|
208 | return _functionToString.call(it);
|
209 | };
|
210 |
|
211 | (module.exports = function (O, key, val, safe) {
|
212 | var isFunction = typeof val == 'function';
|
213 | if (isFunction) _has(val, 'name') || _hide(val, 'name', key);
|
214 | if (O[key] === val) return;
|
215 | if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
|
216 |
|
217 | if (O === _global) {
|
218 | O[key] = val;
|
219 | } else if (!safe) {
|
220 | delete O[key];
|
221 |
|
222 | _hide(O, key, val);
|
223 | } else if (O[key]) {
|
224 | O[key] = val;
|
225 | } else {
|
226 | _hide(O, key, val);
|
227 | }
|
228 |
|
229 | })(Function.prototype, TO_STRING, function toString() {
|
230 | return typeof this == 'function' && this[SRC] || _functionToString.call(this);
|
231 | });
|
232 | });
|
233 |
|
234 | var _aFunction = function (it) {
|
235 | if (typeof it != 'function') throw TypeError(it + ' is not a function!');
|
236 | return it;
|
237 | };
|
238 |
|
239 | var _ctx = function (fn, that, length) {
|
240 | _aFunction(fn);
|
241 |
|
242 | if (that === undefined) return fn;
|
243 |
|
244 | switch (length) {
|
245 | case 1:
|
246 | return function (a) {
|
247 | return fn.call(that, a);
|
248 | };
|
249 |
|
250 | case 2:
|
251 | return function (a, b) {
|
252 | return fn.call(that, a, b);
|
253 | };
|
254 |
|
255 | case 3:
|
256 | return function (a, b, c) {
|
257 | return fn.call(that, a, b, c);
|
258 | };
|
259 | }
|
260 |
|
261 | return function ()
|
262 | /* ...args */
|
263 | {
|
264 | return fn.apply(that, arguments);
|
265 | };
|
266 | };
|
267 |
|
268 | var PROTOTYPE = 'prototype';
|
269 |
|
270 | var $export = function (type, name, source) {
|
271 | var IS_FORCED = type & $export.F;
|
272 | var IS_GLOBAL = type & $export.G;
|
273 | var IS_STATIC = type & $export.S;
|
274 | var IS_PROTO = type & $export.P;
|
275 | var IS_BIND = type & $export.B;
|
276 | var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
|
277 | var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
|
278 | var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
|
279 | var key, own, out, exp;
|
280 | if (IS_GLOBAL) source = name;
|
281 |
|
282 | for (key in source) {
|
283 |
|
284 | own = !IS_FORCED && target && target[key] !== undefined;
|
285 |
|
286 | out = (own ? target : source)[key];
|
287 |
|
288 | exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
|
289 |
|
290 | if (target) _redefine(target, key, out, type & $export.U);
|
291 |
|
292 | if (exports[key] != out) _hide(exports, key, exp);
|
293 | if (IS_PROTO && expProto[key] != out) expProto[key] = out;
|
294 | }
|
295 | };
|
296 |
|
297 | _global.core = _core;
|
298 |
|
299 | $export.F = 1;
|
300 |
|
301 | $export.G = 2;
|
302 |
|
303 | $export.S = 4;
|
304 |
|
305 | $export.P = 8;
|
306 |
|
307 | $export.B = 16;
|
308 |
|
309 | $export.W = 32;
|
310 |
|
311 | $export.U = 64;
|
312 |
|
313 | $export.R = 128;
|
314 |
|
315 | var _export = $export;
|
316 |
|
317 | var _meta = createCommonjsModule(function (module) {
|
318 | var META = _uid('meta');
|
319 |
|
320 | var setDesc = _objectDp.f;
|
321 | var id = 0;
|
322 |
|
323 | var isExtensible = Object.isExtensible || function () {
|
324 | return true;
|
325 | };
|
326 |
|
327 | var FREEZE = !_fails(function () {
|
328 | return isExtensible(Object.preventExtensions({}));
|
329 | });
|
330 |
|
331 | var setMeta = function (it) {
|
332 | setDesc(it, META, {
|
333 | value: {
|
334 | i: 'O' + ++id,
|
335 |
|
336 | w: {}
|
337 |
|
338 | }
|
339 | });
|
340 | };
|
341 |
|
342 | var fastKey = function (it, create) {
|
343 |
|
344 | if (!_isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
|
345 |
|
346 | if (!_has(it, META)) {
|
347 |
|
348 | if (!isExtensible(it)) return 'F';
|
349 |
|
350 | if (!create) return 'E';
|
351 |
|
352 | setMeta(it);
|
353 | }
|
354 |
|
355 | return it[META].i;
|
356 | };
|
357 |
|
358 | var getWeak = function (it, create) {
|
359 | if (!_has(it, META)) {
|
360 |
|
361 | if (!isExtensible(it)) return true;
|
362 |
|
363 | if (!create) return false;
|
364 |
|
365 | setMeta(it);
|
366 | }
|
367 |
|
368 | return it[META].w;
|
369 | };
|
370 |
|
371 |
|
372 | var onFreeze = function (it) {
|
373 | if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it);
|
374 | return it;
|
375 | };
|
376 |
|
377 | var meta = module.exports = {
|
378 | KEY: META,
|
379 | NEED: false,
|
380 | fastKey: fastKey,
|
381 | getWeak: getWeak,
|
382 | onFreeze: onFreeze
|
383 | };
|
384 | });
|
385 |
|
386 | var _meta_1 = _meta.KEY;
|
387 | var _meta_2 = _meta.NEED;
|
388 | var _meta_3 = _meta.fastKey;
|
389 | var _meta_4 = _meta.getWeak;
|
390 | var _meta_5 = _meta.onFreeze;
|
391 | var def = _objectDp.f;
|
392 |
|
393 | var TAG = _wks('toStringTag');
|
394 |
|
395 | var _setToStringTag = function (it, tag, stat) {
|
396 | if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {
|
397 | configurable: true,
|
398 | value: tag
|
399 | });
|
400 | };
|
401 |
|
402 | var toString = {}.toString;
|
403 |
|
404 | var _cof = function (it) {
|
405 | return toString.call(it).slice(8, -1);
|
406 | };
|
407 |
|
408 |
|
409 | var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
|
410 | return _cof(it) == 'String' ? it.split('') : Object(it);
|
411 | };
|
412 |
|
413 |
|
414 | var _defined = function (it) {
|
415 | if (it == undefined) throw TypeError("Can't call method on " + it);
|
416 | return it;
|
417 | };
|
418 |
|
419 | var _toIobject = function (it) {
|
420 | return _iobject(_defined(it));
|
421 | };
|
422 |
|
423 |
|
424 | var ceil = Math.ceil;
|
425 | var floor = Math.floor;
|
426 |
|
427 | var _toInteger = function (it) {
|
428 | return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
|
429 | };
|
430 |
|
431 | var min = Math.min;
|
432 |
|
433 | var _toLength = function (it) {
|
434 | return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0;
|
435 | };
|
436 |
|
437 | var max = Math.max;
|
438 | var min$1 = Math.min;
|
439 |
|
440 | var _toAbsoluteIndex = function (index, length) {
|
441 | index = _toInteger(index);
|
442 | return index < 0 ? max(index + length, 0) : min$1(index, length);
|
443 | };
|
444 |
|
445 |
|
446 | var _arrayIncludes = function (IS_INCLUDES) {
|
447 | return function ($this, el, fromIndex) {
|
448 | var O = _toIobject($this);
|
449 |
|
450 | var length = _toLength(O.length);
|
451 |
|
452 | var index = _toAbsoluteIndex(fromIndex, length);
|
453 |
|
454 | var value;
|
455 |
|
456 |
|
457 | if (IS_INCLUDES && el != el) while (length > index) {
|
458 | value = O[index++];
|
459 |
|
460 | if (value != value) return true;
|
461 | } else for (; length > index; index++) if (IS_INCLUDES || index in O) {
|
462 | if (O[index] === el) return IS_INCLUDES || index || 0;
|
463 | }
|
464 | return !IS_INCLUDES && -1;
|
465 | };
|
466 | };
|
467 |
|
468 | var shared = _shared('keys');
|
469 |
|
470 | var _sharedKey = function (key) {
|
471 | return shared[key] || (shared[key] = _uid(key));
|
472 | };
|
473 |
|
474 | var arrayIndexOf = _arrayIncludes(false);
|
475 |
|
476 | var IE_PROTO = _sharedKey('IE_PROTO');
|
477 |
|
478 | var _objectKeysInternal = function (object, names) {
|
479 | var O = _toIobject(object);
|
480 |
|
481 | var i = 0;
|
482 | var result = [];
|
483 | var key;
|
484 |
|
485 | for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key);
|
486 |
|
487 |
|
488 | while (names.length > i) if (_has(O, key = names[i++])) {
|
489 | ~arrayIndexOf(result, key) || result.push(key);
|
490 | }
|
491 |
|
492 | return result;
|
493 | };
|
494 |
|
495 |
|
496 | var _enumBugKeys = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(',');
|
497 |
|
498 | var _objectKeys = Object.keys || function keys(O) {
|
499 | return _objectKeysInternal(O, _enumBugKeys);
|
500 | };
|
501 |
|
502 | var f$2 = Object.getOwnPropertySymbols;
|
503 | var _objectGops = {
|
504 | f: f$2
|
505 | };
|
506 | var f$3 = {}.propertyIsEnumerable;
|
507 | var _objectPie = {
|
508 | f: f$3
|
509 | };
|
510 |
|
511 | var _enumKeys = function (it) {
|
512 | var result = _objectKeys(it);
|
513 |
|
514 | var getSymbols = _objectGops.f;
|
515 |
|
516 | if (getSymbols) {
|
517 | var symbols = getSymbols(it);
|
518 | var isEnum = _objectPie.f;
|
519 | var i = 0;
|
520 | var key;
|
521 |
|
522 | while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
|
523 | }
|
524 |
|
525 | return result;
|
526 | };
|
527 |
|
528 | var _isArray = Array.isArray || function isArray(arg) {
|
529 | return _cof(arg) == 'Array';
|
530 | };
|
531 |
|
532 | var _toObject = function (it) {
|
533 | return Object(_defined(it));
|
534 | };
|
535 |
|
536 | var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
|
537 | _anObject(O);
|
538 |
|
539 | var keys = _objectKeys(Properties);
|
540 |
|
541 | var length = keys.length;
|
542 | var i = 0;
|
543 | var P;
|
544 |
|
545 | while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
|
546 |
|
547 | return O;
|
548 | };
|
549 |
|
550 | var document$2 = _global.document;
|
551 |
|
552 | var _html = document$2 && document$2.documentElement;
|
553 |
|
554 | var IE_PROTO$1 = _sharedKey('IE_PROTO');
|
555 |
|
556 | var Empty = function () {
|
557 |
|
558 | };
|
559 |
|
560 | var PROTOTYPE$1 = 'prototype';
|
561 |
|
562 | var createDict = function () {
|
563 |
|
564 | var iframe = _domCreate('iframe');
|
565 |
|
566 | var i = _enumBugKeys.length;
|
567 | var lt = '<';
|
568 | var gt = '>';
|
569 | var iframeDocument;
|
570 | iframe.style.display = 'none';
|
571 |
|
572 | _html.appendChild(iframe);
|
573 |
|
574 | iframe.src = 'javascript:';
|
575 |
|
576 |
|
577 |
|
578 | iframeDocument = iframe.contentWindow.document;
|
579 | iframeDocument.open();
|
580 | iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
|
581 | iframeDocument.close();
|
582 | createDict = iframeDocument.F;
|
583 |
|
584 | while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
|
585 |
|
586 | return createDict();
|
587 | };
|
588 |
|
589 | var _objectCreate = Object.create || function create(O, Properties) {
|
590 | var result;
|
591 |
|
592 | if (O !== null) {
|
593 | Empty[PROTOTYPE$1] = _anObject(O);
|
594 | result = new Empty();
|
595 | Empty[PROTOTYPE$1] = null;
|
596 |
|
597 | result[IE_PROTO$1] = O;
|
598 | } else result = createDict();
|
599 |
|
600 | return Properties === undefined ? result : _objectDps(result, Properties);
|
601 | };
|
602 |
|
603 | var hiddenKeys = _enumBugKeys.concat('length', 'prototype');
|
604 |
|
605 | var f$4 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
|
606 | return _objectKeysInternal(O, hiddenKeys);
|
607 | };
|
608 |
|
609 | var _objectGopn = {
|
610 | f: f$4
|
611 | };
|
612 | var gOPN = _objectGopn.f;
|
613 | var toString$1 = {}.toString;
|
614 | var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
|
615 |
|
616 | var getWindowNames = function (it) {
|
617 | try {
|
618 | return gOPN(it);
|
619 | } catch (e) {
|
620 | return windowNames.slice();
|
621 | }
|
622 | };
|
623 |
|
624 | var f$5 = function getOwnPropertyNames(it) {
|
625 | return windowNames && toString$1.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(_toIobject(it));
|
626 | };
|
627 |
|
628 | var _objectGopnExt = {
|
629 | f: f$5
|
630 | };
|
631 | var gOPD = Object.getOwnPropertyDescriptor;
|
632 | var f$6 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) {
|
633 | O = _toIobject(O);
|
634 | P = _toPrimitive(P, true);
|
635 | if (_ie8DomDefine) try {
|
636 | return gOPD(O, P);
|
637 | } catch (e) {
|
638 |
|
639 | }
|
640 | if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]);
|
641 | };
|
642 | var _objectGopd = {
|
643 | f: f$6
|
644 | };
|
645 | var META = _meta.KEY;
|
646 | var gOPD$1 = _objectGopd.f;
|
647 | var dP$1 = _objectDp.f;
|
648 | var gOPN$1 = _objectGopnExt.f;
|
649 | var $Symbol = _global.Symbol;
|
650 | var $JSON = _global.JSON;
|
651 |
|
652 | var _stringify = $JSON && $JSON.stringify;
|
653 |
|
654 | var PROTOTYPE$2 = 'prototype';
|
655 |
|
656 | var HIDDEN = _wks('_hidden');
|
657 |
|
658 | var TO_PRIMITIVE = _wks('toPrimitive');
|
659 |
|
660 | var isEnum = {}.propertyIsEnumerable;
|
661 |
|
662 | var SymbolRegistry = _shared('symbol-registry');
|
663 |
|
664 | var AllSymbols = _shared('symbols');
|
665 |
|
666 | var OPSymbols = _shared('op-symbols');
|
667 |
|
668 | var ObjectProto = Object[PROTOTYPE$2];
|
669 | var USE_NATIVE = typeof $Symbol == 'function' && !!_objectGops.f;
|
670 | var QObject = _global.QObject;
|
671 |
|
672 | var setter = !QObject || !QObject[PROTOTYPE$2] || !QObject[PROTOTYPE$2].findChild;
|
673 |
|
674 | var setSymbolDesc = _descriptors && _fails(function () {
|
675 | return _objectCreate(dP$1({}, 'a', {
|
676 | get: function () {
|
677 | return dP$1(this, 'a', {
|
678 | value: 7
|
679 | }).a;
|
680 | }
|
681 | })).a != 7;
|
682 | }) ? function (it, key, D) {
|
683 | var protoDesc = gOPD$1(ObjectProto, key);
|
684 | if (protoDesc) delete ObjectProto[key];
|
685 | dP$1(it, key, D);
|
686 | if (protoDesc && it !== ObjectProto) dP$1(ObjectProto, key, protoDesc);
|
687 | } : dP$1;
|
688 |
|
689 | var wrap = function (tag) {
|
690 | var sym = AllSymbols[tag] = _objectCreate($Symbol[PROTOTYPE$2]);
|
691 |
|
692 | sym._k = tag;
|
693 | return sym;
|
694 | };
|
695 |
|
696 | var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
|
697 | return typeof it == 'symbol';
|
698 | } : function (it) {
|
699 | return it instanceof $Symbol;
|
700 | };
|
701 |
|
702 | var $defineProperty = function defineProperty(it, key, D) {
|
703 | if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
|
704 |
|
705 | _anObject(it);
|
706 |
|
707 | key = _toPrimitive(key, true);
|
708 |
|
709 | _anObject(D);
|
710 |
|
711 | if (_has(AllSymbols, key)) {
|
712 | if (!D.enumerable) {
|
713 | if (!_has(it, HIDDEN)) dP$1(it, HIDDEN, _propertyDesc(1, {}));
|
714 | it[HIDDEN][key] = true;
|
715 | } else {
|
716 | if (_has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
|
717 | D = _objectCreate(D, {
|
718 | enumerable: _propertyDesc(0, false)
|
719 | });
|
720 | }
|
721 |
|
722 | return setSymbolDesc(it, key, D);
|
723 | }
|
724 |
|
725 | return dP$1(it, key, D);
|
726 | };
|
727 |
|
728 | var $defineProperties = function defineProperties(it, P) {
|
729 | _anObject(it);
|
730 |
|
731 | var keys = _enumKeys(P = _toIobject(P));
|
732 |
|
733 | var i = 0;
|
734 | var l = keys.length;
|
735 | var key;
|
736 |
|
737 | while (l > i) $defineProperty(it, key = keys[i++], P[key]);
|
738 |
|
739 | return it;
|
740 | };
|
741 |
|
742 | var $create = function create(it, P) {
|
743 | return P === undefined ? _objectCreate(it) : $defineProperties(_objectCreate(it), P);
|
744 | };
|
745 |
|
746 | var $propertyIsEnumerable = function propertyIsEnumerable(key) {
|
747 | var E = isEnum.call(this, key = _toPrimitive(key, true));
|
748 | if (this === ObjectProto && _has(AllSymbols, key) && !_has(OPSymbols, key)) return false;
|
749 | return E || !_has(this, key) || !_has(AllSymbols, key) || _has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
|
750 | };
|
751 |
|
752 | var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
|
753 | it = _toIobject(it);
|
754 | key = _toPrimitive(key, true);
|
755 | if (it === ObjectProto && _has(AllSymbols, key) && !_has(OPSymbols, key)) return;
|
756 | var D = gOPD$1(it, key);
|
757 | if (D && _has(AllSymbols, key) && !(_has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
|
758 | return D;
|
759 | };
|
760 |
|
761 | var $getOwnPropertyNames = function getOwnPropertyNames(it) {
|
762 | var names = gOPN$1(_toIobject(it));
|
763 | var result = [];
|
764 | var i = 0;
|
765 | var key;
|
766 |
|
767 | while (names.length > i) {
|
768 | if (!_has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
|
769 | }
|
770 |
|
771 | return result;
|
772 | };
|
773 |
|
774 | var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
|
775 | var IS_OP = it === ObjectProto;
|
776 | var names = gOPN$1(IS_OP ? OPSymbols : _toIobject(it));
|
777 | var result = [];
|
778 | var i = 0;
|
779 | var key;
|
780 |
|
781 | while (names.length > i) {
|
782 | if (_has(AllSymbols, key = names[i++]) && (IS_OP ? _has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
|
783 | }
|
784 |
|
785 | return result;
|
786 | };
|
787 |
|
788 |
|
789 | if (!USE_NATIVE) {
|
790 | $Symbol = function Symbol() {
|
791 | if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
|
792 |
|
793 | var tag = _uid(arguments.length > 0 ? arguments[0] : undefined);
|
794 |
|
795 | var $set = function (value) {
|
796 | if (this === ObjectProto) $set.call(OPSymbols, value);
|
797 | if (_has(this, HIDDEN) && _has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
|
798 | setSymbolDesc(this, tag, _propertyDesc(1, value));
|
799 | };
|
800 |
|
801 | if (_descriptors && setter) setSymbolDesc(ObjectProto, tag, {
|
802 | configurable: true,
|
803 | set: $set
|
804 | });
|
805 | return wrap(tag);
|
806 | };
|
807 |
|
808 | _redefine($Symbol[PROTOTYPE$2], 'toString', function toString() {
|
809 | return this._k;
|
810 | });
|
811 |
|
812 | _objectGopd.f = $getOwnPropertyDescriptor;
|
813 | _objectDp.f = $defineProperty;
|
814 | _objectGopn.f = _objectGopnExt.f = $getOwnPropertyNames;
|
815 | _objectPie.f = $propertyIsEnumerable;
|
816 | _objectGops.f = $getOwnPropertySymbols;
|
817 |
|
818 | if (_descriptors && !_library) {
|
819 | _redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
|
820 | }
|
821 |
|
822 | _wksExt.f = function (name) {
|
823 | return wrap(_wks(name));
|
824 | };
|
825 | }
|
826 |
|
827 | _export(_export.G + _export.W + _export.F * !USE_NATIVE, {
|
828 | Symbol: $Symbol
|
829 | });
|
830 |
|
831 | for (var es6Symbols =
|
832 | 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'.split(','), j = 0; es6Symbols.length > j;) _wks(es6Symbols[j++]);
|
833 |
|
834 | for (var wellKnownSymbols = _objectKeys(_wks.store), k = 0; wellKnownSymbols.length > k;) _wksDefine(wellKnownSymbols[k++]);
|
835 |
|
836 | _export(_export.S + _export.F * !USE_NATIVE, 'Symbol', {
|
837 |
|
838 | 'for': function (key) {
|
839 | return _has(SymbolRegistry, key += '') ? SymbolRegistry[key] : SymbolRegistry[key] = $Symbol(key);
|
840 | },
|
841 |
|
842 | keyFor: function keyFor(sym) {
|
843 | if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
|
844 |
|
845 | for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
|
846 | },
|
847 | useSetter: function () {
|
848 | setter = true;
|
849 | },
|
850 | useSimple: function () {
|
851 | setter = false;
|
852 | }
|
853 | });
|
854 |
|
855 | _export(_export.S + _export.F * !USE_NATIVE, 'Object', {
|
856 |
|
857 | create: $create,
|
858 |
|
859 | defineProperty: $defineProperty,
|
860 |
|
861 | defineProperties: $defineProperties,
|
862 |
|
863 | getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
|
864 |
|
865 | getOwnPropertyNames: $getOwnPropertyNames,
|
866 |
|
867 | getOwnPropertySymbols: $getOwnPropertySymbols
|
868 | });
|
869 |
|
870 |
|
871 |
|
872 | var FAILS_ON_PRIMITIVES = _fails(function () {
|
873 | _objectGops.f(1);
|
874 | });
|
875 |
|
876 | _export(_export.S + _export.F * FAILS_ON_PRIMITIVES, 'Object', {
|
877 | getOwnPropertySymbols: function getOwnPropertySymbols(it) {
|
878 | return _objectGops.f(_toObject(it));
|
879 | }
|
880 | });
|
881 |
|
882 |
|
883 | $JSON && _export(_export.S + _export.F * (!USE_NATIVE || _fails(function () {
|
884 | var S = $Symbol();
|
885 |
|
886 |
|
887 |
|
888 | return _stringify([S]) != '[null]' || _stringify({
|
889 | a: S
|
890 | }) != '{}' || _stringify(Object(S)) != '{}';
|
891 | })), 'JSON', {
|
892 | stringify: function stringify(it) {
|
893 | var args = [it];
|
894 | var i = 1;
|
895 | var replacer, $replacer;
|
896 |
|
897 | while (arguments.length > i) args.push(arguments[i++]);
|
898 |
|
899 | $replacer = replacer = args[1];
|
900 | if (!_isObject(replacer) && it === undefined || isSymbol(it)) return;
|
901 |
|
902 | if (!_isArray(replacer)) replacer = function (key, value) {
|
903 | if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
|
904 | if (!isSymbol(value)) return value;
|
905 | };
|
906 | args[1] = replacer;
|
907 | return _stringify.apply($JSON, args);
|
908 | }
|
909 | });
|
910 |
|
911 | $Symbol[PROTOTYPE$2][TO_PRIMITIVE] || _hide($Symbol[PROTOTYPE$2], TO_PRIMITIVE, $Symbol[PROTOTYPE$2].valueOf);
|
912 |
|
913 | _setToStringTag($Symbol, 'Symbol');
|
914 |
|
915 |
|
916 | _setToStringTag(Math, 'Math', true);
|
917 |
|
918 |
|
919 | _setToStringTag(_global.JSON, 'JSON', true);
|
920 |
|
921 | function _typeof(obj) {
|
922 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
923 | _typeof = function (obj) {
|
924 | return typeof obj;
|
925 | };
|
926 | } else {
|
927 | _typeof = function (obj) {
|
928 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
929 | };
|
930 | }
|
931 |
|
932 | return _typeof(obj);
|
933 | }
|
934 |
|
935 | function _defineProperty(obj, key, value) {
|
936 | if (key in obj) {
|
937 | Object.defineProperty(obj, key, {
|
938 | value: value,
|
939 | enumerable: true,
|
940 | configurable: true,
|
941 | writable: true
|
942 | });
|
943 | } else {
|
944 | obj[key] = value;
|
945 | }
|
946 |
|
947 | return obj;
|
948 | }
|
949 |
|
950 | function ownKeys(object, enumerableOnly) {
|
951 | var keys = Object.keys(object);
|
952 |
|
953 | if (Object.getOwnPropertySymbols) {
|
954 | keys.push.apply(keys, Object.getOwnPropertySymbols(object));
|
955 | }
|
956 |
|
957 | if (enumerableOnly) keys = keys.filter(function (sym) {
|
958 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
959 | });
|
960 | return keys;
|
961 | }
|
962 |
|
963 | function _objectSpread2(target) {
|
964 | for (var i = 1; i < arguments.length; i++) {
|
965 | var source = arguments[i] != null ? arguments[i] : {};
|
966 |
|
967 | if (i % 2) {
|
968 | ownKeys(source, true).forEach(function (key) {
|
969 | _defineProperty(target, key, source[key]);
|
970 | });
|
971 | } else if (Object.getOwnPropertyDescriptors) {
|
972 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
973 | } else {
|
974 | ownKeys(source).forEach(function (key) {
|
975 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
976 | });
|
977 | }
|
978 | }
|
979 |
|
980 | return target;
|
981 | }
|
982 |
|
983 | function _toConsumableArray(arr) {
|
984 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
985 | }
|
986 |
|
987 | function _arrayWithoutHoles(arr) {
|
988 | if (Array.isArray(arr)) {
|
989 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
990 |
|
991 | return arr2;
|
992 | }
|
993 | }
|
994 |
|
995 | function _iterableToArray(iter) {
|
996 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
997 | }
|
998 |
|
999 | function _nonIterableSpread() {
|
1000 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
1001 | }
|
1002 |
|
1003 | var _objectSap = function (KEY, exec) {
|
1004 | var fn = (_core.Object || {})[KEY] || Object[KEY];
|
1005 | var exp = {};
|
1006 | exp[KEY] = exec(fn);
|
1007 |
|
1008 | _export(_export.S + _export.F * _fails(function () {
|
1009 | fn(1);
|
1010 | }), 'Object', exp);
|
1011 | };
|
1012 |
|
1013 | _objectSap('keys', function () {
|
1014 | return function keys(it) {
|
1015 | return _objectKeys(_toObject(it));
|
1016 | };
|
1017 | });
|
1018 |
|
1019 | var _flags = function () {
|
1020 | var that = _anObject(this);
|
1021 |
|
1022 | var result = '';
|
1023 | if (that.global) result += 'g';
|
1024 | if (that.ignoreCase) result += 'i';
|
1025 | if (that.multiline) result += 'm';
|
1026 | if (that.unicode) result += 'u';
|
1027 | if (that.sticky) result += 'y';
|
1028 | return result;
|
1029 | };
|
1030 |
|
1031 | if (_descriptors && /./g.flags != 'g') _objectDp.f(RegExp.prototype, 'flags', {
|
1032 | configurable: true,
|
1033 | get: _flags
|
1034 | });
|
1035 | var TO_STRING = 'toString';
|
1036 | var $toString = /./[TO_STRING];
|
1037 |
|
1038 | var define = function (fn) {
|
1039 | _redefine(RegExp.prototype, TO_STRING, fn, true);
|
1040 | };
|
1041 |
|
1042 |
|
1043 | if (_fails(function () {
|
1044 | return $toString.call({
|
1045 | source: 'a',
|
1046 | flags: 'b'
|
1047 | }) != '/a/b';
|
1048 | })) {
|
1049 | define(function toString() {
|
1050 | var R = _anObject(this);
|
1051 |
|
1052 | return '/'.concat(R.source, '/', 'flags' in R ? R.flags : !_descriptors && R instanceof RegExp ? _flags.call(R) : undefined);
|
1053 | });
|
1054 | } else if ($toString.name != TO_STRING) {
|
1055 | define(function toString() {
|
1056 | return $toString.call(this);
|
1057 | });
|
1058 | }
|
1059 |
|
1060 |
|
1061 | var _stringAt = function (TO_STRING) {
|
1062 | return function (that, pos) {
|
1063 | var s = String(_defined(that));
|
1064 |
|
1065 | var i = _toInteger(pos);
|
1066 |
|
1067 | var l = s.length;
|
1068 | var a, b;
|
1069 | if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
|
1070 | a = s.charCodeAt(i);
|
1071 | return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
|
1072 | };
|
1073 | };
|
1074 |
|
1075 | var at = _stringAt(true);
|
1076 |
|
1077 |
|
1078 |
|
1079 | var _advanceStringIndex = function (S, index, unicode) {
|
1080 | return index + (unicode ? at(S, index).length : 1);
|
1081 | };
|
1082 |
|
1083 | var TAG$1 = _wks('toStringTag');
|
1084 |
|
1085 |
|
1086 | var ARG = _cof(function () {
|
1087 | return arguments;
|
1088 | }()) == 'Arguments';
|
1089 |
|
1090 | var tryGet = function (it, key) {
|
1091 | try {
|
1092 | return it[key];
|
1093 | } catch (e) {
|
1094 |
|
1095 | }
|
1096 | };
|
1097 |
|
1098 | var _classof = function (it) {
|
1099 | var O, T, B;
|
1100 | return it === undefined ? 'Undefined' : it === null ? 'Null'
|
1101 | : typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T
|
1102 | : ARG ? _cof(O)
|
1103 | : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
|
1104 | };
|
1105 |
|
1106 | var builtinExec = RegExp.prototype.exec;
|
1107 |
|
1108 |
|
1109 | var _regexpExecAbstract = function (R, S) {
|
1110 | var exec = R.exec;
|
1111 |
|
1112 | if (typeof exec === 'function') {
|
1113 | var result = exec.call(R, S);
|
1114 |
|
1115 | if (typeof result !== 'object') {
|
1116 | throw new TypeError('RegExp exec method returned something other than an Object or null');
|
1117 | }
|
1118 |
|
1119 | return result;
|
1120 | }
|
1121 |
|
1122 | if (_classof(R) !== 'RegExp') {
|
1123 | throw new TypeError('RegExp#exec called on incompatible receiver');
|
1124 | }
|
1125 |
|
1126 | return builtinExec.call(R, S);
|
1127 | };
|
1128 |
|
1129 | var nativeExec = RegExp.prototype.exec;
|
1130 |
|
1131 |
|
1132 |
|
1133 | var nativeReplace = String.prototype.replace;
|
1134 | var patchedExec = nativeExec;
|
1135 | var LAST_INDEX = 'lastIndex';
|
1136 |
|
1137 | var UPDATES_LAST_INDEX_WRONG = function () {
|
1138 | var re1 = /a/,
|
1139 | re2 = /b*/g;
|
1140 | nativeExec.call(re1, 'a');
|
1141 | nativeExec.call(re2, 'a');
|
1142 | return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0;
|
1143 | }();
|
1144 |
|
1145 |
|
1146 | var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
|
1147 | var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
|
1148 |
|
1149 | if (PATCH) {
|
1150 | patchedExec = function exec(str) {
|
1151 | var re = this;
|
1152 | var lastIndex, reCopy, match, i;
|
1153 |
|
1154 | if (NPCG_INCLUDED) {
|
1155 | reCopy = new RegExp('^' + re.source + '$(?!\\s)', _flags.call(re));
|
1156 | }
|
1157 |
|
1158 | if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX];
|
1159 | match = nativeExec.call(re, str);
|
1160 |
|
1161 | if (UPDATES_LAST_INDEX_WRONG && match) {
|
1162 | re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex;
|
1163 | }
|
1164 |
|
1165 | if (NPCG_INCLUDED && match && match.length > 1) {
|
1166 |
|
1167 |
|
1168 |
|
1169 | nativeReplace.call(match[0], reCopy, function () {
|
1170 | for (i = 1; i < arguments.length - 2; i++) {
|
1171 | if (arguments[i] === undefined) match[i] = undefined;
|
1172 | }
|
1173 | });
|
1174 | }
|
1175 |
|
1176 | return match;
|
1177 | };
|
1178 | }
|
1179 |
|
1180 | var _regexpExec = patchedExec;
|
1181 |
|
1182 | _export({
|
1183 | target: 'RegExp',
|
1184 | proto: true,
|
1185 | forced: _regexpExec !== /./.exec
|
1186 | }, {
|
1187 | exec: _regexpExec
|
1188 | });
|
1189 |
|
1190 | var SPECIES = _wks('species');
|
1191 |
|
1192 | var REPLACE_SUPPORTS_NAMED_GROUPS = !_fails(function () {
|
1193 |
|
1194 |
|
1195 |
|
1196 | var re = /./;
|
1197 |
|
1198 | re.exec = function () {
|
1199 | var result = [];
|
1200 | result.groups = {
|
1201 | a: '7'
|
1202 | };
|
1203 | return result;
|
1204 | };
|
1205 |
|
1206 | return ''.replace(re, '$<a>') !== '7';
|
1207 | });
|
1208 |
|
1209 | var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = function () {
|
1210 |
|
1211 | var re = /(?:)/;
|
1212 | var originalExec = re.exec;
|
1213 |
|
1214 | re.exec = function () {
|
1215 | return originalExec.apply(this, arguments);
|
1216 | };
|
1217 |
|
1218 | var result = 'ab'.split(re);
|
1219 | return result.length === 2 && result[0] === 'a' && result[1] === 'b';
|
1220 | }();
|
1221 |
|
1222 | var _fixReWks = function (KEY, length, exec) {
|
1223 | var SYMBOL = _wks(KEY);
|
1224 |
|
1225 | var DELEGATES_TO_SYMBOL = !_fails(function () {
|
1226 |
|
1227 | var O = {};
|
1228 |
|
1229 | O[SYMBOL] = function () {
|
1230 | return 7;
|
1231 | };
|
1232 |
|
1233 | return ''[KEY](O) != 7;
|
1234 | });
|
1235 | var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !_fails(function () {
|
1236 |
|
1237 | var execCalled = false;
|
1238 | var re = /a/;
|
1239 |
|
1240 | re.exec = function () {
|
1241 | execCalled = true;
|
1242 | return null;
|
1243 | };
|
1244 |
|
1245 | if (KEY === 'split') {
|
1246 |
|
1247 |
|
1248 | re.constructor = {};
|
1249 |
|
1250 | re.constructor[SPECIES] = function () {
|
1251 | return re;
|
1252 | };
|
1253 | }
|
1254 |
|
1255 | re[SYMBOL]('');
|
1256 | return !execCalled;
|
1257 | }) : undefined;
|
1258 |
|
1259 | if (!DELEGATES_TO_SYMBOL || !DELEGATES_TO_EXEC || KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS || KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC) {
|
1260 | var nativeRegExpMethod = /./[SYMBOL];
|
1261 | var fns = exec(_defined, SYMBOL, ''[KEY], function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) {
|
1262 | if (regexp.exec === _regexpExec) {
|
1263 | if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
|
1264 |
|
1265 |
|
1266 |
|
1267 | return {
|
1268 | done: true,
|
1269 | value: nativeRegExpMethod.call(regexp, str, arg2)
|
1270 | };
|
1271 | }
|
1272 |
|
1273 | return {
|
1274 | done: true,
|
1275 | value: nativeMethod.call(str, regexp, arg2)
|
1276 | };
|
1277 | }
|
1278 |
|
1279 | return {
|
1280 | done: false
|
1281 | };
|
1282 | });
|
1283 | var strfn = fns[0];
|
1284 | var rxfn = fns[1];
|
1285 |
|
1286 | _redefine(String.prototype, KEY, strfn);
|
1287 |
|
1288 | _hide(RegExp.prototype, SYMBOL, length == 2
|
1289 |
|
1290 | ? function (string, arg) {
|
1291 | return rxfn.call(string, this, arg);
|
1292 | }
|
1293 |
|
1294 | : function (string) {
|
1295 | return rxfn.call(string, this);
|
1296 | });
|
1297 | }
|
1298 | };
|
1299 |
|
1300 | var max$1 = Math.max;
|
1301 | var min$2 = Math.min;
|
1302 | var floor$1 = Math.floor;
|
1303 | var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g;
|
1304 | var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g;
|
1305 |
|
1306 | var maybeToString = function (it) {
|
1307 | return it === undefined ? it : String(it);
|
1308 | };
|
1309 |
|
1310 |
|
1311 | _fixReWks('replace', 2, function (defined, REPLACE, $replace, maybeCallNative) {
|
1312 | return [
|
1313 |
|
1314 | function replace(searchValue, replaceValue) {
|
1315 | var O = defined(this);
|
1316 | var fn = searchValue == undefined ? undefined : searchValue[REPLACE];
|
1317 | return fn !== undefined ? fn.call(searchValue, O, replaceValue) : $replace.call(String(O), searchValue, replaceValue);
|
1318 | },
|
1319 |
|
1320 | function (regexp, replaceValue) {
|
1321 | var res = maybeCallNative($replace, regexp, this, replaceValue);
|
1322 | if (res.done) return res.value;
|
1323 |
|
1324 | var rx = _anObject(regexp);
|
1325 |
|
1326 | var S = String(this);
|
1327 | var functionalReplace = typeof replaceValue === 'function';
|
1328 | if (!functionalReplace) replaceValue = String(replaceValue);
|
1329 | var global = rx.global;
|
1330 |
|
1331 | if (global) {
|
1332 | var fullUnicode = rx.unicode;
|
1333 | rx.lastIndex = 0;
|
1334 | }
|
1335 |
|
1336 | var results = [];
|
1337 |
|
1338 | while (true) {
|
1339 | var result = _regexpExecAbstract(rx, S);
|
1340 |
|
1341 | if (result === null) break;
|
1342 | results.push(result);
|
1343 | if (!global) break;
|
1344 | var matchStr = String(result[0]);
|
1345 | if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode);
|
1346 | }
|
1347 |
|
1348 | var accumulatedResult = '';
|
1349 | var nextSourcePosition = 0;
|
1350 |
|
1351 | for (var i = 0; i < results.length; i++) {
|
1352 | result = results[i];
|
1353 | var matched = String(result[0]);
|
1354 | var position = max$1(min$2(_toInteger(result.index), S.length), 0);
|
1355 | var captures = [];
|
1356 |
|
1357 |
|
1358 |
|
1359 |
|
1360 |
|
1361 | for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
|
1362 |
|
1363 | var namedCaptures = result.groups;
|
1364 |
|
1365 | if (functionalReplace) {
|
1366 | var replacerArgs = [matched].concat(captures, position, S);
|
1367 | if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
|
1368 | var replacement = String(replaceValue.apply(undefined, replacerArgs));
|
1369 | } else {
|
1370 | replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
|
1371 | }
|
1372 |
|
1373 | if (position >= nextSourcePosition) {
|
1374 | accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
|
1375 | nextSourcePosition = position + matched.length;
|
1376 | }
|
1377 | }
|
1378 |
|
1379 | return accumulatedResult + S.slice(nextSourcePosition);
|
1380 | }];
|
1381 |
|
1382 | function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
|
1383 | var tailPos = position + matched.length;
|
1384 | var m = captures.length;
|
1385 | var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
|
1386 |
|
1387 | if (namedCaptures !== undefined) {
|
1388 | namedCaptures = _toObject(namedCaptures);
|
1389 | symbols = SUBSTITUTION_SYMBOLS;
|
1390 | }
|
1391 |
|
1392 | return $replace.call(replacement, symbols, function (match, ch) {
|
1393 | var capture;
|
1394 |
|
1395 | switch (ch.charAt(0)) {
|
1396 | case '$':
|
1397 | return '$';
|
1398 |
|
1399 | case '&':
|
1400 | return matched;
|
1401 |
|
1402 | case '`':
|
1403 | return str.slice(0, position);
|
1404 |
|
1405 | case "'":
|
1406 | return str.slice(tailPos);
|
1407 |
|
1408 | case '<':
|
1409 | capture = namedCaptures[ch.slice(1, -1)];
|
1410 | break;
|
1411 |
|
1412 | default:
|
1413 |
|
1414 | var n = +ch;
|
1415 | if (n === 0) return match;
|
1416 |
|
1417 | if (n > m) {
|
1418 | var f = floor$1(n / 10);
|
1419 | if (f === 0) return match;
|
1420 | if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
|
1421 | return match;
|
1422 | }
|
1423 |
|
1424 | capture = captures[n - 1];
|
1425 | }
|
1426 |
|
1427 | return capture === undefined ? '' : capture;
|
1428 | });
|
1429 | }
|
1430 | });
|
1431 |
|
1432 | var UNSCOPABLES = _wks('unscopables');
|
1433 |
|
1434 | var ArrayProto = Array.prototype;
|
1435 | if (ArrayProto[UNSCOPABLES] == undefined) _hide(ArrayProto, UNSCOPABLES, {});
|
1436 |
|
1437 | var _addToUnscopables = function (key) {
|
1438 | ArrayProto[UNSCOPABLES][key] = true;
|
1439 | };
|
1440 |
|
1441 | var _iterStep = function (done, value) {
|
1442 | return {
|
1443 | value: value,
|
1444 | done: !!done
|
1445 | };
|
1446 | };
|
1447 |
|
1448 | var _iterators = {};
|
1449 | var IteratorPrototype = {};
|
1450 |
|
1451 | _hide(IteratorPrototype, _wks('iterator'), function () {
|
1452 | return this;
|
1453 | });
|
1454 |
|
1455 | var _iterCreate = function (Constructor, NAME, next) {
|
1456 | Constructor.prototype = _objectCreate(IteratorPrototype, {
|
1457 | next: _propertyDesc(1, next)
|
1458 | });
|
1459 |
|
1460 | _setToStringTag(Constructor, NAME + ' Iterator');
|
1461 | };
|
1462 |
|
1463 | var IE_PROTO$2 = _sharedKey('IE_PROTO');
|
1464 |
|
1465 | var ObjectProto$1 = Object.prototype;
|
1466 |
|
1467 | var _objectGpo = Object.getPrototypeOf || function (O) {
|
1468 | O = _toObject(O);
|
1469 | if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
|
1470 |
|
1471 | if (typeof O.constructor == 'function' && O instanceof O.constructor) {
|
1472 | return O.constructor.prototype;
|
1473 | }
|
1474 |
|
1475 | return O instanceof Object ? ObjectProto$1 : null;
|
1476 | };
|
1477 |
|
1478 | var ITERATOR = _wks('iterator');
|
1479 |
|
1480 | var BUGGY = !([].keys && 'next' in [].keys());
|
1481 |
|
1482 | var FF_ITERATOR = '@@iterator';
|
1483 | var KEYS = 'keys';
|
1484 | var VALUES = 'values';
|
1485 |
|
1486 | var returnThis = function () {
|
1487 | return this;
|
1488 | };
|
1489 |
|
1490 | var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
|
1491 | _iterCreate(Constructor, NAME, next);
|
1492 |
|
1493 | var getMethod = function (kind) {
|
1494 | if (!BUGGY && kind in proto) return proto[kind];
|
1495 |
|
1496 | switch (kind) {
|
1497 | case KEYS:
|
1498 | return function keys() {
|
1499 | return new Constructor(this, kind);
|
1500 | };
|
1501 |
|
1502 | case VALUES:
|
1503 | return function values() {
|
1504 | return new Constructor(this, kind);
|
1505 | };
|
1506 | }
|
1507 |
|
1508 | return function entries() {
|
1509 | return new Constructor(this, kind);
|
1510 | };
|
1511 | };
|
1512 |
|
1513 | var TAG = NAME + ' Iterator';
|
1514 | var DEF_VALUES = DEFAULT == VALUES;
|
1515 | var VALUES_BUG = false;
|
1516 | var proto = Base.prototype;
|
1517 | var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
|
1518 | var $default = $native || getMethod(DEFAULT);
|
1519 | var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
|
1520 | var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
|
1521 | var methods, key, IteratorPrototype;
|
1522 |
|
1523 | if ($anyNative) {
|
1524 | IteratorPrototype = _objectGpo($anyNative.call(new Base()));
|
1525 |
|
1526 | if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
|
1527 |
|
1528 | _setToStringTag(IteratorPrototype, TAG, true);
|
1529 |
|
1530 |
|
1531 | if (typeof IteratorPrototype[ITERATOR] != 'function') _hide(IteratorPrototype, ITERATOR, returnThis);
|
1532 | }
|
1533 | }
|
1534 |
|
1535 |
|
1536 | if (DEF_VALUES && $native && $native.name !== VALUES) {
|
1537 | VALUES_BUG = true;
|
1538 |
|
1539 | $default = function values() {
|
1540 | return $native.call(this);
|
1541 | };
|
1542 | }
|
1543 |
|
1544 |
|
1545 | if (BUGGY || VALUES_BUG || !proto[ITERATOR]) {
|
1546 | _hide(proto, ITERATOR, $default);
|
1547 | }
|
1548 |
|
1549 |
|
1550 | _iterators[NAME] = $default;
|
1551 | _iterators[TAG] = returnThis;
|
1552 |
|
1553 | if (DEFAULT) {
|
1554 | methods = {
|
1555 | values: DEF_VALUES ? $default : getMethod(VALUES),
|
1556 | keys: IS_SET ? $default : getMethod(KEYS),
|
1557 | entries: $entries
|
1558 | };
|
1559 | if (FORCED) for (key in methods) {
|
1560 | if (!(key in proto)) _redefine(proto, key, methods[key]);
|
1561 | } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
|
1562 | }
|
1563 |
|
1564 | return methods;
|
1565 | };
|
1566 |
|
1567 |
|
1568 |
|
1569 |
|
1570 | var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
|
1571 | this._t = _toIobject(iterated);
|
1572 |
|
1573 | this._i = 0;
|
1574 |
|
1575 | this._k = kind;
|
1576 |
|
1577 | }, function () {
|
1578 | var O = this._t;
|
1579 | var kind = this._k;
|
1580 | var index = this._i++;
|
1581 |
|
1582 | if (!O || index >= O.length) {
|
1583 | this._t = undefined;
|
1584 | return _iterStep(1);
|
1585 | }
|
1586 |
|
1587 | if (kind == 'keys') return _iterStep(0, index);
|
1588 | if (kind == 'values') return _iterStep(0, O[index]);
|
1589 | return _iterStep(0, [index, O[index]]);
|
1590 | }, 'values');
|
1591 |
|
1592 |
|
1593 | _iterators.Arguments = _iterators.Array;
|
1594 |
|
1595 | _addToUnscopables('keys');
|
1596 |
|
1597 | _addToUnscopables('values');
|
1598 |
|
1599 | _addToUnscopables('entries');
|
1600 |
|
1601 | var ITERATOR$1 = _wks('iterator');
|
1602 |
|
1603 | var TO_STRING_TAG = _wks('toStringTag');
|
1604 |
|
1605 | var ArrayValues = _iterators.Array;
|
1606 | var DOMIterables = {
|
1607 | CSSRuleList: true,
|
1608 |
|
1609 | CSSStyleDeclaration: false,
|
1610 | CSSValueList: false,
|
1611 | ClientRectList: false,
|
1612 | DOMRectList: false,
|
1613 | DOMStringList: false,
|
1614 | DOMTokenList: true,
|
1615 | DataTransferItemList: false,
|
1616 | FileList: false,
|
1617 | HTMLAllCollection: false,
|
1618 | HTMLCollection: false,
|
1619 | HTMLFormElement: false,
|
1620 | HTMLSelectElement: false,
|
1621 | MediaList: true,
|
1622 |
|
1623 | MimeTypeArray: false,
|
1624 | NamedNodeMap: false,
|
1625 | NodeList: true,
|
1626 | PaintRequestList: false,
|
1627 | Plugin: false,
|
1628 | PluginArray: false,
|
1629 | SVGLengthList: false,
|
1630 | SVGNumberList: false,
|
1631 | SVGPathSegList: false,
|
1632 | SVGPointList: false,
|
1633 | SVGStringList: false,
|
1634 | SVGTransformList: false,
|
1635 | SourceBufferList: false,
|
1636 | StyleSheetList: true,
|
1637 |
|
1638 | TextTrackCueList: false,
|
1639 | TextTrackList: false,
|
1640 | TouchList: false
|
1641 | };
|
1642 |
|
1643 | for (var collections = _objectKeys(DOMIterables), i = 0; i < collections.length; i++) {
|
1644 | var NAME = collections[i];
|
1645 | var explicit = DOMIterables[NAME];
|
1646 | var Collection = _global[NAME];
|
1647 | var proto = Collection && Collection.prototype;
|
1648 | var key;
|
1649 |
|
1650 | if (proto) {
|
1651 | if (!proto[ITERATOR$1]) _hide(proto, ITERATOR$1, ArrayValues);
|
1652 | if (!proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME);
|
1653 | _iterators[NAME] = ArrayValues;
|
1654 | if (explicit) for (key in es6_array_iterator) if (!proto[key]) _redefine(proto, key, es6_array_iterator[key], true);
|
1655 | }
|
1656 | }
|
1657 |
|
1658 | var test = {};
|
1659 | test[_wks('toStringTag')] = 'z';
|
1660 |
|
1661 | if (test + '' != '[object z]') {
|
1662 | _redefine(Object.prototype, 'toString', function toString() {
|
1663 | return '[object ' + _classof(this) + ']';
|
1664 | }, true);
|
1665 | }
|
1666 |
|
1667 | var isEnum$1 = _objectPie.f;
|
1668 |
|
1669 | var _objectToArray = function (isEntries) {
|
1670 | return function (it) {
|
1671 | var O = _toIobject(it);
|
1672 |
|
1673 | var keys = _objectKeys(O);
|
1674 |
|
1675 | var length = keys.length;
|
1676 | var i = 0;
|
1677 | var result = [];
|
1678 | var key;
|
1679 |
|
1680 | while (length > i) {
|
1681 | key = keys[i++];
|
1682 |
|
1683 | if (!_descriptors || isEnum$1.call(O, key)) {
|
1684 | result.push(isEntries ? [key, O[key]] : O[key]);
|
1685 | }
|
1686 | }
|
1687 |
|
1688 | return result;
|
1689 | };
|
1690 | };
|
1691 |
|
1692 | var $values = _objectToArray(false);
|
1693 |
|
1694 | _export(_export.S, 'Object', {
|
1695 | values: function values(it) {
|
1696 | return $values(it);
|
1697 | }
|
1698 | });
|
1699 |
|
1700 | var MATCH = _wks('match');
|
1701 |
|
1702 | var _isRegexp = function (it) {
|
1703 | var isRegExp;
|
1704 | return _isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : _cof(it) == 'RegExp');
|
1705 | };
|
1706 |
|
1707 | var SPECIES$1 = _wks('species');
|
1708 |
|
1709 | var _speciesConstructor = function (O, D) {
|
1710 | var C = _anObject(O).constructor;
|
1711 |
|
1712 | var S;
|
1713 | return C === undefined || (S = _anObject(C)[SPECIES$1]) == undefined ? D : _aFunction(S);
|
1714 | };
|
1715 |
|
1716 | var $min = Math.min;
|
1717 | var $push = [].push;
|
1718 | var $SPLIT = 'split';
|
1719 | var LENGTH = 'length';
|
1720 | var LAST_INDEX$1 = 'lastIndex';
|
1721 | var MAX_UINT32 = 0xffffffff;
|
1722 |
|
1723 | var SUPPORTS_Y = !_fails(function () {
|
1724 | RegExp(MAX_UINT32, 'y');
|
1725 | });
|
1726 |
|
1727 | _fixReWks('split', 2, function (defined, SPLIT, $split, maybeCallNative) {
|
1728 | var internalSplit;
|
1729 |
|
1730 | if ('abbc'[$SPLIT](/(b)*/)[1] == 'c' || 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 || 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 || '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 || '.'[$SPLIT](/()()/)[LENGTH] > 1 || ''[$SPLIT](/.?/)[LENGTH]) {
|
1731 |
|
1732 | internalSplit = function (separator, limit) {
|
1733 | var string = String(this);
|
1734 | if (separator === undefined && limit === 0) return [];
|
1735 |
|
1736 | if (!_isRegexp(separator)) return $split.call(string, separator, limit);
|
1737 | var output = [];
|
1738 | var flags = (separator.ignoreCase ? 'i' : '') + (separator.multiline ? 'm' : '') + (separator.unicode ? 'u' : '') + (separator.sticky ? 'y' : '');
|
1739 | var lastLastIndex = 0;
|
1740 | var splitLimit = limit === undefined ? MAX_UINT32 : limit >>> 0;
|
1741 |
|
1742 | var separatorCopy = new RegExp(separator.source, flags + 'g');
|
1743 | var match, lastIndex, lastLength;
|
1744 |
|
1745 | while (match = _regexpExec.call(separatorCopy, string)) {
|
1746 | lastIndex = separatorCopy[LAST_INDEX$1];
|
1747 |
|
1748 | if (lastIndex > lastLastIndex) {
|
1749 | output.push(string.slice(lastLastIndex, match.index));
|
1750 | if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1));
|
1751 | lastLength = match[0][LENGTH];
|
1752 | lastLastIndex = lastIndex;
|
1753 | if (output[LENGTH] >= splitLimit) break;
|
1754 | }
|
1755 |
|
1756 | if (separatorCopy[LAST_INDEX$1] === match.index) separatorCopy[LAST_INDEX$1]++;
|
1757 | }
|
1758 |
|
1759 | if (lastLastIndex === string[LENGTH]) {
|
1760 | if (lastLength || !separatorCopy.test('')) output.push('');
|
1761 | } else output.push(string.slice(lastLastIndex));
|
1762 |
|
1763 | return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;
|
1764 | };
|
1765 |
|
1766 | } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) {
|
1767 | internalSplit = function (separator, limit) {
|
1768 | return separator === undefined && limit === 0 ? [] : $split.call(this, separator, limit);
|
1769 | };
|
1770 | } else {
|
1771 | internalSplit = $split;
|
1772 | }
|
1773 |
|
1774 | return [
|
1775 |
|
1776 | function split(separator, limit) {
|
1777 | var O = defined(this);
|
1778 | var splitter = separator == undefined ? undefined : separator[SPLIT];
|
1779 | return splitter !== undefined ? splitter.call(separator, O, limit) : internalSplit.call(String(O), separator, limit);
|
1780 | },
|
1781 |
|
1782 |
|
1783 |
|
1784 |
|
1785 | function (regexp, limit) {
|
1786 | var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== $split);
|
1787 | if (res.done) return res.value;
|
1788 |
|
1789 | var rx = _anObject(regexp);
|
1790 |
|
1791 | var S = String(this);
|
1792 |
|
1793 | var C = _speciesConstructor(rx, RegExp);
|
1794 |
|
1795 | var unicodeMatching = rx.unicode;
|
1796 | var flags = (rx.ignoreCase ? 'i' : '') + (rx.multiline ? 'm' : '') + (rx.unicode ? 'u' : '') + (SUPPORTS_Y ? 'y' : 'g');
|
1797 |
|
1798 |
|
1799 | var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);
|
1800 | var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
|
1801 | if (lim === 0) return [];
|
1802 | if (S.length === 0) return _regexpExecAbstract(splitter, S) === null ? [S] : [];
|
1803 | var p = 0;
|
1804 | var q = 0;
|
1805 | var A = [];
|
1806 |
|
1807 | while (q < S.length) {
|
1808 | splitter.lastIndex = SUPPORTS_Y ? q : 0;
|
1809 |
|
1810 | var z = _regexpExecAbstract(splitter, SUPPORTS_Y ? S : S.slice(q));
|
1811 |
|
1812 | var e;
|
1813 |
|
1814 | if (z === null || (e = $min(_toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p) {
|
1815 | q = _advanceStringIndex(S, q, unicodeMatching);
|
1816 | } else {
|
1817 | A.push(S.slice(p, q));
|
1818 | if (A.length === lim) return A;
|
1819 |
|
1820 | for (var i = 1; i <= z.length - 1; i++) {
|
1821 | A.push(z[i]);
|
1822 | if (A.length === lim) return A;
|
1823 | }
|
1824 |
|
1825 | q = p = e;
|
1826 | }
|
1827 | }
|
1828 |
|
1829 | A.push(S.slice(p));
|
1830 | return A;
|
1831 | }];
|
1832 | });
|
1833 |
|
1834 | var $assign = Object.assign;
|
1835 |
|
1836 | var _objectAssign = !$assign || _fails(function () {
|
1837 | var A = {};
|
1838 | var B = {};
|
1839 |
|
1840 | var S = Symbol();
|
1841 | var K = 'abcdefghijklmnopqrst';
|
1842 | A[S] = 7;
|
1843 | K.split('').forEach(function (k) {
|
1844 | B[k] = k;
|
1845 | });
|
1846 | return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
|
1847 | }) ? function assign(target, source) {
|
1848 |
|
1849 | var T = _toObject(target);
|
1850 |
|
1851 | var aLen = arguments.length;
|
1852 | var index = 1;
|
1853 | var getSymbols = _objectGops.f;
|
1854 | var isEnum = _objectPie.f;
|
1855 |
|
1856 | while (aLen > index) {
|
1857 | var S = _iobject(arguments[index++]);
|
1858 |
|
1859 | var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S);
|
1860 | var length = keys.length;
|
1861 | var j = 0;
|
1862 | var key;
|
1863 |
|
1864 | while (length > j) {
|
1865 | key = keys[j++];
|
1866 | if (!_descriptors || isEnum.call(S, key)) T[key] = S[key];
|
1867 | }
|
1868 | }
|
1869 |
|
1870 | return T;
|
1871 | } : $assign;
|
1872 |
|
1873 | _export(_export.S + _export.F, 'Object', {
|
1874 | assign: _objectAssign
|
1875 | });
|
1876 |
|
1877 |
|
1878 |
|
1879 | var check = function (O, proto) {
|
1880 | _anObject(O);
|
1881 |
|
1882 | if (!_isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
|
1883 | };
|
1884 |
|
1885 | var _setProto = {
|
1886 | set: Object.setPrototypeOf || ('__proto__' in {} ?
|
1887 | function (test, buggy, set) {
|
1888 | try {
|
1889 | set = _ctx(Function.call, _objectGopd.f(Object.prototype, '__proto__').set, 2);
|
1890 | set(test, []);
|
1891 | buggy = !(test instanceof Array);
|
1892 | } catch (e) {
|
1893 | buggy = true;
|
1894 | }
|
1895 |
|
1896 | return function setPrototypeOf(O, proto) {
|
1897 | check(O, proto);
|
1898 | if (buggy) O.__proto__ = proto;else set(O, proto);
|
1899 | return O;
|
1900 | };
|
1901 | }({}, false) : undefined),
|
1902 | check: check
|
1903 | };
|
1904 | var setPrototypeOf = _setProto.set;
|
1905 |
|
1906 | var _inheritIfRequired = function (that, target, C) {
|
1907 | var S = target.constructor;
|
1908 | var P;
|
1909 |
|
1910 | if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && _isObject(P) && setPrototypeOf) {
|
1911 | setPrototypeOf(that, P);
|
1912 | }
|
1913 |
|
1914 | return that;
|
1915 | };
|
1916 |
|
1917 | var _stringWs = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
|
1918 |
|
1919 | var space = '[' + _stringWs + ']';
|
1920 | var non = '\u200b\u0085';
|
1921 | var ltrim = RegExp('^' + space + space + '*');
|
1922 | var rtrim = RegExp(space + space + '*$');
|
1923 |
|
1924 | var exporter = function (KEY, exec, ALIAS) {
|
1925 | var exp = {};
|
1926 |
|
1927 | var FORCE = _fails(function () {
|
1928 | return !!_stringWs[KEY]() || non[KEY]() != non;
|
1929 | });
|
1930 |
|
1931 | var fn = exp[KEY] = FORCE ? exec(trim) : _stringWs[KEY];
|
1932 | if (ALIAS) exp[ALIAS] = fn;
|
1933 |
|
1934 | _export(_export.P + _export.F * FORCE, 'String', exp);
|
1935 | };
|
1936 |
|
1937 |
|
1938 |
|
1939 |
|
1940 | var trim = exporter.trim = function (string, TYPE) {
|
1941 | string = String(_defined(string));
|
1942 | if (TYPE & 1) string = string.replace(ltrim, '');
|
1943 | if (TYPE & 2) string = string.replace(rtrim, '');
|
1944 | return string;
|
1945 | };
|
1946 |
|
1947 | var _stringTrim = exporter;
|
1948 | var gOPN$2 = _objectGopn.f;
|
1949 | var gOPD$2 = _objectGopd.f;
|
1950 | var dP$2 = _objectDp.f;
|
1951 | var $trim = _stringTrim.trim;
|
1952 | var NUMBER = 'Number';
|
1953 | var $Number = _global[NUMBER];
|
1954 | var Base = $Number;
|
1955 | var proto$1 = $Number.prototype;
|
1956 |
|
1957 | var BROKEN_COF = _cof(_objectCreate(proto$1)) == NUMBER;
|
1958 | var TRIM = 'trim' in String.prototype;
|
1959 |
|
1960 | var toNumber = function (argument) {
|
1961 | var it = _toPrimitive(argument, false);
|
1962 |
|
1963 | if (typeof it == 'string' && it.length > 2) {
|
1964 | it = TRIM ? it.trim() : $trim(it, 3);
|
1965 | var first = it.charCodeAt(0);
|
1966 | var third, radix, maxCode;
|
1967 |
|
1968 | if (first === 43 || first === 45) {
|
1969 | third = it.charCodeAt(2);
|
1970 | if (third === 88 || third === 120) return NaN;
|
1971 | } else if (first === 48) {
|
1972 | switch (it.charCodeAt(1)) {
|
1973 | case 66:
|
1974 | case 98:
|
1975 | radix = 2;
|
1976 | maxCode = 49;
|
1977 | break;
|
1978 |
|
1979 |
|
1980 | case 79:
|
1981 | case 111:
|
1982 | radix = 8;
|
1983 | maxCode = 55;
|
1984 | break;
|
1985 |
|
1986 |
|
1987 | default:
|
1988 | return +it;
|
1989 | }
|
1990 |
|
1991 | for (var digits = it.slice(2), i = 0, l = digits.length, code; i < l; i++) {
|
1992 | code = digits.charCodeAt(i);
|
1993 |
|
1994 |
|
1995 | if (code < 48 || code > maxCode) return NaN;
|
1996 | }
|
1997 |
|
1998 | return parseInt(digits, radix);
|
1999 | }
|
2000 | }
|
2001 |
|
2002 | return +it;
|
2003 | };
|
2004 |
|
2005 | if (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) {
|
2006 | $Number = function Number(value) {
|
2007 | var it = arguments.length < 1 ? 0 : value;
|
2008 | var that = this;
|
2009 | return that instanceof $Number
|
2010 | && (BROKEN_COF ? _fails(function () {
|
2011 | proto$1.valueOf.call(that);
|
2012 | }) : _cof(that) != NUMBER) ? _inheritIfRequired(new Base(toNumber(it)), that, $Number) : toNumber(it);
|
2013 | };
|
2014 |
|
2015 | for (var keys = _descriptors ? gOPN$2(Base) : (
|
2016 | 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
|
2017 | 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' + 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger').split(','), j$1 = 0, key$1; keys.length > j$1; j$1++) {
|
2018 | if (_has(Base, key$1 = keys[j$1]) && !_has($Number, key$1)) {
|
2019 | dP$2($Number, key$1, gOPD$2(Base, key$1));
|
2020 | }
|
2021 | }
|
2022 |
|
2023 | $Number.prototype = proto$1;
|
2024 | proto$1.constructor = $Number;
|
2025 |
|
2026 | _redefine(_global, NUMBER, $Number);
|
2027 | }
|
2028 |
|
2029 | var moment = createCommonjsModule(function (module, exports) {
|
2030 | (function (global, factory) {
|
2031 | module.exports = factory();
|
2032 | })(commonjsGlobal, function () {
|
2033 | var hookCallback;
|
2034 |
|
2035 | function hooks() {
|
2036 | return hookCallback.apply(null, arguments);
|
2037 | }
|
2038 |
|
2039 |
|
2040 |
|
2041 | function setHookCallback(callback) {
|
2042 | hookCallback = callback;
|
2043 | }
|
2044 |
|
2045 | function isArray(input) {
|
2046 | return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
|
2047 | }
|
2048 |
|
2049 | function isObject(input) {
|
2050 |
|
2051 |
|
2052 | return input != null && Object.prototype.toString.call(input) === '[object Object]';
|
2053 | }
|
2054 |
|
2055 | function isObjectEmpty(obj) {
|
2056 | if (Object.getOwnPropertyNames) {
|
2057 | return Object.getOwnPropertyNames(obj).length === 0;
|
2058 | } else {
|
2059 | var k;
|
2060 |
|
2061 | for (k in obj) {
|
2062 | if (obj.hasOwnProperty(k)) {
|
2063 | return false;
|
2064 | }
|
2065 | }
|
2066 |
|
2067 | return true;
|
2068 | }
|
2069 | }
|
2070 |
|
2071 | function isUndefined(input) {
|
2072 | return input === void 0;
|
2073 | }
|
2074 |
|
2075 | function isNumber(input) {
|
2076 | return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
|
2077 | }
|
2078 |
|
2079 | function isDate(input) {
|
2080 | return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
|
2081 | }
|
2082 |
|
2083 | function map(arr, fn) {
|
2084 | var res = [],
|
2085 | i;
|
2086 |
|
2087 | for (i = 0; i < arr.length; ++i) {
|
2088 | res.push(fn(arr[i], i));
|
2089 | }
|
2090 |
|
2091 | return res;
|
2092 | }
|
2093 |
|
2094 | function hasOwnProp(a, b) {
|
2095 | return Object.prototype.hasOwnProperty.call(a, b);
|
2096 | }
|
2097 |
|
2098 | function extend(a, b) {
|
2099 | for (var i in b) {
|
2100 | if (hasOwnProp(b, i)) {
|
2101 | a[i] = b[i];
|
2102 | }
|
2103 | }
|
2104 |
|
2105 | if (hasOwnProp(b, 'toString')) {
|
2106 | a.toString = b.toString;
|
2107 | }
|
2108 |
|
2109 | if (hasOwnProp(b, 'valueOf')) {
|
2110 | a.valueOf = b.valueOf;
|
2111 | }
|
2112 |
|
2113 | return a;
|
2114 | }
|
2115 |
|
2116 | function createUTC(input, format, locale, strict) {
|
2117 | return createLocalOrUTC(input, format, locale, strict, true).utc();
|
2118 | }
|
2119 |
|
2120 | function defaultParsingFlags() {
|
2121 |
|
2122 | return {
|
2123 | empty: false,
|
2124 | unusedTokens: [],
|
2125 | unusedInput: [],
|
2126 | overflow: -2,
|
2127 | charsLeftOver: 0,
|
2128 | nullInput: false,
|
2129 | invalidMonth: null,
|
2130 | invalidFormat: false,
|
2131 | userInvalidated: false,
|
2132 | iso: false,
|
2133 | parsedDateParts: [],
|
2134 | meridiem: null,
|
2135 | rfc2822: false,
|
2136 | weekdayMismatch: false
|
2137 | };
|
2138 | }
|
2139 |
|
2140 | function getParsingFlags(m) {
|
2141 | if (m._pf == null) {
|
2142 | m._pf = defaultParsingFlags();
|
2143 | }
|
2144 |
|
2145 | return m._pf;
|
2146 | }
|
2147 |
|
2148 | var some;
|
2149 |
|
2150 | if (Array.prototype.some) {
|
2151 | some = Array.prototype.some;
|
2152 | } else {
|
2153 | some = function (fun) {
|
2154 | var t = Object(this);
|
2155 | var len = t.length >>> 0;
|
2156 |
|
2157 | for (var i = 0; i < len; i++) {
|
2158 | if (i in t && fun.call(this, t[i], i, t)) {
|
2159 | return true;
|
2160 | }
|
2161 | }
|
2162 |
|
2163 | return false;
|
2164 | };
|
2165 | }
|
2166 |
|
2167 | function isValid(m) {
|
2168 | if (m._isValid == null) {
|
2169 | var flags = getParsingFlags(m);
|
2170 | var parsedParts = some.call(flags.parsedDateParts, function (i) {
|
2171 | return i != null;
|
2172 | });
|
2173 | var isNowValid = !isNaN(m._d.getTime()) && flags.overflow < 0 && !flags.empty && !flags.invalidMonth && !flags.invalidWeekday && !flags.weekdayMismatch && !flags.nullInput && !flags.invalidFormat && !flags.userInvalidated && (!flags.meridiem || flags.meridiem && parsedParts);
|
2174 |
|
2175 | if (m._strict) {
|
2176 | isNowValid = isNowValid && flags.charsLeftOver === 0 && flags.unusedTokens.length === 0 && flags.bigHour === undefined;
|
2177 | }
|
2178 |
|
2179 | if (Object.isFrozen == null || !Object.isFrozen(m)) {
|
2180 | m._isValid = isNowValid;
|
2181 | } else {
|
2182 | return isNowValid;
|
2183 | }
|
2184 | }
|
2185 |
|
2186 | return m._isValid;
|
2187 | }
|
2188 |
|
2189 | function createInvalid(flags) {
|
2190 | var m = createUTC(NaN);
|
2191 |
|
2192 | if (flags != null) {
|
2193 | extend(getParsingFlags(m), flags);
|
2194 | } else {
|
2195 | getParsingFlags(m).userInvalidated = true;
|
2196 | }
|
2197 |
|
2198 | return m;
|
2199 | }
|
2200 |
|
2201 |
|
2202 |
|
2203 | var momentProperties = hooks.momentProperties = [];
|
2204 |
|
2205 | function copyConfig(to, from) {
|
2206 | var i, prop, val;
|
2207 |
|
2208 | if (!isUndefined(from._isAMomentObject)) {
|
2209 | to._isAMomentObject = from._isAMomentObject;
|
2210 | }
|
2211 |
|
2212 | if (!isUndefined(from._i)) {
|
2213 | to._i = from._i;
|
2214 | }
|
2215 |
|
2216 | if (!isUndefined(from._f)) {
|
2217 | to._f = from._f;
|
2218 | }
|
2219 |
|
2220 | if (!isUndefined(from._l)) {
|
2221 | to._l = from._l;
|
2222 | }
|
2223 |
|
2224 | if (!isUndefined(from._strict)) {
|
2225 | to._strict = from._strict;
|
2226 | }
|
2227 |
|
2228 | if (!isUndefined(from._tzm)) {
|
2229 | to._tzm = from._tzm;
|
2230 | }
|
2231 |
|
2232 | if (!isUndefined(from._isUTC)) {
|
2233 | to._isUTC = from._isUTC;
|
2234 | }
|
2235 |
|
2236 | if (!isUndefined(from._offset)) {
|
2237 | to._offset = from._offset;
|
2238 | }
|
2239 |
|
2240 | if (!isUndefined(from._pf)) {
|
2241 | to._pf = getParsingFlags(from);
|
2242 | }
|
2243 |
|
2244 | if (!isUndefined(from._locale)) {
|
2245 | to._locale = from._locale;
|
2246 | }
|
2247 |
|
2248 | if (momentProperties.length > 0) {
|
2249 | for (i = 0; i < momentProperties.length; i++) {
|
2250 | prop = momentProperties[i];
|
2251 | val = from[prop];
|
2252 |
|
2253 | if (!isUndefined(val)) {
|
2254 | to[prop] = val;
|
2255 | }
|
2256 | }
|
2257 | }
|
2258 |
|
2259 | return to;
|
2260 | }
|
2261 |
|
2262 | var updateInProgress = false;
|
2263 |
|
2264 | function Moment(config) {
|
2265 | copyConfig(this, config);
|
2266 | this._d = new Date(config._d != null ? config._d.getTime() : NaN);
|
2267 |
|
2268 | if (!this.isValid()) {
|
2269 | this._d = new Date(NaN);
|
2270 | }
|
2271 |
|
2272 |
|
2273 |
|
2274 | if (updateInProgress === false) {
|
2275 | updateInProgress = true;
|
2276 | hooks.updateOffset(this);
|
2277 | updateInProgress = false;
|
2278 | }
|
2279 | }
|
2280 |
|
2281 | function isMoment(obj) {
|
2282 | return obj instanceof Moment || obj != null && obj._isAMomentObject != null;
|
2283 | }
|
2284 |
|
2285 | function absFloor(number) {
|
2286 | if (number < 0) {
|
2287 |
|
2288 | return Math.ceil(number) || 0;
|
2289 | } else {
|
2290 | return Math.floor(number);
|
2291 | }
|
2292 | }
|
2293 |
|
2294 | function toInt(argumentForCoercion) {
|
2295 | var coercedNumber = +argumentForCoercion,
|
2296 | value = 0;
|
2297 |
|
2298 | if (coercedNumber !== 0 && isFinite(coercedNumber)) {
|
2299 | value = absFloor(coercedNumber);
|
2300 | }
|
2301 |
|
2302 | return value;
|
2303 | }
|
2304 |
|
2305 |
|
2306 | function compareArrays(array1, array2, dontConvert) {
|
2307 | var len = Math.min(array1.length, array2.length),
|
2308 | lengthDiff = Math.abs(array1.length - array2.length),
|
2309 | diffs = 0,
|
2310 | i;
|
2311 |
|
2312 | for (i = 0; i < len; i++) {
|
2313 | if (dontConvert && array1[i] !== array2[i] || !dontConvert && toInt(array1[i]) !== toInt(array2[i])) {
|
2314 | diffs++;
|
2315 | }
|
2316 | }
|
2317 |
|
2318 | return diffs + lengthDiff;
|
2319 | }
|
2320 |
|
2321 | function warn(msg) {
|
2322 | if (hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
|
2323 | console.warn('Deprecation warning: ' + msg);
|
2324 | }
|
2325 | }
|
2326 |
|
2327 | function deprecate(msg, fn) {
|
2328 | var firstTime = true;
|
2329 | return extend(function () {
|
2330 | if (hooks.deprecationHandler != null) {
|
2331 | hooks.deprecationHandler(null, msg);
|
2332 | }
|
2333 |
|
2334 | if (firstTime) {
|
2335 | var args = [];
|
2336 | var arg;
|
2337 |
|
2338 | for (var i = 0; i < arguments.length; i++) {
|
2339 | arg = '';
|
2340 |
|
2341 | if (typeof arguments[i] === 'object') {
|
2342 | arg += '\n[' + i + '] ';
|
2343 |
|
2344 | for (var key in arguments[0]) {
|
2345 | arg += key + ': ' + arguments[0][key] + ', ';
|
2346 | }
|
2347 |
|
2348 | arg = arg.slice(0, -2);
|
2349 | } else {
|
2350 | arg = arguments[i];
|
2351 | }
|
2352 |
|
2353 | args.push(arg);
|
2354 | }
|
2355 |
|
2356 | warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + new Error().stack);
|
2357 | firstTime = false;
|
2358 | }
|
2359 |
|
2360 | return fn.apply(this, arguments);
|
2361 | }, fn);
|
2362 | }
|
2363 |
|
2364 | var deprecations = {};
|
2365 |
|
2366 | function deprecateSimple(name, msg) {
|
2367 | if (hooks.deprecationHandler != null) {
|
2368 | hooks.deprecationHandler(name, msg);
|
2369 | }
|
2370 |
|
2371 | if (!deprecations[name]) {
|
2372 | warn(msg);
|
2373 | deprecations[name] = true;
|
2374 | }
|
2375 | }
|
2376 |
|
2377 | hooks.suppressDeprecationWarnings = false;
|
2378 | hooks.deprecationHandler = null;
|
2379 |
|
2380 | function isFunction(input) {
|
2381 | return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
|
2382 | }
|
2383 |
|
2384 | function set(config) {
|
2385 | var prop, i;
|
2386 |
|
2387 | for (i in config) {
|
2388 | prop = config[i];
|
2389 |
|
2390 | if (isFunction(prop)) {
|
2391 | this[i] = prop;
|
2392 | } else {
|
2393 | this['_' + i] = prop;
|
2394 | }
|
2395 | }
|
2396 |
|
2397 | this._config = config;
|
2398 |
|
2399 |
|
2400 |
|
2401 | this._dayOfMonthOrdinalParseLenient = new RegExp((this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + '|' + /\d{1,2}/.source);
|
2402 | }
|
2403 |
|
2404 | function mergeConfigs(parentConfig, childConfig) {
|
2405 | var res = extend({}, parentConfig),
|
2406 | prop;
|
2407 |
|
2408 | for (prop in childConfig) {
|
2409 | if (hasOwnProp(childConfig, prop)) {
|
2410 | if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
|
2411 | res[prop] = {};
|
2412 | extend(res[prop], parentConfig[prop]);
|
2413 | extend(res[prop], childConfig[prop]);
|
2414 | } else if (childConfig[prop] != null) {
|
2415 | res[prop] = childConfig[prop];
|
2416 | } else {
|
2417 | delete res[prop];
|
2418 | }
|
2419 | }
|
2420 | }
|
2421 |
|
2422 | for (prop in parentConfig) {
|
2423 | if (hasOwnProp(parentConfig, prop) && !hasOwnProp(childConfig, prop) && isObject(parentConfig[prop])) {
|
2424 |
|
2425 | res[prop] = extend({}, res[prop]);
|
2426 | }
|
2427 | }
|
2428 |
|
2429 | return res;
|
2430 | }
|
2431 |
|
2432 | function Locale(config) {
|
2433 | if (config != null) {
|
2434 | this.set(config);
|
2435 | }
|
2436 | }
|
2437 |
|
2438 | var keys;
|
2439 |
|
2440 | if (Object.keys) {
|
2441 | keys = Object.keys;
|
2442 | } else {
|
2443 | keys = function (obj) {
|
2444 | var i,
|
2445 | res = [];
|
2446 |
|
2447 | for (i in obj) {
|
2448 | if (hasOwnProp(obj, i)) {
|
2449 | res.push(i);
|
2450 | }
|
2451 | }
|
2452 |
|
2453 | return res;
|
2454 | };
|
2455 | }
|
2456 |
|
2457 | var defaultCalendar = {
|
2458 | sameDay: '[Today at] LT',
|
2459 | nextDay: '[Tomorrow at] LT',
|
2460 | nextWeek: 'dddd [at] LT',
|
2461 | lastDay: '[Yesterday at] LT',
|
2462 | lastWeek: '[Last] dddd [at] LT',
|
2463 | sameElse: 'L'
|
2464 | };
|
2465 |
|
2466 | function calendar(key, mom, now) {
|
2467 | var output = this._calendar[key] || this._calendar['sameElse'];
|
2468 | return isFunction(output) ? output.call(mom, now) : output;
|
2469 | }
|
2470 |
|
2471 | var defaultLongDateFormat = {
|
2472 | LTS: 'h:mm:ss A',
|
2473 | LT: 'h:mm A',
|
2474 | L: 'MM/DD/YYYY',
|
2475 | LL: 'MMMM D, YYYY',
|
2476 | LLL: 'MMMM D, YYYY h:mm A',
|
2477 | LLLL: 'dddd, MMMM D, YYYY h:mm A'
|
2478 | };
|
2479 |
|
2480 | function longDateFormat(key) {
|
2481 | var format = this._longDateFormat[key],
|
2482 | formatUpper = this._longDateFormat[key.toUpperCase()];
|
2483 |
|
2484 | if (format || !formatUpper) {
|
2485 | return format;
|
2486 | }
|
2487 |
|
2488 | this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
|
2489 | return val.slice(1);
|
2490 | });
|
2491 | return this._longDateFormat[key];
|
2492 | }
|
2493 |
|
2494 | var defaultInvalidDate = 'Invalid date';
|
2495 |
|
2496 | function invalidDate() {
|
2497 | return this._invalidDate;
|
2498 | }
|
2499 |
|
2500 | var defaultOrdinal = '%d';
|
2501 | var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
|
2502 |
|
2503 | function ordinal(number) {
|
2504 | return this._ordinal.replace('%d', number);
|
2505 | }
|
2506 |
|
2507 | var defaultRelativeTime = {
|
2508 | future: 'in %s',
|
2509 | past: '%s ago',
|
2510 | s: 'a few seconds',
|
2511 | ss: '%d seconds',
|
2512 | m: 'a minute',
|
2513 | mm: '%d minutes',
|
2514 | h: 'an hour',
|
2515 | hh: '%d hours',
|
2516 | d: 'a day',
|
2517 | dd: '%d days',
|
2518 | M: 'a month',
|
2519 | MM: '%d months',
|
2520 | y: 'a year',
|
2521 | yy: '%d years'
|
2522 | };
|
2523 |
|
2524 | function relativeTime(number, withoutSuffix, string, isFuture) {
|
2525 | var output = this._relativeTime[string];
|
2526 | return isFunction(output) ? output(number, withoutSuffix, string, isFuture) : output.replace(/%d/i, number);
|
2527 | }
|
2528 |
|
2529 | function pastFuture(diff, output) {
|
2530 | var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
|
2531 | return isFunction(format) ? format(output) : format.replace(/%s/i, output);
|
2532 | }
|
2533 |
|
2534 | var aliases = {};
|
2535 |
|
2536 | function addUnitAlias(unit, shorthand) {
|
2537 | var lowerCase = unit.toLowerCase();
|
2538 | aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
|
2539 | }
|
2540 |
|
2541 | function normalizeUnits(units) {
|
2542 | return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
|
2543 | }
|
2544 |
|
2545 | function normalizeObjectUnits(inputObject) {
|
2546 | var normalizedInput = {},
|
2547 | normalizedProp,
|
2548 | prop;
|
2549 |
|
2550 | for (prop in inputObject) {
|
2551 | if (hasOwnProp(inputObject, prop)) {
|
2552 | normalizedProp = normalizeUnits(prop);
|
2553 |
|
2554 | if (normalizedProp) {
|
2555 | normalizedInput[normalizedProp] = inputObject[prop];
|
2556 | }
|
2557 | }
|
2558 | }
|
2559 |
|
2560 | return normalizedInput;
|
2561 | }
|
2562 |
|
2563 | var priorities = {};
|
2564 |
|
2565 | function addUnitPriority(unit, priority) {
|
2566 | priorities[unit] = priority;
|
2567 | }
|
2568 |
|
2569 | function getPrioritizedUnits(unitsObj) {
|
2570 | var units = [];
|
2571 |
|
2572 | for (var u in unitsObj) {
|
2573 | units.push({
|
2574 | unit: u,
|
2575 | priority: priorities[u]
|
2576 | });
|
2577 | }
|
2578 |
|
2579 | units.sort(function (a, b) {
|
2580 | return a.priority - b.priority;
|
2581 | });
|
2582 | return units;
|
2583 | }
|
2584 |
|
2585 | function zeroFill(number, targetLength, forceSign) {
|
2586 | var absNumber = '' + Math.abs(number),
|
2587 | zerosToFill = targetLength - absNumber.length,
|
2588 | sign = number >= 0;
|
2589 | return (sign ? forceSign ? '+' : '' : '-') + Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
|
2590 | }
|
2591 |
|
2592 | 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;
|
2593 | var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
|
2594 | var formatFunctions = {};
|
2595 | var formatTokenFunctions = {};
|
2596 |
|
2597 |
|
2598 |
|
2599 |
|
2600 | function addFormatToken(token, padded, ordinal, callback) {
|
2601 | var func = callback;
|
2602 |
|
2603 | if (typeof callback === 'string') {
|
2604 | func = function () {
|
2605 | return this[callback]();
|
2606 | };
|
2607 | }
|
2608 |
|
2609 | if (token) {
|
2610 | formatTokenFunctions[token] = func;
|
2611 | }
|
2612 |
|
2613 | if (padded) {
|
2614 | formatTokenFunctions[padded[0]] = function () {
|
2615 | return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
|
2616 | };
|
2617 | }
|
2618 |
|
2619 | if (ordinal) {
|
2620 | formatTokenFunctions[ordinal] = function () {
|
2621 | return this.localeData().ordinal(func.apply(this, arguments), token);
|
2622 | };
|
2623 | }
|
2624 | }
|
2625 |
|
2626 | function removeFormattingTokens(input) {
|
2627 | if (input.match(/\[[\s\S]/)) {
|
2628 | return input.replace(/^\[|\]$/g, '');
|
2629 | }
|
2630 |
|
2631 | return input.replace(/\\/g, '');
|
2632 | }
|
2633 |
|
2634 | function makeFormatFunction(format) {
|
2635 | var array = format.match(formattingTokens),
|
2636 | i,
|
2637 | length;
|
2638 |
|
2639 | for (i = 0, length = array.length; i < length; i++) {
|
2640 | if (formatTokenFunctions[array[i]]) {
|
2641 | array[i] = formatTokenFunctions[array[i]];
|
2642 | } else {
|
2643 | array[i] = removeFormattingTokens(array[i]);
|
2644 | }
|
2645 | }
|
2646 |
|
2647 | return function (mom) {
|
2648 | var output = '',
|
2649 | i;
|
2650 |
|
2651 | for (i = 0; i < length; i++) {
|
2652 | output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
|
2653 | }
|
2654 |
|
2655 | return output;
|
2656 | };
|
2657 | }
|
2658 |
|
2659 |
|
2660 | function formatMoment(m, format) {
|
2661 | if (!m.isValid()) {
|
2662 | return m.localeData().invalidDate();
|
2663 | }
|
2664 |
|
2665 | format = expandFormat(format, m.localeData());
|
2666 | formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
|
2667 | return formatFunctions[format](m);
|
2668 | }
|
2669 |
|
2670 | function expandFormat(format, locale) {
|
2671 | var i = 5;
|
2672 |
|
2673 | function replaceLongDateFormatTokens(input) {
|
2674 | return locale.longDateFormat(input) || input;
|
2675 | }
|
2676 |
|
2677 | localFormattingTokens.lastIndex = 0;
|
2678 |
|
2679 | while (i >= 0 && localFormattingTokens.test(format)) {
|
2680 | format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
|
2681 | localFormattingTokens.lastIndex = 0;
|
2682 | i -= 1;
|
2683 | }
|
2684 |
|
2685 | return format;
|
2686 | }
|
2687 |
|
2688 | var match1 = /\d/;
|
2689 |
|
2690 | var match2 = /\d\d/;
|
2691 |
|
2692 | var match3 = /\d{3}/;
|
2693 |
|
2694 | var match4 = /\d{4}/;
|
2695 |
|
2696 | var match6 = /[+-]?\d{6}/;
|
2697 |
|
2698 | var match1to2 = /\d\d?/;
|
2699 |
|
2700 | var match3to4 = /\d\d\d\d?/;
|
2701 |
|
2702 | var match5to6 = /\d\d\d\d\d\d?/;
|
2703 |
|
2704 | var match1to3 = /\d{1,3}/;
|
2705 |
|
2706 | var match1to4 = /\d{1,4}/;
|
2707 |
|
2708 | var match1to6 = /[+-]?\d{1,6}/;
|
2709 |
|
2710 | var matchUnsigned = /\d+/;
|
2711 |
|
2712 | var matchSigned = /[+-]?\d+/;
|
2713 |
|
2714 | var matchOffset = /Z|[+-]\d\d:?\d\d/gi;
|
2715 |
|
2716 | var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi;
|
2717 |
|
2718 | var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/;
|
2719 |
|
2720 |
|
2721 |
|
2722 | var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
|
2723 | var regexes = {};
|
2724 |
|
2725 | function addRegexToken(token, regex, strictRegex) {
|
2726 | regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
|
2727 | return isStrict && strictRegex ? strictRegex : regex;
|
2728 | };
|
2729 | }
|
2730 |
|
2731 | function getParseRegexForToken(token, config) {
|
2732 | if (!hasOwnProp(regexes, token)) {
|
2733 | return new RegExp(unescapeFormat(token));
|
2734 | }
|
2735 |
|
2736 | return regexes[token](config._strict, config._locale);
|
2737 | }
|
2738 |
|
2739 |
|
2740 | function unescapeFormat(s) {
|
2741 | return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
|
2742 | return p1 || p2 || p3 || p4;
|
2743 | }));
|
2744 | }
|
2745 |
|
2746 | function regexEscape(s) {
|
2747 | return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
2748 | }
|
2749 |
|
2750 | var tokens = {};
|
2751 |
|
2752 | function addParseToken(token, callback) {
|
2753 | var i,
|
2754 | func = callback;
|
2755 |
|
2756 | if (typeof token === 'string') {
|
2757 | token = [token];
|
2758 | }
|
2759 |
|
2760 | if (isNumber(callback)) {
|
2761 | func = function (input, array) {
|
2762 | array[callback] = toInt(input);
|
2763 | };
|
2764 | }
|
2765 |
|
2766 | for (i = 0; i < token.length; i++) {
|
2767 | tokens[token[i]] = func;
|
2768 | }
|
2769 | }
|
2770 |
|
2771 | function addWeekParseToken(token, callback) {
|
2772 | addParseToken(token, function (input, array, config, token) {
|
2773 | config._w = config._w || {};
|
2774 | callback(input, config._w, config, token);
|
2775 | });
|
2776 | }
|
2777 |
|
2778 | function addTimeToArrayFromToken(token, input, config) {
|
2779 | if (input != null && hasOwnProp(tokens, token)) {
|
2780 | tokens[token](input, config._a, config, token);
|
2781 | }
|
2782 | }
|
2783 |
|
2784 | var YEAR = 0;
|
2785 | var MONTH = 1;
|
2786 | var DATE = 2;
|
2787 | var HOUR = 3;
|
2788 | var MINUTE = 4;
|
2789 | var SECOND = 5;
|
2790 | var MILLISECOND = 6;
|
2791 | var WEEK = 7;
|
2792 | var WEEKDAY = 8;
|
2793 |
|
2794 | addFormatToken('Y', 0, 0, function () {
|
2795 | var y = this.year();
|
2796 | return y <= 9999 ? '' + y : '+' + y;
|
2797 | });
|
2798 | addFormatToken(0, ['YY', 2], 0, function () {
|
2799 | return this.year() % 100;
|
2800 | });
|
2801 | addFormatToken(0, ['YYYY', 4], 0, 'year');
|
2802 | addFormatToken(0, ['YYYYY', 5], 0, 'year');
|
2803 | addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
|
2804 |
|
2805 | addUnitAlias('year', 'y');
|
2806 |
|
2807 | addUnitPriority('year', 1);
|
2808 |
|
2809 | addRegexToken('Y', matchSigned);
|
2810 | addRegexToken('YY', match1to2, match2);
|
2811 | addRegexToken('YYYY', match1to4, match4);
|
2812 | addRegexToken('YYYYY', match1to6, match6);
|
2813 | addRegexToken('YYYYYY', match1to6, match6);
|
2814 | addParseToken(['YYYYY', 'YYYYYY'], YEAR);
|
2815 | addParseToken('YYYY', function (input, array) {
|
2816 | array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
|
2817 | });
|
2818 | addParseToken('YY', function (input, array) {
|
2819 | array[YEAR] = hooks.parseTwoDigitYear(input);
|
2820 | });
|
2821 | addParseToken('Y', function (input, array) {
|
2822 | array[YEAR] = parseInt(input, 10);
|
2823 | });
|
2824 |
|
2825 | function daysInYear(year) {
|
2826 | return isLeapYear(year) ? 366 : 365;
|
2827 | }
|
2828 |
|
2829 | function isLeapYear(year) {
|
2830 | return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
2831 | }
|
2832 |
|
2833 |
|
2834 | hooks.parseTwoDigitYear = function (input) {
|
2835 | return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
|
2836 | };
|
2837 |
|
2838 |
|
2839 | var getSetYear = makeGetSet('FullYear', true);
|
2840 |
|
2841 | function getIsLeapYear() {
|
2842 | return isLeapYear(this.year());
|
2843 | }
|
2844 |
|
2845 | function makeGetSet(unit, keepTime) {
|
2846 | return function (value) {
|
2847 | if (value != null) {
|
2848 | set$1(this, unit, value);
|
2849 | hooks.updateOffset(this, keepTime);
|
2850 | return this;
|
2851 | } else {
|
2852 | return get(this, unit);
|
2853 | }
|
2854 | };
|
2855 | }
|
2856 |
|
2857 | function get(mom, unit) {
|
2858 | return mom.isValid() ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
|
2859 | }
|
2860 |
|
2861 | function set$1(mom, unit, value) {
|
2862 | if (mom.isValid() && !isNaN(value)) {
|
2863 | if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
|
2864 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
|
2865 | } else {
|
2866 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
|
2867 | }
|
2868 | }
|
2869 | }
|
2870 |
|
2871 |
|
2872 | function stringGet(units) {
|
2873 | units = normalizeUnits(units);
|
2874 |
|
2875 | if (isFunction(this[units])) {
|
2876 | return this[units]();
|
2877 | }
|
2878 |
|
2879 | return this;
|
2880 | }
|
2881 |
|
2882 | function stringSet(units, value) {
|
2883 | if (typeof units === 'object') {
|
2884 | units = normalizeObjectUnits(units);
|
2885 | var prioritized = getPrioritizedUnits(units);
|
2886 |
|
2887 | for (var i = 0; i < prioritized.length; i++) {
|
2888 | this[prioritized[i].unit](units[prioritized[i].unit]);
|
2889 | }
|
2890 | } else {
|
2891 | units = normalizeUnits(units);
|
2892 |
|
2893 | if (isFunction(this[units])) {
|
2894 | return this[units](value);
|
2895 | }
|
2896 | }
|
2897 |
|
2898 | return this;
|
2899 | }
|
2900 |
|
2901 | function mod(n, x) {
|
2902 | return (n % x + x) % x;
|
2903 | }
|
2904 |
|
2905 | var indexOf;
|
2906 |
|
2907 | if (Array.prototype.indexOf) {
|
2908 | indexOf = Array.prototype.indexOf;
|
2909 | } else {
|
2910 | indexOf = function (o) {
|
2911 |
|
2912 | var i;
|
2913 |
|
2914 | for (i = 0; i < this.length; ++i) {
|
2915 | if (this[i] === o) {
|
2916 | return i;
|
2917 | }
|
2918 | }
|
2919 |
|
2920 | return -1;
|
2921 | };
|
2922 | }
|
2923 |
|
2924 | function daysInMonth(year, month) {
|
2925 | if (isNaN(year) || isNaN(month)) {
|
2926 | return NaN;
|
2927 | }
|
2928 |
|
2929 | var modMonth = mod(month, 12);
|
2930 | year += (month - modMonth) / 12;
|
2931 | return modMonth === 1 ? isLeapYear(year) ? 29 : 28 : 31 - modMonth % 7 % 2;
|
2932 | }
|
2933 |
|
2934 |
|
2935 | addFormatToken('M', ['MM', 2], 'Mo', function () {
|
2936 | return this.month() + 1;
|
2937 | });
|
2938 | addFormatToken('MMM', 0, 0, function (format) {
|
2939 | return this.localeData().monthsShort(this, format);
|
2940 | });
|
2941 | addFormatToken('MMMM', 0, 0, function (format) {
|
2942 | return this.localeData().months(this, format);
|
2943 | });
|
2944 |
|
2945 | addUnitAlias('month', 'M');
|
2946 |
|
2947 | addUnitPriority('month', 8);
|
2948 |
|
2949 | addRegexToken('M', match1to2);
|
2950 | addRegexToken('MM', match1to2, match2);
|
2951 | addRegexToken('MMM', function (isStrict, locale) {
|
2952 | return locale.monthsShortRegex(isStrict);
|
2953 | });
|
2954 | addRegexToken('MMMM', function (isStrict, locale) {
|
2955 | return locale.monthsRegex(isStrict);
|
2956 | });
|
2957 | addParseToken(['M', 'MM'], function (input, array) {
|
2958 | array[MONTH] = toInt(input) - 1;
|
2959 | });
|
2960 | addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
|
2961 | var month = config._locale.monthsParse(input, token, config._strict);
|
2962 |
|
2963 |
|
2964 | if (month != null) {
|
2965 | array[MONTH] = month;
|
2966 | } else {
|
2967 | getParsingFlags(config).invalidMonth = input;
|
2968 | }
|
2969 | });
|
2970 |
|
2971 | var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
|
2972 | var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
|
2973 |
|
2974 | function localeMonths(m, format) {
|
2975 | if (!m) {
|
2976 | return isArray(this._months) ? this._months : this._months['standalone'];
|
2977 | }
|
2978 |
|
2979 | return isArray(this._months) ? this._months[m.month()] : this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
|
2980 | }
|
2981 |
|
2982 | var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
|
2983 |
|
2984 | function localeMonthsShort(m, format) {
|
2985 | if (!m) {
|
2986 | return isArray(this._monthsShort) ? this._monthsShort : this._monthsShort['standalone'];
|
2987 | }
|
2988 |
|
2989 | return isArray(this._monthsShort) ? this._monthsShort[m.month()] : this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
|
2990 | }
|
2991 |
|
2992 | function handleStrictParse(monthName, format, strict) {
|
2993 | var i,
|
2994 | ii,
|
2995 | mom,
|
2996 | llc = monthName.toLocaleLowerCase();
|
2997 |
|
2998 | if (!this._monthsParse) {
|
2999 |
|
3000 | this._monthsParse = [];
|
3001 | this._longMonthsParse = [];
|
3002 | this._shortMonthsParse = [];
|
3003 |
|
3004 | for (i = 0; i < 12; ++i) {
|
3005 | mom = createUTC([2000, i]);
|
3006 | this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
|
3007 | this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
|
3008 | }
|
3009 | }
|
3010 |
|
3011 | if (strict) {
|
3012 | if (format === 'MMM') {
|
3013 | ii = indexOf.call(this._shortMonthsParse, llc);
|
3014 | return ii !== -1 ? ii : null;
|
3015 | } else {
|
3016 | ii = indexOf.call(this._longMonthsParse, llc);
|
3017 | return ii !== -1 ? ii : null;
|
3018 | }
|
3019 | } else {
|
3020 | if (format === 'MMM') {
|
3021 | ii = indexOf.call(this._shortMonthsParse, llc);
|
3022 |
|
3023 | if (ii !== -1) {
|
3024 | return ii;
|
3025 | }
|
3026 |
|
3027 | ii = indexOf.call(this._longMonthsParse, llc);
|
3028 | return ii !== -1 ? ii : null;
|
3029 | } else {
|
3030 | ii = indexOf.call(this._longMonthsParse, llc);
|
3031 |
|
3032 | if (ii !== -1) {
|
3033 | return ii;
|
3034 | }
|
3035 |
|
3036 | ii = indexOf.call(this._shortMonthsParse, llc);
|
3037 | return ii !== -1 ? ii : null;
|
3038 | }
|
3039 | }
|
3040 | }
|
3041 |
|
3042 | function localeMonthsParse(monthName, format, strict) {
|
3043 | var i, mom, regex;
|
3044 |
|
3045 | if (this._monthsParseExact) {
|
3046 | return handleStrictParse.call(this, monthName, format, strict);
|
3047 | }
|
3048 |
|
3049 | if (!this._monthsParse) {
|
3050 | this._monthsParse = [];
|
3051 | this._longMonthsParse = [];
|
3052 | this._shortMonthsParse = [];
|
3053 | }
|
3054 |
|
3055 |
|
3056 |
|
3057 |
|
3058 | for (i = 0; i < 12; i++) {
|
3059 |
|
3060 | mom = createUTC([2000, i]);
|
3061 |
|
3062 | if (strict && !this._longMonthsParse[i]) {
|
3063 | this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
|
3064 | this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
|
3065 | }
|
3066 |
|
3067 | if (!strict && !this._monthsParse[i]) {
|
3068 | regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
|
3069 | this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
3070 | }
|
3071 |
|
3072 |
|
3073 | if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
|
3074 | return i;
|
3075 | } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
|
3076 | return i;
|
3077 | } else if (!strict && this._monthsParse[i].test(monthName)) {
|
3078 | return i;
|
3079 | }
|
3080 | }
|
3081 | }
|
3082 |
|
3083 |
|
3084 | function setMonth(mom, value) {
|
3085 | var dayOfMonth;
|
3086 |
|
3087 | if (!mom.isValid()) {
|
3088 |
|
3089 | return mom;
|
3090 | }
|
3091 |
|
3092 | if (typeof value === 'string') {
|
3093 | if (/^\d+$/.test(value)) {
|
3094 | value = toInt(value);
|
3095 | } else {
|
3096 | value = mom.localeData().monthsParse(value);
|
3097 |
|
3098 | if (!isNumber(value)) {
|
3099 | return mom;
|
3100 | }
|
3101 | }
|
3102 | }
|
3103 |
|
3104 | dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
|
3105 |
|
3106 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
|
3107 |
|
3108 | return mom;
|
3109 | }
|
3110 |
|
3111 | function getSetMonth(value) {
|
3112 | if (value != null) {
|
3113 | setMonth(this, value);
|
3114 | hooks.updateOffset(this, true);
|
3115 | return this;
|
3116 | } else {
|
3117 | return get(this, 'Month');
|
3118 | }
|
3119 | }
|
3120 |
|
3121 | function getDaysInMonth() {
|
3122 | return daysInMonth(this.year(), this.month());
|
3123 | }
|
3124 |
|
3125 | var defaultMonthsShortRegex = matchWord;
|
3126 |
|
3127 | function monthsShortRegex(isStrict) {
|
3128 | if (this._monthsParseExact) {
|
3129 | if (!hasOwnProp(this, '_monthsRegex')) {
|
3130 | computeMonthsParse.call(this);
|
3131 | }
|
3132 |
|
3133 | if (isStrict) {
|
3134 | return this._monthsShortStrictRegex;
|
3135 | } else {
|
3136 | return this._monthsShortRegex;
|
3137 | }
|
3138 | } else {
|
3139 | if (!hasOwnProp(this, '_monthsShortRegex')) {
|
3140 | this._monthsShortRegex = defaultMonthsShortRegex;
|
3141 | }
|
3142 |
|
3143 | return this._monthsShortStrictRegex && isStrict ? this._monthsShortStrictRegex : this._monthsShortRegex;
|
3144 | }
|
3145 | }
|
3146 |
|
3147 | var defaultMonthsRegex = matchWord;
|
3148 |
|
3149 | function monthsRegex(isStrict) {
|
3150 | if (this._monthsParseExact) {
|
3151 | if (!hasOwnProp(this, '_monthsRegex')) {
|
3152 | computeMonthsParse.call(this);
|
3153 | }
|
3154 |
|
3155 | if (isStrict) {
|
3156 | return this._monthsStrictRegex;
|
3157 | } else {
|
3158 | return this._monthsRegex;
|
3159 | }
|
3160 | } else {
|
3161 | if (!hasOwnProp(this, '_monthsRegex')) {
|
3162 | this._monthsRegex = defaultMonthsRegex;
|
3163 | }
|
3164 |
|
3165 | return this._monthsStrictRegex && isStrict ? this._monthsStrictRegex : this._monthsRegex;
|
3166 | }
|
3167 | }
|
3168 |
|
3169 | function computeMonthsParse() {
|
3170 | function cmpLenRev(a, b) {
|
3171 | return b.length - a.length;
|
3172 | }
|
3173 |
|
3174 | var shortPieces = [],
|
3175 | longPieces = [],
|
3176 | mixedPieces = [],
|
3177 | i,
|
3178 | mom;
|
3179 |
|
3180 | for (i = 0; i < 12; i++) {
|
3181 |
|
3182 | mom = createUTC([2000, i]);
|
3183 | shortPieces.push(this.monthsShort(mom, ''));
|
3184 | longPieces.push(this.months(mom, ''));
|
3185 | mixedPieces.push(this.months(mom, ''));
|
3186 | mixedPieces.push(this.monthsShort(mom, ''));
|
3187 | }
|
3188 |
|
3189 |
|
3190 |
|
3191 | shortPieces.sort(cmpLenRev);
|
3192 | longPieces.sort(cmpLenRev);
|
3193 | mixedPieces.sort(cmpLenRev);
|
3194 |
|
3195 | for (i = 0; i < 12; i++) {
|
3196 | shortPieces[i] = regexEscape(shortPieces[i]);
|
3197 | longPieces[i] = regexEscape(longPieces[i]);
|
3198 | }
|
3199 |
|
3200 | for (i = 0; i < 24; i++) {
|
3201 | mixedPieces[i] = regexEscape(mixedPieces[i]);
|
3202 | }
|
3203 |
|
3204 | this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
3205 | this._monthsShortRegex = this._monthsRegex;
|
3206 | this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
3207 | this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
3208 | }
|
3209 |
|
3210 | function createDate(y, m, d, h, M, s, ms) {
|
3211 |
|
3212 |
|
3213 | var date;
|
3214 |
|
3215 | if (y < 100 && y >= 0) {
|
3216 |
|
3217 | date = new Date(y + 400, m, d, h, M, s, ms);
|
3218 |
|
3219 | if (isFinite(date.getFullYear())) {
|
3220 | date.setFullYear(y);
|
3221 | }
|
3222 | } else {
|
3223 | date = new Date(y, m, d, h, M, s, ms);
|
3224 | }
|
3225 |
|
3226 | return date;
|
3227 | }
|
3228 |
|
3229 | function createUTCDate(y) {
|
3230 | var date;
|
3231 |
|
3232 | if (y < 100 && y >= 0) {
|
3233 | var args = Array.prototype.slice.call(arguments);
|
3234 |
|
3235 | args[0] = y + 400;
|
3236 | date = new Date(Date.UTC.apply(null, args));
|
3237 |
|
3238 | if (isFinite(date.getUTCFullYear())) {
|
3239 | date.setUTCFullYear(y);
|
3240 | }
|
3241 | } else {
|
3242 | date = new Date(Date.UTC.apply(null, arguments));
|
3243 | }
|
3244 |
|
3245 | return date;
|
3246 | }
|
3247 |
|
3248 |
|
3249 | function firstWeekOffset(year, dow, doy) {
|
3250 | var
|
3251 | fwd = 7 + dow - doy,
|
3252 |
|
3253 | fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
|
3254 | return -fwdlw + fwd - 1;
|
3255 | }
|
3256 |
|
3257 |
|
3258 | function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
|
3259 | var localWeekday = (7 + weekday - dow) % 7,
|
3260 | weekOffset = firstWeekOffset(year, dow, doy),
|
3261 | dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
|
3262 | resYear,
|
3263 | resDayOfYear;
|
3264 |
|
3265 | if (dayOfYear <= 0) {
|
3266 | resYear = year - 1;
|
3267 | resDayOfYear = daysInYear(resYear) + dayOfYear;
|
3268 | } else if (dayOfYear > daysInYear(year)) {
|
3269 | resYear = year + 1;
|
3270 | resDayOfYear = dayOfYear - daysInYear(year);
|
3271 | } else {
|
3272 | resYear = year;
|
3273 | resDayOfYear = dayOfYear;
|
3274 | }
|
3275 |
|
3276 | return {
|
3277 | year: resYear,
|
3278 | dayOfYear: resDayOfYear
|
3279 | };
|
3280 | }
|
3281 |
|
3282 | function weekOfYear(mom, dow, doy) {
|
3283 | var weekOffset = firstWeekOffset(mom.year(), dow, doy),
|
3284 | week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
|
3285 | resWeek,
|
3286 | resYear;
|
3287 |
|
3288 | if (week < 1) {
|
3289 | resYear = mom.year() - 1;
|
3290 | resWeek = week + weeksInYear(resYear, dow, doy);
|
3291 | } else if (week > weeksInYear(mom.year(), dow, doy)) {
|
3292 | resWeek = week - weeksInYear(mom.year(), dow, doy);
|
3293 | resYear = mom.year() + 1;
|
3294 | } else {
|
3295 | resYear = mom.year();
|
3296 | resWeek = week;
|
3297 | }
|
3298 |
|
3299 | return {
|
3300 | week: resWeek,
|
3301 | year: resYear
|
3302 | };
|
3303 | }
|
3304 |
|
3305 | function weeksInYear(year, dow, doy) {
|
3306 | var weekOffset = firstWeekOffset(year, dow, doy),
|
3307 | weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
|
3308 | return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
|
3309 | }
|
3310 |
|
3311 |
|
3312 | addFormatToken('w', ['ww', 2], 'wo', 'week');
|
3313 | addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
|
3314 |
|
3315 | addUnitAlias('week', 'w');
|
3316 | addUnitAlias('isoWeek', 'W');
|
3317 |
|
3318 | addUnitPriority('week', 5);
|
3319 | addUnitPriority('isoWeek', 5);
|
3320 |
|
3321 | addRegexToken('w', match1to2);
|
3322 | addRegexToken('ww', match1to2, match2);
|
3323 | addRegexToken('W', match1to2);
|
3324 | addRegexToken('WW', match1to2, match2);
|
3325 | addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
|
3326 | week[token.substr(0, 1)] = toInt(input);
|
3327 | });
|
3328 |
|
3329 |
|
3330 | function localeWeek(mom) {
|
3331 | return weekOfYear(mom, this._week.dow, this._week.doy).week;
|
3332 | }
|
3333 |
|
3334 | var defaultLocaleWeek = {
|
3335 | dow: 0,
|
3336 |
|
3337 | doy: 6
|
3338 |
|
3339 | };
|
3340 |
|
3341 | function localeFirstDayOfWeek() {
|
3342 | return this._week.dow;
|
3343 | }
|
3344 |
|
3345 | function localeFirstDayOfYear() {
|
3346 | return this._week.doy;
|
3347 | }
|
3348 |
|
3349 |
|
3350 | function getSetWeek(input) {
|
3351 | var week = this.localeData().week(this);
|
3352 | return input == null ? week : this.add((input - week) * 7, 'd');
|
3353 | }
|
3354 |
|
3355 | function getSetISOWeek(input) {
|
3356 | var week = weekOfYear(this, 1, 4).week;
|
3357 | return input == null ? week : this.add((input - week) * 7, 'd');
|
3358 | }
|
3359 |
|
3360 |
|
3361 | addFormatToken('d', 0, 'do', 'day');
|
3362 | addFormatToken('dd', 0, 0, function (format) {
|
3363 | return this.localeData().weekdaysMin(this, format);
|
3364 | });
|
3365 | addFormatToken('ddd', 0, 0, function (format) {
|
3366 | return this.localeData().weekdaysShort(this, format);
|
3367 | });
|
3368 | addFormatToken('dddd', 0, 0, function (format) {
|
3369 | return this.localeData().weekdays(this, format);
|
3370 | });
|
3371 | addFormatToken('e', 0, 0, 'weekday');
|
3372 | addFormatToken('E', 0, 0, 'isoWeekday');
|
3373 |
|
3374 | addUnitAlias('day', 'd');
|
3375 | addUnitAlias('weekday', 'e');
|
3376 | addUnitAlias('isoWeekday', 'E');
|
3377 |
|
3378 | addUnitPriority('day', 11);
|
3379 | addUnitPriority('weekday', 11);
|
3380 | addUnitPriority('isoWeekday', 11);
|
3381 |
|
3382 | addRegexToken('d', match1to2);
|
3383 | addRegexToken('e', match1to2);
|
3384 | addRegexToken('E', match1to2);
|
3385 | addRegexToken('dd', function (isStrict, locale) {
|
3386 | return locale.weekdaysMinRegex(isStrict);
|
3387 | });
|
3388 | addRegexToken('ddd', function (isStrict, locale) {
|
3389 | return locale.weekdaysShortRegex(isStrict);
|
3390 | });
|
3391 | addRegexToken('dddd', function (isStrict, locale) {
|
3392 | return locale.weekdaysRegex(isStrict);
|
3393 | });
|
3394 | addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
|
3395 | var weekday = config._locale.weekdaysParse(input, token, config._strict);
|
3396 |
|
3397 |
|
3398 | if (weekday != null) {
|
3399 | week.d = weekday;
|
3400 | } else {
|
3401 | getParsingFlags(config).invalidWeekday = input;
|
3402 | }
|
3403 | });
|
3404 | addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
|
3405 | week[token] = toInt(input);
|
3406 | });
|
3407 |
|
3408 | function parseWeekday(input, locale) {
|
3409 | if (typeof input !== 'string') {
|
3410 | return input;
|
3411 | }
|
3412 |
|
3413 | if (!isNaN(input)) {
|
3414 | return parseInt(input, 10);
|
3415 | }
|
3416 |
|
3417 | input = locale.weekdaysParse(input);
|
3418 |
|
3419 | if (typeof input === 'number') {
|
3420 | return input;
|
3421 | }
|
3422 |
|
3423 | return null;
|
3424 | }
|
3425 |
|
3426 | function parseIsoWeekday(input, locale) {
|
3427 | if (typeof input === 'string') {
|
3428 | return locale.weekdaysParse(input) % 7 || 7;
|
3429 | }
|
3430 |
|
3431 | return isNaN(input) ? null : input;
|
3432 | }
|
3433 |
|
3434 |
|
3435 | function shiftWeekdays(ws, n) {
|
3436 | return ws.slice(n, 7).concat(ws.slice(0, n));
|
3437 | }
|
3438 |
|
3439 | var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
|
3440 |
|
3441 | function localeWeekdays(m, format) {
|
3442 | var weekdays = isArray(this._weekdays) ? this._weekdays : this._weekdays[m && m !== true && this._weekdays.isFormat.test(format) ? 'format' : 'standalone'];
|
3443 | return m === true ? shiftWeekdays(weekdays, this._week.dow) : m ? weekdays[m.day()] : weekdays;
|
3444 | }
|
3445 |
|
3446 | var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
|
3447 |
|
3448 | function localeWeekdaysShort(m) {
|
3449 | return m === true ? shiftWeekdays(this._weekdaysShort, this._week.dow) : m ? this._weekdaysShort[m.day()] : this._weekdaysShort;
|
3450 | }
|
3451 |
|
3452 | var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
|
3453 |
|
3454 | function localeWeekdaysMin(m) {
|
3455 | return m === true ? shiftWeekdays(this._weekdaysMin, this._week.dow) : m ? this._weekdaysMin[m.day()] : this._weekdaysMin;
|
3456 | }
|
3457 |
|
3458 | function handleStrictParse$1(weekdayName, format, strict) {
|
3459 | var i,
|
3460 | ii,
|
3461 | mom,
|
3462 | llc = weekdayName.toLocaleLowerCase();
|
3463 |
|
3464 | if (!this._weekdaysParse) {
|
3465 | this._weekdaysParse = [];
|
3466 | this._shortWeekdaysParse = [];
|
3467 | this._minWeekdaysParse = [];
|
3468 |
|
3469 | for (i = 0; i < 7; ++i) {
|
3470 | mom = createUTC([2000, 1]).day(i);
|
3471 | this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
|
3472 | this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
|
3473 | this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
|
3474 | }
|
3475 | }
|
3476 |
|
3477 | if (strict) {
|
3478 | if (format === 'dddd') {
|
3479 | ii = indexOf.call(this._weekdaysParse, llc);
|
3480 | return ii !== -1 ? ii : null;
|
3481 | } else if (format === 'ddd') {
|
3482 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
3483 | return ii !== -1 ? ii : null;
|
3484 | } else {
|
3485 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
3486 | return ii !== -1 ? ii : null;
|
3487 | }
|
3488 | } else {
|
3489 | if (format === 'dddd') {
|
3490 | ii = indexOf.call(this._weekdaysParse, llc);
|
3491 |
|
3492 | if (ii !== -1) {
|
3493 | return ii;
|
3494 | }
|
3495 |
|
3496 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
3497 |
|
3498 | if (ii !== -1) {
|
3499 | return ii;
|
3500 | }
|
3501 |
|
3502 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
3503 | return ii !== -1 ? ii : null;
|
3504 | } else if (format === 'ddd') {
|
3505 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
3506 |
|
3507 | if (ii !== -1) {
|
3508 | return ii;
|
3509 | }
|
3510 |
|
3511 | ii = indexOf.call(this._weekdaysParse, llc);
|
3512 |
|
3513 | if (ii !== -1) {
|
3514 | return ii;
|
3515 | }
|
3516 |
|
3517 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
3518 | return ii !== -1 ? ii : null;
|
3519 | } else {
|
3520 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
3521 |
|
3522 | if (ii !== -1) {
|
3523 | return ii;
|
3524 | }
|
3525 |
|
3526 | ii = indexOf.call(this._weekdaysParse, llc);
|
3527 |
|
3528 | if (ii !== -1) {
|
3529 | return ii;
|
3530 | }
|
3531 |
|
3532 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
3533 | return ii !== -1 ? ii : null;
|
3534 | }
|
3535 | }
|
3536 | }
|
3537 |
|
3538 | function localeWeekdaysParse(weekdayName, format, strict) {
|
3539 | var i, mom, regex;
|
3540 |
|
3541 | if (this._weekdaysParseExact) {
|
3542 | return handleStrictParse$1.call(this, weekdayName, format, strict);
|
3543 | }
|
3544 |
|
3545 | if (!this._weekdaysParse) {
|
3546 | this._weekdaysParse = [];
|
3547 | this._minWeekdaysParse = [];
|
3548 | this._shortWeekdaysParse = [];
|
3549 | this._fullWeekdaysParse = [];
|
3550 | }
|
3551 |
|
3552 | for (i = 0; i < 7; i++) {
|
3553 |
|
3554 | mom = createUTC([2000, 1]).day(i);
|
3555 |
|
3556 | if (strict && !this._fullWeekdaysParse[i]) {
|
3557 | this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i');
|
3558 | this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i');
|
3559 | this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i');
|
3560 | }
|
3561 |
|
3562 | if (!this._weekdaysParse[i]) {
|
3563 | regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
|
3564 | this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
3565 | }
|
3566 |
|
3567 |
|
3568 | if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
|
3569 | return i;
|
3570 | } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
|
3571 | return i;
|
3572 | } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
|
3573 | return i;
|
3574 | } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
|
3575 | return i;
|
3576 | }
|
3577 | }
|
3578 | }
|
3579 |
|
3580 |
|
3581 | function getSetDayOfWeek(input) {
|
3582 | if (!this.isValid()) {
|
3583 | return input != null ? this : NaN;
|
3584 | }
|
3585 |
|
3586 | var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
|
3587 |
|
3588 | if (input != null) {
|
3589 | input = parseWeekday(input, this.localeData());
|
3590 | return this.add(input - day, 'd');
|
3591 | } else {
|
3592 | return day;
|
3593 | }
|
3594 | }
|
3595 |
|
3596 | function getSetLocaleDayOfWeek(input) {
|
3597 | if (!this.isValid()) {
|
3598 | return input != null ? this : NaN;
|
3599 | }
|
3600 |
|
3601 | var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
|
3602 | return input == null ? weekday : this.add(input - weekday, 'd');
|
3603 | }
|
3604 |
|
3605 | function getSetISODayOfWeek(input) {
|
3606 | if (!this.isValid()) {
|
3607 | return input != null ? this : NaN;
|
3608 | }
|
3609 |
|
3610 |
|
3611 |
|
3612 |
|
3613 | if (input != null) {
|
3614 | var weekday = parseIsoWeekday(input, this.localeData());
|
3615 | return this.day(this.day() % 7 ? weekday : weekday - 7);
|
3616 | } else {
|
3617 | return this.day() || 7;
|
3618 | }
|
3619 | }
|
3620 |
|
3621 | var defaultWeekdaysRegex = matchWord;
|
3622 |
|
3623 | function weekdaysRegex(isStrict) {
|
3624 | if (this._weekdaysParseExact) {
|
3625 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
3626 | computeWeekdaysParse.call(this);
|
3627 | }
|
3628 |
|
3629 | if (isStrict) {
|
3630 | return this._weekdaysStrictRegex;
|
3631 | } else {
|
3632 | return this._weekdaysRegex;
|
3633 | }
|
3634 | } else {
|
3635 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
3636 | this._weekdaysRegex = defaultWeekdaysRegex;
|
3637 | }
|
3638 |
|
3639 | return this._weekdaysStrictRegex && isStrict ? this._weekdaysStrictRegex : this._weekdaysRegex;
|
3640 | }
|
3641 | }
|
3642 |
|
3643 | var defaultWeekdaysShortRegex = matchWord;
|
3644 |
|
3645 | function weekdaysShortRegex(isStrict) {
|
3646 | if (this._weekdaysParseExact) {
|
3647 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
3648 | computeWeekdaysParse.call(this);
|
3649 | }
|
3650 |
|
3651 | if (isStrict) {
|
3652 | return this._weekdaysShortStrictRegex;
|
3653 | } else {
|
3654 | return this._weekdaysShortRegex;
|
3655 | }
|
3656 | } else {
|
3657 | if (!hasOwnProp(this, '_weekdaysShortRegex')) {
|
3658 | this._weekdaysShortRegex = defaultWeekdaysShortRegex;
|
3659 | }
|
3660 |
|
3661 | return this._weekdaysShortStrictRegex && isStrict ? this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
|
3662 | }
|
3663 | }
|
3664 |
|
3665 | var defaultWeekdaysMinRegex = matchWord;
|
3666 |
|
3667 | function weekdaysMinRegex(isStrict) {
|
3668 | if (this._weekdaysParseExact) {
|
3669 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
3670 | computeWeekdaysParse.call(this);
|
3671 | }
|
3672 |
|
3673 | if (isStrict) {
|
3674 | return this._weekdaysMinStrictRegex;
|
3675 | } else {
|
3676 | return this._weekdaysMinRegex;
|
3677 | }
|
3678 | } else {
|
3679 | if (!hasOwnProp(this, '_weekdaysMinRegex')) {
|
3680 | this._weekdaysMinRegex = defaultWeekdaysMinRegex;
|
3681 | }
|
3682 |
|
3683 | return this._weekdaysMinStrictRegex && isStrict ? this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
|
3684 | }
|
3685 | }
|
3686 |
|
3687 | function computeWeekdaysParse() {
|
3688 | function cmpLenRev(a, b) {
|
3689 | return b.length - a.length;
|
3690 | }
|
3691 |
|
3692 | var minPieces = [],
|
3693 | shortPieces = [],
|
3694 | longPieces = [],
|
3695 | mixedPieces = [],
|
3696 | i,
|
3697 | mom,
|
3698 | minp,
|
3699 | shortp,
|
3700 | longp;
|
3701 |
|
3702 | for (i = 0; i < 7; i++) {
|
3703 |
|
3704 | mom = createUTC([2000, 1]).day(i);
|
3705 | minp = this.weekdaysMin(mom, '');
|
3706 | shortp = this.weekdaysShort(mom, '');
|
3707 | longp = this.weekdays(mom, '');
|
3708 | minPieces.push(minp);
|
3709 | shortPieces.push(shortp);
|
3710 | longPieces.push(longp);
|
3711 | mixedPieces.push(minp);
|
3712 | mixedPieces.push(shortp);
|
3713 | mixedPieces.push(longp);
|
3714 | }
|
3715 |
|
3716 |
|
3717 |
|
3718 | minPieces.sort(cmpLenRev);
|
3719 | shortPieces.sort(cmpLenRev);
|
3720 | longPieces.sort(cmpLenRev);
|
3721 | mixedPieces.sort(cmpLenRev);
|
3722 |
|
3723 | for (i = 0; i < 7; i++) {
|
3724 | shortPieces[i] = regexEscape(shortPieces[i]);
|
3725 | longPieces[i] = regexEscape(longPieces[i]);
|
3726 | mixedPieces[i] = regexEscape(mixedPieces[i]);
|
3727 | }
|
3728 |
|
3729 | this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
3730 | this._weekdaysShortRegex = this._weekdaysRegex;
|
3731 | this._weekdaysMinRegex = this._weekdaysRegex;
|
3732 | this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
3733 | this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
3734 | this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
|
3735 | }
|
3736 |
|
3737 |
|
3738 | function hFormat() {
|
3739 | return this.hours() % 12 || 12;
|
3740 | }
|
3741 |
|
3742 | function kFormat() {
|
3743 | return this.hours() || 24;
|
3744 | }
|
3745 |
|
3746 | addFormatToken('H', ['HH', 2], 0, 'hour');
|
3747 | addFormatToken('h', ['hh', 2], 0, hFormat);
|
3748 | addFormatToken('k', ['kk', 2], 0, kFormat);
|
3749 | addFormatToken('hmm', 0, 0, function () {
|
3750 | return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
|
3751 | });
|
3752 | addFormatToken('hmmss', 0, 0, function () {
|
3753 | return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
|
3754 | });
|
3755 | addFormatToken('Hmm', 0, 0, function () {
|
3756 | return '' + this.hours() + zeroFill(this.minutes(), 2);
|
3757 | });
|
3758 | addFormatToken('Hmmss', 0, 0, function () {
|
3759 | return '' + this.hours() + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
|
3760 | });
|
3761 |
|
3762 | function meridiem(token, lowercase) {
|
3763 | addFormatToken(token, 0, 0, function () {
|
3764 | return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
|
3765 | });
|
3766 | }
|
3767 |
|
3768 | meridiem('a', true);
|
3769 | meridiem('A', false);
|
3770 |
|
3771 | addUnitAlias('hour', 'h');
|
3772 |
|
3773 | addUnitPriority('hour', 13);
|
3774 |
|
3775 | function matchMeridiem(isStrict, locale) {
|
3776 | return locale._meridiemParse;
|
3777 | }
|
3778 |
|
3779 | addRegexToken('a', matchMeridiem);
|
3780 | addRegexToken('A', matchMeridiem);
|
3781 | addRegexToken('H', match1to2);
|
3782 | addRegexToken('h', match1to2);
|
3783 | addRegexToken('k', match1to2);
|
3784 | addRegexToken('HH', match1to2, match2);
|
3785 | addRegexToken('hh', match1to2, match2);
|
3786 | addRegexToken('kk', match1to2, match2);
|
3787 | addRegexToken('hmm', match3to4);
|
3788 | addRegexToken('hmmss', match5to6);
|
3789 | addRegexToken('Hmm', match3to4);
|
3790 | addRegexToken('Hmmss', match5to6);
|
3791 | addParseToken(['H', 'HH'], HOUR);
|
3792 | addParseToken(['k', 'kk'], function (input, array, config) {
|
3793 | var kInput = toInt(input);
|
3794 | array[HOUR] = kInput === 24 ? 0 : kInput;
|
3795 | });
|
3796 | addParseToken(['a', 'A'], function (input, array, config) {
|
3797 | config._isPm = config._locale.isPM(input);
|
3798 | config._meridiem = input;
|
3799 | });
|
3800 | addParseToken(['h', 'hh'], function (input, array, config) {
|
3801 | array[HOUR] = toInt(input);
|
3802 | getParsingFlags(config).bigHour = true;
|
3803 | });
|
3804 | addParseToken('hmm', function (input, array, config) {
|
3805 | var pos = input.length - 2;
|
3806 | array[HOUR] = toInt(input.substr(0, pos));
|
3807 | array[MINUTE] = toInt(input.substr(pos));
|
3808 | getParsingFlags(config).bigHour = true;
|
3809 | });
|
3810 | addParseToken('hmmss', function (input, array, config) {
|
3811 | var pos1 = input.length - 4;
|
3812 | var pos2 = input.length - 2;
|
3813 | array[HOUR] = toInt(input.substr(0, pos1));
|
3814 | array[MINUTE] = toInt(input.substr(pos1, 2));
|
3815 | array[SECOND] = toInt(input.substr(pos2));
|
3816 | getParsingFlags(config).bigHour = true;
|
3817 | });
|
3818 | addParseToken('Hmm', function (input, array, config) {
|
3819 | var pos = input.length - 2;
|
3820 | array[HOUR] = toInt(input.substr(0, pos));
|
3821 | array[MINUTE] = toInt(input.substr(pos));
|
3822 | });
|
3823 | addParseToken('Hmmss', function (input, array, config) {
|
3824 | var pos1 = input.length - 4;
|
3825 | var pos2 = input.length - 2;
|
3826 | array[HOUR] = toInt(input.substr(0, pos1));
|
3827 | array[MINUTE] = toInt(input.substr(pos1, 2));
|
3828 | array[SECOND] = toInt(input.substr(pos2));
|
3829 | });
|
3830 |
|
3831 | function localeIsPM(input) {
|
3832 |
|
3833 |
|
3834 | return (input + '').toLowerCase().charAt(0) === 'p';
|
3835 | }
|
3836 |
|
3837 | var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
|
3838 |
|
3839 | function localeMeridiem(hours, minutes, isLower) {
|
3840 | if (hours > 11) {
|
3841 | return isLower ? 'pm' : 'PM';
|
3842 | } else {
|
3843 | return isLower ? 'am' : 'AM';
|
3844 | }
|
3845 | }
|
3846 |
|
3847 |
|
3848 |
|
3849 |
|
3850 |
|
3851 |
|
3852 | var getSetHour = makeGetSet('Hours', true);
|
3853 | var baseConfig = {
|
3854 | calendar: defaultCalendar,
|
3855 | longDateFormat: defaultLongDateFormat,
|
3856 | invalidDate: defaultInvalidDate,
|
3857 | ordinal: defaultOrdinal,
|
3858 | dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
|
3859 | relativeTime: defaultRelativeTime,
|
3860 | months: defaultLocaleMonths,
|
3861 | monthsShort: defaultLocaleMonthsShort,
|
3862 | week: defaultLocaleWeek,
|
3863 | weekdays: defaultLocaleWeekdays,
|
3864 | weekdaysMin: defaultLocaleWeekdaysMin,
|
3865 | weekdaysShort: defaultLocaleWeekdaysShort,
|
3866 | meridiemParse: defaultLocaleMeridiemParse
|
3867 | };
|
3868 |
|
3869 | var locales = {};
|
3870 | var localeFamilies = {};
|
3871 | var globalLocale;
|
3872 |
|
3873 | function normalizeLocale(key) {
|
3874 | return key ? key.toLowerCase().replace('_', '-') : key;
|
3875 | }
|
3876 |
|
3877 |
|
3878 |
|
3879 |
|
3880 | function chooseLocale(names) {
|
3881 | var i = 0,
|
3882 | j,
|
3883 | next,
|
3884 | locale,
|
3885 | split;
|
3886 |
|
3887 | while (i < names.length) {
|
3888 | split = normalizeLocale(names[i]).split('-');
|
3889 | j = split.length;
|
3890 | next = normalizeLocale(names[i + 1]);
|
3891 | next = next ? next.split('-') : null;
|
3892 |
|
3893 | while (j > 0) {
|
3894 | locale = loadLocale(split.slice(0, j).join('-'));
|
3895 |
|
3896 | if (locale) {
|
3897 | return locale;
|
3898 | }
|
3899 |
|
3900 | if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
|
3901 |
|
3902 | break;
|
3903 | }
|
3904 |
|
3905 | j--;
|
3906 | }
|
3907 |
|
3908 | i++;
|
3909 | }
|
3910 |
|
3911 | return globalLocale;
|
3912 | }
|
3913 |
|
3914 | function loadLocale(name) {
|
3915 | var oldLocale = null;
|
3916 |
|
3917 | if (!locales[name] && 'object' !== 'undefined' && module && module.exports) {
|
3918 | try {
|
3919 | oldLocale = globalLocale._abbr;
|
3920 | var aliasedRequire = commonjsRequire;
|
3921 | aliasedRequire('./locale/' + name);
|
3922 | getSetGlobalLocale(oldLocale);
|
3923 | } catch (e) {}
|
3924 | }
|
3925 |
|
3926 | return locales[name];
|
3927 | }
|
3928 |
|
3929 |
|
3930 |
|
3931 |
|
3932 | function getSetGlobalLocale(key, values) {
|
3933 | var data;
|
3934 |
|
3935 | if (key) {
|
3936 | if (isUndefined(values)) {
|
3937 | data = getLocale(key);
|
3938 | } else {
|
3939 | data = defineLocale(key, values);
|
3940 | }
|
3941 |
|
3942 | if (data) {
|
3943 |
|
3944 | globalLocale = data;
|
3945 | } else {
|
3946 | if (typeof console !== 'undefined' && console.warn) {
|
3947 |
|
3948 | console.warn('Locale ' + key + ' not found. Did you forget to load it?');
|
3949 | }
|
3950 | }
|
3951 | }
|
3952 |
|
3953 | return globalLocale._abbr;
|
3954 | }
|
3955 |
|
3956 | function defineLocale(name, config) {
|
3957 | if (config !== null) {
|
3958 | var locale,
|
3959 | parentConfig = baseConfig;
|
3960 | config.abbr = name;
|
3961 |
|
3962 | if (locales[name] != null) {
|
3963 | deprecateSimple('defineLocaleOverride', 'use moment.updateLocale(localeName, config) to change ' + 'an existing locale. moment.defineLocale(localeName, ' + 'config) should only be used for creating a new locale ' + 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
|
3964 | parentConfig = locales[name]._config;
|
3965 | } else if (config.parentLocale != null) {
|
3966 | if (locales[config.parentLocale] != null) {
|
3967 | parentConfig = locales[config.parentLocale]._config;
|
3968 | } else {
|
3969 | locale = loadLocale(config.parentLocale);
|
3970 |
|
3971 | if (locale != null) {
|
3972 | parentConfig = locale._config;
|
3973 | } else {
|
3974 | if (!localeFamilies[config.parentLocale]) {
|
3975 | localeFamilies[config.parentLocale] = [];
|
3976 | }
|
3977 |
|
3978 | localeFamilies[config.parentLocale].push({
|
3979 | name: name,
|
3980 | config: config
|
3981 | });
|
3982 | return null;
|
3983 | }
|
3984 | }
|
3985 | }
|
3986 |
|
3987 | locales[name] = new Locale(mergeConfigs(parentConfig, config));
|
3988 |
|
3989 | if (localeFamilies[name]) {
|
3990 | localeFamilies[name].forEach(function (x) {
|
3991 | defineLocale(x.name, x.config);
|
3992 | });
|
3993 | }
|
3994 |
|
3995 |
|
3996 |
|
3997 |
|
3998 | getSetGlobalLocale(name);
|
3999 | return locales[name];
|
4000 | } else {
|
4001 |
|
4002 | delete locales[name];
|
4003 | return null;
|
4004 | }
|
4005 | }
|
4006 |
|
4007 | function updateLocale(name, config) {
|
4008 | if (config != null) {
|
4009 | var locale,
|
4010 | tmpLocale,
|
4011 | parentConfig = baseConfig;
|
4012 |
|
4013 | tmpLocale = loadLocale(name);
|
4014 |
|
4015 | if (tmpLocale != null) {
|
4016 | parentConfig = tmpLocale._config;
|
4017 | }
|
4018 |
|
4019 | config = mergeConfigs(parentConfig, config);
|
4020 | locale = new Locale(config);
|
4021 | locale.parentLocale = locales[name];
|
4022 | locales[name] = locale;
|
4023 |
|
4024 | getSetGlobalLocale(name);
|
4025 | } else {
|
4026 |
|
4027 | if (locales[name] != null) {
|
4028 | if (locales[name].parentLocale != null) {
|
4029 | locales[name] = locales[name].parentLocale;
|
4030 | } else if (locales[name] != null) {
|
4031 | delete locales[name];
|
4032 | }
|
4033 | }
|
4034 | }
|
4035 |
|
4036 | return locales[name];
|
4037 | }
|
4038 |
|
4039 |
|
4040 | function getLocale(key) {
|
4041 | var locale;
|
4042 |
|
4043 | if (key && key._locale && key._locale._abbr) {
|
4044 | key = key._locale._abbr;
|
4045 | }
|
4046 |
|
4047 | if (!key) {
|
4048 | return globalLocale;
|
4049 | }
|
4050 |
|
4051 | if (!isArray(key)) {
|
4052 |
|
4053 | locale = loadLocale(key);
|
4054 |
|
4055 | if (locale) {
|
4056 | return locale;
|
4057 | }
|
4058 |
|
4059 | key = [key];
|
4060 | }
|
4061 |
|
4062 | return chooseLocale(key);
|
4063 | }
|
4064 |
|
4065 | function listLocales() {
|
4066 | return keys(locales);
|
4067 | }
|
4068 |
|
4069 | function checkOverflow(m) {
|
4070 | var overflow;
|
4071 | var a = m._a;
|
4072 |
|
4073 | if (a && getParsingFlags(m).overflow === -2) {
|
4074 | overflow = a[MONTH] < 0 || a[MONTH] > 11 ? MONTH : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE : a[HOUR] < 0 || a[HOUR] > 24 || a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0) ? HOUR : a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE : a[SECOND] < 0 || a[SECOND] > 59 ? SECOND : a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND : -1;
|
4075 |
|
4076 | if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
|
4077 | overflow = DATE;
|
4078 | }
|
4079 |
|
4080 | if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
|
4081 | overflow = WEEK;
|
4082 | }
|
4083 |
|
4084 | if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
|
4085 | overflow = WEEKDAY;
|
4086 | }
|
4087 |
|
4088 | getParsingFlags(m).overflow = overflow;
|
4089 | }
|
4090 |
|
4091 | return m;
|
4092 | }
|
4093 |
|
4094 |
|
4095 | function defaults(a, b, c) {
|
4096 | if (a != null) {
|
4097 | return a;
|
4098 | }
|
4099 |
|
4100 | if (b != null) {
|
4101 | return b;
|
4102 | }
|
4103 |
|
4104 | return c;
|
4105 | }
|
4106 |
|
4107 | function currentDateArray(config) {
|
4108 |
|
4109 | var nowValue = new Date(hooks.now());
|
4110 |
|
4111 | if (config._useUTC) {
|
4112 | return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
|
4113 | }
|
4114 |
|
4115 | return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
|
4116 | }
|
4117 |
|
4118 |
|
4119 |
|
4120 |
|
4121 |
|
4122 | function configFromArray(config) {
|
4123 | var i,
|
4124 | date,
|
4125 | input = [],
|
4126 | currentDate,
|
4127 | expectedWeekday,
|
4128 | yearToUse;
|
4129 |
|
4130 | if (config._d) {
|
4131 | return;
|
4132 | }
|
4133 |
|
4134 | currentDate = currentDateArray(config);
|
4135 |
|
4136 | if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
|
4137 | dayOfYearFromWeekInfo(config);
|
4138 | }
|
4139 |
|
4140 |
|
4141 | if (config._dayOfYear != null) {
|
4142 | yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
|
4143 |
|
4144 | if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
|
4145 | getParsingFlags(config)._overflowDayOfYear = true;
|
4146 | }
|
4147 |
|
4148 | date = createUTCDate(yearToUse, 0, config._dayOfYear);
|
4149 | config._a[MONTH] = date.getUTCMonth();
|
4150 | config._a[DATE] = date.getUTCDate();
|
4151 | }
|
4152 |
|
4153 |
|
4154 |
|
4155 |
|
4156 |
|
4157 |
|
4158 | for (i = 0; i < 3 && config._a[i] == null; ++i) {
|
4159 | config._a[i] = input[i] = currentDate[i];
|
4160 | }
|
4161 |
|
4162 |
|
4163 | for (; i < 7; i++) {
|
4164 | config._a[i] = input[i] = config._a[i] == null ? i === 2 ? 1 : 0 : config._a[i];
|
4165 | }
|
4166 |
|
4167 |
|
4168 | if (config._a[HOUR] === 24 && config._a[MINUTE] === 0 && config._a[SECOND] === 0 && config._a[MILLISECOND] === 0) {
|
4169 | config._nextDay = true;
|
4170 | config._a[HOUR] = 0;
|
4171 | }
|
4172 |
|
4173 | config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
|
4174 | expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
|
4175 |
|
4176 |
|
4177 | if (config._tzm != null) {
|
4178 | config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
4179 | }
|
4180 |
|
4181 | if (config._nextDay) {
|
4182 | config._a[HOUR] = 24;
|
4183 | }
|
4184 |
|
4185 |
|
4186 | if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
|
4187 | getParsingFlags(config).weekdayMismatch = true;
|
4188 | }
|
4189 | }
|
4190 |
|
4191 | function dayOfYearFromWeekInfo(config) {
|
4192 | var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
|
4193 | w = config._w;
|
4194 |
|
4195 | if (w.GG != null || w.W != null || w.E != null) {
|
4196 | dow = 1;
|
4197 | doy = 4;
|
4198 |
|
4199 |
|
4200 |
|
4201 |
|
4202 | weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
|
4203 | week = defaults(w.W, 1);
|
4204 | weekday = defaults(w.E, 1);
|
4205 |
|
4206 | if (weekday < 1 || weekday > 7) {
|
4207 | weekdayOverflow = true;
|
4208 | }
|
4209 | } else {
|
4210 | dow = config._locale._week.dow;
|
4211 | doy = config._locale._week.doy;
|
4212 | var curWeek = weekOfYear(createLocal(), dow, doy);
|
4213 | weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
|
4214 |
|
4215 | week = defaults(w.w, curWeek.week);
|
4216 |
|
4217 | if (w.d != null) {
|
4218 |
|
4219 | weekday = w.d;
|
4220 |
|
4221 | if (weekday < 0 || weekday > 6) {
|
4222 | weekdayOverflow = true;
|
4223 | }
|
4224 | } else if (w.e != null) {
|
4225 |
|
4226 | weekday = w.e + dow;
|
4227 |
|
4228 | if (w.e < 0 || w.e > 6) {
|
4229 | weekdayOverflow = true;
|
4230 | }
|
4231 | } else {
|
4232 |
|
4233 | weekday = dow;
|
4234 | }
|
4235 | }
|
4236 |
|
4237 | if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
|
4238 | getParsingFlags(config)._overflowWeeks = true;
|
4239 | } else if (weekdayOverflow != null) {
|
4240 | getParsingFlags(config)._overflowWeekday = true;
|
4241 | } else {
|
4242 | temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
|
4243 | config._a[YEAR] = temp.year;
|
4244 | config._dayOfYear = temp.dayOfYear;
|
4245 | }
|
4246 | }
|
4247 |
|
4248 |
|
4249 |
|
4250 | 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)?)?$/;
|
4251 | 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)?)?$/;
|
4252 | var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
|
4253 | var isoDates = [['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], ['GGGG-[W]WW', /\d{4}-W\d\d/, false], ['YYYY-DDD', /\d{4}-\d{3}/], ['YYYY-MM', /\d{4}-\d\d/, false], ['YYYYYYMMDD', /[+-]\d{10}/], ['YYYYMMDD', /\d{8}/],
|
4254 | ['GGGG[W]WWE', /\d{4}W\d{3}/], ['GGGG[W]WW', /\d{4}W\d{2}/, false], ['YYYYDDD', /\d{7}/]];
|
4255 |
|
4256 | var isoTimes = [['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], ['HH:mm:ss', /\d\d:\d\d:\d\d/], ['HH:mm', /\d\d:\d\d/], ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], ['HHmmss', /\d\d\d\d\d\d/], ['HHmm', /\d\d\d\d/], ['HH', /\d\d/]];
|
4257 | var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
|
4258 |
|
4259 | function configFromISO(config) {
|
4260 | var i,
|
4261 | l,
|
4262 | string = config._i,
|
4263 | match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
|
4264 | allowTime,
|
4265 | dateFormat,
|
4266 | timeFormat,
|
4267 | tzFormat;
|
4268 |
|
4269 | if (match) {
|
4270 | getParsingFlags(config).iso = true;
|
4271 |
|
4272 | for (i = 0, l = isoDates.length; i < l; i++) {
|
4273 | if (isoDates[i][1].exec(match[1])) {
|
4274 | dateFormat = isoDates[i][0];
|
4275 | allowTime = isoDates[i][2] !== false;
|
4276 | break;
|
4277 | }
|
4278 | }
|
4279 |
|
4280 | if (dateFormat == null) {
|
4281 | config._isValid = false;
|
4282 | return;
|
4283 | }
|
4284 |
|
4285 | if (match[3]) {
|
4286 | for (i = 0, l = isoTimes.length; i < l; i++) {
|
4287 | if (isoTimes[i][1].exec(match[3])) {
|
4288 |
|
4289 | timeFormat = (match[2] || ' ') + isoTimes[i][0];
|
4290 | break;
|
4291 | }
|
4292 | }
|
4293 |
|
4294 | if (timeFormat == null) {
|
4295 | config._isValid = false;
|
4296 | return;
|
4297 | }
|
4298 | }
|
4299 |
|
4300 | if (!allowTime && timeFormat != null) {
|
4301 | config._isValid = false;
|
4302 | return;
|
4303 | }
|
4304 |
|
4305 | if (match[4]) {
|
4306 | if (tzRegex.exec(match[4])) {
|
4307 | tzFormat = 'Z';
|
4308 | } else {
|
4309 | config._isValid = false;
|
4310 | return;
|
4311 | }
|
4312 | }
|
4313 |
|
4314 | config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
|
4315 | configFromStringAndFormat(config);
|
4316 | } else {
|
4317 | config._isValid = false;
|
4318 | }
|
4319 | }
|
4320 |
|
4321 |
|
4322 | var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;
|
4323 |
|
4324 | function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
|
4325 | var result = [untruncateYear(yearStr), defaultLocaleMonthsShort.indexOf(monthStr), parseInt(dayStr, 10), parseInt(hourStr, 10), parseInt(minuteStr, 10)];
|
4326 |
|
4327 | if (secondStr) {
|
4328 | result.push(parseInt(secondStr, 10));
|
4329 | }
|
4330 |
|
4331 | return result;
|
4332 | }
|
4333 |
|
4334 | function untruncateYear(yearStr) {
|
4335 | var year = parseInt(yearStr, 10);
|
4336 |
|
4337 | if (year <= 49) {
|
4338 | return 2000 + year;
|
4339 | } else if (year <= 999) {
|
4340 | return 1900 + year;
|
4341 | }
|
4342 |
|
4343 | return year;
|
4344 | }
|
4345 |
|
4346 | function preprocessRFC2822(s) {
|
4347 |
|
4348 | return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
4349 | }
|
4350 |
|
4351 | function checkWeekday(weekdayStr, parsedInput, config) {
|
4352 | if (weekdayStr) {
|
4353 |
|
4354 | var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
|
4355 | weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
|
4356 |
|
4357 | if (weekdayProvided !== weekdayActual) {
|
4358 | getParsingFlags(config).weekdayMismatch = true;
|
4359 | config._isValid = false;
|
4360 | return false;
|
4361 | }
|
4362 | }
|
4363 |
|
4364 | return true;
|
4365 | }
|
4366 |
|
4367 | var obsOffsets = {
|
4368 | UT: 0,
|
4369 | GMT: 0,
|
4370 | EDT: -4 * 60,
|
4371 | EST: -5 * 60,
|
4372 | CDT: -5 * 60,
|
4373 | CST: -6 * 60,
|
4374 | MDT: -6 * 60,
|
4375 | MST: -7 * 60,
|
4376 | PDT: -7 * 60,
|
4377 | PST: -8 * 60
|
4378 | };
|
4379 |
|
4380 | function calculateOffset(obsOffset, militaryOffset, numOffset) {
|
4381 | if (obsOffset) {
|
4382 | return obsOffsets[obsOffset];
|
4383 | } else if (militaryOffset) {
|
4384 |
|
4385 | return 0;
|
4386 | } else {
|
4387 | var hm = parseInt(numOffset, 10);
|
4388 | var m = hm % 100,
|
4389 | h = (hm - m) / 100;
|
4390 | return h * 60 + m;
|
4391 | }
|
4392 | }
|
4393 |
|
4394 |
|
4395 | function configFromRFC2822(config) {
|
4396 | var match = rfc2822.exec(preprocessRFC2822(config._i));
|
4397 |
|
4398 | if (match) {
|
4399 | var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
|
4400 |
|
4401 | if (!checkWeekday(match[1], parsedArray, config)) {
|
4402 | return;
|
4403 | }
|
4404 |
|
4405 | config._a = parsedArray;
|
4406 | config._tzm = calculateOffset(match[8], match[9], match[10]);
|
4407 | config._d = createUTCDate.apply(null, config._a);
|
4408 |
|
4409 | config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
4410 |
|
4411 | getParsingFlags(config).rfc2822 = true;
|
4412 | } else {
|
4413 | config._isValid = false;
|
4414 | }
|
4415 | }
|
4416 |
|
4417 |
|
4418 | function configFromString(config) {
|
4419 | var matched = aspNetJsonRegex.exec(config._i);
|
4420 |
|
4421 | if (matched !== null) {
|
4422 | config._d = new Date(+matched[1]);
|
4423 | return;
|
4424 | }
|
4425 |
|
4426 | configFromISO(config);
|
4427 |
|
4428 | if (config._isValid === false) {
|
4429 | delete config._isValid;
|
4430 | } else {
|
4431 | return;
|
4432 | }
|
4433 |
|
4434 | configFromRFC2822(config);
|
4435 |
|
4436 | if (config._isValid === false) {
|
4437 | delete config._isValid;
|
4438 | } else {
|
4439 | return;
|
4440 | }
|
4441 |
|
4442 |
|
4443 | hooks.createFromInputFallback(config);
|
4444 | }
|
4445 |
|
4446 | hooks.createFromInputFallback = deprecate('value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' + 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' + 'discouraged and will be removed in an upcoming major release. Please refer to ' + 'http://momentjs.com/guides/#/warnings/js-date/ for more info.', function (config) {
|
4447 | config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
|
4448 | });
|
4449 |
|
4450 | hooks.ISO_8601 = function () {};
|
4451 |
|
4452 |
|
4453 | hooks.RFC_2822 = function () {};
|
4454 |
|
4455 |
|
4456 | function configFromStringAndFormat(config) {
|
4457 |
|
4458 | if (config._f === hooks.ISO_8601) {
|
4459 | configFromISO(config);
|
4460 | return;
|
4461 | }
|
4462 |
|
4463 | if (config._f === hooks.RFC_2822) {
|
4464 | configFromRFC2822(config);
|
4465 | return;
|
4466 | }
|
4467 |
|
4468 | config._a = [];
|
4469 | getParsingFlags(config).empty = true;
|
4470 |
|
4471 | var string = '' + config._i,
|
4472 | i,
|
4473 | parsedInput,
|
4474 | tokens,
|
4475 | token,
|
4476 | skipped,
|
4477 | stringLength = string.length,
|
4478 | totalParsedInputLength = 0;
|
4479 | tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
|
4480 |
|
4481 | for (i = 0; i < tokens.length; i++) {
|
4482 | token = tokens[i];
|
4483 | parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
|
4484 |
|
4485 |
|
4486 | if (parsedInput) {
|
4487 | skipped = string.substr(0, string.indexOf(parsedInput));
|
4488 |
|
4489 | if (skipped.length > 0) {
|
4490 | getParsingFlags(config).unusedInput.push(skipped);
|
4491 | }
|
4492 |
|
4493 | string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
|
4494 | totalParsedInputLength += parsedInput.length;
|
4495 | }
|
4496 |
|
4497 |
|
4498 | if (formatTokenFunctions[token]) {
|
4499 | if (parsedInput) {
|
4500 | getParsingFlags(config).empty = false;
|
4501 | } else {
|
4502 | getParsingFlags(config).unusedTokens.push(token);
|
4503 | }
|
4504 |
|
4505 | addTimeToArrayFromToken(token, parsedInput, config);
|
4506 | } else if (config._strict && !parsedInput) {
|
4507 | getParsingFlags(config).unusedTokens.push(token);
|
4508 | }
|
4509 | }
|
4510 |
|
4511 |
|
4512 | getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
|
4513 |
|
4514 | if (string.length > 0) {
|
4515 | getParsingFlags(config).unusedInput.push(string);
|
4516 | }
|
4517 |
|
4518 |
|
4519 | if (config._a[HOUR] <= 12 && getParsingFlags(config).bigHour === true && config._a[HOUR] > 0) {
|
4520 | getParsingFlags(config).bigHour = undefined;
|
4521 | }
|
4522 |
|
4523 | getParsingFlags(config).parsedDateParts = config._a.slice(0);
|
4524 | getParsingFlags(config).meridiem = config._meridiem;
|
4525 |
|
4526 | config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
4527 | configFromArray(config);
|
4528 | checkOverflow(config);
|
4529 | }
|
4530 |
|
4531 | function meridiemFixWrap(locale, hour, meridiem) {
|
4532 | var isPm;
|
4533 |
|
4534 | if (meridiem == null) {
|
4535 |
|
4536 | return hour;
|
4537 | }
|
4538 |
|
4539 | if (locale.meridiemHour != null) {
|
4540 | return locale.meridiemHour(hour, meridiem);
|
4541 | } else if (locale.isPM != null) {
|
4542 |
|
4543 | isPm = locale.isPM(meridiem);
|
4544 |
|
4545 | if (isPm && hour < 12) {
|
4546 | hour += 12;
|
4547 | }
|
4548 |
|
4549 | if (!isPm && hour === 12) {
|
4550 | hour = 0;
|
4551 | }
|
4552 |
|
4553 | return hour;
|
4554 | } else {
|
4555 |
|
4556 | return hour;
|
4557 | }
|
4558 | }
|
4559 |
|
4560 |
|
4561 | function configFromStringAndArray(config) {
|
4562 | var tempConfig, bestMoment, scoreToBeat, i, currentScore;
|
4563 |
|
4564 | if (config._f.length === 0) {
|
4565 | getParsingFlags(config).invalidFormat = true;
|
4566 | config._d = new Date(NaN);
|
4567 | return;
|
4568 | }
|
4569 |
|
4570 | for (i = 0; i < config._f.length; i++) {
|
4571 | currentScore = 0;
|
4572 | tempConfig = copyConfig({}, config);
|
4573 |
|
4574 | if (config._useUTC != null) {
|
4575 | tempConfig._useUTC = config._useUTC;
|
4576 | }
|
4577 |
|
4578 | tempConfig._f = config._f[i];
|
4579 | configFromStringAndFormat(tempConfig);
|
4580 |
|
4581 | if (!isValid(tempConfig)) {
|
4582 | continue;
|
4583 | }
|
4584 |
|
4585 |
|
4586 | currentScore += getParsingFlags(tempConfig).charsLeftOver;
|
4587 |
|
4588 | currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
|
4589 | getParsingFlags(tempConfig).score = currentScore;
|
4590 |
|
4591 | if (scoreToBeat == null || currentScore < scoreToBeat) {
|
4592 | scoreToBeat = currentScore;
|
4593 | bestMoment = tempConfig;
|
4594 | }
|
4595 | }
|
4596 |
|
4597 | extend(config, bestMoment || tempConfig);
|
4598 | }
|
4599 |
|
4600 | function configFromObject(config) {
|
4601 | if (config._d) {
|
4602 | return;
|
4603 | }
|
4604 |
|
4605 | var i = normalizeObjectUnits(config._i);
|
4606 | config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
|
4607 | return obj && parseInt(obj, 10);
|
4608 | });
|
4609 | configFromArray(config);
|
4610 | }
|
4611 |
|
4612 | function createFromConfig(config) {
|
4613 | var res = new Moment(checkOverflow(prepareConfig(config)));
|
4614 |
|
4615 | if (res._nextDay) {
|
4616 |
|
4617 | res.add(1, 'd');
|
4618 | res._nextDay = undefined;
|
4619 | }
|
4620 |
|
4621 | return res;
|
4622 | }
|
4623 |
|
4624 | function prepareConfig(config) {
|
4625 | var input = config._i,
|
4626 | format = config._f;
|
4627 | config._locale = config._locale || getLocale(config._l);
|
4628 |
|
4629 | if (input === null || format === undefined && input === '') {
|
4630 | return createInvalid({
|
4631 | nullInput: true
|
4632 | });
|
4633 | }
|
4634 |
|
4635 | if (typeof input === 'string') {
|
4636 | config._i = input = config._locale.preparse(input);
|
4637 | }
|
4638 |
|
4639 | if (isMoment(input)) {
|
4640 | return new Moment(checkOverflow(input));
|
4641 | } else if (isDate(input)) {
|
4642 | config._d = input;
|
4643 | } else if (isArray(format)) {
|
4644 | configFromStringAndArray(config);
|
4645 | } else if (format) {
|
4646 | configFromStringAndFormat(config);
|
4647 | } else {
|
4648 | configFromInput(config);
|
4649 | }
|
4650 |
|
4651 | if (!isValid(config)) {
|
4652 | config._d = null;
|
4653 | }
|
4654 |
|
4655 | return config;
|
4656 | }
|
4657 |
|
4658 | function configFromInput(config) {
|
4659 | var input = config._i;
|
4660 |
|
4661 | if (isUndefined(input)) {
|
4662 | config._d = new Date(hooks.now());
|
4663 | } else if (isDate(input)) {
|
4664 | config._d = new Date(input.valueOf());
|
4665 | } else if (typeof input === 'string') {
|
4666 | configFromString(config);
|
4667 | } else if (isArray(input)) {
|
4668 | config._a = map(input.slice(0), function (obj) {
|
4669 | return parseInt(obj, 10);
|
4670 | });
|
4671 | configFromArray(config);
|
4672 | } else if (isObject(input)) {
|
4673 | configFromObject(config);
|
4674 | } else if (isNumber(input)) {
|
4675 |
|
4676 | config._d = new Date(input);
|
4677 | } else {
|
4678 | hooks.createFromInputFallback(config);
|
4679 | }
|
4680 | }
|
4681 |
|
4682 | function createLocalOrUTC(input, format, locale, strict, isUTC) {
|
4683 | var c = {};
|
4684 |
|
4685 | if (locale === true || locale === false) {
|
4686 | strict = locale;
|
4687 | locale = undefined;
|
4688 | }
|
4689 |
|
4690 | if (isObject(input) && isObjectEmpty(input) || isArray(input) && input.length === 0) {
|
4691 | input = undefined;
|
4692 | }
|
4693 |
|
4694 |
|
4695 |
|
4696 | c._isAMomentObject = true;
|
4697 | c._useUTC = c._isUTC = isUTC;
|
4698 | c._l = locale;
|
4699 | c._i = input;
|
4700 | c._f = format;
|
4701 | c._strict = strict;
|
4702 | return createFromConfig(c);
|
4703 | }
|
4704 |
|
4705 | function createLocal(input, format, locale, strict) {
|
4706 | return createLocalOrUTC(input, format, locale, strict, false);
|
4707 | }
|
4708 |
|
4709 | var prototypeMin = deprecate('moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/', function () {
|
4710 | var other = createLocal.apply(null, arguments);
|
4711 |
|
4712 | if (this.isValid() && other.isValid()) {
|
4713 | return other < this ? this : other;
|
4714 | } else {
|
4715 | return createInvalid();
|
4716 | }
|
4717 | });
|
4718 | var prototypeMax = deprecate('moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', function () {
|
4719 | var other = createLocal.apply(null, arguments);
|
4720 |
|
4721 | if (this.isValid() && other.isValid()) {
|
4722 | return other > this ? this : other;
|
4723 | } else {
|
4724 | return createInvalid();
|
4725 | }
|
4726 | });
|
4727 |
|
4728 |
|
4729 |
|
4730 |
|
4731 |
|
4732 | function pickBy(fn, moments) {
|
4733 | var res, i;
|
4734 |
|
4735 | if (moments.length === 1 && isArray(moments[0])) {
|
4736 | moments = moments[0];
|
4737 | }
|
4738 |
|
4739 | if (!moments.length) {
|
4740 | return createLocal();
|
4741 | }
|
4742 |
|
4743 | res = moments[0];
|
4744 |
|
4745 | for (i = 1; i < moments.length; ++i) {
|
4746 | if (!moments[i].isValid() || moments[i][fn](res)) {
|
4747 | res = moments[i];
|
4748 | }
|
4749 | }
|
4750 |
|
4751 | return res;
|
4752 | }
|
4753 |
|
4754 |
|
4755 | function min() {
|
4756 | var args = [].slice.call(arguments, 0);
|
4757 | return pickBy('isBefore', args);
|
4758 | }
|
4759 |
|
4760 | function max() {
|
4761 | var args = [].slice.call(arguments, 0);
|
4762 | return pickBy('isAfter', args);
|
4763 | }
|
4764 |
|
4765 | var now = function () {
|
4766 | return Date.now ? Date.now() : +new Date();
|
4767 | };
|
4768 |
|
4769 | var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
|
4770 |
|
4771 | function isDurationValid(m) {
|
4772 | for (var key in m) {
|
4773 | if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
|
4774 | return false;
|
4775 | }
|
4776 | }
|
4777 |
|
4778 | var unitHasDecimal = false;
|
4779 |
|
4780 | for (var i = 0; i < ordering.length; ++i) {
|
4781 | if (m[ordering[i]]) {
|
4782 | if (unitHasDecimal) {
|
4783 | return false;
|
4784 | }
|
4785 |
|
4786 | if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
|
4787 | unitHasDecimal = true;
|
4788 | }
|
4789 | }
|
4790 | }
|
4791 |
|
4792 | return true;
|
4793 | }
|
4794 |
|
4795 | function isValid$1() {
|
4796 | return this._isValid;
|
4797 | }
|
4798 |
|
4799 | function createInvalid$1() {
|
4800 | return createDuration(NaN);
|
4801 | }
|
4802 |
|
4803 | function Duration(duration) {
|
4804 | var normalizedInput = normalizeObjectUnits(duration),
|
4805 | years = normalizedInput.year || 0,
|
4806 | quarters = normalizedInput.quarter || 0,
|
4807 | months = normalizedInput.month || 0,
|
4808 | weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
|
4809 | days = normalizedInput.day || 0,
|
4810 | hours = normalizedInput.hour || 0,
|
4811 | minutes = normalizedInput.minute || 0,
|
4812 | seconds = normalizedInput.second || 0,
|
4813 | milliseconds = normalizedInput.millisecond || 0;
|
4814 | this._isValid = isDurationValid(normalizedInput);
|
4815 |
|
4816 | this._milliseconds = +milliseconds + seconds * 1e3 +
|
4817 | minutes * 6e4 +
|
4818 | hours * 1000 * 60 * 60;
|
4819 |
|
4820 |
|
4821 |
|
4822 | this._days = +days + weeks * 7;
|
4823 |
|
4824 |
|
4825 |
|
4826 | this._months = +months + quarters * 3 + years * 12;
|
4827 | this._data = {};
|
4828 | this._locale = getLocale();
|
4829 |
|
4830 | this._bubble();
|
4831 | }
|
4832 |
|
4833 | function isDuration(obj) {
|
4834 | return obj instanceof Duration;
|
4835 | }
|
4836 |
|
4837 | function absRound(number) {
|
4838 | if (number < 0) {
|
4839 | return Math.round(-1 * number) * -1;
|
4840 | } else {
|
4841 | return Math.round(number);
|
4842 | }
|
4843 | }
|
4844 |
|
4845 |
|
4846 | function offset(token, separator) {
|
4847 | addFormatToken(token, 0, 0, function () {
|
4848 | var offset = this.utcOffset();
|
4849 | var sign = '+';
|
4850 |
|
4851 | if (offset < 0) {
|
4852 | offset = -offset;
|
4853 | sign = '-';
|
4854 | }
|
4855 |
|
4856 | return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~offset % 60, 2);
|
4857 | });
|
4858 | }
|
4859 |
|
4860 | offset('Z', ':');
|
4861 | offset('ZZ', '');
|
4862 |
|
4863 | addRegexToken('Z', matchShortOffset);
|
4864 | addRegexToken('ZZ', matchShortOffset);
|
4865 | addParseToken(['Z', 'ZZ'], function (input, array, config) {
|
4866 | config._useUTC = true;
|
4867 | config._tzm = offsetFromString(matchShortOffset, input);
|
4868 | });
|
4869 |
|
4870 |
|
4871 |
|
4872 |
|
4873 | var chunkOffset = /([\+\-]|\d\d)/gi;
|
4874 |
|
4875 | function offsetFromString(matcher, string) {
|
4876 | var matches = (string || '').match(matcher);
|
4877 |
|
4878 | if (matches === null) {
|
4879 | return null;
|
4880 | }
|
4881 |
|
4882 | var chunk = matches[matches.length - 1] || [];
|
4883 | var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
|
4884 | var minutes = +(parts[1] * 60) + toInt(parts[2]);
|
4885 | return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
|
4886 | }
|
4887 |
|
4888 |
|
4889 | function cloneWithOffset(input, model) {
|
4890 | var res, diff;
|
4891 |
|
4892 | if (model._isUTC) {
|
4893 | res = model.clone();
|
4894 | diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
|
4895 |
|
4896 | res._d.setTime(res._d.valueOf() + diff);
|
4897 |
|
4898 | hooks.updateOffset(res, false);
|
4899 | return res;
|
4900 | } else {
|
4901 | return createLocal(input).local();
|
4902 | }
|
4903 | }
|
4904 |
|
4905 | function getDateOffset(m) {
|
4906 |
|
4907 |
|
4908 | return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
|
4909 | }
|
4910 |
|
4911 |
|
4912 |
|
4913 |
|
4914 | hooks.updateOffset = function () {};
|
4915 |
|
4916 |
|
4917 |
|
4918 |
|
4919 |
|
4920 |
|
4921 |
|
4922 |
|
4923 |
|
4924 |
|
4925 |
|
4926 |
|
4927 | function getSetOffset(input, keepLocalTime, keepMinutes) {
|
4928 | var offset = this._offset || 0,
|
4929 | localAdjust;
|
4930 |
|
4931 | if (!this.isValid()) {
|
4932 | return input != null ? this : NaN;
|
4933 | }
|
4934 |
|
4935 | if (input != null) {
|
4936 | if (typeof input === 'string') {
|
4937 | input = offsetFromString(matchShortOffset, input);
|
4938 |
|
4939 | if (input === null) {
|
4940 | return this;
|
4941 | }
|
4942 | } else if (Math.abs(input) < 16 && !keepMinutes) {
|
4943 | input = input * 60;
|
4944 | }
|
4945 |
|
4946 | if (!this._isUTC && keepLocalTime) {
|
4947 | localAdjust = getDateOffset(this);
|
4948 | }
|
4949 |
|
4950 | this._offset = input;
|
4951 | this._isUTC = true;
|
4952 |
|
4953 | if (localAdjust != null) {
|
4954 | this.add(localAdjust, 'm');
|
4955 | }
|
4956 |
|
4957 | if (offset !== input) {
|
4958 | if (!keepLocalTime || this._changeInProgress) {
|
4959 | addSubtract(this, createDuration(input - offset, 'm'), 1, false);
|
4960 | } else if (!this._changeInProgress) {
|
4961 | this._changeInProgress = true;
|
4962 | hooks.updateOffset(this, true);
|
4963 | this._changeInProgress = null;
|
4964 | }
|
4965 | }
|
4966 |
|
4967 | return this;
|
4968 | } else {
|
4969 | return this._isUTC ? offset : getDateOffset(this);
|
4970 | }
|
4971 | }
|
4972 |
|
4973 | function getSetZone(input, keepLocalTime) {
|
4974 | if (input != null) {
|
4975 | if (typeof input !== 'string') {
|
4976 | input = -input;
|
4977 | }
|
4978 |
|
4979 | this.utcOffset(input, keepLocalTime);
|
4980 | return this;
|
4981 | } else {
|
4982 | return -this.utcOffset();
|
4983 | }
|
4984 | }
|
4985 |
|
4986 | function setOffsetToUTC(keepLocalTime) {
|
4987 | return this.utcOffset(0, keepLocalTime);
|
4988 | }
|
4989 |
|
4990 | function setOffsetToLocal(keepLocalTime) {
|
4991 | if (this._isUTC) {
|
4992 | this.utcOffset(0, keepLocalTime);
|
4993 | this._isUTC = false;
|
4994 |
|
4995 | if (keepLocalTime) {
|
4996 | this.subtract(getDateOffset(this), 'm');
|
4997 | }
|
4998 | }
|
4999 |
|
5000 | return this;
|
5001 | }
|
5002 |
|
5003 | function setOffsetToParsedOffset() {
|
5004 | if (this._tzm != null) {
|
5005 | this.utcOffset(this._tzm, false, true);
|
5006 | } else if (typeof this._i === 'string') {
|
5007 | var tZone = offsetFromString(matchOffset, this._i);
|
5008 |
|
5009 | if (tZone != null) {
|
5010 | this.utcOffset(tZone);
|
5011 | } else {
|
5012 | this.utcOffset(0, true);
|
5013 | }
|
5014 | }
|
5015 |
|
5016 | return this;
|
5017 | }
|
5018 |
|
5019 | function hasAlignedHourOffset(input) {
|
5020 | if (!this.isValid()) {
|
5021 | return false;
|
5022 | }
|
5023 |
|
5024 | input = input ? createLocal(input).utcOffset() : 0;
|
5025 | return (this.utcOffset() - input) % 60 === 0;
|
5026 | }
|
5027 |
|
5028 | function isDaylightSavingTime() {
|
5029 | return this.utcOffset() > this.clone().month(0).utcOffset() || this.utcOffset() > this.clone().month(5).utcOffset();
|
5030 | }
|
5031 |
|
5032 | function isDaylightSavingTimeShifted() {
|
5033 | if (!isUndefined(this._isDSTShifted)) {
|
5034 | return this._isDSTShifted;
|
5035 | }
|
5036 |
|
5037 | var c = {};
|
5038 | copyConfig(c, this);
|
5039 | c = prepareConfig(c);
|
5040 |
|
5041 | if (c._a) {
|
5042 | var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
|
5043 | this._isDSTShifted = this.isValid() && compareArrays(c._a, other.toArray()) > 0;
|
5044 | } else {
|
5045 | this._isDSTShifted = false;
|
5046 | }
|
5047 |
|
5048 | return this._isDSTShifted;
|
5049 | }
|
5050 |
|
5051 | function isLocal() {
|
5052 | return this.isValid() ? !this._isUTC : false;
|
5053 | }
|
5054 |
|
5055 | function isUtcOffset() {
|
5056 | return this.isValid() ? this._isUTC : false;
|
5057 | }
|
5058 |
|
5059 | function isUtc() {
|
5060 | return this.isValid() ? this._isUTC && this._offset === 0 : false;
|
5061 | }
|
5062 |
|
5063 |
|
5064 | var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
|
5065 |
|
5066 |
|
5067 |
|
5068 | var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
|
5069 |
|
5070 | function createDuration(input, key) {
|
5071 | var duration = input,
|
5072 |
|
5073 | match = null,
|
5074 | sign,
|
5075 | ret,
|
5076 | diffRes;
|
5077 |
|
5078 | if (isDuration(input)) {
|
5079 | duration = {
|
5080 | ms: input._milliseconds,
|
5081 | d: input._days,
|
5082 | M: input._months
|
5083 | };
|
5084 | } else if (isNumber(input)) {
|
5085 | duration = {};
|
5086 |
|
5087 | if (key) {
|
5088 | duration[key] = input;
|
5089 | } else {
|
5090 | duration.milliseconds = input;
|
5091 | }
|
5092 | } else if (!!(match = aspNetRegex.exec(input))) {
|
5093 | sign = match[1] === '-' ? -1 : 1;
|
5094 | duration = {
|
5095 | y: 0,
|
5096 | d: toInt(match[DATE]) * sign,
|
5097 | h: toInt(match[HOUR]) * sign,
|
5098 | m: toInt(match[MINUTE]) * sign,
|
5099 | s: toInt(match[SECOND]) * sign,
|
5100 | ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign
|
5101 |
|
5102 | };
|
5103 | } else if (!!(match = isoRegex.exec(input))) {
|
5104 | sign = match[1] === '-' ? -1 : 1;
|
5105 | duration = {
|
5106 | y: parseIso(match[2], sign),
|
5107 | M: parseIso(match[3], sign),
|
5108 | w: parseIso(match[4], sign),
|
5109 | d: parseIso(match[5], sign),
|
5110 | h: parseIso(match[6], sign),
|
5111 | m: parseIso(match[7], sign),
|
5112 | s: parseIso(match[8], sign)
|
5113 | };
|
5114 | } else if (duration == null) {
|
5115 |
|
5116 | duration = {};
|
5117 | } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
|
5118 | diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
|
5119 | duration = {};
|
5120 | duration.ms = diffRes.milliseconds;
|
5121 | duration.M = diffRes.months;
|
5122 | }
|
5123 |
|
5124 | ret = new Duration(duration);
|
5125 |
|
5126 | if (isDuration(input) && hasOwnProp(input, '_locale')) {
|
5127 | ret._locale = input._locale;
|
5128 | }
|
5129 |
|
5130 | return ret;
|
5131 | }
|
5132 |
|
5133 | createDuration.fn = Duration.prototype;
|
5134 | createDuration.invalid = createInvalid$1;
|
5135 |
|
5136 | function parseIso(inp, sign) {
|
5137 |
|
5138 |
|
5139 |
|
5140 | var res = inp && parseFloat(inp.replace(',', '.'));
|
5141 |
|
5142 | return (isNaN(res) ? 0 : res) * sign;
|
5143 | }
|
5144 |
|
5145 | function positiveMomentsDifference(base, other) {
|
5146 | var res = {};
|
5147 | res.months = other.month() - base.month() + (other.year() - base.year()) * 12;
|
5148 |
|
5149 | if (base.clone().add(res.months, 'M').isAfter(other)) {
|
5150 | --res.months;
|
5151 | }
|
5152 |
|
5153 | res.milliseconds = +other - +base.clone().add(res.months, 'M');
|
5154 | return res;
|
5155 | }
|
5156 |
|
5157 | function momentsDifference(base, other) {
|
5158 | var res;
|
5159 |
|
5160 | if (!(base.isValid() && other.isValid())) {
|
5161 | return {
|
5162 | milliseconds: 0,
|
5163 | months: 0
|
5164 | };
|
5165 | }
|
5166 |
|
5167 | other = cloneWithOffset(other, base);
|
5168 |
|
5169 | if (base.isBefore(other)) {
|
5170 | res = positiveMomentsDifference(base, other);
|
5171 | } else {
|
5172 | res = positiveMomentsDifference(other, base);
|
5173 | res.milliseconds = -res.milliseconds;
|
5174 | res.months = -res.months;
|
5175 | }
|
5176 |
|
5177 | return res;
|
5178 | }
|
5179 |
|
5180 |
|
5181 | function createAdder(direction, name) {
|
5182 | return function (val, period) {
|
5183 | var dur, tmp;
|
5184 |
|
5185 | if (period !== null && !isNaN(+period)) {
|
5186 | deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' + 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
|
5187 | tmp = val;
|
5188 | val = period;
|
5189 | period = tmp;
|
5190 | }
|
5191 |
|
5192 | val = typeof val === 'string' ? +val : val;
|
5193 | dur = createDuration(val, period);
|
5194 | addSubtract(this, dur, direction);
|
5195 | return this;
|
5196 | };
|
5197 | }
|
5198 |
|
5199 | function addSubtract(mom, duration, isAdding, updateOffset) {
|
5200 | var milliseconds = duration._milliseconds,
|
5201 | days = absRound(duration._days),
|
5202 | months = absRound(duration._months);
|
5203 |
|
5204 | if (!mom.isValid()) {
|
5205 |
|
5206 | return;
|
5207 | }
|
5208 |
|
5209 | updateOffset = updateOffset == null ? true : updateOffset;
|
5210 |
|
5211 | if (months) {
|
5212 | setMonth(mom, get(mom, 'Month') + months * isAdding);
|
5213 | }
|
5214 |
|
5215 | if (days) {
|
5216 | set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
|
5217 | }
|
5218 |
|
5219 | if (milliseconds) {
|
5220 | mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
|
5221 | }
|
5222 |
|
5223 | if (updateOffset) {
|
5224 | hooks.updateOffset(mom, days || months);
|
5225 | }
|
5226 | }
|
5227 |
|
5228 | var add = createAdder(1, 'add');
|
5229 | var subtract = createAdder(-1, 'subtract');
|
5230 |
|
5231 | function getCalendarFormat(myMoment, now) {
|
5232 | var diff = myMoment.diff(now, 'days', true);
|
5233 | return diff < -6 ? 'sameElse' : diff < -1 ? 'lastWeek' : diff < 0 ? 'lastDay' : diff < 1 ? 'sameDay' : diff < 2 ? 'nextDay' : diff < 7 ? 'nextWeek' : 'sameElse';
|
5234 | }
|
5235 |
|
5236 | function calendar$1(time, formats) {
|
5237 |
|
5238 |
|
5239 | var now = time || createLocal(),
|
5240 | sod = cloneWithOffset(now, this).startOf('day'),
|
5241 | format = hooks.calendarFormat(this, sod) || 'sameElse';
|
5242 | var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
|
5243 | return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
|
5244 | }
|
5245 |
|
5246 | function clone() {
|
5247 | return new Moment(this);
|
5248 | }
|
5249 |
|
5250 | function isAfter(input, units) {
|
5251 | var localInput = isMoment(input) ? input : createLocal(input);
|
5252 |
|
5253 | if (!(this.isValid() && localInput.isValid())) {
|
5254 | return false;
|
5255 | }
|
5256 |
|
5257 | units = normalizeUnits(units) || 'millisecond';
|
5258 |
|
5259 | if (units === 'millisecond') {
|
5260 | return this.valueOf() > localInput.valueOf();
|
5261 | } else {
|
5262 | return localInput.valueOf() < this.clone().startOf(units).valueOf();
|
5263 | }
|
5264 | }
|
5265 |
|
5266 | function isBefore(input, units) {
|
5267 | var localInput = isMoment(input) ? input : createLocal(input);
|
5268 |
|
5269 | if (!(this.isValid() && localInput.isValid())) {
|
5270 | return false;
|
5271 | }
|
5272 |
|
5273 | units = normalizeUnits(units) || 'millisecond';
|
5274 |
|
5275 | if (units === 'millisecond') {
|
5276 | return this.valueOf() < localInput.valueOf();
|
5277 | } else {
|
5278 | return this.clone().endOf(units).valueOf() < localInput.valueOf();
|
5279 | }
|
5280 | }
|
5281 |
|
5282 | function isBetween(from, to, units, inclusivity) {
|
5283 | var localFrom = isMoment(from) ? from : createLocal(from),
|
5284 | localTo = isMoment(to) ? to : createLocal(to);
|
5285 |
|
5286 | if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
|
5287 | return false;
|
5288 | }
|
5289 |
|
5290 | inclusivity = inclusivity || '()';
|
5291 | return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) && (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
|
5292 | }
|
5293 |
|
5294 | function isSame(input, units) {
|
5295 | var localInput = isMoment(input) ? input : createLocal(input),
|
5296 | inputMs;
|
5297 |
|
5298 | if (!(this.isValid() && localInput.isValid())) {
|
5299 | return false;
|
5300 | }
|
5301 |
|
5302 | units = normalizeUnits(units) || 'millisecond';
|
5303 |
|
5304 | if (units === 'millisecond') {
|
5305 | return this.valueOf() === localInput.valueOf();
|
5306 | } else {
|
5307 | inputMs = localInput.valueOf();
|
5308 | return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
|
5309 | }
|
5310 | }
|
5311 |
|
5312 | function isSameOrAfter(input, units) {
|
5313 | return this.isSame(input, units) || this.isAfter(input, units);
|
5314 | }
|
5315 |
|
5316 | function isSameOrBefore(input, units) {
|
5317 | return this.isSame(input, units) || this.isBefore(input, units);
|
5318 | }
|
5319 |
|
5320 | function diff(input, units, asFloat) {
|
5321 | var that, zoneDelta, output;
|
5322 |
|
5323 | if (!this.isValid()) {
|
5324 | return NaN;
|
5325 | }
|
5326 |
|
5327 | that = cloneWithOffset(input, this);
|
5328 |
|
5329 | if (!that.isValid()) {
|
5330 | return NaN;
|
5331 | }
|
5332 |
|
5333 | zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
|
5334 | units = normalizeUnits(units);
|
5335 |
|
5336 | switch (units) {
|
5337 | case 'year':
|
5338 | output = monthDiff(this, that) / 12;
|
5339 | break;
|
5340 |
|
5341 | case 'month':
|
5342 | output = monthDiff(this, that);
|
5343 | break;
|
5344 |
|
5345 | case 'quarter':
|
5346 | output = monthDiff(this, that) / 3;
|
5347 | break;
|
5348 |
|
5349 | case 'second':
|
5350 | output = (this - that) / 1e3;
|
5351 | break;
|
5352 |
|
5353 |
|
5354 | case 'minute':
|
5355 | output = (this - that) / 6e4;
|
5356 | break;
|
5357 |
|
5358 |
|
5359 | case 'hour':
|
5360 | output = (this - that) / 36e5;
|
5361 | break;
|
5362 |
|
5363 |
|
5364 | case 'day':
|
5365 | output = (this - that - zoneDelta) / 864e5;
|
5366 | break;
|
5367 |
|
5368 |
|
5369 | case 'week':
|
5370 | output = (this - that - zoneDelta) / 6048e5;
|
5371 | break;
|
5372 |
|
5373 |
|
5374 | default:
|
5375 | output = this - that;
|
5376 | }
|
5377 |
|
5378 | return asFloat ? output : absFloor(output);
|
5379 | }
|
5380 |
|
5381 | function monthDiff(a, b) {
|
5382 |
|
5383 | var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
|
5384 |
|
5385 | anchor = a.clone().add(wholeMonthDiff, 'months'),
|
5386 | anchor2,
|
5387 | adjust;
|
5388 |
|
5389 | if (b - anchor < 0) {
|
5390 | anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
|
5391 |
|
5392 | adjust = (b - anchor) / (anchor - anchor2);
|
5393 | } else {
|
5394 | anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
|
5395 |
|
5396 | adjust = (b - anchor) / (anchor2 - anchor);
|
5397 | }
|
5398 |
|
5399 |
|
5400 | return -(wholeMonthDiff + adjust) || 0;
|
5401 | }
|
5402 |
|
5403 | hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
|
5404 | hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
|
5405 |
|
5406 | function toString() {
|
5407 | return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
|
5408 | }
|
5409 |
|
5410 | function toISOString(keepOffset) {
|
5411 | if (!this.isValid()) {
|
5412 | return null;
|
5413 | }
|
5414 |
|
5415 | var utc = keepOffset !== true;
|
5416 | var m = utc ? this.clone().utc() : this;
|
5417 |
|
5418 | if (m.year() < 0 || m.year() > 9999) {
|
5419 | return formatMoment(m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
5420 | }
|
5421 |
|
5422 | if (isFunction(Date.prototype.toISOString)) {
|
5423 |
|
5424 | if (utc) {
|
5425 | return this.toDate().toISOString();
|
5426 | } else {
|
5427 | return new Date(this.valueOf() + this.utcOffset() * 60 * 1000).toISOString().replace('Z', formatMoment(m, 'Z'));
|
5428 | }
|
5429 | }
|
5430 |
|
5431 | return formatMoment(m, utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
5432 | }
|
5433 | |
5434 |
|
5435 |
|
5436 |
|
5437 |
|
5438 |
|
5439 |
|
5440 |
|
5441 | function inspect() {
|
5442 | if (!this.isValid()) {
|
5443 | return 'moment.invalid(/* ' + this._i + ' */)';
|
5444 | }
|
5445 |
|
5446 | var func = 'moment';
|
5447 | var zone = '';
|
5448 |
|
5449 | if (!this.isLocal()) {
|
5450 | func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
|
5451 | zone = 'Z';
|
5452 | }
|
5453 |
|
5454 | var prefix = '[' + func + '("]';
|
5455 | var year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
|
5456 | var datetime = '-MM-DD[T]HH:mm:ss.SSS';
|
5457 | var suffix = zone + '[")]';
|
5458 | return this.format(prefix + year + datetime + suffix);
|
5459 | }
|
5460 |
|
5461 | function format(inputString) {
|
5462 | if (!inputString) {
|
5463 | inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
|
5464 | }
|
5465 |
|
5466 | var output = formatMoment(this, inputString);
|
5467 | return this.localeData().postformat(output);
|
5468 | }
|
5469 |
|
5470 | function from(time, withoutSuffix) {
|
5471 | if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
|
5472 | return createDuration({
|
5473 | to: this,
|
5474 | from: time
|
5475 | }).locale(this.locale()).humanize(!withoutSuffix);
|
5476 | } else {
|
5477 | return this.localeData().invalidDate();
|
5478 | }
|
5479 | }
|
5480 |
|
5481 | function fromNow(withoutSuffix) {
|
5482 | return this.from(createLocal(), withoutSuffix);
|
5483 | }
|
5484 |
|
5485 | function to(time, withoutSuffix) {
|
5486 | if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
|
5487 | return createDuration({
|
5488 | from: this,
|
5489 | to: time
|
5490 | }).locale(this.locale()).humanize(!withoutSuffix);
|
5491 | } else {
|
5492 | return this.localeData().invalidDate();
|
5493 | }
|
5494 | }
|
5495 |
|
5496 | function toNow(withoutSuffix) {
|
5497 | return this.to(createLocal(), withoutSuffix);
|
5498 | }
|
5499 |
|
5500 |
|
5501 |
|
5502 |
|
5503 | function locale(key) {
|
5504 | var newLocaleData;
|
5505 |
|
5506 | if (key === undefined) {
|
5507 | return this._locale._abbr;
|
5508 | } else {
|
5509 | newLocaleData = getLocale(key);
|
5510 |
|
5511 | if (newLocaleData != null) {
|
5512 | this._locale = newLocaleData;
|
5513 | }
|
5514 |
|
5515 | return this;
|
5516 | }
|
5517 | }
|
5518 |
|
5519 | var lang = deprecate('moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', function (key) {
|
5520 | if (key === undefined) {
|
5521 | return this.localeData();
|
5522 | } else {
|
5523 | return this.locale(key);
|
5524 | }
|
5525 | });
|
5526 |
|
5527 | function localeData() {
|
5528 | return this._locale;
|
5529 | }
|
5530 |
|
5531 | var MS_PER_SECOND = 1000;
|
5532 | var MS_PER_MINUTE = 60 * MS_PER_SECOND;
|
5533 | var MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
5534 | var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
|
5535 |
|
5536 | function mod$1(dividend, divisor) {
|
5537 | return (dividend % divisor + divisor) % divisor;
|
5538 | }
|
5539 |
|
5540 | function localStartOfDate(y, m, d) {
|
5541 |
|
5542 | if (y < 100 && y >= 0) {
|
5543 |
|
5544 | return new Date(y + 400, m, d) - MS_PER_400_YEARS;
|
5545 | } else {
|
5546 | return new Date(y, m, d).valueOf();
|
5547 | }
|
5548 | }
|
5549 |
|
5550 | function utcStartOfDate(y, m, d) {
|
5551 |
|
5552 | if (y < 100 && y >= 0) {
|
5553 |
|
5554 | return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
|
5555 | } else {
|
5556 | return Date.UTC(y, m, d);
|
5557 | }
|
5558 | }
|
5559 |
|
5560 | function startOf(units) {
|
5561 | var time;
|
5562 | units = normalizeUnits(units);
|
5563 |
|
5564 | if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
5565 | return this;
|
5566 | }
|
5567 |
|
5568 | var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
5569 |
|
5570 | switch (units) {
|
5571 | case 'year':
|
5572 | time = startOfDate(this.year(), 0, 1);
|
5573 | break;
|
5574 |
|
5575 | case 'quarter':
|
5576 | time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
|
5577 | break;
|
5578 |
|
5579 | case 'month':
|
5580 | time = startOfDate(this.year(), this.month(), 1);
|
5581 | break;
|
5582 |
|
5583 | case 'week':
|
5584 | time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
|
5585 | break;
|
5586 |
|
5587 | case 'isoWeek':
|
5588 | time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
|
5589 | break;
|
5590 |
|
5591 | case 'day':
|
5592 | case 'date':
|
5593 | time = startOfDate(this.year(), this.month(), this.date());
|
5594 | break;
|
5595 |
|
5596 | case 'hour':
|
5597 | time = this._d.valueOf();
|
5598 | time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
|
5599 | break;
|
5600 |
|
5601 | case 'minute':
|
5602 | time = this._d.valueOf();
|
5603 | time -= mod$1(time, MS_PER_MINUTE);
|
5604 | break;
|
5605 |
|
5606 | case 'second':
|
5607 | time = this._d.valueOf();
|
5608 | time -= mod$1(time, MS_PER_SECOND);
|
5609 | break;
|
5610 | }
|
5611 |
|
5612 | this._d.setTime(time);
|
5613 |
|
5614 | hooks.updateOffset(this, true);
|
5615 | return this;
|
5616 | }
|
5617 |
|
5618 | function endOf(units) {
|
5619 | var time;
|
5620 | units = normalizeUnits(units);
|
5621 |
|
5622 | if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
5623 | return this;
|
5624 | }
|
5625 |
|
5626 | var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
5627 |
|
5628 | switch (units) {
|
5629 | case 'year':
|
5630 | time = startOfDate(this.year() + 1, 0, 1) - 1;
|
5631 | break;
|
5632 |
|
5633 | case 'quarter':
|
5634 | time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
|
5635 | break;
|
5636 |
|
5637 | case 'month':
|
5638 | time = startOfDate(this.year(), this.month() + 1, 1) - 1;
|
5639 | break;
|
5640 |
|
5641 | case 'week':
|
5642 | time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
|
5643 | break;
|
5644 |
|
5645 | case 'isoWeek':
|
5646 | time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
|
5647 | break;
|
5648 |
|
5649 | case 'day':
|
5650 | case 'date':
|
5651 | time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
|
5652 | break;
|
5653 |
|
5654 | case 'hour':
|
5655 | time = this._d.valueOf();
|
5656 | time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
|
5657 | break;
|
5658 |
|
5659 | case 'minute':
|
5660 | time = this._d.valueOf();
|
5661 | time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
|
5662 | break;
|
5663 |
|
5664 | case 'second':
|
5665 | time = this._d.valueOf();
|
5666 | time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
|
5667 | break;
|
5668 | }
|
5669 |
|
5670 | this._d.setTime(time);
|
5671 |
|
5672 | hooks.updateOffset(this, true);
|
5673 | return this;
|
5674 | }
|
5675 |
|
5676 | function valueOf() {
|
5677 | return this._d.valueOf() - (this._offset || 0) * 60000;
|
5678 | }
|
5679 |
|
5680 | function unix() {
|
5681 | return Math.floor(this.valueOf() / 1000);
|
5682 | }
|
5683 |
|
5684 | function toDate() {
|
5685 | return new Date(this.valueOf());
|
5686 | }
|
5687 |
|
5688 | function toArray() {
|
5689 | var m = this;
|
5690 | return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
|
5691 | }
|
5692 |
|
5693 | function toObject() {
|
5694 | var m = this;
|
5695 | return {
|
5696 | years: m.year(),
|
5697 | months: m.month(),
|
5698 | date: m.date(),
|
5699 | hours: m.hours(),
|
5700 | minutes: m.minutes(),
|
5701 | seconds: m.seconds(),
|
5702 | milliseconds: m.milliseconds()
|
5703 | };
|
5704 | }
|
5705 |
|
5706 | function toJSON() {
|
5707 |
|
5708 | return this.isValid() ? this.toISOString() : null;
|
5709 | }
|
5710 |
|
5711 | function isValid$2() {
|
5712 | return isValid(this);
|
5713 | }
|
5714 |
|
5715 | function parsingFlags() {
|
5716 | return extend({}, getParsingFlags(this));
|
5717 | }
|
5718 |
|
5719 | function invalidAt() {
|
5720 | return getParsingFlags(this).overflow;
|
5721 | }
|
5722 |
|
5723 | function creationData() {
|
5724 | return {
|
5725 | input: this._i,
|
5726 | format: this._f,
|
5727 | locale: this._locale,
|
5728 | isUTC: this._isUTC,
|
5729 | strict: this._strict
|
5730 | };
|
5731 | }
|
5732 |
|
5733 |
|
5734 | addFormatToken(0, ['gg', 2], 0, function () {
|
5735 | return this.weekYear() % 100;
|
5736 | });
|
5737 | addFormatToken(0, ['GG', 2], 0, function () {
|
5738 | return this.isoWeekYear() % 100;
|
5739 | });
|
5740 |
|
5741 | function addWeekYearFormatToken(token, getter) {
|
5742 | addFormatToken(0, [token, token.length], 0, getter);
|
5743 | }
|
5744 |
|
5745 | addWeekYearFormatToken('gggg', 'weekYear');
|
5746 | addWeekYearFormatToken('ggggg', 'weekYear');
|
5747 | addWeekYearFormatToken('GGGG', 'isoWeekYear');
|
5748 | addWeekYearFormatToken('GGGGG', 'isoWeekYear');
|
5749 |
|
5750 | addUnitAlias('weekYear', 'gg');
|
5751 | addUnitAlias('isoWeekYear', 'GG');
|
5752 |
|
5753 | addUnitPriority('weekYear', 1);
|
5754 | addUnitPriority('isoWeekYear', 1);
|
5755 |
|
5756 | addRegexToken('G', matchSigned);
|
5757 | addRegexToken('g', matchSigned);
|
5758 | addRegexToken('GG', match1to2, match2);
|
5759 | addRegexToken('gg', match1to2, match2);
|
5760 | addRegexToken('GGGG', match1to4, match4);
|
5761 | addRegexToken('gggg', match1to4, match4);
|
5762 | addRegexToken('GGGGG', match1to6, match6);
|
5763 | addRegexToken('ggggg', match1to6, match6);
|
5764 | addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
|
5765 | week[token.substr(0, 2)] = toInt(input);
|
5766 | });
|
5767 | addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
|
5768 | week[token] = hooks.parseTwoDigitYear(input);
|
5769 | });
|
5770 |
|
5771 | function getSetWeekYear(input) {
|
5772 | return getSetWeekYearHelper.call(this, input, this.week(), this.weekday(), this.localeData()._week.dow, this.localeData()._week.doy);
|
5773 | }
|
5774 |
|
5775 | function getSetISOWeekYear(input) {
|
5776 | return getSetWeekYearHelper.call(this, input, this.isoWeek(), this.isoWeekday(), 1, 4);
|
5777 | }
|
5778 |
|
5779 | function getISOWeeksInYear() {
|
5780 | return weeksInYear(this.year(), 1, 4);
|
5781 | }
|
5782 |
|
5783 | function getWeeksInYear() {
|
5784 | var weekInfo = this.localeData()._week;
|
5785 |
|
5786 | return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
|
5787 | }
|
5788 |
|
5789 | function getSetWeekYearHelper(input, week, weekday, dow, doy) {
|
5790 | var weeksTarget;
|
5791 |
|
5792 | if (input == null) {
|
5793 | return weekOfYear(this, dow, doy).year;
|
5794 | } else {
|
5795 | weeksTarget = weeksInYear(input, dow, doy);
|
5796 |
|
5797 | if (week > weeksTarget) {
|
5798 | week = weeksTarget;
|
5799 | }
|
5800 |
|
5801 | return setWeekAll.call(this, input, week, weekday, dow, doy);
|
5802 | }
|
5803 | }
|
5804 |
|
5805 | function setWeekAll(weekYear, week, weekday, dow, doy) {
|
5806 | var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
|
5807 | date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
|
5808 | this.year(date.getUTCFullYear());
|
5809 | this.month(date.getUTCMonth());
|
5810 | this.date(date.getUTCDate());
|
5811 | return this;
|
5812 | }
|
5813 |
|
5814 |
|
5815 | addFormatToken('Q', 0, 'Qo', 'quarter');
|
5816 |
|
5817 | addUnitAlias('quarter', 'Q');
|
5818 |
|
5819 | addUnitPriority('quarter', 7);
|
5820 |
|
5821 | addRegexToken('Q', match1);
|
5822 | addParseToken('Q', function (input, array) {
|
5823 | array[MONTH] = (toInt(input) - 1) * 3;
|
5824 | });
|
5825 |
|
5826 | function getSetQuarter(input) {
|
5827 | return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
|
5828 | }
|
5829 |
|
5830 |
|
5831 | addFormatToken('D', ['DD', 2], 'Do', 'date');
|
5832 |
|
5833 | addUnitAlias('date', 'D');
|
5834 |
|
5835 | addUnitPriority('date', 9);
|
5836 |
|
5837 | addRegexToken('D', match1to2);
|
5838 | addRegexToken('DD', match1to2, match2);
|
5839 | addRegexToken('Do', function (isStrict, locale) {
|
5840 |
|
5841 | return isStrict ? locale._dayOfMonthOrdinalParse || locale._ordinalParse : locale._dayOfMonthOrdinalParseLenient;
|
5842 | });
|
5843 | addParseToken(['D', 'DD'], DATE);
|
5844 | addParseToken('Do', function (input, array) {
|
5845 | array[DATE] = toInt(input.match(match1to2)[0]);
|
5846 | });
|
5847 |
|
5848 | var getSetDayOfMonth = makeGetSet('Date', true);
|
5849 |
|
5850 | addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
|
5851 |
|
5852 | addUnitAlias('dayOfYear', 'DDD');
|
5853 |
|
5854 | addUnitPriority('dayOfYear', 4);
|
5855 |
|
5856 | addRegexToken('DDD', match1to3);
|
5857 | addRegexToken('DDDD', match3);
|
5858 | addParseToken(['DDD', 'DDDD'], function (input, array, config) {
|
5859 | config._dayOfYear = toInt(input);
|
5860 | });
|
5861 |
|
5862 |
|
5863 | function getSetDayOfYear(input) {
|
5864 | var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
|
5865 | return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
|
5866 | }
|
5867 |
|
5868 |
|
5869 | addFormatToken('m', ['mm', 2], 0, 'minute');
|
5870 |
|
5871 | addUnitAlias('minute', 'm');
|
5872 |
|
5873 | addUnitPriority('minute', 14);
|
5874 |
|
5875 | addRegexToken('m', match1to2);
|
5876 | addRegexToken('mm', match1to2, match2);
|
5877 | addParseToken(['m', 'mm'], MINUTE);
|
5878 |
|
5879 | var getSetMinute = makeGetSet('Minutes', false);
|
5880 |
|
5881 | addFormatToken('s', ['ss', 2], 0, 'second');
|
5882 |
|
5883 | addUnitAlias('second', 's');
|
5884 |
|
5885 | addUnitPriority('second', 15);
|
5886 |
|
5887 | addRegexToken('s', match1to2);
|
5888 | addRegexToken('ss', match1to2, match2);
|
5889 | addParseToken(['s', 'ss'], SECOND);
|
5890 |
|
5891 | var getSetSecond = makeGetSet('Seconds', false);
|
5892 |
|
5893 | addFormatToken('S', 0, 0, function () {
|
5894 | return ~~(this.millisecond() / 100);
|
5895 | });
|
5896 | addFormatToken(0, ['SS', 2], 0, function () {
|
5897 | return ~~(this.millisecond() / 10);
|
5898 | });
|
5899 | addFormatToken(0, ['SSS', 3], 0, 'millisecond');
|
5900 | addFormatToken(0, ['SSSS', 4], 0, function () {
|
5901 | return this.millisecond() * 10;
|
5902 | });
|
5903 | addFormatToken(0, ['SSSSS', 5], 0, function () {
|
5904 | return this.millisecond() * 100;
|
5905 | });
|
5906 | addFormatToken(0, ['SSSSSS', 6], 0, function () {
|
5907 | return this.millisecond() * 1000;
|
5908 | });
|
5909 | addFormatToken(0, ['SSSSSSS', 7], 0, function () {
|
5910 | return this.millisecond() * 10000;
|
5911 | });
|
5912 | addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
|
5913 | return this.millisecond() * 100000;
|
5914 | });
|
5915 | addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
|
5916 | return this.millisecond() * 1000000;
|
5917 | });
|
5918 |
|
5919 | addUnitAlias('millisecond', 'ms');
|
5920 |
|
5921 | addUnitPriority('millisecond', 16);
|
5922 |
|
5923 | addRegexToken('S', match1to3, match1);
|
5924 | addRegexToken('SS', match1to3, match2);
|
5925 | addRegexToken('SSS', match1to3, match3);
|
5926 | var token;
|
5927 |
|
5928 | for (token = 'SSSS'; token.length <= 9; token += 'S') {
|
5929 | addRegexToken(token, matchUnsigned);
|
5930 | }
|
5931 |
|
5932 | function parseMs(input, array) {
|
5933 | array[MILLISECOND] = toInt(('0.' + input) * 1000);
|
5934 | }
|
5935 |
|
5936 | for (token = 'S'; token.length <= 9; token += 'S') {
|
5937 | addParseToken(token, parseMs);
|
5938 | }
|
5939 |
|
5940 |
|
5941 | var getSetMillisecond = makeGetSet('Milliseconds', false);
|
5942 |
|
5943 | addFormatToken('z', 0, 0, 'zoneAbbr');
|
5944 | addFormatToken('zz', 0, 0, 'zoneName');
|
5945 |
|
5946 | function getZoneAbbr() {
|
5947 | return this._isUTC ? 'UTC' : '';
|
5948 | }
|
5949 |
|
5950 | function getZoneName() {
|
5951 | return this._isUTC ? 'Coordinated Universal Time' : '';
|
5952 | }
|
5953 |
|
5954 | var proto = Moment.prototype;
|
5955 | proto.add = add;
|
5956 | proto.calendar = calendar$1;
|
5957 | proto.clone = clone;
|
5958 | proto.diff = diff;
|
5959 | proto.endOf = endOf;
|
5960 | proto.format = format;
|
5961 | proto.from = from;
|
5962 | proto.fromNow = fromNow;
|
5963 | proto.to = to;
|
5964 | proto.toNow = toNow;
|
5965 | proto.get = stringGet;
|
5966 | proto.invalidAt = invalidAt;
|
5967 | proto.isAfter = isAfter;
|
5968 | proto.isBefore = isBefore;
|
5969 | proto.isBetween = isBetween;
|
5970 | proto.isSame = isSame;
|
5971 | proto.isSameOrAfter = isSameOrAfter;
|
5972 | proto.isSameOrBefore = isSameOrBefore;
|
5973 | proto.isValid = isValid$2;
|
5974 | proto.lang = lang;
|
5975 | proto.locale = locale;
|
5976 | proto.localeData = localeData;
|
5977 | proto.max = prototypeMax;
|
5978 | proto.min = prototypeMin;
|
5979 | proto.parsingFlags = parsingFlags;
|
5980 | proto.set = stringSet;
|
5981 | proto.startOf = startOf;
|
5982 | proto.subtract = subtract;
|
5983 | proto.toArray = toArray;
|
5984 | proto.toObject = toObject;
|
5985 | proto.toDate = toDate;
|
5986 | proto.toISOString = toISOString;
|
5987 | proto.inspect = inspect;
|
5988 | proto.toJSON = toJSON;
|
5989 | proto.toString = toString;
|
5990 | proto.unix = unix;
|
5991 | proto.valueOf = valueOf;
|
5992 | proto.creationData = creationData;
|
5993 | proto.year = getSetYear;
|
5994 | proto.isLeapYear = getIsLeapYear;
|
5995 | proto.weekYear = getSetWeekYear;
|
5996 | proto.isoWeekYear = getSetISOWeekYear;
|
5997 | proto.quarter = proto.quarters = getSetQuarter;
|
5998 | proto.month = getSetMonth;
|
5999 | proto.daysInMonth = getDaysInMonth;
|
6000 | proto.week = proto.weeks = getSetWeek;
|
6001 | proto.isoWeek = proto.isoWeeks = getSetISOWeek;
|
6002 | proto.weeksInYear = getWeeksInYear;
|
6003 | proto.isoWeeksInYear = getISOWeeksInYear;
|
6004 | proto.date = getSetDayOfMonth;
|
6005 | proto.day = proto.days = getSetDayOfWeek;
|
6006 | proto.weekday = getSetLocaleDayOfWeek;
|
6007 | proto.isoWeekday = getSetISODayOfWeek;
|
6008 | proto.dayOfYear = getSetDayOfYear;
|
6009 | proto.hour = proto.hours = getSetHour;
|
6010 | proto.minute = proto.minutes = getSetMinute;
|
6011 | proto.second = proto.seconds = getSetSecond;
|
6012 | proto.millisecond = proto.milliseconds = getSetMillisecond;
|
6013 | proto.utcOffset = getSetOffset;
|
6014 | proto.utc = setOffsetToUTC;
|
6015 | proto.local = setOffsetToLocal;
|
6016 | proto.parseZone = setOffsetToParsedOffset;
|
6017 | proto.hasAlignedHourOffset = hasAlignedHourOffset;
|
6018 | proto.isDST = isDaylightSavingTime;
|
6019 | proto.isLocal = isLocal;
|
6020 | proto.isUtcOffset = isUtcOffset;
|
6021 | proto.isUtc = isUtc;
|
6022 | proto.isUTC = isUtc;
|
6023 | proto.zoneAbbr = getZoneAbbr;
|
6024 | proto.zoneName = getZoneName;
|
6025 | proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
|
6026 | proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
|
6027 | proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
|
6028 | proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
|
6029 | proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
|
6030 |
|
6031 | function createUnix(input) {
|
6032 | return createLocal(input * 1000);
|
6033 | }
|
6034 |
|
6035 | function createInZone() {
|
6036 | return createLocal.apply(null, arguments).parseZone();
|
6037 | }
|
6038 |
|
6039 | function preParsePostFormat(string) {
|
6040 | return string;
|
6041 | }
|
6042 |
|
6043 | var proto$1 = Locale.prototype;
|
6044 | proto$1.calendar = calendar;
|
6045 | proto$1.longDateFormat = longDateFormat;
|
6046 | proto$1.invalidDate = invalidDate;
|
6047 | proto$1.ordinal = ordinal;
|
6048 | proto$1.preparse = preParsePostFormat;
|
6049 | proto$1.postformat = preParsePostFormat;
|
6050 | proto$1.relativeTime = relativeTime;
|
6051 | proto$1.pastFuture = pastFuture;
|
6052 | proto$1.set = set;
|
6053 | proto$1.months = localeMonths;
|
6054 | proto$1.monthsShort = localeMonthsShort;
|
6055 | proto$1.monthsParse = localeMonthsParse;
|
6056 | proto$1.monthsRegex = monthsRegex;
|
6057 | proto$1.monthsShortRegex = monthsShortRegex;
|
6058 | proto$1.week = localeWeek;
|
6059 | proto$1.firstDayOfYear = localeFirstDayOfYear;
|
6060 | proto$1.firstDayOfWeek = localeFirstDayOfWeek;
|
6061 | proto$1.weekdays = localeWeekdays;
|
6062 | proto$1.weekdaysMin = localeWeekdaysMin;
|
6063 | proto$1.weekdaysShort = localeWeekdaysShort;
|
6064 | proto$1.weekdaysParse = localeWeekdaysParse;
|
6065 | proto$1.weekdaysRegex = weekdaysRegex;
|
6066 | proto$1.weekdaysShortRegex = weekdaysShortRegex;
|
6067 | proto$1.weekdaysMinRegex = weekdaysMinRegex;
|
6068 | proto$1.isPM = localeIsPM;
|
6069 | proto$1.meridiem = localeMeridiem;
|
6070 |
|
6071 | function get$1(format, index, field, setter) {
|
6072 | var locale = getLocale();
|
6073 | var utc = createUTC().set(setter, index);
|
6074 | return locale[field](utc, format);
|
6075 | }
|
6076 |
|
6077 | function listMonthsImpl(format, index, field) {
|
6078 | if (isNumber(format)) {
|
6079 | index = format;
|
6080 | format = undefined;
|
6081 | }
|
6082 |
|
6083 | format = format || '';
|
6084 |
|
6085 | if (index != null) {
|
6086 | return get$1(format, index, field, 'month');
|
6087 | }
|
6088 |
|
6089 | var i;
|
6090 | var out = [];
|
6091 |
|
6092 | for (i = 0; i < 12; i++) {
|
6093 | out[i] = get$1(format, i, field, 'month');
|
6094 | }
|
6095 |
|
6096 | return out;
|
6097 | } // ()
|
6098 | // (5)
|
6099 | // (fmt, 5)
|
6100 | // (fmt)
|
6101 | // (true)
|
6102 | // (true, 5)
|
6103 | // (true, fmt, 5)
|
6104 | // (true, fmt)
|
6105 |
|
6106 |
|
6107 | function listWeekdaysImpl(localeSorted, format, index, field) {
|
6108 | if (typeof localeSorted === 'boolean') {
|
6109 | if (isNumber(format)) {
|
6110 | index = format;
|
6111 | format = undefined;
|
6112 | }
|
6113 |
|
6114 | format = format || '';
|
6115 | } else {
|
6116 | format = localeSorted;
|
6117 | index = format;
|
6118 | localeSorted = false;
|
6119 |
|
6120 | if (isNumber(format)) {
|
6121 | index = format;
|
6122 | format = undefined;
|
6123 | }
|
6124 |
|
6125 | format = format || '';
|
6126 | }
|
6127 |
|
6128 | var locale = getLocale(),
|
6129 | shift = localeSorted ? locale._week.dow : 0;
|
6130 |
|
6131 | if (index != null) {
|
6132 | return get$1(format, (index + shift) % 7, field, 'day');
|
6133 | }
|
6134 |
|
6135 | var i;
|
6136 | var out = [];
|
6137 |
|
6138 | for (i = 0; i < 7; i++) {
|
6139 | out[i] = get$1(format, (i + shift) % 7, field, 'day');
|
6140 | }
|
6141 |
|
6142 | return out;
|
6143 | }
|
6144 |
|
6145 | function listMonths(format, index) {
|
6146 | return listMonthsImpl(format, index, 'months');
|
6147 | }
|
6148 |
|
6149 | function listMonthsShort(format, index) {
|
6150 | return listMonthsImpl(format, index, 'monthsShort');
|
6151 | }
|
6152 |
|
6153 | function listWeekdays(localeSorted, format, index) {
|
6154 | return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
|
6155 | }
|
6156 |
|
6157 | function listWeekdaysShort(localeSorted, format, index) {
|
6158 | return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
|
6159 | }
|
6160 |
|
6161 | function listWeekdaysMin(localeSorted, format, index) {
|
6162 | return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
|
6163 | }
|
6164 |
|
6165 | getSetGlobalLocale('en', {
|
6166 | dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
|
6167 | ordinal: function (number) {
|
6168 | var b = number % 10,
|
6169 | output = toInt(number % 100 / 10) === 1 ? 'th' : b === 1 ? 'st' : b === 2 ? 'nd' : b === 3 ? 'rd' : 'th';
|
6170 | return number + output;
|
6171 | }
|
6172 | });
|
6173 |
|
6174 | hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
|
6175 | hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
|
6176 | var mathAbs = Math.abs;
|
6177 |
|
6178 | function abs() {
|
6179 | var data = this._data;
|
6180 | this._milliseconds = mathAbs(this._milliseconds);
|
6181 | this._days = mathAbs(this._days);
|
6182 | this._months = mathAbs(this._months);
|
6183 | data.milliseconds = mathAbs(data.milliseconds);
|
6184 | data.seconds = mathAbs(data.seconds);
|
6185 | data.minutes = mathAbs(data.minutes);
|
6186 | data.hours = mathAbs(data.hours);
|
6187 | data.months = mathAbs(data.months);
|
6188 | data.years = mathAbs(data.years);
|
6189 | return this;
|
6190 | }
|
6191 |
|
6192 | function addSubtract$1(duration, input, value, direction) {
|
6193 | var other = createDuration(input, value);
|
6194 | duration._milliseconds += direction * other._milliseconds;
|
6195 | duration._days += direction * other._days;
|
6196 | duration._months += direction * other._months;
|
6197 | return duration._bubble();
|
6198 | }
|
6199 |
|
6200 |
|
6201 | function add$1(input, value) {
|
6202 | return addSubtract$1(this, input, value, 1);
|
6203 | }
|
6204 |
|
6205 |
|
6206 | function subtract$1(input, value) {
|
6207 | return addSubtract$1(this, input, value, -1);
|
6208 | }
|
6209 |
|
6210 | function absCeil(number) {
|
6211 | if (number < 0) {
|
6212 | return Math.floor(number);
|
6213 | } else {
|
6214 | return Math.ceil(number);
|
6215 | }
|
6216 | }
|
6217 |
|
6218 | function bubble() {
|
6219 | var milliseconds = this._milliseconds;
|
6220 | var days = this._days;
|
6221 | var months = this._months;
|
6222 | var data = this._data;
|
6223 | var seconds, minutes, hours, years, monthsFromDays;
|
6224 |
|
6225 |
|
6226 | if (!(milliseconds >= 0 && days >= 0 && months >= 0 || milliseconds <= 0 && days <= 0 && months <= 0)) {
|
6227 | milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
|
6228 | days = 0;
|
6229 | months = 0;
|
6230 | }
|
6231 |
|
6232 |
|
6233 |
|
6234 | data.milliseconds = milliseconds % 1000;
|
6235 | seconds = absFloor(milliseconds / 1000);
|
6236 | data.seconds = seconds % 60;
|
6237 | minutes = absFloor(seconds / 60);
|
6238 | data.minutes = minutes % 60;
|
6239 | hours = absFloor(minutes / 60);
|
6240 | data.hours = hours % 24;
|
6241 | days += absFloor(hours / 24);
|
6242 |
|
6243 | monthsFromDays = absFloor(daysToMonths(days));
|
6244 | months += monthsFromDays;
|
6245 | days -= absCeil(monthsToDays(monthsFromDays));
|
6246 |
|
6247 | years = absFloor(months / 12);
|
6248 | months %= 12;
|
6249 | data.days = days;
|
6250 | data.months = months;
|
6251 | data.years = years;
|
6252 | return this;
|
6253 | }
|
6254 |
|
6255 | function daysToMonths(days) {
|
6256 |
|
6257 |
|
6258 | return days * 4800 / 146097;
|
6259 | }
|
6260 |
|
6261 | function monthsToDays(months) {
|
6262 |
|
6263 | return months * 146097 / 4800;
|
6264 | }
|
6265 |
|
6266 | function as(units) {
|
6267 | if (!this.isValid()) {
|
6268 | return NaN;
|
6269 | }
|
6270 |
|
6271 | var days;
|
6272 | var months;
|
6273 | var milliseconds = this._milliseconds;
|
6274 | units = normalizeUnits(units);
|
6275 |
|
6276 | if (units === 'month' || units === 'quarter' || units === 'year') {
|
6277 | days = this._days + milliseconds / 864e5;
|
6278 | months = this._months + daysToMonths(days);
|
6279 |
|
6280 | switch (units) {
|
6281 | case 'month':
|
6282 | return months;
|
6283 |
|
6284 | case 'quarter':
|
6285 | return months / 3;
|
6286 |
|
6287 | case 'year':
|
6288 | return months / 12;
|
6289 | }
|
6290 | } else {
|
6291 |
|
6292 | days = this._days + Math.round(monthsToDays(this._months));
|
6293 |
|
6294 | switch (units) {
|
6295 | case 'week':
|
6296 | return days / 7 + milliseconds / 6048e5;
|
6297 |
|
6298 | case 'day':
|
6299 | return days + milliseconds / 864e5;
|
6300 |
|
6301 | case 'hour':
|
6302 | return days * 24 + milliseconds / 36e5;
|
6303 |
|
6304 | case 'minute':
|
6305 | return days * 1440 + milliseconds / 6e4;
|
6306 |
|
6307 | case 'second':
|
6308 | return days * 86400 + milliseconds / 1000;
|
6309 |
|
6310 |
|
6311 | case 'millisecond':
|
6312 | return Math.floor(days * 864e5) + milliseconds;
|
6313 |
|
6314 | default:
|
6315 | throw new Error('Unknown unit ' + units);
|
6316 | }
|
6317 | }
|
6318 | }
|
6319 |
|
6320 |
|
6321 | function valueOf$1() {
|
6322 | if (!this.isValid()) {
|
6323 | return NaN;
|
6324 | }
|
6325 |
|
6326 | return this._milliseconds + this._days * 864e5 + this._months % 12 * 2592e6 + toInt(this._months / 12) * 31536e6;
|
6327 | }
|
6328 |
|
6329 | function makeAs(alias) {
|
6330 | return function () {
|
6331 | return this.as(alias);
|
6332 | };
|
6333 | }
|
6334 |
|
6335 | var asMilliseconds = makeAs('ms');
|
6336 | var asSeconds = makeAs('s');
|
6337 | var asMinutes = makeAs('m');
|
6338 | var asHours = makeAs('h');
|
6339 | var asDays = makeAs('d');
|
6340 | var asWeeks = makeAs('w');
|
6341 | var asMonths = makeAs('M');
|
6342 | var asQuarters = makeAs('Q');
|
6343 | var asYears = makeAs('y');
|
6344 |
|
6345 | function clone$1() {
|
6346 | return createDuration(this);
|
6347 | }
|
6348 |
|
6349 | function get$2(units) {
|
6350 | units = normalizeUnits(units);
|
6351 | return this.isValid() ? this[units + 's']() : NaN;
|
6352 | }
|
6353 |
|
6354 | function makeGetter(name) {
|
6355 | return function () {
|
6356 | return this.isValid() ? this._data[name] : NaN;
|
6357 | };
|
6358 | }
|
6359 |
|
6360 | var milliseconds = makeGetter('milliseconds');
|
6361 | var seconds = makeGetter('seconds');
|
6362 | var minutes = makeGetter('minutes');
|
6363 | var hours = makeGetter('hours');
|
6364 | var days = makeGetter('days');
|
6365 | var months = makeGetter('months');
|
6366 | var years = makeGetter('years');
|
6367 |
|
6368 | function weeks() {
|
6369 | return absFloor(this.days() / 7);
|
6370 | }
|
6371 |
|
6372 | var round = Math.round;
|
6373 | var thresholds = {
|
6374 | ss: 44,
|
6375 |
|
6376 | s: 45,
|
6377 |
|
6378 | m: 45,
|
6379 |
|
6380 | h: 22,
|
6381 |
|
6382 | d: 26,
|
6383 |
|
6384 | M: 11
|
6385 |
|
6386 | };
|
6387 |
|
6388 | function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
|
6389 | return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
|
6390 | }
|
6391 |
|
6392 | function relativeTime$1(posNegDuration, withoutSuffix, locale) {
|
6393 | var duration = createDuration(posNegDuration).abs();
|
6394 | var seconds = round(duration.as('s'));
|
6395 | var minutes = round(duration.as('m'));
|
6396 | var hours = round(duration.as('h'));
|
6397 | var days = round(duration.as('d'));
|
6398 | var months = round(duration.as('M'));
|
6399 | var years = round(duration.as('y'));
|
6400 | var a = seconds <= thresholds.ss && ['s', seconds] || seconds < thresholds.s && ['ss', seconds] || minutes <= 1 && ['m'] || minutes < thresholds.m && ['mm', minutes] || hours <= 1 && ['h'] || hours < thresholds.h && ['hh', hours] || days <= 1 && ['d'] || days < thresholds.d && ['dd', days] || months <= 1 && ['M'] || months < thresholds.M && ['MM', months] || years <= 1 && ['y'] || ['yy', years];
|
6401 | a[2] = withoutSuffix;
|
6402 | a[3] = +posNegDuration > 0;
|
6403 | a[4] = locale;
|
6404 | return substituteTimeAgo.apply(null, a);
|
6405 | }
|
6406 |
|
6407 |
|
6408 | function getSetRelativeTimeRounding(roundingFunction) {
|
6409 | if (roundingFunction === undefined) {
|
6410 | return round;
|
6411 | }
|
6412 |
|
6413 | if (typeof roundingFunction === 'function') {
|
6414 | round = roundingFunction;
|
6415 | return true;
|
6416 | }
|
6417 |
|
6418 | return false;
|
6419 | }
|
6420 |
|
6421 |
|
6422 | function getSetRelativeTimeThreshold(threshold, limit) {
|
6423 | if (thresholds[threshold] === undefined) {
|
6424 | return false;
|
6425 | }
|
6426 |
|
6427 | if (limit === undefined) {
|
6428 | return thresholds[threshold];
|
6429 | }
|
6430 |
|
6431 | thresholds[threshold] = limit;
|
6432 |
|
6433 | if (threshold === 's') {
|
6434 | thresholds.ss = limit - 1;
|
6435 | }
|
6436 |
|
6437 | return true;
|
6438 | }
|
6439 |
|
6440 | function humanize(withSuffix) {
|
6441 | if (!this.isValid()) {
|
6442 | return this.localeData().invalidDate();
|
6443 | }
|
6444 |
|
6445 | var locale = this.localeData();
|
6446 | var output = relativeTime$1(this, !withSuffix, locale);
|
6447 |
|
6448 | if (withSuffix) {
|
6449 | output = locale.pastFuture(+this, output);
|
6450 | }
|
6451 |
|
6452 | return locale.postformat(output);
|
6453 | }
|
6454 |
|
6455 | var abs$1 = Math.abs;
|
6456 |
|
6457 | function sign(x) {
|
6458 | return (x > 0) - (x < 0) || +x;
|
6459 | }
|
6460 |
|
6461 | function toISOString$1() {
|
6462 |
|
6463 |
|
6464 |
|
6465 |
|
6466 |
|
6467 |
|
6468 |
|
6469 | if (!this.isValid()) {
|
6470 | return this.localeData().invalidDate();
|
6471 | }
|
6472 |
|
6473 | var seconds = abs$1(this._milliseconds) / 1000;
|
6474 | var days = abs$1(this._days);
|
6475 | var months = abs$1(this._months);
|
6476 | var minutes, hours, years;
|
6477 |
|
6478 | minutes = absFloor(seconds / 60);
|
6479 | hours = absFloor(minutes / 60);
|
6480 | seconds %= 60;
|
6481 | minutes %= 60;
|
6482 |
|
6483 | years = absFloor(months / 12);
|
6484 | months %= 12;
|
6485 |
|
6486 | var Y = years;
|
6487 | var M = months;
|
6488 | var D = days;
|
6489 | var h = hours;
|
6490 | var m = minutes;
|
6491 | var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
|
6492 | var total = this.asSeconds();
|
6493 |
|
6494 | if (!total) {
|
6495 |
|
6496 |
|
6497 | return 'P0D';
|
6498 | }
|
6499 |
|
6500 | var totalSign = total < 0 ? '-' : '';
|
6501 | var ymSign = sign(this._months) !== sign(total) ? '-' : '';
|
6502 | var daysSign = sign(this._days) !== sign(total) ? '-' : '';
|
6503 | var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
|
6504 | return totalSign + 'P' + (Y ? ymSign + Y + 'Y' : '') + (M ? ymSign + M + 'M' : '') + (D ? daysSign + D + 'D' : '') + (h || m || s ? 'T' : '') + (h ? hmsSign + h + 'H' : '') + (m ? hmsSign + m + 'M' : '') + (s ? hmsSign + s + 'S' : '');
|
6505 | }
|
6506 |
|
6507 | var proto$2 = Duration.prototype;
|
6508 | proto$2.isValid = isValid$1;
|
6509 | proto$2.abs = abs;
|
6510 | proto$2.add = add$1;
|
6511 | proto$2.subtract = subtract$1;
|
6512 | proto$2.as = as;
|
6513 | proto$2.asMilliseconds = asMilliseconds;
|
6514 | proto$2.asSeconds = asSeconds;
|
6515 | proto$2.asMinutes = asMinutes;
|
6516 | proto$2.asHours = asHours;
|
6517 | proto$2.asDays = asDays;
|
6518 | proto$2.asWeeks = asWeeks;
|
6519 | proto$2.asMonths = asMonths;
|
6520 | proto$2.asQuarters = asQuarters;
|
6521 | proto$2.asYears = asYears;
|
6522 | proto$2.valueOf = valueOf$1;
|
6523 | proto$2._bubble = bubble;
|
6524 | proto$2.clone = clone$1;
|
6525 | proto$2.get = get$2;
|
6526 | proto$2.milliseconds = milliseconds;
|
6527 | proto$2.seconds = seconds;
|
6528 | proto$2.minutes = minutes;
|
6529 | proto$2.hours = hours;
|
6530 | proto$2.days = days;
|
6531 | proto$2.weeks = weeks;
|
6532 | proto$2.months = months;
|
6533 | proto$2.years = years;
|
6534 | proto$2.humanize = humanize;
|
6535 | proto$2.toISOString = toISOString$1;
|
6536 | proto$2.toString = toISOString$1;
|
6537 | proto$2.toJSON = toISOString$1;
|
6538 | proto$2.locale = locale;
|
6539 | proto$2.localeData = localeData;
|
6540 | proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
|
6541 | proto$2.lang = lang; // Side effect imports
|
6542 | // FORMATTING
|
6543 |
|
6544 | addFormatToken('X', 0, 0, 'unix');
|
6545 | addFormatToken('x', 0, 0, 'valueOf'); // PARSING
|
6546 |
|
6547 | addRegexToken('x', matchSigned);
|
6548 | addRegexToken('X', matchTimestamp);
|
6549 | addParseToken('X', function (input, array, config) {
|
6550 | config._d = new Date(parseFloat(input, 10) * 1000);
|
6551 | });
|
6552 | addParseToken('x', function (input, array, config) {
|
6553 | config._d = new Date(toInt(input));
|
6554 | });
|
6555 |
|
6556 | hooks.version = '2.24.0';
|
6557 | setHookCallback(createLocal);
|
6558 | hooks.fn = proto;
|
6559 | hooks.min = min;
|
6560 | hooks.max = max;
|
6561 | hooks.now = now;
|
6562 | hooks.utc = createUTC;
|
6563 | hooks.unix = createUnix;
|
6564 | hooks.months = listMonths;
|
6565 | hooks.isDate = isDate;
|
6566 | hooks.locale = getSetGlobalLocale;
|
6567 | hooks.invalid = createInvalid;
|
6568 | hooks.duration = createDuration;
|
6569 | hooks.isMoment = isMoment;
|
6570 | hooks.weekdays = listWeekdays;
|
6571 | hooks.parseZone = createInZone;
|
6572 | hooks.localeData = getLocale;
|
6573 | hooks.isDuration = isDuration;
|
6574 | hooks.monthsShort = listMonthsShort;
|
6575 | hooks.weekdaysMin = listWeekdaysMin;
|
6576 | hooks.defineLocale = defineLocale;
|
6577 | hooks.updateLocale = updateLocale;
|
6578 | hooks.locales = listLocales;
|
6579 | hooks.weekdaysShort = listWeekdaysShort;
|
6580 | hooks.normalizeUnits = normalizeUnits;
|
6581 | hooks.relativeTimeRounding = getSetRelativeTimeRounding;
|
6582 | hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
|
6583 | hooks.calendarFormat = getCalendarFormat;
|
6584 | hooks.prototype = proto;
|
6585 |
|
6586 | hooks.HTML5_FMT = {
|
6587 | DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm',
|
6588 |
|
6589 | DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss',
|
6590 |
|
6591 | DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS',
|
6592 |
|
6593 | DATE: 'YYYY-MM-DD',
|
6594 |
|
6595 | TIME: 'HH:mm',
|
6596 |
|
6597 | TIME_SECONDS: 'HH:mm:ss',
|
6598 |
|
6599 | TIME_MS: 'HH:mm:ss.SSS',
|
6600 |
|
6601 | WEEK: 'GGGG-[W]WW',
|
6602 |
|
6603 | MONTH: 'YYYY-MM'
|
6604 |
|
6605 | };
|
6606 | return hooks;
|
6607 | });
|
6608 | });
|
6609 |
|
6610 | var byteToHex = [];
|
6611 |
|
6612 | for (var i$1 = 0; i$1 < 256; i$1++) {
|
6613 | byteToHex[i$1] = (i$1 + 0x100).toString(16).substr(1);
|
6614 | }
|
6615 |
|
6616 |
|
6617 |
|
6618 |
|
6619 |
|
6620 |
|
6621 |
|
6622 |
|
6623 |
|
6624 |
|
6625 | function stringifyUUID(buf, offset) {
|
6626 | var i = offset || 0;
|
6627 | var bth = byteToHex;
|
6628 | return bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]];
|
6629 | }
|
6630 |
|
6631 |
|
6632 |
|
6633 |
|
6634 |
|
6635 |
|
6636 |
|
6637 | var random = function () {
|
6638 | if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
|
6639 |
|
6640 |
|
6641 | var _rnds8 = new Uint8Array(16);
|
6642 |
|
6643 | return function whatwgRNG() {
|
6644 | crypto.getRandomValues(_rnds8);
|
6645 | return _rnds8;
|
6646 | };
|
6647 | }
|
6648 |
|
6649 |
|
6650 |
|
6651 |
|
6652 |
|
6653 | var _rnds = new Array(16);
|
6654 |
|
6655 | return function () {
|
6656 | for (var i = 0, r; i < 16; i++) {
|
6657 | if ((i & 0x03) === 0) {
|
6658 | r = Math.random() * 0x100000000;
|
6659 | }
|
6660 |
|
6661 | _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
|
6662 | }
|
6663 |
|
6664 | return _rnds;
|
6665 | };
|
6666 |
|
6667 |
|
6668 |
|
6669 |
|
6670 |
|
6671 |
|
6672 |
|
6673 | }();
|
6674 |
|
6675 | var byteToHex$1 = [];
|
6676 |
|
6677 | for (var i$1$1 = 0; i$1$1 < 256; i$1$1++) {
|
6678 | byteToHex$1[i$1$1] = (i$1$1 + 0x100).toString(16).substr(1);
|
6679 | }
|
6680 |
|
6681 |
|
6682 |
|
6683 |
|
6684 |
|
6685 |
|
6686 | var seedBytes = random();
|
6687 |
|
6688 | var defaultNodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
|
6689 |
|
6690 | var defaultClockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
|
6691 |
|
6692 |
|
6693 |
|
6694 |
|
6695 |
|
6696 |
|
6697 |
|
6698 |
|
6699 |
|
6700 |
|
6701 |
|
6702 |
|
6703 |
|
6704 |
|
6705 |
|
6706 |
|
6707 | function uuid4() {
|
6708 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
6709 | var buf = arguments.length > 1 ? arguments[1] : undefined;
|
6710 | var offset = arguments.length > 2 ? arguments[2] : undefined;
|
6711 |
|
6712 | var i = buf && offset || 0;
|
6713 |
|
6714 | if (typeof options === 'string') {
|
6715 | buf = options === 'binary' ? new Array(16) : undefined;
|
6716 | options = {};
|
6717 | }
|
6718 |
|
6719 | var rnds = options.random || (options.rng || random)();
|
6720 |
|
6721 | rnds[6] = rnds[6] & 0x0f | 0x40;
|
6722 | rnds[8] = rnds[8] & 0x3f | 0x80;
|
6723 |
|
6724 | if (buf) {
|
6725 | for (var ii = 0; ii < 16; ii++) {
|
6726 | buf[i + ii] = rnds[ii];
|
6727 | }
|
6728 | }
|
6729 |
|
6730 | return buf || stringifyUUID(rnds);
|
6731 | }
|
6732 |
|
6733 |
|
6734 |
|
6735 |
|
6736 | var ASPDateRegex = /^\/?Date\((-?\d+)/i;
|
6737 |
|
6738 | var fullHexRE = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
|
6739 | var shortHexRE = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
6740 | var rgbRE = /^rgb\( *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *\)$/i;
|
6741 | var rgbaRE = /^rgba\( *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *([01]|0?\.\d+) *\)$/i;
|
6742 |
|
6743 |
|
6744 |
|
6745 |
|
6746 |
|
6747 |
|
6748 |
|
6749 |
|
6750 |
|
6751 |
|
6752 |
|
6753 |
|
6754 | function isNumber(value) {
|
6755 | return value instanceof Number || typeof value === "number";
|
6756 | }
|
6757 |
|
6758 |
|
6759 |
|
6760 |
|
6761 |
|
6762 |
|
6763 |
|
6764 | function recursiveDOMDelete(DOMobject) {
|
6765 | if (DOMobject) {
|
6766 | while (DOMobject.hasChildNodes() === true) {
|
6767 | var child = DOMobject.firstChild;
|
6768 |
|
6769 | if (child) {
|
6770 | recursiveDOMDelete(child);
|
6771 | DOMobject.removeChild(child);
|
6772 | }
|
6773 | }
|
6774 | }
|
6775 | }
|
6776 |
|
6777 |
|
6778 |
|
6779 |
|
6780 |
|
6781 |
|
6782 |
|
6783 |
|
6784 |
|
6785 | function isString(value) {
|
6786 | return value instanceof String || typeof value === "string";
|
6787 | }
|
6788 |
|
6789 |
|
6790 |
|
6791 |
|
6792 |
|
6793 |
|
6794 |
|
6795 |
|
6796 |
|
6797 | function isObject(value) {
|
6798 | return _typeof(value) === "object" && value !== null;
|
6799 | }
|
6800 |
|
6801 |
|
6802 |
|
6803 |
|
6804 |
|
6805 |
|
6806 |
|
6807 |
|
6808 |
|
6809 | function isDate(value) {
|
6810 | if (value instanceof Date) {
|
6811 | return true;
|
6812 | } else if (isString(value)) {
|
6813 |
|
6814 | var match = ASPDateRegex.exec(value);
|
6815 |
|
6816 | if (match) {
|
6817 | return true;
|
6818 | } else if (!isNaN(Date.parse(value))) {
|
6819 | return true;
|
6820 | }
|
6821 | }
|
6822 |
|
6823 | return false;
|
6824 | }
|
6825 |
|
6826 |
|
6827 |
|
6828 |
|
6829 |
|
6830 |
|
6831 |
|
6832 |
|
6833 |
|
6834 |
|
6835 | function isMoment(value) {
|
6836 | return moment.isMoment(value);
|
6837 | }
|
6838 |
|
6839 |
|
6840 |
|
6841 |
|
6842 |
|
6843 |
|
6844 |
|
6845 |
|
6846 |
|
6847 |
|
6848 |
|
6849 |
|
6850 |
|
6851 | function copyOrDelete(a, b, prop, allowDeletion) {
|
6852 | var doDeletion = false;
|
6853 |
|
6854 | if (allowDeletion === true) {
|
6855 | doDeletion = b[prop] === null && a[prop] !== undefined;
|
6856 | }
|
6857 |
|
6858 | if (doDeletion) {
|
6859 | delete a[prop];
|
6860 | } else {
|
6861 | a[prop] = b[prop];
|
6862 | }
|
6863 | }
|
6864 |
|
6865 |
|
6866 |
|
6867 |
|
6868 |
|
6869 |
|
6870 |
|
6871 |
|
6872 |
|
6873 |
|
6874 |
|
6875 |
|
6876 | function fillIfDefined(a, b) {
|
6877 | var allowDeletion = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
6878 |
|
6879 |
|
6880 | for (var prop in a) {
|
6881 | if (b[prop] !== undefined) {
|
6882 | if (b[prop] === null || _typeof(b[prop]) !== "object") {
|
6883 |
|
6884 | copyOrDelete(a, b, prop, allowDeletion);
|
6885 | } else {
|
6886 | var aProp = a[prop];
|
6887 | var bProp = b[prop];
|
6888 |
|
6889 | if (isObject(aProp) && isObject(bProp)) {
|
6890 | fillIfDefined(aProp, bProp, allowDeletion);
|
6891 | }
|
6892 | }
|
6893 | }
|
6894 | }
|
6895 | }
|
6896 |
|
6897 |
|
6898 |
|
6899 |
|
6900 |
|
6901 |
|
6902 |
|
6903 |
|
6904 |
|
6905 |
|
6906 |
|
6907 | var extend = Object.assign;
|
6908 |
|
6909 |
|
6910 |
|
6911 |
|
6912 |
|
6913 |
|
6914 |
|
6915 |
|
6916 |
|
6917 |
|
6918 |
|
6919 | function selectiveExtend(props, a) {
|
6920 | if (!Array.isArray(props)) {
|
6921 | throw new Error("Array with property names expected as first argument");
|
6922 | }
|
6923 |
|
6924 | for (var _len = arguments.length, others = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
6925 | others[_key - 2] = arguments[_key];
|
6926 | }
|
6927 |
|
6928 | for (var _i = 0, _others = others; _i < _others.length; _i++) {
|
6929 | var other = _others[_i];
|
6930 |
|
6931 | for (var p = 0; p < props.length; p++) {
|
6932 | var prop = props[p];
|
6933 |
|
6934 | if (other && Object.prototype.hasOwnProperty.call(other, prop)) {
|
6935 | a[prop] = other[prop];
|
6936 | }
|
6937 | }
|
6938 | }
|
6939 |
|
6940 | return a;
|
6941 | }
|
6942 |
|
6943 |
|
6944 |
|
6945 |
|
6946 |
|
6947 |
|
6948 |
|
6949 |
|
6950 |
|
6951 |
|
6952 |
|
6953 |
|
6954 |
|
6955 |
|
6956 |
|
6957 |
|
6958 |
|
6959 |
|
6960 | function selectiveDeepExtend(props, a, b) {
|
6961 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
6962 |
|
6963 | if (Array.isArray(b)) {
|
6964 | throw new TypeError("Arrays are not supported by deepExtend");
|
6965 | }
|
6966 |
|
6967 | for (var p = 0; p < props.length; p++) {
|
6968 | var prop = props[p];
|
6969 |
|
6970 | if (Object.prototype.hasOwnProperty.call(b, prop)) {
|
6971 | if (b[prop] && b[prop].constructor === Object) {
|
6972 | if (a[prop] === undefined) {
|
6973 | a[prop] = {};
|
6974 | }
|
6975 |
|
6976 | if (a[prop].constructor === Object) {
|
6977 | deepExtend(a[prop], b[prop], false, allowDeletion);
|
6978 | } else {
|
6979 | copyOrDelete(a, b, prop, allowDeletion);
|
6980 | }
|
6981 | } else if (Array.isArray(b[prop])) {
|
6982 | throw new TypeError("Arrays are not supported by deepExtend");
|
6983 | } else {
|
6984 | copyOrDelete(a, b, prop, allowDeletion);
|
6985 | }
|
6986 | }
|
6987 | }
|
6988 |
|
6989 | return a;
|
6990 | }
|
6991 |
|
6992 |
|
6993 |
|
6994 |
|
6995 |
|
6996 |
|
6997 |
|
6998 |
|
6999 |
|
7000 |
|
7001 |
|
7002 |
|
7003 |
|
7004 |
|
7005 |
|
7006 |
|
7007 |
|
7008 | function selectiveNotDeepExtend(propsToExclude, a, b) {
|
7009 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
7010 |
|
7011 |
|
7012 | if (Array.isArray(b)) {
|
7013 | throw new TypeError("Arrays are not supported by deepExtend");
|
7014 | }
|
7015 |
|
7016 | for (var prop in b) {
|
7017 | if (!Object.prototype.hasOwnProperty.call(b, prop)) {
|
7018 | continue;
|
7019 | }
|
7020 |
|
7021 |
|
7022 | if (propsToExclude.indexOf(prop) !== -1) {
|
7023 | continue;
|
7024 | }
|
7025 |
|
7026 |
|
7027 | if (b[prop] && b[prop].constructor === Object) {
|
7028 | if (a[prop] === undefined) {
|
7029 | a[prop] = {};
|
7030 | }
|
7031 |
|
7032 | if (a[prop].constructor === Object) {
|
7033 | deepExtend(a[prop], b[prop]);
|
7034 | } else {
|
7035 | copyOrDelete(a, b, prop, allowDeletion);
|
7036 | }
|
7037 | } else if (Array.isArray(b[prop])) {
|
7038 | a[prop] = [];
|
7039 |
|
7040 | for (var i = 0; i < b[prop].length; i++) {
|
7041 | a[prop].push(b[prop][i]);
|
7042 | }
|
7043 | } else {
|
7044 | copyOrDelete(a, b, prop, allowDeletion);
|
7045 | }
|
7046 | }
|
7047 |
|
7048 | return a;
|
7049 | }
|
7050 |
|
7051 |
|
7052 |
|
7053 |
|
7054 |
|
7055 |
|
7056 |
|
7057 |
|
7058 |
|
7059 |
|
7060 |
|
7061 |
|
7062 |
|
7063 | function deepExtend(a, b) {
|
7064 | var protoExtend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
7065 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
7066 |
|
7067 | for (var prop in b) {
|
7068 | if (Object.prototype.hasOwnProperty.call(b, prop) || protoExtend === true) {
|
7069 | if (b[prop] && Object.getPrototypeOf(b[prop]) === Object.prototype) {
|
7070 | if (a[prop] === undefined) {
|
7071 | a[prop] = deepExtend({}, b[prop], protoExtend);
|
7072 | } else if (a[prop] && Object.getPrototypeOf(a[prop]) === Object.prototype) {
|
7073 | deepExtend(a[prop], b[prop], protoExtend);
|
7074 | } else {
|
7075 | copyOrDelete(a, b, prop, allowDeletion);
|
7076 | }
|
7077 | } else if (Array.isArray(b[prop])) {
|
7078 | a[prop] = b[prop].slice();
|
7079 | } else {
|
7080 | copyOrDelete(a, b, prop, allowDeletion);
|
7081 | }
|
7082 | }
|
7083 | }
|
7084 |
|
7085 | return a;
|
7086 | }
|
7087 |
|
7088 |
|
7089 |
|
7090 |
|
7091 |
|
7092 |
|
7093 |
|
7094 |
|
7095 |
|
7096 |
|
7097 | function equalArray(a, b) {
|
7098 | if (a.length !== b.length) {
|
7099 | return false;
|
7100 | }
|
7101 |
|
7102 | for (var i = 0, len = a.length; i < len; i++) {
|
7103 | if (a[i] != b[i]) {
|
7104 | return false;
|
7105 | }
|
7106 | }
|
7107 |
|
7108 | return true;
|
7109 | }
|
7110 |
|
7111 |
|
7112 |
|
7113 |
|
7114 |
|
7115 |
|
7116 |
|
7117 |
|
7118 |
|
7119 |
|
7120 |
|
7121 | function convert(object, type) {
|
7122 | var match;
|
7123 |
|
7124 | if (object === undefined) {
|
7125 | return undefined;
|
7126 | }
|
7127 |
|
7128 | if (object === null) {
|
7129 | return null;
|
7130 | }
|
7131 |
|
7132 | if (!type) {
|
7133 | return object;
|
7134 | }
|
7135 |
|
7136 | if (!(typeof type === "string") && !(type instanceof String)) {
|
7137 | throw new Error("Type must be a string");
|
7138 | }
|
7139 |
|
7140 |
|
7141 | switch (type) {
|
7142 | case "boolean":
|
7143 | case "Boolean":
|
7144 | return Boolean(object);
|
7145 |
|
7146 | case "number":
|
7147 | case "Number":
|
7148 | if (isString(object) && !isNaN(Date.parse(object))) {
|
7149 | return moment(object).valueOf();
|
7150 | } else {
|
7151 |
|
7152 |
|
7153 |
|
7154 | return Number(object.valueOf());
|
7155 | }
|
7156 |
|
7157 | case "string":
|
7158 | case "String":
|
7159 | return String(object);
|
7160 |
|
7161 | case "Date":
|
7162 | if (isNumber(object)) {
|
7163 | return new Date(object);
|
7164 | }
|
7165 |
|
7166 | if (object instanceof Date) {
|
7167 | return new Date(object.valueOf());
|
7168 | } else if (isMoment(object)) {
|
7169 | return new Date(object.valueOf());
|
7170 | }
|
7171 |
|
7172 | if (isString(object)) {
|
7173 | match = ASPDateRegex.exec(object);
|
7174 |
|
7175 | if (match) {
|
7176 |
|
7177 | return new Date(Number(match[1]));
|
7178 | } else {
|
7179 | return moment(new Date(object)).toDate();
|
7180 | }
|
7181 | } else {
|
7182 | throw new Error("Cannot convert object of type " + getType(object) + " to type Date");
|
7183 | }
|
7184 |
|
7185 | case "Moment":
|
7186 | if (isNumber(object)) {
|
7187 | return moment(object);
|
7188 | }
|
7189 |
|
7190 | if (object instanceof Date) {
|
7191 | return moment(object.valueOf());
|
7192 | } else if (isMoment(object)) {
|
7193 | return moment(object);
|
7194 | }
|
7195 |
|
7196 | if (isString(object)) {
|
7197 | match = ASPDateRegex.exec(object);
|
7198 |
|
7199 | if (match) {
|
7200 |
|
7201 | return moment(Number(match[1]));
|
7202 | } else {
|
7203 | return moment(object);
|
7204 | }
|
7205 | } else {
|
7206 | throw new Error("Cannot convert object of type " + getType(object) + " to type Date");
|
7207 | }
|
7208 |
|
7209 | case "ISODate":
|
7210 | if (isNumber(object)) {
|
7211 | return new Date(object);
|
7212 | } else if (object instanceof Date) {
|
7213 | return object.toISOString();
|
7214 | } else if (isMoment(object)) {
|
7215 | return object.toDate().toISOString();
|
7216 | } else if (isString(object)) {
|
7217 | match = ASPDateRegex.exec(object);
|
7218 |
|
7219 | if (match) {
|
7220 |
|
7221 | return new Date(Number(match[1])).toISOString();
|
7222 | } else {
|
7223 | return moment(object).format();
|
7224 | }
|
7225 | } else {
|
7226 | throw new Error("Cannot convert object of type " + getType(object) + " to type ISODate");
|
7227 | }
|
7228 |
|
7229 | case "ASPDate":
|
7230 | if (isNumber(object)) {
|
7231 | return "/Date(" + object + ")/";
|
7232 | } else if (object instanceof Date || isMoment(object)) {
|
7233 | return "/Date(" + object.valueOf() + ")/";
|
7234 | } else if (isString(object)) {
|
7235 | match = ASPDateRegex.exec(object);
|
7236 |
|
7237 | var _value;
|
7238 |
|
7239 | if (match) {
|
7240 |
|
7241 | _value = new Date(Number(match[1])).valueOf();
|
7242 | } else {
|
7243 | _value = new Date(object).valueOf();
|
7244 | }
|
7245 |
|
7246 | return "/Date(" + _value + ")/";
|
7247 | } else {
|
7248 | throw new Error("Cannot convert object of type " + getType(object) + " to type ASPDate");
|
7249 | }
|
7250 |
|
7251 | default:
|
7252 | var never = type;
|
7253 | throw new Error("Unknown type ".concat(never));
|
7254 | }
|
7255 | }
|
7256 |
|
7257 |
|
7258 |
|
7259 |
|
7260 |
|
7261 |
|
7262 |
|
7263 |
|
7264 |
|
7265 | function getType(object) {
|
7266 | var type = _typeof(object);
|
7267 |
|
7268 | if (type === "object") {
|
7269 | if (object === null) {
|
7270 | return "null";
|
7271 | }
|
7272 |
|
7273 | if (object instanceof Boolean) {
|
7274 | return "Boolean";
|
7275 | }
|
7276 |
|
7277 | if (object instanceof Number) {
|
7278 | return "Number";
|
7279 | }
|
7280 |
|
7281 | if (object instanceof String) {
|
7282 | return "String";
|
7283 | }
|
7284 |
|
7285 | if (Array.isArray(object)) {
|
7286 | return "Array";
|
7287 | }
|
7288 |
|
7289 | if (object instanceof Date) {
|
7290 | return "Date";
|
7291 | }
|
7292 |
|
7293 | return "Object";
|
7294 | }
|
7295 |
|
7296 | if (type === "number") {
|
7297 | return "Number";
|
7298 | }
|
7299 |
|
7300 | if (type === "boolean") {
|
7301 | return "Boolean";
|
7302 | }
|
7303 |
|
7304 | if (type === "string") {
|
7305 | return "String";
|
7306 | }
|
7307 |
|
7308 | if (type === undefined) {
|
7309 | return "undefined";
|
7310 | }
|
7311 |
|
7312 | return type;
|
7313 | }
|
7314 |
|
7315 |
|
7316 |
|
7317 |
|
7318 |
|
7319 |
|
7320 |
|
7321 |
|
7322 |
|
7323 |
|
7324 | function copyAndExtendArray(arr, newValue) {
|
7325 | return [].concat(_toConsumableArray(arr), [newValue]);
|
7326 | }
|
7327 |
|
7328 |
|
7329 |
|
7330 |
|
7331 |
|
7332 |
|
7333 |
|
7334 |
|
7335 |
|
7336 | function copyArray(arr) {
|
7337 | return arr.slice();
|
7338 | }
|
7339 |
|
7340 |
|
7341 |
|
7342 |
|
7343 |
|
7344 |
|
7345 |
|
7346 |
|
7347 |
|
7348 | function getAbsoluteLeft(elem) {
|
7349 | return elem.getBoundingClientRect().left;
|
7350 | }
|
7351 |
|
7352 |
|
7353 |
|
7354 |
|
7355 |
|
7356 |
|
7357 |
|
7358 |
|
7359 |
|
7360 | function getAbsoluteRight(elem) {
|
7361 | return elem.getBoundingClientRect().right;
|
7362 | }
|
7363 |
|
7364 |
|
7365 |
|
7366 |
|
7367 |
|
7368 |
|
7369 |
|
7370 |
|
7371 |
|
7372 | function getAbsoluteTop(elem) {
|
7373 | return elem.getBoundingClientRect().top;
|
7374 | }
|
7375 |
|
7376 |
|
7377 |
|
7378 |
|
7379 |
|
7380 |
|
7381 |
|
7382 |
|
7383 | function addClassName(elem, classNames) {
|
7384 | var classes = elem.className.split(" ");
|
7385 | var newClasses = classNames.split(" ");
|
7386 | classes = classes.concat(newClasses.filter(function (className) {
|
7387 | return classes.indexOf(className) < 0;
|
7388 | }));
|
7389 | elem.className = classes.join(" ");
|
7390 | }
|
7391 |
|
7392 |
|
7393 |
|
7394 |
|
7395 |
|
7396 |
|
7397 |
|
7398 |
|
7399 | function removeClassName(elem, classNames) {
|
7400 | var classes = elem.className.split(" ");
|
7401 | var oldClasses = classNames.split(" ");
|
7402 | classes = classes.filter(function (className) {
|
7403 | return oldClasses.indexOf(className) < 0;
|
7404 | });
|
7405 | elem.className = classes.join(" ");
|
7406 | }
|
7407 |
|
7408 |
|
7409 |
|
7410 |
|
7411 |
|
7412 |
|
7413 |
|
7414 |
|
7415 |
|
7416 |
|
7417 | function forEach(object, callback) {
|
7418 | if (Array.isArray(object)) {
|
7419 |
|
7420 | var len = object.length;
|
7421 |
|
7422 | for (var i = 0; i < len; i++) {
|
7423 | callback(object[i], i, object);
|
7424 | }
|
7425 | } else {
|
7426 |
|
7427 | for (var _key2 in object) {
|
7428 | if (Object.prototype.hasOwnProperty.call(object, _key2)) {
|
7429 | callback(object[_key2], _key2, object);
|
7430 | }
|
7431 | }
|
7432 | }
|
7433 | }
|
7434 |
|
7435 |
|
7436 |
|
7437 |
|
7438 |
|
7439 |
|
7440 |
|
7441 |
|
7442 |
|
7443 | var toArray = Object.values;
|
7444 |
|
7445 |
|
7446 |
|
7447 |
|
7448 |
|
7449 |
|
7450 |
|
7451 |
|
7452 |
|
7453 |
|
7454 | function updateProperty(object, key, value) {
|
7455 | if (object[key] !== value) {
|
7456 | object[key] = value;
|
7457 | return true;
|
7458 | } else {
|
7459 | return false;
|
7460 | }
|
7461 | }
|
7462 |
|
7463 |
|
7464 |
|
7465 |
|
7466 |
|
7467 |
|
7468 |
|
7469 |
|
7470 |
|
7471 | function throttle(fn) {
|
7472 | var scheduled = false;
|
7473 | return function () {
|
7474 | if (!scheduled) {
|
7475 | scheduled = true;
|
7476 | requestAnimationFrame(function () {
|
7477 | scheduled = false;
|
7478 | fn();
|
7479 | });
|
7480 | }
|
7481 | };
|
7482 | }
|
7483 |
|
7484 |
|
7485 |
|
7486 |
|
7487 |
|
7488 |
|
7489 |
|
7490 |
|
7491 |
|
7492 |
|
7493 | function addEventListener(element, action, listener, useCapture) {
|
7494 | if (element.addEventListener) {
|
7495 | if (useCapture === undefined) {
|
7496 | useCapture = false;
|
7497 | }
|
7498 |
|
7499 | if (action === "mousewheel" && navigator.userAgent.indexOf("Firefox") >= 0) {
|
7500 | action = "DOMMouseScroll";
|
7501 | }
|
7502 |
|
7503 | element.addEventListener(action, listener, useCapture);
|
7504 | } else {
|
7505 |
|
7506 | element.attachEvent("on" + action, listener);
|
7507 | }
|
7508 | }
|
7509 |
|
7510 |
|
7511 |
|
7512 |
|
7513 |
|
7514 |
|
7515 |
|
7516 |
|
7517 |
|
7518 |
|
7519 | function removeEventListener(element, action, listener, useCapture) {
|
7520 | if (element.removeEventListener) {
|
7521 |
|
7522 | if (useCapture === undefined) {
|
7523 | useCapture = false;
|
7524 | }
|
7525 |
|
7526 | if (action === "mousewheel" && navigator.userAgent.indexOf("Firefox") >= 0) {
|
7527 | action = "DOMMouseScroll";
|
7528 | }
|
7529 |
|
7530 | element.removeEventListener(action, listener, useCapture);
|
7531 | } else {
|
7532 |
|
7533 | element.detachEvent("on" + action, listener);
|
7534 | }
|
7535 | }
|
7536 |
|
7537 |
|
7538 |
|
7539 |
|
7540 |
|
7541 |
|
7542 |
|
7543 | function preventDefault(event) {
|
7544 | if (!event) {
|
7545 | event = window.event;
|
7546 | }
|
7547 |
|
7548 | if (!event) ;else if (event.preventDefault) {
|
7549 | event.preventDefault();
|
7550 | } else {
|
7551 |
|
7552 | event.returnValue = false;
|
7553 | }
|
7554 | }
|
7555 |
|
7556 |
|
7557 |
|
7558 |
|
7559 |
|
7560 |
|
7561 |
|
7562 |
|
7563 |
|
7564 | function getTarget() {
|
7565 | var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.event;
|
7566 |
|
7567 |
|
7568 | var target = null;
|
7569 | if (!event) ;else if (event.target) {
|
7570 | target = event.target;
|
7571 | } else if (event.srcElement) {
|
7572 | target = event.srcElement;
|
7573 | }
|
7574 |
|
7575 | if (!(target instanceof Element)) {
|
7576 | return null;
|
7577 | }
|
7578 |
|
7579 | if (target.nodeType != null && target.nodeType == 3) {
|
7580 |
|
7581 | target = target.parentNode;
|
7582 |
|
7583 | if (!(target instanceof Element)) {
|
7584 | return null;
|
7585 | }
|
7586 | }
|
7587 |
|
7588 | return target;
|
7589 | }
|
7590 |
|
7591 |
|
7592 |
|
7593 |
|
7594 |
|
7595 |
|
7596 |
|
7597 |
|
7598 |
|
7599 |
|
7600 | function hasParent(element, parent) {
|
7601 | var elem = element;
|
7602 |
|
7603 | while (elem) {
|
7604 | if (elem === parent) {
|
7605 | return true;
|
7606 | } else if (elem.parentNode) {
|
7607 | elem = elem.parentNode;
|
7608 | } else {
|
7609 | return false;
|
7610 | }
|
7611 | }
|
7612 |
|
7613 | return false;
|
7614 | }
|
7615 |
|
7616 | var option = {
|
7617 | |
7618 |
|
7619 |
|
7620 |
|
7621 |
|
7622 |
|
7623 |
|
7624 |
|
7625 | asBoolean: function asBoolean(value, defaultValue) {
|
7626 | if (typeof value == "function") {
|
7627 | value = value();
|
7628 | }
|
7629 |
|
7630 | if (value != null) {
|
7631 | return value != false;
|
7632 | }
|
7633 |
|
7634 | return defaultValue || null;
|
7635 | },
|
7636 |
|
7637 | |
7638 |
|
7639 |
|
7640 |
|
7641 |
|
7642 |
|
7643 |
|
7644 |
|
7645 | asNumber: function asNumber(value, defaultValue) {
|
7646 | if (typeof value == "function") {
|
7647 | value = value();
|
7648 | }
|
7649 |
|
7650 | if (value != null) {
|
7651 | return Number(value) || defaultValue || null;
|
7652 | }
|
7653 |
|
7654 | return defaultValue || null;
|
7655 | },
|
7656 |
|
7657 | |
7658 |
|
7659 |
|
7660 |
|
7661 |
|
7662 |
|
7663 |
|
7664 |
|
7665 | asString: function asString(value, defaultValue) {
|
7666 | if (typeof value == "function") {
|
7667 | value = value();
|
7668 | }
|
7669 |
|
7670 | if (value != null) {
|
7671 | return String(value);
|
7672 | }
|
7673 |
|
7674 | return defaultValue || null;
|
7675 | },
|
7676 |
|
7677 | |
7678 |
|
7679 |
|
7680 |
|
7681 |
|
7682 |
|
7683 |
|
7684 |
|
7685 | asSize: function asSize(value, defaultValue) {
|
7686 | if (typeof value == "function") {
|
7687 | value = value();
|
7688 | }
|
7689 |
|
7690 | if (isString(value)) {
|
7691 | return value;
|
7692 | } else if (isNumber(value)) {
|
7693 | return value + "px";
|
7694 | } else {
|
7695 | return defaultValue || null;
|
7696 | }
|
7697 | },
|
7698 |
|
7699 | |
7700 |
|
7701 |
|
7702 |
|
7703 |
|
7704 |
|
7705 |
|
7706 |
|
7707 | asElement: function asElement(value, defaultValue) {
|
7708 | if (typeof value == "function") {
|
7709 | value = value();
|
7710 | }
|
7711 |
|
7712 | return value || defaultValue || null;
|
7713 | }
|
7714 | };
|
7715 |
|
7716 |
|
7717 |
|
7718 |
|
7719 |
|
7720 |
|
7721 |
|
7722 |
|
7723 |
|
7724 | function hexToRGB(hex) {
|
7725 | var result;
|
7726 |
|
7727 | switch (hex.length) {
|
7728 | case 3:
|
7729 | case 4:
|
7730 | result = shortHexRE.exec(hex);
|
7731 | return result ? {
|
7732 | r: parseInt(result[1] + result[1], 16),
|
7733 | g: parseInt(result[2] + result[2], 16),
|
7734 | b: parseInt(result[3] + result[3], 16)
|
7735 | } : null;
|
7736 |
|
7737 | case 6:
|
7738 | case 7:
|
7739 | result = fullHexRE.exec(hex);
|
7740 | return result ? {
|
7741 | r: parseInt(result[1], 16),
|
7742 | g: parseInt(result[2], 16),
|
7743 | b: parseInt(result[3], 16)
|
7744 | } : null;
|
7745 |
|
7746 | default:
|
7747 | return null;
|
7748 | }
|
7749 | }
|
7750 |
|
7751 |
|
7752 |
|
7753 |
|
7754 |
|
7755 |
|
7756 |
|
7757 |
|
7758 |
|
7759 |
|
7760 | function overrideOpacity(color, opacity) {
|
7761 | if (color.indexOf("rgba") !== -1) {
|
7762 | return color;
|
7763 | } else if (color.indexOf("rgb") !== -1) {
|
7764 | var rgb = color.substr(color.indexOf("(") + 1).replace(")", "").split(",");
|
7765 | return "rgba(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "," + opacity + ")";
|
7766 | } else {
|
7767 | var _rgb = hexToRGB(color);
|
7768 |
|
7769 | if (_rgb == null) {
|
7770 | return color;
|
7771 | } else {
|
7772 | return "rgba(" + _rgb.r + "," + _rgb.g + "," + _rgb.b + "," + opacity + ")";
|
7773 | }
|
7774 | }
|
7775 | }
|
7776 |
|
7777 |
|
7778 |
|
7779 |
|
7780 |
|
7781 |
|
7782 |
|
7783 |
|
7784 |
|
7785 |
|
7786 |
|
7787 | function RGBToHex(red, green, blue) {
|
7788 | return "#" + ((1 << 24) + (red << 16) + (green << 8) + blue).toString(16).slice(1);
|
7789 | }
|
7790 |
|
7791 |
|
7792 |
|
7793 |
|
7794 |
|
7795 |
|
7796 |
|
7797 |
|
7798 |
|
7799 |
|
7800 | function parseColor(inputColor, defaultColor) {
|
7801 | if (isString(inputColor)) {
|
7802 | var colorStr = inputColor;
|
7803 |
|
7804 | if (isValidRGB(colorStr)) {
|
7805 | var rgb = colorStr.substr(4).substr(0, colorStr.length - 5).split(",").map(function (value) {
|
7806 | return parseInt(value);
|
7807 | });
|
7808 | colorStr = RGBToHex(rgb[0], rgb[1], rgb[2]);
|
7809 | }
|
7810 |
|
7811 | if (isValidHex(colorStr) === true) {
|
7812 | var hsv = hexToHSV(colorStr);
|
7813 | var lighterColorHSV = {
|
7814 | h: hsv.h,
|
7815 | s: hsv.s * 0.8,
|
7816 | v: Math.min(1, hsv.v * 1.02)
|
7817 | };
|
7818 | var darkerColorHSV = {
|
7819 | h: hsv.h,
|
7820 | s: Math.min(1, hsv.s * 1.25),
|
7821 | v: hsv.v * 0.8
|
7822 | };
|
7823 | var darkerColorHex = HSVToHex(darkerColorHSV.h, darkerColorHSV.s, darkerColorHSV.v);
|
7824 | var lighterColorHex = HSVToHex(lighterColorHSV.h, lighterColorHSV.s, lighterColorHSV.v);
|
7825 | return {
|
7826 | background: colorStr,
|
7827 | border: darkerColorHex,
|
7828 | highlight: {
|
7829 | background: lighterColorHex,
|
7830 | border: darkerColorHex
|
7831 | },
|
7832 | hover: {
|
7833 | background: lighterColorHex,
|
7834 | border: darkerColorHex
|
7835 | }
|
7836 | };
|
7837 | } else {
|
7838 | return {
|
7839 | background: colorStr,
|
7840 | border: colorStr,
|
7841 | highlight: {
|
7842 | background: colorStr,
|
7843 | border: colorStr
|
7844 | },
|
7845 | hover: {
|
7846 | background: colorStr,
|
7847 | border: colorStr
|
7848 | }
|
7849 | };
|
7850 | }
|
7851 | } else {
|
7852 | if (defaultColor) {
|
7853 | var color = {
|
7854 | background: inputColor.background || defaultColor.background,
|
7855 | border: inputColor.border || defaultColor.border,
|
7856 | highlight: isString(inputColor.highlight) ? {
|
7857 | border: inputColor.highlight,
|
7858 | background: inputColor.highlight
|
7859 | } : {
|
7860 | background: inputColor.highlight && inputColor.highlight.background || defaultColor.highlight.background,
|
7861 | border: inputColor.highlight && inputColor.highlight.border || defaultColor.highlight.border
|
7862 | },
|
7863 | hover: isString(inputColor.hover) ? {
|
7864 | border: inputColor.hover,
|
7865 | background: inputColor.hover
|
7866 | } : {
|
7867 | border: inputColor.hover && inputColor.hover.border || defaultColor.hover.border,
|
7868 | background: inputColor.hover && inputColor.hover.background || defaultColor.hover.background
|
7869 | }
|
7870 | };
|
7871 | return color;
|
7872 | } else {
|
7873 | var _color = {
|
7874 | background: inputColor.background || undefined,
|
7875 | border: inputColor.border || undefined,
|
7876 | highlight: isString(inputColor.highlight) ? {
|
7877 | border: inputColor.highlight,
|
7878 | background: inputColor.highlight
|
7879 | } : {
|
7880 | background: inputColor.highlight && inputColor.highlight.background || undefined,
|
7881 | border: inputColor.highlight && inputColor.highlight.border || undefined
|
7882 | },
|
7883 | hover: isString(inputColor.hover) ? {
|
7884 | border: inputColor.hover,
|
7885 | background: inputColor.hover
|
7886 | } : {
|
7887 | border: inputColor.hover && inputColor.hover.border || undefined,
|
7888 | background: inputColor.hover && inputColor.hover.background || undefined
|
7889 | }
|
7890 | };
|
7891 | return _color;
|
7892 | }
|
7893 | }
|
7894 | }
|
7895 |
|
7896 |
|
7897 |
|
7898 |
|
7899 |
|
7900 |
|
7901 |
|
7902 |
|
7903 |
|
7904 |
|
7905 |
|
7906 |
|
7907 | function RGBToHSV(red, green, blue) {
|
7908 | red = red / 255;
|
7909 | green = green / 255;
|
7910 | blue = blue / 255;
|
7911 | var minRGB = Math.min(red, Math.min(green, blue));
|
7912 | var maxRGB = Math.max(red, Math.max(green, blue));
|
7913 |
|
7914 | if (minRGB === maxRGB) {
|
7915 | return {
|
7916 | h: 0,
|
7917 | s: 0,
|
7918 | v: minRGB
|
7919 | };
|
7920 | }
|
7921 |
|
7922 |
|
7923 | var d = red === minRGB ? green - blue : blue === minRGB ? red - green : blue - red;
|
7924 | var h = red === minRGB ? 3 : blue === minRGB ? 1 : 5;
|
7925 | var hue = 60 * (h - d / (maxRGB - minRGB)) / 360;
|
7926 | var saturation = (maxRGB - minRGB) / maxRGB;
|
7927 | var value = maxRGB;
|
7928 | return {
|
7929 | h: hue,
|
7930 | s: saturation,
|
7931 | v: value
|
7932 | };
|
7933 | }
|
7934 |
|
7935 | var cssUtil = {
|
7936 |
|
7937 | split: function split(cssText) {
|
7938 | var styles = {};
|
7939 | cssText.split(";").forEach(function (style) {
|
7940 | if (style.trim() != "") {
|
7941 | var parts = style.split(":");
|
7942 |
|
7943 | var _key3 = parts[0].trim();
|
7944 |
|
7945 | var _value2 = parts[1].trim();
|
7946 |
|
7947 | styles[_key3] = _value2;
|
7948 | }
|
7949 | });
|
7950 | return styles;
|
7951 | },
|
7952 |
|
7953 | join: function join(styles) {
|
7954 | return Object.keys(styles).map(function (key) {
|
7955 | return key + ": " + styles[key];
|
7956 | }).join("; ");
|
7957 | }
|
7958 | };
|
7959 |
|
7960 |
|
7961 |
|
7962 |
|
7963 |
|
7964 |
|
7965 |
|
7966 | function addCssText(element, cssText) {
|
7967 | var currentStyles = cssUtil.split(element.style.cssText);
|
7968 | var newStyles = cssUtil.split(cssText);
|
7969 |
|
7970 | var styles = _objectSpread2({}, currentStyles, {}, newStyles);
|
7971 |
|
7972 | element.style.cssText = cssUtil.join(styles);
|
7973 | }
|
7974 |
|
7975 |
|
7976 |
|
7977 |
|
7978 |
|
7979 |
|
7980 |
|
7981 |
|
7982 | function removeCssText(element, cssText) {
|
7983 | var styles = cssUtil.split(element.style.cssText);
|
7984 | var removeStyles = cssUtil.split(cssText);
|
7985 |
|
7986 | for (var _key4 in removeStyles) {
|
7987 | if (Object.prototype.hasOwnProperty.call(removeStyles, _key4)) {
|
7988 | delete styles[_key4];
|
7989 | }
|
7990 | }
|
7991 |
|
7992 | element.style.cssText = cssUtil.join(styles);
|
7993 | }
|
7994 |
|
7995 |
|
7996 |
|
7997 |
|
7998 |
|
7999 |
|
8000 |
|
8001 |
|
8002 |
|
8003 |
|
8004 |
|
8005 |
|
8006 | function HSVToRGB(h, s, v) {
|
8007 | var r;
|
8008 | var g;
|
8009 | var b;
|
8010 | var i = Math.floor(h * 6);
|
8011 | var f = h * 6 - i;
|
8012 | var p = v * (1 - s);
|
8013 | var q = v * (1 - f * s);
|
8014 | var t = v * (1 - (1 - f) * s);
|
8015 |
|
8016 | switch (i % 6) {
|
8017 | case 0:
|
8018 | r = v, g = t, b = p;
|
8019 | break;
|
8020 |
|
8021 | case 1:
|
8022 | r = q, g = v, b = p;
|
8023 | break;
|
8024 |
|
8025 | case 2:
|
8026 | r = p, g = v, b = t;
|
8027 | break;
|
8028 |
|
8029 | case 3:
|
8030 | r = p, g = q, b = v;
|
8031 | break;
|
8032 |
|
8033 | case 4:
|
8034 | r = t, g = p, b = v;
|
8035 | break;
|
8036 |
|
8037 | case 5:
|
8038 | r = v, g = p, b = q;
|
8039 | break;
|
8040 | }
|
8041 |
|
8042 | return {
|
8043 | r: Math.floor(r * 255),
|
8044 | g: Math.floor(g * 255),
|
8045 | b: Math.floor(b * 255)
|
8046 | };
|
8047 | }
|
8048 |
|
8049 |
|
8050 |
|
8051 |
|
8052 |
|
8053 |
|
8054 |
|
8055 |
|
8056 |
|
8057 |
|
8058 |
|
8059 | function HSVToHex(h, s, v) {
|
8060 | var rgb = HSVToRGB(h, s, v);
|
8061 | return RGBToHex(rgb.r, rgb.g, rgb.b);
|
8062 | }
|
8063 |
|
8064 |
|
8065 |
|
8066 |
|
8067 |
|
8068 |
|
8069 |
|
8070 |
|
8071 |
|
8072 | function hexToHSV(hex) {
|
8073 | var rgb = hexToRGB(hex);
|
8074 |
|
8075 | if (!rgb) {
|
8076 | throw new TypeError("'".concat(hex, "' is not a valid color."));
|
8077 | }
|
8078 |
|
8079 | return RGBToHSV(rgb.r, rgb.g, rgb.b);
|
8080 | }
|
8081 |
|
8082 |
|
8083 |
|
8084 |
|
8085 |
|
8086 |
|
8087 |
|
8088 |
|
8089 |
|
8090 | function isValidHex(hex) {
|
8091 | var isOk = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex);
|
8092 | return isOk;
|
8093 | }
|
8094 |
|
8095 |
|
8096 |
|
8097 |
|
8098 |
|
8099 |
|
8100 |
|
8101 |
|
8102 |
|
8103 | function isValidRGB(rgb) {
|
8104 | return rgbRE.test(rgb);
|
8105 | }
|
8106 |
|
8107 |
|
8108 |
|
8109 |
|
8110 |
|
8111 |
|
8112 |
|
8113 |
|
8114 |
|
8115 | function isValidRGBA(rgba) {
|
8116 | return rgbaRE.test(rgba);
|
8117 | }
|
8118 |
|
8119 |
|
8120 |
|
8121 |
|
8122 |
|
8123 |
|
8124 |
|
8125 |
|
8126 |
|
8127 |
|
8128 |
|
8129 | function selectiveBridgeObject(fields, referenceObject) {
|
8130 | if (referenceObject !== null && _typeof(referenceObject) === "object") {
|
8131 |
|
8132 | var objectTo = Object.create(referenceObject);
|
8133 |
|
8134 | for (var i = 0; i < fields.length; i++) {
|
8135 | if (Object.prototype.hasOwnProperty.call(referenceObject, fields[i])) {
|
8136 | if (_typeof(referenceObject[fields[i]]) == "object") {
|
8137 | objectTo[fields[i]] = bridgeObject(referenceObject[fields[i]]);
|
8138 | }
|
8139 | }
|
8140 | }
|
8141 |
|
8142 | return objectTo;
|
8143 | } else {
|
8144 | return null;
|
8145 | }
|
8146 | }
|
8147 |
|
8148 |
|
8149 |
|
8150 |
|
8151 |
|
8152 |
|
8153 |
|
8154 |
|
8155 |
|
8156 |
|
8157 | function bridgeObject(referenceObject) {
|
8158 | if (referenceObject === null || _typeof(referenceObject) !== "object") {
|
8159 | return null;
|
8160 | }
|
8161 |
|
8162 | if (referenceObject instanceof Element) {
|
8163 |
|
8164 | return referenceObject;
|
8165 | }
|
8166 |
|
8167 | var objectTo = Object.create(referenceObject);
|
8168 |
|
8169 | for (var i in referenceObject) {
|
8170 | if (Object.prototype.hasOwnProperty.call(referenceObject, i)) {
|
8171 | if (_typeof(referenceObject[i]) == "object") {
|
8172 | objectTo[i] = bridgeObject(referenceObject[i]);
|
8173 | }
|
8174 | }
|
8175 | }
|
8176 |
|
8177 | return objectTo;
|
8178 | }
|
8179 |
|
8180 |
|
8181 |
|
8182 |
|
8183 |
|
8184 |
|
8185 |
|
8186 |
|
8187 |
|
8188 |
|
8189 | function insertSort(a, compare) {
|
8190 | for (var i = 0; i < a.length; i++) {
|
8191 | var k = a[i];
|
8192 | var j = void 0;
|
8193 |
|
8194 | for (j = i; j > 0 && compare(k, a[j - 1]) < 0; j--) {
|
8195 | a[j] = a[j - 1];
|
8196 | }
|
8197 |
|
8198 | a[j] = k;
|
8199 | }
|
8200 |
|
8201 | return a;
|
8202 | }
|
8203 |
|
8204 |
|
8205 |
|
8206 |
|
8207 |
|
8208 |
|
8209 |
|
8210 |
|
8211 |
|
8212 |
|
8213 |
|
8214 |
|
8215 |
|
8216 |
|
8217 |
|
8218 | function mergeOptions(mergeTarget, options, option) {
|
8219 | var globalOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
8220 |
|
8221 | var isPresent = function isPresent(obj) {
|
8222 | return obj !== null && obj !== undefined;
|
8223 | };
|
8224 |
|
8225 | var isObject = function isObject(obj) {
|
8226 | return obj !== null && _typeof(obj) === "object";
|
8227 | };
|
8228 |
|
8229 |
|
8230 | var isEmpty = function isEmpty(obj) {
|
8231 | for (var x in obj) {
|
8232 | if (Object.prototype.hasOwnProperty.call(obj, x)) {
|
8233 | return false;
|
8234 | }
|
8235 | }
|
8236 |
|
8237 | return true;
|
8238 | };
|
8239 |
|
8240 |
|
8241 | if (!isObject(mergeTarget)) {
|
8242 | throw new Error("Parameter mergeTarget must be an object");
|
8243 | }
|
8244 |
|
8245 | if (!isObject(options)) {
|
8246 | throw new Error("Parameter options must be an object");
|
8247 | }
|
8248 |
|
8249 | if (!isPresent(option)) {
|
8250 | throw new Error("Parameter option must have a value");
|
8251 | }
|
8252 |
|
8253 | if (!isObject(globalOptions)) {
|
8254 | throw new Error("Parameter globalOptions must be an object");
|
8255 | }
|
8256 |
|
8257 |
|
8258 |
|
8259 |
|
8260 |
|
8261 | var doMerge = function doMerge(target, options, option) {
|
8262 | if (!isObject(target[option])) {
|
8263 | target[option] = {};
|
8264 | }
|
8265 |
|
8266 | var src = options[option];
|
8267 | var dst = target[option];
|
8268 |
|
8269 | for (var prop in src) {
|
8270 | if (Object.prototype.hasOwnProperty.call(src, prop)) {
|
8271 | dst[prop] = src[prop];
|
8272 | }
|
8273 | }
|
8274 | };
|
8275 |
|
8276 |
|
8277 | var srcOption = options[option];
|
8278 | var globalPassed = isObject(globalOptions) && !isEmpty(globalOptions);
|
8279 | var globalOption = globalPassed ? globalOptions[option] : undefined;
|
8280 | var globalEnabled = globalOption ? globalOption.enabled : undefined;
|
8281 |
|
8282 |
|
8283 |
|
8284 | if (srcOption === undefined) {
|
8285 | return;
|
8286 | }
|
8287 |
|
8288 | if (typeof srcOption === "boolean") {
|
8289 | if (!isObject(mergeTarget[option])) {
|
8290 | mergeTarget[option] = {};
|
8291 | }
|
8292 |
|
8293 | mergeTarget[option].enabled = srcOption;
|
8294 | return;
|
8295 | }
|
8296 |
|
8297 | if (srcOption === null && !isObject(mergeTarget[option])) {
|
8298 |
|
8299 | if (isPresent(globalOption)) {
|
8300 | mergeTarget[option] = Object.create(globalOption);
|
8301 | } else {
|
8302 | return;
|
8303 | }
|
8304 | }
|
8305 |
|
8306 | if (!isObject(srcOption)) {
|
8307 | return;
|
8308 | }
|
8309 |
|
8310 |
|
8311 |
|
8312 |
|
8313 |
|
8314 | var enabled = true;
|
8315 |
|
8316 | if (srcOption.enabled !== undefined) {
|
8317 | enabled = srcOption.enabled;
|
8318 | } else {
|
8319 |
|
8320 | if (globalEnabled !== undefined) {
|
8321 | enabled = globalOption.enabled;
|
8322 | }
|
8323 | }
|
8324 |
|
8325 | doMerge(mergeTarget, options, option);
|
8326 | mergeTarget[option].enabled = enabled;
|
8327 | }
|
8328 |
|
8329 |
|
8330 |
|
8331 |
|
8332 |
|
8333 |
|
8334 |
|
8335 |
|
8336 |
|
8337 |
|
8338 |
|
8339 |
|
8340 |
|
8341 | function binarySearchCustom(orderedItems, comparator, field, field2) {
|
8342 | var maxIterations = 10000;
|
8343 | var iteration = 0;
|
8344 | var low = 0;
|
8345 | var high = orderedItems.length - 1;
|
8346 |
|
8347 | while (low <= high && iteration < maxIterations) {
|
8348 | var middle = Math.floor((low + high) / 2);
|
8349 | var item = orderedItems[middle];
|
8350 |
|
8351 | var _value3 = field2 === undefined ? item[field] : item[field][field2];
|
8352 |
|
8353 | var searchResult = comparator(_value3);
|
8354 |
|
8355 | if (searchResult == 0) {
|
8356 |
|
8357 | return middle;
|
8358 | } else if (searchResult == -1) {
|
8359 |
|
8360 | low = middle + 1;
|
8361 | } else {
|
8362 |
|
8363 | high = middle - 1;
|
8364 | }
|
8365 |
|
8366 | iteration++;
|
8367 | }
|
8368 |
|
8369 | return -1;
|
8370 | }
|
8371 |
|
8372 |
|
8373 |
|
8374 |
|
8375 |
|
8376 |
|
8377 |
|
8378 |
|
8379 |
|
8380 |
|
8381 |
|
8382 |
|
8383 |
|
8384 |
|
8385 |
|
8386 | function binarySearchValue(orderedItems, target, field, sidePreference, comparator) {
|
8387 | var maxIterations = 10000;
|
8388 | var iteration = 0;
|
8389 | var low = 0;
|
8390 | var high = orderedItems.length - 1;
|
8391 | var prevValue;
|
8392 | var value;
|
8393 | var nextValue;
|
8394 | var middle;
|
8395 | comparator = comparator != undefined ? comparator : function (a, b) {
|
8396 | return a == b ? 0 : a < b ? -1 : 1;
|
8397 | };
|
8398 |
|
8399 | while (low <= high && iteration < maxIterations) {
|
8400 |
|
8401 | middle = Math.floor(0.5 * (high + low));
|
8402 | prevValue = orderedItems[Math.max(0, middle - 1)][field];
|
8403 | value = orderedItems[middle][field];
|
8404 | nextValue = orderedItems[Math.min(orderedItems.length - 1, middle + 1)][field];
|
8405 |
|
8406 | if (comparator(value, target) == 0) {
|
8407 |
|
8408 | return middle;
|
8409 | } else if (comparator(prevValue, target) < 0 && comparator(value, target) > 0) {
|
8410 |
|
8411 | return sidePreference == "before" ? Math.max(0, middle - 1) : middle;
|
8412 | } else if (comparator(value, target) < 0 && comparator(nextValue, target) > 0) {
|
8413 |
|
8414 | return sidePreference == "before" ? middle : Math.min(orderedItems.length - 1, middle + 1);
|
8415 | } else {
|
8416 |
|
8417 | if (comparator(value, target) < 0) {
|
8418 |
|
8419 | low = middle + 1;
|
8420 | } else {
|
8421 |
|
8422 | high = middle - 1;
|
8423 | }
|
8424 | }
|
8425 |
|
8426 | iteration++;
|
8427 | }
|
8428 |
|
8429 |
|
8430 | return -1;
|
8431 | }
|
8432 |
|
8433 |
|
8434 |
|
8435 |
|
8436 |
|
8437 |
|
8438 |
|
8439 |
|
8440 |
|
8441 | var easingFunctions = {
|
8442 | |
8443 |
|
8444 |
|
8445 |
|
8446 |
|
8447 |
|
8448 |
|
8449 | linear: function linear(t) {
|
8450 | return t;
|
8451 | },
|
8452 |
|
8453 | |
8454 |
|
8455 |
|
8456 |
|
8457 |
|
8458 |
|
8459 |
|
8460 | easeInQuad: function easeInQuad(t) {
|
8461 | return t * t;
|
8462 | },
|
8463 |
|
8464 | |
8465 |
|
8466 |
|
8467 |
|
8468 |
|
8469 |
|
8470 |
|
8471 | easeOutQuad: function easeOutQuad(t) {
|
8472 | return t * (2 - t);
|
8473 | },
|
8474 |
|
8475 | |
8476 |
|
8477 |
|
8478 |
|
8479 |
|
8480 |
|
8481 |
|
8482 | easeInOutQuad: function easeInOutQuad(t) {
|
8483 | return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
8484 | },
|
8485 |
|
8486 | |
8487 |
|
8488 |
|
8489 |
|
8490 |
|
8491 |
|
8492 |
|
8493 | easeInCubic: function easeInCubic(t) {
|
8494 | return t * t * t;
|
8495 | },
|
8496 |
|
8497 | |
8498 |
|
8499 |
|
8500 |
|
8501 |
|
8502 |
|
8503 |
|
8504 | easeOutCubic: function easeOutCubic(t) {
|
8505 | return --t * t * t + 1;
|
8506 | },
|
8507 |
|
8508 | |
8509 |
|
8510 |
|
8511 |
|
8512 |
|
8513 |
|
8514 |
|
8515 | easeInOutCubic: function easeInOutCubic(t) {
|
8516 | return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
|
8517 | },
|
8518 |
|
8519 | |
8520 |
|
8521 |
|
8522 |
|
8523 |
|
8524 |
|
8525 |
|
8526 | easeInQuart: function easeInQuart(t) {
|
8527 | return t * t * t * t;
|
8528 | },
|
8529 |
|
8530 | |
8531 |
|
8532 |
|
8533 |
|
8534 |
|
8535 |
|
8536 |
|
8537 | easeOutQuart: function easeOutQuart(t) {
|
8538 | return 1 - --t * t * t * t;
|
8539 | },
|
8540 |
|
8541 | |
8542 |
|
8543 |
|
8544 |
|
8545 |
|
8546 |
|
8547 |
|
8548 | easeInOutQuart: function easeInOutQuart(t) {
|
8549 | return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t;
|
8550 | },
|
8551 |
|
8552 | |
8553 |
|
8554 |
|
8555 |
|
8556 |
|
8557 |
|
8558 |
|
8559 | easeInQuint: function easeInQuint(t) {
|
8560 | return t * t * t * t * t;
|
8561 | },
|
8562 |
|
8563 | |
8564 |
|
8565 |
|
8566 |
|
8567 |
|
8568 |
|
8569 |
|
8570 | easeOutQuint: function easeOutQuint(t) {
|
8571 | return 1 + --t * t * t * t * t;
|
8572 | },
|
8573 |
|
8574 | |
8575 |
|
8576 |
|
8577 |
|
8578 |
|
8579 |
|
8580 |
|
8581 | easeInOutQuint: function easeInOutQuint(t) {
|
8582 | return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t;
|
8583 | }
|
8584 | };
|
8585 |
|
8586 |
|
8587 |
|
8588 |
|
8589 |
|
8590 |
|
8591 | function getScrollBarWidth() {
|
8592 | var inner = document.createElement("p");
|
8593 | inner.style.width = "100%";
|
8594 | inner.style.height = "200px";
|
8595 | var outer = document.createElement("div");
|
8596 | outer.style.position = "absolute";
|
8597 | outer.style.top = "0px";
|
8598 | outer.style.left = "0px";
|
8599 | outer.style.visibility = "hidden";
|
8600 | outer.style.width = "200px";
|
8601 | outer.style.height = "150px";
|
8602 | outer.style.overflow = "hidden";
|
8603 | outer.appendChild(inner);
|
8604 | document.body.appendChild(outer);
|
8605 | var w1 = inner.offsetWidth;
|
8606 | outer.style.overflow = "scroll";
|
8607 | var w2 = inner.offsetWidth;
|
8608 |
|
8609 | if (w1 == w2) {
|
8610 | w2 = outer.clientWidth;
|
8611 | }
|
8612 |
|
8613 | document.body.removeChild(outer);
|
8614 | return w1 - w2;
|
8615 | }
|
8616 |
|
8617 |
|
8618 |
|
8619 |
|
8620 |
|
8621 |
|
8622 |
|
8623 |
|
8624 |
|
8625 |
|
8626 |
|
8627 |
|
8628 |
|
8629 |
|
8630 |
|
8631 |
|
8632 |
|
8633 |
|
8634 |
|
8635 |
|
8636 |
|
8637 |
|
8638 |
|
8639 |
|
8640 |
|
8641 | function topMost(pile, accessors) {
|
8642 | var candidate;
|
8643 |
|
8644 | if (!Array.isArray(accessors)) {
|
8645 | accessors = [accessors];
|
8646 | }
|
8647 |
|
8648 | var _iteratorNormalCompletion = true;
|
8649 | var _didIteratorError = false;
|
8650 | var _iteratorError = undefined;
|
8651 |
|
8652 | try {
|
8653 | for (var _iterator = pile[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
8654 | var member = _step.value;
|
8655 |
|
8656 | if (member) {
|
8657 | candidate = member[accessors[0]];
|
8658 |
|
8659 | for (var i = 1; i < accessors.length; i++) {
|
8660 | if (candidate) {
|
8661 | candidate = candidate[accessors[i]];
|
8662 | }
|
8663 | }
|
8664 |
|
8665 | if (typeof candidate !== "undefined") {
|
8666 | break;
|
8667 | }
|
8668 | }
|
8669 | }
|
8670 | } catch (err) {
|
8671 | _didIteratorError = true;
|
8672 | _iteratorError = err;
|
8673 | } finally {
|
8674 | try {
|
8675 | if (!_iteratorNormalCompletion && _iterator.return != null) {
|
8676 | _iterator.return();
|
8677 | }
|
8678 | } finally {
|
8679 | if (_didIteratorError) {
|
8680 | throw _iteratorError;
|
8681 | }
|
8682 | }
|
8683 | }
|
8684 |
|
8685 | return candidate;
|
8686 | }
|
8687 |
|
8688 | var util =
|
8689 |
|
8690 | Object.freeze({
|
8691 | isNumber: isNumber,
|
8692 | recursiveDOMDelete: recursiveDOMDelete,
|
8693 | isString: isString,
|
8694 | isObject: isObject,
|
8695 | isDate: isDate,
|
8696 | isMoment: isMoment,
|
8697 | fillIfDefined: fillIfDefined,
|
8698 | extend: extend,
|
8699 | selectiveExtend: selectiveExtend,
|
8700 | selectiveDeepExtend: selectiveDeepExtend,
|
8701 | selectiveNotDeepExtend: selectiveNotDeepExtend,
|
8702 | deepExtend: deepExtend,
|
8703 | equalArray: equalArray,
|
8704 | convert: convert,
|
8705 | getType: getType,
|
8706 | copyAndExtendArray: copyAndExtendArray,
|
8707 | copyArray: copyArray,
|
8708 | getAbsoluteLeft: getAbsoluteLeft,
|
8709 | getAbsoluteRight: getAbsoluteRight,
|
8710 | getAbsoluteTop: getAbsoluteTop,
|
8711 | addClassName: addClassName,
|
8712 | removeClassName: removeClassName,
|
8713 | forEach: forEach,
|
8714 | toArray: toArray,
|
8715 | updateProperty: updateProperty,
|
8716 | throttle: throttle,
|
8717 | addEventListener: addEventListener,
|
8718 | removeEventListener: removeEventListener,
|
8719 | preventDefault: preventDefault,
|
8720 | getTarget: getTarget,
|
8721 | hasParent: hasParent,
|
8722 | option: option,
|
8723 | hexToRGB: hexToRGB,
|
8724 | overrideOpacity: overrideOpacity,
|
8725 | RGBToHex: RGBToHex,
|
8726 | parseColor: parseColor,
|
8727 | RGBToHSV: RGBToHSV,
|
8728 | addCssText: addCssText,
|
8729 | removeCssText: removeCssText,
|
8730 | HSVToRGB: HSVToRGB,
|
8731 | HSVToHex: HSVToHex,
|
8732 | hexToHSV: hexToHSV,
|
8733 | isValidHex: isValidHex,
|
8734 | isValidRGB: isValidRGB,
|
8735 | isValidRGBA: isValidRGBA,
|
8736 | selectiveBridgeObject: selectiveBridgeObject,
|
8737 | bridgeObject: bridgeObject,
|
8738 | insertSort: insertSort,
|
8739 | mergeOptions: mergeOptions,
|
8740 | binarySearchCustom: binarySearchCustom,
|
8741 | binarySearchValue: binarySearchValue,
|
8742 | easingFunctions: easingFunctions,
|
8743 | getScrollBarWidth: getScrollBarWidth,
|
8744 | topMost: topMost,
|
8745 | randomUUID: uuid4
|
8746 | });
|
8747 |
|
8748 | var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
8749 |
|
8750 | function commonjsRequire$1 () {
|
8751 | throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
|
8752 | }
|
8753 |
|
8754 | function createCommonjsModule$1(fn, module) {
|
8755 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
8756 | }
|
8757 |
|
8758 | var DOMutil = createCommonjsModule$1(function (module, exports) {
|
8759 |
|
8760 |
|
8761 | |
8762 |
|
8763 |
|
8764 |
|
8765 |
|
8766 | exports.prepareElements = function (JSONcontainer) {
|
8767 |
|
8768 | for (var elementType in JSONcontainer) {
|
8769 | if (JSONcontainer.hasOwnProperty(elementType)) {
|
8770 | JSONcontainer[elementType].redundant = JSONcontainer[elementType].used;
|
8771 | JSONcontainer[elementType].used = [];
|
8772 | }
|
8773 | }
|
8774 | };
|
8775 | |
8776 |
|
8777 |
|
8778 |
|
8779 |
|
8780 |
|
8781 |
|
8782 |
|
8783 |
|
8784 | exports.cleanupElements = function (JSONcontainer) {
|
8785 |
|
8786 | for (var elementType in JSONcontainer) {
|
8787 | if (JSONcontainer.hasOwnProperty(elementType)) {
|
8788 | if (JSONcontainer[elementType].redundant) {
|
8789 | for (var i = 0; i < JSONcontainer[elementType].redundant.length; i++) {
|
8790 | JSONcontainer[elementType].redundant[i].parentNode.removeChild(JSONcontainer[elementType].redundant[i]);
|
8791 | }
|
8792 |
|
8793 | JSONcontainer[elementType].redundant = [];
|
8794 | }
|
8795 | }
|
8796 | }
|
8797 | };
|
8798 | |
8799 |
|
8800 |
|
8801 |
|
8802 |
|
8803 |
|
8804 | exports.resetElements = function (JSONcontainer) {
|
8805 | exports.prepareElements(JSONcontainer);
|
8806 | exports.cleanupElements(JSONcontainer);
|
8807 | exports.prepareElements(JSONcontainer);
|
8808 | };
|
8809 | |
8810 |
|
8811 |
|
8812 |
|
8813 |
|
8814 |
|
8815 |
|
8816 |
|
8817 |
|
8818 |
|
8819 |
|
8820 |
|
8821 | exports.getSVGElement = function (elementType, JSONcontainer, svgContainer) {
|
8822 | var element;
|
8823 |
|
8824 | if (JSONcontainer.hasOwnProperty(elementType)) {
|
8825 |
|
8826 |
|
8827 | if (JSONcontainer[elementType].redundant.length > 0) {
|
8828 | element = JSONcontainer[elementType].redundant[0];
|
8829 | JSONcontainer[elementType].redundant.shift();
|
8830 | } else {
|
8831 |
|
8832 | element = document.createElementNS('http://www.w3.org/2000/svg', elementType);
|
8833 | svgContainer.appendChild(element);
|
8834 | }
|
8835 | } else {
|
8836 |
|
8837 | element = document.createElementNS('http://www.w3.org/2000/svg', elementType);
|
8838 | JSONcontainer[elementType] = {
|
8839 | used: [],
|
8840 | redundant: []
|
8841 | };
|
8842 | svgContainer.appendChild(element);
|
8843 | }
|
8844 |
|
8845 | JSONcontainer[elementType].used.push(element);
|
8846 | return element;
|
8847 | };
|
8848 | |
8849 |
|
8850 |
|
8851 |
|
8852 |
|
8853 |
|
8854 |
|
8855 |
|
8856 |
|
8857 |
|
8858 |
|
8859 |
|
8860 | exports.getDOMElement = function (elementType, JSONcontainer, DOMContainer, insertBefore) {
|
8861 | var element;
|
8862 |
|
8863 | if (JSONcontainer.hasOwnProperty(elementType)) {
|
8864 |
|
8865 |
|
8866 | if (JSONcontainer[elementType].redundant.length > 0) {
|
8867 | element = JSONcontainer[elementType].redundant[0];
|
8868 | JSONcontainer[elementType].redundant.shift();
|
8869 | } else {
|
8870 |
|
8871 | element = document.createElement(elementType);
|
8872 |
|
8873 | if (insertBefore !== undefined) {
|
8874 | DOMContainer.insertBefore(element, insertBefore);
|
8875 | } else {
|
8876 | DOMContainer.appendChild(element);
|
8877 | }
|
8878 | }
|
8879 | } else {
|
8880 |
|
8881 | element = document.createElement(elementType);
|
8882 | JSONcontainer[elementType] = {
|
8883 | used: [],
|
8884 | redundant: []
|
8885 | };
|
8886 |
|
8887 | if (insertBefore !== undefined) {
|
8888 | DOMContainer.insertBefore(element, insertBefore);
|
8889 | } else {
|
8890 | DOMContainer.appendChild(element);
|
8891 | }
|
8892 | }
|
8893 |
|
8894 | JSONcontainer[elementType].used.push(element);
|
8895 | return element;
|
8896 | };
|
8897 | |
8898 |
|
8899 |
|
8900 |
|
8901 |
|
8902 |
|
8903 |
|
8904 |
|
8905 |
|
8906 |
|
8907 |
|
8908 |
|
8909 |
|
8910 |
|
8911 |
|
8912 | exports.drawPoint = function (x, y, groupTemplate, JSONcontainer, svgContainer, labelObj) {
|
8913 | var point;
|
8914 |
|
8915 | if (groupTemplate.style == 'circle') {
|
8916 | point = exports.getSVGElement('circle', JSONcontainer, svgContainer);
|
8917 | point.setAttributeNS(null, "cx", x);
|
8918 | point.setAttributeNS(null, "cy", y);
|
8919 | point.setAttributeNS(null, "r", 0.5 * groupTemplate.size);
|
8920 | } else {
|
8921 | point = exports.getSVGElement('rect', JSONcontainer, svgContainer);
|
8922 | point.setAttributeNS(null, "x", x - 0.5 * groupTemplate.size);
|
8923 | point.setAttributeNS(null, "y", y - 0.5 * groupTemplate.size);
|
8924 | point.setAttributeNS(null, "width", groupTemplate.size);
|
8925 | point.setAttributeNS(null, "height", groupTemplate.size);
|
8926 | }
|
8927 |
|
8928 | if (groupTemplate.styles !== undefined) {
|
8929 | point.setAttributeNS(null, "style", groupTemplate.styles);
|
8930 | }
|
8931 |
|
8932 | point.setAttributeNS(null, "class", groupTemplate.className + " vis-point");
|
8933 |
|
8934 | if (labelObj) {
|
8935 | var label = exports.getSVGElement('text', JSONcontainer, svgContainer);
|
8936 |
|
8937 | if (labelObj.xOffset) {
|
8938 | x = x + labelObj.xOffset;
|
8939 | }
|
8940 |
|
8941 | if (labelObj.yOffset) {
|
8942 | y = y + labelObj.yOffset;
|
8943 | }
|
8944 |
|
8945 | if (labelObj.content) {
|
8946 | label.textContent = labelObj.content;
|
8947 | }
|
8948 |
|
8949 | if (labelObj.className) {
|
8950 | label.setAttributeNS(null, "class", labelObj.className + " vis-label");
|
8951 | }
|
8952 |
|
8953 | label.setAttributeNS(null, "x", x);
|
8954 | label.setAttributeNS(null, "y", y);
|
8955 | }
|
8956 |
|
8957 | return point;
|
8958 | };
|
8959 | |
8960 |
|
8961 |
|
8962 |
|
8963 |
|
8964 |
|
8965 |
|
8966 |
|
8967 |
|
8968 |
|
8969 |
|
8970 |
|
8971 |
|
8972 |
|
8973 | exports.drawBar = function (x, y, width, height, className, JSONcontainer, svgContainer, style) {
|
8974 | if (height != 0) {
|
8975 | if (height < 0) {
|
8976 | height *= -1;
|
8977 | y -= height;
|
8978 | }
|
8979 |
|
8980 | var rect = exports.getSVGElement('rect', JSONcontainer, svgContainer);
|
8981 | rect.setAttributeNS(null, "x", x - 0.5 * width);
|
8982 | rect.setAttributeNS(null, "y", y);
|
8983 | rect.setAttributeNS(null, "width", width);
|
8984 | rect.setAttributeNS(null, "height", height);
|
8985 | rect.setAttributeNS(null, "class", className);
|
8986 |
|
8987 | if (style) {
|
8988 | rect.setAttributeNS(null, "style", style);
|
8989 | }
|
8990 | }
|
8991 | };
|
8992 | });
|
8993 | var DOMutil_1 = DOMutil.prepareElements;
|
8994 | var DOMutil_2 = DOMutil.cleanupElements;
|
8995 | var DOMutil_3 = DOMutil.resetElements;
|
8996 | var DOMutil_4 = DOMutil.getSVGElement;
|
8997 | var DOMutil_5 = DOMutil.getDOMElement;
|
8998 | var DOMutil_6 = DOMutil.drawPoint;
|
8999 | var DOMutil_7 = DOMutil.drawBar;
|
9000 |
|
9001 |
|
9002 |
|
9003 |
|
9004 |
|
9005 |
|
9006 |
|
9007 |
|
9008 |
|
9009 |
|
9010 |
|
9011 |
|
9012 |
|
9013 |
|
9014 |
|
9015 |
|
9016 |
|
9017 |
|
9018 |
|
9019 |
|
9020 |
|
9021 |
|
9022 |
|
9023 |
|
9024 |
|
9025 |
|
9026 | function createCommonjsModule$2(fn, module) {
|
9027 | return module = {
|
9028 | exports: {}
|
9029 | }, fn(module, module.exports), module.exports;
|
9030 | }
|
9031 |
|
9032 | var runtime_1 = createCommonjsModule$2(function (module) {
|
9033 | |
9034 |
|
9035 |
|
9036 |
|
9037 |
|
9038 |
|
9039 | var runtime = function (exports) {
|
9040 | var Op = Object.prototype;
|
9041 | var hasOwn = Op.hasOwnProperty;
|
9042 | var undefined$1;
|
9043 |
|
9044 | var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
9045 | var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
9046 | var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
9047 | var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
9048 |
|
9049 | function wrap(innerFn, outerFn, self, tryLocsList) {
|
9050 |
|
9051 | var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
9052 | var generator = Object.create(protoGenerator.prototype);
|
9053 | var context = new Context(tryLocsList || []);
|
9054 |
|
9055 |
|
9056 | generator._invoke = makeInvokeMethod(innerFn, self, context);
|
9057 | return generator;
|
9058 | }
|
9059 |
|
9060 | exports.wrap = wrap;
|
9061 |
|
9062 |
|
9063 |
|
9064 |
|
9065 |
|
9066 |
|
9067 |
|
9068 |
|
9069 |
|
9070 |
|
9071 | function tryCatch(fn, obj, arg) {
|
9072 | try {
|
9073 | return {
|
9074 | type: "normal",
|
9075 | arg: fn.call(obj, arg)
|
9076 | };
|
9077 | } catch (err) {
|
9078 | return {
|
9079 | type: "throw",
|
9080 | arg: err
|
9081 | };
|
9082 | }
|
9083 | }
|
9084 |
|
9085 | var GenStateSuspendedStart = "suspendedStart";
|
9086 | var GenStateSuspendedYield = "suspendedYield";
|
9087 | var GenStateExecuting = "executing";
|
9088 | var GenStateCompleted = "completed";
|
9089 |
|
9090 |
|
9091 | var ContinueSentinel = {};
|
9092 |
|
9093 |
|
9094 |
|
9095 |
|
9096 | function Generator() {}
|
9097 |
|
9098 | function GeneratorFunction() {}
|
9099 |
|
9100 | function GeneratorFunctionPrototype() {}
|
9101 |
|
9102 |
|
9103 |
|
9104 | var IteratorPrototype = {};
|
9105 |
|
9106 | IteratorPrototype[iteratorSymbol] = function () {
|
9107 | return this;
|
9108 | };
|
9109 |
|
9110 | var getProto = Object.getPrototypeOf;
|
9111 | var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
9112 |
|
9113 | if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
9114 |
|
9115 |
|
9116 | IteratorPrototype = NativeIteratorPrototype;
|
9117 | }
|
9118 |
|
9119 | var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
9120 | GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
9121 | GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
9122 | GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
|
9123 |
|
9124 |
|
9125 | function defineIteratorMethods(prototype) {
|
9126 | ["next", "throw", "return"].forEach(function (method) {
|
9127 | prototype[method] = function (arg) {
|
9128 | return this._invoke(method, arg);
|
9129 | };
|
9130 | });
|
9131 | }
|
9132 |
|
9133 | exports.isGeneratorFunction = function (genFun) {
|
9134 | var ctor = typeof genFun === "function" && genFun.constructor;
|
9135 | return ctor ? ctor === GeneratorFunction ||
|
9136 |
|
9137 | (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
9138 | };
|
9139 |
|
9140 | exports.mark = function (genFun) {
|
9141 | if (Object.setPrototypeOf) {
|
9142 | Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
9143 | } else {
|
9144 | genFun.__proto__ = GeneratorFunctionPrototype;
|
9145 |
|
9146 | if (!(toStringTagSymbol in genFun)) {
|
9147 | genFun[toStringTagSymbol] = "GeneratorFunction";
|
9148 | }
|
9149 | }
|
9150 |
|
9151 | genFun.prototype = Object.create(Gp);
|
9152 | return genFun;
|
9153 | };
|
9154 |
|
9155 |
|
9156 |
|
9157 |
|
9158 |
|
9159 | exports.awrap = function (arg) {
|
9160 | return {
|
9161 | __await: arg
|
9162 | };
|
9163 | };
|
9164 |
|
9165 | function AsyncIterator(generator) {
|
9166 | function invoke(method, arg, resolve, reject) {
|
9167 | var record = tryCatch(generator[method], generator, arg);
|
9168 |
|
9169 | if (record.type === "throw") {
|
9170 | reject(record.arg);
|
9171 | } else {
|
9172 | var result = record.arg;
|
9173 | var value = result.value;
|
9174 |
|
9175 | if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
9176 | return Promise.resolve(value.__await).then(function (value) {
|
9177 | invoke("next", value, resolve, reject);
|
9178 | }, function (err) {
|
9179 | invoke("throw", err, resolve, reject);
|
9180 | });
|
9181 | }
|
9182 |
|
9183 | return Promise.resolve(value).then(function (unwrapped) {
|
9184 |
|
9185 |
|
9186 |
|
9187 | result.value = unwrapped;
|
9188 | resolve(result);
|
9189 | }, function (error) {
|
9190 |
|
9191 |
|
9192 | return invoke("throw", error, resolve, reject);
|
9193 | });
|
9194 | }
|
9195 | }
|
9196 |
|
9197 | var previousPromise;
|
9198 |
|
9199 | function enqueue(method, arg) {
|
9200 | function callInvokeWithMethodAndArg() {
|
9201 | return new Promise(function (resolve, reject) {
|
9202 | invoke(method, arg, resolve, reject);
|
9203 | });
|
9204 | }
|
9205 |
|
9206 | return previousPromise =
|
9207 |
|
9208 |
|
9209 |
|
9210 |
|
9211 |
|
9212 |
|
9213 |
|
9214 |
|
9215 |
|
9216 |
|
9217 |
|
9218 | previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
9219 |
|
9220 | callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
9221 | }
|
9222 |
|
9223 |
|
9224 |
|
9225 | this._invoke = enqueue;
|
9226 | }
|
9227 |
|
9228 | defineIteratorMethods(AsyncIterator.prototype);
|
9229 |
|
9230 | AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
9231 | return this;
|
9232 | };
|
9233 |
|
9234 | exports.AsyncIterator = AsyncIterator;
|
9235 |
|
9236 |
|
9237 |
|
9238 | exports.async = function (innerFn, outerFn, self, tryLocsList) {
|
9239 | var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
|
9240 | return exports.isGeneratorFunction(outerFn) ? iter
|
9241 | : iter.next().then(function (result) {
|
9242 | return result.done ? result.value : iter.next();
|
9243 | });
|
9244 | };
|
9245 |
|
9246 | function makeInvokeMethod(innerFn, self, context) {
|
9247 | var state = GenStateSuspendedStart;
|
9248 | return function invoke(method, arg) {
|
9249 | if (state === GenStateExecuting) {
|
9250 | throw new Error("Generator is already running");
|
9251 | }
|
9252 |
|
9253 | if (state === GenStateCompleted) {
|
9254 | if (method === "throw") {
|
9255 | throw arg;
|
9256 | }
|
9257 |
|
9258 |
|
9259 |
|
9260 | return doneResult();
|
9261 | }
|
9262 |
|
9263 | context.method = method;
|
9264 | context.arg = arg;
|
9265 |
|
9266 | while (true) {
|
9267 | var delegate = context.delegate;
|
9268 |
|
9269 | if (delegate) {
|
9270 | var delegateResult = maybeInvokeDelegate(delegate, context);
|
9271 |
|
9272 | if (delegateResult) {
|
9273 | if (delegateResult === ContinueSentinel) continue;
|
9274 | return delegateResult;
|
9275 | }
|
9276 | }
|
9277 |
|
9278 | if (context.method === "next") {
|
9279 |
|
9280 |
|
9281 | context.sent = context._sent = context.arg;
|
9282 | } else if (context.method === "throw") {
|
9283 | if (state === GenStateSuspendedStart) {
|
9284 | state = GenStateCompleted;
|
9285 | throw context.arg;
|
9286 | }
|
9287 |
|
9288 | context.dispatchException(context.arg);
|
9289 | } else if (context.method === "return") {
|
9290 | context.abrupt("return", context.arg);
|
9291 | }
|
9292 |
|
9293 | state = GenStateExecuting;
|
9294 | var record = tryCatch(innerFn, self, context);
|
9295 |
|
9296 | if (record.type === "normal") {
|
9297 |
|
9298 |
|
9299 | state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
9300 |
|
9301 | if (record.arg === ContinueSentinel) {
|
9302 | continue;
|
9303 | }
|
9304 |
|
9305 | return {
|
9306 | value: record.arg,
|
9307 | done: context.done
|
9308 | };
|
9309 | } else if (record.type === "throw") {
|
9310 | state = GenStateCompleted;
|
9311 |
|
9312 |
|
9313 | context.method = "throw";
|
9314 | context.arg = record.arg;
|
9315 | }
|
9316 | }
|
9317 | };
|
9318 | }
|
9319 |
|
9320 |
|
9321 |
|
9322 |
|
9323 |
|
9324 | function maybeInvokeDelegate(delegate, context) {
|
9325 | var method = delegate.iterator[context.method];
|
9326 |
|
9327 | if (method === undefined$1) {
|
9328 |
|
9329 |
|
9330 | context.delegate = null;
|
9331 |
|
9332 | if (context.method === "throw") {
|
9333 |
|
9334 | if (delegate.iterator["return"]) {
|
9335 |
|
9336 |
|
9337 | context.method = "return";
|
9338 | context.arg = undefined$1;
|
9339 | maybeInvokeDelegate(delegate, context);
|
9340 |
|
9341 | if (context.method === "throw") {
|
9342 |
|
9343 |
|
9344 | return ContinueSentinel;
|
9345 | }
|
9346 | }
|
9347 |
|
9348 | context.method = "throw";
|
9349 | context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
9350 | }
|
9351 |
|
9352 | return ContinueSentinel;
|
9353 | }
|
9354 |
|
9355 | var record = tryCatch(method, delegate.iterator, context.arg);
|
9356 |
|
9357 | if (record.type === "throw") {
|
9358 | context.method = "throw";
|
9359 | context.arg = record.arg;
|
9360 | context.delegate = null;
|
9361 | return ContinueSentinel;
|
9362 | }
|
9363 |
|
9364 | var info = record.arg;
|
9365 |
|
9366 | if (!info) {
|
9367 | context.method = "throw";
|
9368 | context.arg = new TypeError("iterator result is not an object");
|
9369 | context.delegate = null;
|
9370 | return ContinueSentinel;
|
9371 | }
|
9372 |
|
9373 | if (info.done) {
|
9374 |
|
9375 |
|
9376 | context[delegate.resultName] = info.value;
|
9377 |
|
9378 | context.next = delegate.nextLoc;
|
9379 |
|
9380 |
|
9381 |
|
9382 |
|
9383 |
|
9384 |
|
9385 | if (context.method !== "return") {
|
9386 | context.method = "next";
|
9387 | context.arg = undefined$1;
|
9388 | }
|
9389 | } else {
|
9390 |
|
9391 | return info;
|
9392 | }
|
9393 |
|
9394 |
|
9395 |
|
9396 | context.delegate = null;
|
9397 | return ContinueSentinel;
|
9398 | }
|
9399 |
|
9400 |
|
9401 |
|
9402 | defineIteratorMethods(Gp);
|
9403 | Gp[toStringTagSymbol] = "Generator";
|
9404 |
|
9405 |
|
9406 |
|
9407 |
|
9408 |
|
9409 | Gp[iteratorSymbol] = function () {
|
9410 | return this;
|
9411 | };
|
9412 |
|
9413 | Gp.toString = function () {
|
9414 | return "[object Generator]";
|
9415 | };
|
9416 |
|
9417 | function pushTryEntry(locs) {
|
9418 | var entry = {
|
9419 | tryLoc: locs[0]
|
9420 | };
|
9421 |
|
9422 | if (1 in locs) {
|
9423 | entry.catchLoc = locs[1];
|
9424 | }
|
9425 |
|
9426 | if (2 in locs) {
|
9427 | entry.finallyLoc = locs[2];
|
9428 | entry.afterLoc = locs[3];
|
9429 | }
|
9430 |
|
9431 | this.tryEntries.push(entry);
|
9432 | }
|
9433 |
|
9434 | function resetTryEntry(entry) {
|
9435 | var record = entry.completion || {};
|
9436 | record.type = "normal";
|
9437 | delete record.arg;
|
9438 | entry.completion = record;
|
9439 | }
|
9440 |
|
9441 | function Context(tryLocsList) {
|
9442 |
|
9443 |
|
9444 |
|
9445 | this.tryEntries = [{
|
9446 | tryLoc: "root"
|
9447 | }];
|
9448 | tryLocsList.forEach(pushTryEntry, this);
|
9449 | this.reset(true);
|
9450 | }
|
9451 |
|
9452 | exports.keys = function (object) {
|
9453 | var keys = [];
|
9454 |
|
9455 | for (var key in object) {
|
9456 | keys.push(key);
|
9457 | }
|
9458 |
|
9459 | keys.reverse();
|
9460 |
|
9461 |
|
9462 | return function next() {
|
9463 | while (keys.length) {
|
9464 | var key = keys.pop();
|
9465 |
|
9466 | if (key in object) {
|
9467 | next.value = key;
|
9468 | next.done = false;
|
9469 | return next;
|
9470 | }
|
9471 | }
|
9472 |
|
9473 |
|
9474 |
|
9475 |
|
9476 | next.done = true;
|
9477 | return next;
|
9478 | };
|
9479 | };
|
9480 |
|
9481 | function values(iterable) {
|
9482 | if (iterable) {
|
9483 | var iteratorMethod = iterable[iteratorSymbol];
|
9484 |
|
9485 | if (iteratorMethod) {
|
9486 | return iteratorMethod.call(iterable);
|
9487 | }
|
9488 |
|
9489 | if (typeof iterable.next === "function") {
|
9490 | return iterable;
|
9491 | }
|
9492 |
|
9493 | if (!isNaN(iterable.length)) {
|
9494 | var i = -1,
|
9495 | next = function next() {
|
9496 | while (++i < iterable.length) {
|
9497 | if (hasOwn.call(iterable, i)) {
|
9498 | next.value = iterable[i];
|
9499 | next.done = false;
|
9500 | return next;
|
9501 | }
|
9502 | }
|
9503 |
|
9504 | next.value = undefined$1;
|
9505 | next.done = true;
|
9506 | return next;
|
9507 | };
|
9508 |
|
9509 | return next.next = next;
|
9510 | }
|
9511 | }
|
9512 |
|
9513 |
|
9514 | return {
|
9515 | next: doneResult
|
9516 | };
|
9517 | }
|
9518 |
|
9519 | exports.values = values;
|
9520 |
|
9521 | function doneResult() {
|
9522 | return {
|
9523 | value: undefined$1,
|
9524 | done: true
|
9525 | };
|
9526 | }
|
9527 |
|
9528 | Context.prototype = {
|
9529 | constructor: Context,
|
9530 | reset: function (skipTempReset) {
|
9531 | this.prev = 0;
|
9532 | this.next = 0;
|
9533 |
|
9534 |
|
9535 | this.sent = this._sent = undefined$1;
|
9536 | this.done = false;
|
9537 | this.delegate = null;
|
9538 | this.method = "next";
|
9539 | this.arg = undefined$1;
|
9540 | this.tryEntries.forEach(resetTryEntry);
|
9541 |
|
9542 | if (!skipTempReset) {
|
9543 | for (var name in this) {
|
9544 |
|
9545 | if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
9546 | this[name] = undefined$1;
|
9547 | }
|
9548 | }
|
9549 | }
|
9550 | },
|
9551 | stop: function () {
|
9552 | this.done = true;
|
9553 | var rootEntry = this.tryEntries[0];
|
9554 | var rootRecord = rootEntry.completion;
|
9555 |
|
9556 | if (rootRecord.type === "throw") {
|
9557 | throw rootRecord.arg;
|
9558 | }
|
9559 |
|
9560 | return this.rval;
|
9561 | },
|
9562 | dispatchException: function (exception) {
|
9563 | if (this.done) {
|
9564 | throw exception;
|
9565 | }
|
9566 |
|
9567 | var context = this;
|
9568 |
|
9569 | function handle(loc, caught) {
|
9570 | record.type = "throw";
|
9571 | record.arg = exception;
|
9572 | context.next = loc;
|
9573 |
|
9574 | if (caught) {
|
9575 |
|
9576 |
|
9577 | context.method = "next";
|
9578 | context.arg = undefined$1;
|
9579 | }
|
9580 |
|
9581 | return !!caught;
|
9582 | }
|
9583 |
|
9584 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
9585 | var entry = this.tryEntries[i];
|
9586 | var record = entry.completion;
|
9587 |
|
9588 | if (entry.tryLoc === "root") {
|
9589 |
|
9590 |
|
9591 |
|
9592 | return handle("end");
|
9593 | }
|
9594 |
|
9595 | if (entry.tryLoc <= this.prev) {
|
9596 | var hasCatch = hasOwn.call(entry, "catchLoc");
|
9597 | var hasFinally = hasOwn.call(entry, "finallyLoc");
|
9598 |
|
9599 | if (hasCatch && hasFinally) {
|
9600 | if (this.prev < entry.catchLoc) {
|
9601 | return handle(entry.catchLoc, true);
|
9602 | } else if (this.prev < entry.finallyLoc) {
|
9603 | return handle(entry.finallyLoc);
|
9604 | }
|
9605 | } else if (hasCatch) {
|
9606 | if (this.prev < entry.catchLoc) {
|
9607 | return handle(entry.catchLoc, true);
|
9608 | }
|
9609 | } else if (hasFinally) {
|
9610 | if (this.prev < entry.finallyLoc) {
|
9611 | return handle(entry.finallyLoc);
|
9612 | }
|
9613 | } else {
|
9614 | throw new Error("try statement without catch or finally");
|
9615 | }
|
9616 | }
|
9617 | }
|
9618 | },
|
9619 | abrupt: function (type, arg) {
|
9620 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
9621 | var entry = this.tryEntries[i];
|
9622 |
|
9623 | if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
9624 | var finallyEntry = entry;
|
9625 | break;
|
9626 | }
|
9627 | }
|
9628 |
|
9629 | if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
9630 |
|
9631 |
|
9632 | finallyEntry = null;
|
9633 | }
|
9634 |
|
9635 | var record = finallyEntry ? finallyEntry.completion : {};
|
9636 | record.type = type;
|
9637 | record.arg = arg;
|
9638 |
|
9639 | if (finallyEntry) {
|
9640 | this.method = "next";
|
9641 | this.next = finallyEntry.finallyLoc;
|
9642 | return ContinueSentinel;
|
9643 | }
|
9644 |
|
9645 | return this.complete(record);
|
9646 | },
|
9647 | complete: function (record, afterLoc) {
|
9648 | if (record.type === "throw") {
|
9649 | throw record.arg;
|
9650 | }
|
9651 |
|
9652 | if (record.type === "break" || record.type === "continue") {
|
9653 | this.next = record.arg;
|
9654 | } else if (record.type === "return") {
|
9655 | this.rval = this.arg = record.arg;
|
9656 | this.method = "return";
|
9657 | this.next = "end";
|
9658 | } else if (record.type === "normal" && afterLoc) {
|
9659 | this.next = afterLoc;
|
9660 | }
|
9661 |
|
9662 | return ContinueSentinel;
|
9663 | },
|
9664 | finish: function (finallyLoc) {
|
9665 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
9666 | var entry = this.tryEntries[i];
|
9667 |
|
9668 | if (entry.finallyLoc === finallyLoc) {
|
9669 | this.complete(entry.completion, entry.afterLoc);
|
9670 | resetTryEntry(entry);
|
9671 | return ContinueSentinel;
|
9672 | }
|
9673 | }
|
9674 | },
|
9675 | "catch": function (tryLoc) {
|
9676 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
9677 | var entry = this.tryEntries[i];
|
9678 |
|
9679 | if (entry.tryLoc === tryLoc) {
|
9680 | var record = entry.completion;
|
9681 |
|
9682 | if (record.type === "throw") {
|
9683 | var thrown = record.arg;
|
9684 | resetTryEntry(entry);
|
9685 | }
|
9686 |
|
9687 | return thrown;
|
9688 | }
|
9689 | }
|
9690 |
|
9691 |
|
9692 |
|
9693 | throw new Error("illegal catch attempt");
|
9694 | },
|
9695 | delegateYield: function (iterable, resultName, nextLoc) {
|
9696 | this.delegate = {
|
9697 | iterator: values(iterable),
|
9698 | resultName: resultName,
|
9699 | nextLoc: nextLoc
|
9700 | };
|
9701 |
|
9702 | if (this.method === "next") {
|
9703 |
|
9704 |
|
9705 | this.arg = undefined$1;
|
9706 | }
|
9707 |
|
9708 | return ContinueSentinel;
|
9709 | }
|
9710 | };
|
9711 |
|
9712 |
|
9713 |
|
9714 |
|
9715 | return exports;
|
9716 | }(
|
9717 |
|
9718 |
|
9719 |
|
9720 | module.exports);
|
9721 |
|
9722 | try {
|
9723 | regeneratorRuntime = runtime;
|
9724 | } catch (accidentalStrictMode) {
|
9725 |
|
9726 |
|
9727 |
|
9728 |
|
9729 |
|
9730 |
|
9731 |
|
9732 |
|
9733 |
|
9734 | Function("r", "regeneratorRuntime = r")(runtime);
|
9735 | }
|
9736 | });
|
9737 | var regenerator = runtime_1;
|
9738 |
|
9739 | function _defineProperty$1(obj, key, value) {
|
9740 | if (key in obj) {
|
9741 | Object.defineProperty(obj, key, {
|
9742 | value: value,
|
9743 | enumerable: true,
|
9744 | configurable: true,
|
9745 | writable: true
|
9746 | });
|
9747 | } else {
|
9748 | obj[key] = value;
|
9749 | }
|
9750 |
|
9751 | return obj;
|
9752 | }
|
9753 |
|
9754 | var defineProperty$1 = _defineProperty$1;
|
9755 |
|
9756 | function _arrayWithoutHoles$1(arr) {
|
9757 | if (Array.isArray(arr)) {
|
9758 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
|
9759 | arr2[i] = arr[i];
|
9760 | }
|
9761 |
|
9762 | return arr2;
|
9763 | }
|
9764 | }
|
9765 |
|
9766 | var arrayWithoutHoles = _arrayWithoutHoles$1;
|
9767 |
|
9768 | function _iterableToArray$1(iter) {
|
9769 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
9770 | }
|
9771 |
|
9772 | var iterableToArray = _iterableToArray$1;
|
9773 |
|
9774 | function _nonIterableSpread$1() {
|
9775 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
9776 | }
|
9777 |
|
9778 | var nonIterableSpread = _nonIterableSpread$1;
|
9779 |
|
9780 | function _toConsumableArray$1(arr) {
|
9781 | return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
|
9782 | }
|
9783 |
|
9784 | var toConsumableArray = _toConsumableArray$1;
|
9785 |
|
9786 | var _typeof_1 = createCommonjsModule$2(function (module) {
|
9787 | function _typeof2(obj) {
|
9788 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
9789 | _typeof2 = function _typeof2(obj) {
|
9790 | return typeof obj;
|
9791 | };
|
9792 | } else {
|
9793 | _typeof2 = function _typeof2(obj) {
|
9794 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
9795 | };
|
9796 | }
|
9797 |
|
9798 | return _typeof2(obj);
|
9799 | }
|
9800 |
|
9801 | function _typeof(obj) {
|
9802 | if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
|
9803 | module.exports = _typeof = function _typeof(obj) {
|
9804 | return _typeof2(obj);
|
9805 | };
|
9806 | } else {
|
9807 | module.exports = _typeof = function _typeof(obj) {
|
9808 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
|
9809 | };
|
9810 | }
|
9811 |
|
9812 | return _typeof(obj);
|
9813 | }
|
9814 |
|
9815 | module.exports = _typeof;
|
9816 | });
|
9817 |
|
9818 | function _classCallCheck(instance, Constructor) {
|
9819 | if (!(instance instanceof Constructor)) {
|
9820 | throw new TypeError("Cannot call a class as a function");
|
9821 | }
|
9822 | }
|
9823 |
|
9824 | var classCallCheck = _classCallCheck;
|
9825 |
|
9826 | function _defineProperties(target, props) {
|
9827 | for (var i = 0; i < props.length; i++) {
|
9828 | var descriptor = props[i];
|
9829 | descriptor.enumerable = descriptor.enumerable || false;
|
9830 | descriptor.configurable = true;
|
9831 | if ("value" in descriptor) descriptor.writable = true;
|
9832 | Object.defineProperty(target, descriptor.key, descriptor);
|
9833 | }
|
9834 | }
|
9835 |
|
9836 | function _createClass(Constructor, protoProps, staticProps) {
|
9837 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
9838 | if (staticProps) _defineProperties(Constructor, staticProps);
|
9839 | return Constructor;
|
9840 | }
|
9841 |
|
9842 | var createClass = _createClass;
|
9843 |
|
9844 | function _assertThisInitialized(self) {
|
9845 | if (self === void 0) {
|
9846 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
9847 | }
|
9848 |
|
9849 | return self;
|
9850 | }
|
9851 |
|
9852 | var assertThisInitialized = _assertThisInitialized;
|
9853 |
|
9854 | function _possibleConstructorReturn(self, call) {
|
9855 | if (call && (_typeof_1(call) === "object" || typeof call === "function")) {
|
9856 | return call;
|
9857 | }
|
9858 |
|
9859 | return assertThisInitialized(self);
|
9860 | }
|
9861 |
|
9862 | var possibleConstructorReturn = _possibleConstructorReturn;
|
9863 | var getPrototypeOf = createCommonjsModule$2(function (module) {
|
9864 | function _getPrototypeOf(o) {
|
9865 | module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
9866 | return o.__proto__ || Object.getPrototypeOf(o);
|
9867 | };
|
9868 | return _getPrototypeOf(o);
|
9869 | }
|
9870 |
|
9871 | module.exports = _getPrototypeOf;
|
9872 | });
|
9873 | var setPrototypeOf$1 = createCommonjsModule$2(function (module) {
|
9874 | function _setPrototypeOf(o, p) {
|
9875 | module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
9876 | o.__proto__ = p;
|
9877 | return o;
|
9878 | };
|
9879 |
|
9880 | return _setPrototypeOf(o, p);
|
9881 | }
|
9882 |
|
9883 | module.exports = _setPrototypeOf;
|
9884 | });
|
9885 |
|
9886 | function _inherits(subClass, superClass) {
|
9887 | if (typeof superClass !== "function" && superClass !== null) {
|
9888 | throw new TypeError("Super expression must either be null or a function");
|
9889 | }
|
9890 |
|
9891 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
9892 | constructor: {
|
9893 | value: subClass,
|
9894 | writable: true,
|
9895 | configurable: true
|
9896 | }
|
9897 | });
|
9898 | if (superClass) setPrototypeOf$1(subClass, superClass);
|
9899 | }
|
9900 |
|
9901 | var inherits = _inherits;
|
9902 |
|
9903 | var byteToHex$2 = [];
|
9904 |
|
9905 | for (var i$2 = 0; i$2 < 256; i$2++) {
|
9906 | byteToHex$2[i$2] = (i$2 + 0x100).toString(16).substr(1);
|
9907 | }
|
9908 |
|
9909 |
|
9910 |
|
9911 |
|
9912 |
|
9913 |
|
9914 |
|
9915 |
|
9916 |
|
9917 |
|
9918 | function stringifyUUID$1(buf, offset) {
|
9919 | var i = offset || 0;
|
9920 | var bth = byteToHex$2;
|
9921 | return bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]];
|
9922 | }
|
9923 |
|
9924 |
|
9925 |
|
9926 |
|
9927 |
|
9928 |
|
9929 |
|
9930 | var random$1 = function () {
|
9931 | if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
|
9932 |
|
9933 |
|
9934 | var _rnds8 = new Uint8Array(16);
|
9935 |
|
9936 | return function whatwgRNG() {
|
9937 | crypto.getRandomValues(_rnds8);
|
9938 | return _rnds8;
|
9939 | };
|
9940 | }
|
9941 |
|
9942 |
|
9943 |
|
9944 |
|
9945 |
|
9946 | var _rnds = new Array(16);
|
9947 |
|
9948 | return function () {
|
9949 | for (var i = 0, r; i < 16; i++) {
|
9950 | if ((i & 0x03) === 0) {
|
9951 | r = Math.random() * 0x100000000;
|
9952 | }
|
9953 |
|
9954 | _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
|
9955 | }
|
9956 |
|
9957 | return _rnds;
|
9958 | };
|
9959 |
|
9960 |
|
9961 |
|
9962 |
|
9963 |
|
9964 |
|
9965 |
|
9966 | }();
|
9967 |
|
9968 | var byteToHex$1$1 = [];
|
9969 |
|
9970 | for (var i$1$2 = 0; i$1$2 < 256; i$1$2++) {
|
9971 | byteToHex$1$1[i$1$2] = (i$1$2 + 0x100).toString(16).substr(1);
|
9972 | }
|
9973 |
|
9974 |
|
9975 |
|
9976 |
|
9977 |
|
9978 |
|
9979 | var seedBytes$1 = random$1();
|
9980 |
|
9981 | var defaultNodeId$1 = [seedBytes$1[0] | 0x01, seedBytes$1[1], seedBytes$1[2], seedBytes$1[3], seedBytes$1[4], seedBytes$1[5]];
|
9982 |
|
9983 | var defaultClockseq$1 = (seedBytes$1[6] << 8 | seedBytes$1[7]) & 0x3fff;
|
9984 |
|
9985 |
|
9986 |
|
9987 |
|
9988 |
|
9989 |
|
9990 |
|
9991 |
|
9992 |
|
9993 |
|
9994 |
|
9995 |
|
9996 |
|
9997 |
|
9998 |
|
9999 |
|
10000 | function uuid4$1() {
|
10001 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
10002 | var buf = arguments.length > 1 ? arguments[1] : undefined;
|
10003 | var offset = arguments.length > 2 ? arguments[2] : undefined;
|
10004 |
|
10005 | var i = buf && offset || 0;
|
10006 |
|
10007 | if (typeof options === 'string') {
|
10008 | buf = options === 'binary' ? new Array(16) : undefined;
|
10009 | options = {};
|
10010 | }
|
10011 |
|
10012 | var rnds = options.random || (options.rng || random$1)();
|
10013 |
|
10014 | rnds[6] = rnds[6] & 0x0f | 0x40;
|
10015 | rnds[8] = rnds[8] & 0x3f | 0x80;
|
10016 |
|
10017 | if (buf) {
|
10018 | for (var ii = 0; ii < 16; ii++) {
|
10019 | buf[i + ii] = rnds[ii];
|
10020 | }
|
10021 | }
|
10022 |
|
10023 | return buf || stringifyUUID$1(rnds);
|
10024 | }
|
10025 |
|
10026 |
|
10027 | function _typeof$1(obj) {
|
10028 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
10029 | _typeof$1 = function (obj) {
|
10030 | return typeof obj;
|
10031 | };
|
10032 | } else {
|
10033 | _typeof$1 = function (obj) {
|
10034 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
10035 | };
|
10036 | }
|
10037 |
|
10038 | return _typeof$1(obj);
|
10039 | }
|
10040 |
|
10041 | var commonjsGlobal$2 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
10042 |
|
10043 | function commonjsRequire$2() {
|
10044 | throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
|
10045 | }
|
10046 |
|
10047 | function createCommonjsModule$1$1(fn, module) {
|
10048 | return module = {
|
10049 | exports: {}
|
10050 | }, fn(module, module.exports), module.exports;
|
10051 | }
|
10052 |
|
10053 | var moment$1 = createCommonjsModule$1$1(function (module, exports) {
|
10054 | (function (global, factory) {
|
10055 | module.exports = factory();
|
10056 | })(commonjsGlobal$2, function () {
|
10057 | var hookCallback;
|
10058 |
|
10059 | function hooks() {
|
10060 | return hookCallback.apply(null, arguments);
|
10061 | }
|
10062 |
|
10063 |
|
10064 |
|
10065 | function setHookCallback(callback) {
|
10066 | hookCallback = callback;
|
10067 | }
|
10068 |
|
10069 | function isArray(input) {
|
10070 | return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
|
10071 | }
|
10072 |
|
10073 | function isObject(input) {
|
10074 |
|
10075 |
|
10076 | return input != null && Object.prototype.toString.call(input) === '[object Object]';
|
10077 | }
|
10078 |
|
10079 | function isObjectEmpty(obj) {
|
10080 | if (Object.getOwnPropertyNames) {
|
10081 | return Object.getOwnPropertyNames(obj).length === 0;
|
10082 | } else {
|
10083 | var k;
|
10084 |
|
10085 | for (k in obj) {
|
10086 | if (obj.hasOwnProperty(k)) {
|
10087 | return false;
|
10088 | }
|
10089 | }
|
10090 |
|
10091 | return true;
|
10092 | }
|
10093 | }
|
10094 |
|
10095 | function isUndefined(input) {
|
10096 | return input === void 0;
|
10097 | }
|
10098 |
|
10099 | function isNumber(input) {
|
10100 | return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
|
10101 | }
|
10102 |
|
10103 | function isDate(input) {
|
10104 | return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
|
10105 | }
|
10106 |
|
10107 | function map(arr, fn) {
|
10108 | var res = [],
|
10109 | i;
|
10110 |
|
10111 | for (i = 0; i < arr.length; ++i) {
|
10112 | res.push(fn(arr[i], i));
|
10113 | }
|
10114 |
|
10115 | return res;
|
10116 | }
|
10117 |
|
10118 | function hasOwnProp(a, b) {
|
10119 | return Object.prototype.hasOwnProperty.call(a, b);
|
10120 | }
|
10121 |
|
10122 | function extend(a, b) {
|
10123 | for (var i in b) {
|
10124 | if (hasOwnProp(b, i)) {
|
10125 | a[i] = b[i];
|
10126 | }
|
10127 | }
|
10128 |
|
10129 | if (hasOwnProp(b, 'toString')) {
|
10130 | a.toString = b.toString;
|
10131 | }
|
10132 |
|
10133 | if (hasOwnProp(b, 'valueOf')) {
|
10134 | a.valueOf = b.valueOf;
|
10135 | }
|
10136 |
|
10137 | return a;
|
10138 | }
|
10139 |
|
10140 | function createUTC(input, format, locale, strict) {
|
10141 | return createLocalOrUTC(input, format, locale, strict, true).utc();
|
10142 | }
|
10143 |
|
10144 | function defaultParsingFlags() {
|
10145 |
|
10146 | return {
|
10147 | empty: false,
|
10148 | unusedTokens: [],
|
10149 | unusedInput: [],
|
10150 | overflow: -2,
|
10151 | charsLeftOver: 0,
|
10152 | nullInput: false,
|
10153 | invalidMonth: null,
|
10154 | invalidFormat: false,
|
10155 | userInvalidated: false,
|
10156 | iso: false,
|
10157 | parsedDateParts: [],
|
10158 | meridiem: null,
|
10159 | rfc2822: false,
|
10160 | weekdayMismatch: false
|
10161 | };
|
10162 | }
|
10163 |
|
10164 | function getParsingFlags(m) {
|
10165 | if (m._pf == null) {
|
10166 | m._pf = defaultParsingFlags();
|
10167 | }
|
10168 |
|
10169 | return m._pf;
|
10170 | }
|
10171 |
|
10172 | var some;
|
10173 |
|
10174 | if (Array.prototype.some) {
|
10175 | some = Array.prototype.some;
|
10176 | } else {
|
10177 | some = function (fun) {
|
10178 | var t = Object(this);
|
10179 | var len = t.length >>> 0;
|
10180 |
|
10181 | for (var i = 0; i < len; i++) {
|
10182 | if (i in t && fun.call(this, t[i], i, t)) {
|
10183 | return true;
|
10184 | }
|
10185 | }
|
10186 |
|
10187 | return false;
|
10188 | };
|
10189 | }
|
10190 |
|
10191 | function isValid(m) {
|
10192 | if (m._isValid == null) {
|
10193 | var flags = getParsingFlags(m);
|
10194 | var parsedParts = some.call(flags.parsedDateParts, function (i) {
|
10195 | return i != null;
|
10196 | });
|
10197 | var isNowValid = !isNaN(m._d.getTime()) && flags.overflow < 0 && !flags.empty && !flags.invalidMonth && !flags.invalidWeekday && !flags.weekdayMismatch && !flags.nullInput && !flags.invalidFormat && !flags.userInvalidated && (!flags.meridiem || flags.meridiem && parsedParts);
|
10198 |
|
10199 | if (m._strict) {
|
10200 | isNowValid = isNowValid && flags.charsLeftOver === 0 && flags.unusedTokens.length === 0 && flags.bigHour === undefined;
|
10201 | }
|
10202 |
|
10203 | if (Object.isFrozen == null || !Object.isFrozen(m)) {
|
10204 | m._isValid = isNowValid;
|
10205 | } else {
|
10206 | return isNowValid;
|
10207 | }
|
10208 | }
|
10209 |
|
10210 | return m._isValid;
|
10211 | }
|
10212 |
|
10213 | function createInvalid(flags) {
|
10214 | var m = createUTC(NaN);
|
10215 |
|
10216 | if (flags != null) {
|
10217 | extend(getParsingFlags(m), flags);
|
10218 | } else {
|
10219 | getParsingFlags(m).userInvalidated = true;
|
10220 | }
|
10221 |
|
10222 | return m;
|
10223 | }
|
10224 |
|
10225 |
|
10226 |
|
10227 | var momentProperties = hooks.momentProperties = [];
|
10228 |
|
10229 | function copyConfig(to, from) {
|
10230 | var i, prop, val;
|
10231 |
|
10232 | if (!isUndefined(from._isAMomentObject)) {
|
10233 | to._isAMomentObject = from._isAMomentObject;
|
10234 | }
|
10235 |
|
10236 | if (!isUndefined(from._i)) {
|
10237 | to._i = from._i;
|
10238 | }
|
10239 |
|
10240 | if (!isUndefined(from._f)) {
|
10241 | to._f = from._f;
|
10242 | }
|
10243 |
|
10244 | if (!isUndefined(from._l)) {
|
10245 | to._l = from._l;
|
10246 | }
|
10247 |
|
10248 | if (!isUndefined(from._strict)) {
|
10249 | to._strict = from._strict;
|
10250 | }
|
10251 |
|
10252 | if (!isUndefined(from._tzm)) {
|
10253 | to._tzm = from._tzm;
|
10254 | }
|
10255 |
|
10256 | if (!isUndefined(from._isUTC)) {
|
10257 | to._isUTC = from._isUTC;
|
10258 | }
|
10259 |
|
10260 | if (!isUndefined(from._offset)) {
|
10261 | to._offset = from._offset;
|
10262 | }
|
10263 |
|
10264 | if (!isUndefined(from._pf)) {
|
10265 | to._pf = getParsingFlags(from);
|
10266 | }
|
10267 |
|
10268 | if (!isUndefined(from._locale)) {
|
10269 | to._locale = from._locale;
|
10270 | }
|
10271 |
|
10272 | if (momentProperties.length > 0) {
|
10273 | for (i = 0; i < momentProperties.length; i++) {
|
10274 | prop = momentProperties[i];
|
10275 | val = from[prop];
|
10276 |
|
10277 | if (!isUndefined(val)) {
|
10278 | to[prop] = val;
|
10279 | }
|
10280 | }
|
10281 | }
|
10282 |
|
10283 | return to;
|
10284 | }
|
10285 |
|
10286 | var updateInProgress = false;
|
10287 |
|
10288 | function Moment(config) {
|
10289 | copyConfig(this, config);
|
10290 | this._d = new Date(config._d != null ? config._d.getTime() : NaN);
|
10291 |
|
10292 | if (!this.isValid()) {
|
10293 | this._d = new Date(NaN);
|
10294 | }
|
10295 |
|
10296 |
|
10297 |
|
10298 | if (updateInProgress === false) {
|
10299 | updateInProgress = true;
|
10300 | hooks.updateOffset(this);
|
10301 | updateInProgress = false;
|
10302 | }
|
10303 | }
|
10304 |
|
10305 | function isMoment(obj) {
|
10306 | return obj instanceof Moment || obj != null && obj._isAMomentObject != null;
|
10307 | }
|
10308 |
|
10309 | function absFloor(number) {
|
10310 | if (number < 0) {
|
10311 |
|
10312 | return Math.ceil(number) || 0;
|
10313 | } else {
|
10314 | return Math.floor(number);
|
10315 | }
|
10316 | }
|
10317 |
|
10318 | function toInt(argumentForCoercion) {
|
10319 | var coercedNumber = +argumentForCoercion,
|
10320 | value = 0;
|
10321 |
|
10322 | if (coercedNumber !== 0 && isFinite(coercedNumber)) {
|
10323 | value = absFloor(coercedNumber);
|
10324 | }
|
10325 |
|
10326 | return value;
|
10327 | }
|
10328 |
|
10329 |
|
10330 | function compareArrays(array1, array2, dontConvert) {
|
10331 | var len = Math.min(array1.length, array2.length),
|
10332 | lengthDiff = Math.abs(array1.length - array2.length),
|
10333 | diffs = 0,
|
10334 | i;
|
10335 |
|
10336 | for (i = 0; i < len; i++) {
|
10337 | if (dontConvert && array1[i] !== array2[i] || !dontConvert && toInt(array1[i]) !== toInt(array2[i])) {
|
10338 | diffs++;
|
10339 | }
|
10340 | }
|
10341 |
|
10342 | return diffs + lengthDiff;
|
10343 | }
|
10344 |
|
10345 | function warn(msg) {
|
10346 | if (hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
|
10347 | console.warn('Deprecation warning: ' + msg);
|
10348 | }
|
10349 | }
|
10350 |
|
10351 | function deprecate(msg, fn) {
|
10352 | var firstTime = true;
|
10353 | return extend(function () {
|
10354 | if (hooks.deprecationHandler != null) {
|
10355 | hooks.deprecationHandler(null, msg);
|
10356 | }
|
10357 |
|
10358 | if (firstTime) {
|
10359 | var args = [];
|
10360 | var arg;
|
10361 |
|
10362 | for (var i = 0; i < arguments.length; i++) {
|
10363 | arg = '';
|
10364 |
|
10365 | if (typeof arguments[i] === 'object') {
|
10366 | arg += '\n[' + i + '] ';
|
10367 |
|
10368 | for (var key in arguments[0]) {
|
10369 | arg += key + ': ' + arguments[0][key] + ', ';
|
10370 | }
|
10371 |
|
10372 | arg = arg.slice(0, -2);
|
10373 | } else {
|
10374 | arg = arguments[i];
|
10375 | }
|
10376 |
|
10377 | args.push(arg);
|
10378 | }
|
10379 |
|
10380 | warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + new Error().stack);
|
10381 | firstTime = false;
|
10382 | }
|
10383 |
|
10384 | return fn.apply(this, arguments);
|
10385 | }, fn);
|
10386 | }
|
10387 |
|
10388 | var deprecations = {};
|
10389 |
|
10390 | function deprecateSimple(name, msg) {
|
10391 | if (hooks.deprecationHandler != null) {
|
10392 | hooks.deprecationHandler(name, msg);
|
10393 | }
|
10394 |
|
10395 | if (!deprecations[name]) {
|
10396 | warn(msg);
|
10397 | deprecations[name] = true;
|
10398 | }
|
10399 | }
|
10400 |
|
10401 | hooks.suppressDeprecationWarnings = false;
|
10402 | hooks.deprecationHandler = null;
|
10403 |
|
10404 | function isFunction(input) {
|
10405 | return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
|
10406 | }
|
10407 |
|
10408 | function set(config) {
|
10409 | var prop, i;
|
10410 |
|
10411 | for (i in config) {
|
10412 | prop = config[i];
|
10413 |
|
10414 | if (isFunction(prop)) {
|
10415 | this[i] = prop;
|
10416 | } else {
|
10417 | this['_' + i] = prop;
|
10418 | }
|
10419 | }
|
10420 |
|
10421 | this._config = config;
|
10422 |
|
10423 |
|
10424 |
|
10425 | this._dayOfMonthOrdinalParseLenient = new RegExp((this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + '|' + /\d{1,2}/.source);
|
10426 | }
|
10427 |
|
10428 | function mergeConfigs(parentConfig, childConfig) {
|
10429 | var res = extend({}, parentConfig),
|
10430 | prop;
|
10431 |
|
10432 | for (prop in childConfig) {
|
10433 | if (hasOwnProp(childConfig, prop)) {
|
10434 | if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
|
10435 | res[prop] = {};
|
10436 | extend(res[prop], parentConfig[prop]);
|
10437 | extend(res[prop], childConfig[prop]);
|
10438 | } else if (childConfig[prop] != null) {
|
10439 | res[prop] = childConfig[prop];
|
10440 | } else {
|
10441 | delete res[prop];
|
10442 | }
|
10443 | }
|
10444 | }
|
10445 |
|
10446 | for (prop in parentConfig) {
|
10447 | if (hasOwnProp(parentConfig, prop) && !hasOwnProp(childConfig, prop) && isObject(parentConfig[prop])) {
|
10448 |
|
10449 | res[prop] = extend({}, res[prop]);
|
10450 | }
|
10451 | }
|
10452 |
|
10453 | return res;
|
10454 | }
|
10455 |
|
10456 | function Locale(config) {
|
10457 | if (config != null) {
|
10458 | this.set(config);
|
10459 | }
|
10460 | }
|
10461 |
|
10462 | var keys;
|
10463 |
|
10464 | if (Object.keys) {
|
10465 | keys = Object.keys;
|
10466 | } else {
|
10467 | keys = function (obj) {
|
10468 | var i,
|
10469 | res = [];
|
10470 |
|
10471 | for (i in obj) {
|
10472 | if (hasOwnProp(obj, i)) {
|
10473 | res.push(i);
|
10474 | }
|
10475 | }
|
10476 |
|
10477 | return res;
|
10478 | };
|
10479 | }
|
10480 |
|
10481 | var defaultCalendar = {
|
10482 | sameDay: '[Today at] LT',
|
10483 | nextDay: '[Tomorrow at] LT',
|
10484 | nextWeek: 'dddd [at] LT',
|
10485 | lastDay: '[Yesterday at] LT',
|
10486 | lastWeek: '[Last] dddd [at] LT',
|
10487 | sameElse: 'L'
|
10488 | };
|
10489 |
|
10490 | function calendar(key, mom, now) {
|
10491 | var output = this._calendar[key] || this._calendar['sameElse'];
|
10492 | return isFunction(output) ? output.call(mom, now) : output;
|
10493 | }
|
10494 |
|
10495 | var defaultLongDateFormat = {
|
10496 | LTS: 'h:mm:ss A',
|
10497 | LT: 'h:mm A',
|
10498 | L: 'MM/DD/YYYY',
|
10499 | LL: 'MMMM D, YYYY',
|
10500 | LLL: 'MMMM D, YYYY h:mm A',
|
10501 | LLLL: 'dddd, MMMM D, YYYY h:mm A'
|
10502 | };
|
10503 |
|
10504 | function longDateFormat(key) {
|
10505 | var format = this._longDateFormat[key],
|
10506 | formatUpper = this._longDateFormat[key.toUpperCase()];
|
10507 |
|
10508 | if (format || !formatUpper) {
|
10509 | return format;
|
10510 | }
|
10511 |
|
10512 | this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
|
10513 | return val.slice(1);
|
10514 | });
|
10515 | return this._longDateFormat[key];
|
10516 | }
|
10517 |
|
10518 | var defaultInvalidDate = 'Invalid date';
|
10519 |
|
10520 | function invalidDate() {
|
10521 | return this._invalidDate;
|
10522 | }
|
10523 |
|
10524 | var defaultOrdinal = '%d';
|
10525 | var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
|
10526 |
|
10527 | function ordinal(number) {
|
10528 | return this._ordinal.replace('%d', number);
|
10529 | }
|
10530 |
|
10531 | var defaultRelativeTime = {
|
10532 | future: 'in %s',
|
10533 | past: '%s ago',
|
10534 | s: 'a few seconds',
|
10535 | ss: '%d seconds',
|
10536 | m: 'a minute',
|
10537 | mm: '%d minutes',
|
10538 | h: 'an hour',
|
10539 | hh: '%d hours',
|
10540 | d: 'a day',
|
10541 | dd: '%d days',
|
10542 | M: 'a month',
|
10543 | MM: '%d months',
|
10544 | y: 'a year',
|
10545 | yy: '%d years'
|
10546 | };
|
10547 |
|
10548 | function relativeTime(number, withoutSuffix, string, isFuture) {
|
10549 | var output = this._relativeTime[string];
|
10550 | return isFunction(output) ? output(number, withoutSuffix, string, isFuture) : output.replace(/%d/i, number);
|
10551 | }
|
10552 |
|
10553 | function pastFuture(diff, output) {
|
10554 | var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
|
10555 | return isFunction(format) ? format(output) : format.replace(/%s/i, output);
|
10556 | }
|
10557 |
|
10558 | var aliases = {};
|
10559 |
|
10560 | function addUnitAlias(unit, shorthand) {
|
10561 | var lowerCase = unit.toLowerCase();
|
10562 | aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
|
10563 | }
|
10564 |
|
10565 | function normalizeUnits(units) {
|
10566 | return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
|
10567 | }
|
10568 |
|
10569 | function normalizeObjectUnits(inputObject) {
|
10570 | var normalizedInput = {},
|
10571 | normalizedProp,
|
10572 | prop;
|
10573 |
|
10574 | for (prop in inputObject) {
|
10575 | if (hasOwnProp(inputObject, prop)) {
|
10576 | normalizedProp = normalizeUnits(prop);
|
10577 |
|
10578 | if (normalizedProp) {
|
10579 | normalizedInput[normalizedProp] = inputObject[prop];
|
10580 | }
|
10581 | }
|
10582 | }
|
10583 |
|
10584 | return normalizedInput;
|
10585 | }
|
10586 |
|
10587 | var priorities = {};
|
10588 |
|
10589 | function addUnitPriority(unit, priority) {
|
10590 | priorities[unit] = priority;
|
10591 | }
|
10592 |
|
10593 | function getPrioritizedUnits(unitsObj) {
|
10594 | var units = [];
|
10595 |
|
10596 | for (var u in unitsObj) {
|
10597 | units.push({
|
10598 | unit: u,
|
10599 | priority: priorities[u]
|
10600 | });
|
10601 | }
|
10602 |
|
10603 | units.sort(function (a, b) {
|
10604 | return a.priority - b.priority;
|
10605 | });
|
10606 | return units;
|
10607 | }
|
10608 |
|
10609 | function zeroFill(number, targetLength, forceSign) {
|
10610 | var absNumber = '' + Math.abs(number),
|
10611 | zerosToFill = targetLength - absNumber.length,
|
10612 | sign = number >= 0;
|
10613 | return (sign ? forceSign ? '+' : '' : '-') + Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
|
10614 | }
|
10615 |
|
10616 | 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;
|
10617 | var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
|
10618 | var formatFunctions = {};
|
10619 | var formatTokenFunctions = {};
|
10620 |
|
10621 |
|
10622 |
|
10623 |
|
10624 | function addFormatToken(token, padded, ordinal, callback) {
|
10625 | var func = callback;
|
10626 |
|
10627 | if (typeof callback === 'string') {
|
10628 | func = function () {
|
10629 | return this[callback]();
|
10630 | };
|
10631 | }
|
10632 |
|
10633 | if (token) {
|
10634 | formatTokenFunctions[token] = func;
|
10635 | }
|
10636 |
|
10637 | if (padded) {
|
10638 | formatTokenFunctions[padded[0]] = function () {
|
10639 | return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
|
10640 | };
|
10641 | }
|
10642 |
|
10643 | if (ordinal) {
|
10644 | formatTokenFunctions[ordinal] = function () {
|
10645 | return this.localeData().ordinal(func.apply(this, arguments), token);
|
10646 | };
|
10647 | }
|
10648 | }
|
10649 |
|
10650 | function removeFormattingTokens(input) {
|
10651 | if (input.match(/\[[\s\S]/)) {
|
10652 | return input.replace(/^\[|\]$/g, '');
|
10653 | }
|
10654 |
|
10655 | return input.replace(/\\/g, '');
|
10656 | }
|
10657 |
|
10658 | function makeFormatFunction(format) {
|
10659 | var array = format.match(formattingTokens),
|
10660 | i,
|
10661 | length;
|
10662 |
|
10663 | for (i = 0, length = array.length; i < length; i++) {
|
10664 | if (formatTokenFunctions[array[i]]) {
|
10665 | array[i] = formatTokenFunctions[array[i]];
|
10666 | } else {
|
10667 | array[i] = removeFormattingTokens(array[i]);
|
10668 | }
|
10669 | }
|
10670 |
|
10671 | return function (mom) {
|
10672 | var output = '',
|
10673 | i;
|
10674 |
|
10675 | for (i = 0; i < length; i++) {
|
10676 | output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
|
10677 | }
|
10678 |
|
10679 | return output;
|
10680 | };
|
10681 | }
|
10682 |
|
10683 |
|
10684 | function formatMoment(m, format) {
|
10685 | if (!m.isValid()) {
|
10686 | return m.localeData().invalidDate();
|
10687 | }
|
10688 |
|
10689 | format = expandFormat(format, m.localeData());
|
10690 | formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
|
10691 | return formatFunctions[format](m);
|
10692 | }
|
10693 |
|
10694 | function expandFormat(format, locale) {
|
10695 | var i = 5;
|
10696 |
|
10697 | function replaceLongDateFormatTokens(input) {
|
10698 | return locale.longDateFormat(input) || input;
|
10699 | }
|
10700 |
|
10701 | localFormattingTokens.lastIndex = 0;
|
10702 |
|
10703 | while (i >= 0 && localFormattingTokens.test(format)) {
|
10704 | format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
|
10705 | localFormattingTokens.lastIndex = 0;
|
10706 | i -= 1;
|
10707 | }
|
10708 |
|
10709 | return format;
|
10710 | }
|
10711 |
|
10712 | var match1 = /\d/;
|
10713 |
|
10714 | var match2 = /\d\d/;
|
10715 |
|
10716 | var match3 = /\d{3}/;
|
10717 |
|
10718 | var match4 = /\d{4}/;
|
10719 |
|
10720 | var match6 = /[+-]?\d{6}/;
|
10721 |
|
10722 | var match1to2 = /\d\d?/;
|
10723 |
|
10724 | var match3to4 = /\d\d\d\d?/;
|
10725 |
|
10726 | var match5to6 = /\d\d\d\d\d\d?/;
|
10727 |
|
10728 | var match1to3 = /\d{1,3}/;
|
10729 |
|
10730 | var match1to4 = /\d{1,4}/;
|
10731 |
|
10732 | var match1to6 = /[+-]?\d{1,6}/;
|
10733 |
|
10734 | var matchUnsigned = /\d+/;
|
10735 |
|
10736 | var matchSigned = /[+-]?\d+/;
|
10737 |
|
10738 | var matchOffset = /Z|[+-]\d\d:?\d\d/gi;
|
10739 |
|
10740 | var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi;
|
10741 |
|
10742 | var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/;
|
10743 |
|
10744 |
|
10745 |
|
10746 | var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
|
10747 | var regexes = {};
|
10748 |
|
10749 | function addRegexToken(token, regex, strictRegex) {
|
10750 | regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
|
10751 | return isStrict && strictRegex ? strictRegex : regex;
|
10752 | };
|
10753 | }
|
10754 |
|
10755 | function getParseRegexForToken(token, config) {
|
10756 | if (!hasOwnProp(regexes, token)) {
|
10757 | return new RegExp(unescapeFormat(token));
|
10758 | }
|
10759 |
|
10760 | return regexes[token](config._strict, config._locale);
|
10761 | }
|
10762 |
|
10763 |
|
10764 | function unescapeFormat(s) {
|
10765 | return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
|
10766 | return p1 || p2 || p3 || p4;
|
10767 | }));
|
10768 | }
|
10769 |
|
10770 | function regexEscape(s) {
|
10771 | return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
10772 | }
|
10773 |
|
10774 | var tokens = {};
|
10775 |
|
10776 | function addParseToken(token, callback) {
|
10777 | var i,
|
10778 | func = callback;
|
10779 |
|
10780 | if (typeof token === 'string') {
|
10781 | token = [token];
|
10782 | }
|
10783 |
|
10784 | if (isNumber(callback)) {
|
10785 | func = function (input, array) {
|
10786 | array[callback] = toInt(input);
|
10787 | };
|
10788 | }
|
10789 |
|
10790 | for (i = 0; i < token.length; i++) {
|
10791 | tokens[token[i]] = func;
|
10792 | }
|
10793 | }
|
10794 |
|
10795 | function addWeekParseToken(token, callback) {
|
10796 | addParseToken(token, function (input, array, config, token) {
|
10797 | config._w = config._w || {};
|
10798 | callback(input, config._w, config, token);
|
10799 | });
|
10800 | }
|
10801 |
|
10802 | function addTimeToArrayFromToken(token, input, config) {
|
10803 | if (input != null && hasOwnProp(tokens, token)) {
|
10804 | tokens[token](input, config._a, config, token);
|
10805 | }
|
10806 | }
|
10807 |
|
10808 | var YEAR = 0;
|
10809 | var MONTH = 1;
|
10810 | var DATE = 2;
|
10811 | var HOUR = 3;
|
10812 | var MINUTE = 4;
|
10813 | var SECOND = 5;
|
10814 | var MILLISECOND = 6;
|
10815 | var WEEK = 7;
|
10816 | var WEEKDAY = 8;
|
10817 |
|
10818 | addFormatToken('Y', 0, 0, function () {
|
10819 | var y = this.year();
|
10820 | return y <= 9999 ? '' + y : '+' + y;
|
10821 | });
|
10822 | addFormatToken(0, ['YY', 2], 0, function () {
|
10823 | return this.year() % 100;
|
10824 | });
|
10825 | addFormatToken(0, ['YYYY', 4], 0, 'year');
|
10826 | addFormatToken(0, ['YYYYY', 5], 0, 'year');
|
10827 | addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
|
10828 |
|
10829 | addUnitAlias('year', 'y');
|
10830 |
|
10831 | addUnitPriority('year', 1);
|
10832 |
|
10833 | addRegexToken('Y', matchSigned);
|
10834 | addRegexToken('YY', match1to2, match2);
|
10835 | addRegexToken('YYYY', match1to4, match4);
|
10836 | addRegexToken('YYYYY', match1to6, match6);
|
10837 | addRegexToken('YYYYYY', match1to6, match6);
|
10838 | addParseToken(['YYYYY', 'YYYYYY'], YEAR);
|
10839 | addParseToken('YYYY', function (input, array) {
|
10840 | array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
|
10841 | });
|
10842 | addParseToken('YY', function (input, array) {
|
10843 | array[YEAR] = hooks.parseTwoDigitYear(input);
|
10844 | });
|
10845 | addParseToken('Y', function (input, array) {
|
10846 | array[YEAR] = parseInt(input, 10);
|
10847 | });
|
10848 |
|
10849 | function daysInYear(year) {
|
10850 | return isLeapYear(year) ? 366 : 365;
|
10851 | }
|
10852 |
|
10853 | function isLeapYear(year) {
|
10854 | return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
10855 | }
|
10856 |
|
10857 |
|
10858 | hooks.parseTwoDigitYear = function (input) {
|
10859 | return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
|
10860 | };
|
10861 |
|
10862 |
|
10863 | var getSetYear = makeGetSet('FullYear', true);
|
10864 |
|
10865 | function getIsLeapYear() {
|
10866 | return isLeapYear(this.year());
|
10867 | }
|
10868 |
|
10869 | function makeGetSet(unit, keepTime) {
|
10870 | return function (value) {
|
10871 | if (value != null) {
|
10872 | set$1(this, unit, value);
|
10873 | hooks.updateOffset(this, keepTime);
|
10874 | return this;
|
10875 | } else {
|
10876 | return get(this, unit);
|
10877 | }
|
10878 | };
|
10879 | }
|
10880 |
|
10881 | function get(mom, unit) {
|
10882 | return mom.isValid() ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
|
10883 | }
|
10884 |
|
10885 | function set$1(mom, unit, value) {
|
10886 | if (mom.isValid() && !isNaN(value)) {
|
10887 | if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
|
10888 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
|
10889 | } else {
|
10890 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
|
10891 | }
|
10892 | }
|
10893 | }
|
10894 |
|
10895 |
|
10896 | function stringGet(units) {
|
10897 | units = normalizeUnits(units);
|
10898 |
|
10899 | if (isFunction(this[units])) {
|
10900 | return this[units]();
|
10901 | }
|
10902 |
|
10903 | return this;
|
10904 | }
|
10905 |
|
10906 | function stringSet(units, value) {
|
10907 | if (typeof units === 'object') {
|
10908 | units = normalizeObjectUnits(units);
|
10909 | var prioritized = getPrioritizedUnits(units);
|
10910 |
|
10911 | for (var i = 0; i < prioritized.length; i++) {
|
10912 | this[prioritized[i].unit](units[prioritized[i].unit]);
|
10913 | }
|
10914 | } else {
|
10915 | units = normalizeUnits(units);
|
10916 |
|
10917 | if (isFunction(this[units])) {
|
10918 | return this[units](value);
|
10919 | }
|
10920 | }
|
10921 |
|
10922 | return this;
|
10923 | }
|
10924 |
|
10925 | function mod(n, x) {
|
10926 | return (n % x + x) % x;
|
10927 | }
|
10928 |
|
10929 | var indexOf;
|
10930 |
|
10931 | if (Array.prototype.indexOf) {
|
10932 | indexOf = Array.prototype.indexOf;
|
10933 | } else {
|
10934 | indexOf = function (o) {
|
10935 |
|
10936 | var i;
|
10937 |
|
10938 | for (i = 0; i < this.length; ++i) {
|
10939 | if (this[i] === o) {
|
10940 | return i;
|
10941 | }
|
10942 | }
|
10943 |
|
10944 | return -1;
|
10945 | };
|
10946 | }
|
10947 |
|
10948 | function daysInMonth(year, month) {
|
10949 | if (isNaN(year) || isNaN(month)) {
|
10950 | return NaN;
|
10951 | }
|
10952 |
|
10953 | var modMonth = mod(month, 12);
|
10954 | year += (month - modMonth) / 12;
|
10955 | return modMonth === 1 ? isLeapYear(year) ? 29 : 28 : 31 - modMonth % 7 % 2;
|
10956 | }
|
10957 |
|
10958 |
|
10959 | addFormatToken('M', ['MM', 2], 'Mo', function () {
|
10960 | return this.month() + 1;
|
10961 | });
|
10962 | addFormatToken('MMM', 0, 0, function (format) {
|
10963 | return this.localeData().monthsShort(this, format);
|
10964 | });
|
10965 | addFormatToken('MMMM', 0, 0, function (format) {
|
10966 | return this.localeData().months(this, format);
|
10967 | });
|
10968 |
|
10969 | addUnitAlias('month', 'M');
|
10970 |
|
10971 | addUnitPriority('month', 8);
|
10972 |
|
10973 | addRegexToken('M', match1to2);
|
10974 | addRegexToken('MM', match1to2, match2);
|
10975 | addRegexToken('MMM', function (isStrict, locale) {
|
10976 | return locale.monthsShortRegex(isStrict);
|
10977 | });
|
10978 | addRegexToken('MMMM', function (isStrict, locale) {
|
10979 | return locale.monthsRegex(isStrict);
|
10980 | });
|
10981 | addParseToken(['M', 'MM'], function (input, array) {
|
10982 | array[MONTH] = toInt(input) - 1;
|
10983 | });
|
10984 | addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
|
10985 | var month = config._locale.monthsParse(input, token, config._strict);
|
10986 |
|
10987 |
|
10988 | if (month != null) {
|
10989 | array[MONTH] = month;
|
10990 | } else {
|
10991 | getParsingFlags(config).invalidMonth = input;
|
10992 | }
|
10993 | });
|
10994 |
|
10995 | var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
|
10996 | var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
|
10997 |
|
10998 | function localeMonths(m, format) {
|
10999 | if (!m) {
|
11000 | return isArray(this._months) ? this._months : this._months['standalone'];
|
11001 | }
|
11002 |
|
11003 | return isArray(this._months) ? this._months[m.month()] : this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
|
11004 | }
|
11005 |
|
11006 | var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
|
11007 |
|
11008 | function localeMonthsShort(m, format) {
|
11009 | if (!m) {
|
11010 | return isArray(this._monthsShort) ? this._monthsShort : this._monthsShort['standalone'];
|
11011 | }
|
11012 |
|
11013 | return isArray(this._monthsShort) ? this._monthsShort[m.month()] : this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
|
11014 | }
|
11015 |
|
11016 | function handleStrictParse(monthName, format, strict) {
|
11017 | var i,
|
11018 | ii,
|
11019 | mom,
|
11020 | llc = monthName.toLocaleLowerCase();
|
11021 |
|
11022 | if (!this._monthsParse) {
|
11023 |
|
11024 | this._monthsParse = [];
|
11025 | this._longMonthsParse = [];
|
11026 | this._shortMonthsParse = [];
|
11027 |
|
11028 | for (i = 0; i < 12; ++i) {
|
11029 | mom = createUTC([2000, i]);
|
11030 | this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
|
11031 | this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
|
11032 | }
|
11033 | }
|
11034 |
|
11035 | if (strict) {
|
11036 | if (format === 'MMM') {
|
11037 | ii = indexOf.call(this._shortMonthsParse, llc);
|
11038 | return ii !== -1 ? ii : null;
|
11039 | } else {
|
11040 | ii = indexOf.call(this._longMonthsParse, llc);
|
11041 | return ii !== -1 ? ii : null;
|
11042 | }
|
11043 | } else {
|
11044 | if (format === 'MMM') {
|
11045 | ii = indexOf.call(this._shortMonthsParse, llc);
|
11046 |
|
11047 | if (ii !== -1) {
|
11048 | return ii;
|
11049 | }
|
11050 |
|
11051 | ii = indexOf.call(this._longMonthsParse, llc);
|
11052 | return ii !== -1 ? ii : null;
|
11053 | } else {
|
11054 | ii = indexOf.call(this._longMonthsParse, llc);
|
11055 |
|
11056 | if (ii !== -1) {
|
11057 | return ii;
|
11058 | }
|
11059 |
|
11060 | ii = indexOf.call(this._shortMonthsParse, llc);
|
11061 | return ii !== -1 ? ii : null;
|
11062 | }
|
11063 | }
|
11064 | }
|
11065 |
|
11066 | function localeMonthsParse(monthName, format, strict) {
|
11067 | var i, mom, regex;
|
11068 |
|
11069 | if (this._monthsParseExact) {
|
11070 | return handleStrictParse.call(this, monthName, format, strict);
|
11071 | }
|
11072 |
|
11073 | if (!this._monthsParse) {
|
11074 | this._monthsParse = [];
|
11075 | this._longMonthsParse = [];
|
11076 | this._shortMonthsParse = [];
|
11077 | }
|
11078 |
|
11079 |
|
11080 |
|
11081 |
|
11082 | for (i = 0; i < 12; i++) {
|
11083 |
|
11084 | mom = createUTC([2000, i]);
|
11085 |
|
11086 | if (strict && !this._longMonthsParse[i]) {
|
11087 | this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
|
11088 | this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
|
11089 | }
|
11090 |
|
11091 | if (!strict && !this._monthsParse[i]) {
|
11092 | regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
|
11093 | this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
11094 | }
|
11095 |
|
11096 |
|
11097 | if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
|
11098 | return i;
|
11099 | } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
|
11100 | return i;
|
11101 | } else if (!strict && this._monthsParse[i].test(monthName)) {
|
11102 | return i;
|
11103 | }
|
11104 | }
|
11105 | }
|
11106 |
|
11107 |
|
11108 | function setMonth(mom, value) {
|
11109 | var dayOfMonth;
|
11110 |
|
11111 | if (!mom.isValid()) {
|
11112 |
|
11113 | return mom;
|
11114 | }
|
11115 |
|
11116 | if (typeof value === 'string') {
|
11117 | if (/^\d+$/.test(value)) {
|
11118 | value = toInt(value);
|
11119 | } else {
|
11120 | value = mom.localeData().monthsParse(value);
|
11121 |
|
11122 | if (!isNumber(value)) {
|
11123 | return mom;
|
11124 | }
|
11125 | }
|
11126 | }
|
11127 |
|
11128 | dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
|
11129 |
|
11130 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
|
11131 |
|
11132 | return mom;
|
11133 | }
|
11134 |
|
11135 | function getSetMonth(value) {
|
11136 | if (value != null) {
|
11137 | setMonth(this, value);
|
11138 | hooks.updateOffset(this, true);
|
11139 | return this;
|
11140 | } else {
|
11141 | return get(this, 'Month');
|
11142 | }
|
11143 | }
|
11144 |
|
11145 | function getDaysInMonth() {
|
11146 | return daysInMonth(this.year(), this.month());
|
11147 | }
|
11148 |
|
11149 | var defaultMonthsShortRegex = matchWord;
|
11150 |
|
11151 | function monthsShortRegex(isStrict) {
|
11152 | if (this._monthsParseExact) {
|
11153 | if (!hasOwnProp(this, '_monthsRegex')) {
|
11154 | computeMonthsParse.call(this);
|
11155 | }
|
11156 |
|
11157 | if (isStrict) {
|
11158 | return this._monthsShortStrictRegex;
|
11159 | } else {
|
11160 | return this._monthsShortRegex;
|
11161 | }
|
11162 | } else {
|
11163 | if (!hasOwnProp(this, '_monthsShortRegex')) {
|
11164 | this._monthsShortRegex = defaultMonthsShortRegex;
|
11165 | }
|
11166 |
|
11167 | return this._monthsShortStrictRegex && isStrict ? this._monthsShortStrictRegex : this._monthsShortRegex;
|
11168 | }
|
11169 | }
|
11170 |
|
11171 | var defaultMonthsRegex = matchWord;
|
11172 |
|
11173 | function monthsRegex(isStrict) {
|
11174 | if (this._monthsParseExact) {
|
11175 | if (!hasOwnProp(this, '_monthsRegex')) {
|
11176 | computeMonthsParse.call(this);
|
11177 | }
|
11178 |
|
11179 | if (isStrict) {
|
11180 | return this._monthsStrictRegex;
|
11181 | } else {
|
11182 | return this._monthsRegex;
|
11183 | }
|
11184 | } else {
|
11185 | if (!hasOwnProp(this, '_monthsRegex')) {
|
11186 | this._monthsRegex = defaultMonthsRegex;
|
11187 | }
|
11188 |
|
11189 | return this._monthsStrictRegex && isStrict ? this._monthsStrictRegex : this._monthsRegex;
|
11190 | }
|
11191 | }
|
11192 |
|
11193 | function computeMonthsParse() {
|
11194 | function cmpLenRev(a, b) {
|
11195 | return b.length - a.length;
|
11196 | }
|
11197 |
|
11198 | var shortPieces = [],
|
11199 | longPieces = [],
|
11200 | mixedPieces = [],
|
11201 | i,
|
11202 | mom;
|
11203 |
|
11204 | for (i = 0; i < 12; i++) {
|
11205 |
|
11206 | mom = createUTC([2000, i]);
|
11207 | shortPieces.push(this.monthsShort(mom, ''));
|
11208 | longPieces.push(this.months(mom, ''));
|
11209 | mixedPieces.push(this.months(mom, ''));
|
11210 | mixedPieces.push(this.monthsShort(mom, ''));
|
11211 | }
|
11212 |
|
11213 |
|
11214 |
|
11215 | shortPieces.sort(cmpLenRev);
|
11216 | longPieces.sort(cmpLenRev);
|
11217 | mixedPieces.sort(cmpLenRev);
|
11218 |
|
11219 | for (i = 0; i < 12; i++) {
|
11220 | shortPieces[i] = regexEscape(shortPieces[i]);
|
11221 | longPieces[i] = regexEscape(longPieces[i]);
|
11222 | }
|
11223 |
|
11224 | for (i = 0; i < 24; i++) {
|
11225 | mixedPieces[i] = regexEscape(mixedPieces[i]);
|
11226 | }
|
11227 |
|
11228 | this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
11229 | this._monthsShortRegex = this._monthsRegex;
|
11230 | this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
11231 | this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
11232 | }
|
11233 |
|
11234 | function createDate(y, m, d, h, M, s, ms) {
|
11235 |
|
11236 |
|
11237 | var date;
|
11238 |
|
11239 | if (y < 100 && y >= 0) {
|
11240 |
|
11241 | date = new Date(y + 400, m, d, h, M, s, ms);
|
11242 |
|
11243 | if (isFinite(date.getFullYear())) {
|
11244 | date.setFullYear(y);
|
11245 | }
|
11246 | } else {
|
11247 | date = new Date(y, m, d, h, M, s, ms);
|
11248 | }
|
11249 |
|
11250 | return date;
|
11251 | }
|
11252 |
|
11253 | function createUTCDate(y) {
|
11254 | var date;
|
11255 |
|
11256 | if (y < 100 && y >= 0) {
|
11257 | var args = Array.prototype.slice.call(arguments);
|
11258 |
|
11259 | args[0] = y + 400;
|
11260 | date = new Date(Date.UTC.apply(null, args));
|
11261 |
|
11262 | if (isFinite(date.getUTCFullYear())) {
|
11263 | date.setUTCFullYear(y);
|
11264 | }
|
11265 | } else {
|
11266 | date = new Date(Date.UTC.apply(null, arguments));
|
11267 | }
|
11268 |
|
11269 | return date;
|
11270 | }
|
11271 |
|
11272 |
|
11273 | function firstWeekOffset(year, dow, doy) {
|
11274 | var
|
11275 | fwd = 7 + dow - doy,
|
11276 |
|
11277 | fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
|
11278 | return -fwdlw + fwd - 1;
|
11279 | }
|
11280 |
|
11281 |
|
11282 | function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
|
11283 | var localWeekday = (7 + weekday - dow) % 7,
|
11284 | weekOffset = firstWeekOffset(year, dow, doy),
|
11285 | dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
|
11286 | resYear,
|
11287 | resDayOfYear;
|
11288 |
|
11289 | if (dayOfYear <= 0) {
|
11290 | resYear = year - 1;
|
11291 | resDayOfYear = daysInYear(resYear) + dayOfYear;
|
11292 | } else if (dayOfYear > daysInYear(year)) {
|
11293 | resYear = year + 1;
|
11294 | resDayOfYear = dayOfYear - daysInYear(year);
|
11295 | } else {
|
11296 | resYear = year;
|
11297 | resDayOfYear = dayOfYear;
|
11298 | }
|
11299 |
|
11300 | return {
|
11301 | year: resYear,
|
11302 | dayOfYear: resDayOfYear
|
11303 | };
|
11304 | }
|
11305 |
|
11306 | function weekOfYear(mom, dow, doy) {
|
11307 | var weekOffset = firstWeekOffset(mom.year(), dow, doy),
|
11308 | week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
|
11309 | resWeek,
|
11310 | resYear;
|
11311 |
|
11312 | if (week < 1) {
|
11313 | resYear = mom.year() - 1;
|
11314 | resWeek = week + weeksInYear(resYear, dow, doy);
|
11315 | } else if (week > weeksInYear(mom.year(), dow, doy)) {
|
11316 | resWeek = week - weeksInYear(mom.year(), dow, doy);
|
11317 | resYear = mom.year() + 1;
|
11318 | } else {
|
11319 | resYear = mom.year();
|
11320 | resWeek = week;
|
11321 | }
|
11322 |
|
11323 | return {
|
11324 | week: resWeek,
|
11325 | year: resYear
|
11326 | };
|
11327 | }
|
11328 |
|
11329 | function weeksInYear(year, dow, doy) {
|
11330 | var weekOffset = firstWeekOffset(year, dow, doy),
|
11331 | weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
|
11332 | return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
|
11333 | }
|
11334 |
|
11335 |
|
11336 | addFormatToken('w', ['ww', 2], 'wo', 'week');
|
11337 | addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
|
11338 |
|
11339 | addUnitAlias('week', 'w');
|
11340 | addUnitAlias('isoWeek', 'W');
|
11341 |
|
11342 | addUnitPriority('week', 5);
|
11343 | addUnitPriority('isoWeek', 5);
|
11344 |
|
11345 | addRegexToken('w', match1to2);
|
11346 | addRegexToken('ww', match1to2, match2);
|
11347 | addRegexToken('W', match1to2);
|
11348 | addRegexToken('WW', match1to2, match2);
|
11349 | addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
|
11350 | week[token.substr(0, 1)] = toInt(input);
|
11351 | });
|
11352 |
|
11353 |
|
11354 | function localeWeek(mom) {
|
11355 | return weekOfYear(mom, this._week.dow, this._week.doy).week;
|
11356 | }
|
11357 |
|
11358 | var defaultLocaleWeek = {
|
11359 | dow: 0,
|
11360 |
|
11361 | doy: 6
|
11362 |
|
11363 | };
|
11364 |
|
11365 | function localeFirstDayOfWeek() {
|
11366 | return this._week.dow;
|
11367 | }
|
11368 |
|
11369 | function localeFirstDayOfYear() {
|
11370 | return this._week.doy;
|
11371 | }
|
11372 |
|
11373 |
|
11374 | function getSetWeek(input) {
|
11375 | var week = this.localeData().week(this);
|
11376 | return input == null ? week : this.add((input - week) * 7, 'd');
|
11377 | }
|
11378 |
|
11379 | function getSetISOWeek(input) {
|
11380 | var week = weekOfYear(this, 1, 4).week;
|
11381 | return input == null ? week : this.add((input - week) * 7, 'd');
|
11382 | }
|
11383 |
|
11384 |
|
11385 | addFormatToken('d', 0, 'do', 'day');
|
11386 | addFormatToken('dd', 0, 0, function (format) {
|
11387 | return this.localeData().weekdaysMin(this, format);
|
11388 | });
|
11389 | addFormatToken('ddd', 0, 0, function (format) {
|
11390 | return this.localeData().weekdaysShort(this, format);
|
11391 | });
|
11392 | addFormatToken('dddd', 0, 0, function (format) {
|
11393 | return this.localeData().weekdays(this, format);
|
11394 | });
|
11395 | addFormatToken('e', 0, 0, 'weekday');
|
11396 | addFormatToken('E', 0, 0, 'isoWeekday');
|
11397 |
|
11398 | addUnitAlias('day', 'd');
|
11399 | addUnitAlias('weekday', 'e');
|
11400 | addUnitAlias('isoWeekday', 'E');
|
11401 |
|
11402 | addUnitPriority('day', 11);
|
11403 | addUnitPriority('weekday', 11);
|
11404 | addUnitPriority('isoWeekday', 11);
|
11405 |
|
11406 | addRegexToken('d', match1to2);
|
11407 | addRegexToken('e', match1to2);
|
11408 | addRegexToken('E', match1to2);
|
11409 | addRegexToken('dd', function (isStrict, locale) {
|
11410 | return locale.weekdaysMinRegex(isStrict);
|
11411 | });
|
11412 | addRegexToken('ddd', function (isStrict, locale) {
|
11413 | return locale.weekdaysShortRegex(isStrict);
|
11414 | });
|
11415 | addRegexToken('dddd', function (isStrict, locale) {
|
11416 | return locale.weekdaysRegex(isStrict);
|
11417 | });
|
11418 | addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
|
11419 | var weekday = config._locale.weekdaysParse(input, token, config._strict);
|
11420 |
|
11421 |
|
11422 | if (weekday != null) {
|
11423 | week.d = weekday;
|
11424 | } else {
|
11425 | getParsingFlags(config).invalidWeekday = input;
|
11426 | }
|
11427 | });
|
11428 | addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
|
11429 | week[token] = toInt(input);
|
11430 | });
|
11431 |
|
11432 | function parseWeekday(input, locale) {
|
11433 | if (typeof input !== 'string') {
|
11434 | return input;
|
11435 | }
|
11436 |
|
11437 | if (!isNaN(input)) {
|
11438 | return parseInt(input, 10);
|
11439 | }
|
11440 |
|
11441 | input = locale.weekdaysParse(input);
|
11442 |
|
11443 | if (typeof input === 'number') {
|
11444 | return input;
|
11445 | }
|
11446 |
|
11447 | return null;
|
11448 | }
|
11449 |
|
11450 | function parseIsoWeekday(input, locale) {
|
11451 | if (typeof input === 'string') {
|
11452 | return locale.weekdaysParse(input) % 7 || 7;
|
11453 | }
|
11454 |
|
11455 | return isNaN(input) ? null : input;
|
11456 | }
|
11457 |
|
11458 |
|
11459 | function shiftWeekdays(ws, n) {
|
11460 | return ws.slice(n, 7).concat(ws.slice(0, n));
|
11461 | }
|
11462 |
|
11463 | var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
|
11464 |
|
11465 | function localeWeekdays(m, format) {
|
11466 | var weekdays = isArray(this._weekdays) ? this._weekdays : this._weekdays[m && m !== true && this._weekdays.isFormat.test(format) ? 'format' : 'standalone'];
|
11467 | return m === true ? shiftWeekdays(weekdays, this._week.dow) : m ? weekdays[m.day()] : weekdays;
|
11468 | }
|
11469 |
|
11470 | var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
|
11471 |
|
11472 | function localeWeekdaysShort(m) {
|
11473 | return m === true ? shiftWeekdays(this._weekdaysShort, this._week.dow) : m ? this._weekdaysShort[m.day()] : this._weekdaysShort;
|
11474 | }
|
11475 |
|
11476 | var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
|
11477 |
|
11478 | function localeWeekdaysMin(m) {
|
11479 | return m === true ? shiftWeekdays(this._weekdaysMin, this._week.dow) : m ? this._weekdaysMin[m.day()] : this._weekdaysMin;
|
11480 | }
|
11481 |
|
11482 | function handleStrictParse$1(weekdayName, format, strict) {
|
11483 | var i,
|
11484 | ii,
|
11485 | mom,
|
11486 | llc = weekdayName.toLocaleLowerCase();
|
11487 |
|
11488 | if (!this._weekdaysParse) {
|
11489 | this._weekdaysParse = [];
|
11490 | this._shortWeekdaysParse = [];
|
11491 | this._minWeekdaysParse = [];
|
11492 |
|
11493 | for (i = 0; i < 7; ++i) {
|
11494 | mom = createUTC([2000, 1]).day(i);
|
11495 | this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
|
11496 | this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
|
11497 | this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
|
11498 | }
|
11499 | }
|
11500 |
|
11501 | if (strict) {
|
11502 | if (format === 'dddd') {
|
11503 | ii = indexOf.call(this._weekdaysParse, llc);
|
11504 | return ii !== -1 ? ii : null;
|
11505 | } else if (format === 'ddd') {
|
11506 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
11507 | return ii !== -1 ? ii : null;
|
11508 | } else {
|
11509 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
11510 | return ii !== -1 ? ii : null;
|
11511 | }
|
11512 | } else {
|
11513 | if (format === 'dddd') {
|
11514 | ii = indexOf.call(this._weekdaysParse, llc);
|
11515 |
|
11516 | if (ii !== -1) {
|
11517 | return ii;
|
11518 | }
|
11519 |
|
11520 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
11521 |
|
11522 | if (ii !== -1) {
|
11523 | return ii;
|
11524 | }
|
11525 |
|
11526 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
11527 | return ii !== -1 ? ii : null;
|
11528 | } else if (format === 'ddd') {
|
11529 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
11530 |
|
11531 | if (ii !== -1) {
|
11532 | return ii;
|
11533 | }
|
11534 |
|
11535 | ii = indexOf.call(this._weekdaysParse, llc);
|
11536 |
|
11537 | if (ii !== -1) {
|
11538 | return ii;
|
11539 | }
|
11540 |
|
11541 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
11542 | return ii !== -1 ? ii : null;
|
11543 | } else {
|
11544 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
11545 |
|
11546 | if (ii !== -1) {
|
11547 | return ii;
|
11548 | }
|
11549 |
|
11550 | ii = indexOf.call(this._weekdaysParse, llc);
|
11551 |
|
11552 | if (ii !== -1) {
|
11553 | return ii;
|
11554 | }
|
11555 |
|
11556 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
11557 | return ii !== -1 ? ii : null;
|
11558 | }
|
11559 | }
|
11560 | }
|
11561 |
|
11562 | function localeWeekdaysParse(weekdayName, format, strict) {
|
11563 | var i, mom, regex;
|
11564 |
|
11565 | if (this._weekdaysParseExact) {
|
11566 | return handleStrictParse$1.call(this, weekdayName, format, strict);
|
11567 | }
|
11568 |
|
11569 | if (!this._weekdaysParse) {
|
11570 | this._weekdaysParse = [];
|
11571 | this._minWeekdaysParse = [];
|
11572 | this._shortWeekdaysParse = [];
|
11573 | this._fullWeekdaysParse = [];
|
11574 | }
|
11575 |
|
11576 | for (i = 0; i < 7; i++) {
|
11577 |
|
11578 | mom = createUTC([2000, 1]).day(i);
|
11579 |
|
11580 | if (strict && !this._fullWeekdaysParse[i]) {
|
11581 | this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i');
|
11582 | this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i');
|
11583 | this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i');
|
11584 | }
|
11585 |
|
11586 | if (!this._weekdaysParse[i]) {
|
11587 | regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
|
11588 | this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
11589 | }
|
11590 |
|
11591 |
|
11592 | if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
|
11593 | return i;
|
11594 | } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
|
11595 | return i;
|
11596 | } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
|
11597 | return i;
|
11598 | } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
|
11599 | return i;
|
11600 | }
|
11601 | }
|
11602 | }
|
11603 |
|
11604 |
|
11605 | function getSetDayOfWeek(input) {
|
11606 | if (!this.isValid()) {
|
11607 | return input != null ? this : NaN;
|
11608 | }
|
11609 |
|
11610 | var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
|
11611 |
|
11612 | if (input != null) {
|
11613 | input = parseWeekday(input, this.localeData());
|
11614 | return this.add(input - day, 'd');
|
11615 | } else {
|
11616 | return day;
|
11617 | }
|
11618 | }
|
11619 |
|
11620 | function getSetLocaleDayOfWeek(input) {
|
11621 | if (!this.isValid()) {
|
11622 | return input != null ? this : NaN;
|
11623 | }
|
11624 |
|
11625 | var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
|
11626 | return input == null ? weekday : this.add(input - weekday, 'd');
|
11627 | }
|
11628 |
|
11629 | function getSetISODayOfWeek(input) {
|
11630 | if (!this.isValid()) {
|
11631 | return input != null ? this : NaN;
|
11632 | }
|
11633 |
|
11634 |
|
11635 |
|
11636 |
|
11637 | if (input != null) {
|
11638 | var weekday = parseIsoWeekday(input, this.localeData());
|
11639 | return this.day(this.day() % 7 ? weekday : weekday - 7);
|
11640 | } else {
|
11641 | return this.day() || 7;
|
11642 | }
|
11643 | }
|
11644 |
|
11645 | var defaultWeekdaysRegex = matchWord;
|
11646 |
|
11647 | function weekdaysRegex(isStrict) {
|
11648 | if (this._weekdaysParseExact) {
|
11649 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
11650 | computeWeekdaysParse.call(this);
|
11651 | }
|
11652 |
|
11653 | if (isStrict) {
|
11654 | return this._weekdaysStrictRegex;
|
11655 | } else {
|
11656 | return this._weekdaysRegex;
|
11657 | }
|
11658 | } else {
|
11659 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
11660 | this._weekdaysRegex = defaultWeekdaysRegex;
|
11661 | }
|
11662 |
|
11663 | return this._weekdaysStrictRegex && isStrict ? this._weekdaysStrictRegex : this._weekdaysRegex;
|
11664 | }
|
11665 | }
|
11666 |
|
11667 | var defaultWeekdaysShortRegex = matchWord;
|
11668 |
|
11669 | function weekdaysShortRegex(isStrict) {
|
11670 | if (this._weekdaysParseExact) {
|
11671 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
11672 | computeWeekdaysParse.call(this);
|
11673 | }
|
11674 |
|
11675 | if (isStrict) {
|
11676 | return this._weekdaysShortStrictRegex;
|
11677 | } else {
|
11678 | return this._weekdaysShortRegex;
|
11679 | }
|
11680 | } else {
|
11681 | if (!hasOwnProp(this, '_weekdaysShortRegex')) {
|
11682 | this._weekdaysShortRegex = defaultWeekdaysShortRegex;
|
11683 | }
|
11684 |
|
11685 | return this._weekdaysShortStrictRegex && isStrict ? this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
|
11686 | }
|
11687 | }
|
11688 |
|
11689 | var defaultWeekdaysMinRegex = matchWord;
|
11690 |
|
11691 | function weekdaysMinRegex(isStrict) {
|
11692 | if (this._weekdaysParseExact) {
|
11693 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
11694 | computeWeekdaysParse.call(this);
|
11695 | }
|
11696 |
|
11697 | if (isStrict) {
|
11698 | return this._weekdaysMinStrictRegex;
|
11699 | } else {
|
11700 | return this._weekdaysMinRegex;
|
11701 | }
|
11702 | } else {
|
11703 | if (!hasOwnProp(this, '_weekdaysMinRegex')) {
|
11704 | this._weekdaysMinRegex = defaultWeekdaysMinRegex;
|
11705 | }
|
11706 |
|
11707 | return this._weekdaysMinStrictRegex && isStrict ? this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
|
11708 | }
|
11709 | }
|
11710 |
|
11711 | function computeWeekdaysParse() {
|
11712 | function cmpLenRev(a, b) {
|
11713 | return b.length - a.length;
|
11714 | }
|
11715 |
|
11716 | var minPieces = [],
|
11717 | shortPieces = [],
|
11718 | longPieces = [],
|
11719 | mixedPieces = [],
|
11720 | i,
|
11721 | mom,
|
11722 | minp,
|
11723 | shortp,
|
11724 | longp;
|
11725 |
|
11726 | for (i = 0; i < 7; i++) {
|
11727 |
|
11728 | mom = createUTC([2000, 1]).day(i);
|
11729 | minp = this.weekdaysMin(mom, '');
|
11730 | shortp = this.weekdaysShort(mom, '');
|
11731 | longp = this.weekdays(mom, '');
|
11732 | minPieces.push(minp);
|
11733 | shortPieces.push(shortp);
|
11734 | longPieces.push(longp);
|
11735 | mixedPieces.push(minp);
|
11736 | mixedPieces.push(shortp);
|
11737 | mixedPieces.push(longp);
|
11738 | }
|
11739 |
|
11740 |
|
11741 |
|
11742 | minPieces.sort(cmpLenRev);
|
11743 | shortPieces.sort(cmpLenRev);
|
11744 | longPieces.sort(cmpLenRev);
|
11745 | mixedPieces.sort(cmpLenRev);
|
11746 |
|
11747 | for (i = 0; i < 7; i++) {
|
11748 | shortPieces[i] = regexEscape(shortPieces[i]);
|
11749 | longPieces[i] = regexEscape(longPieces[i]);
|
11750 | mixedPieces[i] = regexEscape(mixedPieces[i]);
|
11751 | }
|
11752 |
|
11753 | this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
11754 | this._weekdaysShortRegex = this._weekdaysRegex;
|
11755 | this._weekdaysMinRegex = this._weekdaysRegex;
|
11756 | this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
11757 | this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
11758 | this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
|
11759 | }
|
11760 |
|
11761 |
|
11762 | function hFormat() {
|
11763 | return this.hours() % 12 || 12;
|
11764 | }
|
11765 |
|
11766 | function kFormat() {
|
11767 | return this.hours() || 24;
|
11768 | }
|
11769 |
|
11770 | addFormatToken('H', ['HH', 2], 0, 'hour');
|
11771 | addFormatToken('h', ['hh', 2], 0, hFormat);
|
11772 | addFormatToken('k', ['kk', 2], 0, kFormat);
|
11773 | addFormatToken('hmm', 0, 0, function () {
|
11774 | return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
|
11775 | });
|
11776 | addFormatToken('hmmss', 0, 0, function () {
|
11777 | return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
|
11778 | });
|
11779 | addFormatToken('Hmm', 0, 0, function () {
|
11780 | return '' + this.hours() + zeroFill(this.minutes(), 2);
|
11781 | });
|
11782 | addFormatToken('Hmmss', 0, 0, function () {
|
11783 | return '' + this.hours() + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
|
11784 | });
|
11785 |
|
11786 | function meridiem(token, lowercase) {
|
11787 | addFormatToken(token, 0, 0, function () {
|
11788 | return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
|
11789 | });
|
11790 | }
|
11791 |
|
11792 | meridiem('a', true);
|
11793 | meridiem('A', false);
|
11794 |
|
11795 | addUnitAlias('hour', 'h');
|
11796 |
|
11797 | addUnitPriority('hour', 13);
|
11798 |
|
11799 | function matchMeridiem(isStrict, locale) {
|
11800 | return locale._meridiemParse;
|
11801 | }
|
11802 |
|
11803 | addRegexToken('a', matchMeridiem);
|
11804 | addRegexToken('A', matchMeridiem);
|
11805 | addRegexToken('H', match1to2);
|
11806 | addRegexToken('h', match1to2);
|
11807 | addRegexToken('k', match1to2);
|
11808 | addRegexToken('HH', match1to2, match2);
|
11809 | addRegexToken('hh', match1to2, match2);
|
11810 | addRegexToken('kk', match1to2, match2);
|
11811 | addRegexToken('hmm', match3to4);
|
11812 | addRegexToken('hmmss', match5to6);
|
11813 | addRegexToken('Hmm', match3to4);
|
11814 | addRegexToken('Hmmss', match5to6);
|
11815 | addParseToken(['H', 'HH'], HOUR);
|
11816 | addParseToken(['k', 'kk'], function (input, array, config) {
|
11817 | var kInput = toInt(input);
|
11818 | array[HOUR] = kInput === 24 ? 0 : kInput;
|
11819 | });
|
11820 | addParseToken(['a', 'A'], function (input, array, config) {
|
11821 | config._isPm = config._locale.isPM(input);
|
11822 | config._meridiem = input;
|
11823 | });
|
11824 | addParseToken(['h', 'hh'], function (input, array, config) {
|
11825 | array[HOUR] = toInt(input);
|
11826 | getParsingFlags(config).bigHour = true;
|
11827 | });
|
11828 | addParseToken('hmm', function (input, array, config) {
|
11829 | var pos = input.length - 2;
|
11830 | array[HOUR] = toInt(input.substr(0, pos));
|
11831 | array[MINUTE] = toInt(input.substr(pos));
|
11832 | getParsingFlags(config).bigHour = true;
|
11833 | });
|
11834 | addParseToken('hmmss', function (input, array, config) {
|
11835 | var pos1 = input.length - 4;
|
11836 | var pos2 = input.length - 2;
|
11837 | array[HOUR] = toInt(input.substr(0, pos1));
|
11838 | array[MINUTE] = toInt(input.substr(pos1, 2));
|
11839 | array[SECOND] = toInt(input.substr(pos2));
|
11840 | getParsingFlags(config).bigHour = true;
|
11841 | });
|
11842 | addParseToken('Hmm', function (input, array, config) {
|
11843 | var pos = input.length - 2;
|
11844 | array[HOUR] = toInt(input.substr(0, pos));
|
11845 | array[MINUTE] = toInt(input.substr(pos));
|
11846 | });
|
11847 | addParseToken('Hmmss', function (input, array, config) {
|
11848 | var pos1 = input.length - 4;
|
11849 | var pos2 = input.length - 2;
|
11850 | array[HOUR] = toInt(input.substr(0, pos1));
|
11851 | array[MINUTE] = toInt(input.substr(pos1, 2));
|
11852 | array[SECOND] = toInt(input.substr(pos2));
|
11853 | });
|
11854 |
|
11855 | function localeIsPM(input) {
|
11856 |
|
11857 |
|
11858 | return (input + '').toLowerCase().charAt(0) === 'p';
|
11859 | }
|
11860 |
|
11861 | var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
|
11862 |
|
11863 | function localeMeridiem(hours, minutes, isLower) {
|
11864 | if (hours > 11) {
|
11865 | return isLower ? 'pm' : 'PM';
|
11866 | } else {
|
11867 | return isLower ? 'am' : 'AM';
|
11868 | }
|
11869 | }
|
11870 |
|
11871 |
|
11872 |
|
11873 |
|
11874 |
|
11875 |
|
11876 | var getSetHour = makeGetSet('Hours', true);
|
11877 | var baseConfig = {
|
11878 | calendar: defaultCalendar,
|
11879 | longDateFormat: defaultLongDateFormat,
|
11880 | invalidDate: defaultInvalidDate,
|
11881 | ordinal: defaultOrdinal,
|
11882 | dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
|
11883 | relativeTime: defaultRelativeTime,
|
11884 | months: defaultLocaleMonths,
|
11885 | monthsShort: defaultLocaleMonthsShort,
|
11886 | week: defaultLocaleWeek,
|
11887 | weekdays: defaultLocaleWeekdays,
|
11888 | weekdaysMin: defaultLocaleWeekdaysMin,
|
11889 | weekdaysShort: defaultLocaleWeekdaysShort,
|
11890 | meridiemParse: defaultLocaleMeridiemParse
|
11891 | };
|
11892 |
|
11893 | var locales = {};
|
11894 | var localeFamilies = {};
|
11895 | var globalLocale;
|
11896 |
|
11897 | function normalizeLocale(key) {
|
11898 | return key ? key.toLowerCase().replace('_', '-') : key;
|
11899 | }
|
11900 |
|
11901 |
|
11902 |
|
11903 |
|
11904 | function chooseLocale(names) {
|
11905 | var i = 0,
|
11906 | j,
|
11907 | next,
|
11908 | locale,
|
11909 | split;
|
11910 |
|
11911 | while (i < names.length) {
|
11912 | split = normalizeLocale(names[i]).split('-');
|
11913 | j = split.length;
|
11914 | next = normalizeLocale(names[i + 1]);
|
11915 | next = next ? next.split('-') : null;
|
11916 |
|
11917 | while (j > 0) {
|
11918 | locale = loadLocale(split.slice(0, j).join('-'));
|
11919 |
|
11920 | if (locale) {
|
11921 | return locale;
|
11922 | }
|
11923 |
|
11924 | if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
|
11925 |
|
11926 | break;
|
11927 | }
|
11928 |
|
11929 | j--;
|
11930 | }
|
11931 |
|
11932 | i++;
|
11933 | }
|
11934 |
|
11935 | return globalLocale;
|
11936 | }
|
11937 |
|
11938 | function loadLocale(name) {
|
11939 | var oldLocale = null;
|
11940 |
|
11941 | if (!locales[name] && 'object' !== 'undefined' && module && module.exports) {
|
11942 | try {
|
11943 | oldLocale = globalLocale._abbr;
|
11944 | var aliasedRequire = commonjsRequire$2;
|
11945 | aliasedRequire('./locale/' + name);
|
11946 | getSetGlobalLocale(oldLocale);
|
11947 | } catch (e) {}
|
11948 | }
|
11949 |
|
11950 | return locales[name];
|
11951 | }
|
11952 |
|
11953 |
|
11954 |
|
11955 |
|
11956 | function getSetGlobalLocale(key, values) {
|
11957 | var data;
|
11958 |
|
11959 | if (key) {
|
11960 | if (isUndefined(values)) {
|
11961 | data = getLocale(key);
|
11962 | } else {
|
11963 | data = defineLocale(key, values);
|
11964 | }
|
11965 |
|
11966 | if (data) {
|
11967 |
|
11968 | globalLocale = data;
|
11969 | } else {
|
11970 | if (typeof console !== 'undefined' && console.warn) {
|
11971 |
|
11972 | console.warn('Locale ' + key + ' not found. Did you forget to load it?');
|
11973 | }
|
11974 | }
|
11975 | }
|
11976 |
|
11977 | return globalLocale._abbr;
|
11978 | }
|
11979 |
|
11980 | function defineLocale(name, config) {
|
11981 | if (config !== null) {
|
11982 | var locale,
|
11983 | parentConfig = baseConfig;
|
11984 | config.abbr = name;
|
11985 |
|
11986 | if (locales[name] != null) {
|
11987 | deprecateSimple('defineLocaleOverride', 'use moment.updateLocale(localeName, config) to change ' + 'an existing locale. moment.defineLocale(localeName, ' + 'config) should only be used for creating a new locale ' + 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
|
11988 | parentConfig = locales[name]._config;
|
11989 | } else if (config.parentLocale != null) {
|
11990 | if (locales[config.parentLocale] != null) {
|
11991 | parentConfig = locales[config.parentLocale]._config;
|
11992 | } else {
|
11993 | locale = loadLocale(config.parentLocale);
|
11994 |
|
11995 | if (locale != null) {
|
11996 | parentConfig = locale._config;
|
11997 | } else {
|
11998 | if (!localeFamilies[config.parentLocale]) {
|
11999 | localeFamilies[config.parentLocale] = [];
|
12000 | }
|
12001 |
|
12002 | localeFamilies[config.parentLocale].push({
|
12003 | name: name,
|
12004 | config: config
|
12005 | });
|
12006 | return null;
|
12007 | }
|
12008 | }
|
12009 | }
|
12010 |
|
12011 | locales[name] = new Locale(mergeConfigs(parentConfig, config));
|
12012 |
|
12013 | if (localeFamilies[name]) {
|
12014 | localeFamilies[name].forEach(function (x) {
|
12015 | defineLocale(x.name, x.config);
|
12016 | });
|
12017 | }
|
12018 |
|
12019 |
|
12020 |
|
12021 |
|
12022 | getSetGlobalLocale(name);
|
12023 | return locales[name];
|
12024 | } else {
|
12025 |
|
12026 | delete locales[name];
|
12027 | return null;
|
12028 | }
|
12029 | }
|
12030 |
|
12031 | function updateLocale(name, config) {
|
12032 | if (config != null) {
|
12033 | var locale,
|
12034 | tmpLocale,
|
12035 | parentConfig = baseConfig;
|
12036 |
|
12037 | tmpLocale = loadLocale(name);
|
12038 |
|
12039 | if (tmpLocale != null) {
|
12040 | parentConfig = tmpLocale._config;
|
12041 | }
|
12042 |
|
12043 | config = mergeConfigs(parentConfig, config);
|
12044 | locale = new Locale(config);
|
12045 | locale.parentLocale = locales[name];
|
12046 | locales[name] = locale;
|
12047 |
|
12048 | getSetGlobalLocale(name);
|
12049 | } else {
|
12050 |
|
12051 | if (locales[name] != null) {
|
12052 | if (locales[name].parentLocale != null) {
|
12053 | locales[name] = locales[name].parentLocale;
|
12054 | } else if (locales[name] != null) {
|
12055 | delete locales[name];
|
12056 | }
|
12057 | }
|
12058 | }
|
12059 |
|
12060 | return locales[name];
|
12061 | }
|
12062 |
|
12063 |
|
12064 | function getLocale(key) {
|
12065 | var locale;
|
12066 |
|
12067 | if (key && key._locale && key._locale._abbr) {
|
12068 | key = key._locale._abbr;
|
12069 | }
|
12070 |
|
12071 | if (!key) {
|
12072 | return globalLocale;
|
12073 | }
|
12074 |
|
12075 | if (!isArray(key)) {
|
12076 |
|
12077 | locale = loadLocale(key);
|
12078 |
|
12079 | if (locale) {
|
12080 | return locale;
|
12081 | }
|
12082 |
|
12083 | key = [key];
|
12084 | }
|
12085 |
|
12086 | return chooseLocale(key);
|
12087 | }
|
12088 |
|
12089 | function listLocales() {
|
12090 | return keys(locales);
|
12091 | }
|
12092 |
|
12093 | function checkOverflow(m) {
|
12094 | var overflow;
|
12095 | var a = m._a;
|
12096 |
|
12097 | if (a && getParsingFlags(m).overflow === -2) {
|
12098 | overflow = a[MONTH] < 0 || a[MONTH] > 11 ? MONTH : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE : a[HOUR] < 0 || a[HOUR] > 24 || a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0) ? HOUR : a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE : a[SECOND] < 0 || a[SECOND] > 59 ? SECOND : a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND : -1;
|
12099 |
|
12100 | if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
|
12101 | overflow = DATE;
|
12102 | }
|
12103 |
|
12104 | if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
|
12105 | overflow = WEEK;
|
12106 | }
|
12107 |
|
12108 | if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
|
12109 | overflow = WEEKDAY;
|
12110 | }
|
12111 |
|
12112 | getParsingFlags(m).overflow = overflow;
|
12113 | }
|
12114 |
|
12115 | return m;
|
12116 | }
|
12117 |
|
12118 |
|
12119 | function defaults(a, b, c) {
|
12120 | if (a != null) {
|
12121 | return a;
|
12122 | }
|
12123 |
|
12124 | if (b != null) {
|
12125 | return b;
|
12126 | }
|
12127 |
|
12128 | return c;
|
12129 | }
|
12130 |
|
12131 | function currentDateArray(config) {
|
12132 |
|
12133 | var nowValue = new Date(hooks.now());
|
12134 |
|
12135 | if (config._useUTC) {
|
12136 | return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
|
12137 | }
|
12138 |
|
12139 | return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
|
12140 | }
|
12141 |
|
12142 |
|
12143 |
|
12144 |
|
12145 |
|
12146 | function configFromArray(config) {
|
12147 | var i,
|
12148 | date,
|
12149 | input = [],
|
12150 | currentDate,
|
12151 | expectedWeekday,
|
12152 | yearToUse;
|
12153 |
|
12154 | if (config._d) {
|
12155 | return;
|
12156 | }
|
12157 |
|
12158 | currentDate = currentDateArray(config);
|
12159 |
|
12160 | if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
|
12161 | dayOfYearFromWeekInfo(config);
|
12162 | }
|
12163 |
|
12164 |
|
12165 | if (config._dayOfYear != null) {
|
12166 | yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
|
12167 |
|
12168 | if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
|
12169 | getParsingFlags(config)._overflowDayOfYear = true;
|
12170 | }
|
12171 |
|
12172 | date = createUTCDate(yearToUse, 0, config._dayOfYear);
|
12173 | config._a[MONTH] = date.getUTCMonth();
|
12174 | config._a[DATE] = date.getUTCDate();
|
12175 | }
|
12176 |
|
12177 |
|
12178 |
|
12179 |
|
12180 |
|
12181 |
|
12182 | for (i = 0; i < 3 && config._a[i] == null; ++i) {
|
12183 | config._a[i] = input[i] = currentDate[i];
|
12184 | }
|
12185 |
|
12186 |
|
12187 | for (; i < 7; i++) {
|
12188 | config._a[i] = input[i] = config._a[i] == null ? i === 2 ? 1 : 0 : config._a[i];
|
12189 | }
|
12190 |
|
12191 |
|
12192 | if (config._a[HOUR] === 24 && config._a[MINUTE] === 0 && config._a[SECOND] === 0 && config._a[MILLISECOND] === 0) {
|
12193 | config._nextDay = true;
|
12194 | config._a[HOUR] = 0;
|
12195 | }
|
12196 |
|
12197 | config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
|
12198 | expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
|
12199 |
|
12200 |
|
12201 | if (config._tzm != null) {
|
12202 | config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
12203 | }
|
12204 |
|
12205 | if (config._nextDay) {
|
12206 | config._a[HOUR] = 24;
|
12207 | }
|
12208 |
|
12209 |
|
12210 | if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
|
12211 | getParsingFlags(config).weekdayMismatch = true;
|
12212 | }
|
12213 | }
|
12214 |
|
12215 | function dayOfYearFromWeekInfo(config) {
|
12216 | var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
|
12217 | w = config._w;
|
12218 |
|
12219 | if (w.GG != null || w.W != null || w.E != null) {
|
12220 | dow = 1;
|
12221 | doy = 4;
|
12222 |
|
12223 |
|
12224 |
|
12225 |
|
12226 | weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
|
12227 | week = defaults(w.W, 1);
|
12228 | weekday = defaults(w.E, 1);
|
12229 |
|
12230 | if (weekday < 1 || weekday > 7) {
|
12231 | weekdayOverflow = true;
|
12232 | }
|
12233 | } else {
|
12234 | dow = config._locale._week.dow;
|
12235 | doy = config._locale._week.doy;
|
12236 | var curWeek = weekOfYear(createLocal(), dow, doy);
|
12237 | weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
|
12238 |
|
12239 | week = defaults(w.w, curWeek.week);
|
12240 |
|
12241 | if (w.d != null) {
|
12242 |
|
12243 | weekday = w.d;
|
12244 |
|
12245 | if (weekday < 0 || weekday > 6) {
|
12246 | weekdayOverflow = true;
|
12247 | }
|
12248 | } else if (w.e != null) {
|
12249 |
|
12250 | weekday = w.e + dow;
|
12251 |
|
12252 | if (w.e < 0 || w.e > 6) {
|
12253 | weekdayOverflow = true;
|
12254 | }
|
12255 | } else {
|
12256 |
|
12257 | weekday = dow;
|
12258 | }
|
12259 | }
|
12260 |
|
12261 | if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
|
12262 | getParsingFlags(config)._overflowWeeks = true;
|
12263 | } else if (weekdayOverflow != null) {
|
12264 | getParsingFlags(config)._overflowWeekday = true;
|
12265 | } else {
|
12266 | temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
|
12267 | config._a[YEAR] = temp.year;
|
12268 | config._dayOfYear = temp.dayOfYear;
|
12269 | }
|
12270 | }
|
12271 |
|
12272 |
|
12273 |
|
12274 | 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)?)?$/;
|
12275 | 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)?)?$/;
|
12276 | var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
|
12277 | var isoDates = [['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], ['GGGG-[W]WW', /\d{4}-W\d\d/, false], ['YYYY-DDD', /\d{4}-\d{3}/], ['YYYY-MM', /\d{4}-\d\d/, false], ['YYYYYYMMDD', /[+-]\d{10}/], ['YYYYMMDD', /\d{8}/],
|
12278 | ['GGGG[W]WWE', /\d{4}W\d{3}/], ['GGGG[W]WW', /\d{4}W\d{2}/, false], ['YYYYDDD', /\d{7}/]];
|
12279 |
|
12280 | var isoTimes = [['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], ['HH:mm:ss', /\d\d:\d\d:\d\d/], ['HH:mm', /\d\d:\d\d/], ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], ['HHmmss', /\d\d\d\d\d\d/], ['HHmm', /\d\d\d\d/], ['HH', /\d\d/]];
|
12281 | var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
|
12282 |
|
12283 | function configFromISO(config) {
|
12284 | var i,
|
12285 | l,
|
12286 | string = config._i,
|
12287 | match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
|
12288 | allowTime,
|
12289 | dateFormat,
|
12290 | timeFormat,
|
12291 | tzFormat;
|
12292 |
|
12293 | if (match) {
|
12294 | getParsingFlags(config).iso = true;
|
12295 |
|
12296 | for (i = 0, l = isoDates.length; i < l; i++) {
|
12297 | if (isoDates[i][1].exec(match[1])) {
|
12298 | dateFormat = isoDates[i][0];
|
12299 | allowTime = isoDates[i][2] !== false;
|
12300 | break;
|
12301 | }
|
12302 | }
|
12303 |
|
12304 | if (dateFormat == null) {
|
12305 | config._isValid = false;
|
12306 | return;
|
12307 | }
|
12308 |
|
12309 | if (match[3]) {
|
12310 | for (i = 0, l = isoTimes.length; i < l; i++) {
|
12311 | if (isoTimes[i][1].exec(match[3])) {
|
12312 |
|
12313 | timeFormat = (match[2] || ' ') + isoTimes[i][0];
|
12314 | break;
|
12315 | }
|
12316 | }
|
12317 |
|
12318 | if (timeFormat == null) {
|
12319 | config._isValid = false;
|
12320 | return;
|
12321 | }
|
12322 | }
|
12323 |
|
12324 | if (!allowTime && timeFormat != null) {
|
12325 | config._isValid = false;
|
12326 | return;
|
12327 | }
|
12328 |
|
12329 | if (match[4]) {
|
12330 | if (tzRegex.exec(match[4])) {
|
12331 | tzFormat = 'Z';
|
12332 | } else {
|
12333 | config._isValid = false;
|
12334 | return;
|
12335 | }
|
12336 | }
|
12337 |
|
12338 | config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
|
12339 | configFromStringAndFormat(config);
|
12340 | } else {
|
12341 | config._isValid = false;
|
12342 | }
|
12343 | }
|
12344 |
|
12345 |
|
12346 | var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;
|
12347 |
|
12348 | function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
|
12349 | var result = [untruncateYear(yearStr), defaultLocaleMonthsShort.indexOf(monthStr), parseInt(dayStr, 10), parseInt(hourStr, 10), parseInt(minuteStr, 10)];
|
12350 |
|
12351 | if (secondStr) {
|
12352 | result.push(parseInt(secondStr, 10));
|
12353 | }
|
12354 |
|
12355 | return result;
|
12356 | }
|
12357 |
|
12358 | function untruncateYear(yearStr) {
|
12359 | var year = parseInt(yearStr, 10);
|
12360 |
|
12361 | if (year <= 49) {
|
12362 | return 2000 + year;
|
12363 | } else if (year <= 999) {
|
12364 | return 1900 + year;
|
12365 | }
|
12366 |
|
12367 | return year;
|
12368 | }
|
12369 |
|
12370 | function preprocessRFC2822(s) {
|
12371 |
|
12372 | return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
12373 | }
|
12374 |
|
12375 | function checkWeekday(weekdayStr, parsedInput, config) {
|
12376 | if (weekdayStr) {
|
12377 |
|
12378 | var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
|
12379 | weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
|
12380 |
|
12381 | if (weekdayProvided !== weekdayActual) {
|
12382 | getParsingFlags(config).weekdayMismatch = true;
|
12383 | config._isValid = false;
|
12384 | return false;
|
12385 | }
|
12386 | }
|
12387 |
|
12388 | return true;
|
12389 | }
|
12390 |
|
12391 | var obsOffsets = {
|
12392 | UT: 0,
|
12393 | GMT: 0,
|
12394 | EDT: -4 * 60,
|
12395 | EST: -5 * 60,
|
12396 | CDT: -5 * 60,
|
12397 | CST: -6 * 60,
|
12398 | MDT: -6 * 60,
|
12399 | MST: -7 * 60,
|
12400 | PDT: -7 * 60,
|
12401 | PST: -8 * 60
|
12402 | };
|
12403 |
|
12404 | function calculateOffset(obsOffset, militaryOffset, numOffset) {
|
12405 | if (obsOffset) {
|
12406 | return obsOffsets[obsOffset];
|
12407 | } else if (militaryOffset) {
|
12408 |
|
12409 | return 0;
|
12410 | } else {
|
12411 | var hm = parseInt(numOffset, 10);
|
12412 | var m = hm % 100,
|
12413 | h = (hm - m) / 100;
|
12414 | return h * 60 + m;
|
12415 | }
|
12416 | }
|
12417 |
|
12418 |
|
12419 | function configFromRFC2822(config) {
|
12420 | var match = rfc2822.exec(preprocessRFC2822(config._i));
|
12421 |
|
12422 | if (match) {
|
12423 | var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
|
12424 |
|
12425 | if (!checkWeekday(match[1], parsedArray, config)) {
|
12426 | return;
|
12427 | }
|
12428 |
|
12429 | config._a = parsedArray;
|
12430 | config._tzm = calculateOffset(match[8], match[9], match[10]);
|
12431 | config._d = createUTCDate.apply(null, config._a);
|
12432 |
|
12433 | config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
12434 |
|
12435 | getParsingFlags(config).rfc2822 = true;
|
12436 | } else {
|
12437 | config._isValid = false;
|
12438 | }
|
12439 | }
|
12440 |
|
12441 |
|
12442 | function configFromString(config) {
|
12443 | var matched = aspNetJsonRegex.exec(config._i);
|
12444 |
|
12445 | if (matched !== null) {
|
12446 | config._d = new Date(+matched[1]);
|
12447 | return;
|
12448 | }
|
12449 |
|
12450 | configFromISO(config);
|
12451 |
|
12452 | if (config._isValid === false) {
|
12453 | delete config._isValid;
|
12454 | } else {
|
12455 | return;
|
12456 | }
|
12457 |
|
12458 | configFromRFC2822(config);
|
12459 |
|
12460 | if (config._isValid === false) {
|
12461 | delete config._isValid;
|
12462 | } else {
|
12463 | return;
|
12464 | }
|
12465 |
|
12466 |
|
12467 | hooks.createFromInputFallback(config);
|
12468 | }
|
12469 |
|
12470 | hooks.createFromInputFallback = deprecate('value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' + 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' + 'discouraged and will be removed in an upcoming major release. Please refer to ' + 'http://momentjs.com/guides/#/warnings/js-date/ for more info.', function (config) {
|
12471 | config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
|
12472 | });
|
12473 |
|
12474 | hooks.ISO_8601 = function () {};
|
12475 |
|
12476 |
|
12477 | hooks.RFC_2822 = function () {};
|
12478 |
|
12479 |
|
12480 | function configFromStringAndFormat(config) {
|
12481 |
|
12482 | if (config._f === hooks.ISO_8601) {
|
12483 | configFromISO(config);
|
12484 | return;
|
12485 | }
|
12486 |
|
12487 | if (config._f === hooks.RFC_2822) {
|
12488 | configFromRFC2822(config);
|
12489 | return;
|
12490 | }
|
12491 |
|
12492 | config._a = [];
|
12493 | getParsingFlags(config).empty = true;
|
12494 |
|
12495 | var string = '' + config._i,
|
12496 | i,
|
12497 | parsedInput,
|
12498 | tokens,
|
12499 | token,
|
12500 | skipped,
|
12501 | stringLength = string.length,
|
12502 | totalParsedInputLength = 0;
|
12503 | tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
|
12504 |
|
12505 | for (i = 0; i < tokens.length; i++) {
|
12506 | token = tokens[i];
|
12507 | parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
|
12508 |
|
12509 |
|
12510 | if (parsedInput) {
|
12511 | skipped = string.substr(0, string.indexOf(parsedInput));
|
12512 |
|
12513 | if (skipped.length > 0) {
|
12514 | getParsingFlags(config).unusedInput.push(skipped);
|
12515 | }
|
12516 |
|
12517 | string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
|
12518 | totalParsedInputLength += parsedInput.length;
|
12519 | }
|
12520 |
|
12521 |
|
12522 | if (formatTokenFunctions[token]) {
|
12523 | if (parsedInput) {
|
12524 | getParsingFlags(config).empty = false;
|
12525 | } else {
|
12526 | getParsingFlags(config).unusedTokens.push(token);
|
12527 | }
|
12528 |
|
12529 | addTimeToArrayFromToken(token, parsedInput, config);
|
12530 | } else if (config._strict && !parsedInput) {
|
12531 | getParsingFlags(config).unusedTokens.push(token);
|
12532 | }
|
12533 | }
|
12534 |
|
12535 |
|
12536 | getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
|
12537 |
|
12538 | if (string.length > 0) {
|
12539 | getParsingFlags(config).unusedInput.push(string);
|
12540 | }
|
12541 |
|
12542 |
|
12543 | if (config._a[HOUR] <= 12 && getParsingFlags(config).bigHour === true && config._a[HOUR] > 0) {
|
12544 | getParsingFlags(config).bigHour = undefined;
|
12545 | }
|
12546 |
|
12547 | getParsingFlags(config).parsedDateParts = config._a.slice(0);
|
12548 | getParsingFlags(config).meridiem = config._meridiem;
|
12549 |
|
12550 | config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
12551 | configFromArray(config);
|
12552 | checkOverflow(config);
|
12553 | }
|
12554 |
|
12555 | function meridiemFixWrap(locale, hour, meridiem) {
|
12556 | var isPm;
|
12557 |
|
12558 | if (meridiem == null) {
|
12559 |
|
12560 | return hour;
|
12561 | }
|
12562 |
|
12563 | if (locale.meridiemHour != null) {
|
12564 | return locale.meridiemHour(hour, meridiem);
|
12565 | } else if (locale.isPM != null) {
|
12566 |
|
12567 | isPm = locale.isPM(meridiem);
|
12568 |
|
12569 | if (isPm && hour < 12) {
|
12570 | hour += 12;
|
12571 | }
|
12572 |
|
12573 | if (!isPm && hour === 12) {
|
12574 | hour = 0;
|
12575 | }
|
12576 |
|
12577 | return hour;
|
12578 | } else {
|
12579 |
|
12580 | return hour;
|
12581 | }
|
12582 | }
|
12583 |
|
12584 |
|
12585 | function configFromStringAndArray(config) {
|
12586 | var tempConfig, bestMoment, scoreToBeat, i, currentScore;
|
12587 |
|
12588 | if (config._f.length === 0) {
|
12589 | getParsingFlags(config).invalidFormat = true;
|
12590 | config._d = new Date(NaN);
|
12591 | return;
|
12592 | }
|
12593 |
|
12594 | for (i = 0; i < config._f.length; i++) {
|
12595 | currentScore = 0;
|
12596 | tempConfig = copyConfig({}, config);
|
12597 |
|
12598 | if (config._useUTC != null) {
|
12599 | tempConfig._useUTC = config._useUTC;
|
12600 | }
|
12601 |
|
12602 | tempConfig._f = config._f[i];
|
12603 | configFromStringAndFormat(tempConfig);
|
12604 |
|
12605 | if (!isValid(tempConfig)) {
|
12606 | continue;
|
12607 | }
|
12608 |
|
12609 |
|
12610 | currentScore += getParsingFlags(tempConfig).charsLeftOver;
|
12611 |
|
12612 | currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
|
12613 | getParsingFlags(tempConfig).score = currentScore;
|
12614 |
|
12615 | if (scoreToBeat == null || currentScore < scoreToBeat) {
|
12616 | scoreToBeat = currentScore;
|
12617 | bestMoment = tempConfig;
|
12618 | }
|
12619 | }
|
12620 |
|
12621 | extend(config, bestMoment || tempConfig);
|
12622 | }
|
12623 |
|
12624 | function configFromObject(config) {
|
12625 | if (config._d) {
|
12626 | return;
|
12627 | }
|
12628 |
|
12629 | var i = normalizeObjectUnits(config._i);
|
12630 | config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
|
12631 | return obj && parseInt(obj, 10);
|
12632 | });
|
12633 | configFromArray(config);
|
12634 | }
|
12635 |
|
12636 | function createFromConfig(config) {
|
12637 | var res = new Moment(checkOverflow(prepareConfig(config)));
|
12638 |
|
12639 | if (res._nextDay) {
|
12640 |
|
12641 | res.add(1, 'd');
|
12642 | res._nextDay = undefined;
|
12643 | }
|
12644 |
|
12645 | return res;
|
12646 | }
|
12647 |
|
12648 | function prepareConfig(config) {
|
12649 | var input = config._i,
|
12650 | format = config._f;
|
12651 | config._locale = config._locale || getLocale(config._l);
|
12652 |
|
12653 | if (input === null || format === undefined && input === '') {
|
12654 | return createInvalid({
|
12655 | nullInput: true
|
12656 | });
|
12657 | }
|
12658 |
|
12659 | if (typeof input === 'string') {
|
12660 | config._i = input = config._locale.preparse(input);
|
12661 | }
|
12662 |
|
12663 | if (isMoment(input)) {
|
12664 | return new Moment(checkOverflow(input));
|
12665 | } else if (isDate(input)) {
|
12666 | config._d = input;
|
12667 | } else if (isArray(format)) {
|
12668 | configFromStringAndArray(config);
|
12669 | } else if (format) {
|
12670 | configFromStringAndFormat(config);
|
12671 | } else {
|
12672 | configFromInput(config);
|
12673 | }
|
12674 |
|
12675 | if (!isValid(config)) {
|
12676 | config._d = null;
|
12677 | }
|
12678 |
|
12679 | return config;
|
12680 | }
|
12681 |
|
12682 | function configFromInput(config) {
|
12683 | var input = config._i;
|
12684 |
|
12685 | if (isUndefined(input)) {
|
12686 | config._d = new Date(hooks.now());
|
12687 | } else if (isDate(input)) {
|
12688 | config._d = new Date(input.valueOf());
|
12689 | } else if (typeof input === 'string') {
|
12690 | configFromString(config);
|
12691 | } else if (isArray(input)) {
|
12692 | config._a = map(input.slice(0), function (obj) {
|
12693 | return parseInt(obj, 10);
|
12694 | });
|
12695 | configFromArray(config);
|
12696 | } else if (isObject(input)) {
|
12697 | configFromObject(config);
|
12698 | } else if (isNumber(input)) {
|
12699 |
|
12700 | config._d = new Date(input);
|
12701 | } else {
|
12702 | hooks.createFromInputFallback(config);
|
12703 | }
|
12704 | }
|
12705 |
|
12706 | function createLocalOrUTC(input, format, locale, strict, isUTC) {
|
12707 | var c = {};
|
12708 |
|
12709 | if (locale === true || locale === false) {
|
12710 | strict = locale;
|
12711 | locale = undefined;
|
12712 | }
|
12713 |
|
12714 | if (isObject(input) && isObjectEmpty(input) || isArray(input) && input.length === 0) {
|
12715 | input = undefined;
|
12716 | }
|
12717 |
|
12718 |
|
12719 |
|
12720 | c._isAMomentObject = true;
|
12721 | c._useUTC = c._isUTC = isUTC;
|
12722 | c._l = locale;
|
12723 | c._i = input;
|
12724 | c._f = format;
|
12725 | c._strict = strict;
|
12726 | return createFromConfig(c);
|
12727 | }
|
12728 |
|
12729 | function createLocal(input, format, locale, strict) {
|
12730 | return createLocalOrUTC(input, format, locale, strict, false);
|
12731 | }
|
12732 |
|
12733 | var prototypeMin = deprecate('moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/', function () {
|
12734 | var other = createLocal.apply(null, arguments);
|
12735 |
|
12736 | if (this.isValid() && other.isValid()) {
|
12737 | return other < this ? this : other;
|
12738 | } else {
|
12739 | return createInvalid();
|
12740 | }
|
12741 | });
|
12742 | var prototypeMax = deprecate('moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', function () {
|
12743 | var other = createLocal.apply(null, arguments);
|
12744 |
|
12745 | if (this.isValid() && other.isValid()) {
|
12746 | return other > this ? this : other;
|
12747 | } else {
|
12748 | return createInvalid();
|
12749 | }
|
12750 | });
|
12751 |
|
12752 |
|
12753 |
|
12754 |
|
12755 |
|
12756 | function pickBy(fn, moments) {
|
12757 | var res, i;
|
12758 |
|
12759 | if (moments.length === 1 && isArray(moments[0])) {
|
12760 | moments = moments[0];
|
12761 | }
|
12762 |
|
12763 | if (!moments.length) {
|
12764 | return createLocal();
|
12765 | }
|
12766 |
|
12767 | res = moments[0];
|
12768 |
|
12769 | for (i = 1; i < moments.length; ++i) {
|
12770 | if (!moments[i].isValid() || moments[i][fn](res)) {
|
12771 | res = moments[i];
|
12772 | }
|
12773 | }
|
12774 |
|
12775 | return res;
|
12776 | }
|
12777 |
|
12778 |
|
12779 | function min() {
|
12780 | var args = [].slice.call(arguments, 0);
|
12781 | return pickBy('isBefore', args);
|
12782 | }
|
12783 |
|
12784 | function max() {
|
12785 | var args = [].slice.call(arguments, 0);
|
12786 | return pickBy('isAfter', args);
|
12787 | }
|
12788 |
|
12789 | var now = function () {
|
12790 | return Date.now ? Date.now() : +new Date();
|
12791 | };
|
12792 |
|
12793 | var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
|
12794 |
|
12795 | function isDurationValid(m) {
|
12796 | for (var key in m) {
|
12797 | if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
|
12798 | return false;
|
12799 | }
|
12800 | }
|
12801 |
|
12802 | var unitHasDecimal = false;
|
12803 |
|
12804 | for (var i = 0; i < ordering.length; ++i) {
|
12805 | if (m[ordering[i]]) {
|
12806 | if (unitHasDecimal) {
|
12807 | return false;
|
12808 | }
|
12809 |
|
12810 | if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
|
12811 | unitHasDecimal = true;
|
12812 | }
|
12813 | }
|
12814 | }
|
12815 |
|
12816 | return true;
|
12817 | }
|
12818 |
|
12819 | function isValid$1() {
|
12820 | return this._isValid;
|
12821 | }
|
12822 |
|
12823 | function createInvalid$1() {
|
12824 | return createDuration(NaN);
|
12825 | }
|
12826 |
|
12827 | function Duration(duration) {
|
12828 | var normalizedInput = normalizeObjectUnits(duration),
|
12829 | years = normalizedInput.year || 0,
|
12830 | quarters = normalizedInput.quarter || 0,
|
12831 | months = normalizedInput.month || 0,
|
12832 | weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
|
12833 | days = normalizedInput.day || 0,
|
12834 | hours = normalizedInput.hour || 0,
|
12835 | minutes = normalizedInput.minute || 0,
|
12836 | seconds = normalizedInput.second || 0,
|
12837 | milliseconds = normalizedInput.millisecond || 0;
|
12838 | this._isValid = isDurationValid(normalizedInput);
|
12839 |
|
12840 | this._milliseconds = +milliseconds + seconds * 1e3 +
|
12841 | minutes * 6e4 +
|
12842 | hours * 1000 * 60 * 60;
|
12843 |
|
12844 |
|
12845 |
|
12846 | this._days = +days + weeks * 7;
|
12847 |
|
12848 |
|
12849 |
|
12850 | this._months = +months + quarters * 3 + years * 12;
|
12851 | this._data = {};
|
12852 | this._locale = getLocale();
|
12853 |
|
12854 | this._bubble();
|
12855 | }
|
12856 |
|
12857 | function isDuration(obj) {
|
12858 | return obj instanceof Duration;
|
12859 | }
|
12860 |
|
12861 | function absRound(number) {
|
12862 | if (number < 0) {
|
12863 | return Math.round(-1 * number) * -1;
|
12864 | } else {
|
12865 | return Math.round(number);
|
12866 | }
|
12867 | }
|
12868 |
|
12869 |
|
12870 | function offset(token, separator) {
|
12871 | addFormatToken(token, 0, 0, function () {
|
12872 | var offset = this.utcOffset();
|
12873 | var sign = '+';
|
12874 |
|
12875 | if (offset < 0) {
|
12876 | offset = -offset;
|
12877 | sign = '-';
|
12878 | }
|
12879 |
|
12880 | return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~offset % 60, 2);
|
12881 | });
|
12882 | }
|
12883 |
|
12884 | offset('Z', ':');
|
12885 | offset('ZZ', '');
|
12886 |
|
12887 | addRegexToken('Z', matchShortOffset);
|
12888 | addRegexToken('ZZ', matchShortOffset);
|
12889 | addParseToken(['Z', 'ZZ'], function (input, array, config) {
|
12890 | config._useUTC = true;
|
12891 | config._tzm = offsetFromString(matchShortOffset, input);
|
12892 | });
|
12893 |
|
12894 |
|
12895 |
|
12896 |
|
12897 | var chunkOffset = /([\+\-]|\d\d)/gi;
|
12898 |
|
12899 | function offsetFromString(matcher, string) {
|
12900 | var matches = (string || '').match(matcher);
|
12901 |
|
12902 | if (matches === null) {
|
12903 | return null;
|
12904 | }
|
12905 |
|
12906 | var chunk = matches[matches.length - 1] || [];
|
12907 | var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
|
12908 | var minutes = +(parts[1] * 60) + toInt(parts[2]);
|
12909 | return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
|
12910 | }
|
12911 |
|
12912 |
|
12913 | function cloneWithOffset(input, model) {
|
12914 | var res, diff;
|
12915 |
|
12916 | if (model._isUTC) {
|
12917 | res = model.clone();
|
12918 | diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
|
12919 |
|
12920 | res._d.setTime(res._d.valueOf() + diff);
|
12921 |
|
12922 | hooks.updateOffset(res, false);
|
12923 | return res;
|
12924 | } else {
|
12925 | return createLocal(input).local();
|
12926 | }
|
12927 | }
|
12928 |
|
12929 | function getDateOffset(m) {
|
12930 |
|
12931 |
|
12932 | return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
|
12933 | }
|
12934 |
|
12935 |
|
12936 |
|
12937 |
|
12938 | hooks.updateOffset = function () {};
|
12939 |
|
12940 |
|
12941 |
|
12942 |
|
12943 |
|
12944 |
|
12945 |
|
12946 |
|
12947 |
|
12948 |
|
12949 |
|
12950 |
|
12951 | function getSetOffset(input, keepLocalTime, keepMinutes) {
|
12952 | var offset = this._offset || 0,
|
12953 | localAdjust;
|
12954 |
|
12955 | if (!this.isValid()) {
|
12956 | return input != null ? this : NaN;
|
12957 | }
|
12958 |
|
12959 | if (input != null) {
|
12960 | if (typeof input === 'string') {
|
12961 | input = offsetFromString(matchShortOffset, input);
|
12962 |
|
12963 | if (input === null) {
|
12964 | return this;
|
12965 | }
|
12966 | } else if (Math.abs(input) < 16 && !keepMinutes) {
|
12967 | input = input * 60;
|
12968 | }
|
12969 |
|
12970 | if (!this._isUTC && keepLocalTime) {
|
12971 | localAdjust = getDateOffset(this);
|
12972 | }
|
12973 |
|
12974 | this._offset = input;
|
12975 | this._isUTC = true;
|
12976 |
|
12977 | if (localAdjust != null) {
|
12978 | this.add(localAdjust, 'm');
|
12979 | }
|
12980 |
|
12981 | if (offset !== input) {
|
12982 | if (!keepLocalTime || this._changeInProgress) {
|
12983 | addSubtract(this, createDuration(input - offset, 'm'), 1, false);
|
12984 | } else if (!this._changeInProgress) {
|
12985 | this._changeInProgress = true;
|
12986 | hooks.updateOffset(this, true);
|
12987 | this._changeInProgress = null;
|
12988 | }
|
12989 | }
|
12990 |
|
12991 | return this;
|
12992 | } else {
|
12993 | return this._isUTC ? offset : getDateOffset(this);
|
12994 | }
|
12995 | }
|
12996 |
|
12997 | function getSetZone(input, keepLocalTime) {
|
12998 | if (input != null) {
|
12999 | if (typeof input !== 'string') {
|
13000 | input = -input;
|
13001 | }
|
13002 |
|
13003 | this.utcOffset(input, keepLocalTime);
|
13004 | return this;
|
13005 | } else {
|
13006 | return -this.utcOffset();
|
13007 | }
|
13008 | }
|
13009 |
|
13010 | function setOffsetToUTC(keepLocalTime) {
|
13011 | return this.utcOffset(0, keepLocalTime);
|
13012 | }
|
13013 |
|
13014 | function setOffsetToLocal(keepLocalTime) {
|
13015 | if (this._isUTC) {
|
13016 | this.utcOffset(0, keepLocalTime);
|
13017 | this._isUTC = false;
|
13018 |
|
13019 | if (keepLocalTime) {
|
13020 | this.subtract(getDateOffset(this), 'm');
|
13021 | }
|
13022 | }
|
13023 |
|
13024 | return this;
|
13025 | }
|
13026 |
|
13027 | function setOffsetToParsedOffset() {
|
13028 | if (this._tzm != null) {
|
13029 | this.utcOffset(this._tzm, false, true);
|
13030 | } else if (typeof this._i === 'string') {
|
13031 | var tZone = offsetFromString(matchOffset, this._i);
|
13032 |
|
13033 | if (tZone != null) {
|
13034 | this.utcOffset(tZone);
|
13035 | } else {
|
13036 | this.utcOffset(0, true);
|
13037 | }
|
13038 | }
|
13039 |
|
13040 | return this;
|
13041 | }
|
13042 |
|
13043 | function hasAlignedHourOffset(input) {
|
13044 | if (!this.isValid()) {
|
13045 | return false;
|
13046 | }
|
13047 |
|
13048 | input = input ? createLocal(input).utcOffset() : 0;
|
13049 | return (this.utcOffset() - input) % 60 === 0;
|
13050 | }
|
13051 |
|
13052 | function isDaylightSavingTime() {
|
13053 | return this.utcOffset() > this.clone().month(0).utcOffset() || this.utcOffset() > this.clone().month(5).utcOffset();
|
13054 | }
|
13055 |
|
13056 | function isDaylightSavingTimeShifted() {
|
13057 | if (!isUndefined(this._isDSTShifted)) {
|
13058 | return this._isDSTShifted;
|
13059 | }
|
13060 |
|
13061 | var c = {};
|
13062 | copyConfig(c, this);
|
13063 | c = prepareConfig(c);
|
13064 |
|
13065 | if (c._a) {
|
13066 | var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
|
13067 | this._isDSTShifted = this.isValid() && compareArrays(c._a, other.toArray()) > 0;
|
13068 | } else {
|
13069 | this._isDSTShifted = false;
|
13070 | }
|
13071 |
|
13072 | return this._isDSTShifted;
|
13073 | }
|
13074 |
|
13075 | function isLocal() {
|
13076 | return this.isValid() ? !this._isUTC : false;
|
13077 | }
|
13078 |
|
13079 | function isUtcOffset() {
|
13080 | return this.isValid() ? this._isUTC : false;
|
13081 | }
|
13082 |
|
13083 | function isUtc() {
|
13084 | return this.isValid() ? this._isUTC && this._offset === 0 : false;
|
13085 | }
|
13086 |
|
13087 |
|
13088 | var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
|
13089 |
|
13090 |
|
13091 |
|
13092 | var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
|
13093 |
|
13094 | function createDuration(input, key) {
|
13095 | var duration = input,
|
13096 |
|
13097 | match = null,
|
13098 | sign,
|
13099 | ret,
|
13100 | diffRes;
|
13101 |
|
13102 | if (isDuration(input)) {
|
13103 | duration = {
|
13104 | ms: input._milliseconds,
|
13105 | d: input._days,
|
13106 | M: input._months
|
13107 | };
|
13108 | } else if (isNumber(input)) {
|
13109 | duration = {};
|
13110 |
|
13111 | if (key) {
|
13112 | duration[key] = input;
|
13113 | } else {
|
13114 | duration.milliseconds = input;
|
13115 | }
|
13116 | } else if (!!(match = aspNetRegex.exec(input))) {
|
13117 | sign = match[1] === '-' ? -1 : 1;
|
13118 | duration = {
|
13119 | y: 0,
|
13120 | d: toInt(match[DATE]) * sign,
|
13121 | h: toInt(match[HOUR]) * sign,
|
13122 | m: toInt(match[MINUTE]) * sign,
|
13123 | s: toInt(match[SECOND]) * sign,
|
13124 | ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign
|
13125 |
|
13126 | };
|
13127 | } else if (!!(match = isoRegex.exec(input))) {
|
13128 | sign = match[1] === '-' ? -1 : 1;
|
13129 | duration = {
|
13130 | y: parseIso(match[2], sign),
|
13131 | M: parseIso(match[3], sign),
|
13132 | w: parseIso(match[4], sign),
|
13133 | d: parseIso(match[5], sign),
|
13134 | h: parseIso(match[6], sign),
|
13135 | m: parseIso(match[7], sign),
|
13136 | s: parseIso(match[8], sign)
|
13137 | };
|
13138 | } else if (duration == null) {
|
13139 |
|
13140 | duration = {};
|
13141 | } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
|
13142 | diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
|
13143 | duration = {};
|
13144 | duration.ms = diffRes.milliseconds;
|
13145 | duration.M = diffRes.months;
|
13146 | }
|
13147 |
|
13148 | ret = new Duration(duration);
|
13149 |
|
13150 | if (isDuration(input) && hasOwnProp(input, '_locale')) {
|
13151 | ret._locale = input._locale;
|
13152 | }
|
13153 |
|
13154 | return ret;
|
13155 | }
|
13156 |
|
13157 | createDuration.fn = Duration.prototype;
|
13158 | createDuration.invalid = createInvalid$1;
|
13159 |
|
13160 | function parseIso(inp, sign) {
|
13161 |
|
13162 |
|
13163 |
|
13164 | var res = inp && parseFloat(inp.replace(',', '.'));
|
13165 |
|
13166 | return (isNaN(res) ? 0 : res) * sign;
|
13167 | }
|
13168 |
|
13169 | function positiveMomentsDifference(base, other) {
|
13170 | var res = {};
|
13171 | res.months = other.month() - base.month() + (other.year() - base.year()) * 12;
|
13172 |
|
13173 | if (base.clone().add(res.months, 'M').isAfter(other)) {
|
13174 | --res.months;
|
13175 | }
|
13176 |
|
13177 | res.milliseconds = +other - +base.clone().add(res.months, 'M');
|
13178 | return res;
|
13179 | }
|
13180 |
|
13181 | function momentsDifference(base, other) {
|
13182 | var res;
|
13183 |
|
13184 | if (!(base.isValid() && other.isValid())) {
|
13185 | return {
|
13186 | milliseconds: 0,
|
13187 | months: 0
|
13188 | };
|
13189 | }
|
13190 |
|
13191 | other = cloneWithOffset(other, base);
|
13192 |
|
13193 | if (base.isBefore(other)) {
|
13194 | res = positiveMomentsDifference(base, other);
|
13195 | } else {
|
13196 | res = positiveMomentsDifference(other, base);
|
13197 | res.milliseconds = -res.milliseconds;
|
13198 | res.months = -res.months;
|
13199 | }
|
13200 |
|
13201 | return res;
|
13202 | }
|
13203 |
|
13204 |
|
13205 | function createAdder(direction, name) {
|
13206 | return function (val, period) {
|
13207 | var dur, tmp;
|
13208 |
|
13209 | if (period !== null && !isNaN(+period)) {
|
13210 | deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' + 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
|
13211 | tmp = val;
|
13212 | val = period;
|
13213 | period = tmp;
|
13214 | }
|
13215 |
|
13216 | val = typeof val === 'string' ? +val : val;
|
13217 | dur = createDuration(val, period);
|
13218 | addSubtract(this, dur, direction);
|
13219 | return this;
|
13220 | };
|
13221 | }
|
13222 |
|
13223 | function addSubtract(mom, duration, isAdding, updateOffset) {
|
13224 | var milliseconds = duration._milliseconds,
|
13225 | days = absRound(duration._days),
|
13226 | months = absRound(duration._months);
|
13227 |
|
13228 | if (!mom.isValid()) {
|
13229 |
|
13230 | return;
|
13231 | }
|
13232 |
|
13233 | updateOffset = updateOffset == null ? true : updateOffset;
|
13234 |
|
13235 | if (months) {
|
13236 | setMonth(mom, get(mom, 'Month') + months * isAdding);
|
13237 | }
|
13238 |
|
13239 | if (days) {
|
13240 | set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
|
13241 | }
|
13242 |
|
13243 | if (milliseconds) {
|
13244 | mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
|
13245 | }
|
13246 |
|
13247 | if (updateOffset) {
|
13248 | hooks.updateOffset(mom, days || months);
|
13249 | }
|
13250 | }
|
13251 |
|
13252 | var add = createAdder(1, 'add');
|
13253 | var subtract = createAdder(-1, 'subtract');
|
13254 |
|
13255 | function getCalendarFormat(myMoment, now) {
|
13256 | var diff = myMoment.diff(now, 'days', true);
|
13257 | return diff < -6 ? 'sameElse' : diff < -1 ? 'lastWeek' : diff < 0 ? 'lastDay' : diff < 1 ? 'sameDay' : diff < 2 ? 'nextDay' : diff < 7 ? 'nextWeek' : 'sameElse';
|
13258 | }
|
13259 |
|
13260 | function calendar$1(time, formats) {
|
13261 |
|
13262 |
|
13263 | var now = time || createLocal(),
|
13264 | sod = cloneWithOffset(now, this).startOf('day'),
|
13265 | format = hooks.calendarFormat(this, sod) || 'sameElse';
|
13266 | var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
|
13267 | return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
|
13268 | }
|
13269 |
|
13270 | function clone() {
|
13271 | return new Moment(this);
|
13272 | }
|
13273 |
|
13274 | function isAfter(input, units) {
|
13275 | var localInput = isMoment(input) ? input : createLocal(input);
|
13276 |
|
13277 | if (!(this.isValid() && localInput.isValid())) {
|
13278 | return false;
|
13279 | }
|
13280 |
|
13281 | units = normalizeUnits(units) || 'millisecond';
|
13282 |
|
13283 | if (units === 'millisecond') {
|
13284 | return this.valueOf() > localInput.valueOf();
|
13285 | } else {
|
13286 | return localInput.valueOf() < this.clone().startOf(units).valueOf();
|
13287 | }
|
13288 | }
|
13289 |
|
13290 | function isBefore(input, units) {
|
13291 | var localInput = isMoment(input) ? input : createLocal(input);
|
13292 |
|
13293 | if (!(this.isValid() && localInput.isValid())) {
|
13294 | return false;
|
13295 | }
|
13296 |
|
13297 | units = normalizeUnits(units) || 'millisecond';
|
13298 |
|
13299 | if (units === 'millisecond') {
|
13300 | return this.valueOf() < localInput.valueOf();
|
13301 | } else {
|
13302 | return this.clone().endOf(units).valueOf() < localInput.valueOf();
|
13303 | }
|
13304 | }
|
13305 |
|
13306 | function isBetween(from, to, units, inclusivity) {
|
13307 | var localFrom = isMoment(from) ? from : createLocal(from),
|
13308 | localTo = isMoment(to) ? to : createLocal(to);
|
13309 |
|
13310 | if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
|
13311 | return false;
|
13312 | }
|
13313 |
|
13314 | inclusivity = inclusivity || '()';
|
13315 | return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) && (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
|
13316 | }
|
13317 |
|
13318 | function isSame(input, units) {
|
13319 | var localInput = isMoment(input) ? input : createLocal(input),
|
13320 | inputMs;
|
13321 |
|
13322 | if (!(this.isValid() && localInput.isValid())) {
|
13323 | return false;
|
13324 | }
|
13325 |
|
13326 | units = normalizeUnits(units) || 'millisecond';
|
13327 |
|
13328 | if (units === 'millisecond') {
|
13329 | return this.valueOf() === localInput.valueOf();
|
13330 | } else {
|
13331 | inputMs = localInput.valueOf();
|
13332 | return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
|
13333 | }
|
13334 | }
|
13335 |
|
13336 | function isSameOrAfter(input, units) {
|
13337 | return this.isSame(input, units) || this.isAfter(input, units);
|
13338 | }
|
13339 |
|
13340 | function isSameOrBefore(input, units) {
|
13341 | return this.isSame(input, units) || this.isBefore(input, units);
|
13342 | }
|
13343 |
|
13344 | function diff(input, units, asFloat) {
|
13345 | var that, zoneDelta, output;
|
13346 |
|
13347 | if (!this.isValid()) {
|
13348 | return NaN;
|
13349 | }
|
13350 |
|
13351 | that = cloneWithOffset(input, this);
|
13352 |
|
13353 | if (!that.isValid()) {
|
13354 | return NaN;
|
13355 | }
|
13356 |
|
13357 | zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
|
13358 | units = normalizeUnits(units);
|
13359 |
|
13360 | switch (units) {
|
13361 | case 'year':
|
13362 | output = monthDiff(this, that) / 12;
|
13363 | break;
|
13364 |
|
13365 | case 'month':
|
13366 | output = monthDiff(this, that);
|
13367 | break;
|
13368 |
|
13369 | case 'quarter':
|
13370 | output = monthDiff(this, that) / 3;
|
13371 | break;
|
13372 |
|
13373 | case 'second':
|
13374 | output = (this - that) / 1e3;
|
13375 | break;
|
13376 |
|
13377 |
|
13378 | case 'minute':
|
13379 | output = (this - that) / 6e4;
|
13380 | break;
|
13381 |
|
13382 |
|
13383 | case 'hour':
|
13384 | output = (this - that) / 36e5;
|
13385 | break;
|
13386 |
|
13387 |
|
13388 | case 'day':
|
13389 | output = (this - that - zoneDelta) / 864e5;
|
13390 | break;
|
13391 |
|
13392 |
|
13393 | case 'week':
|
13394 | output = (this - that - zoneDelta) / 6048e5;
|
13395 | break;
|
13396 |
|
13397 |
|
13398 | default:
|
13399 | output = this - that;
|
13400 | }
|
13401 |
|
13402 | return asFloat ? output : absFloor(output);
|
13403 | }
|
13404 |
|
13405 | function monthDiff(a, b) {
|
13406 |
|
13407 | var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
|
13408 |
|
13409 | anchor = a.clone().add(wholeMonthDiff, 'months'),
|
13410 | anchor2,
|
13411 | adjust;
|
13412 |
|
13413 | if (b - anchor < 0) {
|
13414 | anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
|
13415 |
|
13416 | adjust = (b - anchor) / (anchor - anchor2);
|
13417 | } else {
|
13418 | anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
|
13419 |
|
13420 | adjust = (b - anchor) / (anchor2 - anchor);
|
13421 | }
|
13422 |
|
13423 |
|
13424 | return -(wholeMonthDiff + adjust) || 0;
|
13425 | }
|
13426 |
|
13427 | hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
|
13428 | hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
|
13429 |
|
13430 | function toString() {
|
13431 | return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
|
13432 | }
|
13433 |
|
13434 | function toISOString(keepOffset) {
|
13435 | if (!this.isValid()) {
|
13436 | return null;
|
13437 | }
|
13438 |
|
13439 | var utc = keepOffset !== true;
|
13440 | var m = utc ? this.clone().utc() : this;
|
13441 |
|
13442 | if (m.year() < 0 || m.year() > 9999) {
|
13443 | return formatMoment(m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
13444 | }
|
13445 |
|
13446 | if (isFunction(Date.prototype.toISOString)) {
|
13447 |
|
13448 | if (utc) {
|
13449 | return this.toDate().toISOString();
|
13450 | } else {
|
13451 | return new Date(this.valueOf() + this.utcOffset() * 60 * 1000).toISOString().replace('Z', formatMoment(m, 'Z'));
|
13452 | }
|
13453 | }
|
13454 |
|
13455 | return formatMoment(m, utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
13456 | }
|
13457 | |
13458 |
|
13459 |
|
13460 |
|
13461 |
|
13462 |
|
13463 |
|
13464 |
|
13465 | function inspect() {
|
13466 | if (!this.isValid()) {
|
13467 | return 'moment.invalid(/* ' + this._i + ' */)';
|
13468 | }
|
13469 |
|
13470 | var func = 'moment';
|
13471 | var zone = '';
|
13472 |
|
13473 | if (!this.isLocal()) {
|
13474 | func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
|
13475 | zone = 'Z';
|
13476 | }
|
13477 |
|
13478 | var prefix = '[' + func + '("]';
|
13479 | var year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
|
13480 | var datetime = '-MM-DD[T]HH:mm:ss.SSS';
|
13481 | var suffix = zone + '[")]';
|
13482 | return this.format(prefix + year + datetime + suffix);
|
13483 | }
|
13484 |
|
13485 | function format(inputString) {
|
13486 | if (!inputString) {
|
13487 | inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
|
13488 | }
|
13489 |
|
13490 | var output = formatMoment(this, inputString);
|
13491 | return this.localeData().postformat(output);
|
13492 | }
|
13493 |
|
13494 | function from(time, withoutSuffix) {
|
13495 | if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
|
13496 | return createDuration({
|
13497 | to: this,
|
13498 | from: time
|
13499 | }).locale(this.locale()).humanize(!withoutSuffix);
|
13500 | } else {
|
13501 | return this.localeData().invalidDate();
|
13502 | }
|
13503 | }
|
13504 |
|
13505 | function fromNow(withoutSuffix) {
|
13506 | return this.from(createLocal(), withoutSuffix);
|
13507 | }
|
13508 |
|
13509 | function to(time, withoutSuffix) {
|
13510 | if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
|
13511 | return createDuration({
|
13512 | from: this,
|
13513 | to: time
|
13514 | }).locale(this.locale()).humanize(!withoutSuffix);
|
13515 | } else {
|
13516 | return this.localeData().invalidDate();
|
13517 | }
|
13518 | }
|
13519 |
|
13520 | function toNow(withoutSuffix) {
|
13521 | return this.to(createLocal(), withoutSuffix);
|
13522 | }
|
13523 |
|
13524 |
|
13525 |
|
13526 |
|
13527 | function locale(key) {
|
13528 | var newLocaleData;
|
13529 |
|
13530 | if (key === undefined) {
|
13531 | return this._locale._abbr;
|
13532 | } else {
|
13533 | newLocaleData = getLocale(key);
|
13534 |
|
13535 | if (newLocaleData != null) {
|
13536 | this._locale = newLocaleData;
|
13537 | }
|
13538 |
|
13539 | return this;
|
13540 | }
|
13541 | }
|
13542 |
|
13543 | var lang = deprecate('moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', function (key) {
|
13544 | if (key === undefined) {
|
13545 | return this.localeData();
|
13546 | } else {
|
13547 | return this.locale(key);
|
13548 | }
|
13549 | });
|
13550 |
|
13551 | function localeData() {
|
13552 | return this._locale;
|
13553 | }
|
13554 |
|
13555 | var MS_PER_SECOND = 1000;
|
13556 | var MS_PER_MINUTE = 60 * MS_PER_SECOND;
|
13557 | var MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
13558 | var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
|
13559 |
|
13560 | function mod$1(dividend, divisor) {
|
13561 | return (dividend % divisor + divisor) % divisor;
|
13562 | }
|
13563 |
|
13564 | function localStartOfDate(y, m, d) {
|
13565 |
|
13566 | if (y < 100 && y >= 0) {
|
13567 |
|
13568 | return new Date(y + 400, m, d) - MS_PER_400_YEARS;
|
13569 | } else {
|
13570 | return new Date(y, m, d).valueOf();
|
13571 | }
|
13572 | }
|
13573 |
|
13574 | function utcStartOfDate(y, m, d) {
|
13575 |
|
13576 | if (y < 100 && y >= 0) {
|
13577 |
|
13578 | return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
|
13579 | } else {
|
13580 | return Date.UTC(y, m, d);
|
13581 | }
|
13582 | }
|
13583 |
|
13584 | function startOf(units) {
|
13585 | var time;
|
13586 | units = normalizeUnits(units);
|
13587 |
|
13588 | if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
13589 | return this;
|
13590 | }
|
13591 |
|
13592 | var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
13593 |
|
13594 | switch (units) {
|
13595 | case 'year':
|
13596 | time = startOfDate(this.year(), 0, 1);
|
13597 | break;
|
13598 |
|
13599 | case 'quarter':
|
13600 | time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
|
13601 | break;
|
13602 |
|
13603 | case 'month':
|
13604 | time = startOfDate(this.year(), this.month(), 1);
|
13605 | break;
|
13606 |
|
13607 | case 'week':
|
13608 | time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
|
13609 | break;
|
13610 |
|
13611 | case 'isoWeek':
|
13612 | time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
|
13613 | break;
|
13614 |
|
13615 | case 'day':
|
13616 | case 'date':
|
13617 | time = startOfDate(this.year(), this.month(), this.date());
|
13618 | break;
|
13619 |
|
13620 | case 'hour':
|
13621 | time = this._d.valueOf();
|
13622 | time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
|
13623 | break;
|
13624 |
|
13625 | case 'minute':
|
13626 | time = this._d.valueOf();
|
13627 | time -= mod$1(time, MS_PER_MINUTE);
|
13628 | break;
|
13629 |
|
13630 | case 'second':
|
13631 | time = this._d.valueOf();
|
13632 | time -= mod$1(time, MS_PER_SECOND);
|
13633 | break;
|
13634 | }
|
13635 |
|
13636 | this._d.setTime(time);
|
13637 |
|
13638 | hooks.updateOffset(this, true);
|
13639 | return this;
|
13640 | }
|
13641 |
|
13642 | function endOf(units) {
|
13643 | var time;
|
13644 | units = normalizeUnits(units);
|
13645 |
|
13646 | if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
13647 | return this;
|
13648 | }
|
13649 |
|
13650 | var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
13651 |
|
13652 | switch (units) {
|
13653 | case 'year':
|
13654 | time = startOfDate(this.year() + 1, 0, 1) - 1;
|
13655 | break;
|
13656 |
|
13657 | case 'quarter':
|
13658 | time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
|
13659 | break;
|
13660 |
|
13661 | case 'month':
|
13662 | time = startOfDate(this.year(), this.month() + 1, 1) - 1;
|
13663 | break;
|
13664 |
|
13665 | case 'week':
|
13666 | time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
|
13667 | break;
|
13668 |
|
13669 | case 'isoWeek':
|
13670 | time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
|
13671 | break;
|
13672 |
|
13673 | case 'day':
|
13674 | case 'date':
|
13675 | time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
|
13676 | break;
|
13677 |
|
13678 | case 'hour':
|
13679 | time = this._d.valueOf();
|
13680 | time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
|
13681 | break;
|
13682 |
|
13683 | case 'minute':
|
13684 | time = this._d.valueOf();
|
13685 | time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
|
13686 | break;
|
13687 |
|
13688 | case 'second':
|
13689 | time = this._d.valueOf();
|
13690 | time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
|
13691 | break;
|
13692 | }
|
13693 |
|
13694 | this._d.setTime(time);
|
13695 |
|
13696 | hooks.updateOffset(this, true);
|
13697 | return this;
|
13698 | }
|
13699 |
|
13700 | function valueOf() {
|
13701 | return this._d.valueOf() - (this._offset || 0) * 60000;
|
13702 | }
|
13703 |
|
13704 | function unix() {
|
13705 | return Math.floor(this.valueOf() / 1000);
|
13706 | }
|
13707 |
|
13708 | function toDate() {
|
13709 | return new Date(this.valueOf());
|
13710 | }
|
13711 |
|
13712 | function toArray() {
|
13713 | var m = this;
|
13714 | return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
|
13715 | }
|
13716 |
|
13717 | function toObject() {
|
13718 | var m = this;
|
13719 | return {
|
13720 | years: m.year(),
|
13721 | months: m.month(),
|
13722 | date: m.date(),
|
13723 | hours: m.hours(),
|
13724 | minutes: m.minutes(),
|
13725 | seconds: m.seconds(),
|
13726 | milliseconds: m.milliseconds()
|
13727 | };
|
13728 | }
|
13729 |
|
13730 | function toJSON() {
|
13731 |
|
13732 | return this.isValid() ? this.toISOString() : null;
|
13733 | }
|
13734 |
|
13735 | function isValid$2() {
|
13736 | return isValid(this);
|
13737 | }
|
13738 |
|
13739 | function parsingFlags() {
|
13740 | return extend({}, getParsingFlags(this));
|
13741 | }
|
13742 |
|
13743 | function invalidAt() {
|
13744 | return getParsingFlags(this).overflow;
|
13745 | }
|
13746 |
|
13747 | function creationData() {
|
13748 | return {
|
13749 | input: this._i,
|
13750 | format: this._f,
|
13751 | locale: this._locale,
|
13752 | isUTC: this._isUTC,
|
13753 | strict: this._strict
|
13754 | };
|
13755 | }
|
13756 |
|
13757 |
|
13758 | addFormatToken(0, ['gg', 2], 0, function () {
|
13759 | return this.weekYear() % 100;
|
13760 | });
|
13761 | addFormatToken(0, ['GG', 2], 0, function () {
|
13762 | return this.isoWeekYear() % 100;
|
13763 | });
|
13764 |
|
13765 | function addWeekYearFormatToken(token, getter) {
|
13766 | addFormatToken(0, [token, token.length], 0, getter);
|
13767 | }
|
13768 |
|
13769 | addWeekYearFormatToken('gggg', 'weekYear');
|
13770 | addWeekYearFormatToken('ggggg', 'weekYear');
|
13771 | addWeekYearFormatToken('GGGG', 'isoWeekYear');
|
13772 | addWeekYearFormatToken('GGGGG', 'isoWeekYear');
|
13773 |
|
13774 | addUnitAlias('weekYear', 'gg');
|
13775 | addUnitAlias('isoWeekYear', 'GG');
|
13776 |
|
13777 | addUnitPriority('weekYear', 1);
|
13778 | addUnitPriority('isoWeekYear', 1);
|
13779 |
|
13780 | addRegexToken('G', matchSigned);
|
13781 | addRegexToken('g', matchSigned);
|
13782 | addRegexToken('GG', match1to2, match2);
|
13783 | addRegexToken('gg', match1to2, match2);
|
13784 | addRegexToken('GGGG', match1to4, match4);
|
13785 | addRegexToken('gggg', match1to4, match4);
|
13786 | addRegexToken('GGGGG', match1to6, match6);
|
13787 | addRegexToken('ggggg', match1to6, match6);
|
13788 | addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
|
13789 | week[token.substr(0, 2)] = toInt(input);
|
13790 | });
|
13791 | addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
|
13792 | week[token] = hooks.parseTwoDigitYear(input);
|
13793 | });
|
13794 |
|
13795 | function getSetWeekYear(input) {
|
13796 | return getSetWeekYearHelper.call(this, input, this.week(), this.weekday(), this.localeData()._week.dow, this.localeData()._week.doy);
|
13797 | }
|
13798 |
|
13799 | function getSetISOWeekYear(input) {
|
13800 | return getSetWeekYearHelper.call(this, input, this.isoWeek(), this.isoWeekday(), 1, 4);
|
13801 | }
|
13802 |
|
13803 | function getISOWeeksInYear() {
|
13804 | return weeksInYear(this.year(), 1, 4);
|
13805 | }
|
13806 |
|
13807 | function getWeeksInYear() {
|
13808 | var weekInfo = this.localeData()._week;
|
13809 |
|
13810 | return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
|
13811 | }
|
13812 |
|
13813 | function getSetWeekYearHelper(input, week, weekday, dow, doy) {
|
13814 | var weeksTarget;
|
13815 |
|
13816 | if (input == null) {
|
13817 | return weekOfYear(this, dow, doy).year;
|
13818 | } else {
|
13819 | weeksTarget = weeksInYear(input, dow, doy);
|
13820 |
|
13821 | if (week > weeksTarget) {
|
13822 | week = weeksTarget;
|
13823 | }
|
13824 |
|
13825 | return setWeekAll.call(this, input, week, weekday, dow, doy);
|
13826 | }
|
13827 | }
|
13828 |
|
13829 | function setWeekAll(weekYear, week, weekday, dow, doy) {
|
13830 | var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
|
13831 | date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
|
13832 | this.year(date.getUTCFullYear());
|
13833 | this.month(date.getUTCMonth());
|
13834 | this.date(date.getUTCDate());
|
13835 | return this;
|
13836 | }
|
13837 |
|
13838 |
|
13839 | addFormatToken('Q', 0, 'Qo', 'quarter');
|
13840 |
|
13841 | addUnitAlias('quarter', 'Q');
|
13842 |
|
13843 | addUnitPriority('quarter', 7);
|
13844 |
|
13845 | addRegexToken('Q', match1);
|
13846 | addParseToken('Q', function (input, array) {
|
13847 | array[MONTH] = (toInt(input) - 1) * 3;
|
13848 | });
|
13849 |
|
13850 | function getSetQuarter(input) {
|
13851 | return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
|
13852 | }
|
13853 |
|
13854 |
|
13855 | addFormatToken('D', ['DD', 2], 'Do', 'date');
|
13856 |
|
13857 | addUnitAlias('date', 'D');
|
13858 |
|
13859 | addUnitPriority('date', 9);
|
13860 |
|
13861 | addRegexToken('D', match1to2);
|
13862 | addRegexToken('DD', match1to2, match2);
|
13863 | addRegexToken('Do', function (isStrict, locale) {
|
13864 |
|
13865 | return isStrict ? locale._dayOfMonthOrdinalParse || locale._ordinalParse : locale._dayOfMonthOrdinalParseLenient;
|
13866 | });
|
13867 | addParseToken(['D', 'DD'], DATE);
|
13868 | addParseToken('Do', function (input, array) {
|
13869 | array[DATE] = toInt(input.match(match1to2)[0]);
|
13870 | });
|
13871 |
|
13872 | var getSetDayOfMonth = makeGetSet('Date', true);
|
13873 |
|
13874 | addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
|
13875 |
|
13876 | addUnitAlias('dayOfYear', 'DDD');
|
13877 |
|
13878 | addUnitPriority('dayOfYear', 4);
|
13879 |
|
13880 | addRegexToken('DDD', match1to3);
|
13881 | addRegexToken('DDDD', match3);
|
13882 | addParseToken(['DDD', 'DDDD'], function (input, array, config) {
|
13883 | config._dayOfYear = toInt(input);
|
13884 | });
|
13885 |
|
13886 |
|
13887 | function getSetDayOfYear(input) {
|
13888 | var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
|
13889 | return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
|
13890 | }
|
13891 |
|
13892 |
|
13893 | addFormatToken('m', ['mm', 2], 0, 'minute');
|
13894 |
|
13895 | addUnitAlias('minute', 'm');
|
13896 |
|
13897 | addUnitPriority('minute', 14);
|
13898 |
|
13899 | addRegexToken('m', match1to2);
|
13900 | addRegexToken('mm', match1to2, match2);
|
13901 | addParseToken(['m', 'mm'], MINUTE);
|
13902 |
|
13903 | var getSetMinute = makeGetSet('Minutes', false);
|
13904 |
|
13905 | addFormatToken('s', ['ss', 2], 0, 'second');
|
13906 |
|
13907 | addUnitAlias('second', 's');
|
13908 |
|
13909 | addUnitPriority('second', 15);
|
13910 |
|
13911 | addRegexToken('s', match1to2);
|
13912 | addRegexToken('ss', match1to2, match2);
|
13913 | addParseToken(['s', 'ss'], SECOND);
|
13914 |
|
13915 | var getSetSecond = makeGetSet('Seconds', false);
|
13916 |
|
13917 | addFormatToken('S', 0, 0, function () {
|
13918 | return ~~(this.millisecond() / 100);
|
13919 | });
|
13920 | addFormatToken(0, ['SS', 2], 0, function () {
|
13921 | return ~~(this.millisecond() / 10);
|
13922 | });
|
13923 | addFormatToken(0, ['SSS', 3], 0, 'millisecond');
|
13924 | addFormatToken(0, ['SSSS', 4], 0, function () {
|
13925 | return this.millisecond() * 10;
|
13926 | });
|
13927 | addFormatToken(0, ['SSSSS', 5], 0, function () {
|
13928 | return this.millisecond() * 100;
|
13929 | });
|
13930 | addFormatToken(0, ['SSSSSS', 6], 0, function () {
|
13931 | return this.millisecond() * 1000;
|
13932 | });
|
13933 | addFormatToken(0, ['SSSSSSS', 7], 0, function () {
|
13934 | return this.millisecond() * 10000;
|
13935 | });
|
13936 | addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
|
13937 | return this.millisecond() * 100000;
|
13938 | });
|
13939 | addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
|
13940 | return this.millisecond() * 1000000;
|
13941 | });
|
13942 |
|
13943 | addUnitAlias('millisecond', 'ms');
|
13944 |
|
13945 | addUnitPriority('millisecond', 16);
|
13946 |
|
13947 | addRegexToken('S', match1to3, match1);
|
13948 | addRegexToken('SS', match1to3, match2);
|
13949 | addRegexToken('SSS', match1to3, match3);
|
13950 | var token;
|
13951 |
|
13952 | for (token = 'SSSS'; token.length <= 9; token += 'S') {
|
13953 | addRegexToken(token, matchUnsigned);
|
13954 | }
|
13955 |
|
13956 | function parseMs(input, array) {
|
13957 | array[MILLISECOND] = toInt(('0.' + input) * 1000);
|
13958 | }
|
13959 |
|
13960 | for (token = 'S'; token.length <= 9; token += 'S') {
|
13961 | addParseToken(token, parseMs);
|
13962 | }
|
13963 |
|
13964 |
|
13965 | var getSetMillisecond = makeGetSet('Milliseconds', false);
|
13966 |
|
13967 | addFormatToken('z', 0, 0, 'zoneAbbr');
|
13968 | addFormatToken('zz', 0, 0, 'zoneName');
|
13969 |
|
13970 | function getZoneAbbr() {
|
13971 | return this._isUTC ? 'UTC' : '';
|
13972 | }
|
13973 |
|
13974 | function getZoneName() {
|
13975 | return this._isUTC ? 'Coordinated Universal Time' : '';
|
13976 | }
|
13977 |
|
13978 | var proto = Moment.prototype;
|
13979 | proto.add = add;
|
13980 | proto.calendar = calendar$1;
|
13981 | proto.clone = clone;
|
13982 | proto.diff = diff;
|
13983 | proto.endOf = endOf;
|
13984 | proto.format = format;
|
13985 | proto.from = from;
|
13986 | proto.fromNow = fromNow;
|
13987 | proto.to = to;
|
13988 | proto.toNow = toNow;
|
13989 | proto.get = stringGet;
|
13990 | proto.invalidAt = invalidAt;
|
13991 | proto.isAfter = isAfter;
|
13992 | proto.isBefore = isBefore;
|
13993 | proto.isBetween = isBetween;
|
13994 | proto.isSame = isSame;
|
13995 | proto.isSameOrAfter = isSameOrAfter;
|
13996 | proto.isSameOrBefore = isSameOrBefore;
|
13997 | proto.isValid = isValid$2;
|
13998 | proto.lang = lang;
|
13999 | proto.locale = locale;
|
14000 | proto.localeData = localeData;
|
14001 | proto.max = prototypeMax;
|
14002 | proto.min = prototypeMin;
|
14003 | proto.parsingFlags = parsingFlags;
|
14004 | proto.set = stringSet;
|
14005 | proto.startOf = startOf;
|
14006 | proto.subtract = subtract;
|
14007 | proto.toArray = toArray;
|
14008 | proto.toObject = toObject;
|
14009 | proto.toDate = toDate;
|
14010 | proto.toISOString = toISOString;
|
14011 | proto.inspect = inspect;
|
14012 | proto.toJSON = toJSON;
|
14013 | proto.toString = toString;
|
14014 | proto.unix = unix;
|
14015 | proto.valueOf = valueOf;
|
14016 | proto.creationData = creationData;
|
14017 | proto.year = getSetYear;
|
14018 | proto.isLeapYear = getIsLeapYear;
|
14019 | proto.weekYear = getSetWeekYear;
|
14020 | proto.isoWeekYear = getSetISOWeekYear;
|
14021 | proto.quarter = proto.quarters = getSetQuarter;
|
14022 | proto.month = getSetMonth;
|
14023 | proto.daysInMonth = getDaysInMonth;
|
14024 | proto.week = proto.weeks = getSetWeek;
|
14025 | proto.isoWeek = proto.isoWeeks = getSetISOWeek;
|
14026 | proto.weeksInYear = getWeeksInYear;
|
14027 | proto.isoWeeksInYear = getISOWeeksInYear;
|
14028 | proto.date = getSetDayOfMonth;
|
14029 | proto.day = proto.days = getSetDayOfWeek;
|
14030 | proto.weekday = getSetLocaleDayOfWeek;
|
14031 | proto.isoWeekday = getSetISODayOfWeek;
|
14032 | proto.dayOfYear = getSetDayOfYear;
|
14033 | proto.hour = proto.hours = getSetHour;
|
14034 | proto.minute = proto.minutes = getSetMinute;
|
14035 | proto.second = proto.seconds = getSetSecond;
|
14036 | proto.millisecond = proto.milliseconds = getSetMillisecond;
|
14037 | proto.utcOffset = getSetOffset;
|
14038 | proto.utc = setOffsetToUTC;
|
14039 | proto.local = setOffsetToLocal;
|
14040 | proto.parseZone = setOffsetToParsedOffset;
|
14041 | proto.hasAlignedHourOffset = hasAlignedHourOffset;
|
14042 | proto.isDST = isDaylightSavingTime;
|
14043 | proto.isLocal = isLocal;
|
14044 | proto.isUtcOffset = isUtcOffset;
|
14045 | proto.isUtc = isUtc;
|
14046 | proto.isUTC = isUtc;
|
14047 | proto.zoneAbbr = getZoneAbbr;
|
14048 | proto.zoneName = getZoneName;
|
14049 | proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
|
14050 | proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
|
14051 | proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
|
14052 | proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
|
14053 | proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
|
14054 |
|
14055 | function createUnix(input) {
|
14056 | return createLocal(input * 1000);
|
14057 | }
|
14058 |
|
14059 | function createInZone() {
|
14060 | return createLocal.apply(null, arguments).parseZone();
|
14061 | }
|
14062 |
|
14063 | function preParsePostFormat(string) {
|
14064 | return string;
|
14065 | }
|
14066 |
|
14067 | var proto$1 = Locale.prototype;
|
14068 | proto$1.calendar = calendar;
|
14069 | proto$1.longDateFormat = longDateFormat;
|
14070 | proto$1.invalidDate = invalidDate;
|
14071 | proto$1.ordinal = ordinal;
|
14072 | proto$1.preparse = preParsePostFormat;
|
14073 | proto$1.postformat = preParsePostFormat;
|
14074 | proto$1.relativeTime = relativeTime;
|
14075 | proto$1.pastFuture = pastFuture;
|
14076 | proto$1.set = set;
|
14077 | proto$1.months = localeMonths;
|
14078 | proto$1.monthsShort = localeMonthsShort;
|
14079 | proto$1.monthsParse = localeMonthsParse;
|
14080 | proto$1.monthsRegex = monthsRegex;
|
14081 | proto$1.monthsShortRegex = monthsShortRegex;
|
14082 | proto$1.week = localeWeek;
|
14083 | proto$1.firstDayOfYear = localeFirstDayOfYear;
|
14084 | proto$1.firstDayOfWeek = localeFirstDayOfWeek;
|
14085 | proto$1.weekdays = localeWeekdays;
|
14086 | proto$1.weekdaysMin = localeWeekdaysMin;
|
14087 | proto$1.weekdaysShort = localeWeekdaysShort;
|
14088 | proto$1.weekdaysParse = localeWeekdaysParse;
|
14089 | proto$1.weekdaysRegex = weekdaysRegex;
|
14090 | proto$1.weekdaysShortRegex = weekdaysShortRegex;
|
14091 | proto$1.weekdaysMinRegex = weekdaysMinRegex;
|
14092 | proto$1.isPM = localeIsPM;
|
14093 | proto$1.meridiem = localeMeridiem;
|
14094 |
|
14095 | function get$1(format, index, field, setter) {
|
14096 | var locale = getLocale();
|
14097 | var utc = createUTC().set(setter, index);
|
14098 | return locale[field](utc, format);
|
14099 | }
|
14100 |
|
14101 | function listMonthsImpl(format, index, field) {
|
14102 | if (isNumber(format)) {
|
14103 | index = format;
|
14104 | format = undefined;
|
14105 | }
|
14106 |
|
14107 | format = format || '';
|
14108 |
|
14109 | if (index != null) {
|
14110 | return get$1(format, index, field, 'month');
|
14111 | }
|
14112 |
|
14113 | var i;
|
14114 | var out = [];
|
14115 |
|
14116 | for (i = 0; i < 12; i++) {
|
14117 | out[i] = get$1(format, i, field, 'month');
|
14118 | }
|
14119 |
|
14120 | return out;
|
14121 | } // ()
|
14122 | // (5)
|
14123 | // (fmt, 5)
|
14124 | // (fmt)
|
14125 | // (true)
|
14126 | // (true, 5)
|
14127 | // (true, fmt, 5)
|
14128 | // (true, fmt)
|
14129 |
|
14130 |
|
14131 | function listWeekdaysImpl(localeSorted, format, index, field) {
|
14132 | if (typeof localeSorted === 'boolean') {
|
14133 | if (isNumber(format)) {
|
14134 | index = format;
|
14135 | format = undefined;
|
14136 | }
|
14137 |
|
14138 | format = format || '';
|
14139 | } else {
|
14140 | format = localeSorted;
|
14141 | index = format;
|
14142 | localeSorted = false;
|
14143 |
|
14144 | if (isNumber(format)) {
|
14145 | index = format;
|
14146 | format = undefined;
|
14147 | }
|
14148 |
|
14149 | format = format || '';
|
14150 | }
|
14151 |
|
14152 | var locale = getLocale(),
|
14153 | shift = localeSorted ? locale._week.dow : 0;
|
14154 |
|
14155 | if (index != null) {
|
14156 | return get$1(format, (index + shift) % 7, field, 'day');
|
14157 | }
|
14158 |
|
14159 | var i;
|
14160 | var out = [];
|
14161 |
|
14162 | for (i = 0; i < 7; i++) {
|
14163 | out[i] = get$1(format, (i + shift) % 7, field, 'day');
|
14164 | }
|
14165 |
|
14166 | return out;
|
14167 | }
|
14168 |
|
14169 | function listMonths(format, index) {
|
14170 | return listMonthsImpl(format, index, 'months');
|
14171 | }
|
14172 |
|
14173 | function listMonthsShort(format, index) {
|
14174 | return listMonthsImpl(format, index, 'monthsShort');
|
14175 | }
|
14176 |
|
14177 | function listWeekdays(localeSorted, format, index) {
|
14178 | return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
|
14179 | }
|
14180 |
|
14181 | function listWeekdaysShort(localeSorted, format, index) {
|
14182 | return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
|
14183 | }
|
14184 |
|
14185 | function listWeekdaysMin(localeSorted, format, index) {
|
14186 | return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
|
14187 | }
|
14188 |
|
14189 | getSetGlobalLocale('en', {
|
14190 | dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
|
14191 | ordinal: function (number) {
|
14192 | var b = number % 10,
|
14193 | output = toInt(number % 100 / 10) === 1 ? 'th' : b === 1 ? 'st' : b === 2 ? 'nd' : b === 3 ? 'rd' : 'th';
|
14194 | return number + output;
|
14195 | }
|
14196 | });
|
14197 |
|
14198 | hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
|
14199 | hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
|
14200 | var mathAbs = Math.abs;
|
14201 |
|
14202 | function abs() {
|
14203 | var data = this._data;
|
14204 | this._milliseconds = mathAbs(this._milliseconds);
|
14205 | this._days = mathAbs(this._days);
|
14206 | this._months = mathAbs(this._months);
|
14207 | data.milliseconds = mathAbs(data.milliseconds);
|
14208 | data.seconds = mathAbs(data.seconds);
|
14209 | data.minutes = mathAbs(data.minutes);
|
14210 | data.hours = mathAbs(data.hours);
|
14211 | data.months = mathAbs(data.months);
|
14212 | data.years = mathAbs(data.years);
|
14213 | return this;
|
14214 | }
|
14215 |
|
14216 | function addSubtract$1(duration, input, value, direction) {
|
14217 | var other = createDuration(input, value);
|
14218 | duration._milliseconds += direction * other._milliseconds;
|
14219 | duration._days += direction * other._days;
|
14220 | duration._months += direction * other._months;
|
14221 | return duration._bubble();
|
14222 | }
|
14223 |
|
14224 |
|
14225 | function add$1(input, value) {
|
14226 | return addSubtract$1(this, input, value, 1);
|
14227 | }
|
14228 |
|
14229 |
|
14230 | function subtract$1(input, value) {
|
14231 | return addSubtract$1(this, input, value, -1);
|
14232 | }
|
14233 |
|
14234 | function absCeil(number) {
|
14235 | if (number < 0) {
|
14236 | return Math.floor(number);
|
14237 | } else {
|
14238 | return Math.ceil(number);
|
14239 | }
|
14240 | }
|
14241 |
|
14242 | function bubble() {
|
14243 | var milliseconds = this._milliseconds;
|
14244 | var days = this._days;
|
14245 | var months = this._months;
|
14246 | var data = this._data;
|
14247 | var seconds, minutes, hours, years, monthsFromDays;
|
14248 |
|
14249 |
|
14250 | if (!(milliseconds >= 0 && days >= 0 && months >= 0 || milliseconds <= 0 && days <= 0 && months <= 0)) {
|
14251 | milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
|
14252 | days = 0;
|
14253 | months = 0;
|
14254 | }
|
14255 |
|
14256 |
|
14257 |
|
14258 | data.milliseconds = milliseconds % 1000;
|
14259 | seconds = absFloor(milliseconds / 1000);
|
14260 | data.seconds = seconds % 60;
|
14261 | minutes = absFloor(seconds / 60);
|
14262 | data.minutes = minutes % 60;
|
14263 | hours = absFloor(minutes / 60);
|
14264 | data.hours = hours % 24;
|
14265 | days += absFloor(hours / 24);
|
14266 |
|
14267 | monthsFromDays = absFloor(daysToMonths(days));
|
14268 | months += monthsFromDays;
|
14269 | days -= absCeil(monthsToDays(monthsFromDays));
|
14270 |
|
14271 | years = absFloor(months / 12);
|
14272 | months %= 12;
|
14273 | data.days = days;
|
14274 | data.months = months;
|
14275 | data.years = years;
|
14276 | return this;
|
14277 | }
|
14278 |
|
14279 | function daysToMonths(days) {
|
14280 |
|
14281 |
|
14282 | return days * 4800 / 146097;
|
14283 | }
|
14284 |
|
14285 | function monthsToDays(months) {
|
14286 |
|
14287 | return months * 146097 / 4800;
|
14288 | }
|
14289 |
|
14290 | function as(units) {
|
14291 | if (!this.isValid()) {
|
14292 | return NaN;
|
14293 | }
|
14294 |
|
14295 | var days;
|
14296 | var months;
|
14297 | var milliseconds = this._milliseconds;
|
14298 | units = normalizeUnits(units);
|
14299 |
|
14300 | if (units === 'month' || units === 'quarter' || units === 'year') {
|
14301 | days = this._days + milliseconds / 864e5;
|
14302 | months = this._months + daysToMonths(days);
|
14303 |
|
14304 | switch (units) {
|
14305 | case 'month':
|
14306 | return months;
|
14307 |
|
14308 | case 'quarter':
|
14309 | return months / 3;
|
14310 |
|
14311 | case 'year':
|
14312 | return months / 12;
|
14313 | }
|
14314 | } else {
|
14315 |
|
14316 | days = this._days + Math.round(monthsToDays(this._months));
|
14317 |
|
14318 | switch (units) {
|
14319 | case 'week':
|
14320 | return days / 7 + milliseconds / 6048e5;
|
14321 |
|
14322 | case 'day':
|
14323 | return days + milliseconds / 864e5;
|
14324 |
|
14325 | case 'hour':
|
14326 | return days * 24 + milliseconds / 36e5;
|
14327 |
|
14328 | case 'minute':
|
14329 | return days * 1440 + milliseconds / 6e4;
|
14330 |
|
14331 | case 'second':
|
14332 | return days * 86400 + milliseconds / 1000;
|
14333 |
|
14334 |
|
14335 | case 'millisecond':
|
14336 | return Math.floor(days * 864e5) + milliseconds;
|
14337 |
|
14338 | default:
|
14339 | throw new Error('Unknown unit ' + units);
|
14340 | }
|
14341 | }
|
14342 | }
|
14343 |
|
14344 |
|
14345 | function valueOf$1() {
|
14346 | if (!this.isValid()) {
|
14347 | return NaN;
|
14348 | }
|
14349 |
|
14350 | return this._milliseconds + this._days * 864e5 + this._months % 12 * 2592e6 + toInt(this._months / 12) * 31536e6;
|
14351 | }
|
14352 |
|
14353 | function makeAs(alias) {
|
14354 | return function () {
|
14355 | return this.as(alias);
|
14356 | };
|
14357 | }
|
14358 |
|
14359 | var asMilliseconds = makeAs('ms');
|
14360 | var asSeconds = makeAs('s');
|
14361 | var asMinutes = makeAs('m');
|
14362 | var asHours = makeAs('h');
|
14363 | var asDays = makeAs('d');
|
14364 | var asWeeks = makeAs('w');
|
14365 | var asMonths = makeAs('M');
|
14366 | var asQuarters = makeAs('Q');
|
14367 | var asYears = makeAs('y');
|
14368 |
|
14369 | function clone$1() {
|
14370 | return createDuration(this);
|
14371 | }
|
14372 |
|
14373 | function get$2(units) {
|
14374 | units = normalizeUnits(units);
|
14375 | return this.isValid() ? this[units + 's']() : NaN;
|
14376 | }
|
14377 |
|
14378 | function makeGetter(name) {
|
14379 | return function () {
|
14380 | return this.isValid() ? this._data[name] : NaN;
|
14381 | };
|
14382 | }
|
14383 |
|
14384 | var milliseconds = makeGetter('milliseconds');
|
14385 | var seconds = makeGetter('seconds');
|
14386 | var minutes = makeGetter('minutes');
|
14387 | var hours = makeGetter('hours');
|
14388 | var days = makeGetter('days');
|
14389 | var months = makeGetter('months');
|
14390 | var years = makeGetter('years');
|
14391 |
|
14392 | function weeks() {
|
14393 | return absFloor(this.days() / 7);
|
14394 | }
|
14395 |
|
14396 | var round = Math.round;
|
14397 | var thresholds = {
|
14398 | ss: 44,
|
14399 |
|
14400 | s: 45,
|
14401 |
|
14402 | m: 45,
|
14403 |
|
14404 | h: 22,
|
14405 |
|
14406 | d: 26,
|
14407 |
|
14408 | M: 11
|
14409 |
|
14410 | };
|
14411 |
|
14412 | function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
|
14413 | return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
|
14414 | }
|
14415 |
|
14416 | function relativeTime$1(posNegDuration, withoutSuffix, locale) {
|
14417 | var duration = createDuration(posNegDuration).abs();
|
14418 | var seconds = round(duration.as('s'));
|
14419 | var minutes = round(duration.as('m'));
|
14420 | var hours = round(duration.as('h'));
|
14421 | var days = round(duration.as('d'));
|
14422 | var months = round(duration.as('M'));
|
14423 | var years = round(duration.as('y'));
|
14424 | var a = seconds <= thresholds.ss && ['s', seconds] || seconds < thresholds.s && ['ss', seconds] || minutes <= 1 && ['m'] || minutes < thresholds.m && ['mm', minutes] || hours <= 1 && ['h'] || hours < thresholds.h && ['hh', hours] || days <= 1 && ['d'] || days < thresholds.d && ['dd', days] || months <= 1 && ['M'] || months < thresholds.M && ['MM', months] || years <= 1 && ['y'] || ['yy', years];
|
14425 | a[2] = withoutSuffix;
|
14426 | a[3] = +posNegDuration > 0;
|
14427 | a[4] = locale;
|
14428 | return substituteTimeAgo.apply(null, a);
|
14429 | }
|
14430 |
|
14431 |
|
14432 | function getSetRelativeTimeRounding(roundingFunction) {
|
14433 | if (roundingFunction === undefined) {
|
14434 | return round;
|
14435 | }
|
14436 |
|
14437 | if (typeof roundingFunction === 'function') {
|
14438 | round = roundingFunction;
|
14439 | return true;
|
14440 | }
|
14441 |
|
14442 | return false;
|
14443 | }
|
14444 |
|
14445 |
|
14446 | function getSetRelativeTimeThreshold(threshold, limit) {
|
14447 | if (thresholds[threshold] === undefined) {
|
14448 | return false;
|
14449 | }
|
14450 |
|
14451 | if (limit === undefined) {
|
14452 | return thresholds[threshold];
|
14453 | }
|
14454 |
|
14455 | thresholds[threshold] = limit;
|
14456 |
|
14457 | if (threshold === 's') {
|
14458 | thresholds.ss = limit - 1;
|
14459 | }
|
14460 |
|
14461 | return true;
|
14462 | }
|
14463 |
|
14464 | function humanize(withSuffix) {
|
14465 | if (!this.isValid()) {
|
14466 | return this.localeData().invalidDate();
|
14467 | }
|
14468 |
|
14469 | var locale = this.localeData();
|
14470 | var output = relativeTime$1(this, !withSuffix, locale);
|
14471 |
|
14472 | if (withSuffix) {
|
14473 | output = locale.pastFuture(+this, output);
|
14474 | }
|
14475 |
|
14476 | return locale.postformat(output);
|
14477 | }
|
14478 |
|
14479 | var abs$1 = Math.abs;
|
14480 |
|
14481 | function sign(x) {
|
14482 | return (x > 0) - (x < 0) || +x;
|
14483 | }
|
14484 |
|
14485 | function toISOString$1() {
|
14486 |
|
14487 |
|
14488 |
|
14489 |
|
14490 |
|
14491 |
|
14492 |
|
14493 | if (!this.isValid()) {
|
14494 | return this.localeData().invalidDate();
|
14495 | }
|
14496 |
|
14497 | var seconds = abs$1(this._milliseconds) / 1000;
|
14498 | var days = abs$1(this._days);
|
14499 | var months = abs$1(this._months);
|
14500 | var minutes, hours, years;
|
14501 |
|
14502 | minutes = absFloor(seconds / 60);
|
14503 | hours = absFloor(minutes / 60);
|
14504 | seconds %= 60;
|
14505 | minutes %= 60;
|
14506 |
|
14507 | years = absFloor(months / 12);
|
14508 | months %= 12;
|
14509 |
|
14510 | var Y = years;
|
14511 | var M = months;
|
14512 | var D = days;
|
14513 | var h = hours;
|
14514 | var m = minutes;
|
14515 | var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
|
14516 | var total = this.asSeconds();
|
14517 |
|
14518 | if (!total) {
|
14519 |
|
14520 |
|
14521 | return 'P0D';
|
14522 | }
|
14523 |
|
14524 | var totalSign = total < 0 ? '-' : '';
|
14525 | var ymSign = sign(this._months) !== sign(total) ? '-' : '';
|
14526 | var daysSign = sign(this._days) !== sign(total) ? '-' : '';
|
14527 | var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
|
14528 | return totalSign + 'P' + (Y ? ymSign + Y + 'Y' : '') + (M ? ymSign + M + 'M' : '') + (D ? daysSign + D + 'D' : '') + (h || m || s ? 'T' : '') + (h ? hmsSign + h + 'H' : '') + (m ? hmsSign + m + 'M' : '') + (s ? hmsSign + s + 'S' : '');
|
14529 | }
|
14530 |
|
14531 | var proto$2 = Duration.prototype;
|
14532 | proto$2.isValid = isValid$1;
|
14533 | proto$2.abs = abs;
|
14534 | proto$2.add = add$1;
|
14535 | proto$2.subtract = subtract$1;
|
14536 | proto$2.as = as;
|
14537 | proto$2.asMilliseconds = asMilliseconds;
|
14538 | proto$2.asSeconds = asSeconds;
|
14539 | proto$2.asMinutes = asMinutes;
|
14540 | proto$2.asHours = asHours;
|
14541 | proto$2.asDays = asDays;
|
14542 | proto$2.asWeeks = asWeeks;
|
14543 | proto$2.asMonths = asMonths;
|
14544 | proto$2.asQuarters = asQuarters;
|
14545 | proto$2.asYears = asYears;
|
14546 | proto$2.valueOf = valueOf$1;
|
14547 | proto$2._bubble = bubble;
|
14548 | proto$2.clone = clone$1;
|
14549 | proto$2.get = get$2;
|
14550 | proto$2.milliseconds = milliseconds;
|
14551 | proto$2.seconds = seconds;
|
14552 | proto$2.minutes = minutes;
|
14553 | proto$2.hours = hours;
|
14554 | proto$2.days = days;
|
14555 | proto$2.weeks = weeks;
|
14556 | proto$2.months = months;
|
14557 | proto$2.years = years;
|
14558 | proto$2.humanize = humanize;
|
14559 | proto$2.toISOString = toISOString$1;
|
14560 | proto$2.toString = toISOString$1;
|
14561 | proto$2.toJSON = toISOString$1;
|
14562 | proto$2.locale = locale;
|
14563 | proto$2.localeData = localeData;
|
14564 | proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
|
14565 | proto$2.lang = lang; // Side effect imports
|
14566 | // FORMATTING
|
14567 |
|
14568 | addFormatToken('X', 0, 0, 'unix');
|
14569 | addFormatToken('x', 0, 0, 'valueOf'); // PARSING
|
14570 |
|
14571 | addRegexToken('x', matchSigned);
|
14572 | addRegexToken('X', matchTimestamp);
|
14573 | addParseToken('X', function (input, array, config) {
|
14574 | config._d = new Date(parseFloat(input, 10) * 1000);
|
14575 | });
|
14576 | addParseToken('x', function (input, array, config) {
|
14577 | config._d = new Date(toInt(input));
|
14578 | });
|
14579 |
|
14580 | hooks.version = '2.24.0';
|
14581 | setHookCallback(createLocal);
|
14582 | hooks.fn = proto;
|
14583 | hooks.min = min;
|
14584 | hooks.max = max;
|
14585 | hooks.now = now;
|
14586 | hooks.utc = createUTC;
|
14587 | hooks.unix = createUnix;
|
14588 | hooks.months = listMonths;
|
14589 | hooks.isDate = isDate;
|
14590 | hooks.locale = getSetGlobalLocale;
|
14591 | hooks.invalid = createInvalid;
|
14592 | hooks.duration = createDuration;
|
14593 | hooks.isMoment = isMoment;
|
14594 | hooks.weekdays = listWeekdays;
|
14595 | hooks.parseZone = createInZone;
|
14596 | hooks.localeData = getLocale;
|
14597 | hooks.isDuration = isDuration;
|
14598 | hooks.monthsShort = listMonthsShort;
|
14599 | hooks.weekdaysMin = listWeekdaysMin;
|
14600 | hooks.defineLocale = defineLocale;
|
14601 | hooks.updateLocale = updateLocale;
|
14602 | hooks.locales = listLocales;
|
14603 | hooks.weekdaysShort = listWeekdaysShort;
|
14604 | hooks.normalizeUnits = normalizeUnits;
|
14605 | hooks.relativeTimeRounding = getSetRelativeTimeRounding;
|
14606 | hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
|
14607 | hooks.calendarFormat = getCalendarFormat;
|
14608 | hooks.prototype = proto;
|
14609 |
|
14610 | hooks.HTML5_FMT = {
|
14611 | DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm',
|
14612 |
|
14613 | DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss',
|
14614 |
|
14615 | DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS',
|
14616 |
|
14617 | DATE: 'YYYY-MM-DD',
|
14618 |
|
14619 | TIME: 'HH:mm',
|
14620 |
|
14621 | TIME_SECONDS: 'HH:mm:ss',
|
14622 |
|
14623 | TIME_MS: 'HH:mm:ss.SSS',
|
14624 |
|
14625 | WEEK: 'GGGG-[W]WW',
|
14626 |
|
14627 | MONTH: 'YYYY-MM'
|
14628 |
|
14629 | };
|
14630 | return hooks;
|
14631 | });
|
14632 | });
|
14633 |
|
14634 | var byteToHex$2$1 = [];
|
14635 |
|
14636 | for (var i$2$1 = 0; i$2$1 < 256; i$2$1++) {
|
14637 | byteToHex$2$1[i$2$1] = (i$2$1 + 0x100).toString(16).substr(1);
|
14638 | }
|
14639 |
|
14640 |
|
14641 |
|
14642 |
|
14643 |
|
14644 |
|
14645 |
|
14646 | var random$1$1 = function () {
|
14647 | if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
|
14648 |
|
14649 |
|
14650 | var _rnds8 = new Uint8Array(16);
|
14651 |
|
14652 | return function whatwgRNG() {
|
14653 | crypto.getRandomValues(_rnds8);
|
14654 | return _rnds8;
|
14655 | };
|
14656 | }
|
14657 |
|
14658 |
|
14659 |
|
14660 |
|
14661 |
|
14662 | var _rnds = new Array(16);
|
14663 |
|
14664 | return function () {
|
14665 | for (var i = 0, r; i < 16; i++) {
|
14666 | if ((i & 0x03) === 0) {
|
14667 | r = Math.random() * 0x100000000;
|
14668 | }
|
14669 |
|
14670 | _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
|
14671 | }
|
14672 |
|
14673 | return _rnds;
|
14674 | };
|
14675 |
|
14676 |
|
14677 |
|
14678 |
|
14679 |
|
14680 |
|
14681 |
|
14682 | }();
|
14683 |
|
14684 | var byteToHex$1$1$1 = [];
|
14685 |
|
14686 | for (var i$1$1$1 = 0; i$1$1$1 < 256; i$1$1$1++) {
|
14687 | byteToHex$1$1$1[i$1$1$1] = (i$1$1$1 + 0x100).toString(16).substr(1);
|
14688 | }
|
14689 |
|
14690 |
|
14691 |
|
14692 |
|
14693 |
|
14694 |
|
14695 | var seedBytes$1$1 = random$1$1();
|
14696 |
|
14697 | var defaultNodeId$1$1 = [seedBytes$1$1[0] | 0x01, seedBytes$1$1[1], seedBytes$1$1[2], seedBytes$1$1[3], seedBytes$1$1[4], seedBytes$1$1[5]];
|
14698 |
|
14699 | var defaultClockseq$1$1 = (seedBytes$1$1[6] << 8 | seedBytes$1$1[7]) & 0x3fff;
|
14700 |
|
14701 |
|
14702 |
|
14703 | var ASPDateRegex$1 = /^\/?Date\((-?\d+)/i;
|
14704 |
|
14705 |
|
14706 |
|
14707 |
|
14708 |
|
14709 |
|
14710 |
|
14711 |
|
14712 |
|
14713 |
|
14714 |
|
14715 |
|
14716 |
|
14717 | function isNumber$1(value) {
|
14718 | return value instanceof Number || typeof value === 'number';
|
14719 | }
|
14720 |
|
14721 |
|
14722 |
|
14723 |
|
14724 |
|
14725 |
|
14726 |
|
14727 |
|
14728 |
|
14729 | function isString$1(value) {
|
14730 | return value instanceof String || typeof value === 'string';
|
14731 | }
|
14732 |
|
14733 |
|
14734 |
|
14735 |
|
14736 |
|
14737 |
|
14738 |
|
14739 |
|
14740 |
|
14741 |
|
14742 | function isMoment$1(value) {
|
14743 | return moment$1.isMoment(value);
|
14744 | }
|
14745 |
|
14746 |
|
14747 |
|
14748 |
|
14749 |
|
14750 |
|
14751 |
|
14752 |
|
14753 |
|
14754 |
|
14755 |
|
14756 |
|
14757 |
|
14758 | function copyOrDelete$1(a, b, prop, allowDeletion) {
|
14759 | var doDeletion = false;
|
14760 |
|
14761 | if (allowDeletion === true) {
|
14762 | doDeletion = b[prop] === null && a[prop] !== undefined;
|
14763 | }
|
14764 |
|
14765 | if (doDeletion) {
|
14766 | delete a[prop];
|
14767 | } else {
|
14768 | a[prop] = b[prop];
|
14769 | }
|
14770 | }
|
14771 |
|
14772 |
|
14773 |
|
14774 |
|
14775 |
|
14776 |
|
14777 |
|
14778 |
|
14779 |
|
14780 |
|
14781 |
|
14782 |
|
14783 |
|
14784 | function deepExtend$1(a, b) {
|
14785 | var protoExtend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
14786 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
14787 |
|
14788 | for (var prop in b) {
|
14789 | if (Object.prototype.hasOwnProperty.call(b, prop) || protoExtend === true) {
|
14790 | if (b[prop] && b[prop].constructor === Object) {
|
14791 | if (a[prop] === undefined) {
|
14792 | a[prop] = {};
|
14793 | }
|
14794 |
|
14795 | if (a[prop].constructor === Object) {
|
14796 | deepExtend$1(a[prop], b[prop], protoExtend);
|
14797 | } else {
|
14798 | copyOrDelete$1(a, b, prop, allowDeletion);
|
14799 | }
|
14800 | } else if (Array.isArray(b[prop])) {
|
14801 | a[prop] = [];
|
14802 |
|
14803 | for (var i = 0; i < b[prop].length; i++) {
|
14804 | a[prop].push(b[prop][i]);
|
14805 | }
|
14806 | } else {
|
14807 | copyOrDelete$1(a, b, prop, allowDeletion);
|
14808 | }
|
14809 | }
|
14810 | }
|
14811 |
|
14812 | return a;
|
14813 | }
|
14814 |
|
14815 |
|
14816 |
|
14817 |
|
14818 |
|
14819 |
|
14820 |
|
14821 |
|
14822 |
|
14823 |
|
14824 |
|
14825 | function convert$1(object, type) {
|
14826 | var match;
|
14827 |
|
14828 | if (object === undefined) {
|
14829 | return undefined;
|
14830 | }
|
14831 |
|
14832 | if (object === null) {
|
14833 | return null;
|
14834 | }
|
14835 |
|
14836 | if (!type) {
|
14837 | return object;
|
14838 | }
|
14839 |
|
14840 | if (!(typeof type === 'string') && !(type instanceof String)) {
|
14841 | throw new Error('Type must be a string');
|
14842 | }
|
14843 |
|
14844 |
|
14845 | switch (type) {
|
14846 | case 'boolean':
|
14847 | case 'Boolean':
|
14848 | return Boolean(object);
|
14849 |
|
14850 | case 'number':
|
14851 | case 'Number':
|
14852 | if (isString$1(object) && !isNaN(Date.parse(object))) {
|
14853 | return moment$1(object).valueOf();
|
14854 | } else {
|
14855 |
|
14856 |
|
14857 |
|
14858 | return Number(object.valueOf());
|
14859 | }
|
14860 |
|
14861 | case 'string':
|
14862 | case 'String':
|
14863 | return String(object);
|
14864 |
|
14865 | case 'Date':
|
14866 | if (isNumber$1(object)) {
|
14867 | return new Date(object);
|
14868 | }
|
14869 |
|
14870 | if (object instanceof Date) {
|
14871 | return new Date(object.valueOf());
|
14872 | } else if (isMoment$1(object)) {
|
14873 | return new Date(object.valueOf());
|
14874 | }
|
14875 |
|
14876 | if (isString$1(object)) {
|
14877 | match = ASPDateRegex$1.exec(object);
|
14878 |
|
14879 | if (match) {
|
14880 |
|
14881 | return new Date(Number(match[1]));
|
14882 | } else {
|
14883 | return moment$1(new Date(object)).toDate();
|
14884 | }
|
14885 | } else {
|
14886 | throw new Error('Cannot convert object of type ' + getType$1(object) + ' to type Date');
|
14887 | }
|
14888 |
|
14889 | case 'Moment':
|
14890 | if (isNumber$1(object)) {
|
14891 | return moment$1(object);
|
14892 | }
|
14893 |
|
14894 | if (object instanceof Date) {
|
14895 | return moment$1(object.valueOf());
|
14896 | } else if (isMoment$1(object)) {
|
14897 | return moment$1(object);
|
14898 | }
|
14899 |
|
14900 | if (isString$1(object)) {
|
14901 | match = ASPDateRegex$1.exec(object);
|
14902 |
|
14903 | if (match) {
|
14904 |
|
14905 | return moment$1(Number(match[1]));
|
14906 | } else {
|
14907 | return moment$1(object);
|
14908 | }
|
14909 | } else {
|
14910 | throw new Error('Cannot convert object of type ' + getType$1(object) + ' to type Date');
|
14911 | }
|
14912 |
|
14913 | case 'ISODate':
|
14914 | if (isNumber$1(object)) {
|
14915 | return new Date(object);
|
14916 | } else if (object instanceof Date) {
|
14917 | return object.toISOString();
|
14918 | } else if (isMoment$1(object)) {
|
14919 | return object.toDate().toISOString();
|
14920 | } else if (isString$1(object)) {
|
14921 | match = ASPDateRegex$1.exec(object);
|
14922 |
|
14923 | if (match) {
|
14924 |
|
14925 | return new Date(Number(match[1])).toISOString();
|
14926 | } else {
|
14927 | return moment$1(object).format();
|
14928 | }
|
14929 | } else {
|
14930 | throw new Error('Cannot convert object of type ' + getType$1(object) + ' to type ISODate');
|
14931 | }
|
14932 |
|
14933 | case 'ASPDate':
|
14934 | if (isNumber$1(object)) {
|
14935 | return '/Date(' + object + ')/';
|
14936 | } else if (object instanceof Date) {
|
14937 | return '/Date(' + object.valueOf() + ')/';
|
14938 | } else if (isString$1(object)) {
|
14939 | match = ASPDateRegex$1.exec(object);
|
14940 |
|
14941 | var _value;
|
14942 |
|
14943 | if (match) {
|
14944 |
|
14945 | _value = new Date(Number(match[1])).valueOf();
|
14946 | } else {
|
14947 | _value = new Date(object).valueOf();
|
14948 | }
|
14949 |
|
14950 | return '/Date(' + _value + ')/';
|
14951 | } else {
|
14952 | throw new Error('Cannot convert object of type ' + getType$1(object) + ' to type ASPDate');
|
14953 | }
|
14954 |
|
14955 | default:
|
14956 | var never = type;
|
14957 | throw new Error("Unknown type ".concat(never));
|
14958 | }
|
14959 | }
|
14960 |
|
14961 |
|
14962 |
|
14963 |
|
14964 |
|
14965 |
|
14966 |
|
14967 |
|
14968 |
|
14969 | function getType$1(object) {
|
14970 | var type = _typeof$1(object);
|
14971 |
|
14972 | if (type === 'object') {
|
14973 | if (object === null) {
|
14974 | return 'null';
|
14975 | }
|
14976 |
|
14977 | if (object instanceof Boolean) {
|
14978 | return 'Boolean';
|
14979 | }
|
14980 |
|
14981 | if (object instanceof Number) {
|
14982 | return 'Number';
|
14983 | }
|
14984 |
|
14985 | if (object instanceof String) {
|
14986 | return 'String';
|
14987 | }
|
14988 |
|
14989 | if (Array.isArray(object)) {
|
14990 | return 'Array';
|
14991 | }
|
14992 |
|
14993 | if (object instanceof Date) {
|
14994 | return 'Date';
|
14995 | }
|
14996 |
|
14997 | return 'Object';
|
14998 | }
|
14999 |
|
15000 | if (type === 'number') {
|
15001 | return 'Number';
|
15002 | }
|
15003 |
|
15004 | if (type === 'boolean') {
|
15005 | return 'Boolean';
|
15006 | }
|
15007 |
|
15008 | if (type === 'string') {
|
15009 | return 'String';
|
15010 | }
|
15011 |
|
15012 | if (type === undefined) {
|
15013 | return 'undefined';
|
15014 | }
|
15015 |
|
15016 | return type;
|
15017 | }
|
15018 |
|
15019 |
|
15020 |
|
15021 |
|
15022 |
|
15023 |
|
15024 |
|
15025 |
|
15026 |
|
15027 | function isId(value) {
|
15028 | return typeof value === "string" || typeof value === "number";
|
15029 | }
|
15030 |
|
15031 |
|
15032 |
|
15033 |
|
15034 |
|
15035 |
|
15036 |
|
15037 |
|
15038 |
|
15039 | var Queue =
|
15040 |
|
15041 | function () {
|
15042 | |
15043 |
|
15044 |
|
15045 |
|
15046 |
|
15047 | function Queue(options) {
|
15048 | classCallCheck(this, Queue);
|
15049 | this._queue = [];
|
15050 | this._timeout = null;
|
15051 | this._extended = null;
|
15052 |
|
15053 | this.delay = null;
|
15054 | this.max = Infinity;
|
15055 | this.setOptions(options);
|
15056 | }
|
15057 | |
15058 |
|
15059 |
|
15060 |
|
15061 |
|
15062 |
|
15063 |
|
15064 | createClass(Queue, [{
|
15065 | key: "setOptions",
|
15066 | value: function setOptions(options) {
|
15067 | if (options && typeof options.delay !== "undefined") {
|
15068 | this.delay = options.delay;
|
15069 | }
|
15070 |
|
15071 | if (options && typeof options.max !== "undefined") {
|
15072 | this.max = options.max;
|
15073 | }
|
15074 |
|
15075 | this._flushIfNeeded();
|
15076 | }
|
15077 | |
15078 |
|
15079 |
|
15080 |
|
15081 |
|
15082 |
|
15083 |
|
15084 |
|
15085 |
|
15086 |
|
15087 | }, {
|
15088 | key: "destroy",
|
15089 |
|
15090 | |
15091 |
|
15092 |
|
15093 | value: function destroy() {
|
15094 | this.flush();
|
15095 |
|
15096 | if (this._extended) {
|
15097 | var object = this._extended.object;
|
15098 | var methods = this._extended.methods;
|
15099 |
|
15100 | for (var i = 0; i < methods.length; i++) {
|
15101 | var method = methods[i];
|
15102 |
|
15103 | if (method.original) {
|
15104 |
|
15105 | object[method.name] = method.original;
|
15106 | } else {
|
15107 |
|
15108 | delete object[method.name];
|
15109 | }
|
15110 | }
|
15111 |
|
15112 | this._extended = null;
|
15113 | }
|
15114 | }
|
15115 | |
15116 |
|
15117 |
|
15118 |
|
15119 |
|
15120 |
|
15121 |
|
15122 | }, {
|
15123 | key: "replace",
|
15124 | value: function replace(object, method) {
|
15125 | var me = this;
|
15126 | var original = object[method];
|
15127 |
|
15128 | if (!original) {
|
15129 | throw new Error("Method " + method + " undefined");
|
15130 | }
|
15131 |
|
15132 | object[method] = function () {
|
15133 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
15134 | args[_key] = arguments[_key];
|
15135 | }
|
15136 |
|
15137 |
|
15138 | me.queue({
|
15139 | args: args,
|
15140 | fn: original,
|
15141 | context: this
|
15142 | });
|
15143 | };
|
15144 | }
|
15145 | |
15146 |
|
15147 |
|
15148 |
|
15149 |
|
15150 |
|
15151 | }, {
|
15152 | key: "queue",
|
15153 | value: function queue(entry) {
|
15154 | if (typeof entry === "function") {
|
15155 | this._queue.push({
|
15156 | fn: entry
|
15157 | });
|
15158 | } else {
|
15159 | this._queue.push(entry);
|
15160 | }
|
15161 |
|
15162 | this._flushIfNeeded();
|
15163 | }
|
15164 | |
15165 |
|
15166 |
|
15167 |
|
15168 | }, {
|
15169 | key: "_flushIfNeeded",
|
15170 | value: function _flushIfNeeded() {
|
15171 | var _this = this;
|
15172 |
|
15173 |
|
15174 | if (this._queue.length > this.max) {
|
15175 | this.flush();
|
15176 | }
|
15177 |
|
15178 |
|
15179 | if (this._timeout != null) {
|
15180 | clearTimeout(this._timeout);
|
15181 | this._timeout = null;
|
15182 | }
|
15183 |
|
15184 | if (this.queue.length > 0 && typeof this.delay === "number") {
|
15185 | this._timeout = setTimeout(function () {
|
15186 | _this.flush();
|
15187 | }, this.delay);
|
15188 | }
|
15189 | }
|
15190 | |
15191 |
|
15192 |
|
15193 |
|
15194 | }, {
|
15195 | key: "flush",
|
15196 | value: function flush() {
|
15197 | this._queue.splice(0).forEach(function (entry) {
|
15198 | entry.fn.apply(entry.context || entry.fn, entry.args || []);
|
15199 | });
|
15200 | }
|
15201 | }], [{
|
15202 | key: "extend",
|
15203 | value: function extend(object, options) {
|
15204 | var queue = new Queue(options);
|
15205 |
|
15206 | if (object.flush !== undefined) {
|
15207 | throw new Error("Target object already has a property flush");
|
15208 | }
|
15209 |
|
15210 | object.flush = function () {
|
15211 | queue.flush();
|
15212 | };
|
15213 |
|
15214 | var methods = [{
|
15215 | name: "flush",
|
15216 | original: undefined
|
15217 | }];
|
15218 |
|
15219 | if (options && options.replace) {
|
15220 | for (var i = 0; i < options.replace.length; i++) {
|
15221 | var name = options.replace[i];
|
15222 | methods.push({
|
15223 | name: name,
|
15224 |
|
15225 | original: object[name]
|
15226 | });
|
15227 |
|
15228 | queue.replace(object, name);
|
15229 | }
|
15230 | }
|
15231 |
|
15232 | queue._extended = {
|
15233 | object: object,
|
15234 | methods: methods
|
15235 | };
|
15236 | return queue;
|
15237 | }
|
15238 | }]);
|
15239 | return Queue;
|
15240 | }();
|
15241 |
|
15242 |
|
15243 |
|
15244 |
|
15245 |
|
15246 |
|
15247 |
|
15248 |
|
15249 |
|
15250 |
|
15251 | var DataSetPart =
|
15252 |
|
15253 | function () {
|
15254 | function DataSetPart() {
|
15255 | classCallCheck(this, DataSetPart);
|
15256 | this._subscribers = {
|
15257 | "*": [],
|
15258 | add: [],
|
15259 | remove: [],
|
15260 | update: []
|
15261 | };
|
15262 | |
15263 |
|
15264 |
|
15265 |
|
15266 | this.subscribe = DataSetPart.prototype.on;
|
15267 | |
15268 |
|
15269 |
|
15270 |
|
15271 | this.unsubscribe = DataSetPart.prototype.off;
|
15272 | }
|
15273 | |
15274 |
|
15275 |
|
15276 |
|
15277 |
|
15278 |
|
15279 |
|
15280 |
|
15281 |
|
15282 | createClass(DataSetPart, [{
|
15283 | key: "_trigger",
|
15284 | value: function _trigger(event, payload, senderId) {
|
15285 | if (event === "*") {
|
15286 | throw new Error("Cannot trigger event *");
|
15287 | }
|
15288 |
|
15289 | [].concat(toConsumableArray(this._subscribers[event]), toConsumableArray(this._subscribers["*"])).forEach(function (subscriber) {
|
15290 | subscriber(event, payload, senderId != null ? senderId : null);
|
15291 | });
|
15292 | }
|
15293 | |
15294 |
|
15295 |
|
15296 |
|
15297 |
|
15298 |
|
15299 |
|
15300 |
|
15301 |
|
15302 | }, {
|
15303 | key: "on",
|
15304 | value: function on(event, callback) {
|
15305 | if (typeof callback === "function") {
|
15306 | this._subscribers[event].push(callback);
|
15307 | }
|
15308 |
|
15309 | }
|
15310 | |
15311 |
|
15312 |
|
15313 |
|
15314 |
|
15315 |
|
15316 |
|
15317 |
|
15318 |
|
15319 | }, {
|
15320 | key: "off",
|
15321 | value: function off(event, callback) {
|
15322 | this._subscribers[event] = this._subscribers[event].filter(function (subscriber) {
|
15323 | return subscriber !== callback;
|
15324 | });
|
15325 | }
|
15326 | }]);
|
15327 | return DataSetPart;
|
15328 | }();
|
15329 |
|
15330 | function _arrayWithHoles(arr) {
|
15331 | if (Array.isArray(arr)) return arr;
|
15332 | }
|
15333 |
|
15334 | var arrayWithHoles = _arrayWithHoles;
|
15335 |
|
15336 | function _iterableToArrayLimit(arr, i) {
|
15337 | var _arr = [];
|
15338 | var _n = true;
|
15339 | var _d = false;
|
15340 | var _e = undefined;
|
15341 |
|
15342 | try {
|
15343 | for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
15344 | _arr.push(_s.value);
|
15345 |
|
15346 | if (i && _arr.length === i) break;
|
15347 | }
|
15348 | } catch (err) {
|
15349 | _d = true;
|
15350 | _e = err;
|
15351 | } finally {
|
15352 | try {
|
15353 | if (!_n && _i["return"] != null) _i["return"]();
|
15354 | } finally {
|
15355 | if (_d) throw _e;
|
15356 | }
|
15357 | }
|
15358 |
|
15359 | return _arr;
|
15360 | }
|
15361 |
|
15362 | var iterableToArrayLimit = _iterableToArrayLimit;
|
15363 |
|
15364 | function _nonIterableRest() {
|
15365 | throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
15366 | }
|
15367 |
|
15368 | var nonIterableRest = _nonIterableRest;
|
15369 |
|
15370 | function _slicedToArray(arr, i) {
|
15371 | return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();
|
15372 | }
|
15373 |
|
15374 | var slicedToArray = _slicedToArray;
|
15375 |
|
15376 |
|
15377 |
|
15378 |
|
15379 |
|
15380 |
|
15381 |
|
15382 |
|
15383 |
|
15384 |
|
15385 |
|
15386 | var DataStream =
|
15387 |
|
15388 | function () {
|
15389 | |
15390 |
|
15391 |
|
15392 |
|
15393 |
|
15394 | function DataStream(_pairs) {
|
15395 | classCallCheck(this, DataStream);
|
15396 | this._pairs = _pairs;
|
15397 | }
|
15398 | |
15399 |
|
15400 |
|
15401 |
|
15402 |
|
15403 | createClass(DataStream, [{
|
15404 | key: Symbol.iterator,
|
15405 | value:
|
15406 |
|
15407 | regenerator.mark(function value() {
|
15408 | var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step$value, id, item;
|
15409 |
|
15410 | return regenerator.wrap(function value$(_context) {
|
15411 | while (1) {
|
15412 | switch (_context.prev = _context.next) {
|
15413 | case 0:
|
15414 | _iteratorNormalCompletion = true;
|
15415 | _didIteratorError = false;
|
15416 | _iteratorError = undefined;
|
15417 | _context.prev = 3;
|
15418 | _iterator = this._pairs[Symbol.iterator]();
|
15419 |
|
15420 | case 5:
|
15421 | if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
|
15422 | _context.next = 12;
|
15423 | break;
|
15424 | }
|
15425 |
|
15426 | _step$value = slicedToArray(_step.value, 2), id = _step$value[0], item = _step$value[1];
|
15427 | _context.next = 9;
|
15428 | return [id, item];
|
15429 |
|
15430 | case 9:
|
15431 | _iteratorNormalCompletion = true;
|
15432 | _context.next = 5;
|
15433 | break;
|
15434 |
|
15435 | case 12:
|
15436 | _context.next = 18;
|
15437 | break;
|
15438 |
|
15439 | case 14:
|
15440 | _context.prev = 14;
|
15441 | _context.t0 = _context["catch"](3);
|
15442 | _didIteratorError = true;
|
15443 | _iteratorError = _context.t0;
|
15444 |
|
15445 | case 18:
|
15446 | _context.prev = 18;
|
15447 | _context.prev = 19;
|
15448 |
|
15449 | if (!_iteratorNormalCompletion && _iterator.return != null) {
|
15450 | _iterator.return();
|
15451 | }
|
15452 |
|
15453 | case 21:
|
15454 | _context.prev = 21;
|
15455 |
|
15456 | if (!_didIteratorError) {
|
15457 | _context.next = 24;
|
15458 | break;
|
15459 | }
|
15460 |
|
15461 | throw _iteratorError;
|
15462 |
|
15463 | case 24:
|
15464 | return _context.finish(21);
|
15465 |
|
15466 | case 25:
|
15467 | return _context.finish(18);
|
15468 |
|
15469 | case 26:
|
15470 | case "end":
|
15471 | return _context.stop();
|
15472 | }
|
15473 | }
|
15474 | }, value, this, [[3, 14, 18, 26], [19,, 21, 25]]);
|
15475 | })
|
15476 | |
15477 |
|
15478 |
|
15479 |
|
15480 | }, {
|
15481 | key: "entries",
|
15482 | value:
|
15483 |
|
15484 | regenerator.mark(function entries() {
|
15485 | var _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step2$value, id, item;
|
15486 |
|
15487 | return regenerator.wrap(function entries$(_context2) {
|
15488 | while (1) {
|
15489 | switch (_context2.prev = _context2.next) {
|
15490 | case 0:
|
15491 | _iteratorNormalCompletion2 = true;
|
15492 | _didIteratorError2 = false;
|
15493 | _iteratorError2 = undefined;
|
15494 | _context2.prev = 3;
|
15495 | _iterator2 = this._pairs[Symbol.iterator]();
|
15496 |
|
15497 | case 5:
|
15498 | if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) {
|
15499 | _context2.next = 12;
|
15500 | break;
|
15501 | }
|
15502 |
|
15503 | _step2$value = slicedToArray(_step2.value, 2), id = _step2$value[0], item = _step2$value[1];
|
15504 | _context2.next = 9;
|
15505 | return [id, item];
|
15506 |
|
15507 | case 9:
|
15508 | _iteratorNormalCompletion2 = true;
|
15509 | _context2.next = 5;
|
15510 | break;
|
15511 |
|
15512 | case 12:
|
15513 | _context2.next = 18;
|
15514 | break;
|
15515 |
|
15516 | case 14:
|
15517 | _context2.prev = 14;
|
15518 | _context2.t0 = _context2["catch"](3);
|
15519 | _didIteratorError2 = true;
|
15520 | _iteratorError2 = _context2.t0;
|
15521 |
|
15522 | case 18:
|
15523 | _context2.prev = 18;
|
15524 | _context2.prev = 19;
|
15525 |
|
15526 | if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
15527 | _iterator2.return();
|
15528 | }
|
15529 |
|
15530 | case 21:
|
15531 | _context2.prev = 21;
|
15532 |
|
15533 | if (!_didIteratorError2) {
|
15534 | _context2.next = 24;
|
15535 | break;
|
15536 | }
|
15537 |
|
15538 | throw _iteratorError2;
|
15539 |
|
15540 | case 24:
|
15541 | return _context2.finish(21);
|
15542 |
|
15543 | case 25:
|
15544 | return _context2.finish(18);
|
15545 |
|
15546 | case 26:
|
15547 | case "end":
|
15548 | return _context2.stop();
|
15549 | }
|
15550 | }
|
15551 | }, entries, this, [[3, 14, 18, 26], [19,, 21, 25]]);
|
15552 | })
|
15553 | |
15554 |
|
15555 |
|
15556 |
|
15557 | }, {
|
15558 | key: "keys",
|
15559 | value:
|
15560 |
|
15561 | regenerator.mark(function keys() {
|
15562 | var _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _step3$value, id;
|
15563 |
|
15564 | return regenerator.wrap(function keys$(_context3) {
|
15565 | while (1) {
|
15566 | switch (_context3.prev = _context3.next) {
|
15567 | case 0:
|
15568 | _iteratorNormalCompletion3 = true;
|
15569 | _didIteratorError3 = false;
|
15570 | _iteratorError3 = undefined;
|
15571 | _context3.prev = 3;
|
15572 | _iterator3 = this._pairs[Symbol.iterator]();
|
15573 |
|
15574 | case 5:
|
15575 | if (_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done) {
|
15576 | _context3.next = 12;
|
15577 | break;
|
15578 | }
|
15579 |
|
15580 | _step3$value = slicedToArray(_step3.value, 1), id = _step3$value[0];
|
15581 | _context3.next = 9;
|
15582 | return id;
|
15583 |
|
15584 | case 9:
|
15585 | _iteratorNormalCompletion3 = true;
|
15586 | _context3.next = 5;
|
15587 | break;
|
15588 |
|
15589 | case 12:
|
15590 | _context3.next = 18;
|
15591 | break;
|
15592 |
|
15593 | case 14:
|
15594 | _context3.prev = 14;
|
15595 | _context3.t0 = _context3["catch"](3);
|
15596 | _didIteratorError3 = true;
|
15597 | _iteratorError3 = _context3.t0;
|
15598 |
|
15599 | case 18:
|
15600 | _context3.prev = 18;
|
15601 | _context3.prev = 19;
|
15602 |
|
15603 | if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
15604 | _iterator3.return();
|
15605 | }
|
15606 |
|
15607 | case 21:
|
15608 | _context3.prev = 21;
|
15609 |
|
15610 | if (!_didIteratorError3) {
|
15611 | _context3.next = 24;
|
15612 | break;
|
15613 | }
|
15614 |
|
15615 | throw _iteratorError3;
|
15616 |
|
15617 | case 24:
|
15618 | return _context3.finish(21);
|
15619 |
|
15620 | case 25:
|
15621 | return _context3.finish(18);
|
15622 |
|
15623 | case 26:
|
15624 | case "end":
|
15625 | return _context3.stop();
|
15626 | }
|
15627 | }
|
15628 | }, keys, this, [[3, 14, 18, 26], [19,, 21, 25]]);
|
15629 | })
|
15630 | |
15631 |
|
15632 |
|
15633 |
|
15634 | }, {
|
15635 | key: "values",
|
15636 | value:
|
15637 |
|
15638 | regenerator.mark(function values() {
|
15639 | var _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _step4$value, item;
|
15640 |
|
15641 | return regenerator.wrap(function values$(_context4) {
|
15642 | while (1) {
|
15643 | switch (_context4.prev = _context4.next) {
|
15644 | case 0:
|
15645 | _iteratorNormalCompletion4 = true;
|
15646 | _didIteratorError4 = false;
|
15647 | _iteratorError4 = undefined;
|
15648 | _context4.prev = 3;
|
15649 | _iterator4 = this._pairs[Symbol.iterator]();
|
15650 |
|
15651 | case 5:
|
15652 | if (_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done) {
|
15653 | _context4.next = 12;
|
15654 | break;
|
15655 | }
|
15656 |
|
15657 | _step4$value = slicedToArray(_step4.value, 2), item = _step4$value[1];
|
15658 | _context4.next = 9;
|
15659 | return item;
|
15660 |
|
15661 | case 9:
|
15662 | _iteratorNormalCompletion4 = true;
|
15663 | _context4.next = 5;
|
15664 | break;
|
15665 |
|
15666 | case 12:
|
15667 | _context4.next = 18;
|
15668 | break;
|
15669 |
|
15670 | case 14:
|
15671 | _context4.prev = 14;
|
15672 | _context4.t0 = _context4["catch"](3);
|
15673 | _didIteratorError4 = true;
|
15674 | _iteratorError4 = _context4.t0;
|
15675 |
|
15676 | case 18:
|
15677 | _context4.prev = 18;
|
15678 | _context4.prev = 19;
|
15679 |
|
15680 | if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
15681 | _iterator4.return();
|
15682 | }
|
15683 |
|
15684 | case 21:
|
15685 | _context4.prev = 21;
|
15686 |
|
15687 | if (!_didIteratorError4) {
|
15688 | _context4.next = 24;
|
15689 | break;
|
15690 | }
|
15691 |
|
15692 | throw _iteratorError4;
|
15693 |
|
15694 | case 24:
|
15695 | return _context4.finish(21);
|
15696 |
|
15697 | case 25:
|
15698 | return _context4.finish(18);
|
15699 |
|
15700 | case 26:
|
15701 | case "end":
|
15702 | return _context4.stop();
|
15703 | }
|
15704 | }
|
15705 | }, values, this, [[3, 14, 18, 26], [19,, 21, 25]]);
|
15706 | })
|
15707 | |
15708 |
|
15709 |
|
15710 |
|
15711 |
|
15712 |
|
15713 |
|
15714 |
|
15715 |
|
15716 | }, {
|
15717 | key: "toIdArray",
|
15718 | value: function toIdArray() {
|
15719 | return toConsumableArray(this._pairs).map(function (pair) {
|
15720 | return pair[0];
|
15721 | });
|
15722 | }
|
15723 | |
15724 |
|
15725 |
|
15726 |
|
15727 |
|
15728 |
|
15729 |
|
15730 |
|
15731 |
|
15732 | }, {
|
15733 | key: "toItemArray",
|
15734 | value: function toItemArray() {
|
15735 | return toConsumableArray(this._pairs).map(function (pair) {
|
15736 | return pair[1];
|
15737 | });
|
15738 | }
|
15739 | |
15740 |
|
15741 |
|
15742 |
|
15743 |
|
15744 |
|
15745 |
|
15746 |
|
15747 |
|
15748 | }, {
|
15749 | key: "toEntryArray",
|
15750 | value: function toEntryArray() {
|
15751 | return toConsumableArray(this._pairs);
|
15752 | }
|
15753 | |
15754 |
|
15755 |
|
15756 |
|
15757 |
|
15758 |
|
15759 |
|
15760 |
|
15761 |
|
15762 | }, {
|
15763 | key: "toObjectMap",
|
15764 | value: function toObjectMap() {
|
15765 | var map = Object.create(null);
|
15766 | var _iteratorNormalCompletion5 = true;
|
15767 | var _didIteratorError5 = false;
|
15768 | var _iteratorError5 = undefined;
|
15769 |
|
15770 | try {
|
15771 | for (var _iterator5 = this._pairs[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
15772 | var _step5$value = slicedToArray(_step5.value, 2),
|
15773 | id = _step5$value[0],
|
15774 | item = _step5$value[1];
|
15775 |
|
15776 | map[id] = item;
|
15777 | }
|
15778 | } catch (err) {
|
15779 | _didIteratorError5 = true;
|
15780 | _iteratorError5 = err;
|
15781 | } finally {
|
15782 | try {
|
15783 | if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
15784 | _iterator5.return();
|
15785 | }
|
15786 | } finally {
|
15787 | if (_didIteratorError5) {
|
15788 | throw _iteratorError5;
|
15789 | }
|
15790 | }
|
15791 | }
|
15792 |
|
15793 | return map;
|
15794 | }
|
15795 | |
15796 |
|
15797 |
|
15798 |
|
15799 |
|
15800 |
|
15801 | }, {
|
15802 | key: "toMap",
|
15803 | value: function toMap() {
|
15804 | return new Map(this._pairs);
|
15805 | }
|
15806 | |
15807 |
|
15808 |
|
15809 |
|
15810 |
|
15811 |
|
15812 | }, {
|
15813 | key: "toIdSet",
|
15814 | value: function toIdSet() {
|
15815 | return new Set(this.toIdArray());
|
15816 | }
|
15817 | |
15818 |
|
15819 |
|
15820 |
|
15821 |
|
15822 |
|
15823 | }, {
|
15824 | key: "toItemSet",
|
15825 | value: function toItemSet() {
|
15826 | return new Set(this.toItemArray());
|
15827 | }
|
15828 | |
15829 |
|
15830 |
|
15831 |
|
15832 |
|
15833 |
|
15834 |
|
15835 |
|
15836 |
|
15837 |
|
15838 |
|
15839 |
|
15840 |
|
15841 |
|
15842 |
|
15843 |
|
15844 |
|
15845 |
|
15846 |
|
15847 |
|
15848 |
|
15849 |
|
15850 |
|
15851 |
|
15852 | }, {
|
15853 | key: "cache",
|
15854 | value: function cache() {
|
15855 | return new DataStream(toConsumableArray(this._pairs));
|
15856 | }
|
15857 | |
15858 |
|
15859 |
|
15860 |
|
15861 |
|
15862 |
|
15863 |
|
15864 |
|
15865 |
|
15866 |
|
15867 | }, {
|
15868 | key: "distinct",
|
15869 | value: function distinct(callback) {
|
15870 | var set = new Set();
|
15871 | var _iteratorNormalCompletion6 = true;
|
15872 | var _didIteratorError6 = false;
|
15873 | var _iteratorError6 = undefined;
|
15874 |
|
15875 | try {
|
15876 | for (var _iterator6 = this._pairs[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
|
15877 | var _step6$value = slicedToArray(_step6.value, 2),
|
15878 | id = _step6$value[0],
|
15879 | item = _step6$value[1];
|
15880 |
|
15881 | set.add(callback(item, id));
|
15882 | }
|
15883 | } catch (err) {
|
15884 | _didIteratorError6 = true;
|
15885 | _iteratorError6 = err;
|
15886 | } finally {
|
15887 | try {
|
15888 | if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
|
15889 | _iterator6.return();
|
15890 | }
|
15891 | } finally {
|
15892 | if (_didIteratorError6) {
|
15893 | throw _iteratorError6;
|
15894 | }
|
15895 | }
|
15896 | }
|
15897 |
|
15898 | return set;
|
15899 | }
|
15900 | /**
|
15901 | * Filter the items of the stream.
|
15902 | *
|
15903 | * @param callback - The function that decides whether an item will be included.
|
15904 | *
|
15905 | * @returns A new data stream with the filtered items.
|
15906 | */
|
15907 |
|
15908 | }, {
|
15909 | key: "filter",
|
15910 | value: function filter(callback) {
|
15911 | var pairs = this._pairs;
|
15912 | return new DataStream(defineProperty$1({}, Symbol.iterator,
|
15913 |
|
15914 | regenerator.mark(function _callee() {
|
15915 | var _iteratorNormalCompletion7, _didIteratorError7, _iteratorError7, _iterator7, _step7, _step7$value, id, item;
|
15916 |
|
15917 | return regenerator.wrap(function _callee$(_context5) {
|
15918 | while (1) {
|
15919 | switch (_context5.prev = _context5.next) {
|
15920 | case 0:
|
15921 | _iteratorNormalCompletion7 = true;
|
15922 | _didIteratorError7 = false;
|
15923 | _iteratorError7 = undefined;
|
15924 | _context5.prev = 3;
|
15925 | _iterator7 = pairs[Symbol.iterator]();
|
15926 |
|
15927 | case 5:
|
15928 | if (_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done) {
|
15929 | _context5.next = 13;
|
15930 | break;
|
15931 | }
|
15932 |
|
15933 | _step7$value = slicedToArray(_step7.value, 2), id = _step7$value[0], item = _step7$value[1];
|
15934 |
|
15935 | if (!callback(item, id)) {
|
15936 | _context5.next = 10;
|
15937 | break;
|
15938 | }
|
15939 |
|
15940 | _context5.next = 10;
|
15941 | return [id, item];
|
15942 |
|
15943 | case 10:
|
15944 | _iteratorNormalCompletion7 = true;
|
15945 | _context5.next = 5;
|
15946 | break;
|
15947 |
|
15948 | case 13:
|
15949 | _context5.next = 19;
|
15950 | break;
|
15951 |
|
15952 | case 15:
|
15953 | _context5.prev = 15;
|
15954 | _context5.t0 = _context5["catch"](3);
|
15955 | _didIteratorError7 = true;
|
15956 | _iteratorError7 = _context5.t0;
|
15957 |
|
15958 | case 19:
|
15959 | _context5.prev = 19;
|
15960 | _context5.prev = 20;
|
15961 |
|
15962 | if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
|
15963 | _iterator7.return();
|
15964 | }
|
15965 |
|
15966 | case 22:
|
15967 | _context5.prev = 22;
|
15968 |
|
15969 | if (!_didIteratorError7) {
|
15970 | _context5.next = 25;
|
15971 | break;
|
15972 | }
|
15973 |
|
15974 | throw _iteratorError7;
|
15975 |
|
15976 | case 25:
|
15977 | return _context5.finish(22);
|
15978 |
|
15979 | case 26:
|
15980 | return _context5.finish(19);
|
15981 |
|
15982 | case 27:
|
15983 | case "end":
|
15984 | return _context5.stop();
|
15985 | }
|
15986 | }
|
15987 | }, _callee, null, [[3, 15, 19, 27], [20,, 22, 26]]);
|
15988 | })));
|
15989 | }
|
15990 | |
15991 |
|
15992 |
|
15993 |
|
15994 |
|
15995 |
|
15996 | }, {
|
15997 | key: "forEach",
|
15998 | value: function forEach(callback) {
|
15999 | var _iteratorNormalCompletion8 = true;
|
16000 | var _didIteratorError8 = false;
|
16001 | var _iteratorError8 = undefined;
|
16002 |
|
16003 | try {
|
16004 | for (var _iterator8 = this._pairs[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
|
16005 | var _step8$value = slicedToArray(_step8.value, 2),
|
16006 | id = _step8$value[0],
|
16007 | item = _step8$value[1];
|
16008 |
|
16009 | callback(item, id);
|
16010 | }
|
16011 | } catch (err) {
|
16012 | _didIteratorError8 = true;
|
16013 | _iteratorError8 = err;
|
16014 | } finally {
|
16015 | try {
|
16016 | if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
|
16017 | _iterator8.return();
|
16018 | }
|
16019 | } finally {
|
16020 | if (_didIteratorError8) {
|
16021 | throw _iteratorError8;
|
16022 | }
|
16023 | }
|
16024 | }
|
16025 | }
|
16026 | |
16027 |
|
16028 |
|
16029 |
|
16030 |
|
16031 |
|
16032 |
|
16033 |
|
16034 |
|
16035 |
|
16036 | }, {
|
16037 | key: "map",
|
16038 | value: function map(callback) {
|
16039 | var pairs = this._pairs;
|
16040 | return new DataStream(defineProperty$1({}, Symbol.iterator,
|
16041 |
|
16042 | regenerator.mark(function _callee2() {
|
16043 | var _iteratorNormalCompletion9, _didIteratorError9, _iteratorError9, _iterator9, _step9, _step9$value, id, item;
|
16044 |
|
16045 | return regenerator.wrap(function _callee2$(_context6) {
|
16046 | while (1) {
|
16047 | switch (_context6.prev = _context6.next) {
|
16048 | case 0:
|
16049 | _iteratorNormalCompletion9 = true;
|
16050 | _didIteratorError9 = false;
|
16051 | _iteratorError9 = undefined;
|
16052 | _context6.prev = 3;
|
16053 | _iterator9 = pairs[Symbol.iterator]();
|
16054 |
|
16055 | case 5:
|
16056 | if (_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done) {
|
16057 | _context6.next = 12;
|
16058 | break;
|
16059 | }
|
16060 |
|
16061 | _step9$value = slicedToArray(_step9.value, 2), id = _step9$value[0], item = _step9$value[1];
|
16062 | _context6.next = 9;
|
16063 | return [id, callback(item, id)];
|
16064 |
|
16065 | case 9:
|
16066 | _iteratorNormalCompletion9 = true;
|
16067 | _context6.next = 5;
|
16068 | break;
|
16069 |
|
16070 | case 12:
|
16071 | _context6.next = 18;
|
16072 | break;
|
16073 |
|
16074 | case 14:
|
16075 | _context6.prev = 14;
|
16076 | _context6.t0 = _context6["catch"](3);
|
16077 | _didIteratorError9 = true;
|
16078 | _iteratorError9 = _context6.t0;
|
16079 |
|
16080 | case 18:
|
16081 | _context6.prev = 18;
|
16082 | _context6.prev = 19;
|
16083 |
|
16084 | if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
|
16085 | _iterator9.return();
|
16086 | }
|
16087 |
|
16088 | case 21:
|
16089 | _context6.prev = 21;
|
16090 |
|
16091 | if (!_didIteratorError9) {
|
16092 | _context6.next = 24;
|
16093 | break;
|
16094 | }
|
16095 |
|
16096 | throw _iteratorError9;
|
16097 |
|
16098 | case 24:
|
16099 | return _context6.finish(21);
|
16100 |
|
16101 | case 25:
|
16102 | return _context6.finish(18);
|
16103 |
|
16104 | case 26:
|
16105 | case "end":
|
16106 | return _context6.stop();
|
16107 | }
|
16108 | }
|
16109 | }, _callee2, null, [[3, 14, 18, 26], [19,, 21, 25]]);
|
16110 | })));
|
16111 | }
|
16112 | |
16113 |
|
16114 |
|
16115 |
|
16116 |
|
16117 |
|
16118 |
|
16119 |
|
16120 | }, {
|
16121 | key: "max",
|
16122 | value: function max(callback) {
|
16123 | var iter = this._pairs[Symbol.iterator]();
|
16124 |
|
16125 | var curr = iter.next();
|
16126 |
|
16127 | if (curr.done) {
|
16128 | return null;
|
16129 | }
|
16130 |
|
16131 | var maxItem = curr.value[1];
|
16132 | var maxValue = callback(curr.value[1], curr.value[0]);
|
16133 |
|
16134 | while (!(curr = iter.next()).done) {
|
16135 | var _curr$value = slicedToArray(curr.value, 2),
|
16136 | id = _curr$value[0],
|
16137 | item = _curr$value[1];
|
16138 |
|
16139 | var _value = callback(item, id);
|
16140 |
|
16141 | if (_value > maxValue) {
|
16142 | maxValue = _value;
|
16143 | maxItem = item;
|
16144 | }
|
16145 | }
|
16146 |
|
16147 | return maxItem;
|
16148 | }
|
16149 | |
16150 |
|
16151 |
|
16152 |
|
16153 |
|
16154 |
|
16155 |
|
16156 |
|
16157 | }, {
|
16158 | key: "min",
|
16159 | value: function min(callback) {
|
16160 | var iter = this._pairs[Symbol.iterator]();
|
16161 |
|
16162 | var curr = iter.next();
|
16163 |
|
16164 | if (curr.done) {
|
16165 | return null;
|
16166 | }
|
16167 |
|
16168 | var minItem = curr.value[1];
|
16169 | var minValue = callback(curr.value[1], curr.value[0]);
|
16170 |
|
16171 | while (!(curr = iter.next()).done) {
|
16172 | var _curr$value2 = slicedToArray(curr.value, 2),
|
16173 | id = _curr$value2[0],
|
16174 | item = _curr$value2[1];
|
16175 |
|
16176 | var _value2 = callback(item, id);
|
16177 |
|
16178 | if (_value2 < minValue) {
|
16179 | minValue = _value2;
|
16180 | minItem = item;
|
16181 | }
|
16182 | }
|
16183 |
|
16184 | return minItem;
|
16185 | }
|
16186 | |
16187 |
|
16188 |
|
16189 |
|
16190 |
|
16191 |
|
16192 |
|
16193 |
|
16194 |
|
16195 |
|
16196 |
|
16197 | }, {
|
16198 | key: "reduce",
|
16199 | value: function reduce(callback, accumulator) {
|
16200 | var _iteratorNormalCompletion10 = true;
|
16201 | var _didIteratorError10 = false;
|
16202 | var _iteratorError10 = undefined;
|
16203 |
|
16204 | try {
|
16205 | for (var _iterator10 = this._pairs[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
|
16206 | var _step10$value = slicedToArray(_step10.value, 2),
|
16207 | id = _step10$value[0],
|
16208 | item = _step10$value[1];
|
16209 |
|
16210 | accumulator = callback(accumulator, item, id);
|
16211 | }
|
16212 | } catch (err) {
|
16213 | _didIteratorError10 = true;
|
16214 | _iteratorError10 = err;
|
16215 | } finally {
|
16216 | try {
|
16217 | if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
|
16218 | _iterator10.return();
|
16219 | }
|
16220 | } finally {
|
16221 | if (_didIteratorError10) {
|
16222 | throw _iteratorError10;
|
16223 | }
|
16224 | }
|
16225 | }
|
16226 |
|
16227 | return accumulator;
|
16228 | }
|
16229 | |
16230 |
|
16231 |
|
16232 |
|
16233 |
|
16234 |
|
16235 |
|
16236 |
|
16237 | }, {
|
16238 | key: "sort",
|
16239 | value: function sort(callback) {
|
16240 | var _this = this;
|
16241 |
|
16242 | return new DataStream(defineProperty$1({}, Symbol.iterator, function () {
|
16243 | return toConsumableArray(_this._pairs).sort(function (_ref3, _ref4) {
|
16244 | var _ref5 = slicedToArray(_ref3, 2),
|
16245 | idA = _ref5[0],
|
16246 | itemA = _ref5[1];
|
16247 |
|
16248 | var _ref6 = slicedToArray(_ref4, 2),
|
16249 | idB = _ref6[0],
|
16250 | itemB = _ref6[1];
|
16251 |
|
16252 | return callback(itemA, itemB, idA, idB);
|
16253 | })[Symbol.iterator]();
|
16254 | }));
|
16255 | }
|
16256 | }]);
|
16257 | return DataStream;
|
16258 | }();
|
16259 |
|
16260 | function ownKeys$1(object, enumerableOnly) {
|
16261 | var keys = Object.keys(object);
|
16262 |
|
16263 | if (Object.getOwnPropertySymbols) {
|
16264 | keys.push.apply(keys, Object.getOwnPropertySymbols(object));
|
16265 | }
|
16266 |
|
16267 | if (enumerableOnly) keys = keys.filter(function (sym) {
|
16268 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
16269 | });
|
16270 | return keys;
|
16271 | }
|
16272 |
|
16273 | function _objectSpread(target) {
|
16274 | for (var i = 1; i < arguments.length; i++) {
|
16275 | var source = arguments[i] != null ? arguments[i] : {};
|
16276 |
|
16277 | if (i % 2) {
|
16278 | ownKeys$1(source, true).forEach(function (key) {
|
16279 | defineProperty$1(target, key, source[key]);
|
16280 | });
|
16281 | } else if (Object.getOwnPropertyDescriptors) {
|
16282 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
16283 | } else {
|
16284 | ownKeys$1(source).forEach(function (key) {
|
16285 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
16286 | });
|
16287 | }
|
16288 | }
|
16289 |
|
16290 | return target;
|
16291 | }
|
16292 |
|
16293 |
|
16294 |
|
16295 |
|
16296 |
|
16297 |
|
16298 |
|
16299 |
|
16300 |
|
16301 |
|
16302 |
|
16303 |
|
16304 |
|
16305 |
|
16306 |
|
16307 |
|
16308 |
|
16309 |
|
16310 |
|
16311 |
|
16312 |
|
16313 |
|
16314 |
|
16315 |
|
16316 |
|
16317 |
|
16318 |
|
16319 |
|
16320 |
|
16321 |
|
16322 |
|
16323 |
|
16324 |
|
16325 |
|
16326 |
|
16327 |
|
16328 |
|
16329 |
|
16330 |
|
16331 |
|
16332 |
|
16333 |
|
16334 |
|
16335 |
|
16336 |
|
16337 |
|
16338 |
|
16339 |
|
16340 |
|
16341 |
|
16342 |
|
16343 |
|
16344 |
|
16345 |
|
16346 |
|
16347 |
|
16348 |
|
16349 |
|
16350 |
|
16351 |
|
16352 |
|
16353 |
|
16354 |
|
16355 |
|
16356 |
|
16357 | var DataSet =
|
16358 |
|
16359 | function (_DataSetPart) {
|
16360 | inherits(DataSet, _DataSetPart);
|
16361 | |
16362 |
|
16363 |
|
16364 |
|
16365 |
|
16366 |
|
16367 |
|
16368 | function DataSet(data, options) {
|
16369 | var _this;
|
16370 |
|
16371 | classCallCheck(this, DataSet);
|
16372 | _this = possibleConstructorReturn(this, getPrototypeOf(DataSet).call(this));
|
16373 |
|
16374 | if (data && !Array.isArray(data)) {
|
16375 | options = data;
|
16376 | data = [];
|
16377 | }
|
16378 |
|
16379 | _this._options = options || {};
|
16380 | _this._data = new Map();
|
16381 |
|
16382 | _this.length = 0;
|
16383 |
|
16384 | _this._idProp = _this._options.fieldId || "id";
|
16385 |
|
16386 | _this._type = {};
|
16387 |
|
16388 |
|
16389 |
|
16390 | if (_this._options.type) {
|
16391 | var fields = Object.keys(_this._options.type);
|
16392 |
|
16393 | for (var i = 0, len = fields.length; i < len; i++) {
|
16394 | var field = fields[i];
|
16395 | var value = _this._options.type[field];
|
16396 |
|
16397 | if (value == "Date" || value == "ISODate" || value == "ASPDate") {
|
16398 | _this._type[field] = "Date";
|
16399 | } else {
|
16400 | _this._type[field] = value;
|
16401 | }
|
16402 | }
|
16403 | }
|
16404 |
|
16405 |
|
16406 | if (data && data.length) {
|
16407 | _this.add(data);
|
16408 | }
|
16409 |
|
16410 | _this.setOptions(options);
|
16411 |
|
16412 | return _this;
|
16413 | }
|
16414 | |
16415 |
|
16416 |
|
16417 |
|
16418 |
|
16419 |
|
16420 |
|
16421 | createClass(DataSet, [{
|
16422 | key: "setOptions",
|
16423 | value: function setOptions(options) {
|
16424 | if (options && options.queue !== undefined) {
|
16425 | if (options.queue === false) {
|
16426 |
|
16427 | if (this._queue) {
|
16428 | this._queue.destroy();
|
16429 |
|
16430 | delete this._queue;
|
16431 | }
|
16432 | } else {
|
16433 |
|
16434 | if (!this._queue) {
|
16435 | this._queue = Queue.extend(this, {
|
16436 | replace: ["add", "update", "remove"]
|
16437 | });
|
16438 | }
|
16439 |
|
16440 | if (options.queue && _typeof_1(options.queue) === "object") {
|
16441 | this._queue.setOptions(options.queue);
|
16442 | }
|
16443 | }
|
16444 | }
|
16445 | }
|
16446 | |
16447 |
|
16448 |
|
16449 |
|
16450 |
|
16451 |
|
16452 |
|
16453 |
|
16454 |
|
16455 |
|
16456 |
|
16457 |
|
16458 |
|
16459 |
|
16460 |
|
16461 |
|
16462 |
|
16463 |
|
16464 |
|
16465 |
|
16466 |
|
16467 |
|
16468 |
|
16469 |
|
16470 |
|
16471 |
|
16472 |
|
16473 |
|
16474 |
|
16475 | }, {
|
16476 | key: "add",
|
16477 | value: function add(data, senderId) {
|
16478 | var addedIds = [];
|
16479 | var id;
|
16480 |
|
16481 | if (Array.isArray(data)) {
|
16482 |
|
16483 | for (var i = 0, len = data.length; i < len; i++) {
|
16484 | id = this._addItem(data[i]);
|
16485 | addedIds.push(id);
|
16486 | }
|
16487 | } else if (data && _typeof_1(data) === "object") {
|
16488 |
|
16489 | id = this._addItem(data);
|
16490 | addedIds.push(id);
|
16491 | } else {
|
16492 | throw new Error("Unknown dataType");
|
16493 | }
|
16494 |
|
16495 | if (addedIds.length) {
|
16496 | this._trigger("add", {
|
16497 | items: addedIds
|
16498 | }, senderId);
|
16499 | }
|
16500 |
|
16501 | return addedIds;
|
16502 | }
|
16503 | |
16504 |
|
16505 |
|
16506 |
|
16507 |
|
16508 |
|
16509 |
|
16510 |
|
16511 |
|
16512 |
|
16513 |
|
16514 |
|
16515 |
|
16516 |
|
16517 |
|
16518 |
|
16519 |
|
16520 |
|
16521 |
|
16522 |
|
16523 |
|
16524 |
|
16525 |
|
16526 |
|
16527 |
|
16528 |
|
16529 |
|
16530 |
|
16531 |
|
16532 |
|
16533 |
|
16534 |
|
16535 |
|
16536 |
|
16537 |
|
16538 |
|
16539 |
|
16540 |
|
16541 | }, {
|
16542 | key: "update",
|
16543 | value: function update(data, senderId) {
|
16544 | var _this2 = this;
|
16545 |
|
16546 | var addedIds = [];
|
16547 | var updatedIds = [];
|
16548 | var oldData = [];
|
16549 | var updatedData = [];
|
16550 | var idProp = this._idProp;
|
16551 |
|
16552 | var addOrUpdate = function addOrUpdate(item) {
|
16553 | var origId = item[idProp];
|
16554 |
|
16555 | if (origId != null && _this2._data.has(origId)) {
|
16556 | var fullItem = item;
|
16557 |
|
16558 | var oldItem = Object.assign({}, _this2._data.get(origId));
|
16559 |
|
16560 | var id = _this2._updateItem(fullItem);
|
16561 |
|
16562 | updatedIds.push(id);
|
16563 | updatedData.push(fullItem);
|
16564 | oldData.push(oldItem);
|
16565 | } else {
|
16566 |
|
16567 | var _id = _this2._addItem(item);
|
16568 |
|
16569 | addedIds.push(_id);
|
16570 | }
|
16571 | };
|
16572 |
|
16573 | if (Array.isArray(data)) {
|
16574 |
|
16575 | for (var i = 0, len = data.length; i < len; i++) {
|
16576 | if (data[i] && _typeof_1(data[i]) === "object") {
|
16577 | addOrUpdate(data[i]);
|
16578 | } else {
|
16579 | console.warn("Ignoring input item, which is not an object at index " + i);
|
16580 | }
|
16581 | }
|
16582 | } else if (data && _typeof_1(data) === "object") {
|
16583 |
|
16584 | addOrUpdate(data);
|
16585 | } else {
|
16586 | throw new Error("Unknown dataType");
|
16587 | }
|
16588 |
|
16589 | if (addedIds.length) {
|
16590 | this._trigger("add", {
|
16591 | items: addedIds
|
16592 | }, senderId);
|
16593 | }
|
16594 |
|
16595 | if (updatedIds.length) {
|
16596 | var props = {
|
16597 | items: updatedIds,
|
16598 | oldData: oldData,
|
16599 | data: updatedData
|
16600 | };
|
16601 |
|
16602 |
|
16603 |
|
16604 |
|
16605 |
|
16606 |
|
16607 |
|
16608 | this._trigger("update", props, senderId);
|
16609 | }
|
16610 |
|
16611 | return addedIds.concat(updatedIds);
|
16612 | }
|
16613 | |
16614 |
|
16615 |
|
16616 |
|
16617 |
|
16618 |
|
16619 |
|
16620 |
|
16621 |
|
16622 |
|
16623 |
|
16624 |
|
16625 |
|
16626 |
|
16627 |
|
16628 |
|
16629 |
|
16630 |
|
16631 |
|
16632 |
|
16633 |
|
16634 |
|
16635 |
|
16636 |
|
16637 |
|
16638 |
|
16639 |
|
16640 |
|
16641 |
|
16642 |
|
16643 |
|
16644 |
|
16645 |
|
16646 |
|
16647 |
|
16648 |
|
16649 |
|
16650 |
|
16651 | }, {
|
16652 | key: "updateOnly",
|
16653 | value: function updateOnly(data, senderId) {
|
16654 | var _this3 = this;
|
16655 |
|
16656 | if (!Array.isArray(data)) {
|
16657 | data = [data];
|
16658 | }
|
16659 |
|
16660 | var updateEventData = data.map(function (update) {
|
16661 | var oldData = _this3._data.get(update[_this3._idProp]);
|
16662 |
|
16663 | if (oldData == null) {
|
16664 | throw new Error("Updating non-existent items is not allowed.");
|
16665 | }
|
16666 |
|
16667 | return {
|
16668 | oldData: oldData,
|
16669 | update: update
|
16670 | };
|
16671 | }).map(function (_ref) {
|
16672 | var oldData = _ref.oldData,
|
16673 | update = _ref.update;
|
16674 | var id = oldData[_this3._idProp];
|
16675 | var updatedData = deepExtend$1(deepExtend$1({}, oldData), update);
|
16676 |
|
16677 | _this3._data.set(id, updatedData);
|
16678 |
|
16679 | return {
|
16680 | id: id,
|
16681 | oldData: oldData,
|
16682 | updatedData: updatedData
|
16683 | };
|
16684 | });
|
16685 |
|
16686 | if (updateEventData.length) {
|
16687 | var props = {
|
16688 | items: updateEventData.map(function (value) {
|
16689 | return value.id;
|
16690 | }),
|
16691 | oldData: updateEventData.map(function (value) {
|
16692 | return value.oldData;
|
16693 | }),
|
16694 | data: updateEventData.map(function (value) {
|
16695 | return value.updatedData;
|
16696 | })
|
16697 | };
|
16698 |
|
16699 |
|
16700 |
|
16701 |
|
16702 |
|
16703 |
|
16704 |
|
16705 | this._trigger("update", props, senderId);
|
16706 |
|
16707 | return props.items;
|
16708 | } else {
|
16709 | return [];
|
16710 | }
|
16711 | }
|
16712 |
|
16713 |
|
16714 | }, {
|
16715 | key: "get",
|
16716 | value: function get(first, second) {
|
16717 |
|
16718 |
|
16719 | var id = undefined;
|
16720 | var ids = undefined;
|
16721 | var options = undefined;
|
16722 |
|
16723 | if (isId(first)) {
|
16724 |
|
16725 | id = first;
|
16726 | options = second;
|
16727 | } else if (Array.isArray(first)) {
|
16728 |
|
16729 | ids = first;
|
16730 | options = second;
|
16731 | } else {
|
16732 |
|
16733 | options = first;
|
16734 | }
|
16735 |
|
16736 |
|
16737 | var returnType = options && options.returnType === "Object" ? "Object" : "Array";
|
16738 |
|
16739 |
|
16740 |
|
16741 |
|
16742 |
|
16743 |
|
16744 |
|
16745 |
|
16746 |
|
16747 |
|
16748 |
|
16749 |
|
16750 | var type = options && options.type || this._options.type;
|
16751 | var filter = options && options.filter;
|
16752 | var items = [];
|
16753 | var item = null;
|
16754 | var itemIds = null;
|
16755 | var itemId = null;
|
16756 |
|
16757 | if (id != null) {
|
16758 |
|
16759 | item = this._getItem(id, type);
|
16760 |
|
16761 | if (item && filter && !filter(item)) {
|
16762 | item = null;
|
16763 | }
|
16764 | } else if (ids != null) {
|
16765 |
|
16766 | for (var i = 0, len = ids.length; i < len; i++) {
|
16767 | item = this._getItem(ids[i], type);
|
16768 |
|
16769 | if (item != null && (!filter || filter(item))) {
|
16770 | items.push(item);
|
16771 | }
|
16772 | }
|
16773 | } else {
|
16774 |
|
16775 | itemIds = toConsumableArray(this._data.keys());
|
16776 |
|
16777 | for (var _i = 0, _len = itemIds.length; _i < _len; _i++) {
|
16778 | itemId = itemIds[_i];
|
16779 | item = this._getItem(itemId, type);
|
16780 |
|
16781 | if (item != null && (!filter || filter(item))) {
|
16782 | items.push(item);
|
16783 | }
|
16784 | }
|
16785 | }
|
16786 |
|
16787 |
|
16788 | if (options && options.order && id == undefined) {
|
16789 | this._sort(items, options.order);
|
16790 | }
|
16791 |
|
16792 |
|
16793 | if (options && options.fields) {
|
16794 | var fields = options.fields;
|
16795 |
|
16796 | if (id != undefined && item != null) {
|
16797 | item = this._filterFields(item, fields);
|
16798 | } else {
|
16799 | for (var _i2 = 0, _len2 = items.length; _i2 < _len2; _i2++) {
|
16800 | items[_i2] = this._filterFields(items[_i2], fields);
|
16801 | }
|
16802 | }
|
16803 | }
|
16804 |
|
16805 |
|
16806 | if (returnType == "Object") {
|
16807 | var result = {};
|
16808 |
|
16809 | for (var _i3 = 0, _len3 = items.length; _i3 < _len3; _i3++) {
|
16810 | var resultant = items[_i3];
|
16811 |
|
16812 |
|
16813 | var _id2 = resultant[this._idProp];
|
16814 | result[_id2] = resultant;
|
16815 | }
|
16816 |
|
16817 | return result;
|
16818 | } else {
|
16819 | if (id != null) {
|
16820 |
|
16821 | return item;
|
16822 | } else {
|
16823 |
|
16824 | return items;
|
16825 | }
|
16826 | }
|
16827 | }
|
16828 |
|
16829 |
|
16830 | }, {
|
16831 | key: "getIds",
|
16832 | value: function getIds(options) {
|
16833 | var data = this._data;
|
16834 | var filter = options && options.filter;
|
16835 | var order = options && options.order;
|
16836 | var type = options && options.type || this._options.type;
|
16837 | var itemIds = toConsumableArray(data.keys());
|
16838 | var ids = [];
|
16839 | var item;
|
16840 | var items;
|
16841 |
|
16842 | if (filter) {
|
16843 |
|
16844 | if (order) {
|
16845 |
|
16846 | items = [];
|
16847 |
|
16848 | for (var i = 0, len = itemIds.length; i < len; i++) {
|
16849 | var id = itemIds[i];
|
16850 | item = this._getItem(id, type);
|
16851 |
|
16852 | if (filter(item)) {
|
16853 | items.push(item);
|
16854 | }
|
16855 | }
|
16856 |
|
16857 | this._sort(items, order);
|
16858 |
|
16859 | for (var _i4 = 0, _len4 = items.length; _i4 < _len4; _i4++) {
|
16860 | ids.push(items[_i4][this._idProp]);
|
16861 | }
|
16862 | } else {
|
16863 |
|
16864 | for (var _i5 = 0, _len5 = itemIds.length; _i5 < _len5; _i5++) {
|
16865 | var _id3 = itemIds[_i5];
|
16866 | item = this._getItem(_id3, type);
|
16867 |
|
16868 | if (filter(item)) {
|
16869 | ids.push(item[this._idProp]);
|
16870 | }
|
16871 | }
|
16872 | }
|
16873 | } else {
|
16874 |
|
16875 | if (order) {
|
16876 |
|
16877 | items = [];
|
16878 |
|
16879 | for (var _i6 = 0, _len6 = itemIds.length; _i6 < _len6; _i6++) {
|
16880 | var _id4 = itemIds[_i6];
|
16881 | items.push(data.get(_id4));
|
16882 | }
|
16883 |
|
16884 | this._sort(items, order);
|
16885 |
|
16886 | for (var _i7 = 0, _len7 = items.length; _i7 < _len7; _i7++) {
|
16887 | ids.push(items[_i7][this._idProp]);
|
16888 | }
|
16889 | } else {
|
16890 |
|
16891 | for (var _i8 = 0, _len8 = itemIds.length; _i8 < _len8; _i8++) {
|
16892 | var _id5 = itemIds[_i8];
|
16893 | item = data.get(_id5);
|
16894 | ids.push(item[this._idProp]);
|
16895 | }
|
16896 | }
|
16897 | }
|
16898 |
|
16899 | return ids;
|
16900 | }
|
16901 |
|
16902 |
|
16903 | }, {
|
16904 | key: "getDataSet",
|
16905 | value: function getDataSet() {
|
16906 | return this;
|
16907 | }
|
16908 |
|
16909 |
|
16910 | }, {
|
16911 | key: "forEach",
|
16912 | value: function forEach(callback, options) {
|
16913 | var filter = options && options.filter;
|
16914 | var type = options && options.type || this._options.type;
|
16915 | var data = this._data;
|
16916 | var itemIds = toConsumableArray(data.keys());
|
16917 |
|
16918 | if (options && options.order) {
|
16919 |
|
16920 | var items = this.get(options);
|
16921 |
|
16922 | for (var i = 0, len = items.length; i < len; i++) {
|
16923 | var item = items[i];
|
16924 | var id = item[this._idProp];
|
16925 | callback(item, id);
|
16926 | }
|
16927 | } else {
|
16928 |
|
16929 | for (var _i9 = 0, _len9 = itemIds.length; _i9 < _len9; _i9++) {
|
16930 | var _id6 = itemIds[_i9];
|
16931 |
|
16932 | var _item = this._getItem(_id6, type);
|
16933 |
|
16934 | if (!filter || filter(_item)) {
|
16935 | callback(_item, _id6);
|
16936 | }
|
16937 | }
|
16938 | }
|
16939 | }
|
16940 |
|
16941 |
|
16942 | }, {
|
16943 | key: "map",
|
16944 | value: function map(callback, options) {
|
16945 | var filter = options && options.filter;
|
16946 | var type = options && options.type || this._options.type;
|
16947 | var mappedItems = [];
|
16948 | var data = this._data;
|
16949 | var itemIds = toConsumableArray(data.keys());
|
16950 |
|
16951 | for (var i = 0, len = itemIds.length; i < len; i++) {
|
16952 | var id = itemIds[i];
|
16953 |
|
16954 | var item = this._getItem(id, type);
|
16955 |
|
16956 | if (!filter || filter(item)) {
|
16957 | mappedItems.push(callback(item, id));
|
16958 | }
|
16959 | }
|
16960 |
|
16961 |
|
16962 | if (options && options.order) {
|
16963 | this._sort(mappedItems, options.order);
|
16964 | }
|
16965 |
|
16966 | return mappedItems;
|
16967 | }
|
16968 | |
16969 |
|
16970 |
|
16971 |
|
16972 |
|
16973 |
|
16974 |
|
16975 |
|
16976 |
|
16977 |
|
16978 |
|
16979 | }, {
|
16980 | key: "_filterFields",
|
16981 | value: function _filterFields(item, fields) {
|
16982 | if (!item) {
|
16983 |
|
16984 | return item;
|
16985 | }
|
16986 |
|
16987 | return (Array.isArray(fields) ?
|
16988 | fields :
|
16989 | Object.keys(fields)).reduce(function (filteredItem, field) {
|
16990 | filteredItem[field] = item[field];
|
16991 | return filteredItem;
|
16992 | }, {});
|
16993 | }
|
16994 | |
16995 |
|
16996 |
|
16997 |
|
16998 |
|
16999 |
|
17000 |
|
17001 |
|
17002 |
|
17003 | }, {
|
17004 | key: "_sort",
|
17005 | value: function _sort(items, order) {
|
17006 | if (typeof order === "string") {
|
17007 |
|
17008 | var name = order;
|
17009 |
|
17010 | items.sort(function (a, b) {
|
17011 |
|
17012 | var av = a[name];
|
17013 | var bv = b[name];
|
17014 | return av > bv ? 1 : av < bv ? -1 : 0;
|
17015 | });
|
17016 | } else if (typeof order === "function") {
|
17017 |
|
17018 | items.sort(order);
|
17019 | } else {
|
17020 |
|
17021 |
|
17022 | throw new TypeError("Order must be a function or a string");
|
17023 | }
|
17024 | }
|
17025 | |
17026 |
|
17027 |
|
17028 |
|
17029 |
|
17030 |
|
17031 |
|
17032 |
|
17033 |
|
17034 |
|
17035 |
|
17036 |
|
17037 |
|
17038 |
|
17039 |
|
17040 |
|
17041 |
|
17042 |
|
17043 |
|
17044 |
|
17045 |
|
17046 |
|
17047 |
|
17048 |
|
17049 |
|
17050 |
|
17051 |
|
17052 |
|
17053 | }, {
|
17054 | key: "remove",
|
17055 | value: function remove(id, senderId) {
|
17056 | var removedIds = [];
|
17057 | var removedItems = [];
|
17058 |
|
17059 | var ids = Array.isArray(id) ? id : [id];
|
17060 |
|
17061 | for (var i = 0, len = ids.length; i < len; i++) {
|
17062 | var item = this._remove(ids[i]);
|
17063 |
|
17064 | if (item) {
|
17065 | var itemId = item[this._idProp];
|
17066 |
|
17067 | if (itemId != null) {
|
17068 | removedIds.push(itemId);
|
17069 | removedItems.push(item);
|
17070 | }
|
17071 | }
|
17072 | }
|
17073 |
|
17074 | if (removedIds.length) {
|
17075 | this._trigger("remove", {
|
17076 | items: removedIds,
|
17077 | oldData: removedItems
|
17078 | }, senderId);
|
17079 | }
|
17080 |
|
17081 | return removedIds;
|
17082 | }
|
17083 | |
17084 |
|
17085 |
|
17086 |
|
17087 |
|
17088 |
|
17089 |
|
17090 |
|
17091 | }, {
|
17092 | key: "_remove",
|
17093 | value: function _remove(id) {
|
17094 |
|
17095 |
|
17096 | var ident;
|
17097 |
|
17098 | if (isId(id)) {
|
17099 | ident = id;
|
17100 | } else if (id && _typeof_1(id) === "object") {
|
17101 | ident = id[this._idProp];
|
17102 | }
|
17103 |
|
17104 |
|
17105 | if (ident != null && this._data.has(ident)) {
|
17106 | var item = this._data.get(ident) || null;
|
17107 |
|
17108 | this._data.delete(ident);
|
17109 |
|
17110 | --this.length;
|
17111 | return item;
|
17112 | }
|
17113 |
|
17114 | return null;
|
17115 | }
|
17116 | |
17117 |
|
17118 |
|
17119 |
|
17120 |
|
17121 |
|
17122 |
|
17123 |
|
17124 |
|
17125 |
|
17126 | }, {
|
17127 | key: "clear",
|
17128 | value: function clear(senderId) {
|
17129 | var ids = toConsumableArray(this._data.keys());
|
17130 | var items = [];
|
17131 |
|
17132 | for (var i = 0, len = ids.length; i < len; i++) {
|
17133 | items.push(this._data.get(ids[i]));
|
17134 | }
|
17135 |
|
17136 | this._data.clear();
|
17137 |
|
17138 | this.length = 0;
|
17139 |
|
17140 | this._trigger("remove", {
|
17141 | items: ids,
|
17142 | oldData: items
|
17143 | }, senderId);
|
17144 |
|
17145 | return ids;
|
17146 | }
|
17147 | |
17148 |
|
17149 |
|
17150 |
|
17151 |
|
17152 |
|
17153 |
|
17154 |
|
17155 | }, {
|
17156 | key: "max",
|
17157 | value: function max(field) {
|
17158 | var max = null;
|
17159 | var maxField = null;
|
17160 | var _iteratorNormalCompletion = true;
|
17161 | var _didIteratorError = false;
|
17162 | var _iteratorError = undefined;
|
17163 |
|
17164 | try {
|
17165 | for (var _iterator = this._data.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
17166 | var item = _step.value;
|
17167 | var itemField = item[field];
|
17168 |
|
17169 | if (typeof itemField === "number" && (maxField == null || itemField > maxField)) {
|
17170 | max = item;
|
17171 | maxField = itemField;
|
17172 | }
|
17173 | }
|
17174 | } catch (err) {
|
17175 | _didIteratorError = true;
|
17176 | _iteratorError = err;
|
17177 | } finally {
|
17178 | try {
|
17179 | if (!_iteratorNormalCompletion && _iterator.return != null) {
|
17180 | _iterator.return();
|
17181 | }
|
17182 | } finally {
|
17183 | if (_didIteratorError) {
|
17184 | throw _iteratorError;
|
17185 | }
|
17186 | }
|
17187 | }
|
17188 |
|
17189 | return max || null;
|
17190 | }
|
17191 | |
17192 |
|
17193 |
|
17194 |
|
17195 |
|
17196 |
|
17197 |
|
17198 |
|
17199 | }, {
|
17200 | key: "min",
|
17201 | value: function min(field) {
|
17202 | var min = null;
|
17203 | var minField = null;
|
17204 | var _iteratorNormalCompletion2 = true;
|
17205 | var _didIteratorError2 = false;
|
17206 | var _iteratorError2 = undefined;
|
17207 |
|
17208 | try {
|
17209 | for (var _iterator2 = this._data.values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
17210 | var item = _step2.value;
|
17211 | var itemField = item[field];
|
17212 |
|
17213 | if (typeof itemField === "number" && (minField == null || itemField < minField)) {
|
17214 | min = item;
|
17215 | minField = itemField;
|
17216 | }
|
17217 | }
|
17218 | } catch (err) {
|
17219 | _didIteratorError2 = true;
|
17220 | _iteratorError2 = err;
|
17221 | } finally {
|
17222 | try {
|
17223 | if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
17224 | _iterator2.return();
|
17225 | }
|
17226 | } finally {
|
17227 | if (_didIteratorError2) {
|
17228 | throw _iteratorError2;
|
17229 | }
|
17230 | }
|
17231 | }
|
17232 |
|
17233 | return min || null;
|
17234 | }
|
17235 | |
17236 |
|
17237 |
|
17238 |
|
17239 |
|
17240 |
|
17241 |
|
17242 |
|
17243 | }, {
|
17244 | key: "distinct",
|
17245 | value: function distinct(prop) {
|
17246 | var data = this._data;
|
17247 | var itemIds = toConsumableArray(data.keys());
|
17248 | var values = [];
|
17249 | var fieldType = this._options.type && this._options.type[prop] || null;
|
17250 | var count = 0;
|
17251 |
|
17252 | for (var i = 0, len = itemIds.length; i < len; i++) {
|
17253 | var id = itemIds[i];
|
17254 | var item = data.get(id);
|
17255 | var value = item[prop];
|
17256 | var exists = false;
|
17257 |
|
17258 | for (var j = 0; j < count; j++) {
|
17259 | if (values[j] == value) {
|
17260 | exists = true;
|
17261 | break;
|
17262 | }
|
17263 | }
|
17264 |
|
17265 | if (!exists && value !== undefined) {
|
17266 | values[count] = value;
|
17267 | count++;
|
17268 | }
|
17269 | }
|
17270 |
|
17271 | if (fieldType) {
|
17272 | for (var _i10 = 0, _len10 = values.length; _i10 < _len10; _i10++) {
|
17273 | values[_i10] = convert$1(values[_i10], fieldType);
|
17274 | }
|
17275 | }
|
17276 |
|
17277 | return values;
|
17278 | }
|
17279 | |
17280 |
|
17281 |
|
17282 |
|
17283 |
|
17284 |
|
17285 |
|
17286 |
|
17287 | }, {
|
17288 | key: "_addItem",
|
17289 | value: function _addItem(item) {
|
17290 | var id = item[this._idProp];
|
17291 |
|
17292 | if (id != null) {
|
17293 |
|
17294 | if (this._data.has(id)) {
|
17295 |
|
17296 | throw new Error("Cannot add item: item with id " + id + " already exists");
|
17297 | }
|
17298 | } else {
|
17299 |
|
17300 | id = uuid4$1();
|
17301 | item[this._idProp] = id;
|
17302 | }
|
17303 |
|
17304 | var d = {};
|
17305 | var fields = Object.keys(item);
|
17306 |
|
17307 | for (var i = 0, len = fields.length; i < len; i++) {
|
17308 | var field = fields[i];
|
17309 | var fieldType = this._type[field];
|
17310 |
|
17311 | d[field] = convert$1(item[field], fieldType);
|
17312 | }
|
17313 |
|
17314 | this._data.set(id, d);
|
17315 |
|
17316 | ++this.length;
|
17317 | return id;
|
17318 | }
|
17319 | |
17320 |
|
17321 |
|
17322 |
|
17323 |
|
17324 |
|
17325 |
|
17326 |
|
17327 |
|
17328 | }, {
|
17329 | key: "_getItem",
|
17330 | value: function _getItem(id, types) {
|
17331 |
|
17332 |
|
17333 | var raw = this._data.get(id);
|
17334 |
|
17335 | if (!raw) {
|
17336 | return null;
|
17337 | }
|
17338 |
|
17339 |
|
17340 | var converted;
|
17341 | var fields = Object.keys(raw);
|
17342 |
|
17343 | if (types) {
|
17344 | converted = {};
|
17345 |
|
17346 | for (var i = 0, len = fields.length; i < len; i++) {
|
17347 | var field = fields[i];
|
17348 | var value = raw[field];
|
17349 | converted[field] = convert$1(value, types[field]);
|
17350 | }
|
17351 | } else {
|
17352 |
|
17353 | converted = _objectSpread({}, raw);
|
17354 | }
|
17355 |
|
17356 | if (converted[this._idProp] == null) {
|
17357 | converted[this._idProp] = raw.id;
|
17358 | }
|
17359 |
|
17360 | return converted;
|
17361 | }
|
17362 | |
17363 |
|
17364 |
|
17365 |
|
17366 |
|
17367 |
|
17368 |
|
17369 |
|
17370 |
|
17371 | }, {
|
17372 | key: "_updateItem",
|
17373 | value: function _updateItem(item) {
|
17374 | var id = item[this._idProp];
|
17375 |
|
17376 | if (id == null) {
|
17377 | throw new Error("Cannot update item: item has no id (item: " + JSON.stringify(item) + ")");
|
17378 | }
|
17379 |
|
17380 | var d = this._data.get(id);
|
17381 |
|
17382 | if (!d) {
|
17383 |
|
17384 | throw new Error("Cannot update item: no item with id " + id + " found");
|
17385 | }
|
17386 |
|
17387 |
|
17388 | var fields = Object.keys(item);
|
17389 |
|
17390 | for (var i = 0, len = fields.length; i < len; i++) {
|
17391 | var field = fields[i];
|
17392 | var fieldType = this._type[field];
|
17393 |
|
17394 | d[field] = convert$1(item[field], fieldType);
|
17395 | }
|
17396 |
|
17397 | return id;
|
17398 | }
|
17399 |
|
17400 |
|
17401 | }, {
|
17402 | key: "stream",
|
17403 | value: function stream(ids) {
|
17404 | if (ids) {
|
17405 | var data = this._data;
|
17406 | return new DataStream(defineProperty$1({}, Symbol.iterator,
|
17407 |
|
17408 | regenerator.mark(function _callee() {
|
17409 | var _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, id, item;
|
17410 |
|
17411 | return regenerator.wrap(function _callee$(_context) {
|
17412 | while (1) {
|
17413 | switch (_context.prev = _context.next) {
|
17414 | case 0:
|
17415 | _iteratorNormalCompletion3 = true;
|
17416 | _didIteratorError3 = false;
|
17417 | _iteratorError3 = undefined;
|
17418 | _context.prev = 3;
|
17419 | _iterator3 = ids[Symbol.iterator]();
|
17420 |
|
17421 | case 5:
|
17422 | if (_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done) {
|
17423 | _context.next = 14;
|
17424 | break;
|
17425 | }
|
17426 |
|
17427 | id = _step3.value;
|
17428 | item = data.get(id);
|
17429 |
|
17430 | if (!(item != null)) {
|
17431 | _context.next = 11;
|
17432 | break;
|
17433 | }
|
17434 |
|
17435 | _context.next = 11;
|
17436 | return [id, item];
|
17437 |
|
17438 | case 11:
|
17439 | _iteratorNormalCompletion3 = true;
|
17440 | _context.next = 5;
|
17441 | break;
|
17442 |
|
17443 | case 14:
|
17444 | _context.next = 20;
|
17445 | break;
|
17446 |
|
17447 | case 16:
|
17448 | _context.prev = 16;
|
17449 | _context.t0 = _context["catch"](3);
|
17450 | _didIteratorError3 = true;
|
17451 | _iteratorError3 = _context.t0;
|
17452 |
|
17453 | case 20:
|
17454 | _context.prev = 20;
|
17455 | _context.prev = 21;
|
17456 |
|
17457 | if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
17458 | _iterator3.return();
|
17459 | }
|
17460 |
|
17461 | case 23:
|
17462 | _context.prev = 23;
|
17463 |
|
17464 | if (!_didIteratorError3) {
|
17465 | _context.next = 26;
|
17466 | break;
|
17467 | }
|
17468 |
|
17469 | throw _iteratorError3;
|
17470 |
|
17471 | case 26:
|
17472 | return _context.finish(23);
|
17473 |
|
17474 | case 27:
|
17475 | return _context.finish(20);
|
17476 |
|
17477 | case 28:
|
17478 | case "end":
|
17479 | return _context.stop();
|
17480 | }
|
17481 | }
|
17482 | }, _callee, null, [[3, 16, 20, 28], [21,, 23, 27]]);
|
17483 | })));
|
17484 | } else {
|
17485 | return new DataStream(defineProperty$1({}, Symbol.iterator, this._data.entries.bind(this._data)));
|
17486 | }
|
17487 | }
|
17488 | }]);
|
17489 | return DataSet;
|
17490 | }(DataSetPart);
|
17491 |
|
17492 |
|
17493 |
|
17494 |
|
17495 |
|
17496 |
|
17497 |
|
17498 |
|
17499 |
|
17500 |
|
17501 |
|
17502 |
|
17503 |
|
17504 |
|
17505 |
|
17506 |
|
17507 |
|
17508 |
|
17509 |
|
17510 |
|
17511 |
|
17512 |
|
17513 |
|
17514 |
|
17515 |
|
17516 |
|
17517 |
|
17518 |
|
17519 |
|
17520 |
|
17521 |
|
17522 |
|
17523 |
|
17524 |
|
17525 |
|
17526 |
|
17527 |
|
17528 |
|
17529 |
|
17530 |
|
17531 |
|
17532 |
|
17533 |
|
17534 |
|
17535 |
|
17536 |
|
17537 |
|
17538 | var DataView =
|
17539 |
|
17540 | function (_DataSetPart) {
|
17541 | inherits(DataView, _DataSetPart);
|
17542 | |
17543 |
|
17544 |
|
17545 |
|
17546 |
|
17547 |
|
17548 |
|
17549 | function DataView(data, options) {
|
17550 | var _this;
|
17551 |
|
17552 | classCallCheck(this, DataView);
|
17553 | _this = possibleConstructorReturn(this, getPrototypeOf(DataView).call(this));
|
17554 |
|
17555 |
|
17556 | _this.length = 0;
|
17557 | _this._ids = new Set();
|
17558 |
|
17559 | _this._options = options || {};
|
17560 | _this._listener = _this._onEvent.bind(assertThisInitialized(_this));
|
17561 |
|
17562 | _this.setData(data);
|
17563 |
|
17564 | return _this;
|
17565 | }
|
17566 |
|
17567 |
|
17568 | |
17569 |
|
17570 |
|
17571 |
|
17572 |
|
17573 |
|
17574 |
|
17575 | createClass(DataView, [{
|
17576 | key: "setData",
|
17577 | value: function setData(data) {
|
17578 | if (this._data) {
|
17579 |
|
17580 | if (this._data.off) {
|
17581 | this._data.off("*", this._listener);
|
17582 | }
|
17583 |
|
17584 |
|
17585 | var ids = this._data.getIds({
|
17586 | filter: this._options.filter
|
17587 | });
|
17588 |
|
17589 | var items = this._data.get(ids);
|
17590 |
|
17591 | this._ids.clear();
|
17592 |
|
17593 | this.length = 0;
|
17594 |
|
17595 | this._trigger("remove", {
|
17596 | items: ids,
|
17597 | oldData: items
|
17598 | });
|
17599 | }
|
17600 |
|
17601 | if (data != null) {
|
17602 | this._data = data;
|
17603 |
|
17604 | var _ids = this._data.getIds({
|
17605 | filter: this._options.filter
|
17606 | });
|
17607 |
|
17608 | for (var i = 0, len = _ids.length; i < len; i++) {
|
17609 | var id = _ids[i];
|
17610 |
|
17611 | this._ids.add(id);
|
17612 | }
|
17613 |
|
17614 | this.length = _ids.length;
|
17615 |
|
17616 | this._trigger("add", {
|
17617 | items: _ids
|
17618 | });
|
17619 | } else {
|
17620 | this._data = new DataSet();
|
17621 | }
|
17622 |
|
17623 |
|
17624 | if (this._data.on) {
|
17625 | this._data.on("*", this._listener);
|
17626 | }
|
17627 | }
|
17628 | |
17629 |
|
17630 |
|
17631 |
|
17632 |
|
17633 | }, {
|
17634 | key: "refresh",
|
17635 | value: function refresh() {
|
17636 | var ids = this._data.getIds({
|
17637 | filter: this._options.filter
|
17638 | });
|
17639 |
|
17640 | var oldIds = toConsumableArray(this._ids);
|
17641 | var newIds = {};
|
17642 | var addedIds = [];
|
17643 | var removedIds = [];
|
17644 | var removedItems = [];
|
17645 |
|
17646 | for (var i = 0, len = ids.length; i < len; i++) {
|
17647 | var id = ids[i];
|
17648 | newIds[id] = true;
|
17649 |
|
17650 | if (!this._ids.has(id)) {
|
17651 | addedIds.push(id);
|
17652 |
|
17653 | this._ids.add(id);
|
17654 | }
|
17655 | }
|
17656 |
|
17657 |
|
17658 | for (var _i = 0, _len = oldIds.length; _i < _len; _i++) {
|
17659 | var _id = oldIds[_i];
|
17660 |
|
17661 | var item = this._data.get(_id);
|
17662 |
|
17663 | if (item == null) {
|
17664 |
|
17665 |
|
17666 |
|
17667 |
|
17668 | console.error("If you see this, report it please.");
|
17669 | } else if (!newIds[_id]) {
|
17670 | removedIds.push(_id);
|
17671 | removedItems.push(item);
|
17672 |
|
17673 | this._ids.delete(_id);
|
17674 | }
|
17675 | }
|
17676 |
|
17677 | this.length += addedIds.length - removedIds.length;
|
17678 |
|
17679 | if (addedIds.length) {
|
17680 | this._trigger("add", {
|
17681 | items: addedIds
|
17682 | });
|
17683 | }
|
17684 |
|
17685 | if (removedIds.length) {
|
17686 | this._trigger("remove", {
|
17687 | items: removedIds,
|
17688 | oldData: removedItems
|
17689 | });
|
17690 | }
|
17691 | }
|
17692 |
|
17693 |
|
17694 | }, {
|
17695 | key: "get",
|
17696 | value: function get(first, second) {
|
17697 | if (this._data == null) {
|
17698 | return null;
|
17699 | }
|
17700 |
|
17701 |
|
17702 | var ids = null;
|
17703 | var options;
|
17704 |
|
17705 | if (isId(first) || Array.isArray(first)) {
|
17706 | ids = first;
|
17707 | options = second;
|
17708 | } else {
|
17709 | options = first;
|
17710 | }
|
17711 |
|
17712 |
|
17713 | var viewOptions = Object.assign({}, this._options, options);
|
17714 |
|
17715 | var thisFilter = this._options.filter;
|
17716 | var optionsFilter = options && options.filter;
|
17717 |
|
17718 | if (thisFilter && optionsFilter) {
|
17719 | viewOptions.filter = function (item) {
|
17720 | return thisFilter(item) && optionsFilter(item);
|
17721 | };
|
17722 | }
|
17723 |
|
17724 | if (ids == null) {
|
17725 | return this._data.get(viewOptions);
|
17726 | } else {
|
17727 | return this._data.get(ids, viewOptions);
|
17728 | }
|
17729 | }
|
17730 |
|
17731 |
|
17732 | }, {
|
17733 | key: "getIds",
|
17734 | value: function getIds(options) {
|
17735 | if (this._data.length) {
|
17736 | var defaultFilter = this._options.filter;
|
17737 | var optionsFilter = options != null ? options.filter : null;
|
17738 | var filter;
|
17739 |
|
17740 | if (optionsFilter) {
|
17741 | if (defaultFilter) {
|
17742 | filter = function filter(item) {
|
17743 | return defaultFilter(item) && optionsFilter(item);
|
17744 | };
|
17745 | } else {
|
17746 | filter = optionsFilter;
|
17747 | }
|
17748 | } else {
|
17749 | filter = defaultFilter;
|
17750 | }
|
17751 |
|
17752 | return this._data.getIds({
|
17753 | filter: filter,
|
17754 | order: options && options.order
|
17755 | });
|
17756 | } else {
|
17757 | return [];
|
17758 | }
|
17759 | }
|
17760 |
|
17761 |
|
17762 | }, {
|
17763 | key: "forEach",
|
17764 | value: function forEach(callback, options) {
|
17765 | if (this._data) {
|
17766 | var defaultFilter = this._options.filter;
|
17767 | var optionsFilter = options && options.filter;
|
17768 | var filter;
|
17769 |
|
17770 | if (optionsFilter) {
|
17771 | if (defaultFilter) {
|
17772 | filter = function filter(item) {
|
17773 | return defaultFilter(item) && optionsFilter(item);
|
17774 | };
|
17775 | } else {
|
17776 | filter = optionsFilter;
|
17777 | }
|
17778 | } else {
|
17779 | filter = defaultFilter;
|
17780 | }
|
17781 |
|
17782 | this._data.forEach(callback, {
|
17783 | filter: filter,
|
17784 | order: options && options.order
|
17785 | });
|
17786 | }
|
17787 | }
|
17788 |
|
17789 |
|
17790 | }, {
|
17791 | key: "map",
|
17792 | value: function map(callback, options) {
|
17793 | if (this._data) {
|
17794 | var defaultFilter = this._options.filter;
|
17795 | var optionsFilter = options && options.filter;
|
17796 | var filter;
|
17797 |
|
17798 | if (optionsFilter) {
|
17799 | if (defaultFilter) {
|
17800 | filter = function filter(item) {
|
17801 | return defaultFilter(item) && optionsFilter(item);
|
17802 | };
|
17803 | } else {
|
17804 | filter = optionsFilter;
|
17805 | }
|
17806 | } else {
|
17807 | filter = defaultFilter;
|
17808 | }
|
17809 |
|
17810 | return this._data.map(callback, {
|
17811 | filter: filter,
|
17812 | order: options && options.order
|
17813 | });
|
17814 | } else {
|
17815 | return [];
|
17816 | }
|
17817 | }
|
17818 |
|
17819 |
|
17820 | }, {
|
17821 | key: "getDataSet",
|
17822 | value: function getDataSet() {
|
17823 | return this._data.getDataSet();
|
17824 | }
|
17825 |
|
17826 |
|
17827 | }, {
|
17828 | key: "stream",
|
17829 | value: function stream(ids) {
|
17830 | return this._data.stream(ids || defineProperty$1({}, Symbol.iterator, this._ids.keys.bind(this._ids)));
|
17831 | }
|
17832 | |
17833 |
|
17834 |
|
17835 |
|
17836 |
|
17837 |
|
17838 |
|
17839 |
|
17840 | }, {
|
17841 | key: "_onEvent",
|
17842 | value: function _onEvent(event, params, senderId) {
|
17843 | if (!params || !params.items || !this._data) {
|
17844 | return;
|
17845 | }
|
17846 |
|
17847 | var ids = params.items;
|
17848 | var addedIds = [];
|
17849 | var updatedIds = [];
|
17850 | var removedIds = [];
|
17851 | var oldItems = [];
|
17852 | var updatedItems = [];
|
17853 | var removedItems = [];
|
17854 |
|
17855 | switch (event) {
|
17856 | case "add":
|
17857 |
|
17858 | for (var i = 0, len = ids.length; i < len; i++) {
|
17859 | var id = ids[i];
|
17860 | var item = this.get(id);
|
17861 |
|
17862 | if (item) {
|
17863 | this._ids.add(id);
|
17864 |
|
17865 | addedIds.push(id);
|
17866 | }
|
17867 | }
|
17868 |
|
17869 | break;
|
17870 |
|
17871 | case "update":
|
17872 |
|
17873 |
|
17874 | for (var _i2 = 0, _len2 = ids.length; _i2 < _len2; _i2++) {
|
17875 | var _id2 = ids[_i2];
|
17876 |
|
17877 | var _item = this.get(_id2);
|
17878 |
|
17879 | if (_item) {
|
17880 | if (this._ids.has(_id2)) {
|
17881 | updatedIds.push(_id2);
|
17882 | updatedItems.push(params.data[_i2]);
|
17883 | oldItems.push(params.oldData[_i2]);
|
17884 | } else {
|
17885 | this._ids.add(_id2);
|
17886 |
|
17887 | addedIds.push(_id2);
|
17888 | }
|
17889 | } else {
|
17890 | if (this._ids.has(_id2)) {
|
17891 | this._ids.delete(_id2);
|
17892 |
|
17893 | removedIds.push(_id2);
|
17894 | removedItems.push(params.oldData[_i2]);
|
17895 | }
|
17896 | }
|
17897 | }
|
17898 |
|
17899 | break;
|
17900 |
|
17901 | case "remove":
|
17902 |
|
17903 | for (var _i3 = 0, _len3 = ids.length; _i3 < _len3; _i3++) {
|
17904 | var _id3 = ids[_i3];
|
17905 |
|
17906 | if (this._ids.has(_id3)) {
|
17907 | this._ids.delete(_id3);
|
17908 |
|
17909 | removedIds.push(_id3);
|
17910 | removedItems.push(params.oldData[_i3]);
|
17911 | }
|
17912 | }
|
17913 |
|
17914 | break;
|
17915 | }
|
17916 |
|
17917 | this.length += addedIds.length - removedIds.length;
|
17918 |
|
17919 | if (addedIds.length) {
|
17920 | this._trigger("add", {
|
17921 | items: addedIds
|
17922 | }, senderId);
|
17923 | }
|
17924 |
|
17925 | if (updatedIds.length) {
|
17926 | this._trigger("update", {
|
17927 | items: updatedIds,
|
17928 | oldData: oldItems,
|
17929 | data: updatedItems
|
17930 | }, senderId);
|
17931 | }
|
17932 |
|
17933 | if (removedIds.length) {
|
17934 | this._trigger("remove", {
|
17935 | items: removedIds,
|
17936 | oldData: removedItems
|
17937 | }, senderId);
|
17938 | }
|
17939 | }
|
17940 | }]);
|
17941 | return DataView;
|
17942 | }(DataSetPart);
|
17943 |
|
17944 | var index = {
|
17945 | DataSet: DataSet,
|
17946 | DataView: DataView,
|
17947 | Queue: Queue
|
17948 | };
|
17949 |
|
17950 | function _typeof$2(obj) {
|
17951 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
17952 | _typeof$2 = function (obj) {
|
17953 | return typeof obj;
|
17954 | };
|
17955 | } else {
|
17956 | _typeof$2 = function (obj) {
|
17957 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
17958 | };
|
17959 | }
|
17960 |
|
17961 | return _typeof$2(obj);
|
17962 | }
|
17963 |
|
17964 | function _classCallCheck$1(instance, Constructor) {
|
17965 | if (!(instance instanceof Constructor)) {
|
17966 | throw new TypeError("Cannot call a class as a function");
|
17967 | }
|
17968 | }
|
17969 |
|
17970 | function _defineProperties$1(target, props) {
|
17971 | for (var i = 0; i < props.length; i++) {
|
17972 | var descriptor = props[i];
|
17973 | descriptor.enumerable = descriptor.enumerable || false;
|
17974 | descriptor.configurable = true;
|
17975 | if ("value" in descriptor) descriptor.writable = true;
|
17976 | Object.defineProperty(target, descriptor.key, descriptor);
|
17977 | }
|
17978 | }
|
17979 |
|
17980 | function _createClass$1(Constructor, protoProps, staticProps) {
|
17981 | if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
17982 | if (staticProps) _defineProperties$1(Constructor, staticProps);
|
17983 | return Constructor;
|
17984 | }
|
17985 |
|
17986 |
|
17987 |
|
17988 |
|
17989 | var emitterComponent = Emitter;
|
17990 |
|
17991 |
|
17992 |
|
17993 |
|
17994 |
|
17995 |
|
17996 | function Emitter(obj) {
|
17997 | if (obj) return mixin(obj);
|
17998 | }
|
17999 |
|
18000 |
|
18001 |
|
18002 |
|
18003 |
|
18004 |
|
18005 |
|
18006 |
|
18007 | function mixin(obj) {
|
18008 | for (var key in Emitter.prototype) {
|
18009 | obj[key] = Emitter.prototype[key];
|
18010 | }
|
18011 |
|
18012 | return obj;
|
18013 | }
|
18014 |
|
18015 |
|
18016 |
|
18017 |
|
18018 |
|
18019 |
|
18020 |
|
18021 |
|
18022 |
|
18023 |
|
18024 | Emitter.prototype.on = Emitter.prototype.addEventListener = function (event, fn) {
|
18025 | this._callbacks = this._callbacks || {};
|
18026 | (this._callbacks[event] = this._callbacks[event] || []).push(fn);
|
18027 | return this;
|
18028 | };
|
18029 |
|
18030 |
|
18031 |
|
18032 |
|
18033 |
|
18034 |
|
18035 |
|
18036 |
|
18037 |
|
18038 |
|
18039 |
|
18040 | Emitter.prototype.once = function (event, fn) {
|
18041 | var self = this;
|
18042 | this._callbacks = this._callbacks || {};
|
18043 |
|
18044 | function on() {
|
18045 | self.off(event, on);
|
18046 | fn.apply(this, arguments);
|
18047 | }
|
18048 |
|
18049 | on.fn = fn;
|
18050 | this.on(event, on);
|
18051 | return this;
|
18052 | };
|
18053 |
|
18054 |
|
18055 |
|
18056 |
|
18057 |
|
18058 |
|
18059 |
|
18060 |
|
18061 |
|
18062 |
|
18063 |
|
18064 | Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function (event, fn) {
|
18065 | this._callbacks = this._callbacks || {};
|
18066 |
|
18067 | if (0 == arguments.length) {
|
18068 | this._callbacks = {};
|
18069 | return this;
|
18070 | }
|
18071 |
|
18072 |
|
18073 | var callbacks = this._callbacks[event];
|
18074 | if (!callbacks) return this;
|
18075 |
|
18076 | if (1 == arguments.length) {
|
18077 | delete this._callbacks[event];
|
18078 | return this;
|
18079 | }
|
18080 |
|
18081 |
|
18082 | var cb;
|
18083 |
|
18084 | for (var i = 0; i < callbacks.length; i++) {
|
18085 | cb = callbacks[i];
|
18086 |
|
18087 | if (cb === fn || cb.fn === fn) {
|
18088 | callbacks.splice(i, 1);
|
18089 | break;
|
18090 | }
|
18091 | }
|
18092 |
|
18093 | return this;
|
18094 | };
|
18095 |
|
18096 |
|
18097 |
|
18098 |
|
18099 |
|
18100 |
|
18101 |
|
18102 |
|
18103 |
|
18104 | Emitter.prototype.emit = function (event) {
|
18105 | this._callbacks = this._callbacks || {};
|
18106 | var args = [].slice.call(arguments, 1),
|
18107 | callbacks = this._callbacks[event];
|
18108 |
|
18109 | if (callbacks) {
|
18110 | callbacks = callbacks.slice(0);
|
18111 |
|
18112 | for (var i = 0, len = callbacks.length; i < len; ++i) {
|
18113 | callbacks[i].apply(this, args);
|
18114 | }
|
18115 | }
|
18116 |
|
18117 | return this;
|
18118 | };
|
18119 |
|
18120 |
|
18121 |
|
18122 |
|
18123 |
|
18124 |
|
18125 |
|
18126 |
|
18127 |
|
18128 | Emitter.prototype.listeners = function (event) {
|
18129 | this._callbacks = this._callbacks || {};
|
18130 | return this._callbacks[event] || [];
|
18131 | };
|
18132 |
|
18133 |
|
18134 |
|
18135 |
|
18136 |
|
18137 |
|
18138 |
|
18139 |
|
18140 |
|
18141 | Emitter.prototype.hasListeners = function (event) {
|
18142 | return !!this.listeners(event).length;
|
18143 | };
|
18144 |
|
18145 |
|
18146 |
|
18147 |
|
18148 |
|
18149 |
|
18150 |
|
18151 | function Point3d(x, y, z) {
|
18152 | this.x = x !== undefined ? x : 0;
|
18153 | this.y = y !== undefined ? y : 0;
|
18154 | this.z = z !== undefined ? z : 0;
|
18155 | }
|
18156 |
|
18157 |
|
18158 |
|
18159 |
|
18160 |
|
18161 |
|
18162 |
|
18163 |
|
18164 | Point3d.subtract = function (a, b) {
|
18165 | var sub = new Point3d();
|
18166 | sub.x = a.x - b.x;
|
18167 | sub.y = a.y - b.y;
|
18168 | sub.z = a.z - b.z;
|
18169 | return sub;
|
18170 | };
|
18171 |
|
18172 |
|
18173 |
|
18174 |
|
18175 |
|
18176 |
|
18177 |
|
18178 |
|
18179 | Point3d.add = function (a, b) {
|
18180 | var sum = new Point3d();
|
18181 | sum.x = a.x + b.x;
|
18182 | sum.y = a.y + b.y;
|
18183 | sum.z = a.z + b.z;
|
18184 | return sum;
|
18185 | };
|
18186 |
|
18187 |
|
18188 |
|
18189 |
|
18190 |
|
18191 |
|
18192 |
|
18193 |
|
18194 | Point3d.avg = function (a, b) {
|
18195 | return new Point3d((a.x + b.x) / 2, (a.y + b.y) / 2, (a.z + b.z) / 2);
|
18196 | };
|
18197 |
|
18198 |
|
18199 |
|
18200 |
|
18201 |
|
18202 |
|
18203 |
|
18204 |
|
18205 |
|
18206 | Point3d.crossProduct = function (a, b) {
|
18207 | var crossproduct = new Point3d();
|
18208 | crossproduct.x = a.y * b.z - a.z * b.y;
|
18209 | crossproduct.y = a.z * b.x - a.x * b.z;
|
18210 | crossproduct.z = a.x * b.y - a.y * b.x;
|
18211 | return crossproduct;
|
18212 | };
|
18213 |
|
18214 |
|
18215 |
|
18216 |
|
18217 |
|
18218 |
|
18219 | Point3d.prototype.length = function () {
|
18220 | return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
18221 | };
|
18222 |
|
18223 | var Point3d_1 = Point3d;
|
18224 |
|
18225 |
|
18226 |
|
18227 |
|
18228 |
|
18229 |
|
18230 | function Point2d(x, y) {
|
18231 | this.x = x !== undefined ? x : 0;
|
18232 | this.y = y !== undefined ? y : 0;
|
18233 | }
|
18234 |
|
18235 | var Point2d_1 = Point2d;
|
18236 |
|
18237 |
|
18238 |
|
18239 |
|
18240 |
|
18241 |
|
18242 |
|
18243 |
|
18244 |
|
18245 |
|
18246 |
|
18247 | function Slider(container, options) {
|
18248 | if (container === undefined) {
|
18249 | throw new Error('No container element defined');
|
18250 | }
|
18251 |
|
18252 | this.container = container;
|
18253 | this.visible = options && options.visible != undefined ? options.visible : true;
|
18254 |
|
18255 | if (this.visible) {
|
18256 | this.frame = document.createElement('DIV');
|
18257 |
|
18258 | this.frame.style.width = '100%';
|
18259 | this.frame.style.position = 'relative';
|
18260 | this.container.appendChild(this.frame);
|
18261 | this.frame.prev = document.createElement('INPUT');
|
18262 | this.frame.prev.type = 'BUTTON';
|
18263 | this.frame.prev.value = 'Prev';
|
18264 | this.frame.appendChild(this.frame.prev);
|
18265 | this.frame.play = document.createElement('INPUT');
|
18266 | this.frame.play.type = 'BUTTON';
|
18267 | this.frame.play.value = 'Play';
|
18268 | this.frame.appendChild(this.frame.play);
|
18269 | this.frame.next = document.createElement('INPUT');
|
18270 | this.frame.next.type = 'BUTTON';
|
18271 | this.frame.next.value = 'Next';
|
18272 | this.frame.appendChild(this.frame.next);
|
18273 | this.frame.bar = document.createElement('INPUT');
|
18274 | this.frame.bar.type = 'BUTTON';
|
18275 | this.frame.bar.style.position = 'absolute';
|
18276 | this.frame.bar.style.border = '1px solid red';
|
18277 | this.frame.bar.style.width = '100px';
|
18278 | this.frame.bar.style.height = '6px';
|
18279 | this.frame.bar.style.borderRadius = '2px';
|
18280 | this.frame.bar.style.MozBorderRadius = '2px';
|
18281 | this.frame.bar.style.border = '1px solid #7F7F7F';
|
18282 | this.frame.bar.style.backgroundColor = '#E5E5E5';
|
18283 | this.frame.appendChild(this.frame.bar);
|
18284 | this.frame.slide = document.createElement('INPUT');
|
18285 | this.frame.slide.type = 'BUTTON';
|
18286 | this.frame.slide.style.margin = '0px';
|
18287 | this.frame.slide.value = ' ';
|
18288 | this.frame.slide.style.position = 'relative';
|
18289 | this.frame.slide.style.left = '-100px';
|
18290 | this.frame.appendChild(this.frame.slide);
|
18291 |
|
18292 | var me = this;
|
18293 |
|
18294 | this.frame.slide.onmousedown = function (event) {
|
18295 | me._onMouseDown(event);
|
18296 | };
|
18297 |
|
18298 | this.frame.prev.onclick = function (event) {
|
18299 | me.prev(event);
|
18300 | };
|
18301 |
|
18302 | this.frame.play.onclick = function (event) {
|
18303 | me.togglePlay(event);
|
18304 | };
|
18305 |
|
18306 | this.frame.next.onclick = function (event) {
|
18307 | me.next(event);
|
18308 | };
|
18309 | }
|
18310 |
|
18311 | this.onChangeCallback = undefined;
|
18312 | this.values = [];
|
18313 | this.index = undefined;
|
18314 | this.playTimeout = undefined;
|
18315 | this.playInterval = 1000;
|
18316 |
|
18317 | this.playLoop = true;
|
18318 | }
|
18319 |
|
18320 |
|
18321 |
|
18322 |
|
18323 |
|
18324 | Slider.prototype.prev = function () {
|
18325 | var index = this.getIndex();
|
18326 |
|
18327 | if (index > 0) {
|
18328 | index--;
|
18329 | this.setIndex(index);
|
18330 | }
|
18331 | };
|
18332 |
|
18333 |
|
18334 |
|
18335 |
|
18336 |
|
18337 | Slider.prototype.next = function () {
|
18338 | var index = this.getIndex();
|
18339 |
|
18340 | if (index < this.values.length - 1) {
|
18341 | index++;
|
18342 | this.setIndex(index);
|
18343 | }
|
18344 | };
|
18345 |
|
18346 |
|
18347 |
|
18348 |
|
18349 |
|
18350 | Slider.prototype.playNext = function () {
|
18351 | var start = new Date();
|
18352 | var index = this.getIndex();
|
18353 |
|
18354 | if (index < this.values.length - 1) {
|
18355 | index++;
|
18356 | this.setIndex(index);
|
18357 | } else if (this.playLoop) {
|
18358 |
|
18359 | index = 0;
|
18360 | this.setIndex(index);
|
18361 | }
|
18362 |
|
18363 | var end = new Date();
|
18364 | var diff = end - start;
|
18365 |
|
18366 |
|
18367 | var interval = Math.max(this.playInterval - diff, 0);
|
18368 |
|
18369 | var me = this;
|
18370 | this.playTimeout = setTimeout(function () {
|
18371 | me.playNext();
|
18372 | }, interval);
|
18373 | };
|
18374 |
|
18375 |
|
18376 |
|
18377 |
|
18378 |
|
18379 | Slider.prototype.togglePlay = function () {
|
18380 | if (this.playTimeout === undefined) {
|
18381 | this.play();
|
18382 | } else {
|
18383 | this.stop();
|
18384 | }
|
18385 | };
|
18386 |
|
18387 |
|
18388 |
|
18389 |
|
18390 |
|
18391 | Slider.prototype.play = function () {
|
18392 |
|
18393 | if (this.playTimeout) return;
|
18394 | this.playNext();
|
18395 |
|
18396 | if (this.frame) {
|
18397 | this.frame.play.value = 'Stop';
|
18398 | }
|
18399 | };
|
18400 |
|
18401 |
|
18402 |
|
18403 |
|
18404 |
|
18405 | Slider.prototype.stop = function () {
|
18406 | clearInterval(this.playTimeout);
|
18407 | this.playTimeout = undefined;
|
18408 |
|
18409 | if (this.frame) {
|
18410 | this.frame.play.value = 'Play';
|
18411 | }
|
18412 | };
|
18413 |
|
18414 |
|
18415 |
|
18416 |
|
18417 |
|
18418 |
|
18419 |
|
18420 |
|
18421 | Slider.prototype.setOnChangeCallback = function (callback) {
|
18422 | this.onChangeCallback = callback;
|
18423 | };
|
18424 |
|
18425 |
|
18426 |
|
18427 |
|
18428 |
|
18429 |
|
18430 | Slider.prototype.setPlayInterval = function (interval) {
|
18431 | this.playInterval = interval;
|
18432 | };
|
18433 |
|
18434 |
|
18435 |
|
18436 |
|
18437 |
|
18438 |
|
18439 | Slider.prototype.getPlayInterval = function () {
|
18440 | return this.playInterval;
|
18441 | };
|
18442 |
|
18443 |
|
18444 |
|
18445 |
|
18446 |
|
18447 |
|
18448 |
|
18449 |
|
18450 |
|
18451 | Slider.prototype.setPlayLoop = function (doLoop) {
|
18452 | this.playLoop = doLoop;
|
18453 | };
|
18454 |
|
18455 |
|
18456 |
|
18457 |
|
18458 |
|
18459 | Slider.prototype.onChange = function () {
|
18460 | if (this.onChangeCallback !== undefined) {
|
18461 | this.onChangeCallback();
|
18462 | }
|
18463 | };
|
18464 |
|
18465 |
|
18466 |
|
18467 |
|
18468 |
|
18469 | Slider.prototype.redraw = function () {
|
18470 | if (this.frame) {
|
18471 |
|
18472 | this.frame.bar.style.top = this.frame.clientHeight / 2 - this.frame.bar.offsetHeight / 2 + 'px';
|
18473 | this.frame.bar.style.width = this.frame.clientWidth - this.frame.prev.clientWidth - this.frame.play.clientWidth - this.frame.next.clientWidth - 30 + 'px';
|
18474 |
|
18475 | var left = this.indexToLeft(this.index);
|
18476 | this.frame.slide.style.left = left + 'px';
|
18477 | }
|
18478 | };
|
18479 |
|
18480 |
|
18481 |
|
18482 |
|
18483 |
|
18484 |
|
18485 | Slider.prototype.setValues = function (values) {
|
18486 | this.values = values;
|
18487 | if (this.values.length > 0) this.setIndex(0);else this.index = undefined;
|
18488 | };
|
18489 |
|
18490 |
|
18491 |
|
18492 |
|
18493 |
|
18494 |
|
18495 | Slider.prototype.setIndex = function (index) {
|
18496 | if (index < this.values.length) {
|
18497 | this.index = index;
|
18498 | this.redraw();
|
18499 | this.onChange();
|
18500 | } else {
|
18501 | throw new Error('Index out of range');
|
18502 | }
|
18503 | };
|
18504 |
|
18505 |
|
18506 |
|
18507 |
|
18508 |
|
18509 |
|
18510 | Slider.prototype.getIndex = function () {
|
18511 | return this.index;
|
18512 | };
|
18513 |
|
18514 |
|
18515 |
|
18516 |
|
18517 |
|
18518 |
|
18519 | Slider.prototype.get = function () {
|
18520 | return this.values[this.index];
|
18521 | };
|
18522 |
|
18523 | Slider.prototype._onMouseDown = function (event) {
|
18524 |
|
18525 | var leftButtonDown = event.which ? event.which === 1 : event.button === 1;
|
18526 | if (!leftButtonDown) return;
|
18527 | this.startClientX = event.clientX;
|
18528 | this.startSlideX = parseFloat(this.frame.slide.style.left);
|
18529 | this.frame.style.cursor = 'move';
|
18530 |
|
18531 |
|
18532 |
|
18533 | var me = this;
|
18534 |
|
18535 | this.onmousemove = function (event) {
|
18536 | me._onMouseMove(event);
|
18537 | };
|
18538 |
|
18539 | this.onmouseup = function (event) {
|
18540 | me._onMouseUp(event);
|
18541 | };
|
18542 |
|
18543 | util.addEventListener(document, 'mousemove', this.onmousemove);
|
18544 | util.addEventListener(document, 'mouseup', this.onmouseup);
|
18545 | util.preventDefault(event);
|
18546 | };
|
18547 |
|
18548 | Slider.prototype.leftToIndex = function (left) {
|
18549 | var width = parseFloat(this.frame.bar.style.width) - this.frame.slide.clientWidth - 10;
|
18550 | var x = left - 3;
|
18551 | var index = Math.round(x / width * (this.values.length - 1));
|
18552 | if (index < 0) index = 0;
|
18553 | if (index > this.values.length - 1) index = this.values.length - 1;
|
18554 | return index;
|
18555 | };
|
18556 |
|
18557 | Slider.prototype.indexToLeft = function (index) {
|
18558 | var width = parseFloat(this.frame.bar.style.width) - this.frame.slide.clientWidth - 10;
|
18559 | var x = index / (this.values.length - 1) * width;
|
18560 | var left = x + 3;
|
18561 | return left;
|
18562 | };
|
18563 |
|
18564 | Slider.prototype._onMouseMove = function (event) {
|
18565 | var diff = event.clientX - this.startClientX;
|
18566 | var x = this.startSlideX + diff;
|
18567 | var index = this.leftToIndex(x);
|
18568 | this.setIndex(index);
|
18569 | util.preventDefault();
|
18570 | };
|
18571 |
|
18572 | Slider.prototype._onMouseUp = function (event) {
|
18573 |
|
18574 | this.frame.style.cursor = 'auto';
|
18575 |
|
18576 | util.removeEventListener(document, 'mousemove', this.onmousemove);
|
18577 | util.removeEventListener(document, 'mouseup', this.onmouseup);
|
18578 | util.preventDefault();
|
18579 | };
|
18580 |
|
18581 | var Slider_1 = Slider;
|
18582 |
|
18583 |
|
18584 |
|
18585 |
|
18586 |
|
18587 |
|
18588 |
|
18589 |
|
18590 |
|
18591 |
|
18592 |
|
18593 |
|
18594 |
|
18595 |
|
18596 |
|
18597 |
|
18598 |
|
18599 |
|
18600 |
|
18601 |
|
18602 |
|
18603 |
|
18604 |
|
18605 |
|
18606 |
|
18607 |
|
18608 | function StepNumber(start, end, step, prettyStep) {
|
18609 |
|
18610 | this._start = 0;
|
18611 | this._end = 0;
|
18612 | this._step = 1;
|
18613 | this.prettyStep = true;
|
18614 | this.precision = 5;
|
18615 | this._current = 0;
|
18616 | this.setRange(start, end, step, prettyStep);
|
18617 | }
|
18618 |
|
18619 |
|
18620 |
|
18621 |
|
18622 |
|
18623 |
|
18624 |
|
18625 |
|
18626 |
|
18627 |
|
18628 | StepNumber.prototype.isNumeric = function (n) {
|
18629 | return !isNaN(parseFloat(n)) && isFinite(n);
|
18630 | };
|
18631 |
|
18632 |
|
18633 |
|
18634 |
|
18635 |
|
18636 |
|
18637 |
|
18638 |
|
18639 |
|
18640 |
|
18641 |
|
18642 | StepNumber.prototype.setRange = function (start, end, step, prettyStep) {
|
18643 | if (!this.isNumeric(start)) {
|
18644 | throw new Error('Parameter \'start\' is not numeric; value: ' + start);
|
18645 | }
|
18646 |
|
18647 | if (!this.isNumeric(end)) {
|
18648 | throw new Error('Parameter \'end\' is not numeric; value: ' + start);
|
18649 | }
|
18650 |
|
18651 | if (!this.isNumeric(step)) {
|
18652 | throw new Error('Parameter \'step\' is not numeric; value: ' + start);
|
18653 | }
|
18654 |
|
18655 | this._start = start ? start : 0;
|
18656 | this._end = end ? end : 0;
|
18657 | this.setStep(step, prettyStep);
|
18658 | };
|
18659 |
|
18660 |
|
18661 |
|
18662 |
|
18663 |
|
18664 |
|
18665 |
|
18666 |
|
18667 | StepNumber.prototype.setStep = function (step, prettyStep) {
|
18668 | if (step === undefined || step <= 0) return;
|
18669 | if (prettyStep !== undefined) this.prettyStep = prettyStep;
|
18670 | if (this.prettyStep === true) this._step = StepNumber.calculatePrettyStep(step);else this._step = step;
|
18671 | };
|
18672 |
|
18673 |
|
18674 |
|
18675 |
|
18676 |
|
18677 |
|
18678 |
|
18679 |
|
18680 |
|
18681 | StepNumber.calculatePrettyStep = function (step) {
|
18682 | var log10 = function log10(x) {
|
18683 | return Math.log(x) / Math.LN10;
|
18684 | };
|
18685 |
|
18686 |
|
18687 | var step1 = Math.pow(10, Math.round(log10(step))),
|
18688 | step2 = 2 * Math.pow(10, Math.round(log10(step / 2))),
|
18689 | step5 = 5 * Math.pow(10, Math.round(log10(step / 5)));
|
18690 |
|
18691 | var prettyStep = step1;
|
18692 | if (Math.abs(step2 - step) <= Math.abs(prettyStep - step)) prettyStep = step2;
|
18693 | if (Math.abs(step5 - step) <= Math.abs(prettyStep - step)) prettyStep = step5;
|
18694 |
|
18695 | if (prettyStep <= 0) {
|
18696 | prettyStep = 1;
|
18697 | }
|
18698 |
|
18699 | return prettyStep;
|
18700 | };
|
18701 |
|
18702 |
|
18703 |
|
18704 |
|
18705 |
|
18706 |
|
18707 | StepNumber.prototype.getCurrent = function () {
|
18708 | return parseFloat(this._current.toPrecision(this.precision));
|
18709 | };
|
18710 |
|
18711 |
|
18712 |
|
18713 |
|
18714 |
|
18715 |
|
18716 | StepNumber.prototype.getStep = function () {
|
18717 | return this._step;
|
18718 | };
|
18719 |
|
18720 |
|
18721 |
|
18722 |
|
18723 |
|
18724 |
|
18725 |
|
18726 |
|
18727 |
|
18728 |
|
18729 |
|
18730 |
|
18731 |
|
18732 | StepNumber.prototype.start = function (checkFirst) {
|
18733 | if (checkFirst === undefined) {
|
18734 | checkFirst = false;
|
18735 | }
|
18736 |
|
18737 | this._current = this._start - this._start % this._step;
|
18738 |
|
18739 | if (checkFirst) {
|
18740 | if (this.getCurrent() < this._start) {
|
18741 | this.next();
|
18742 | }
|
18743 | }
|
18744 | };
|
18745 |
|
18746 |
|
18747 |
|
18748 |
|
18749 |
|
18750 | StepNumber.prototype.next = function () {
|
18751 | this._current += this._step;
|
18752 | };
|
18753 |
|
18754 |
|
18755 |
|
18756 |
|
18757 |
|
18758 |
|
18759 | StepNumber.prototype.end = function () {
|
18760 | return this._current > this._end;
|
18761 | };
|
18762 |
|
18763 | var StepNumber_1 = StepNumber;
|
18764 |
|
18765 |
|
18766 |
|
18767 |
|
18768 |
|
18769 |
|
18770 |
|
18771 |
|
18772 |
|
18773 |
|
18774 |
|
18775 |
|
18776 | function Camera() {
|
18777 | this.armLocation = new Point3d_1();
|
18778 | this.armRotation = {};
|
18779 | this.armRotation.horizontal = 0;
|
18780 | this.armRotation.vertical = 0;
|
18781 | this.armLength = 1.7;
|
18782 | this.cameraOffset = new Point3d_1();
|
18783 | this.offsetMultiplier = 0.6;
|
18784 | this.cameraLocation = new Point3d_1();
|
18785 | this.cameraRotation = new Point3d_1(0.5 * Math.PI, 0, 0);
|
18786 | this.calculateCameraOrientation();
|
18787 | }
|
18788 |
|
18789 |
|
18790 |
|
18791 |
|
18792 |
|
18793 |
|
18794 |
|
18795 | Camera.prototype.setOffset = function (x, y) {
|
18796 | var abs = Math.abs,
|
18797 | sign = Math.sign,
|
18798 | mul = this.offsetMultiplier,
|
18799 | border = this.armLength * mul;
|
18800 |
|
18801 | if (abs(x) > border) {
|
18802 | x = sign(x) * border;
|
18803 | }
|
18804 |
|
18805 | if (abs(y) > border) {
|
18806 | y = sign(y) * border;
|
18807 | }
|
18808 |
|
18809 | this.cameraOffset.x = x;
|
18810 | this.cameraOffset.y = y;
|
18811 | this.calculateCameraOrientation();
|
18812 | };
|
18813 |
|
18814 |
|
18815 |
|
18816 |
|
18817 |
|
18818 |
|
18819 | Camera.prototype.getOffset = function () {
|
18820 | return this.cameraOffset;
|
18821 | };
|
18822 |
|
18823 |
|
18824 |
|
18825 |
|
18826 |
|
18827 |
|
18828 |
|
18829 |
|
18830 | Camera.prototype.setArmLocation = function (x, y, z) {
|
18831 | this.armLocation.x = x;
|
18832 | this.armLocation.y = y;
|
18833 | this.armLocation.z = z;
|
18834 | this.calculateCameraOrientation();
|
18835 | };
|
18836 |
|
18837 |
|
18838 |
|
18839 |
|
18840 |
|
18841 |
|
18842 |
|
18843 |
|
18844 |
|
18845 |
|
18846 | Camera.prototype.setArmRotation = function (horizontal, vertical) {
|
18847 | if (horizontal !== undefined) {
|
18848 | this.armRotation.horizontal = horizontal;
|
18849 | }
|
18850 |
|
18851 | if (vertical !== undefined) {
|
18852 | this.armRotation.vertical = vertical;
|
18853 | if (this.armRotation.vertical < 0) this.armRotation.vertical = 0;
|
18854 | if (this.armRotation.vertical > 0.5 * Math.PI) this.armRotation.vertical = 0.5 * Math.PI;
|
18855 | }
|
18856 |
|
18857 | if (horizontal !== undefined || vertical !== undefined) {
|
18858 | this.calculateCameraOrientation();
|
18859 | }
|
18860 | };
|
18861 |
|
18862 |
|
18863 |
|
18864 |
|
18865 |
|
18866 |
|
18867 | Camera.prototype.getArmRotation = function () {
|
18868 | var rot = {};
|
18869 | rot.horizontal = this.armRotation.horizontal;
|
18870 | rot.vertical = this.armRotation.vertical;
|
18871 | return rot;
|
18872 | };
|
18873 |
|
18874 |
|
18875 |
|
18876 |
|
18877 |
|
18878 |
|
18879 | Camera.prototype.setArmLength = function (length) {
|
18880 | if (length === undefined) return;
|
18881 | this.armLength = length;
|
18882 |
|
18883 |
|
18884 |
|
18885 | if (this.armLength < 0.71) this.armLength = 0.71;
|
18886 | if (this.armLength > 5.0) this.armLength = 5.0;
|
18887 | this.setOffset(this.cameraOffset.x, this.cameraOffset.y);
|
18888 | this.calculateCameraOrientation();
|
18889 | };
|
18890 |
|
18891 |
|
18892 |
|
18893 |
|
18894 |
|
18895 |
|
18896 | Camera.prototype.getArmLength = function () {
|
18897 | return this.armLength;
|
18898 | };
|
18899 |
|
18900 |
|
18901 |
|
18902 |
|
18903 |
|
18904 |
|
18905 | Camera.prototype.getCameraLocation = function () {
|
18906 | return this.cameraLocation;
|
18907 | };
|
18908 |
|
18909 |
|
18910 |
|
18911 |
|
18912 |
|
18913 |
|
18914 | Camera.prototype.getCameraRotation = function () {
|
18915 | return this.cameraRotation;
|
18916 | };
|
18917 |
|
18918 |
|
18919 |
|
18920 |
|
18921 |
|
18922 |
|
18923 | Camera.prototype.calculateCameraOrientation = function () {
|
18924 |
|
18925 | this.cameraLocation.x = this.armLocation.x - this.armLength * Math.sin(this.armRotation.horizontal) * Math.cos(this.armRotation.vertical);
|
18926 | this.cameraLocation.y = this.armLocation.y - this.armLength * Math.cos(this.armRotation.horizontal) * Math.cos(this.armRotation.vertical);
|
18927 | this.cameraLocation.z = this.armLocation.z + this.armLength * Math.sin(this.armRotation.vertical);
|
18928 |
|
18929 | this.cameraRotation.x = Math.PI / 2 - this.armRotation.vertical;
|
18930 | this.cameraRotation.y = 0;
|
18931 | this.cameraRotation.z = -this.armRotation.horizontal;
|
18932 | var xa = this.cameraRotation.x;
|
18933 | var za = this.cameraRotation.z;
|
18934 | var dx = this.cameraOffset.x;
|
18935 | var dy = this.cameraOffset.y;
|
18936 | var sin = Math.sin,
|
18937 | cos = Math.cos;
|
18938 | this.cameraLocation.x = this.cameraLocation.x + dx * cos(za) + dy * -sin(za) * cos(xa);
|
18939 | this.cameraLocation.y = this.cameraLocation.y + dx * sin(za) + dy * cos(za) * cos(xa);
|
18940 | this.cameraLocation.z = this.cameraLocation.z + dy * sin(xa);
|
18941 | };
|
18942 |
|
18943 | var Camera_1 = Camera;
|
18944 |
|
18945 |
|
18946 |
|
18947 |
|
18948 |
|
18949 |
|
18950 | var STYLE = {
|
18951 | BAR: 0,
|
18952 | BARCOLOR: 1,
|
18953 | BARSIZE: 2,
|
18954 | DOT: 3,
|
18955 | DOTLINE: 4,
|
18956 | DOTCOLOR: 5,
|
18957 | DOTSIZE: 6,
|
18958 | GRID: 7,
|
18959 | LINE: 8,
|
18960 | SURFACE: 9
|
18961 | };
|
18962 |
|
18963 | var STYLENAME = {
|
18964 | 'dot': STYLE.DOT,
|
18965 | 'dot-line': STYLE.DOTLINE,
|
18966 | 'dot-color': STYLE.DOTCOLOR,
|
18967 | 'dot-size': STYLE.DOTSIZE,
|
18968 | 'line': STYLE.LINE,
|
18969 | 'grid': STYLE.GRID,
|
18970 | 'surface': STYLE.SURFACE,
|
18971 | 'bar': STYLE.BAR,
|
18972 | 'bar-color': STYLE.BARCOLOR,
|
18973 | 'bar-size': STYLE.BARSIZE
|
18974 | };
|
18975 |
|
18976 |
|
18977 |
|
18978 |
|
18979 |
|
18980 |
|
18981 |
|
18982 | var OPTIONKEYS = ['width', 'height', 'filterLabel', 'legendLabel', 'xLabel', 'yLabel', 'zLabel', 'xValueLabel', 'yValueLabel', 'zValueLabel', 'showXAxis', 'showYAxis', 'showZAxis', 'showGrid', 'showPerspective', 'showShadow', 'keepAspectRatio', 'rotateAxisLabels', 'verticalRatio', 'dotSizeRatio', 'dotSizeMinFraction', 'dotSizeMaxFraction', 'showAnimationControls', 'animationInterval', 'animationPreload', 'animationAutoStart', 'axisColor', 'axisFontSize', 'axisFontType', 'gridColor', 'xCenter', 'yCenter', 'zoomable', 'tooltipDelay', 'ctrlToZoom'];
|
18983 |
|
18984 |
|
18985 |
|
18986 |
|
18987 |
|
18988 |
|
18989 |
|
18990 | var PREFIXEDOPTIONKEYS = ['xBarWidth', 'yBarWidth', 'valueMin', 'valueMax', 'xMin', 'xMax', 'xStep', 'yMin', 'yMax', 'yStep', 'zMin', 'zMax', 'zStep'];
|
18991 |
|
18992 | var DEFAULTS = undefined;
|
18993 |
|
18994 |
|
18995 |
|
18996 |
|
18997 |
|
18998 |
|
18999 |
|
19000 |
|
19001 |
|
19002 | function isEmpty(obj) {
|
19003 | for (var prop in obj) {
|
19004 | if (obj.hasOwnProperty(prop)) return false;
|
19005 | }
|
19006 |
|
19007 | return true;
|
19008 | }
|
19009 |
|
19010 |
|
19011 |
|
19012 |
|
19013 |
|
19014 |
|
19015 |
|
19016 |
|
19017 |
|
19018 |
|
19019 | function capitalize(str) {
|
19020 | if (str === undefined || str === "" || typeof str != "string") {
|
19021 | return str;
|
19022 | }
|
19023 |
|
19024 | return str.charAt(0).toUpperCase() + str.slice(1);
|
19025 | }
|
19026 |
|
19027 |
|
19028 |
|
19029 |
|
19030 |
|
19031 |
|
19032 |
|
19033 |
|
19034 |
|
19035 | function prefixFieldName(prefix, fieldName) {
|
19036 | if (prefix === undefined || prefix === "") {
|
19037 | return fieldName;
|
19038 | }
|
19039 |
|
19040 | return prefix + capitalize(fieldName);
|
19041 | }
|
19042 |
|
19043 |
|
19044 |
|
19045 |
|
19046 |
|
19047 |
|
19048 |
|
19049 |
|
19050 |
|
19051 |
|
19052 |
|
19053 |
|
19054 |
|
19055 |
|
19056 |
|
19057 |
|
19058 |
|
19059 |
|
19060 | function forceCopy(src, dst, fields, prefix) {
|
19061 | var srcKey;
|
19062 | var dstKey;
|
19063 |
|
19064 | for (var i = 0; i < fields.length; ++i) {
|
19065 | srcKey = fields[i];
|
19066 | dstKey = prefixFieldName(prefix, srcKey);
|
19067 | dst[dstKey] = src[srcKey];
|
19068 | }
|
19069 | }
|
19070 |
|
19071 |
|
19072 |
|
19073 |
|
19074 |
|
19075 |
|
19076 |
|
19077 |
|
19078 |
|
19079 |
|
19080 |
|
19081 |
|
19082 |
|
19083 | function safeCopy(src, dst, fields, prefix) {
|
19084 | var srcKey;
|
19085 | var dstKey;
|
19086 |
|
19087 | for (var i = 0; i < fields.length; ++i) {
|
19088 | srcKey = fields[i];
|
19089 | if (src[srcKey] === undefined) continue;
|
19090 | dstKey = prefixFieldName(prefix, srcKey);
|
19091 | dst[dstKey] = src[srcKey];
|
19092 | }
|
19093 | }
|
19094 |
|
19095 |
|
19096 |
|
19097 |
|
19098 |
|
19099 |
|
19100 |
|
19101 |
|
19102 |
|
19103 |
|
19104 |
|
19105 |
|
19106 |
|
19107 | function setDefaults(src, dst) {
|
19108 | if (src === undefined || isEmpty(src)) {
|
19109 | throw new Error('No DEFAULTS passed');
|
19110 | }
|
19111 |
|
19112 | if (dst === undefined) {
|
19113 | throw new Error('No dst passed');
|
19114 | }
|
19115 |
|
19116 |
|
19117 | DEFAULTS = src;
|
19118 |
|
19119 | forceCopy(src, dst, OPTIONKEYS);
|
19120 | forceCopy(src, dst, PREFIXEDOPTIONKEYS, 'default');
|
19121 |
|
19122 | setSpecialSettings(src, dst);
|
19123 |
|
19124 | dst.margin = 10;
|
19125 |
|
19126 | dst.showGrayBottom = false;
|
19127 |
|
19128 | dst.showTooltip = false;
|
19129 | dst.onclick_callback = null;
|
19130 | dst.eye = new Point3d_1(0, 0, -1);
|
19131 | }
|
19132 |
|
19133 |
|
19134 |
|
19135 |
|
19136 |
|
19137 |
|
19138 |
|
19139 | function setOptions(options, dst) {
|
19140 | if (options === undefined) {
|
19141 | return;
|
19142 | }
|
19143 |
|
19144 | if (dst === undefined) {
|
19145 | throw new Error('No dst passed');
|
19146 | }
|
19147 |
|
19148 | if (DEFAULTS === undefined || isEmpty(DEFAULTS)) {
|
19149 | throw new Error('DEFAULTS not set for module Settings');
|
19150 | }
|
19151 |
|
19152 |
|
19153 | safeCopy(options, dst, OPTIONKEYS);
|
19154 | safeCopy(options, dst, PREFIXEDOPTIONKEYS, 'default');
|
19155 |
|
19156 | setSpecialSettings(options, dst);
|
19157 | }
|
19158 |
|
19159 |
|
19160 |
|
19161 |
|
19162 |
|
19163 |
|
19164 |
|
19165 |
|
19166 |
|
19167 |
|
19168 | function setSpecialSettings(src, dst) {
|
19169 | if (src.backgroundColor !== undefined) {
|
19170 | setBackgroundColor(src.backgroundColor, dst);
|
19171 | }
|
19172 |
|
19173 | setDataColor(src.dataColor, dst);
|
19174 | setStyle(src.style, dst);
|
19175 | setShowLegend(src.showLegend, dst);
|
19176 | setCameraPosition(src.cameraPosition, dst);
|
19177 |
|
19178 |
|
19179 | if (src.tooltip !== undefined) {
|
19180 | dst.showTooltip = src.tooltip;
|
19181 | }
|
19182 |
|
19183 | if (src.onclick != undefined) {
|
19184 | dst.onclick_callback = src.onclick;
|
19185 | }
|
19186 |
|
19187 | if (src.tooltipStyle !== undefined) {
|
19188 | util.selectiveDeepExtend(['tooltipStyle'], dst, src);
|
19189 | }
|
19190 | }
|
19191 |
|
19192 |
|
19193 |
|
19194 |
|
19195 |
|
19196 |
|
19197 |
|
19198 |
|
19199 |
|
19200 |
|
19201 |
|
19202 | function setShowLegend(showLegend, dst) {
|
19203 | if (showLegend === undefined) {
|
19204 |
|
19205 | var isAutoByDefault = DEFAULTS.showLegend === undefined;
|
19206 |
|
19207 | if (isAutoByDefault) {
|
19208 |
|
19209 | var isLegendGraphStyle = dst.style === STYLE.DOTCOLOR || dst.style === STYLE.DOTSIZE;
|
19210 | dst.showLegend = isLegendGraphStyle;
|
19211 | }
|
19212 | } else {
|
19213 | dst.showLegend = showLegend;
|
19214 | }
|
19215 | }
|
19216 |
|
19217 |
|
19218 |
|
19219 |
|
19220 |
|
19221 |
|
19222 |
|
19223 |
|
19224 | function getStyleNumberByName(styleName) {
|
19225 | var number = STYLENAME[styleName];
|
19226 |
|
19227 | if (number === undefined) {
|
19228 | return -1;
|
19229 | }
|
19230 |
|
19231 | return number;
|
19232 | }
|
19233 |
|
19234 |
|
19235 |
|
19236 |
|
19237 |
|
19238 |
|
19239 |
|
19240 |
|
19241 | function checkStyleNumber(style) {
|
19242 | var valid = false;
|
19243 |
|
19244 | for (var n in STYLE) {
|
19245 | if (STYLE[n] === style) {
|
19246 | valid = true;
|
19247 | break;
|
19248 | }
|
19249 | }
|
19250 |
|
19251 | return valid;
|
19252 | }
|
19253 |
|
19254 |
|
19255 |
|
19256 |
|
19257 |
|
19258 |
|
19259 |
|
19260 | function setStyle(style, dst) {
|
19261 | if (style === undefined) {
|
19262 | return;
|
19263 | }
|
19264 |
|
19265 | var styleNumber;
|
19266 |
|
19267 | if (typeof style === 'string') {
|
19268 | styleNumber = getStyleNumberByName(style);
|
19269 |
|
19270 | if (styleNumber === -1) {
|
19271 | throw new Error('Style \'' + style + '\' is invalid');
|
19272 | }
|
19273 | } else {
|
19274 |
|
19275 | if (!checkStyleNumber(style)) {
|
19276 | throw new Error('Style \'' + style + '\' is invalid');
|
19277 | }
|
19278 |
|
19279 | styleNumber = style;
|
19280 | }
|
19281 |
|
19282 | dst.style = styleNumber;
|
19283 | }
|
19284 |
|
19285 |
|
19286 |
|
19287 |
|
19288 |
|
19289 |
|
19290 |
|
19291 | function setBackgroundColor(backgroundColor, dst) {
|
19292 | var fill = 'white';
|
19293 | var stroke = 'gray';
|
19294 | var strokeWidth = 1;
|
19295 |
|
19296 | if (typeof backgroundColor === 'string') {
|
19297 | fill = backgroundColor;
|
19298 | stroke = 'none';
|
19299 | strokeWidth = 0;
|
19300 | } else if (_typeof$2(backgroundColor) === 'object') {
|
19301 | if (backgroundColor.fill !== undefined) fill = backgroundColor.fill;
|
19302 | if (backgroundColor.stroke !== undefined) stroke = backgroundColor.stroke;
|
19303 | if (backgroundColor.strokeWidth !== undefined) strokeWidth = backgroundColor.strokeWidth;
|
19304 | } else {
|
19305 | throw new Error('Unsupported type of backgroundColor');
|
19306 | }
|
19307 |
|
19308 | dst.frame.style.backgroundColor = fill;
|
19309 | dst.frame.style.borderColor = stroke;
|
19310 | dst.frame.style.borderWidth = strokeWidth + 'px';
|
19311 | dst.frame.style.borderStyle = 'solid';
|
19312 | }
|
19313 |
|
19314 |
|
19315 |
|
19316 |
|
19317 |
|
19318 |
|
19319 |
|
19320 | function setDataColor(dataColor, dst) {
|
19321 | if (dataColor === undefined) {
|
19322 | return;
|
19323 | }
|
19324 |
|
19325 | if (dst.dataColor === undefined) {
|
19326 | dst.dataColor = {};
|
19327 | }
|
19328 |
|
19329 | if (typeof dataColor === 'string') {
|
19330 | dst.dataColor.fill = dataColor;
|
19331 | dst.dataColor.stroke = dataColor;
|
19332 | } else {
|
19333 | if (dataColor.fill) {
|
19334 | dst.dataColor.fill = dataColor.fill;
|
19335 | }
|
19336 |
|
19337 | if (dataColor.stroke) {
|
19338 | dst.dataColor.stroke = dataColor.stroke;
|
19339 | }
|
19340 |
|
19341 | if (dataColor.strokeWidth !== undefined) {
|
19342 | dst.dataColor.strokeWidth = dataColor.strokeWidth;
|
19343 | }
|
19344 | }
|
19345 | }
|
19346 |
|
19347 |
|
19348 |
|
19349 |
|
19350 |
|
19351 |
|
19352 |
|
19353 | function setCameraPosition(cameraPosition, dst) {
|
19354 | var camPos = cameraPosition;
|
19355 |
|
19356 | if (camPos === undefined) {
|
19357 | return;
|
19358 | }
|
19359 |
|
19360 | if (dst.camera === undefined) {
|
19361 | dst.camera = new Camera_1();
|
19362 | }
|
19363 |
|
19364 | dst.camera.setArmRotation(camPos.horizontal, camPos.vertical);
|
19365 | dst.camera.setArmLength(camPos.distance);
|
19366 | }
|
19367 |
|
19368 | var STYLE_1 = STYLE;
|
19369 | var setDefaults_1 = setDefaults;
|
19370 | var setOptions_1 = setOptions;
|
19371 | var setCameraPosition_1 = setCameraPosition;
|
19372 | var Settings = {
|
19373 | STYLE: STYLE_1,
|
19374 | setDefaults: setDefaults_1,
|
19375 | setOptions: setOptions_1,
|
19376 | setCameraPosition: setCameraPosition_1
|
19377 | };
|
19378 |
|
19379 | var errorFound = false;
|
19380 | var allOptions;
|
19381 | var printStyle = 'background: #FFeeee; color: #dd0000';
|
19382 |
|
19383 |
|
19384 |
|
19385 |
|
19386 | var Validator =
|
19387 |
|
19388 | function () {
|
19389 | |
19390 |
|
19391 |
|
19392 | function Validator() {
|
19393 | _classCallCheck$1(this, Validator);
|
19394 | }
|
19395 | |
19396 |
|
19397 |
|
19398 |
|
19399 |
|
19400 |
|
19401 |
|
19402 |
|
19403 |
|
19404 |
|
19405 | _createClass$1(Validator, null, [{
|
19406 | key: "validate",
|
19407 | value: function validate(options, referenceOptions, subObject) {
|
19408 | errorFound = false;
|
19409 | allOptions = referenceOptions;
|
19410 | var usedOptions = referenceOptions;
|
19411 |
|
19412 | if (subObject !== undefined) {
|
19413 | usedOptions = referenceOptions[subObject];
|
19414 | }
|
19415 |
|
19416 | Validator.parse(options, usedOptions, []);
|
19417 | return errorFound;
|
19418 | }
|
19419 | |
19420 |
|
19421 |
|
19422 |
|
19423 |
|
19424 |
|
19425 |
|
19426 |
|
19427 | }, {
|
19428 | key: "parse",
|
19429 | value: function parse(options, referenceOptions, path) {
|
19430 | for (var option in options) {
|
19431 | if (options.hasOwnProperty(option)) {
|
19432 | Validator.check(option, options, referenceOptions, path);
|
19433 | }
|
19434 | }
|
19435 | }
|
19436 | |
19437 |
|
19438 |
|
19439 |
|
19440 |
|
19441 |
|
19442 |
|
19443 |
|
19444 |
|
19445 | }, {
|
19446 | key: "check",
|
19447 | value: function check(option, options, referenceOptions, path) {
|
19448 | if (referenceOptions[option] === undefined && referenceOptions.__any__ === undefined) {
|
19449 | Validator.getSuggestion(option, referenceOptions, path);
|
19450 | return;
|
19451 | }
|
19452 |
|
19453 | var referenceOption = option;
|
19454 | var is_object = true;
|
19455 |
|
19456 | if (referenceOptions[option] === undefined && referenceOptions.__any__ !== undefined) {
|
19457 |
|
19458 |
|
19459 |
|
19460 |
|
19461 | referenceOption = '__any__';
|
19462 |
|
19463 |
|
19464 | is_object = Validator.getType(options[option]) === 'object';
|
19465 | }
|
19466 |
|
19467 | var refOptionObj = referenceOptions[referenceOption];
|
19468 |
|
19469 | if (is_object && refOptionObj.__type__ !== undefined) {
|
19470 | refOptionObj = refOptionObj.__type__;
|
19471 | }
|
19472 |
|
19473 | Validator.checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path);
|
19474 | }
|
19475 | |
19476 |
|
19477 |
|
19478 |
|
19479 |
|
19480 |
|
19481 |
|
19482 |
|
19483 |
|
19484 |
|
19485 |
|
19486 | }, {
|
19487 | key: "checkFields",
|
19488 | value: function checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path) {
|
19489 | var log = function log(message) {
|
19490 | console.log('%c' + message + Validator.printLocation(path, option), printStyle);
|
19491 | };
|
19492 |
|
19493 | var optionType = Validator.getType(options[option]);
|
19494 | var refOptionType = refOptionObj[optionType];
|
19495 |
|
19496 | if (refOptionType !== undefined) {
|
19497 |
|
19498 | if (Validator.getType(refOptionType) === 'array' && refOptionType.indexOf(options[option]) === -1) {
|
19499 | log('Invalid option detected in "' + option + '".' + ' Allowed values are:' + Validator.print(refOptionType) + ' not "' + options[option] + '". ');
|
19500 | errorFound = true;
|
19501 | } else if (optionType === 'object' && referenceOption !== "__any__") {
|
19502 | path = util.copyAndExtendArray(path, option);
|
19503 | Validator.parse(options[option], referenceOptions[referenceOption], path);
|
19504 | }
|
19505 | } else if (refOptionObj['any'] === undefined) {
|
19506 |
|
19507 | log('Invalid type received for "' + option + '". Expected: ' + Validator.print(Object.keys(refOptionObj)) + '. Received [' + optionType + '] "' + options[option] + '"');
|
19508 | errorFound = true;
|
19509 | }
|
19510 | }
|
19511 | |
19512 |
|
19513 |
|
19514 |
|
19515 |
|
19516 |
|
19517 |
|
19518 | }, {
|
19519 | key: "getType",
|
19520 | value: function getType(object) {
|
19521 | var type = _typeof$2(object);
|
19522 |
|
19523 | if (type === 'object') {
|
19524 | if (object === null) {
|
19525 | return 'null';
|
19526 | }
|
19527 |
|
19528 | if (object instanceof Boolean) {
|
19529 | return 'boolean';
|
19530 | }
|
19531 |
|
19532 | if (object instanceof Number) {
|
19533 | return 'number';
|
19534 | }
|
19535 |
|
19536 | if (object instanceof String) {
|
19537 | return 'string';
|
19538 | }
|
19539 |
|
19540 | if (Array.isArray(object)) {
|
19541 | return 'array';
|
19542 | }
|
19543 |
|
19544 | if (object instanceof Date) {
|
19545 | return 'date';
|
19546 | }
|
19547 |
|
19548 | if (object.nodeType !== undefined) {
|
19549 | return 'dom';
|
19550 | }
|
19551 |
|
19552 | if (object._isAMomentObject === true) {
|
19553 | return 'moment';
|
19554 | }
|
19555 |
|
19556 | return 'object';
|
19557 | } else if (type === 'number') {
|
19558 | return 'number';
|
19559 | } else if (type === 'boolean') {
|
19560 | return 'boolean';
|
19561 | } else if (type === 'string') {
|
19562 | return 'string';
|
19563 | } else if (type === undefined) {
|
19564 | return 'undefined';
|
19565 | }
|
19566 |
|
19567 | return type;
|
19568 | }
|
19569 | |
19570 |
|
19571 |
|
19572 |
|
19573 |
|
19574 |
|
19575 |
|
19576 | }, {
|
19577 | key: "getSuggestion",
|
19578 | value: function getSuggestion(option, options, path) {
|
19579 | var localSearch = Validator.findInOptions(option, options, path, false);
|
19580 | var globalSearch = Validator.findInOptions(option, allOptions, [], true);
|
19581 | var localSearchThreshold = 8;
|
19582 | var globalSearchThreshold = 4;
|
19583 | var msg;
|
19584 |
|
19585 | if (localSearch.indexMatch !== undefined) {
|
19586 | msg = ' in ' + Validator.printLocation(localSearch.path, option, '') + 'Perhaps it was incomplete? Did you mean: "' + localSearch.indexMatch + '"?\n\n';
|
19587 | } else if (globalSearch.distance <= globalSearchThreshold && localSearch.distance > globalSearch.distance) {
|
19588 | msg = ' in ' + Validator.printLocation(localSearch.path, option, '') + 'Perhaps it was misplaced? Matching option found at: ' + Validator.printLocation(globalSearch.path, globalSearch.closestMatch, '');
|
19589 | } else if (localSearch.distance <= localSearchThreshold) {
|
19590 | msg = '. Did you mean "' + localSearch.closestMatch + '"?' + Validator.printLocation(localSearch.path, option);
|
19591 | } else {
|
19592 | msg = '. Did you mean one of these: ' + Validator.print(Object.keys(options)) + Validator.printLocation(path, option);
|
19593 | }
|
19594 |
|
19595 | console.log('%cUnknown option detected: "' + option + '"' + msg, printStyle);
|
19596 | errorFound = true;
|
19597 | }
|
19598 | |
19599 |
|
19600 |
|
19601 |
|
19602 |
|
19603 |
|
19604 |
|
19605 |
|
19606 |
|
19607 |
|
19608 | }, {
|
19609 | key: "findInOptions",
|
19610 | value: function findInOptions(option, options, path) {
|
19611 | var recursive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
19612 | var min = 1e9;
|
19613 | var closestMatch = '';
|
19614 | var closestMatchPath = [];
|
19615 | var lowerCaseOption = option.toLowerCase();
|
19616 | var indexMatch = undefined;
|
19617 |
|
19618 | for (var op in options) {
|
19619 |
|
19620 | var distance = void 0;
|
19621 |
|
19622 | if (options[op].__type__ !== undefined && recursive === true) {
|
19623 | var result = Validator.findInOptions(option, options[op], util.copyAndExtendArray(path, op));
|
19624 |
|
19625 | if (min > result.distance) {
|
19626 | closestMatch = result.closestMatch;
|
19627 | closestMatchPath = result.path;
|
19628 | min = result.distance;
|
19629 | indexMatch = result.indexMatch;
|
19630 | }
|
19631 | } else {
|
19632 | if (op.toLowerCase().indexOf(lowerCaseOption) !== -1) {
|
19633 | indexMatch = op;
|
19634 | }
|
19635 |
|
19636 | distance = Validator.levenshteinDistance(option, op);
|
19637 |
|
19638 | if (min > distance) {
|
19639 | closestMatch = op;
|
19640 | closestMatchPath = util.copyArray(path);
|
19641 | min = distance;
|
19642 | }
|
19643 | }
|
19644 | }
|
19645 |
|
19646 | return {
|
19647 | closestMatch: closestMatch,
|
19648 | path: closestMatchPath,
|
19649 | distance: min,
|
19650 | indexMatch: indexMatch
|
19651 | };
|
19652 | }
|
19653 | |
19654 |
|
19655 |
|
19656 |
|
19657 |
|
19658 |
|
19659 |
|
19660 |
|
19661 | }, {
|
19662 | key: "printLocation",
|
19663 | value: function printLocation(path, option) {
|
19664 | var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Problem value found at: \n';
|
19665 | var str = '\n\n' + prefix + 'options = {\n';
|
19666 |
|
19667 | for (var i = 0; i < path.length; i++) {
|
19668 | for (var j = 0; j < i + 1; j++) {
|
19669 | str += ' ';
|
19670 | }
|
19671 |
|
19672 | str += path[i] + ': {\n';
|
19673 | }
|
19674 |
|
19675 | for (var _j = 0; _j < path.length + 1; _j++) {
|
19676 | str += ' ';
|
19677 | }
|
19678 |
|
19679 | str += option + '\n';
|
19680 |
|
19681 | for (var _i = 0; _i < path.length + 1; _i++) {
|
19682 | for (var _j2 = 0; _j2 < path.length - _i; _j2++) {
|
19683 | str += ' ';
|
19684 | }
|
19685 |
|
19686 | str += '}\n';
|
19687 | }
|
19688 |
|
19689 | return str + '\n\n';
|
19690 | }
|
19691 | |
19692 |
|
19693 |
|
19694 |
|
19695 |
|
19696 |
|
19697 | }, {
|
19698 | key: "print",
|
19699 | value: function print(options) {
|
19700 | return JSON.stringify(options).replace(/(\")|(\[)|(\])|(,"__type__")/g, "").replace(/(\,)/g, ', ');
|
19701 | }
|
19702 | |
19703 |
|
19704 |
|
19705 |
|
19706 |
|
19707 |
|
19708 |
|
19709 |
|
19710 |
|
19711 |
|
19712 |
|
19713 |
|
19714 |
|
19715 |
|
19716 |
|
19717 |
|
19718 |
|
19719 |
|
19720 | }, {
|
19721 | key: "levenshteinDistance",
|
19722 | value: function levenshteinDistance(a, b) {
|
19723 | if (a.length === 0) return b.length;
|
19724 | if (b.length === 0) return a.length;
|
19725 | var matrix = [];
|
19726 |
|
19727 | var i;
|
19728 |
|
19729 | for (i = 0; i <= b.length; i++) {
|
19730 | matrix[i] = [i];
|
19731 | }
|
19732 |
|
19733 |
|
19734 | var j;
|
19735 |
|
19736 | for (j = 0; j <= a.length; j++) {
|
19737 | matrix[0][j] = j;
|
19738 | }
|
19739 |
|
19740 |
|
19741 | for (i = 1; i <= b.length; i++) {
|
19742 | for (j = 1; j <= a.length; j++) {
|
19743 | if (b.charAt(i - 1) == a.charAt(j - 1)) {
|
19744 | matrix[i][j] = matrix[i - 1][j - 1];
|
19745 | } else {
|
19746 | matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1,
|
19747 | Math.min(matrix[i][j - 1] + 1,
|
19748 | matrix[i - 1][j] + 1));
|
19749 | }
|
19750 | }
|
19751 | }
|
19752 |
|
19753 | return matrix[b.length][a.length];
|
19754 | }
|
19755 | }]);
|
19756 |
|
19757 | return Validator;
|
19758 | }();
|
19759 |
|
19760 | var Validator$1 = Object.freeze({
|
19761 | Validator: Validator,
|
19762 | printStyle: printStyle
|
19763 | });
|
19764 |
|
19765 |
|
19766 |
|
19767 |
|
19768 |
|
19769 |
|
19770 |
|
19771 |
|
19772 | var string = 'string';
|
19773 | var bool = 'boolean';
|
19774 | var number = 'number';
|
19775 | var object = 'object';
|
19776 |
|
19777 |
|
19778 |
|
19779 |
|
19780 |
|
19781 | var colorOptions = {
|
19782 | fill: {
|
19783 | string: string
|
19784 | },
|
19785 | stroke: {
|
19786 | string: string
|
19787 | },
|
19788 | strokeWidth: {
|
19789 | number: number
|
19790 | },
|
19791 | __type__: {
|
19792 | string: string,
|
19793 | object: object,
|
19794 | 'undefined': 'undefined'
|
19795 | }
|
19796 | };
|
19797 |
|
19798 |
|
19799 |
|
19800 |
|
19801 |
|
19802 |
|
19803 |
|
19804 | var allOptions$1 = {
|
19805 | animationAutoStart: {
|
19806 | boolean: bool,
|
19807 | 'undefined': 'undefined'
|
19808 | },
|
19809 | animationInterval: {
|
19810 | number: number
|
19811 | },
|
19812 | animationPreload: {
|
19813 | boolean: bool
|
19814 | },
|
19815 | axisColor: {
|
19816 | string: string
|
19817 | },
|
19818 | axisFontSize: {
|
19819 | number: number
|
19820 | },
|
19821 | axisFontType: {
|
19822 | string: string
|
19823 | },
|
19824 | backgroundColor: colorOptions,
|
19825 | xBarWidth: {
|
19826 | number: number,
|
19827 | 'undefined': 'undefined'
|
19828 | },
|
19829 | yBarWidth: {
|
19830 | number: number,
|
19831 | 'undefined': 'undefined'
|
19832 | },
|
19833 | cameraPosition: {
|
19834 | distance: {
|
19835 | number: number
|
19836 | },
|
19837 | horizontal: {
|
19838 | number: number
|
19839 | },
|
19840 | vertical: {
|
19841 | number: number
|
19842 | },
|
19843 | __type__: {
|
19844 | object: object
|
19845 | }
|
19846 | },
|
19847 | zoomable: {
|
19848 | boolean: bool
|
19849 | },
|
19850 | ctrlToZoom: {
|
19851 | boolean: bool
|
19852 | },
|
19853 | xCenter: {
|
19854 | string: string
|
19855 | },
|
19856 | yCenter: {
|
19857 | string: string
|
19858 | },
|
19859 | dataColor: colorOptions,
|
19860 | dotSizeMinFraction: {
|
19861 | number: number
|
19862 | },
|
19863 | dotSizeMaxFraction: {
|
19864 | number: number
|
19865 | },
|
19866 | dotSizeRatio: {
|
19867 | number: number
|
19868 | },
|
19869 | filterLabel: {
|
19870 | string: string
|
19871 | },
|
19872 | gridColor: {
|
19873 | string: string
|
19874 | },
|
19875 | onclick: {
|
19876 | 'function': 'function'
|
19877 | },
|
19878 | keepAspectRatio: {
|
19879 | boolean: bool
|
19880 | },
|
19881 | xLabel: {
|
19882 | string: string
|
19883 | },
|
19884 | yLabel: {
|
19885 | string: string
|
19886 | },
|
19887 | zLabel: {
|
19888 | string: string
|
19889 | },
|
19890 | legendLabel: {
|
19891 | string: string
|
19892 | },
|
19893 | xMin: {
|
19894 | number: number,
|
19895 | 'undefined': 'undefined'
|
19896 | },
|
19897 | yMin: {
|
19898 | number: number,
|
19899 | 'undefined': 'undefined'
|
19900 | },
|
19901 | zMin: {
|
19902 | number: number,
|
19903 | 'undefined': 'undefined'
|
19904 | },
|
19905 | xMax: {
|
19906 | number: number,
|
19907 | 'undefined': 'undefined'
|
19908 | },
|
19909 | yMax: {
|
19910 | number: number,
|
19911 | 'undefined': 'undefined'
|
19912 | },
|
19913 | zMax: {
|
19914 | number: number,
|
19915 | 'undefined': 'undefined'
|
19916 | },
|
19917 | showAnimationControls: {
|
19918 | boolean: bool,
|
19919 | 'undefined': 'undefined'
|
19920 | },
|
19921 | showGrid: {
|
19922 | boolean: bool
|
19923 | },
|
19924 | showLegend: {
|
19925 | boolean: bool,
|
19926 | 'undefined': 'undefined'
|
19927 | },
|
19928 | showPerspective: {
|
19929 | boolean: bool
|
19930 | },
|
19931 | showShadow: {
|
19932 | boolean: bool
|
19933 | },
|
19934 | showXAxis: {
|
19935 | boolean: bool
|
19936 | },
|
19937 | showYAxis: {
|
19938 | boolean: bool
|
19939 | },
|
19940 | showZAxis: {
|
19941 | boolean: bool
|
19942 | },
|
19943 | rotateAxisLabels: {
|
19944 | boolean: bool
|
19945 | },
|
19946 | xStep: {
|
19947 | number: number,
|
19948 | 'undefined': 'undefined'
|
19949 | },
|
19950 | yStep: {
|
19951 | number: number,
|
19952 | 'undefined': 'undefined'
|
19953 | },
|
19954 | zStep: {
|
19955 | number: number,
|
19956 | 'undefined': 'undefined'
|
19957 | },
|
19958 | style: {
|
19959 | number: number,
|
19960 |
|
19961 | string: ['bar', 'bar-color', 'bar-size', 'dot', 'dot-line', 'dot-color', 'dot-size', 'line', 'grid', 'surface']
|
19962 | },
|
19963 | tooltip: {
|
19964 | boolean: bool,
|
19965 | 'function': 'function'
|
19966 | },
|
19967 | tooltipDelay: {
|
19968 | number: number
|
19969 | },
|
19970 | tooltipStyle: {
|
19971 | content: {
|
19972 | color: {
|
19973 | string: string
|
19974 | },
|
19975 | background: {
|
19976 | string: string
|
19977 | },
|
19978 | border: {
|
19979 | string: string
|
19980 | },
|
19981 | borderRadius: {
|
19982 | string: string
|
19983 | },
|
19984 | boxShadow: {
|
19985 | string: string
|
19986 | },
|
19987 | padding: {
|
19988 | string: string
|
19989 | },
|
19990 | __type__: {
|
19991 | object: object
|
19992 | }
|
19993 | },
|
19994 | line: {
|
19995 | borderLeft: {
|
19996 | string: string
|
19997 | },
|
19998 | height: {
|
19999 | string: string
|
20000 | },
|
20001 | width: {
|
20002 | string: string
|
20003 | },
|
20004 | pointerEvents: {
|
20005 | string: string
|
20006 | },
|
20007 | __type__: {
|
20008 | object: object
|
20009 | }
|
20010 | },
|
20011 | dot: {
|
20012 | border: {
|
20013 | string: string
|
20014 | },
|
20015 | borderRadius: {
|
20016 | string: string
|
20017 | },
|
20018 | height: {
|
20019 | string: string
|
20020 | },
|
20021 | width: {
|
20022 | string: string
|
20023 | },
|
20024 | pointerEvents: {
|
20025 | string: string
|
20026 | },
|
20027 | __type__: {
|
20028 | object: object
|
20029 | }
|
20030 | },
|
20031 | __type__: {
|
20032 | object: object
|
20033 | }
|
20034 | },
|
20035 | xValueLabel: {
|
20036 | 'function': 'function'
|
20037 | },
|
20038 | yValueLabel: {
|
20039 | 'function': 'function'
|
20040 | },
|
20041 | zValueLabel: {
|
20042 | 'function': 'function'
|
20043 | },
|
20044 | valueMax: {
|
20045 | number: number,
|
20046 | 'undefined': 'undefined'
|
20047 | },
|
20048 | valueMin: {
|
20049 | number: number,
|
20050 | 'undefined': 'undefined'
|
20051 | },
|
20052 | verticalRatio: {
|
20053 | number: number
|
20054 | },
|
20055 |
|
20056 | height: {
|
20057 | string: string
|
20058 | },
|
20059 | width: {
|
20060 | string: string
|
20061 | },
|
20062 | __type__: {
|
20063 | object: object
|
20064 | }
|
20065 | };
|
20066 |
|
20067 | var options = Object.freeze({
|
20068 | allOptions: allOptions$1
|
20069 | });
|
20070 |
|
20071 |
|
20072 |
|
20073 |
|
20074 |
|
20075 |
|
20076 |
|
20077 |
|
20078 |
|
20079 |
|
20080 | function Range() {
|
20081 | this.min = undefined;
|
20082 | this.max = undefined;
|
20083 | }
|
20084 |
|
20085 |
|
20086 |
|
20087 |
|
20088 |
|
20089 |
|
20090 |
|
20091 |
|
20092 |
|
20093 |
|
20094 | Range.prototype.adjust = function (value) {
|
20095 | if (value === undefined) return;
|
20096 |
|
20097 | if (this.min === undefined || this.min > value) {
|
20098 | this.min = value;
|
20099 | }
|
20100 |
|
20101 | if (this.max === undefined || this.max < value) {
|
20102 | this.max = value;
|
20103 | }
|
20104 | };
|
20105 |
|
20106 |
|
20107 |
|
20108 |
|
20109 |
|
20110 |
|
20111 |
|
20112 | Range.prototype.combine = function (range) {
|
20113 | this.add(range.min);
|
20114 | this.add(range.max);
|
20115 | };
|
20116 |
|
20117 |
|
20118 |
|
20119 |
|
20120 |
|
20121 |
|
20122 |
|
20123 |
|
20124 |
|
20125 |
|
20126 |
|
20127 |
|
20128 | Range.prototype.expand = function (val) {
|
20129 | if (val === undefined) {
|
20130 | return;
|
20131 | }
|
20132 |
|
20133 | var newMin = this.min - val;
|
20134 | var newMax = this.max + val;
|
20135 |
|
20136 |
|
20137 | if (newMin > newMax) {
|
20138 | throw new Error('Passed expansion value makes range invalid');
|
20139 | }
|
20140 |
|
20141 | this.min = newMin;
|
20142 | this.max = newMax;
|
20143 | };
|
20144 |
|
20145 |
|
20146 |
|
20147 |
|
20148 |
|
20149 |
|
20150 |
|
20151 | Range.prototype.range = function () {
|
20152 | return this.max - this.min;
|
20153 | };
|
20154 |
|
20155 |
|
20156 |
|
20157 |
|
20158 |
|
20159 |
|
20160 |
|
20161 | Range.prototype.center = function () {
|
20162 | return (this.min + this.max) / 2;
|
20163 | };
|
20164 |
|
20165 | var Range_1 = Range;
|
20166 |
|
20167 | var DataView$1 = index.DataView;
|
20168 |
|
20169 |
|
20170 |
|
20171 |
|
20172 |
|
20173 |
|
20174 |
|
20175 |
|
20176 | function Filter(dataGroup, column, graph) {
|
20177 | this.dataGroup = dataGroup;
|
20178 | this.column = column;
|
20179 | this.graph = graph;
|
20180 |
|
20181 | this.index = undefined;
|
20182 | this.value = undefined;
|
20183 |
|
20184 | this.values = dataGroup.getDistinctValues(this.column);
|
20185 |
|
20186 | if (this.values.length > 0) {
|
20187 | this.selectValue(0);
|
20188 | }
|
20189 |
|
20190 |
|
20191 | this.dataPoints = [];
|
20192 | this.loaded = false;
|
20193 | this.onLoadCallback = undefined;
|
20194 |
|
20195 | if (graph.animationPreload) {
|
20196 | this.loaded = false;
|
20197 | this.loadInBackground();
|
20198 | } else {
|
20199 | this.loaded = true;
|
20200 | }
|
20201 | }
|
20202 |
|
20203 |
|
20204 |
|
20205 |
|
20206 |
|
20207 |
|
20208 | Filter.prototype.isLoaded = function () {
|
20209 | return this.loaded;
|
20210 | };
|
20211 |
|
20212 |
|
20213 |
|
20214 |
|
20215 |
|
20216 |
|
20217 | Filter.prototype.getLoadedProgress = function () {
|
20218 | var len = this.values.length;
|
20219 | var i = 0;
|
20220 |
|
20221 | while (this.dataPoints[i]) {
|
20222 | i++;
|
20223 | }
|
20224 |
|
20225 | return Math.round(i / len * 100);
|
20226 | };
|
20227 |
|
20228 |
|
20229 |
|
20230 |
|
20231 |
|
20232 |
|
20233 | Filter.prototype.getLabel = function () {
|
20234 | return this.graph.filterLabel;
|
20235 | };
|
20236 |
|
20237 |
|
20238 |
|
20239 |
|
20240 |
|
20241 |
|
20242 | Filter.prototype.getColumn = function () {
|
20243 | return this.column;
|
20244 | };
|
20245 |
|
20246 |
|
20247 |
|
20248 |
|
20249 |
|
20250 |
|
20251 | Filter.prototype.getSelectedValue = function () {
|
20252 | if (this.index === undefined) return undefined;
|
20253 | return this.values[this.index];
|
20254 | };
|
20255 |
|
20256 |
|
20257 |
|
20258 |
|
20259 |
|
20260 |
|
20261 | Filter.prototype.getValues = function () {
|
20262 | return this.values;
|
20263 | };
|
20264 |
|
20265 |
|
20266 |
|
20267 |
|
20268 |
|
20269 |
|
20270 |
|
20271 | Filter.prototype.getValue = function (index) {
|
20272 | if (index >= this.values.length) throw new Error('Index out of range');
|
20273 | return this.values[index];
|
20274 | };
|
20275 |
|
20276 |
|
20277 |
|
20278 |
|
20279 |
|
20280 |
|
20281 |
|
20282 | Filter.prototype._getDataPoints = function (index) {
|
20283 | if (index === undefined) index = this.index;
|
20284 | if (index === undefined) return [];
|
20285 | var dataPoints;
|
20286 |
|
20287 | if (this.dataPoints[index]) {
|
20288 | dataPoints = this.dataPoints[index];
|
20289 | } else {
|
20290 | var f = {};
|
20291 | f.column = this.column;
|
20292 | f.value = this.values[index];
|
20293 | var dataView = new DataView$1(this.dataGroup.getDataSet(), {
|
20294 | filter: function filter(item) {
|
20295 | return item[f.column] == f.value;
|
20296 | }
|
20297 | }).get();
|
20298 | dataPoints = this.dataGroup._getDataPoints(dataView);
|
20299 | this.dataPoints[index] = dataPoints;
|
20300 | }
|
20301 |
|
20302 | return dataPoints;
|
20303 | };
|
20304 |
|
20305 |
|
20306 |
|
20307 |
|
20308 |
|
20309 |
|
20310 |
|
20311 | Filter.prototype.setOnLoadCallback = function (callback) {
|
20312 | this.onLoadCallback = callback;
|
20313 | };
|
20314 |
|
20315 |
|
20316 |
|
20317 |
|
20318 |
|
20319 |
|
20320 |
|
20321 | Filter.prototype.selectValue = function (index) {
|
20322 | if (index >= this.values.length) throw new Error('Index out of range');
|
20323 | this.index = index;
|
20324 | this.value = this.values[index];
|
20325 | };
|
20326 |
|
20327 |
|
20328 |
|
20329 |
|
20330 |
|
20331 |
|
20332 |
|
20333 |
|
20334 | Filter.prototype.loadInBackground = function (index) {
|
20335 | if (index === undefined) index = 0;
|
20336 | var frame = this.graph.frame;
|
20337 |
|
20338 | if (index < this.values.length) {
|
20339 |
|
20340 | if (frame.progress === undefined) {
|
20341 | frame.progress = document.createElement('DIV');
|
20342 | frame.progress.style.position = 'absolute';
|
20343 | frame.progress.style.color = 'gray';
|
20344 | frame.appendChild(frame.progress);
|
20345 | }
|
20346 |
|
20347 | var progress = this.getLoadedProgress();
|
20348 | frame.progress.innerHTML = 'Loading animation... ' + progress + '%';
|
20349 |
|
20350 | frame.progress.style.bottom = 60 + 'px';
|
20351 |
|
20352 | frame.progress.style.left = 10 + 'px';
|
20353 | var me = this;
|
20354 | setTimeout(function () {
|
20355 | me.loadInBackground(index + 1);
|
20356 | }, 10);
|
20357 | this.loaded = false;
|
20358 | } else {
|
20359 | this.loaded = true;
|
20360 |
|
20361 | if (frame.progress !== undefined) {
|
20362 | frame.removeChild(frame.progress);
|
20363 | frame.progress = undefined;
|
20364 | }
|
20365 |
|
20366 | if (this.onLoadCallback) this.onLoadCallback();
|
20367 | }
|
20368 | };
|
20369 |
|
20370 | var Filter_1 = Filter;
|
20371 |
|
20372 | var DataSet$1 = index.DataSet;
|
20373 | var DataView$2 = index.DataView;
|
20374 |
|
20375 |
|
20376 |
|
20377 |
|
20378 |
|
20379 |
|
20380 |
|
20381 |
|
20382 |
|
20383 |
|
20384 |
|
20385 |
|
20386 |
|
20387 | function DataGroup() {
|
20388 | this.dataTable = null;
|
20389 | }
|
20390 |
|
20391 |
|
20392 |
|
20393 |
|
20394 |
|
20395 |
|
20396 |
|
20397 |
|
20398 |
|
20399 |
|
20400 |
|
20401 |
|
20402 |
|
20403 |
|
20404 |
|
20405 |
|
20406 |
|
20407 | DataGroup.prototype.initializeData = function (graph3d, rawData, style) {
|
20408 | if (rawData === undefined) return;
|
20409 |
|
20410 | if (Array.isArray(rawData)) {
|
20411 | rawData = new DataSet$1(rawData);
|
20412 | }
|
20413 |
|
20414 | var data;
|
20415 |
|
20416 | if (rawData instanceof DataSet$1 || rawData instanceof DataView$2) {
|
20417 | data = rawData.get();
|
20418 | } else {
|
20419 | throw new Error('Array, DataSet, or DataView expected');
|
20420 | }
|
20421 |
|
20422 | if (data.length == 0) return;
|
20423 | this.style = style;
|
20424 |
|
20425 | if (this.dataSet) {
|
20426 | this.dataSet.off('*', this._onChange);
|
20427 | }
|
20428 |
|
20429 | this.dataSet = rawData;
|
20430 | this.dataTable = data;
|
20431 |
|
20432 | var me = this;
|
20433 |
|
20434 | this._onChange = function () {
|
20435 | graph3d.setData(me.dataSet);
|
20436 | };
|
20437 |
|
20438 | this.dataSet.on('*', this._onChange);
|
20439 |
|
20440 | this.colX = 'x';
|
20441 | this.colY = 'y';
|
20442 | this.colZ = 'z';
|
20443 | var withBars = graph3d.hasBars(style);
|
20444 |
|
20445 | if (withBars) {
|
20446 | if (graph3d.defaultXBarWidth !== undefined) {
|
20447 | this.xBarWidth = graph3d.defaultXBarWidth;
|
20448 | } else {
|
20449 | this.xBarWidth = this.getSmallestDifference(data, this.colX) || 1;
|
20450 | }
|
20451 |
|
20452 | if (graph3d.defaultYBarWidth !== undefined) {
|
20453 | this.yBarWidth = graph3d.defaultYBarWidth;
|
20454 | } else {
|
20455 | this.yBarWidth = this.getSmallestDifference(data, this.colY) || 1;
|
20456 | }
|
20457 | }
|
20458 |
|
20459 |
|
20460 | this._initializeRange(data, this.colX, graph3d, withBars);
|
20461 |
|
20462 | this._initializeRange(data, this.colY, graph3d, withBars);
|
20463 |
|
20464 | this._initializeRange(data, this.colZ, graph3d, false);
|
20465 |
|
20466 | if (data[0].hasOwnProperty('style')) {
|
20467 | this.colValue = 'style';
|
20468 | var valueRange = this.getColumnRange(data, this.colValue);
|
20469 |
|
20470 | this._setRangeDefaults(valueRange, graph3d.defaultValueMin, graph3d.defaultValueMax);
|
20471 |
|
20472 | this.valueRange = valueRange;
|
20473 | }
|
20474 |
|
20475 |
|
20476 | var table = this.getDataTable();
|
20477 |
|
20478 | if (table[0].hasOwnProperty('filter')) {
|
20479 | if (this.dataFilter === undefined) {
|
20480 | this.dataFilter = new Filter_1(this, 'filter', graph3d);
|
20481 | this.dataFilter.setOnLoadCallback(function () {
|
20482 | graph3d.redraw();
|
20483 | });
|
20484 | }
|
20485 | }
|
20486 |
|
20487 | var dataPoints;
|
20488 |
|
20489 | if (this.dataFilter) {
|
20490 |
|
20491 | dataPoints = this.dataFilter._getDataPoints();
|
20492 | } else {
|
20493 |
|
20494 | dataPoints = this._getDataPoints(this.getDataTable());
|
20495 | }
|
20496 |
|
20497 | return dataPoints;
|
20498 | };
|
20499 |
|
20500 |
|
20501 |
|
20502 |
|
20503 |
|
20504 |
|
20505 |
|
20506 |
|
20507 |
|
20508 |
|
20509 |
|
20510 |
|
20511 |
|
20512 |
|
20513 |
|
20514 |
|
20515 |
|
20516 | DataGroup.prototype._collectRangeSettings = function (column, graph3d) {
|
20517 | var index = ['x', 'y', 'z'].indexOf(column);
|
20518 |
|
20519 | if (index == -1) {
|
20520 | throw new Error('Column \'' + column + '\' invalid');
|
20521 | }
|
20522 |
|
20523 | var upper = column.toUpperCase();
|
20524 | return {
|
20525 | barWidth: this[column + 'BarWidth'],
|
20526 | min: graph3d['default' + upper + 'Min'],
|
20527 | max: graph3d['default' + upper + 'Max'],
|
20528 | step: graph3d['default' + upper + 'Step'],
|
20529 | range_label: column + 'Range',
|
20530 |
|
20531 | step_label: column + 'Step'
|
20532 |
|
20533 | };
|
20534 | };
|
20535 |
|
20536 |
|
20537 |
|
20538 |
|
20539 |
|
20540 |
|
20541 |
|
20542 |
|
20543 |
|
20544 |
|
20545 |
|
20546 |
|
20547 |
|
20548 |
|
20549 |
|
20550 | DataGroup.prototype._initializeRange = function (data, column, graph3d, withBars) {
|
20551 | var NUMSTEPS = 5;
|
20552 |
|
20553 | var settings = this._collectRangeSettings(column, graph3d);
|
20554 |
|
20555 | var range = this.getColumnRange(data, column);
|
20556 |
|
20557 | if (withBars && column != 'z') {
|
20558 |
|
20559 | range.expand(settings.barWidth / 2);
|
20560 | }
|
20561 |
|
20562 | this._setRangeDefaults(range, settings.min, settings.max);
|
20563 |
|
20564 | this[settings.range_label] = range;
|
20565 | this[settings.step_label] = settings.step !== undefined ? settings.step : range.range() / NUMSTEPS;
|
20566 | };
|
20567 |
|
20568 |
|
20569 |
|
20570 |
|
20571 |
|
20572 |
|
20573 |
|
20574 |
|
20575 |
|
20576 |
|
20577 |
|
20578 |
|
20579 | DataGroup.prototype.getDistinctValues = function (column, data) {
|
20580 | if (data === undefined) {
|
20581 | data = this.dataTable;
|
20582 | }
|
20583 |
|
20584 | var values = [];
|
20585 |
|
20586 | for (var i = 0; i < data.length; i++) {
|
20587 | var value = data[i][column] || 0;
|
20588 |
|
20589 | if (values.indexOf(value) === -1) {
|
20590 | values.push(value);
|
20591 | }
|
20592 | }
|
20593 |
|
20594 | return values.sort(function (a, b) {
|
20595 | return a - b;
|
20596 | });
|
20597 | };
|
20598 |
|
20599 |
|
20600 |
|
20601 |
|
20602 |
|
20603 |
|
20604 |
|
20605 |
|
20606 |
|
20607 |
|
20608 |
|
20609 |
|
20610 | DataGroup.prototype.getSmallestDifference = function (data, column) {
|
20611 | var values = this.getDistinctValues(data, column);
|
20612 |
|
20613 |
|
20614 | var smallest_diff = null;
|
20615 |
|
20616 | for (var i = 1; i < values.length; i++) {
|
20617 | var diff = values[i] - values[i - 1];
|
20618 |
|
20619 | if (smallest_diff == null || smallest_diff > diff) {
|
20620 | smallest_diff = diff;
|
20621 | }
|
20622 | }
|
20623 |
|
20624 | return smallest_diff;
|
20625 | };
|
20626 |
|
20627 |
|
20628 |
|
20629 |
|
20630 |
|
20631 |
|
20632 |
|
20633 |
|
20634 |
|
20635 |
|
20636 | DataGroup.prototype.getColumnRange = function (data, column) {
|
20637 | var range = new Range_1();
|
20638 |
|
20639 | for (var i = 0; i < data.length; i++) {
|
20640 | var item = data[i][column];
|
20641 | range.adjust(item);
|
20642 | }
|
20643 |
|
20644 | return range;
|
20645 | };
|
20646 |
|
20647 |
|
20648 |
|
20649 |
|
20650 |
|
20651 |
|
20652 |
|
20653 | DataGroup.prototype.getNumberOfRows = function () {
|
20654 | return this.dataTable.length;
|
20655 | };
|
20656 |
|
20657 |
|
20658 |
|
20659 |
|
20660 |
|
20661 |
|
20662 |
|
20663 |
|
20664 |
|
20665 |
|
20666 |
|
20667 |
|
20668 |
|
20669 |
|
20670 |
|
20671 |
|
20672 | DataGroup.prototype._setRangeDefaults = function (range, defaultMin, defaultMax) {
|
20673 | if (defaultMin !== undefined) {
|
20674 | range.min = defaultMin;
|
20675 | }
|
20676 |
|
20677 | if (defaultMax !== undefined) {
|
20678 | range.max = defaultMax;
|
20679 | }
|
20680 |
|
20681 |
|
20682 |
|
20683 |
|
20684 | if (range.max <= range.min) range.max = range.min + 1;
|
20685 | };
|
20686 |
|
20687 | DataGroup.prototype.getDataTable = function () {
|
20688 | return this.dataTable;
|
20689 | };
|
20690 |
|
20691 | DataGroup.prototype.getDataSet = function () {
|
20692 | return this.dataSet;
|
20693 | };
|
20694 |
|
20695 |
|
20696 |
|
20697 |
|
20698 |
|
20699 |
|
20700 |
|
20701 | DataGroup.prototype.getDataPoints = function (data) {
|
20702 | var dataPoints = [];
|
20703 |
|
20704 | for (var i = 0; i < data.length; i++) {
|
20705 | var point = new Point3d_1();
|
20706 | point.x = data[i][this.colX] || 0;
|
20707 | point.y = data[i][this.colY] || 0;
|
20708 | point.z = data[i][this.colZ] || 0;
|
20709 | point.data = data[i];
|
20710 |
|
20711 | if (this.colValue !== undefined) {
|
20712 | point.value = data[i][this.colValue] || 0;
|
20713 | }
|
20714 |
|
20715 | var obj = {};
|
20716 | obj.point = point;
|
20717 | obj.bottom = new Point3d_1(point.x, point.y, this.zRange.min);
|
20718 | obj.trans = undefined;
|
20719 | obj.screen = undefined;
|
20720 | dataPoints.push(obj);
|
20721 | }
|
20722 |
|
20723 | return dataPoints;
|
20724 | };
|
20725 |
|
20726 |
|
20727 |
|
20728 |
|
20729 |
|
20730 |
|
20731 |
|
20732 |
|
20733 |
|
20734 |
|
20735 | DataGroup.prototype.initDataAsMatrix = function (data) {
|
20736 |
|
20737 |
|
20738 | var x, y, i, obj;
|
20739 |
|
20740 | var dataX = this.getDistinctValues(this.colX, data);
|
20741 | var dataY = this.getDistinctValues(this.colY, data);
|
20742 | var dataPoints = this.getDataPoints(data);
|
20743 |
|
20744 | var dataMatrix = [];
|
20745 |
|
20746 | for (i = 0; i < dataPoints.length; i++) {
|
20747 | obj = dataPoints[i];
|
20748 |
|
20749 | var xIndex = dataX.indexOf(obj.point.x);
|
20750 | var yIndex = dataY.indexOf(obj.point.y);
|
20751 |
|
20752 | if (dataMatrix[xIndex] === undefined) {
|
20753 | dataMatrix[xIndex] = [];
|
20754 | }
|
20755 |
|
20756 | dataMatrix[xIndex][yIndex] = obj;
|
20757 | }
|
20758 |
|
20759 |
|
20760 | for (x = 0; x < dataMatrix.length; x++) {
|
20761 | for (y = 0; y < dataMatrix[x].length; y++) {
|
20762 | if (dataMatrix[x][y]) {
|
20763 | dataMatrix[x][y].pointRight = x < dataMatrix.length - 1 ? dataMatrix[x + 1][y] : undefined;
|
20764 | dataMatrix[x][y].pointTop = y < dataMatrix[x].length - 1 ? dataMatrix[x][y + 1] : undefined;
|
20765 | dataMatrix[x][y].pointCross = x < dataMatrix.length - 1 && y < dataMatrix[x].length - 1 ? dataMatrix[x + 1][y + 1] : undefined;
|
20766 | }
|
20767 | }
|
20768 | }
|
20769 |
|
20770 | return dataPoints;
|
20771 | };
|
20772 |
|
20773 |
|
20774 |
|
20775 |
|
20776 |
|
20777 |
|
20778 |
|
20779 | DataGroup.prototype.getInfo = function () {
|
20780 | var dataFilter = this.dataFilter;
|
20781 | if (!dataFilter) return undefined;
|
20782 | return dataFilter.getLabel() + ': ' + dataFilter.getSelectedValue();
|
20783 | };
|
20784 |
|
20785 |
|
20786 |
|
20787 |
|
20788 |
|
20789 | DataGroup.prototype.reload = function () {
|
20790 | if (this.dataTable) {
|
20791 | this.setData(this.dataTable);
|
20792 | }
|
20793 | };
|
20794 |
|
20795 |
|
20796 |
|
20797 |
|
20798 |
|
20799 |
|
20800 |
|
20801 |
|
20802 |
|
20803 | DataGroup.prototype._getDataPoints = function (data) {
|
20804 | var dataPoints = [];
|
20805 |
|
20806 | if (this.style === Settings.STYLE.GRID || this.style === Settings.STYLE.SURFACE) {
|
20807 | dataPoints = this.initDataAsMatrix(data);
|
20808 | } else {
|
20809 |
|
20810 | this._checkValueField(data);
|
20811 |
|
20812 | dataPoints = this.getDataPoints(data);
|
20813 |
|
20814 | if (this.style === Settings.STYLE.LINE) {
|
20815 |
|
20816 | for (var i = 0; i < dataPoints.length; i++) {
|
20817 | if (i > 0) {
|
20818 | dataPoints[i - 1].pointNext = dataPoints[i];
|
20819 | }
|
20820 | }
|
20821 | }
|
20822 | }
|
20823 |
|
20824 | return dataPoints;
|
20825 | };
|
20826 |
|
20827 |
|
20828 |
|
20829 |
|
20830 |
|
20831 |
|
20832 |
|
20833 |
|
20834 |
|
20835 |
|
20836 | DataGroup.prototype._checkValueField = function (data) {
|
20837 | var hasValueField = this.style === Settings.STYLE.BARCOLOR || this.style === Settings.STYLE.BARSIZE || this.style === Settings.STYLE.DOTCOLOR || this.style === Settings.STYLE.DOTSIZE;
|
20838 |
|
20839 | if (!hasValueField) {
|
20840 | return;
|
20841 | }
|
20842 |
|
20843 |
|
20844 | if (this.colValue === undefined) {
|
20845 | throw new Error('Expected data to have ' + ' field \'style\' ' + ' for graph style \'' + this.style + '\'');
|
20846 | }
|
20847 |
|
20848 |
|
20849 |
|
20850 | if (data[0][this.colValue] === undefined) {
|
20851 | throw new Error('Expected data to have ' + ' field \'' + this.colValue + '\' ' + ' for graph style \'' + this.style + '\'');
|
20852 | }
|
20853 | };
|
20854 |
|
20855 | var DataGroup_1 = DataGroup;
|
20856 |
|
20857 | var Validator$2 = Validator$1.Validator;
|
20858 | var printStyle$1 = Validator$1.printStyle;
|
20859 | var allOptions$2 = options.allOptions;
|
20860 |
|
20861 | Graph3d.STYLE = Settings.STYLE;
|
20862 |
|
20863 |
|
20864 |
|
20865 |
|
20866 |
|
20867 |
|
20868 |
|
20869 |
|
20870 | var autoByDefault = undefined;
|
20871 |
|
20872 |
|
20873 |
|
20874 |
|
20875 |
|
20876 |
|
20877 |
|
20878 |
|
20879 |
|
20880 |
|
20881 | Graph3d.DEFAULTS = {
|
20882 | width: '400px',
|
20883 | height: '400px',
|
20884 | filterLabel: 'time',
|
20885 | legendLabel: 'value',
|
20886 | xLabel: 'x',
|
20887 | yLabel: 'y',
|
20888 | zLabel: 'z',
|
20889 | xValueLabel: function xValueLabel(v) {
|
20890 | return v;
|
20891 | },
|
20892 | yValueLabel: function yValueLabel(v) {
|
20893 | return v;
|
20894 | },
|
20895 | zValueLabel: function zValueLabel(v) {
|
20896 | return v;
|
20897 | },
|
20898 | showXAxis: true,
|
20899 | showYAxis: true,
|
20900 | showZAxis: true,
|
20901 | showGrid: true,
|
20902 | showPerspective: true,
|
20903 | showShadow: false,
|
20904 | keepAspectRatio: true,
|
20905 | rotateAxisLabels: true,
|
20906 | verticalRatio: 0.5,
|
20907 |
|
20908 | dotSizeRatio: 0.02,
|
20909 |
|
20910 | dotSizeMinFraction: 0.5,
|
20911 |
|
20912 | dotSizeMaxFraction: 2.5,
|
20913 |
|
20914 | showAnimationControls: autoByDefault,
|
20915 | animationInterval: 1000,
|
20916 |
|
20917 | animationPreload: false,
|
20918 | animationAutoStart: autoByDefault,
|
20919 | axisFontSize: 14,
|
20920 | axisFontType: 'arial',
|
20921 | axisColor: '#4D4D4D',
|
20922 | gridColor: '#D3D3D3',
|
20923 | xCenter: '55%',
|
20924 | yCenter: '50%',
|
20925 | style: Graph3d.STYLE.DOT,
|
20926 | tooltip: false,
|
20927 | tooltipDelay: 300,
|
20928 |
|
20929 | tooltipStyle: {
|
20930 | content: {
|
20931 | padding: '10px',
|
20932 | border: '1px solid #4d4d4d',
|
20933 | color: '#1a1a1a',
|
20934 | background: 'rgba(255,255,255,0.7)',
|
20935 | borderRadius: '2px',
|
20936 | boxShadow: '5px 5px 10px rgba(128,128,128,0.5)'
|
20937 | },
|
20938 | line: {
|
20939 | height: '40px',
|
20940 | width: '0',
|
20941 | borderLeft: '1px solid #4d4d4d',
|
20942 | pointerEvents: 'none'
|
20943 | },
|
20944 | dot: {
|
20945 | height: '0',
|
20946 | width: '0',
|
20947 | border: '5px solid #4d4d4d',
|
20948 | borderRadius: '5px',
|
20949 | pointerEvents: 'none'
|
20950 | }
|
20951 | },
|
20952 | dataColor: {
|
20953 | fill: '#7DC1FF',
|
20954 | stroke: '#3267D2',
|
20955 | strokeWidth: 1
|
20956 |
|
20957 | },
|
20958 | cameraPosition: {
|
20959 | horizontal: 1.0,
|
20960 | vertical: 0.5,
|
20961 | distance: 1.7
|
20962 | },
|
20963 | zoomable: true,
|
20964 | ctrlToZoom: false,
|
20965 |
|
20966 | |
20967 |
|
20968 |
|
20969 | showLegend: autoByDefault,
|
20970 |
|
20971 | backgroundColor: autoByDefault,
|
20972 | xBarWidth: autoByDefault,
|
20973 | yBarWidth: autoByDefault,
|
20974 | valueMin: autoByDefault,
|
20975 | valueMax: autoByDefault,
|
20976 | xMin: autoByDefault,
|
20977 | xMax: autoByDefault,
|
20978 | xStep: autoByDefault,
|
20979 | yMin: autoByDefault,
|
20980 | yMax: autoByDefault,
|
20981 | yStep: autoByDefault,
|
20982 | zMin: autoByDefault,
|
20983 | zMax: autoByDefault,
|
20984 | zStep: autoByDefault
|
20985 | };
|
20986 |
|
20987 |
|
20988 |
|
20989 |
|
20990 |
|
20991 |
|
20992 |
|
20993 |
|
20994 |
|
20995 |
|
20996 |
|
20997 |
|
20998 |
|
20999 |
|
21000 |
|
21001 | function Graph3d(container, data, options) {
|
21002 | if (!(this instanceof Graph3d)) {
|
21003 | throw new SyntaxError('Constructor must be called with the new operator');
|
21004 | }
|
21005 |
|
21006 |
|
21007 | this.containerElement = container;
|
21008 | this.dataGroup = new DataGroup_1();
|
21009 | this.dataPoints = null;
|
21010 |
|
21011 |
|
21012 | this.create();
|
21013 | Settings.setDefaults(Graph3d.DEFAULTS, this);
|
21014 |
|
21015 | this.colX = undefined;
|
21016 | this.colY = undefined;
|
21017 | this.colZ = undefined;
|
21018 | this.colValue = undefined;
|
21019 |
|
21020 |
|
21021 | this.setOptions(options);
|
21022 |
|
21023 | this.setData(data);
|
21024 | }
|
21025 |
|
21026 |
|
21027 | emitterComponent(Graph3d.prototype);
|
21028 |
|
21029 |
|
21030 |
|
21031 |
|
21032 | Graph3d.prototype._setScale = function () {
|
21033 | this.scale = new Point3d_1(1 / this.xRange.range(), 1 / this.yRange.range(), 1 / this.zRange.range());
|
21034 |
|
21035 | if (this.keepAspectRatio) {
|
21036 | if (this.scale.x < this.scale.y) {
|
21037 |
|
21038 | this.scale.y = this.scale.x;
|
21039 | } else {
|
21040 |
|
21041 | this.scale.x = this.scale.y;
|
21042 | }
|
21043 | }
|
21044 |
|
21045 |
|
21046 | this.scale.z *= this.verticalRatio;
|
21047 |
|
21048 |
|
21049 | if (this.valueRange !== undefined) {
|
21050 | this.scale.value = 1 / this.valueRange.range();
|
21051 | }
|
21052 |
|
21053 |
|
21054 | var xCenter = this.xRange.center() * this.scale.x;
|
21055 | var yCenter = this.yRange.center() * this.scale.y;
|
21056 | var zCenter = this.zRange.center() * this.scale.z;
|
21057 | this.camera.setArmLocation(xCenter, yCenter, zCenter);
|
21058 | };
|
21059 |
|
21060 |
|
21061 |
|
21062 |
|
21063 |
|
21064 |
|
21065 |
|
21066 |
|
21067 |
|
21068 | Graph3d.prototype._convert3Dto2D = function (point3d) {
|
21069 | var translation = this._convertPointToTranslation(point3d);
|
21070 |
|
21071 | return this._convertTranslationToScreen(translation);
|
21072 | };
|
21073 |
|
21074 |
|
21075 |
|
21076 |
|
21077 |
|
21078 |
|
21079 |
|
21080 |
|
21081 |
|
21082 |
|
21083 |
|
21084 | Graph3d.prototype._convertPointToTranslation = function (point3d) {
|
21085 | var cameraLocation = this.camera.getCameraLocation(),
|
21086 | cameraRotation = this.camera.getCameraRotation(),
|
21087 | ax = point3d.x * this.scale.x,
|
21088 | ay = point3d.y * this.scale.y,
|
21089 | az = point3d.z * this.scale.z,
|
21090 | cx = cameraLocation.x,
|
21091 | cy = cameraLocation.y,
|
21092 | cz = cameraLocation.z,
|
21093 |
|
21094 | sinTx = Math.sin(cameraRotation.x),
|
21095 | cosTx = Math.cos(cameraRotation.x),
|
21096 | sinTy = Math.sin(cameraRotation.y),
|
21097 | cosTy = Math.cos(cameraRotation.y),
|
21098 | sinTz = Math.sin(cameraRotation.z),
|
21099 | cosTz = Math.cos(cameraRotation.z),
|
21100 |
|
21101 | dx = cosTy * (sinTz * (ay - cy) + cosTz * (ax - cx)) - sinTy * (az - cz),
|
21102 | dy = sinTx * (cosTy * (az - cz) + sinTy * (sinTz * (ay - cy) + cosTz * (ax - cx))) + cosTx * (cosTz * (ay - cy) - sinTz * (ax - cx)),
|
21103 | dz = cosTx * (cosTy * (az - cz) + sinTy * (sinTz * (ay - cy) + cosTz * (ax - cx))) - sinTx * (cosTz * (ay - cy) - sinTz * (ax - cx));
|
21104 | return new Point3d_1(dx, dy, dz);
|
21105 | };
|
21106 |
|
21107 |
|
21108 |
|
21109 |
|
21110 |
|
21111 |
|
21112 |
|
21113 |
|
21114 |
|
21115 |
|
21116 | Graph3d.prototype._convertTranslationToScreen = function (translation) {
|
21117 | var ex = this.eye.x,
|
21118 | ey = this.eye.y,
|
21119 | ez = this.eye.z,
|
21120 | dx = translation.x,
|
21121 | dy = translation.y,
|
21122 | dz = translation.z;
|
21123 |
|
21124 | var bx;
|
21125 | var by;
|
21126 |
|
21127 | if (this.showPerspective) {
|
21128 | bx = (dx - ex) * (ez / dz);
|
21129 | by = (dy - ey) * (ez / dz);
|
21130 | } else {
|
21131 | bx = dx * -(ez / this.camera.getArmLength());
|
21132 | by = dy * -(ez / this.camera.getArmLength());
|
21133 | }
|
21134 |
|
21135 |
|
21136 |
|
21137 | return new Point2d_1(this.currentXCenter + bx * this.frame.canvas.clientWidth, this.currentYCenter - by * this.frame.canvas.clientWidth);
|
21138 | };
|
21139 |
|
21140 |
|
21141 |
|
21142 |
|
21143 |
|
21144 |
|
21145 |
|
21146 |
|
21147 | Graph3d.prototype._calcTranslations = function (points) {
|
21148 | for (var i = 0; i < points.length; i++) {
|
21149 | var point = points[i];
|
21150 | point.trans = this._convertPointToTranslation(point.point);
|
21151 | point.screen = this._convertTranslationToScreen(point.trans);
|
21152 |
|
21153 | var transBottom = this._convertPointToTranslation(point.bottom);
|
21154 |
|
21155 | point.dist = this.showPerspective ? transBottom.length() : -transBottom.z;
|
21156 | }
|
21157 |
|
21158 |
|
21159 | var sortDepth = function sortDepth(a, b) {
|
21160 | return b.dist - a.dist;
|
21161 | };
|
21162 |
|
21163 | points.sort(sortDepth);
|
21164 | };
|
21165 |
|
21166 |
|
21167 |
|
21168 |
|
21169 |
|
21170 | Graph3d.prototype._initializeRanges = function () {
|
21171 |
|
21172 | var dg = this.dataGroup;
|
21173 | this.xRange = dg.xRange;
|
21174 | this.yRange = dg.yRange;
|
21175 | this.zRange = dg.zRange;
|
21176 | this.valueRange = dg.valueRange;
|
21177 |
|
21178 |
|
21179 | this.xStep = dg.xStep;
|
21180 | this.yStep = dg.yStep;
|
21181 | this.zStep = dg.zStep;
|
21182 | this.xBarWidth = dg.xBarWidth;
|
21183 | this.yBarWidth = dg.yBarWidth;
|
21184 | this.colX = dg.colX;
|
21185 | this.colY = dg.colY;
|
21186 | this.colZ = dg.colZ;
|
21187 | this.colValue = dg.colValue;
|
21188 |
|
21189 | this._setScale();
|
21190 | };
|
21191 |
|
21192 |
|
21193 |
|
21194 |
|
21195 |
|
21196 |
|
21197 |
|
21198 |
|
21199 | Graph3d.prototype.getDataPoints = function (data) {
|
21200 | var dataPoints = [];
|
21201 |
|
21202 | for (var i = 0; i < data.length; i++) {
|
21203 | var point = new Point3d_1();
|
21204 | point.x = data[i][this.colX] || 0;
|
21205 | point.y = data[i][this.colY] || 0;
|
21206 | point.z = data[i][this.colZ] || 0;
|
21207 | point.data = data[i];
|
21208 |
|
21209 | if (this.colValue !== undefined) {
|
21210 | point.value = data[i][this.colValue] || 0;
|
21211 | }
|
21212 |
|
21213 | var obj = {};
|
21214 | obj.point = point;
|
21215 | obj.bottom = new Point3d_1(point.x, point.y, this.zRange.min);
|
21216 | obj.trans = undefined;
|
21217 | obj.screen = undefined;
|
21218 | dataPoints.push(obj);
|
21219 | }
|
21220 |
|
21221 | return dataPoints;
|
21222 | };
|
21223 |
|
21224 |
|
21225 |
|
21226 |
|
21227 |
|
21228 |
|
21229 |
|
21230 |
|
21231 |
|
21232 | Graph3d.prototype._getDataPoints = function (data) {
|
21233 |
|
21234 |
|
21235 | var x, y, i, obj;
|
21236 | var dataPoints = [];
|
21237 |
|
21238 | if (this.style === Graph3d.STYLE.GRID || this.style === Graph3d.STYLE.SURFACE) {
|
21239 |
|
21240 |
|
21241 |
|
21242 | var dataX = this.dataGroup.getDistinctValues(this.colX, data);
|
21243 | var dataY = this.dataGroup.getDistinctValues(this.colY, data);
|
21244 | dataPoints = this.getDataPoints(data);
|
21245 |
|
21246 | var dataMatrix = [];
|
21247 |
|
21248 | for (i = 0; i < dataPoints.length; i++) {
|
21249 | obj = dataPoints[i];
|
21250 |
|
21251 | var xIndex = dataX.indexOf(obj.point.x);
|
21252 | var yIndex = dataY.indexOf(obj.point.y);
|
21253 |
|
21254 | if (dataMatrix[xIndex] === undefined) {
|
21255 | dataMatrix[xIndex] = [];
|
21256 | }
|
21257 |
|
21258 | dataMatrix[xIndex][yIndex] = obj;
|
21259 | }
|
21260 |
|
21261 |
|
21262 | for (x = 0; x < dataMatrix.length; x++) {
|
21263 | for (y = 0; y < dataMatrix[x].length; y++) {
|
21264 | if (dataMatrix[x][y]) {
|
21265 | dataMatrix[x][y].pointRight = x < dataMatrix.length - 1 ? dataMatrix[x + 1][y] : undefined;
|
21266 | dataMatrix[x][y].pointTop = y < dataMatrix[x].length - 1 ? dataMatrix[x][y + 1] : undefined;
|
21267 | dataMatrix[x][y].pointCross = x < dataMatrix.length - 1 && y < dataMatrix[x].length - 1 ? dataMatrix[x + 1][y + 1] : undefined;
|
21268 | }
|
21269 | }
|
21270 | }
|
21271 | } else {
|
21272 |
|
21273 | this._checkValueField(data);
|
21274 |
|
21275 | dataPoints = this.getDataPoints(data);
|
21276 |
|
21277 | if (this.style === Graph3d.STYLE.LINE) {
|
21278 |
|
21279 | for (i = 0; i < dataPoints.length; i++) {
|
21280 | if (i > 0) {
|
21281 | dataPoints[i - 1].pointNext = dataPoints[i];
|
21282 | }
|
21283 | }
|
21284 | }
|
21285 | }
|
21286 |
|
21287 | return dataPoints;
|
21288 | };
|
21289 |
|
21290 |
|
21291 |
|
21292 |
|
21293 |
|
21294 |
|
21295 |
|
21296 |
|
21297 |
|
21298 | Graph3d.prototype.create = function () {
|
21299 |
|
21300 | while (this.containerElement.hasChildNodes()) {
|
21301 | this.containerElement.removeChild(this.containerElement.firstChild);
|
21302 | }
|
21303 |
|
21304 | this.frame = document.createElement('div');
|
21305 | this.frame.style.position = 'relative';
|
21306 | this.frame.style.overflow = 'hidden';
|
21307 |
|
21308 | this.frame.canvas = document.createElement('canvas');
|
21309 | this.frame.canvas.style.position = 'relative';
|
21310 | this.frame.appendChild(this.frame.canvas);
|
21311 |
|
21312 | {
|
21313 | var noCanvas = document.createElement('DIV');
|
21314 | noCanvas.style.color = 'red';
|
21315 | noCanvas.style.fontWeight = 'bold';
|
21316 | noCanvas.style.padding = '10px';
|
21317 | noCanvas.innerHTML = 'Error: your browser does not support HTML canvas';
|
21318 | this.frame.canvas.appendChild(noCanvas);
|
21319 | }
|
21320 | this.frame.filter = document.createElement('div');
|
21321 | this.frame.filter.style.position = 'absolute';
|
21322 | this.frame.filter.style.bottom = '0px';
|
21323 | this.frame.filter.style.left = '0px';
|
21324 | this.frame.filter.style.width = '100%';
|
21325 | this.frame.appendChild(this.frame.filter);
|
21326 |
|
21327 | var me = this;
|
21328 |
|
21329 | var onmousedown = function onmousedown(event) {
|
21330 | me._onMouseDown(event);
|
21331 | };
|
21332 |
|
21333 | var ontouchstart = function ontouchstart(event) {
|
21334 | me._onTouchStart(event);
|
21335 | };
|
21336 |
|
21337 | var onmousewheel = function onmousewheel(event) {
|
21338 | me._onWheel(event);
|
21339 | };
|
21340 |
|
21341 | var ontooltip = function ontooltip(event) {
|
21342 | me._onTooltip(event);
|
21343 | };
|
21344 |
|
21345 | var onclick = function onclick(event) {
|
21346 | me._onClick(event);
|
21347 | };
|
21348 |
|
21349 |
|
21350 | util.addEventListener(this.frame.canvas, 'mousedown', onmousedown);
|
21351 | util.addEventListener(this.frame.canvas, 'touchstart', ontouchstart);
|
21352 | util.addEventListener(this.frame.canvas, 'mousewheel', onmousewheel);
|
21353 | util.addEventListener(this.frame.canvas, 'mousemove', ontooltip);
|
21354 | util.addEventListener(this.frame.canvas, 'click', onclick);
|
21355 |
|
21356 | this.containerElement.appendChild(this.frame);
|
21357 | };
|
21358 |
|
21359 |
|
21360 |
|
21361 |
|
21362 |
|
21363 |
|
21364 |
|
21365 |
|
21366 |
|
21367 | Graph3d.prototype._setSize = function (width, height) {
|
21368 | this.frame.style.width = width;
|
21369 | this.frame.style.height = height;
|
21370 |
|
21371 | this._resizeCanvas();
|
21372 | };
|
21373 |
|
21374 |
|
21375 |
|
21376 |
|
21377 |
|
21378 | Graph3d.prototype._resizeCanvas = function () {
|
21379 | this.frame.canvas.style.width = '100%';
|
21380 | this.frame.canvas.style.height = '100%';
|
21381 | this.frame.canvas.width = this.frame.canvas.clientWidth;
|
21382 | this.frame.canvas.height = this.frame.canvas.clientHeight;
|
21383 |
|
21384 | this.frame.filter.style.width = this.frame.canvas.clientWidth - 2 * 10 + 'px';
|
21385 | };
|
21386 |
|
21387 |
|
21388 |
|
21389 |
|
21390 |
|
21391 |
|
21392 | Graph3d.prototype.animationStart = function () {
|
21393 |
|
21394 | if (!this.animationAutoStart || !this.dataGroup.dataFilter) return;
|
21395 | if (!this.frame.filter || !this.frame.filter.slider) throw new Error('No animation available');
|
21396 | this.frame.filter.slider.play();
|
21397 | };
|
21398 |
|
21399 |
|
21400 |
|
21401 |
|
21402 |
|
21403 | Graph3d.prototype.animationStop = function () {
|
21404 | if (!this.frame.filter || !this.frame.filter.slider) return;
|
21405 | this.frame.filter.slider.stop();
|
21406 | };
|
21407 |
|
21408 |
|
21409 |
|
21410 |
|
21411 |
|
21412 |
|
21413 |
|
21414 |
|
21415 | Graph3d.prototype._resizeCenter = function () {
|
21416 |
|
21417 | if (this.xCenter.charAt(this.xCenter.length - 1) === '%') {
|
21418 | this.currentXCenter = parseFloat(this.xCenter) / 100 * this.frame.canvas.clientWidth;
|
21419 | } else {
|
21420 | this.currentXCenter = parseFloat(this.xCenter);
|
21421 | }
|
21422 |
|
21423 |
|
21424 | if (this.yCenter.charAt(this.yCenter.length - 1) === '%') {
|
21425 | this.currentYCenter = parseFloat(this.yCenter) / 100 * (this.frame.canvas.clientHeight - this.frame.filter.clientHeight);
|
21426 | } else {
|
21427 | this.currentYCenter = parseFloat(this.yCenter);
|
21428 | }
|
21429 | };
|
21430 |
|
21431 |
|
21432 |
|
21433 |
|
21434 |
|
21435 |
|
21436 |
|
21437 |
|
21438 | Graph3d.prototype.getCameraPosition = function () {
|
21439 | var pos = this.camera.getArmRotation();
|
21440 | pos.distance = this.camera.getArmLength();
|
21441 | return pos;
|
21442 | };
|
21443 |
|
21444 |
|
21445 |
|
21446 |
|
21447 |
|
21448 |
|
21449 |
|
21450 |
|
21451 | Graph3d.prototype._readData = function (data) {
|
21452 |
|
21453 | this.dataPoints = this.dataGroup.initializeData(this, data, this.style);
|
21454 |
|
21455 | this._initializeRanges();
|
21456 |
|
21457 | this._redrawFilter();
|
21458 | };
|
21459 |
|
21460 |
|
21461 |
|
21462 |
|
21463 |
|
21464 |
|
21465 |
|
21466 | Graph3d.prototype.setData = function (data) {
|
21467 | if (data === undefined || data === null) return;
|
21468 |
|
21469 | this._readData(data);
|
21470 |
|
21471 | this.redraw();
|
21472 | this.animationStart();
|
21473 | };
|
21474 |
|
21475 |
|
21476 |
|
21477 |
|
21478 |
|
21479 |
|
21480 |
|
21481 | Graph3d.prototype.setOptions = function (options) {
|
21482 | if (options === undefined) return;
|
21483 | var errorFound = Validator$2.validate(options, allOptions$2);
|
21484 |
|
21485 | if (errorFound === true) {
|
21486 | console.log('%cErrors have been found in the supplied options object.', printStyle$1);
|
21487 | }
|
21488 |
|
21489 | this.animationStop();
|
21490 | Settings.setOptions(options, this);
|
21491 | this.setPointDrawingMethod();
|
21492 |
|
21493 | this._setSize(this.width, this.height);
|
21494 |
|
21495 | this.setAxisLabelMethod();
|
21496 | this.setData(this.dataGroup.getDataTable());
|
21497 | this.animationStart();
|
21498 | };
|
21499 |
|
21500 |
|
21501 |
|
21502 |
|
21503 |
|
21504 | Graph3d.prototype.setPointDrawingMethod = function () {
|
21505 | var method = undefined;
|
21506 |
|
21507 | switch (this.style) {
|
21508 | case Graph3d.STYLE.BAR:
|
21509 | method = Graph3d.prototype._redrawBarGraphPoint;
|
21510 | break;
|
21511 |
|
21512 | case Graph3d.STYLE.BARCOLOR:
|
21513 | method = Graph3d.prototype._redrawBarColorGraphPoint;
|
21514 | break;
|
21515 |
|
21516 | case Graph3d.STYLE.BARSIZE:
|
21517 | method = Graph3d.prototype._redrawBarSizeGraphPoint;
|
21518 | break;
|
21519 |
|
21520 | case Graph3d.STYLE.DOT:
|
21521 | method = Graph3d.prototype._redrawDotGraphPoint;
|
21522 | break;
|
21523 |
|
21524 | case Graph3d.STYLE.DOTLINE:
|
21525 | method = Graph3d.prototype._redrawDotLineGraphPoint;
|
21526 | break;
|
21527 |
|
21528 | case Graph3d.STYLE.DOTCOLOR:
|
21529 | method = Graph3d.prototype._redrawDotColorGraphPoint;
|
21530 | break;
|
21531 |
|
21532 | case Graph3d.STYLE.DOTSIZE:
|
21533 | method = Graph3d.prototype._redrawDotSizeGraphPoint;
|
21534 | break;
|
21535 |
|
21536 | case Graph3d.STYLE.SURFACE:
|
21537 | method = Graph3d.prototype._redrawSurfaceGraphPoint;
|
21538 | break;
|
21539 |
|
21540 | case Graph3d.STYLE.GRID:
|
21541 | method = Graph3d.prototype._redrawGridGraphPoint;
|
21542 | break;
|
21543 |
|
21544 | case Graph3d.STYLE.LINE:
|
21545 | method = Graph3d.prototype._redrawLineGraphPoint;
|
21546 | break;
|
21547 |
|
21548 | default:
|
21549 | throw new Error('Can not determine point drawing method ' + 'for graph style \'' + this.style + '\'');
|
21550 | }
|
21551 |
|
21552 | this._pointDrawingMethod = method;
|
21553 | };
|
21554 |
|
21555 |
|
21556 |
|
21557 |
|
21558 |
|
21559 | Graph3d.prototype.setAxisLabelMethod = function () {
|
21560 | var method_x, method_y, method_z;
|
21561 | method_x = method_y = method_z = undefined;
|
21562 |
|
21563 | if (this.rotateAxisLabels == true) {
|
21564 | method_x = Graph3d.prototype.drawAxisLabelXRotate;
|
21565 | method_y = Graph3d.prototype.drawAxisLabelYRotate;
|
21566 | method_z = Graph3d.prototype.drawAxisLabelZRotate;
|
21567 | } else {
|
21568 | method_x = Graph3d.prototype.drawAxisLabelX;
|
21569 | method_y = Graph3d.prototype.drawAxisLabelY;
|
21570 | method_z = Graph3d.prototype.drawAxisLabelZ;
|
21571 | }
|
21572 |
|
21573 | this._drawAxisLabelX = method_x;
|
21574 | this._drawAxisLabelY = method_y;
|
21575 | this._drawAxisLabelZ = method_z;
|
21576 | };
|
21577 |
|
21578 |
|
21579 |
|
21580 |
|
21581 |
|
21582 | Graph3d.prototype.redraw = function () {
|
21583 | if (this.dataPoints === undefined) {
|
21584 | throw new Error('Graph data not initialized');
|
21585 | }
|
21586 |
|
21587 | this._resizeCanvas();
|
21588 |
|
21589 | this._resizeCenter();
|
21590 |
|
21591 | this._redrawSlider();
|
21592 |
|
21593 | this._redrawClear();
|
21594 |
|
21595 | this._redrawAxis();
|
21596 |
|
21597 | this._redrawDataGraph();
|
21598 |
|
21599 | this._redrawInfo();
|
21600 |
|
21601 | this._redrawLegend();
|
21602 | };
|
21603 |
|
21604 |
|
21605 |
|
21606 |
|
21607 |
|
21608 |
|
21609 |
|
21610 |
|
21611 | Graph3d.prototype._getContext = function () {
|
21612 | var canvas = this.frame.canvas;
|
21613 | var ctx = canvas.getContext('2d');
|
21614 | ctx.lineJoin = 'round';
|
21615 | ctx.lineCap = 'round';
|
21616 | return ctx;
|
21617 | };
|
21618 |
|
21619 |
|
21620 |
|
21621 |
|
21622 |
|
21623 | Graph3d.prototype._redrawClear = function () {
|
21624 | var canvas = this.frame.canvas;
|
21625 | var ctx = canvas.getContext('2d');
|
21626 | ctx.clearRect(0, 0, canvas.width, canvas.height);
|
21627 | };
|
21628 |
|
21629 | Graph3d.prototype._dotSize = function () {
|
21630 | return this.frame.clientWidth * this.dotSizeRatio;
|
21631 | };
|
21632 |
|
21633 |
|
21634 |
|
21635 |
|
21636 |
|
21637 |
|
21638 |
|
21639 |
|
21640 | Graph3d.prototype._getLegendWidth = function () {
|
21641 | var width;
|
21642 |
|
21643 | if (this.style === Graph3d.STYLE.DOTSIZE) {
|
21644 | var dotSize = this._dotSize();
|
21645 |
|
21646 |
|
21647 | width = dotSize * this.dotSizeMaxFraction;
|
21648 | } else if (this.style === Graph3d.STYLE.BARSIZE) {
|
21649 | width = this.xBarWidth;
|
21650 | } else {
|
21651 | width = 20;
|
21652 | }
|
21653 |
|
21654 | return width;
|
21655 | };
|
21656 |
|
21657 |
|
21658 |
|
21659 |
|
21660 |
|
21661 | Graph3d.prototype._redrawLegend = function () {
|
21662 |
|
21663 | if (this.showLegend !== true) {
|
21664 | return;
|
21665 | }
|
21666 |
|
21667 |
|
21668 | if (this.style === Graph3d.STYLE.LINE || this.style === Graph3d.STYLE.BARSIZE
|
21669 | ) {
|
21670 | return;
|
21671 | }
|
21672 |
|
21673 |
|
21674 | var isSizeLegend = this.style === Graph3d.STYLE.BARSIZE || this.style === Graph3d.STYLE.DOTSIZE;
|
21675 |
|
21676 | var isValueLegend = this.style === Graph3d.STYLE.DOTSIZE || this.style === Graph3d.STYLE.DOTCOLOR || this.style === Graph3d.STYLE.BARCOLOR;
|
21677 | var height = Math.max(this.frame.clientHeight * 0.25, 100);
|
21678 | var top = this.margin;
|
21679 |
|
21680 | var width = this._getLegendWidth();
|
21681 |
|
21682 |
|
21683 | var right = this.frame.clientWidth - this.margin;
|
21684 | var left = right - width;
|
21685 | var bottom = top + height;
|
21686 |
|
21687 | var ctx = this._getContext();
|
21688 |
|
21689 | ctx.lineWidth = 1;
|
21690 | ctx.font = '14px arial';
|
21691 |
|
21692 | if (isSizeLegend === false) {
|
21693 |
|
21694 | var ymin = 0;
|
21695 | var ymax = height;
|
21696 |
|
21697 | var y;
|
21698 |
|
21699 | for (y = ymin; y < ymax; y++) {
|
21700 | var f = (y - ymin) / (ymax - ymin);
|
21701 | var hue = f * 240;
|
21702 |
|
21703 | var color = this._hsv2rgb(hue, 1, 1);
|
21704 |
|
21705 | ctx.strokeStyle = color;
|
21706 | ctx.beginPath();
|
21707 | ctx.moveTo(left, top + y);
|
21708 | ctx.lineTo(right, top + y);
|
21709 | ctx.stroke();
|
21710 | }
|
21711 |
|
21712 | ctx.strokeStyle = this.axisColor;
|
21713 | ctx.strokeRect(left, top, width, height);
|
21714 | } else {
|
21715 |
|
21716 | var widthMin;
|
21717 |
|
21718 | if (this.style === Graph3d.STYLE.DOTSIZE) {
|
21719 |
|
21720 | widthMin = width * (this.dotSizeMinFraction / this.dotSizeMaxFraction);
|
21721 | } else if (this.style === Graph3d.STYLE.BARSIZE) ;
|
21722 |
|
21723 | ctx.strokeStyle = this.axisColor;
|
21724 | ctx.fillStyle = this.dataColor.fill;
|
21725 | ctx.beginPath();
|
21726 | ctx.moveTo(left, top);
|
21727 | ctx.lineTo(right, top);
|
21728 | ctx.lineTo(left + widthMin, bottom);
|
21729 | ctx.lineTo(left, bottom);
|
21730 | ctx.closePath();
|
21731 | ctx.fill();
|
21732 | ctx.stroke();
|
21733 | }
|
21734 |
|
21735 |
|
21736 | var gridLineLen = 5;
|
21737 |
|
21738 | var legendMin = isValueLegend ? this.valueRange.min : this.zRange.min;
|
21739 | var legendMax = isValueLegend ? this.valueRange.max : this.zRange.max;
|
21740 | var step = new StepNumber_1(legendMin, legendMax, (legendMax - legendMin) / 5, true);
|
21741 | step.start(true);
|
21742 | var from;
|
21743 | var to;
|
21744 |
|
21745 | while (!step.end()) {
|
21746 | y = bottom - (step.getCurrent() - legendMin) / (legendMax - legendMin) * height;
|
21747 | from = new Point2d_1(left - gridLineLen, y);
|
21748 | to = new Point2d_1(left, y);
|
21749 |
|
21750 | this._line(ctx, from, to);
|
21751 |
|
21752 | ctx.textAlign = 'right';
|
21753 | ctx.textBaseline = 'middle';
|
21754 | ctx.fillStyle = this.axisColor;
|
21755 | ctx.fillText(step.getCurrent(), left - 2 * gridLineLen, y);
|
21756 | step.next();
|
21757 | }
|
21758 |
|
21759 | ctx.textAlign = 'right';
|
21760 | ctx.textBaseline = 'top';
|
21761 | var label = this.legendLabel;
|
21762 | ctx.fillText(label, right, bottom + this.margin);
|
21763 | };
|
21764 |
|
21765 |
|
21766 |
|
21767 |
|
21768 |
|
21769 | Graph3d.prototype._redrawFilter = function () {
|
21770 | var dataFilter = this.dataGroup.dataFilter;
|
21771 | var filter = this.frame.filter;
|
21772 | filter.innerHTML = '';
|
21773 |
|
21774 | if (!dataFilter) {
|
21775 | filter.slider = undefined;
|
21776 | return;
|
21777 | }
|
21778 |
|
21779 | var options = {
|
21780 | 'visible': this.showAnimationControls
|
21781 | };
|
21782 | var slider = new Slider_1(filter, options);
|
21783 | filter.slider = slider;
|
21784 |
|
21785 | filter.style.padding = '10px';
|
21786 |
|
21787 | slider.setValues(dataFilter.values);
|
21788 | slider.setPlayInterval(this.animationInterval);
|
21789 |
|
21790 | var me = this;
|
21791 |
|
21792 | var onchange = function onchange() {
|
21793 | var dataFilter = me.dataGroup.dataFilter;
|
21794 | var index = slider.getIndex();
|
21795 | dataFilter.selectValue(index);
|
21796 | me.dataPoints = dataFilter._getDataPoints();
|
21797 | me.redraw();
|
21798 | };
|
21799 |
|
21800 | slider.setOnChangeCallback(onchange);
|
21801 | };
|
21802 |
|
21803 |
|
21804 |
|
21805 |
|
21806 |
|
21807 | Graph3d.prototype._redrawSlider = function () {
|
21808 | if (this.frame.filter.slider !== undefined) {
|
21809 | this.frame.filter.slider.redraw();
|
21810 | }
|
21811 | };
|
21812 |
|
21813 |
|
21814 |
|
21815 |
|
21816 |
|
21817 | Graph3d.prototype._redrawInfo = function () {
|
21818 | var info = this.dataGroup.getInfo();
|
21819 | if (info === undefined) return;
|
21820 |
|
21821 | var ctx = this._getContext();
|
21822 |
|
21823 | ctx.font = '14px arial';
|
21824 |
|
21825 | ctx.lineStyle = 'gray';
|
21826 | ctx.fillStyle = 'gray';
|
21827 | ctx.textAlign = 'left';
|
21828 | ctx.textBaseline = 'top';
|
21829 | var x = this.margin;
|
21830 | var y = this.margin;
|
21831 | ctx.fillText(info, x, y);
|
21832 | };
|
21833 |
|
21834 |
|
21835 |
|
21836 |
|
21837 |
|
21838 |
|
21839 |
|
21840 |
|
21841 |
|
21842 |
|
21843 |
|
21844 |
|
21845 |
|
21846 | Graph3d.prototype._line = function (ctx, from, to, strokeStyle) {
|
21847 | if (strokeStyle !== undefined) {
|
21848 | ctx.strokeStyle = strokeStyle;
|
21849 | }
|
21850 |
|
21851 | ctx.beginPath();
|
21852 | ctx.moveTo(from.x, from.y);
|
21853 | ctx.lineTo(to.x, to.y);
|
21854 | ctx.stroke();
|
21855 | };
|
21856 |
|
21857 |
|
21858 |
|
21859 |
|
21860 |
|
21861 |
|
21862 |
|
21863 |
|
21864 |
|
21865 |
|
21866 | Graph3d.prototype.drawAxisLabelX = function (ctx, point3d, text, armAngle, yMargin) {
|
21867 | if (yMargin === undefined) {
|
21868 | yMargin = 0;
|
21869 | }
|
21870 |
|
21871 | var point2d = this._convert3Dto2D(point3d);
|
21872 |
|
21873 | if (Math.cos(armAngle * 2) > 0) {
|
21874 | ctx.textAlign = 'center';
|
21875 | ctx.textBaseline = 'top';
|
21876 | point2d.y += yMargin;
|
21877 | } else if (Math.sin(armAngle * 2) < 0) {
|
21878 | ctx.textAlign = 'right';
|
21879 | ctx.textBaseline = 'middle';
|
21880 | } else {
|
21881 | ctx.textAlign = 'left';
|
21882 | ctx.textBaseline = 'middle';
|
21883 | }
|
21884 |
|
21885 | ctx.fillStyle = this.axisColor;
|
21886 | ctx.fillText(text, point2d.x, point2d.y);
|
21887 | };
|
21888 |
|
21889 |
|
21890 |
|
21891 |
|
21892 |
|
21893 |
|
21894 |
|
21895 |
|
21896 |
|
21897 |
|
21898 | Graph3d.prototype.drawAxisLabelY = function (ctx, point3d, text, armAngle, yMargin) {
|
21899 | if (yMargin === undefined) {
|
21900 | yMargin = 0;
|
21901 | }
|
21902 |
|
21903 | var point2d = this._convert3Dto2D(point3d);
|
21904 |
|
21905 | if (Math.cos(armAngle * 2) < 0) {
|
21906 | ctx.textAlign = 'center';
|
21907 | ctx.textBaseline = 'top';
|
21908 | point2d.y += yMargin;
|
21909 | } else if (Math.sin(armAngle * 2) > 0) {
|
21910 | ctx.textAlign = 'right';
|
21911 | ctx.textBaseline = 'middle';
|
21912 | } else {
|
21913 | ctx.textAlign = 'left';
|
21914 | ctx.textBaseline = 'middle';
|
21915 | }
|
21916 |
|
21917 | ctx.fillStyle = this.axisColor;
|
21918 | ctx.fillText(text, point2d.x, point2d.y);
|
21919 | };
|
21920 |
|
21921 |
|
21922 |
|
21923 |
|
21924 |
|
21925 |
|
21926 |
|
21927 |
|
21928 |
|
21929 | Graph3d.prototype.drawAxisLabelZ = function (ctx, point3d, text, offset) {
|
21930 | if (offset === undefined) {
|
21931 | offset = 0;
|
21932 | }
|
21933 |
|
21934 | var point2d = this._convert3Dto2D(point3d);
|
21935 |
|
21936 | ctx.textAlign = 'right';
|
21937 | ctx.textBaseline = 'middle';
|
21938 | ctx.fillStyle = this.axisColor;
|
21939 | ctx.fillText(text, point2d.x - offset, point2d.y);
|
21940 | };
|
21941 |
|
21942 |
|
21943 |
|
21944 |
|
21945 |
|
21946 |
|
21947 |
|
21948 |
|
21949 |
|
21950 |
|
21951 | Graph3d.prototype.drawAxisLabelXRotate = function (ctx, point3d, text, armAngle, yMargin) {
|
21952 | if (yMargin === undefined) {
|
21953 | yMargin = 0;
|
21954 | }
|
21955 |
|
21956 | var point2d = this._convert3Dto2D(point3d);
|
21957 |
|
21958 | if (Math.cos(armAngle * 2) > 0) {
|
21959 | ctx.save();
|
21960 | ctx.get;
|
21961 | ctx.translate(point2d.x, point2d.y);
|
21962 | ctx.rotate(Math.PI / 2);
|
21963 | ctx.fillText(text, point2d.x / 100, point2d.y / 100);
|
21964 | ctx.textAlign = 'center';
|
21965 | ctx.textBaseline = 'top';
|
21966 | point2d.y += yMargin;
|
21967 | ctx.restore();
|
21968 | } else if (Math.sin(armAngle * 2) < 0) {
|
21969 | ctx.textAlign = 'right';
|
21970 | ctx.textBaseline = 'middle';
|
21971 | ctx.fillStyle = this.axisColor;
|
21972 | ctx.fillText(text, point2d.x, point2d.y);
|
21973 | } else {
|
21974 | ctx.textAlign = 'left';
|
21975 | ctx.textBaseline = 'middle';
|
21976 | ctx.fillStyle = this.axisColor;
|
21977 | ctx.fillText(text, point2d.x, point2d.y);
|
21978 | }
|
21979 | };
|
21980 |
|
21981 |
|
21982 |
|
21983 |
|
21984 |
|
21985 |
|
21986 |
|
21987 |
|
21988 |
|
21989 |
|
21990 | Graph3d.prototype.drawAxisLabelYRotate = function (ctx, point3d, text, armAngle, yMargin) {
|
21991 | if (yMargin === undefined) {
|
21992 | yMargin = 0;
|
21993 | }
|
21994 |
|
21995 | var point2d = this._convert3Dto2D(point3d);
|
21996 |
|
21997 | if (Math.cos(armAngle * 2) < 0 && Math.sin(armAngle * 2) < 0) {
|
21998 | ctx.save();
|
21999 | ctx.get;
|
22000 | ctx.translate(point2d.x, point2d.y);
|
22001 | ctx.rotate(Math.PI / 2 * -1);
|
22002 | ctx.fillText(text, point2d.x / 100, point2d.y / 100);
|
22003 | ctx.textAlign = 'center';
|
22004 | ctx.textBaseline = 'top';
|
22005 | point2d.y += yMargin;
|
22006 | ctx.restore();
|
22007 | } else if (Math.cos(armAngle * 2) < 0) {
|
22008 | ctx.save();
|
22009 | ctx.get;
|
22010 | ctx.translate(point2d.x, point2d.y);
|
22011 | ctx.rotate(Math.PI / 2);
|
22012 | ctx.fillText(text, point2d.x / 100, point2d.y / 100);
|
22013 | ctx.textAlign = 'center';
|
22014 | ctx.textBaseline = 'top';
|
22015 | point2d.y += yMargin;
|
22016 | ctx.restore();
|
22017 | } else if (Math.sin(armAngle * 2) > 0) {
|
22018 | ctx.textAlign = 'right';
|
22019 | ctx.textBaseline = 'middle';
|
22020 | ctx.fillStyle = this.axisColor;
|
22021 | ctx.fillText(text, point2d.x, point2d.y);
|
22022 | } else {
|
22023 | ctx.textAlign = 'left';
|
22024 | ctx.textBaseline = 'middle';
|
22025 | ctx.fillStyle = this.axisColor;
|
22026 | ctx.fillText(text, point2d.x, point2d.y);
|
22027 | }
|
22028 | };
|
22029 |
|
22030 |
|
22031 |
|
22032 |
|
22033 |
|
22034 |
|
22035 |
|
22036 |
|
22037 |
|
22038 | Graph3d.prototype.drawAxisLabelZRotate = function (ctx, point3d, text, offset) {
|
22039 | if (offset === undefined) {
|
22040 | offset = 0;
|
22041 | }
|
22042 |
|
22043 | var point2d = this._convert3Dto2D(point3d);
|
22044 |
|
22045 | ctx.textAlign = 'right';
|
22046 | ctx.textBaseline = 'middle';
|
22047 | ctx.fillStyle = this.axisColor;
|
22048 | ctx.fillText(text, point2d.x - offset, point2d.y);
|
22049 | };
|
22050 |
|
22051 |
|
22052 |
|
22053 |
|
22054 |
|
22055 |
|
22056 |
|
22057 |
|
22058 |
|
22059 |
|
22060 |
|
22061 |
|
22062 |
|
22063 |
|
22064 |
|
22065 |
|
22066 | Graph3d.prototype._line3d = function (ctx, from, to, strokeStyle) {
|
22067 | var from2d = this._convert3Dto2D(from);
|
22068 |
|
22069 | var to2d = this._convert3Dto2D(to);
|
22070 |
|
22071 | this._line(ctx, from2d, to2d, strokeStyle);
|
22072 | };
|
22073 |
|
22074 |
|
22075 |
|
22076 |
|
22077 |
|
22078 | Graph3d.prototype._redrawAxis = function () {
|
22079 | var ctx = this._getContext(),
|
22080 | from,
|
22081 | to,
|
22082 | step,
|
22083 | prettyStep,
|
22084 | text,
|
22085 | xText,
|
22086 | yText,
|
22087 | zText,
|
22088 | offset,
|
22089 | xOffset,
|
22090 | yOffset;
|
22091 |
|
22092 |
|
22093 |
|
22094 |
|
22095 | ctx.font = this.axisFontSize / this.camera.getArmLength() + 'px ' + this.axisFontType;
|
22096 |
|
22097 | var gridLenX = 0.025 / this.scale.x;
|
22098 | var gridLenY = 0.025 / this.scale.y;
|
22099 | var textMargin = 5 / this.camera.getArmLength();
|
22100 |
|
22101 | var armAngle = this.camera.getArmRotation().horizontal;
|
22102 | var armVector = new Point2d_1(Math.cos(armAngle), Math.sin(armAngle));
|
22103 | var xRange = this.xRange;
|
22104 | var yRange = this.yRange;
|
22105 | var zRange = this.zRange;
|
22106 | var point3d;
|
22107 |
|
22108 | ctx.lineWidth = 1;
|
22109 | prettyStep = this.defaultXStep === undefined;
|
22110 | step = new StepNumber_1(xRange.min, xRange.max, this.xStep, prettyStep);
|
22111 | step.start(true);
|
22112 |
|
22113 | while (!step.end()) {
|
22114 | var x = step.getCurrent();
|
22115 |
|
22116 | if (this.showGrid) {
|
22117 | from = new Point3d_1(x, yRange.min, zRange.min);
|
22118 | to = new Point3d_1(x, yRange.max, zRange.min);
|
22119 |
|
22120 | this._line3d(ctx, from, to, this.gridColor);
|
22121 | } else if (this.showXAxis) {
|
22122 | from = new Point3d_1(x, yRange.min, zRange.min);
|
22123 | to = new Point3d_1(x, yRange.min + gridLenX, zRange.min);
|
22124 |
|
22125 | this._line3d(ctx, from, to, this.axisColor);
|
22126 |
|
22127 | from = new Point3d_1(x, yRange.max, zRange.min);
|
22128 | to = new Point3d_1(x, yRange.max - gridLenX, zRange.min);
|
22129 |
|
22130 | this._line3d(ctx, from, to, this.axisColor);
|
22131 | }
|
22132 |
|
22133 | if (this.showXAxis) {
|
22134 | yText = armVector.x > 0 ? yRange.min : yRange.max;
|
22135 | point3d = new Point3d_1(x, yText, zRange.min);
|
22136 | var msg = ' ' + this.xValueLabel(x) + ' ';
|
22137 |
|
22138 | this._drawAxisLabelX.call(this, ctx, point3d, msg, armAngle, textMargin);
|
22139 | }
|
22140 |
|
22141 | step.next();
|
22142 | }
|
22143 |
|
22144 |
|
22145 | ctx.lineWidth = 1;
|
22146 | prettyStep = this.defaultYStep === undefined;
|
22147 | step = new StepNumber_1(yRange.min, yRange.max, this.yStep, prettyStep);
|
22148 | step.start(true);
|
22149 |
|
22150 | while (!step.end()) {
|
22151 | var y = step.getCurrent();
|
22152 |
|
22153 | if (this.showGrid) {
|
22154 | from = new Point3d_1(xRange.min, y, zRange.min);
|
22155 | to = new Point3d_1(xRange.max, y, zRange.min);
|
22156 |
|
22157 | this._line3d(ctx, from, to, this.gridColor);
|
22158 | } else if (this.showYAxis) {
|
22159 | from = new Point3d_1(xRange.min, y, zRange.min);
|
22160 | to = new Point3d_1(xRange.min + gridLenY, y, zRange.min);
|
22161 |
|
22162 | this._line3d(ctx, from, to, this.axisColor);
|
22163 |
|
22164 | from = new Point3d_1(xRange.max, y, zRange.min);
|
22165 | to = new Point3d_1(xRange.max - gridLenY, y, zRange.min);
|
22166 |
|
22167 | this._line3d(ctx, from, to, this.axisColor);
|
22168 | }
|
22169 |
|
22170 | if (this.showYAxis) {
|
22171 | xText = armVector.y > 0 ? xRange.min : xRange.max;
|
22172 | point3d = new Point3d_1(xText, y, zRange.min);
|
22173 |
|
22174 | var _msg = ' ' + this.yValueLabel(y) + ' ';
|
22175 |
|
22176 | this._drawAxisLabelY.call(this, ctx, point3d, _msg, armAngle, textMargin);
|
22177 | }
|
22178 |
|
22179 | step.next();
|
22180 | }
|
22181 |
|
22182 |
|
22183 | if (this.showZAxis) {
|
22184 | ctx.lineWidth = 1;
|
22185 | prettyStep = this.defaultZStep === undefined;
|
22186 | step = new StepNumber_1(zRange.min, zRange.max, this.zStep, prettyStep);
|
22187 | step.start(true);
|
22188 | xText = armVector.x > 0 ? xRange.min : xRange.max;
|
22189 | yText = armVector.y < 0 ? yRange.min : yRange.max;
|
22190 |
|
22191 | while (!step.end()) {
|
22192 | var z = step.getCurrent();
|
22193 |
|
22194 | var from3d = new Point3d_1(xText, yText, z);
|
22195 |
|
22196 | var from2d = this._convert3Dto2D(from3d);
|
22197 |
|
22198 | to = new Point2d_1(from2d.x - textMargin, from2d.y);
|
22199 |
|
22200 | this._line(ctx, from2d, to, this.axisColor);
|
22201 |
|
22202 | var _msg2 = this.zValueLabel(z) + ' ';
|
22203 |
|
22204 | this._drawAxisLabelZ.call(this, ctx, from3d, _msg2, 5);
|
22205 |
|
22206 | step.next();
|
22207 | }
|
22208 |
|
22209 | ctx.lineWidth = 1;
|
22210 | from = new Point3d_1(xText, yText, zRange.min);
|
22211 | to = new Point3d_1(xText, yText, zRange.max);
|
22212 |
|
22213 | this._line3d(ctx, from, to, this.axisColor);
|
22214 | }
|
22215 |
|
22216 |
|
22217 | if (this.showXAxis) {
|
22218 | var xMin2d;
|
22219 | var xMax2d;
|
22220 | ctx.lineWidth = 1;
|
22221 |
|
22222 | xMin2d = new Point3d_1(xRange.min, yRange.min, zRange.min);
|
22223 | xMax2d = new Point3d_1(xRange.max, yRange.min, zRange.min);
|
22224 |
|
22225 | this._line3d(ctx, xMin2d, xMax2d, this.axisColor);
|
22226 |
|
22227 |
|
22228 | xMin2d = new Point3d_1(xRange.min, yRange.max, zRange.min);
|
22229 | xMax2d = new Point3d_1(xRange.max, yRange.max, zRange.min);
|
22230 |
|
22231 | this._line3d(ctx, xMin2d, xMax2d, this.axisColor);
|
22232 | }
|
22233 |
|
22234 |
|
22235 | if (this.showYAxis) {
|
22236 | ctx.lineWidth = 1;
|
22237 |
|
22238 | from = new Point3d_1(xRange.min, yRange.min, zRange.min);
|
22239 | to = new Point3d_1(xRange.min, yRange.max, zRange.min);
|
22240 |
|
22241 | this._line3d(ctx, from, to, this.axisColor);
|
22242 |
|
22243 |
|
22244 | from = new Point3d_1(xRange.max, yRange.min, zRange.min);
|
22245 | to = new Point3d_1(xRange.max, yRange.max, zRange.min);
|
22246 |
|
22247 | this._line3d(ctx, from, to, this.axisColor);
|
22248 | }
|
22249 |
|
22250 |
|
22251 | var xLabel = this.xLabel;
|
22252 |
|
22253 | if (xLabel.length > 0 && this.showXAxis) {
|
22254 | yOffset = 0.1 / this.scale.y;
|
22255 | xText = (xRange.max + 3 * xRange.min) / 4;
|
22256 | yText = armVector.x > 0 ? yRange.min - yOffset : yRange.max + yOffset;
|
22257 | text = new Point3d_1(xText, yText, zRange.min);
|
22258 | this.drawAxisLabelX(ctx, text, xLabel, armAngle);
|
22259 | }
|
22260 |
|
22261 |
|
22262 | var yLabel = this.yLabel;
|
22263 |
|
22264 | if (yLabel.length > 0 && this.showYAxis) {
|
22265 | xOffset = 0.1 / this.scale.x;
|
22266 | xText = armVector.y > 0 ? xRange.min - xOffset : xRange.max + xOffset;
|
22267 | yText = (yRange.max + 3 * yRange.min) / 4;
|
22268 | text = new Point3d_1(xText, yText, zRange.min);
|
22269 | this.drawAxisLabelY(ctx, text, yLabel, armAngle);
|
22270 | }
|
22271 |
|
22272 |
|
22273 | var zLabel = this.zLabel;
|
22274 |
|
22275 | if (zLabel.length > 0 && this.showZAxis) {
|
22276 | offset = 30;
|
22277 |
|
22278 | xText = armVector.x > 0 ? xRange.min : xRange.max;
|
22279 | yText = armVector.y < 0 ? yRange.min : yRange.max;
|
22280 | zText = (zRange.max + 3 * zRange.min) / 4;
|
22281 | text = new Point3d_1(xText, yText, zText);
|
22282 | this.drawAxisLabelZ(ctx, text, zLabel, offset);
|
22283 | }
|
22284 | };
|
22285 |
|
22286 |
|
22287 |
|
22288 |
|
22289 |
|
22290 |
|
22291 |
|
22292 |
|
22293 |
|
22294 |
|
22295 | Graph3d.prototype._hsv2rgb = function (H, S, V) {
|
22296 | var R, G, B, C, Hi, X;
|
22297 | C = V * S;
|
22298 | Hi = Math.floor(H / 60);
|
22299 |
|
22300 | X = C * (1 - Math.abs(H / 60 % 2 - 1));
|
22301 |
|
22302 | switch (Hi) {
|
22303 | case 0:
|
22304 | R = C;
|
22305 | G = X;
|
22306 | B = 0;
|
22307 | break;
|
22308 |
|
22309 | case 1:
|
22310 | R = X;
|
22311 | G = C;
|
22312 | B = 0;
|
22313 | break;
|
22314 |
|
22315 | case 2:
|
22316 | R = 0;
|
22317 | G = C;
|
22318 | B = X;
|
22319 | break;
|
22320 |
|
22321 | case 3:
|
22322 | R = 0;
|
22323 | G = X;
|
22324 | B = C;
|
22325 | break;
|
22326 |
|
22327 | case 4:
|
22328 | R = X;
|
22329 | G = 0;
|
22330 | B = C;
|
22331 | break;
|
22332 |
|
22333 | case 5:
|
22334 | R = C;
|
22335 | G = 0;
|
22336 | B = X;
|
22337 | break;
|
22338 |
|
22339 | default:
|
22340 | R = 0;
|
22341 | G = 0;
|
22342 | B = 0;
|
22343 | break;
|
22344 | }
|
22345 |
|
22346 | return 'RGB(' + parseInt(R * 255) + ',' + parseInt(G * 255) + ',' + parseInt(B * 255) + ')';
|
22347 | };
|
22348 |
|
22349 |
|
22350 |
|
22351 |
|
22352 |
|
22353 |
|
22354 |
|
22355 |
|
22356 | Graph3d.prototype._getStrokeWidth = function (point) {
|
22357 | if (point !== undefined) {
|
22358 | if (this.showPerspective) {
|
22359 | return 1 / -point.trans.z * this.dataColor.strokeWidth;
|
22360 | } else {
|
22361 | return -(this.eye.z / this.camera.getArmLength()) * this.dataColor.strokeWidth;
|
22362 | }
|
22363 | }
|
22364 |
|
22365 | return this.dataColor.strokeWidth;
|
22366 | };
|
22367 |
|
22368 |
|
22369 |
|
22370 |
|
22371 |
|
22372 |
|
22373 |
|
22374 |
|
22375 |
|
22376 |
|
22377 |
|
22378 |
|
22379 |
|
22380 |
|
22381 |
|
22382 |
|
22383 | Graph3d.prototype._redrawBar = function (ctx, point, xWidth, yWidth, color, borderColor) {
|
22384 | var surface;
|
22385 |
|
22386 | var me = this;
|
22387 | var point3d = point.point;
|
22388 | var zMin = this.zRange.min;
|
22389 | var top = [{
|
22390 | point: new Point3d_1(point3d.x - xWidth, point3d.y - yWidth, point3d.z)
|
22391 | }, {
|
22392 | point: new Point3d_1(point3d.x + xWidth, point3d.y - yWidth, point3d.z)
|
22393 | }, {
|
22394 | point: new Point3d_1(point3d.x + xWidth, point3d.y + yWidth, point3d.z)
|
22395 | }, {
|
22396 | point: new Point3d_1(point3d.x - xWidth, point3d.y + yWidth, point3d.z)
|
22397 | }];
|
22398 | var bottom = [{
|
22399 | point: new Point3d_1(point3d.x - xWidth, point3d.y - yWidth, zMin)
|
22400 | }, {
|
22401 | point: new Point3d_1(point3d.x + xWidth, point3d.y - yWidth, zMin)
|
22402 | }, {
|
22403 | point: new Point3d_1(point3d.x + xWidth, point3d.y + yWidth, zMin)
|
22404 | }, {
|
22405 | point: new Point3d_1(point3d.x - xWidth, point3d.y + yWidth, zMin)
|
22406 | }];
|
22407 |
|
22408 | top.forEach(function (obj) {
|
22409 | obj.screen = me._convert3Dto2D(obj.point);
|
22410 | });
|
22411 | bottom.forEach(function (obj) {
|
22412 | obj.screen = me._convert3Dto2D(obj.point);
|
22413 | });
|
22414 |
|
22415 | var surfaces = [{
|
22416 | corners: top,
|
22417 | center: Point3d_1.avg(bottom[0].point, bottom[2].point)
|
22418 | }, {
|
22419 | corners: [top[0], top[1], bottom[1], bottom[0]],
|
22420 | center: Point3d_1.avg(bottom[1].point, bottom[0].point)
|
22421 | }, {
|
22422 | corners: [top[1], top[2], bottom[2], bottom[1]],
|
22423 | center: Point3d_1.avg(bottom[2].point, bottom[1].point)
|
22424 | }, {
|
22425 | corners: [top[2], top[3], bottom[3], bottom[2]],
|
22426 | center: Point3d_1.avg(bottom[3].point, bottom[2].point)
|
22427 | }, {
|
22428 | corners: [top[3], top[0], bottom[0], bottom[3]],
|
22429 | center: Point3d_1.avg(bottom[0].point, bottom[3].point)
|
22430 | }];
|
22431 | point.surfaces = surfaces;
|
22432 |
|
22433 | for (var j = 0; j < surfaces.length; j++) {
|
22434 | surface = surfaces[j];
|
22435 |
|
22436 | var transCenter = this._convertPointToTranslation(surface.center);
|
22437 |
|
22438 | surface.dist = this.showPerspective ? transCenter.length() : -transCenter.z;
|
22439 |
|
22440 |
|
22441 | }
|
22442 |
|
22443 |
|
22444 | surfaces.sort(function (a, b) {
|
22445 | var diff = b.dist - a.dist;
|
22446 | if (diff) return diff;
|
22447 |
|
22448 | if (a.corners === top) return 1;
|
22449 | if (b.corners === top) return -1;
|
22450 |
|
22451 | return 0;
|
22452 | });
|
22453 |
|
22454 | ctx.lineWidth = this._getStrokeWidth(point);
|
22455 | ctx.strokeStyle = borderColor;
|
22456 | ctx.fillStyle = color;
|
22457 |
|
22458 | for (var _j = 2; _j < surfaces.length; _j++) {
|
22459 | surface = surfaces[_j];
|
22460 |
|
22461 | this._polygon(ctx, surface.corners);
|
22462 | }
|
22463 | };
|
22464 |
|
22465 |
|
22466 |
|
22467 |
|
22468 |
|
22469 |
|
22470 |
|
22471 |
|
22472 |
|
22473 |
|
22474 | Graph3d.prototype._polygon = function (ctx, points, fillStyle, strokeStyle) {
|
22475 | if (points.length < 2) {
|
22476 | return;
|
22477 | }
|
22478 |
|
22479 | if (fillStyle !== undefined) {
|
22480 | ctx.fillStyle = fillStyle;
|
22481 | }
|
22482 |
|
22483 | if (strokeStyle !== undefined) {
|
22484 | ctx.strokeStyle = strokeStyle;
|
22485 | }
|
22486 |
|
22487 | ctx.beginPath();
|
22488 | ctx.moveTo(points[0].screen.x, points[0].screen.y);
|
22489 |
|
22490 | for (var i = 1; i < points.length; ++i) {
|
22491 | var point = points[i];
|
22492 | ctx.lineTo(point.screen.x, point.screen.y);
|
22493 | }
|
22494 |
|
22495 | ctx.closePath();
|
22496 | ctx.fill();
|
22497 | ctx.stroke();
|
22498 | };
|
22499 |
|
22500 |
|
22501 |
|
22502 |
|
22503 |
|
22504 |
|
22505 |
|
22506 |
|
22507 |
|
22508 |
|
22509 | Graph3d.prototype._drawCircle = function (ctx, point, color, borderColor, size) {
|
22510 | var radius = this._calcRadius(point, size);
|
22511 |
|
22512 | ctx.lineWidth = this._getStrokeWidth(point);
|
22513 | ctx.strokeStyle = borderColor;
|
22514 | ctx.fillStyle = color;
|
22515 | ctx.beginPath();
|
22516 | ctx.arc(point.screen.x, point.screen.y, radius, 0, Math.PI * 2, true);
|
22517 | ctx.fill();
|
22518 | ctx.stroke();
|
22519 | };
|
22520 |
|
22521 |
|
22522 |
|
22523 |
|
22524 |
|
22525 |
|
22526 |
|
22527 |
|
22528 |
|
22529 | Graph3d.prototype._getColorsRegular = function (point) {
|
22530 |
|
22531 | var hue = (1 - (point.point.z - this.zRange.min) * this.scale.z / this.verticalRatio) * 240;
|
22532 |
|
22533 | var color = this._hsv2rgb(hue, 1, 1);
|
22534 |
|
22535 | var borderColor = this._hsv2rgb(hue, 1, 0.8);
|
22536 |
|
22537 | return {
|
22538 | fill: color,
|
22539 | border: borderColor
|
22540 | };
|
22541 | };
|
22542 |
|
22543 |
|
22544 |
|
22545 |
|
22546 |
|
22547 |
|
22548 |
|
22549 |
|
22550 |
|
22551 |
|
22552 |
|
22553 |
|
22554 |
|
22555 |
|
22556 | Graph3d.prototype._getColorsColor = function (point) {
|
22557 |
|
22558 | var color, borderColor, pointStyle;
|
22559 |
|
22560 | if (point && point.point && point.point.data && point.point.data.style) {
|
22561 | pointStyle = point.point.data.style;
|
22562 | }
|
22563 |
|
22564 | if (pointStyle && _typeof$2(pointStyle) === 'object' && pointStyle.fill && pointStyle.stroke) {
|
22565 | return {
|
22566 | fill: pointStyle.fill,
|
22567 | border: pointStyle.stroke
|
22568 | };
|
22569 | }
|
22570 |
|
22571 | if (typeof point.point.value === "string") {
|
22572 | color = point.point.value;
|
22573 | borderColor = point.point.value;
|
22574 | } else {
|
22575 | var hue = (1 - (point.point.value - this.valueRange.min) * this.scale.value) * 240;
|
22576 | color = this._hsv2rgb(hue, 1, 1);
|
22577 | borderColor = this._hsv2rgb(hue, 1, 0.8);
|
22578 | }
|
22579 |
|
22580 | return {
|
22581 | fill: color,
|
22582 | border: borderColor
|
22583 | };
|
22584 | };
|
22585 |
|
22586 |
|
22587 |
|
22588 |
|
22589 |
|
22590 |
|
22591 |
|
22592 |
|
22593 |
|
22594 | Graph3d.prototype._getColorsSize = function () {
|
22595 | return {
|
22596 | fill: this.dataColor.fill,
|
22597 | border: this.dataColor.stroke
|
22598 | };
|
22599 | };
|
22600 |
|
22601 |
|
22602 |
|
22603 |
|
22604 |
|
22605 |
|
22606 |
|
22607 |
|
22608 |
|
22609 |
|
22610 |
|
22611 |
|
22612 | Graph3d.prototype._calcRadius = function (point, size) {
|
22613 | if (size === undefined) {
|
22614 | size = this._dotSize();
|
22615 | }
|
22616 |
|
22617 | var radius;
|
22618 |
|
22619 | if (this.showPerspective) {
|
22620 | radius = size / -point.trans.z;
|
22621 | } else {
|
22622 | radius = size * -(this.eye.z / this.camera.getArmLength());
|
22623 | }
|
22624 |
|
22625 | if (radius < 0) {
|
22626 | radius = 0;
|
22627 | }
|
22628 |
|
22629 | return radius;
|
22630 | };
|
22631 |
|
22632 |
|
22633 |
|
22634 |
|
22635 |
|
22636 |
|
22637 |
|
22638 |
|
22639 |
|
22640 |
|
22641 |
|
22642 |
|
22643 | Graph3d.prototype._redrawBarGraphPoint = function (ctx, point) {
|
22644 | var xWidth = this.xBarWidth / 2;
|
22645 | var yWidth = this.yBarWidth / 2;
|
22646 |
|
22647 | var colors = this._getColorsRegular(point);
|
22648 |
|
22649 | this._redrawBar(ctx, point, xWidth, yWidth, colors.fill, colors.border);
|
22650 | };
|
22651 |
|
22652 |
|
22653 |
|
22654 |
|
22655 |
|
22656 |
|
22657 |
|
22658 |
|
22659 |
|
22660 | Graph3d.prototype._redrawBarColorGraphPoint = function (ctx, point) {
|
22661 | var xWidth = this.xBarWidth / 2;
|
22662 | var yWidth = this.yBarWidth / 2;
|
22663 |
|
22664 | var colors = this._getColorsColor(point);
|
22665 |
|
22666 | this._redrawBar(ctx, point, xWidth, yWidth, colors.fill, colors.border);
|
22667 | };
|
22668 |
|
22669 |
|
22670 |
|
22671 |
|
22672 |
|
22673 |
|
22674 |
|
22675 |
|
22676 |
|
22677 | Graph3d.prototype._redrawBarSizeGraphPoint = function (ctx, point) {
|
22678 |
|
22679 | var fraction = (point.point.value - this.valueRange.min) / this.valueRange.range();
|
22680 | var xWidth = this.xBarWidth / 2 * (fraction * 0.8 + 0.2);
|
22681 | var yWidth = this.yBarWidth / 2 * (fraction * 0.8 + 0.2);
|
22682 |
|
22683 | var colors = this._getColorsSize();
|
22684 |
|
22685 | this._redrawBar(ctx, point, xWidth, yWidth, colors.fill, colors.border);
|
22686 | };
|
22687 |
|
22688 |
|
22689 |
|
22690 |
|
22691 |
|
22692 |
|
22693 |
|
22694 |
|
22695 |
|
22696 | Graph3d.prototype._redrawDotGraphPoint = function (ctx, point) {
|
22697 | var colors = this._getColorsRegular(point);
|
22698 |
|
22699 | this._drawCircle(ctx, point, colors.fill, colors.border);
|
22700 | };
|
22701 |
|
22702 |
|
22703 |
|
22704 |
|
22705 |
|
22706 |
|
22707 |
|
22708 |
|
22709 |
|
22710 | Graph3d.prototype._redrawDotLineGraphPoint = function (ctx, point) {
|
22711 |
|
22712 | var from = this._convert3Dto2D(point.bottom);
|
22713 |
|
22714 | ctx.lineWidth = 1;
|
22715 |
|
22716 | this._line(ctx, from, point.screen, this.gridColor);
|
22717 |
|
22718 | this._redrawDotGraphPoint(ctx, point);
|
22719 | };
|
22720 |
|
22721 |
|
22722 |
|
22723 |
|
22724 |
|
22725 |
|
22726 |
|
22727 |
|
22728 |
|
22729 | Graph3d.prototype._redrawDotColorGraphPoint = function (ctx, point) {
|
22730 | var colors = this._getColorsColor(point);
|
22731 |
|
22732 | this._drawCircle(ctx, point, colors.fill, colors.border);
|
22733 | };
|
22734 |
|
22735 |
|
22736 |
|
22737 |
|
22738 |
|
22739 |
|
22740 |
|
22741 |
|
22742 |
|
22743 | Graph3d.prototype._redrawDotSizeGraphPoint = function (ctx, point) {
|
22744 | var dotSize = this._dotSize();
|
22745 |
|
22746 | var fraction = (point.point.value - this.valueRange.min) / this.valueRange.range();
|
22747 | var sizeMin = dotSize * this.dotSizeMinFraction;
|
22748 | var sizeRange = dotSize * this.dotSizeMaxFraction - sizeMin;
|
22749 | var size = sizeMin + sizeRange * fraction;
|
22750 |
|
22751 | var colors = this._getColorsSize();
|
22752 |
|
22753 | this._drawCircle(ctx, point, colors.fill, colors.border, size);
|
22754 | };
|
22755 |
|
22756 |
|
22757 |
|
22758 |
|
22759 |
|
22760 |
|
22761 |
|
22762 |
|
22763 |
|
22764 | Graph3d.prototype._redrawSurfaceGraphPoint = function (ctx, point) {
|
22765 | var right = point.pointRight;
|
22766 | var top = point.pointTop;
|
22767 | var cross = point.pointCross;
|
22768 |
|
22769 | if (point === undefined || right === undefined || top === undefined || cross === undefined) {
|
22770 | return;
|
22771 | }
|
22772 |
|
22773 | var topSideVisible = true;
|
22774 | var fillStyle;
|
22775 | var strokeStyle;
|
22776 |
|
22777 | if (this.showGrayBottom || this.showShadow) {
|
22778 |
|
22779 |
|
22780 |
|
22781 |
|
22782 | var aDiff = Point3d_1.subtract(cross.trans, point.trans);
|
22783 | var bDiff = Point3d_1.subtract(top.trans, right.trans);
|
22784 | var crossproduct = Point3d_1.crossProduct(aDiff, bDiff);
|
22785 | var len = crossproduct.length();
|
22786 |
|
22787 | topSideVisible = crossproduct.z > 0;
|
22788 | }
|
22789 |
|
22790 | if (topSideVisible) {
|
22791 |
|
22792 | var zAvg = (point.point.z + right.point.z + top.point.z + cross.point.z) / 4;
|
22793 | var h = (1 - (zAvg - this.zRange.min) * this.scale.z / this.verticalRatio) * 240;
|
22794 | var s = 1;
|
22795 |
|
22796 | var v;
|
22797 |
|
22798 | if (this.showShadow) {
|
22799 | v = Math.min(1 + crossproduct.x / len / 2, 1);
|
22800 |
|
22801 | fillStyle = this._hsv2rgb(h, s, v);
|
22802 | strokeStyle = fillStyle;
|
22803 | } else {
|
22804 | v = 1;
|
22805 | fillStyle = this._hsv2rgb(h, s, v);
|
22806 | strokeStyle = this.axisColor;
|
22807 | }
|
22808 | } else {
|
22809 | fillStyle = 'gray';
|
22810 | strokeStyle = this.axisColor;
|
22811 | }
|
22812 |
|
22813 | ctx.lineWidth = this._getStrokeWidth(point);
|
22814 |
|
22815 | var points = [point, right, cross, top];
|
22816 |
|
22817 | this._polygon(ctx, points, fillStyle, strokeStyle);
|
22818 | };
|
22819 |
|
22820 |
|
22821 |
|
22822 |
|
22823 |
|
22824 |
|
22825 |
|
22826 |
|
22827 |
|
22828 |
|
22829 | Graph3d.prototype._drawGridLine = function (ctx, from, to) {
|
22830 | if (from === undefined || to === undefined) {
|
22831 | return;
|
22832 | }
|
22833 |
|
22834 |
|
22835 | var zAvg = (from.point.z + to.point.z) / 2;
|
22836 | var h = (1 - (zAvg - this.zRange.min) * this.scale.z / this.verticalRatio) * 240;
|
22837 | ctx.lineWidth = this._getStrokeWidth(from) * 2;
|
22838 | ctx.strokeStyle = this._hsv2rgb(h, 1, 1);
|
22839 |
|
22840 | this._line(ctx, from.screen, to.screen);
|
22841 | };
|
22842 |
|
22843 |
|
22844 |
|
22845 |
|
22846 |
|
22847 |
|
22848 |
|
22849 |
|
22850 |
|
22851 | Graph3d.prototype._redrawGridGraphPoint = function (ctx, point) {
|
22852 | this._drawGridLine(ctx, point, point.pointRight);
|
22853 |
|
22854 | this._drawGridLine(ctx, point, point.pointTop);
|
22855 | };
|
22856 |
|
22857 |
|
22858 |
|
22859 |
|
22860 |
|
22861 |
|
22862 |
|
22863 |
|
22864 |
|
22865 | Graph3d.prototype._redrawLineGraphPoint = function (ctx, point) {
|
22866 | if (point.pointNext === undefined) {
|
22867 | return;
|
22868 | }
|
22869 |
|
22870 | ctx.lineWidth = this._getStrokeWidth(point);
|
22871 | ctx.strokeStyle = this.dataColor.stroke;
|
22872 |
|
22873 | this._line(ctx, point.screen, point.pointNext.screen);
|
22874 | };
|
22875 |
|
22876 |
|
22877 |
|
22878 |
|
22879 |
|
22880 |
|
22881 | Graph3d.prototype._redrawDataGraph = function () {
|
22882 | var ctx = this._getContext();
|
22883 |
|
22884 | var i;
|
22885 | if (this.dataPoints === undefined || this.dataPoints.length <= 0) return;
|
22886 |
|
22887 | this._calcTranslations(this.dataPoints);
|
22888 |
|
22889 | for (i = 0; i < this.dataPoints.length; i++) {
|
22890 | var point = this.dataPoints[i];
|
22891 |
|
22892 | this._pointDrawingMethod.call(this, ctx, point);
|
22893 | }
|
22894 | };
|
22895 |
|
22896 |
|
22897 |
|
22898 |
|
22899 |
|
22900 |
|
22901 |
|
22902 |
|
22903 |
|
22904 |
|
22905 | Graph3d.prototype._storeMousePosition = function (event) {
|
22906 |
|
22907 | this.startMouseX = getMouseX(event);
|
22908 | this.startMouseY = getMouseY(event);
|
22909 | this._startCameraOffset = this.camera.getOffset();
|
22910 | };
|
22911 |
|
22912 |
|
22913 |
|
22914 |
|
22915 |
|
22916 |
|
22917 |
|
22918 | Graph3d.prototype._onMouseDown = function (event) {
|
22919 | event = event || window.event;
|
22920 |
|
22921 |
|
22922 | if (this.leftButtonDown) {
|
22923 | this._onMouseUp(event);
|
22924 | }
|
22925 |
|
22926 |
|
22927 | this.leftButtonDown = event.which ? event.which === 1 : event.button === 1;
|
22928 | if (!this.leftButtonDown && !this.touchDown) return;
|
22929 |
|
22930 | this._storeMousePosition(event);
|
22931 |
|
22932 | this.startStart = new Date(this.start);
|
22933 | this.startEnd = new Date(this.end);
|
22934 | this.startArmRotation = this.camera.getArmRotation();
|
22935 | this.frame.style.cursor = 'move';
|
22936 |
|
22937 |
|
22938 |
|
22939 | var me = this;
|
22940 |
|
22941 | this.onmousemove = function (event) {
|
22942 | me._onMouseMove(event);
|
22943 | };
|
22944 |
|
22945 | this.onmouseup = function (event) {
|
22946 | me._onMouseUp(event);
|
22947 | };
|
22948 |
|
22949 | util.addEventListener(document, 'mousemove', me.onmousemove);
|
22950 | util.addEventListener(document, 'mouseup', me.onmouseup);
|
22951 | util.preventDefault(event);
|
22952 | };
|
22953 |
|
22954 |
|
22955 |
|
22956 |
|
22957 |
|
22958 |
|
22959 |
|
22960 | Graph3d.prototype._onMouseMove = function (event) {
|
22961 | this.moving = true;
|
22962 | event = event || window.event;
|
22963 |
|
22964 | var diffX = parseFloat(getMouseX(event)) - this.startMouseX;
|
22965 | var diffY = parseFloat(getMouseY(event)) - this.startMouseY;
|
22966 |
|
22967 | if (event && event.ctrlKey === true) {
|
22968 |
|
22969 | var scaleX = this.frame.clientWidth * 0.5;
|
22970 | var scaleY = this.frame.clientHeight * 0.5;
|
22971 | var offXNew = (this._startCameraOffset.x || 0) - diffX / scaleX * this.camera.armLength * 0.8;
|
22972 | var offYNew = (this._startCameraOffset.y || 0) + diffY / scaleY * this.camera.armLength * 0.8;
|
22973 | this.camera.setOffset(offXNew, offYNew);
|
22974 |
|
22975 | this._storeMousePosition(event);
|
22976 | } else {
|
22977 | var horizontalNew = this.startArmRotation.horizontal + diffX / 200;
|
22978 | var verticalNew = this.startArmRotation.vertical + diffY / 200;
|
22979 | var snapAngle = 4;
|
22980 |
|
22981 | var snapValue = Math.sin(snapAngle / 360 * 2 * Math.PI);
|
22982 |
|
22983 |
|
22984 | if (Math.abs(Math.sin(horizontalNew)) < snapValue) {
|
22985 | horizontalNew = Math.round(horizontalNew / Math.PI) * Math.PI - 0.001;
|
22986 | }
|
22987 |
|
22988 | if (Math.abs(Math.cos(horizontalNew)) < snapValue) {
|
22989 | horizontalNew = (Math.round(horizontalNew / Math.PI - 0.5) + 0.5) * Math.PI - 0.001;
|
22990 | }
|
22991 |
|
22992 |
|
22993 | if (Math.abs(Math.sin(verticalNew)) < snapValue) {
|
22994 | verticalNew = Math.round(verticalNew / Math.PI) * Math.PI;
|
22995 | }
|
22996 |
|
22997 | if (Math.abs(Math.cos(verticalNew)) < snapValue) {
|
22998 | verticalNew = (Math.round(verticalNew / Math.PI - 0.5) + 0.5) * Math.PI;
|
22999 | }
|
23000 |
|
23001 | this.camera.setArmRotation(horizontalNew, verticalNew);
|
23002 | }
|
23003 |
|
23004 | this.redraw();
|
23005 |
|
23006 | var parameters = this.getCameraPosition();
|
23007 | this.emit('cameraPositionChange', parameters);
|
23008 | util.preventDefault(event);
|
23009 | };
|
23010 |
|
23011 |
|
23012 |
|
23013 |
|
23014 |
|
23015 |
|
23016 |
|
23017 | Graph3d.prototype._onMouseUp = function (event) {
|
23018 | this.frame.style.cursor = 'auto';
|
23019 | this.leftButtonDown = false;
|
23020 |
|
23021 | util.removeEventListener(document, 'mousemove', this.onmousemove);
|
23022 | util.removeEventListener(document, 'mouseup', this.onmouseup);
|
23023 | util.preventDefault(event);
|
23024 | };
|
23025 |
|
23026 |
|
23027 |
|
23028 |
|
23029 |
|
23030 | Graph3d.prototype._onClick = function (event) {
|
23031 | if (!this.onclick_callback) return;
|
23032 |
|
23033 | if (!this.moving) {
|
23034 | var boundingRect = this.frame.getBoundingClientRect();
|
23035 | var mouseX = getMouseX(event) - boundingRect.left;
|
23036 | var mouseY = getMouseY(event) - boundingRect.top;
|
23037 |
|
23038 | var dataPoint = this._dataPointFromXY(mouseX, mouseY);
|
23039 |
|
23040 | if (dataPoint) this.onclick_callback(dataPoint.point.data);
|
23041 | } else {
|
23042 |
|
23043 | this.moving = false;
|
23044 | }
|
23045 |
|
23046 | util.preventDefault(event);
|
23047 | };
|
23048 |
|
23049 |
|
23050 |
|
23051 |
|
23052 |
|
23053 |
|
23054 | Graph3d.prototype._onTooltip = function (event) {
|
23055 | var delay = this.tooltipDelay;
|
23056 |
|
23057 | var boundingRect = this.frame.getBoundingClientRect();
|
23058 | var mouseX = getMouseX(event) - boundingRect.left;
|
23059 | var mouseY = getMouseY(event) - boundingRect.top;
|
23060 |
|
23061 | if (!this.showTooltip) {
|
23062 | return;
|
23063 | }
|
23064 |
|
23065 | if (this.tooltipTimeout) {
|
23066 | clearTimeout(this.tooltipTimeout);
|
23067 | }
|
23068 |
|
23069 |
|
23070 | if (this.leftButtonDown) {
|
23071 | this._hideTooltip();
|
23072 |
|
23073 | return;
|
23074 | }
|
23075 |
|
23076 | if (this.tooltip && this.tooltip.dataPoint) {
|
23077 |
|
23078 | var dataPoint = this._dataPointFromXY(mouseX, mouseY);
|
23079 |
|
23080 | if (dataPoint !== this.tooltip.dataPoint) {
|
23081 |
|
23082 | if (dataPoint) {
|
23083 | this._showTooltip(dataPoint);
|
23084 | } else {
|
23085 | this._hideTooltip();
|
23086 | }
|
23087 | }
|
23088 | } else {
|
23089 |
|
23090 | var me = this;
|
23091 | this.tooltipTimeout = setTimeout(function () {
|
23092 | me.tooltipTimeout = null;
|
23093 |
|
23094 | var dataPoint = me._dataPointFromXY(mouseX, mouseY);
|
23095 |
|
23096 | if (dataPoint) {
|
23097 | me._showTooltip(dataPoint);
|
23098 | }
|
23099 | }, delay);
|
23100 | }
|
23101 | };
|
23102 |
|
23103 |
|
23104 |
|
23105 |
|
23106 |
|
23107 |
|
23108 | Graph3d.prototype._onTouchStart = function (event) {
|
23109 | this.touchDown = true;
|
23110 | var me = this;
|
23111 |
|
23112 | this.ontouchmove = function (event) {
|
23113 | me._onTouchMove(event);
|
23114 | };
|
23115 |
|
23116 | this.ontouchend = function (event) {
|
23117 | me._onTouchEnd(event);
|
23118 | };
|
23119 |
|
23120 | util.addEventListener(document, 'touchmove', me.ontouchmove);
|
23121 | util.addEventListener(document, 'touchend', me.ontouchend);
|
23122 |
|
23123 | this._onMouseDown(event);
|
23124 | };
|
23125 |
|
23126 |
|
23127 |
|
23128 |
|
23129 |
|
23130 |
|
23131 | Graph3d.prototype._onTouchMove = function (event) {
|
23132 | this._onMouseMove(event);
|
23133 | };
|
23134 |
|
23135 |
|
23136 |
|
23137 |
|
23138 |
|
23139 |
|
23140 | Graph3d.prototype._onTouchEnd = function (event) {
|
23141 | this.touchDown = false;
|
23142 | util.removeEventListener(document, 'touchmove', this.ontouchmove);
|
23143 | util.removeEventListener(document, 'touchend', this.ontouchend);
|
23144 |
|
23145 | this._onMouseUp(event);
|
23146 | };
|
23147 |
|
23148 |
|
23149 |
|
23150 |
|
23151 |
|
23152 |
|
23153 |
|
23154 | Graph3d.prototype._onWheel = function (event) {
|
23155 | if (!event)
|
23156 |
|
23157 | event = window.event;
|
23158 |
|
23159 | if (this.zoomable && (!this.ctrlToZoom || event.ctrlKey)) {
|
23160 |
|
23161 | var delta = 0;
|
23162 |
|
23163 | if (event.wheelDelta) {
|
23164 |
|
23165 | delta = event.wheelDelta / 120;
|
23166 | } else if (event.detail) {
|
23167 |
|
23168 |
|
23169 |
|
23170 | delta = -event.detail / 3;
|
23171 | }
|
23172 |
|
23173 |
|
23174 |
|
23175 |
|
23176 | if (delta) {
|
23177 | var oldLength = this.camera.getArmLength();
|
23178 | var newLength = oldLength * (1 - delta / 10);
|
23179 | this.camera.setArmLength(newLength);
|
23180 | this.redraw();
|
23181 |
|
23182 | this._hideTooltip();
|
23183 | }
|
23184 |
|
23185 |
|
23186 | var parameters = this.getCameraPosition();
|
23187 | this.emit('cameraPositionChange', parameters);
|
23188 |
|
23189 |
|
23190 |
|
23191 | util.preventDefault(event);
|
23192 | }
|
23193 | };
|
23194 |
|
23195 |
|
23196 |
|
23197 |
|
23198 |
|
23199 |
|
23200 |
|
23201 |
|
23202 |
|
23203 |
|
23204 |
|
23205 | Graph3d.prototype._insideTriangle = function (point, triangle) {
|
23206 | var a = triangle[0],
|
23207 | b = triangle[1],
|
23208 | c = triangle[2];
|
23209 | |
23210 |
|
23211 |
|
23212 |
|
23213 |
|
23214 |
|
23215 | function sign(x) {
|
23216 | return x > 0 ? 1 : x < 0 ? -1 : 0;
|
23217 | }
|
23218 |
|
23219 | var as = sign((b.x - a.x) * (point.y - a.y) - (b.y - a.y) * (point.x - a.x));
|
23220 | var bs = sign((c.x - b.x) * (point.y - b.y) - (c.y - b.y) * (point.x - b.x));
|
23221 | var cs = sign((a.x - c.x) * (point.y - c.y) - (a.y - c.y) * (point.x - c.x));
|
23222 |
|
23223 | return (as == 0 || bs == 0 || as == bs) && (bs == 0 || cs == 0 || bs == cs) && (as == 0 || cs == 0 || as == cs);
|
23224 | };
|
23225 |
|
23226 |
|
23227 |
|
23228 |
|
23229 |
|
23230 |
|
23231 |
|
23232 |
|
23233 |
|
23234 |
|
23235 |
|
23236 | Graph3d.prototype._dataPointFromXY = function (x, y) {
|
23237 | var i,
|
23238 | distMax = 100,
|
23239 |
|
23240 | dataPoint = null,
|
23241 | closestDataPoint = null,
|
23242 | closestDist = null,
|
23243 | center = new Point2d_1(x, y);
|
23244 |
|
23245 | if (this.style === Graph3d.STYLE.BAR || this.style === Graph3d.STYLE.BARCOLOR || this.style === Graph3d.STYLE.BARSIZE) {
|
23246 |
|
23247 | for (i = this.dataPoints.length - 1; i >= 0; i--) {
|
23248 | dataPoint = this.dataPoints[i];
|
23249 | var surfaces = dataPoint.surfaces;
|
23250 |
|
23251 | if (surfaces) {
|
23252 | for (var s = surfaces.length - 1; s >= 0; s--) {
|
23253 |
|
23254 | var surface = surfaces[s];
|
23255 | var corners = surface.corners;
|
23256 | var triangle1 = [corners[0].screen, corners[1].screen, corners[2].screen];
|
23257 | var triangle2 = [corners[2].screen, corners[3].screen, corners[0].screen];
|
23258 |
|
23259 | if (this._insideTriangle(center, triangle1) || this._insideTriangle(center, triangle2)) {
|
23260 |
|
23261 | return dataPoint;
|
23262 | }
|
23263 | }
|
23264 | }
|
23265 | }
|
23266 | } else {
|
23267 |
|
23268 | for (i = 0; i < this.dataPoints.length; i++) {
|
23269 | dataPoint = this.dataPoints[i];
|
23270 | var point = dataPoint.screen;
|
23271 |
|
23272 | if (point) {
|
23273 | var distX = Math.abs(x - point.x);
|
23274 | var distY = Math.abs(y - point.y);
|
23275 | var dist = Math.sqrt(distX * distX + distY * distY);
|
23276 |
|
23277 | if ((closestDist === null || dist < closestDist) && dist < distMax) {
|
23278 | closestDist = dist;
|
23279 | closestDataPoint = dataPoint;
|
23280 | }
|
23281 | }
|
23282 | }
|
23283 | }
|
23284 |
|
23285 | return closestDataPoint;
|
23286 | };
|
23287 |
|
23288 |
|
23289 |
|
23290 |
|
23291 |
|
23292 |
|
23293 |
|
23294 |
|
23295 | Graph3d.prototype.hasBars = function (style) {
|
23296 | return style == Graph3d.STYLE.BAR || style == Graph3d.STYLE.BARCOLOR || style == Graph3d.STYLE.BARSIZE;
|
23297 | };
|
23298 |
|
23299 |
|
23300 |
|
23301 |
|
23302 |
|
23303 |
|
23304 |
|
23305 | Graph3d.prototype._showTooltip = function (dataPoint) {
|
23306 | var content, line, dot;
|
23307 |
|
23308 | if (!this.tooltip) {
|
23309 | content = document.createElement('div');
|
23310 | Object.assign(content.style, {}, this.tooltipStyle.content);
|
23311 | content.style.position = 'absolute';
|
23312 | line = document.createElement('div');
|
23313 | Object.assign(line.style, {}, this.tooltipStyle.line);
|
23314 | line.style.position = 'absolute';
|
23315 | dot = document.createElement('div');
|
23316 | Object.assign(dot.style, {}, this.tooltipStyle.dot);
|
23317 | dot.style.position = 'absolute';
|
23318 | this.tooltip = {
|
23319 | dataPoint: null,
|
23320 | dom: {
|
23321 | content: content,
|
23322 | line: line,
|
23323 | dot: dot
|
23324 | }
|
23325 | };
|
23326 | } else {
|
23327 | content = this.tooltip.dom.content;
|
23328 | line = this.tooltip.dom.line;
|
23329 | dot = this.tooltip.dom.dot;
|
23330 | }
|
23331 |
|
23332 | this._hideTooltip();
|
23333 |
|
23334 | this.tooltip.dataPoint = dataPoint;
|
23335 |
|
23336 | if (typeof this.showTooltip === 'function') {
|
23337 | content.innerHTML = this.showTooltip(dataPoint.point);
|
23338 | } else {
|
23339 | content.innerHTML = '<table>' + '<tr><td>' + this.xLabel + ':</td><td>' + dataPoint.point.x + '</td></tr>' + '<tr><td>' + this.yLabel + ':</td><td>' + dataPoint.point.y + '</td></tr>' + '<tr><td>' + this.zLabel + ':</td><td>' + dataPoint.point.z + '</td></tr>' + '</table>';
|
23340 | }
|
23341 |
|
23342 | content.style.left = '0';
|
23343 | content.style.top = '0';
|
23344 | this.frame.appendChild(content);
|
23345 | this.frame.appendChild(line);
|
23346 | this.frame.appendChild(dot);
|
23347 |
|
23348 | var contentWidth = content.offsetWidth;
|
23349 | var contentHeight = content.offsetHeight;
|
23350 | var lineHeight = line.offsetHeight;
|
23351 | var dotWidth = dot.offsetWidth;
|
23352 | var dotHeight = dot.offsetHeight;
|
23353 | var left = dataPoint.screen.x - contentWidth / 2;
|
23354 | left = Math.min(Math.max(left, 10), this.frame.clientWidth - 10 - contentWidth);
|
23355 | line.style.left = dataPoint.screen.x + 'px';
|
23356 | line.style.top = dataPoint.screen.y - lineHeight + 'px';
|
23357 | content.style.left = left + 'px';
|
23358 | content.style.top = dataPoint.screen.y - lineHeight - contentHeight + 'px';
|
23359 | dot.style.left = dataPoint.screen.x - dotWidth / 2 + 'px';
|
23360 | dot.style.top = dataPoint.screen.y - dotHeight / 2 + 'px';
|
23361 | };
|
23362 |
|
23363 |
|
23364 |
|
23365 |
|
23366 |
|
23367 |
|
23368 | Graph3d.prototype._hideTooltip = function () {
|
23369 | if (this.tooltip) {
|
23370 | this.tooltip.dataPoint = null;
|
23371 |
|
23372 | for (var prop in this.tooltip.dom) {
|
23373 | if (this.tooltip.dom.hasOwnProperty(prop)) {
|
23374 | var elem = this.tooltip.dom[prop];
|
23375 |
|
23376 | if (elem && elem.parentNode) {
|
23377 | elem.parentNode.removeChild(elem);
|
23378 | }
|
23379 | }
|
23380 | }
|
23381 | }
|
23382 | };
|
23383 |
|
23384 |
|
23385 |
|
23386 |
|
23387 |
|
23388 |
|
23389 |
|
23390 |
|
23391 |
|
23392 |
|
23393 | function getMouseX(event) {
|
23394 | if ('clientX' in event) return event.clientX;
|
23395 | return event.targetTouches[0] && event.targetTouches[0].clientX || 0;
|
23396 | }
|
23397 |
|
23398 |
|
23399 |
|
23400 |
|
23401 |
|
23402 |
|
23403 |
|
23404 |
|
23405 | function getMouseY(event) {
|
23406 | if ('clientY' in event) return event.clientY;
|
23407 | return event.targetTouches[0] && event.targetTouches[0].clientY || 0;
|
23408 | }
|
23409 |
|
23410 |
|
23411 |
|
23412 |
|
23413 |
|
23414 |
|
23415 |
|
23416 |
|
23417 |
|
23418 |
|
23419 |
|
23420 |
|
23421 |
|
23422 |
|
23423 |
|
23424 |
|
23425 |
|
23426 |
|
23427 | Graph3d.prototype.setCameraPosition = function (pos) {
|
23428 | Settings.setCameraPosition(pos, this);
|
23429 | this.redraw();
|
23430 | };
|
23431 |
|
23432 |
|
23433 |
|
23434 |
|
23435 |
|
23436 |
|
23437 |
|
23438 |
|
23439 |
|
23440 |
|
23441 | Graph3d.prototype.setSize = function (width, height) {
|
23442 | this._setSize(width, height);
|
23443 |
|
23444 | this.redraw();
|
23445 | };
|
23446 |
|
23447 |
|
23448 |
|
23449 |
|
23450 | var Graph3d_1 = Graph3d;
|
23451 |
|
23452 | var moment$2 = createCommonjsModule$1(function (module, exports) {
|
23453 |
|
23454 | (function (global, factory) {
|
23455 | module.exports = factory() ;
|
23456 | })(commonjsGlobal$1, function () {
|
23457 |
|
23458 | var hookCallback;
|
23459 |
|
23460 | function hooks() {
|
23461 | return hookCallback.apply(null, arguments);
|
23462 | }
|
23463 |
|
23464 |
|
23465 |
|
23466 | function setHookCallback(callback) {
|
23467 | hookCallback = callback;
|
23468 | }
|
23469 |
|
23470 | function isArray(input) {
|
23471 | return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
|
23472 | }
|
23473 |
|
23474 | function isObject(input) {
|
23475 |
|
23476 |
|
23477 | return input != null && Object.prototype.toString.call(input) === '[object Object]';
|
23478 | }
|
23479 |
|
23480 | function isObjectEmpty(obj) {
|
23481 | if (Object.getOwnPropertyNames) {
|
23482 | return Object.getOwnPropertyNames(obj).length === 0;
|
23483 | } else {
|
23484 | var k;
|
23485 |
|
23486 | for (k in obj) {
|
23487 | if (obj.hasOwnProperty(k)) {
|
23488 | return false;
|
23489 | }
|
23490 | }
|
23491 |
|
23492 | return true;
|
23493 | }
|
23494 | }
|
23495 |
|
23496 | function isUndefined(input) {
|
23497 | return input === void 0;
|
23498 | }
|
23499 |
|
23500 | function isNumber(input) {
|
23501 | return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
|
23502 | }
|
23503 |
|
23504 | function isDate(input) {
|
23505 | return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
|
23506 | }
|
23507 |
|
23508 | function map(arr, fn) {
|
23509 | var res = [],
|
23510 | i;
|
23511 |
|
23512 | for (i = 0; i < arr.length; ++i) {
|
23513 | res.push(fn(arr[i], i));
|
23514 | }
|
23515 |
|
23516 | return res;
|
23517 | }
|
23518 |
|
23519 | function hasOwnProp(a, b) {
|
23520 | return Object.prototype.hasOwnProperty.call(a, b);
|
23521 | }
|
23522 |
|
23523 | function extend(a, b) {
|
23524 | for (var i in b) {
|
23525 | if (hasOwnProp(b, i)) {
|
23526 | a[i] = b[i];
|
23527 | }
|
23528 | }
|
23529 |
|
23530 | if (hasOwnProp(b, 'toString')) {
|
23531 | a.toString = b.toString;
|
23532 | }
|
23533 |
|
23534 | if (hasOwnProp(b, 'valueOf')) {
|
23535 | a.valueOf = b.valueOf;
|
23536 | }
|
23537 |
|
23538 | return a;
|
23539 | }
|
23540 |
|
23541 | function createUTC(input, format, locale, strict) {
|
23542 | return createLocalOrUTC(input, format, locale, strict, true).utc();
|
23543 | }
|
23544 |
|
23545 | function defaultParsingFlags() {
|
23546 |
|
23547 | return {
|
23548 | empty: false,
|
23549 | unusedTokens: [],
|
23550 | unusedInput: [],
|
23551 | overflow: -2,
|
23552 | charsLeftOver: 0,
|
23553 | nullInput: false,
|
23554 | invalidMonth: null,
|
23555 | invalidFormat: false,
|
23556 | userInvalidated: false,
|
23557 | iso: false,
|
23558 | parsedDateParts: [],
|
23559 | meridiem: null,
|
23560 | rfc2822: false,
|
23561 | weekdayMismatch: false
|
23562 | };
|
23563 | }
|
23564 |
|
23565 | function getParsingFlags(m) {
|
23566 | if (m._pf == null) {
|
23567 | m._pf = defaultParsingFlags();
|
23568 | }
|
23569 |
|
23570 | return m._pf;
|
23571 | }
|
23572 |
|
23573 | var some;
|
23574 |
|
23575 | if (Array.prototype.some) {
|
23576 | some = Array.prototype.some;
|
23577 | } else {
|
23578 | some = function (fun) {
|
23579 | var t = Object(this);
|
23580 | var len = t.length >>> 0;
|
23581 |
|
23582 | for (var i = 0; i < len; i++) {
|
23583 | if (i in t && fun.call(this, t[i], i, t)) {
|
23584 | return true;
|
23585 | }
|
23586 | }
|
23587 |
|
23588 | return false;
|
23589 | };
|
23590 | }
|
23591 |
|
23592 | function isValid(m) {
|
23593 | if (m._isValid == null) {
|
23594 | var flags = getParsingFlags(m);
|
23595 | var parsedParts = some.call(flags.parsedDateParts, function (i) {
|
23596 | return i != null;
|
23597 | });
|
23598 | var isNowValid = !isNaN(m._d.getTime()) && flags.overflow < 0 && !flags.empty && !flags.invalidMonth && !flags.invalidWeekday && !flags.weekdayMismatch && !flags.nullInput && !flags.invalidFormat && !flags.userInvalidated && (!flags.meridiem || flags.meridiem && parsedParts);
|
23599 |
|
23600 | if (m._strict) {
|
23601 | isNowValid = isNowValid && flags.charsLeftOver === 0 && flags.unusedTokens.length === 0 && flags.bigHour === undefined;
|
23602 | }
|
23603 |
|
23604 | if (Object.isFrozen == null || !Object.isFrozen(m)) {
|
23605 | m._isValid = isNowValid;
|
23606 | } else {
|
23607 | return isNowValid;
|
23608 | }
|
23609 | }
|
23610 |
|
23611 | return m._isValid;
|
23612 | }
|
23613 |
|
23614 | function createInvalid(flags) {
|
23615 | var m = createUTC(NaN);
|
23616 |
|
23617 | if (flags != null) {
|
23618 | extend(getParsingFlags(m), flags);
|
23619 | } else {
|
23620 | getParsingFlags(m).userInvalidated = true;
|
23621 | }
|
23622 |
|
23623 | return m;
|
23624 | }
|
23625 |
|
23626 |
|
23627 |
|
23628 | var momentProperties = hooks.momentProperties = [];
|
23629 |
|
23630 | function copyConfig(to, from) {
|
23631 | var i, prop, val;
|
23632 |
|
23633 | if (!isUndefined(from._isAMomentObject)) {
|
23634 | to._isAMomentObject = from._isAMomentObject;
|
23635 | }
|
23636 |
|
23637 | if (!isUndefined(from._i)) {
|
23638 | to._i = from._i;
|
23639 | }
|
23640 |
|
23641 | if (!isUndefined(from._f)) {
|
23642 | to._f = from._f;
|
23643 | }
|
23644 |
|
23645 | if (!isUndefined(from._l)) {
|
23646 | to._l = from._l;
|
23647 | }
|
23648 |
|
23649 | if (!isUndefined(from._strict)) {
|
23650 | to._strict = from._strict;
|
23651 | }
|
23652 |
|
23653 | if (!isUndefined(from._tzm)) {
|
23654 | to._tzm = from._tzm;
|
23655 | }
|
23656 |
|
23657 | if (!isUndefined(from._isUTC)) {
|
23658 | to._isUTC = from._isUTC;
|
23659 | }
|
23660 |
|
23661 | if (!isUndefined(from._offset)) {
|
23662 | to._offset = from._offset;
|
23663 | }
|
23664 |
|
23665 | if (!isUndefined(from._pf)) {
|
23666 | to._pf = getParsingFlags(from);
|
23667 | }
|
23668 |
|
23669 | if (!isUndefined(from._locale)) {
|
23670 | to._locale = from._locale;
|
23671 | }
|
23672 |
|
23673 | if (momentProperties.length > 0) {
|
23674 | for (i = 0; i < momentProperties.length; i++) {
|
23675 | prop = momentProperties[i];
|
23676 | val = from[prop];
|
23677 |
|
23678 | if (!isUndefined(val)) {
|
23679 | to[prop] = val;
|
23680 | }
|
23681 | }
|
23682 | }
|
23683 |
|
23684 | return to;
|
23685 | }
|
23686 |
|
23687 | var updateInProgress = false;
|
23688 |
|
23689 | function Moment(config) {
|
23690 | copyConfig(this, config);
|
23691 | this._d = new Date(config._d != null ? config._d.getTime() : NaN);
|
23692 |
|
23693 | if (!this.isValid()) {
|
23694 | this._d = new Date(NaN);
|
23695 | }
|
23696 |
|
23697 |
|
23698 |
|
23699 | if (updateInProgress === false) {
|
23700 | updateInProgress = true;
|
23701 | hooks.updateOffset(this);
|
23702 | updateInProgress = false;
|
23703 | }
|
23704 | }
|
23705 |
|
23706 | function isMoment(obj) {
|
23707 | return obj instanceof Moment || obj != null && obj._isAMomentObject != null;
|
23708 | }
|
23709 |
|
23710 | function absFloor(number) {
|
23711 | if (number < 0) {
|
23712 |
|
23713 | return Math.ceil(number) || 0;
|
23714 | } else {
|
23715 | return Math.floor(number);
|
23716 | }
|
23717 | }
|
23718 |
|
23719 | function toInt(argumentForCoercion) {
|
23720 | var coercedNumber = +argumentForCoercion,
|
23721 | value = 0;
|
23722 |
|
23723 | if (coercedNumber !== 0 && isFinite(coercedNumber)) {
|
23724 | value = absFloor(coercedNumber);
|
23725 | }
|
23726 |
|
23727 | return value;
|
23728 | }
|
23729 |
|
23730 |
|
23731 | function compareArrays(array1, array2, dontConvert) {
|
23732 | var len = Math.min(array1.length, array2.length),
|
23733 | lengthDiff = Math.abs(array1.length - array2.length),
|
23734 | diffs = 0,
|
23735 | i;
|
23736 |
|
23737 | for (i = 0; i < len; i++) {
|
23738 | if (dontConvert && array1[i] !== array2[i] || !dontConvert && toInt(array1[i]) !== toInt(array2[i])) {
|
23739 | diffs++;
|
23740 | }
|
23741 | }
|
23742 |
|
23743 | return diffs + lengthDiff;
|
23744 | }
|
23745 |
|
23746 | function warn(msg) {
|
23747 | if (hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
|
23748 | console.warn('Deprecation warning: ' + msg);
|
23749 | }
|
23750 | }
|
23751 |
|
23752 | function deprecate(msg, fn) {
|
23753 | var firstTime = true;
|
23754 | return extend(function () {
|
23755 | if (hooks.deprecationHandler != null) {
|
23756 | hooks.deprecationHandler(null, msg);
|
23757 | }
|
23758 |
|
23759 | if (firstTime) {
|
23760 | var args = [];
|
23761 | var arg;
|
23762 |
|
23763 | for (var i = 0; i < arguments.length; i++) {
|
23764 | arg = '';
|
23765 |
|
23766 | if (typeof arguments[i] === 'object') {
|
23767 | arg += '\n[' + i + '] ';
|
23768 |
|
23769 | for (var key in arguments[0]) {
|
23770 | arg += key + ': ' + arguments[0][key] + ', ';
|
23771 | }
|
23772 |
|
23773 | arg = arg.slice(0, -2);
|
23774 | } else {
|
23775 | arg = arguments[i];
|
23776 | }
|
23777 |
|
23778 | args.push(arg);
|
23779 | }
|
23780 |
|
23781 | warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + new Error().stack);
|
23782 | firstTime = false;
|
23783 | }
|
23784 |
|
23785 | return fn.apply(this, arguments);
|
23786 | }, fn);
|
23787 | }
|
23788 |
|
23789 | var deprecations = {};
|
23790 |
|
23791 | function deprecateSimple(name, msg) {
|
23792 | if (hooks.deprecationHandler != null) {
|
23793 | hooks.deprecationHandler(name, msg);
|
23794 | }
|
23795 |
|
23796 | if (!deprecations[name]) {
|
23797 | warn(msg);
|
23798 | deprecations[name] = true;
|
23799 | }
|
23800 | }
|
23801 |
|
23802 | hooks.suppressDeprecationWarnings = false;
|
23803 | hooks.deprecationHandler = null;
|
23804 |
|
23805 | function isFunction(input) {
|
23806 | return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
|
23807 | }
|
23808 |
|
23809 | function set(config) {
|
23810 | var prop, i;
|
23811 |
|
23812 | for (i in config) {
|
23813 | prop = config[i];
|
23814 |
|
23815 | if (isFunction(prop)) {
|
23816 | this[i] = prop;
|
23817 | } else {
|
23818 | this['_' + i] = prop;
|
23819 | }
|
23820 | }
|
23821 |
|
23822 | this._config = config;
|
23823 |
|
23824 |
|
23825 |
|
23826 | this._dayOfMonthOrdinalParseLenient = new RegExp((this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + '|' + /\d{1,2}/.source);
|
23827 | }
|
23828 |
|
23829 | function mergeConfigs(parentConfig, childConfig) {
|
23830 | var res = extend({}, parentConfig),
|
23831 | prop;
|
23832 |
|
23833 | for (prop in childConfig) {
|
23834 | if (hasOwnProp(childConfig, prop)) {
|
23835 | if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
|
23836 | res[prop] = {};
|
23837 | extend(res[prop], parentConfig[prop]);
|
23838 | extend(res[prop], childConfig[prop]);
|
23839 | } else if (childConfig[prop] != null) {
|
23840 | res[prop] = childConfig[prop];
|
23841 | } else {
|
23842 | delete res[prop];
|
23843 | }
|
23844 | }
|
23845 | }
|
23846 |
|
23847 | for (prop in parentConfig) {
|
23848 | if (hasOwnProp(parentConfig, prop) && !hasOwnProp(childConfig, prop) && isObject(parentConfig[prop])) {
|
23849 |
|
23850 | res[prop] = extend({}, res[prop]);
|
23851 | }
|
23852 | }
|
23853 |
|
23854 | return res;
|
23855 | }
|
23856 |
|
23857 | function Locale(config) {
|
23858 | if (config != null) {
|
23859 | this.set(config);
|
23860 | }
|
23861 | }
|
23862 |
|
23863 | var keys;
|
23864 |
|
23865 | if (Object.keys) {
|
23866 | keys = Object.keys;
|
23867 | } else {
|
23868 | keys = function (obj) {
|
23869 | var i,
|
23870 | res = [];
|
23871 |
|
23872 | for (i in obj) {
|
23873 | if (hasOwnProp(obj, i)) {
|
23874 | res.push(i);
|
23875 | }
|
23876 | }
|
23877 |
|
23878 | return res;
|
23879 | };
|
23880 | }
|
23881 |
|
23882 | var defaultCalendar = {
|
23883 | sameDay: '[Today at] LT',
|
23884 | nextDay: '[Tomorrow at] LT',
|
23885 | nextWeek: 'dddd [at] LT',
|
23886 | lastDay: '[Yesterday at] LT',
|
23887 | lastWeek: '[Last] dddd [at] LT',
|
23888 | sameElse: 'L'
|
23889 | };
|
23890 |
|
23891 | function calendar(key, mom, now) {
|
23892 | var output = this._calendar[key] || this._calendar['sameElse'];
|
23893 | return isFunction(output) ? output.call(mom, now) : output;
|
23894 | }
|
23895 |
|
23896 | var defaultLongDateFormat = {
|
23897 | LTS: 'h:mm:ss A',
|
23898 | LT: 'h:mm A',
|
23899 | L: 'MM/DD/YYYY',
|
23900 | LL: 'MMMM D, YYYY',
|
23901 | LLL: 'MMMM D, YYYY h:mm A',
|
23902 | LLLL: 'dddd, MMMM D, YYYY h:mm A'
|
23903 | };
|
23904 |
|
23905 | function longDateFormat(key) {
|
23906 | var format = this._longDateFormat[key],
|
23907 | formatUpper = this._longDateFormat[key.toUpperCase()];
|
23908 |
|
23909 | if (format || !formatUpper) {
|
23910 | return format;
|
23911 | }
|
23912 |
|
23913 | this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
|
23914 | return val.slice(1);
|
23915 | });
|
23916 | return this._longDateFormat[key];
|
23917 | }
|
23918 |
|
23919 | var defaultInvalidDate = 'Invalid date';
|
23920 |
|
23921 | function invalidDate() {
|
23922 | return this._invalidDate;
|
23923 | }
|
23924 |
|
23925 | var defaultOrdinal = '%d';
|
23926 | var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
|
23927 |
|
23928 | function ordinal(number) {
|
23929 | return this._ordinal.replace('%d', number);
|
23930 | }
|
23931 |
|
23932 | var defaultRelativeTime = {
|
23933 | future: 'in %s',
|
23934 | past: '%s ago',
|
23935 | s: 'a few seconds',
|
23936 | ss: '%d seconds',
|
23937 | m: 'a minute',
|
23938 | mm: '%d minutes',
|
23939 | h: 'an hour',
|
23940 | hh: '%d hours',
|
23941 | d: 'a day',
|
23942 | dd: '%d days',
|
23943 | M: 'a month',
|
23944 | MM: '%d months',
|
23945 | y: 'a year',
|
23946 | yy: '%d years'
|
23947 | };
|
23948 |
|
23949 | function relativeTime(number, withoutSuffix, string, isFuture) {
|
23950 | var output = this._relativeTime[string];
|
23951 | return isFunction(output) ? output(number, withoutSuffix, string, isFuture) : output.replace(/%d/i, number);
|
23952 | }
|
23953 |
|
23954 | function pastFuture(diff, output) {
|
23955 | var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
|
23956 | return isFunction(format) ? format(output) : format.replace(/%s/i, output);
|
23957 | }
|
23958 |
|
23959 | var aliases = {};
|
23960 |
|
23961 | function addUnitAlias(unit, shorthand) {
|
23962 | var lowerCase = unit.toLowerCase();
|
23963 | aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
|
23964 | }
|
23965 |
|
23966 | function normalizeUnits(units) {
|
23967 | return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
|
23968 | }
|
23969 |
|
23970 | function normalizeObjectUnits(inputObject) {
|
23971 | var normalizedInput = {},
|
23972 | normalizedProp,
|
23973 | prop;
|
23974 |
|
23975 | for (prop in inputObject) {
|
23976 | if (hasOwnProp(inputObject, prop)) {
|
23977 | normalizedProp = normalizeUnits(prop);
|
23978 |
|
23979 | if (normalizedProp) {
|
23980 | normalizedInput[normalizedProp] = inputObject[prop];
|
23981 | }
|
23982 | }
|
23983 | }
|
23984 |
|
23985 | return normalizedInput;
|
23986 | }
|
23987 |
|
23988 | var priorities = {};
|
23989 |
|
23990 | function addUnitPriority(unit, priority) {
|
23991 | priorities[unit] = priority;
|
23992 | }
|
23993 |
|
23994 | function getPrioritizedUnits(unitsObj) {
|
23995 | var units = [];
|
23996 |
|
23997 | for (var u in unitsObj) {
|
23998 | units.push({
|
23999 | unit: u,
|
24000 | priority: priorities[u]
|
24001 | });
|
24002 | }
|
24003 |
|
24004 | units.sort(function (a, b) {
|
24005 | return a.priority - b.priority;
|
24006 | });
|
24007 | return units;
|
24008 | }
|
24009 |
|
24010 | function zeroFill(number, targetLength, forceSign) {
|
24011 | var absNumber = '' + Math.abs(number),
|
24012 | zerosToFill = targetLength - absNumber.length,
|
24013 | sign = number >= 0;
|
24014 | return (sign ? forceSign ? '+' : '' : '-') + Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
|
24015 | }
|
24016 |
|
24017 | 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;
|
24018 | var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
|
24019 | var formatFunctions = {};
|
24020 | var formatTokenFunctions = {};
|
24021 |
|
24022 |
|
24023 |
|
24024 |
|
24025 | function addFormatToken(token, padded, ordinal, callback) {
|
24026 | var func = callback;
|
24027 |
|
24028 | if (typeof callback === 'string') {
|
24029 | func = function () {
|
24030 | return this[callback]();
|
24031 | };
|
24032 | }
|
24033 |
|
24034 | if (token) {
|
24035 | formatTokenFunctions[token] = func;
|
24036 | }
|
24037 |
|
24038 | if (padded) {
|
24039 | formatTokenFunctions[padded[0]] = function () {
|
24040 | return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
|
24041 | };
|
24042 | }
|
24043 |
|
24044 | if (ordinal) {
|
24045 | formatTokenFunctions[ordinal] = function () {
|
24046 | return this.localeData().ordinal(func.apply(this, arguments), token);
|
24047 | };
|
24048 | }
|
24049 | }
|
24050 |
|
24051 | function removeFormattingTokens(input) {
|
24052 | if (input.match(/\[[\s\S]/)) {
|
24053 | return input.replace(/^\[|\]$/g, '');
|
24054 | }
|
24055 |
|
24056 | return input.replace(/\\/g, '');
|
24057 | }
|
24058 |
|
24059 | function makeFormatFunction(format) {
|
24060 | var array = format.match(formattingTokens),
|
24061 | i,
|
24062 | length;
|
24063 |
|
24064 | for (i = 0, length = array.length; i < length; i++) {
|
24065 | if (formatTokenFunctions[array[i]]) {
|
24066 | array[i] = formatTokenFunctions[array[i]];
|
24067 | } else {
|
24068 | array[i] = removeFormattingTokens(array[i]);
|
24069 | }
|
24070 | }
|
24071 |
|
24072 | return function (mom) {
|
24073 | var output = '',
|
24074 | i;
|
24075 |
|
24076 | for (i = 0; i < length; i++) {
|
24077 | output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
|
24078 | }
|
24079 |
|
24080 | return output;
|
24081 | };
|
24082 | }
|
24083 |
|
24084 |
|
24085 | function formatMoment(m, format) {
|
24086 | if (!m.isValid()) {
|
24087 | return m.localeData().invalidDate();
|
24088 | }
|
24089 |
|
24090 | format = expandFormat(format, m.localeData());
|
24091 | formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
|
24092 | return formatFunctions[format](m);
|
24093 | }
|
24094 |
|
24095 | function expandFormat(format, locale) {
|
24096 | var i = 5;
|
24097 |
|
24098 | function replaceLongDateFormatTokens(input) {
|
24099 | return locale.longDateFormat(input) || input;
|
24100 | }
|
24101 |
|
24102 | localFormattingTokens.lastIndex = 0;
|
24103 |
|
24104 | while (i >= 0 && localFormattingTokens.test(format)) {
|
24105 | format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
|
24106 | localFormattingTokens.lastIndex = 0;
|
24107 | i -= 1;
|
24108 | }
|
24109 |
|
24110 | return format;
|
24111 | }
|
24112 |
|
24113 | var match1 = /\d/;
|
24114 |
|
24115 | var match2 = /\d\d/;
|
24116 |
|
24117 | var match3 = /\d{3}/;
|
24118 |
|
24119 | var match4 = /\d{4}/;
|
24120 |
|
24121 | var match6 = /[+-]?\d{6}/;
|
24122 |
|
24123 | var match1to2 = /\d\d?/;
|
24124 |
|
24125 | var match3to4 = /\d\d\d\d?/;
|
24126 |
|
24127 | var match5to6 = /\d\d\d\d\d\d?/;
|
24128 |
|
24129 | var match1to3 = /\d{1,3}/;
|
24130 |
|
24131 | var match1to4 = /\d{1,4}/;
|
24132 |
|
24133 | var match1to6 = /[+-]?\d{1,6}/;
|
24134 |
|
24135 | var matchUnsigned = /\d+/;
|
24136 |
|
24137 | var matchSigned = /[+-]?\d+/;
|
24138 |
|
24139 | var matchOffset = /Z|[+-]\d\d:?\d\d/gi;
|
24140 |
|
24141 | var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi;
|
24142 |
|
24143 | var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/;
|
24144 |
|
24145 |
|
24146 |
|
24147 | var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
|
24148 | var regexes = {};
|
24149 |
|
24150 | function addRegexToken(token, regex, strictRegex) {
|
24151 | regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
|
24152 | return isStrict && strictRegex ? strictRegex : regex;
|
24153 | };
|
24154 | }
|
24155 |
|
24156 | function getParseRegexForToken(token, config) {
|
24157 | if (!hasOwnProp(regexes, token)) {
|
24158 | return new RegExp(unescapeFormat(token));
|
24159 | }
|
24160 |
|
24161 | return regexes[token](config._strict, config._locale);
|
24162 | }
|
24163 |
|
24164 |
|
24165 | function unescapeFormat(s) {
|
24166 | return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
|
24167 | return p1 || p2 || p3 || p4;
|
24168 | }));
|
24169 | }
|
24170 |
|
24171 | function regexEscape(s) {
|
24172 | return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
24173 | }
|
24174 |
|
24175 | var tokens = {};
|
24176 |
|
24177 | function addParseToken(token, callback) {
|
24178 | var i,
|
24179 | func = callback;
|
24180 |
|
24181 | if (typeof token === 'string') {
|
24182 | token = [token];
|
24183 | }
|
24184 |
|
24185 | if (isNumber(callback)) {
|
24186 | func = function (input, array) {
|
24187 | array[callback] = toInt(input);
|
24188 | };
|
24189 | }
|
24190 |
|
24191 | for (i = 0; i < token.length; i++) {
|
24192 | tokens[token[i]] = func;
|
24193 | }
|
24194 | }
|
24195 |
|
24196 | function addWeekParseToken(token, callback) {
|
24197 | addParseToken(token, function (input, array, config, token) {
|
24198 | config._w = config._w || {};
|
24199 | callback(input, config._w, config, token);
|
24200 | });
|
24201 | }
|
24202 |
|
24203 | function addTimeToArrayFromToken(token, input, config) {
|
24204 | if (input != null && hasOwnProp(tokens, token)) {
|
24205 | tokens[token](input, config._a, config, token);
|
24206 | }
|
24207 | }
|
24208 |
|
24209 | var YEAR = 0;
|
24210 | var MONTH = 1;
|
24211 | var DATE = 2;
|
24212 | var HOUR = 3;
|
24213 | var MINUTE = 4;
|
24214 | var SECOND = 5;
|
24215 | var MILLISECOND = 6;
|
24216 | var WEEK = 7;
|
24217 | var WEEKDAY = 8;
|
24218 |
|
24219 | addFormatToken('Y', 0, 0, function () {
|
24220 | var y = this.year();
|
24221 | return y <= 9999 ? '' + y : '+' + y;
|
24222 | });
|
24223 | addFormatToken(0, ['YY', 2], 0, function () {
|
24224 | return this.year() % 100;
|
24225 | });
|
24226 | addFormatToken(0, ['YYYY', 4], 0, 'year');
|
24227 | addFormatToken(0, ['YYYYY', 5], 0, 'year');
|
24228 | addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
|
24229 |
|
24230 | addUnitAlias('year', 'y');
|
24231 |
|
24232 | addUnitPriority('year', 1);
|
24233 |
|
24234 | addRegexToken('Y', matchSigned);
|
24235 | addRegexToken('YY', match1to2, match2);
|
24236 | addRegexToken('YYYY', match1to4, match4);
|
24237 | addRegexToken('YYYYY', match1to6, match6);
|
24238 | addRegexToken('YYYYYY', match1to6, match6);
|
24239 | addParseToken(['YYYYY', 'YYYYYY'], YEAR);
|
24240 | addParseToken('YYYY', function (input, array) {
|
24241 | array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
|
24242 | });
|
24243 | addParseToken('YY', function (input, array) {
|
24244 | array[YEAR] = hooks.parseTwoDigitYear(input);
|
24245 | });
|
24246 | addParseToken('Y', function (input, array) {
|
24247 | array[YEAR] = parseInt(input, 10);
|
24248 | });
|
24249 |
|
24250 | function daysInYear(year) {
|
24251 | return isLeapYear(year) ? 366 : 365;
|
24252 | }
|
24253 |
|
24254 | function isLeapYear(year) {
|
24255 | return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
24256 | }
|
24257 |
|
24258 |
|
24259 | hooks.parseTwoDigitYear = function (input) {
|
24260 | return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
|
24261 | };
|
24262 |
|
24263 |
|
24264 | var getSetYear = makeGetSet('FullYear', true);
|
24265 |
|
24266 | function getIsLeapYear() {
|
24267 | return isLeapYear(this.year());
|
24268 | }
|
24269 |
|
24270 | function makeGetSet(unit, keepTime) {
|
24271 | return function (value) {
|
24272 | if (value != null) {
|
24273 | set$1(this, unit, value);
|
24274 | hooks.updateOffset(this, keepTime);
|
24275 | return this;
|
24276 | } else {
|
24277 | return get(this, unit);
|
24278 | }
|
24279 | };
|
24280 | }
|
24281 |
|
24282 | function get(mom, unit) {
|
24283 | return mom.isValid() ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
|
24284 | }
|
24285 |
|
24286 | function set$1(mom, unit, value) {
|
24287 | if (mom.isValid() && !isNaN(value)) {
|
24288 | if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
|
24289 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
|
24290 | } else {
|
24291 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
|
24292 | }
|
24293 | }
|
24294 | }
|
24295 |
|
24296 |
|
24297 | function stringGet(units) {
|
24298 | units = normalizeUnits(units);
|
24299 |
|
24300 | if (isFunction(this[units])) {
|
24301 | return this[units]();
|
24302 | }
|
24303 |
|
24304 | return this;
|
24305 | }
|
24306 |
|
24307 | function stringSet(units, value) {
|
24308 | if (typeof units === 'object') {
|
24309 | units = normalizeObjectUnits(units);
|
24310 | var prioritized = getPrioritizedUnits(units);
|
24311 |
|
24312 | for (var i = 0; i < prioritized.length; i++) {
|
24313 | this[prioritized[i].unit](units[prioritized[i].unit]);
|
24314 | }
|
24315 | } else {
|
24316 | units = normalizeUnits(units);
|
24317 |
|
24318 | if (isFunction(this[units])) {
|
24319 | return this[units](value);
|
24320 | }
|
24321 | }
|
24322 |
|
24323 | return this;
|
24324 | }
|
24325 |
|
24326 | function mod(n, x) {
|
24327 | return (n % x + x) % x;
|
24328 | }
|
24329 |
|
24330 | var indexOf;
|
24331 |
|
24332 | if (Array.prototype.indexOf) {
|
24333 | indexOf = Array.prototype.indexOf;
|
24334 | } else {
|
24335 | indexOf = function (o) {
|
24336 |
|
24337 | var i;
|
24338 |
|
24339 | for (i = 0; i < this.length; ++i) {
|
24340 | if (this[i] === o) {
|
24341 | return i;
|
24342 | }
|
24343 | }
|
24344 |
|
24345 | return -1;
|
24346 | };
|
24347 | }
|
24348 |
|
24349 | function daysInMonth(year, month) {
|
24350 | if (isNaN(year) || isNaN(month)) {
|
24351 | return NaN;
|
24352 | }
|
24353 |
|
24354 | var modMonth = mod(month, 12);
|
24355 | year += (month - modMonth) / 12;
|
24356 | return modMonth === 1 ? isLeapYear(year) ? 29 : 28 : 31 - modMonth % 7 % 2;
|
24357 | }
|
24358 |
|
24359 |
|
24360 | addFormatToken('M', ['MM', 2], 'Mo', function () {
|
24361 | return this.month() + 1;
|
24362 | });
|
24363 | addFormatToken('MMM', 0, 0, function (format) {
|
24364 | return this.localeData().monthsShort(this, format);
|
24365 | });
|
24366 | addFormatToken('MMMM', 0, 0, function (format) {
|
24367 | return this.localeData().months(this, format);
|
24368 | });
|
24369 |
|
24370 | addUnitAlias('month', 'M');
|
24371 |
|
24372 | addUnitPriority('month', 8);
|
24373 |
|
24374 | addRegexToken('M', match1to2);
|
24375 | addRegexToken('MM', match1to2, match2);
|
24376 | addRegexToken('MMM', function (isStrict, locale) {
|
24377 | return locale.monthsShortRegex(isStrict);
|
24378 | });
|
24379 | addRegexToken('MMMM', function (isStrict, locale) {
|
24380 | return locale.monthsRegex(isStrict);
|
24381 | });
|
24382 | addParseToken(['M', 'MM'], function (input, array) {
|
24383 | array[MONTH] = toInt(input) - 1;
|
24384 | });
|
24385 | addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
|
24386 | var month = config._locale.monthsParse(input, token, config._strict);
|
24387 |
|
24388 |
|
24389 | if (month != null) {
|
24390 | array[MONTH] = month;
|
24391 | } else {
|
24392 | getParsingFlags(config).invalidMonth = input;
|
24393 | }
|
24394 | });
|
24395 |
|
24396 | var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
|
24397 | var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
|
24398 |
|
24399 | function localeMonths(m, format) {
|
24400 | if (!m) {
|
24401 | return isArray(this._months) ? this._months : this._months['standalone'];
|
24402 | }
|
24403 |
|
24404 | return isArray(this._months) ? this._months[m.month()] : this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
|
24405 | }
|
24406 |
|
24407 | var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
|
24408 |
|
24409 | function localeMonthsShort(m, format) {
|
24410 | if (!m) {
|
24411 | return isArray(this._monthsShort) ? this._monthsShort : this._monthsShort['standalone'];
|
24412 | }
|
24413 |
|
24414 | return isArray(this._monthsShort) ? this._monthsShort[m.month()] : this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
|
24415 | }
|
24416 |
|
24417 | function handleStrictParse(monthName, format, strict) {
|
24418 | var i,
|
24419 | ii,
|
24420 | mom,
|
24421 | llc = monthName.toLocaleLowerCase();
|
24422 |
|
24423 | if (!this._monthsParse) {
|
24424 |
|
24425 | this._monthsParse = [];
|
24426 | this._longMonthsParse = [];
|
24427 | this._shortMonthsParse = [];
|
24428 |
|
24429 | for (i = 0; i < 12; ++i) {
|
24430 | mom = createUTC([2000, i]);
|
24431 | this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
|
24432 | this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
|
24433 | }
|
24434 | }
|
24435 |
|
24436 | if (strict) {
|
24437 | if (format === 'MMM') {
|
24438 | ii = indexOf.call(this._shortMonthsParse, llc);
|
24439 | return ii !== -1 ? ii : null;
|
24440 | } else {
|
24441 | ii = indexOf.call(this._longMonthsParse, llc);
|
24442 | return ii !== -1 ? ii : null;
|
24443 | }
|
24444 | } else {
|
24445 | if (format === 'MMM') {
|
24446 | ii = indexOf.call(this._shortMonthsParse, llc);
|
24447 |
|
24448 | if (ii !== -1) {
|
24449 | return ii;
|
24450 | }
|
24451 |
|
24452 | ii = indexOf.call(this._longMonthsParse, llc);
|
24453 | return ii !== -1 ? ii : null;
|
24454 | } else {
|
24455 | ii = indexOf.call(this._longMonthsParse, llc);
|
24456 |
|
24457 | if (ii !== -1) {
|
24458 | return ii;
|
24459 | }
|
24460 |
|
24461 | ii = indexOf.call(this._shortMonthsParse, llc);
|
24462 | return ii !== -1 ? ii : null;
|
24463 | }
|
24464 | }
|
24465 | }
|
24466 |
|
24467 | function localeMonthsParse(monthName, format, strict) {
|
24468 | var i, mom, regex;
|
24469 |
|
24470 | if (this._monthsParseExact) {
|
24471 | return handleStrictParse.call(this, monthName, format, strict);
|
24472 | }
|
24473 |
|
24474 | if (!this._monthsParse) {
|
24475 | this._monthsParse = [];
|
24476 | this._longMonthsParse = [];
|
24477 | this._shortMonthsParse = [];
|
24478 | }
|
24479 |
|
24480 |
|
24481 |
|
24482 |
|
24483 | for (i = 0; i < 12; i++) {
|
24484 |
|
24485 | mom = createUTC([2000, i]);
|
24486 |
|
24487 | if (strict && !this._longMonthsParse[i]) {
|
24488 | this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
|
24489 | this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
|
24490 | }
|
24491 |
|
24492 | if (!strict && !this._monthsParse[i]) {
|
24493 | regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
|
24494 | this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
24495 | }
|
24496 |
|
24497 |
|
24498 | if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
|
24499 | return i;
|
24500 | } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
|
24501 | return i;
|
24502 | } else if (!strict && this._monthsParse[i].test(monthName)) {
|
24503 | return i;
|
24504 | }
|
24505 | }
|
24506 | }
|
24507 |
|
24508 |
|
24509 | function setMonth(mom, value) {
|
24510 | var dayOfMonth;
|
24511 |
|
24512 | if (!mom.isValid()) {
|
24513 |
|
24514 | return mom;
|
24515 | }
|
24516 |
|
24517 | if (typeof value === 'string') {
|
24518 | if (/^\d+$/.test(value)) {
|
24519 | value = toInt(value);
|
24520 | } else {
|
24521 | value = mom.localeData().monthsParse(value);
|
24522 |
|
24523 | if (!isNumber(value)) {
|
24524 | return mom;
|
24525 | }
|
24526 | }
|
24527 | }
|
24528 |
|
24529 | dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
|
24530 |
|
24531 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
|
24532 |
|
24533 | return mom;
|
24534 | }
|
24535 |
|
24536 | function getSetMonth(value) {
|
24537 | if (value != null) {
|
24538 | setMonth(this, value);
|
24539 | hooks.updateOffset(this, true);
|
24540 | return this;
|
24541 | } else {
|
24542 | return get(this, 'Month');
|
24543 | }
|
24544 | }
|
24545 |
|
24546 | function getDaysInMonth() {
|
24547 | return daysInMonth(this.year(), this.month());
|
24548 | }
|
24549 |
|
24550 | var defaultMonthsShortRegex = matchWord;
|
24551 |
|
24552 | function monthsShortRegex(isStrict) {
|
24553 | if (this._monthsParseExact) {
|
24554 | if (!hasOwnProp(this, '_monthsRegex')) {
|
24555 | computeMonthsParse.call(this);
|
24556 | }
|
24557 |
|
24558 | if (isStrict) {
|
24559 | return this._monthsShortStrictRegex;
|
24560 | } else {
|
24561 | return this._monthsShortRegex;
|
24562 | }
|
24563 | } else {
|
24564 | if (!hasOwnProp(this, '_monthsShortRegex')) {
|
24565 | this._monthsShortRegex = defaultMonthsShortRegex;
|
24566 | }
|
24567 |
|
24568 | return this._monthsShortStrictRegex && isStrict ? this._monthsShortStrictRegex : this._monthsShortRegex;
|
24569 | }
|
24570 | }
|
24571 |
|
24572 | var defaultMonthsRegex = matchWord;
|
24573 |
|
24574 | function monthsRegex(isStrict) {
|
24575 | if (this._monthsParseExact) {
|
24576 | if (!hasOwnProp(this, '_monthsRegex')) {
|
24577 | computeMonthsParse.call(this);
|
24578 | }
|
24579 |
|
24580 | if (isStrict) {
|
24581 | return this._monthsStrictRegex;
|
24582 | } else {
|
24583 | return this._monthsRegex;
|
24584 | }
|
24585 | } else {
|
24586 | if (!hasOwnProp(this, '_monthsRegex')) {
|
24587 | this._monthsRegex = defaultMonthsRegex;
|
24588 | }
|
24589 |
|
24590 | return this._monthsStrictRegex && isStrict ? this._monthsStrictRegex : this._monthsRegex;
|
24591 | }
|
24592 | }
|
24593 |
|
24594 | function computeMonthsParse() {
|
24595 | function cmpLenRev(a, b) {
|
24596 | return b.length - a.length;
|
24597 | }
|
24598 |
|
24599 | var shortPieces = [],
|
24600 | longPieces = [],
|
24601 | mixedPieces = [],
|
24602 | i,
|
24603 | mom;
|
24604 |
|
24605 | for (i = 0; i < 12; i++) {
|
24606 |
|
24607 | mom = createUTC([2000, i]);
|
24608 | shortPieces.push(this.monthsShort(mom, ''));
|
24609 | longPieces.push(this.months(mom, ''));
|
24610 | mixedPieces.push(this.months(mom, ''));
|
24611 | mixedPieces.push(this.monthsShort(mom, ''));
|
24612 | }
|
24613 |
|
24614 |
|
24615 |
|
24616 | shortPieces.sort(cmpLenRev);
|
24617 | longPieces.sort(cmpLenRev);
|
24618 | mixedPieces.sort(cmpLenRev);
|
24619 |
|
24620 | for (i = 0; i < 12; i++) {
|
24621 | shortPieces[i] = regexEscape(shortPieces[i]);
|
24622 | longPieces[i] = regexEscape(longPieces[i]);
|
24623 | }
|
24624 |
|
24625 | for (i = 0; i < 24; i++) {
|
24626 | mixedPieces[i] = regexEscape(mixedPieces[i]);
|
24627 | }
|
24628 |
|
24629 | this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
24630 | this._monthsShortRegex = this._monthsRegex;
|
24631 | this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
24632 | this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
24633 | }
|
24634 |
|
24635 | function createDate(y, m, d, h, M, s, ms) {
|
24636 |
|
24637 |
|
24638 | var date;
|
24639 |
|
24640 | if (y < 100 && y >= 0) {
|
24641 |
|
24642 | date = new Date(y + 400, m, d, h, M, s, ms);
|
24643 |
|
24644 | if (isFinite(date.getFullYear())) {
|
24645 | date.setFullYear(y);
|
24646 | }
|
24647 | } else {
|
24648 | date = new Date(y, m, d, h, M, s, ms);
|
24649 | }
|
24650 |
|
24651 | return date;
|
24652 | }
|
24653 |
|
24654 | function createUTCDate(y) {
|
24655 | var date;
|
24656 |
|
24657 | if (y < 100 && y >= 0) {
|
24658 | var args = Array.prototype.slice.call(arguments);
|
24659 |
|
24660 | args[0] = y + 400;
|
24661 | date = new Date(Date.UTC.apply(null, args));
|
24662 |
|
24663 | if (isFinite(date.getUTCFullYear())) {
|
24664 | date.setUTCFullYear(y);
|
24665 | }
|
24666 | } else {
|
24667 | date = new Date(Date.UTC.apply(null, arguments));
|
24668 | }
|
24669 |
|
24670 | return date;
|
24671 | }
|
24672 |
|
24673 |
|
24674 | function firstWeekOffset(year, dow, doy) {
|
24675 | var
|
24676 | fwd = 7 + dow - doy,
|
24677 |
|
24678 | fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
|
24679 | return -fwdlw + fwd - 1;
|
24680 | }
|
24681 |
|
24682 |
|
24683 | function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
|
24684 | var localWeekday = (7 + weekday - dow) % 7,
|
24685 | weekOffset = firstWeekOffset(year, dow, doy),
|
24686 | dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
|
24687 | resYear,
|
24688 | resDayOfYear;
|
24689 |
|
24690 | if (dayOfYear <= 0) {
|
24691 | resYear = year - 1;
|
24692 | resDayOfYear = daysInYear(resYear) + dayOfYear;
|
24693 | } else if (dayOfYear > daysInYear(year)) {
|
24694 | resYear = year + 1;
|
24695 | resDayOfYear = dayOfYear - daysInYear(year);
|
24696 | } else {
|
24697 | resYear = year;
|
24698 | resDayOfYear = dayOfYear;
|
24699 | }
|
24700 |
|
24701 | return {
|
24702 | year: resYear,
|
24703 | dayOfYear: resDayOfYear
|
24704 | };
|
24705 | }
|
24706 |
|
24707 | function weekOfYear(mom, dow, doy) {
|
24708 | var weekOffset = firstWeekOffset(mom.year(), dow, doy),
|
24709 | week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
|
24710 | resWeek,
|
24711 | resYear;
|
24712 |
|
24713 | if (week < 1) {
|
24714 | resYear = mom.year() - 1;
|
24715 | resWeek = week + weeksInYear(resYear, dow, doy);
|
24716 | } else if (week > weeksInYear(mom.year(), dow, doy)) {
|
24717 | resWeek = week - weeksInYear(mom.year(), dow, doy);
|
24718 | resYear = mom.year() + 1;
|
24719 | } else {
|
24720 | resYear = mom.year();
|
24721 | resWeek = week;
|
24722 | }
|
24723 |
|
24724 | return {
|
24725 | week: resWeek,
|
24726 | year: resYear
|
24727 | };
|
24728 | }
|
24729 |
|
24730 | function weeksInYear(year, dow, doy) {
|
24731 | var weekOffset = firstWeekOffset(year, dow, doy),
|
24732 | weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
|
24733 | return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
|
24734 | }
|
24735 |
|
24736 |
|
24737 | addFormatToken('w', ['ww', 2], 'wo', 'week');
|
24738 | addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
|
24739 |
|
24740 | addUnitAlias('week', 'w');
|
24741 | addUnitAlias('isoWeek', 'W');
|
24742 |
|
24743 | addUnitPriority('week', 5);
|
24744 | addUnitPriority('isoWeek', 5);
|
24745 |
|
24746 | addRegexToken('w', match1to2);
|
24747 | addRegexToken('ww', match1to2, match2);
|
24748 | addRegexToken('W', match1to2);
|
24749 | addRegexToken('WW', match1to2, match2);
|
24750 | addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
|
24751 | week[token.substr(0, 1)] = toInt(input);
|
24752 | });
|
24753 |
|
24754 |
|
24755 | function localeWeek(mom) {
|
24756 | return weekOfYear(mom, this._week.dow, this._week.doy).week;
|
24757 | }
|
24758 |
|
24759 | var defaultLocaleWeek = {
|
24760 | dow: 0,
|
24761 |
|
24762 | doy: 6
|
24763 |
|
24764 | };
|
24765 |
|
24766 | function localeFirstDayOfWeek() {
|
24767 | return this._week.dow;
|
24768 | }
|
24769 |
|
24770 | function localeFirstDayOfYear() {
|
24771 | return this._week.doy;
|
24772 | }
|
24773 |
|
24774 |
|
24775 | function getSetWeek(input) {
|
24776 | var week = this.localeData().week(this);
|
24777 | return input == null ? week : this.add((input - week) * 7, 'd');
|
24778 | }
|
24779 |
|
24780 | function getSetISOWeek(input) {
|
24781 | var week = weekOfYear(this, 1, 4).week;
|
24782 | return input == null ? week : this.add((input - week) * 7, 'd');
|
24783 | }
|
24784 |
|
24785 |
|
24786 | addFormatToken('d', 0, 'do', 'day');
|
24787 | addFormatToken('dd', 0, 0, function (format) {
|
24788 | return this.localeData().weekdaysMin(this, format);
|
24789 | });
|
24790 | addFormatToken('ddd', 0, 0, function (format) {
|
24791 | return this.localeData().weekdaysShort(this, format);
|
24792 | });
|
24793 | addFormatToken('dddd', 0, 0, function (format) {
|
24794 | return this.localeData().weekdays(this, format);
|
24795 | });
|
24796 | addFormatToken('e', 0, 0, 'weekday');
|
24797 | addFormatToken('E', 0, 0, 'isoWeekday');
|
24798 |
|
24799 | addUnitAlias('day', 'd');
|
24800 | addUnitAlias('weekday', 'e');
|
24801 | addUnitAlias('isoWeekday', 'E');
|
24802 |
|
24803 | addUnitPriority('day', 11);
|
24804 | addUnitPriority('weekday', 11);
|
24805 | addUnitPriority('isoWeekday', 11);
|
24806 |
|
24807 | addRegexToken('d', match1to2);
|
24808 | addRegexToken('e', match1to2);
|
24809 | addRegexToken('E', match1to2);
|
24810 | addRegexToken('dd', function (isStrict, locale) {
|
24811 | return locale.weekdaysMinRegex(isStrict);
|
24812 | });
|
24813 | addRegexToken('ddd', function (isStrict, locale) {
|
24814 | return locale.weekdaysShortRegex(isStrict);
|
24815 | });
|
24816 | addRegexToken('dddd', function (isStrict, locale) {
|
24817 | return locale.weekdaysRegex(isStrict);
|
24818 | });
|
24819 | addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
|
24820 | var weekday = config._locale.weekdaysParse(input, token, config._strict);
|
24821 |
|
24822 |
|
24823 | if (weekday != null) {
|
24824 | week.d = weekday;
|
24825 | } else {
|
24826 | getParsingFlags(config).invalidWeekday = input;
|
24827 | }
|
24828 | });
|
24829 | addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
|
24830 | week[token] = toInt(input);
|
24831 | });
|
24832 |
|
24833 | function parseWeekday(input, locale) {
|
24834 | if (typeof input !== 'string') {
|
24835 | return input;
|
24836 | }
|
24837 |
|
24838 | if (!isNaN(input)) {
|
24839 | return parseInt(input, 10);
|
24840 | }
|
24841 |
|
24842 | input = locale.weekdaysParse(input);
|
24843 |
|
24844 | if (typeof input === 'number') {
|
24845 | return input;
|
24846 | }
|
24847 |
|
24848 | return null;
|
24849 | }
|
24850 |
|
24851 | function parseIsoWeekday(input, locale) {
|
24852 | if (typeof input === 'string') {
|
24853 | return locale.weekdaysParse(input) % 7 || 7;
|
24854 | }
|
24855 |
|
24856 | return isNaN(input) ? null : input;
|
24857 | }
|
24858 |
|
24859 |
|
24860 | function shiftWeekdays(ws, n) {
|
24861 | return ws.slice(n, 7).concat(ws.slice(0, n));
|
24862 | }
|
24863 |
|
24864 | var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
|
24865 |
|
24866 | function localeWeekdays(m, format) {
|
24867 | var weekdays = isArray(this._weekdays) ? this._weekdays : this._weekdays[m && m !== true && this._weekdays.isFormat.test(format) ? 'format' : 'standalone'];
|
24868 | return m === true ? shiftWeekdays(weekdays, this._week.dow) : m ? weekdays[m.day()] : weekdays;
|
24869 | }
|
24870 |
|
24871 | var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
|
24872 |
|
24873 | function localeWeekdaysShort(m) {
|
24874 | return m === true ? shiftWeekdays(this._weekdaysShort, this._week.dow) : m ? this._weekdaysShort[m.day()] : this._weekdaysShort;
|
24875 | }
|
24876 |
|
24877 | var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
|
24878 |
|
24879 | function localeWeekdaysMin(m) {
|
24880 | return m === true ? shiftWeekdays(this._weekdaysMin, this._week.dow) : m ? this._weekdaysMin[m.day()] : this._weekdaysMin;
|
24881 | }
|
24882 |
|
24883 | function handleStrictParse$1(weekdayName, format, strict) {
|
24884 | var i,
|
24885 | ii,
|
24886 | mom,
|
24887 | llc = weekdayName.toLocaleLowerCase();
|
24888 |
|
24889 | if (!this._weekdaysParse) {
|
24890 | this._weekdaysParse = [];
|
24891 | this._shortWeekdaysParse = [];
|
24892 | this._minWeekdaysParse = [];
|
24893 |
|
24894 | for (i = 0; i < 7; ++i) {
|
24895 | mom = createUTC([2000, 1]).day(i);
|
24896 | this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
|
24897 | this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
|
24898 | this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
|
24899 | }
|
24900 | }
|
24901 |
|
24902 | if (strict) {
|
24903 | if (format === 'dddd') {
|
24904 | ii = indexOf.call(this._weekdaysParse, llc);
|
24905 | return ii !== -1 ? ii : null;
|
24906 | } else if (format === 'ddd') {
|
24907 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
24908 | return ii !== -1 ? ii : null;
|
24909 | } else {
|
24910 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
24911 | return ii !== -1 ? ii : null;
|
24912 | }
|
24913 | } else {
|
24914 | if (format === 'dddd') {
|
24915 | ii = indexOf.call(this._weekdaysParse, llc);
|
24916 |
|
24917 | if (ii !== -1) {
|
24918 | return ii;
|
24919 | }
|
24920 |
|
24921 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
24922 |
|
24923 | if (ii !== -1) {
|
24924 | return ii;
|
24925 | }
|
24926 |
|
24927 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
24928 | return ii !== -1 ? ii : null;
|
24929 | } else if (format === 'ddd') {
|
24930 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
24931 |
|
24932 | if (ii !== -1) {
|
24933 | return ii;
|
24934 | }
|
24935 |
|
24936 | ii = indexOf.call(this._weekdaysParse, llc);
|
24937 |
|
24938 | if (ii !== -1) {
|
24939 | return ii;
|
24940 | }
|
24941 |
|
24942 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
24943 | return ii !== -1 ? ii : null;
|
24944 | } else {
|
24945 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
24946 |
|
24947 | if (ii !== -1) {
|
24948 | return ii;
|
24949 | }
|
24950 |
|
24951 | ii = indexOf.call(this._weekdaysParse, llc);
|
24952 |
|
24953 | if (ii !== -1) {
|
24954 | return ii;
|
24955 | }
|
24956 |
|
24957 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
24958 | return ii !== -1 ? ii : null;
|
24959 | }
|
24960 | }
|
24961 | }
|
24962 |
|
24963 | function localeWeekdaysParse(weekdayName, format, strict) {
|
24964 | var i, mom, regex;
|
24965 |
|
24966 | if (this._weekdaysParseExact) {
|
24967 | return handleStrictParse$1.call(this, weekdayName, format, strict);
|
24968 | }
|
24969 |
|
24970 | if (!this._weekdaysParse) {
|
24971 | this._weekdaysParse = [];
|
24972 | this._minWeekdaysParse = [];
|
24973 | this._shortWeekdaysParse = [];
|
24974 | this._fullWeekdaysParse = [];
|
24975 | }
|
24976 |
|
24977 | for (i = 0; i < 7; i++) {
|
24978 |
|
24979 | mom = createUTC([2000, 1]).day(i);
|
24980 |
|
24981 | if (strict && !this._fullWeekdaysParse[i]) {
|
24982 | this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i');
|
24983 | this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i');
|
24984 | this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i');
|
24985 | }
|
24986 |
|
24987 | if (!this._weekdaysParse[i]) {
|
24988 | regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
|
24989 | this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
24990 | }
|
24991 |
|
24992 |
|
24993 | if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
|
24994 | return i;
|
24995 | } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
|
24996 | return i;
|
24997 | } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
|
24998 | return i;
|
24999 | } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
|
25000 | return i;
|
25001 | }
|
25002 | }
|
25003 | }
|
25004 |
|
25005 |
|
25006 | function getSetDayOfWeek(input) {
|
25007 | if (!this.isValid()) {
|
25008 | return input != null ? this : NaN;
|
25009 | }
|
25010 |
|
25011 | var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
|
25012 |
|
25013 | if (input != null) {
|
25014 | input = parseWeekday(input, this.localeData());
|
25015 | return this.add(input - day, 'd');
|
25016 | } else {
|
25017 | return day;
|
25018 | }
|
25019 | }
|
25020 |
|
25021 | function getSetLocaleDayOfWeek(input) {
|
25022 | if (!this.isValid()) {
|
25023 | return input != null ? this : NaN;
|
25024 | }
|
25025 |
|
25026 | var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
|
25027 | return input == null ? weekday : this.add(input - weekday, 'd');
|
25028 | }
|
25029 |
|
25030 | function getSetISODayOfWeek(input) {
|
25031 | if (!this.isValid()) {
|
25032 | return input != null ? this : NaN;
|
25033 | }
|
25034 |
|
25035 |
|
25036 |
|
25037 |
|
25038 | if (input != null) {
|
25039 | var weekday = parseIsoWeekday(input, this.localeData());
|
25040 | return this.day(this.day() % 7 ? weekday : weekday - 7);
|
25041 | } else {
|
25042 | return this.day() || 7;
|
25043 | }
|
25044 | }
|
25045 |
|
25046 | var defaultWeekdaysRegex = matchWord;
|
25047 |
|
25048 | function weekdaysRegex(isStrict) {
|
25049 | if (this._weekdaysParseExact) {
|
25050 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
25051 | computeWeekdaysParse.call(this);
|
25052 | }
|
25053 |
|
25054 | if (isStrict) {
|
25055 | return this._weekdaysStrictRegex;
|
25056 | } else {
|
25057 | return this._weekdaysRegex;
|
25058 | }
|
25059 | } else {
|
25060 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
25061 | this._weekdaysRegex = defaultWeekdaysRegex;
|
25062 | }
|
25063 |
|
25064 | return this._weekdaysStrictRegex && isStrict ? this._weekdaysStrictRegex : this._weekdaysRegex;
|
25065 | }
|
25066 | }
|
25067 |
|
25068 | var defaultWeekdaysShortRegex = matchWord;
|
25069 |
|
25070 | function weekdaysShortRegex(isStrict) {
|
25071 | if (this._weekdaysParseExact) {
|
25072 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
25073 | computeWeekdaysParse.call(this);
|
25074 | }
|
25075 |
|
25076 | if (isStrict) {
|
25077 | return this._weekdaysShortStrictRegex;
|
25078 | } else {
|
25079 | return this._weekdaysShortRegex;
|
25080 | }
|
25081 | } else {
|
25082 | if (!hasOwnProp(this, '_weekdaysShortRegex')) {
|
25083 | this._weekdaysShortRegex = defaultWeekdaysShortRegex;
|
25084 | }
|
25085 |
|
25086 | return this._weekdaysShortStrictRegex && isStrict ? this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
|
25087 | }
|
25088 | }
|
25089 |
|
25090 | var defaultWeekdaysMinRegex = matchWord;
|
25091 |
|
25092 | function weekdaysMinRegex(isStrict) {
|
25093 | if (this._weekdaysParseExact) {
|
25094 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
25095 | computeWeekdaysParse.call(this);
|
25096 | }
|
25097 |
|
25098 | if (isStrict) {
|
25099 | return this._weekdaysMinStrictRegex;
|
25100 | } else {
|
25101 | return this._weekdaysMinRegex;
|
25102 | }
|
25103 | } else {
|
25104 | if (!hasOwnProp(this, '_weekdaysMinRegex')) {
|
25105 | this._weekdaysMinRegex = defaultWeekdaysMinRegex;
|
25106 | }
|
25107 |
|
25108 | return this._weekdaysMinStrictRegex && isStrict ? this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
|
25109 | }
|
25110 | }
|
25111 |
|
25112 | function computeWeekdaysParse() {
|
25113 | function cmpLenRev(a, b) {
|
25114 | return b.length - a.length;
|
25115 | }
|
25116 |
|
25117 | var minPieces = [],
|
25118 | shortPieces = [],
|
25119 | longPieces = [],
|
25120 | mixedPieces = [],
|
25121 | i,
|
25122 | mom,
|
25123 | minp,
|
25124 | shortp,
|
25125 | longp;
|
25126 |
|
25127 | for (i = 0; i < 7; i++) {
|
25128 |
|
25129 | mom = createUTC([2000, 1]).day(i);
|
25130 | minp = this.weekdaysMin(mom, '');
|
25131 | shortp = this.weekdaysShort(mom, '');
|
25132 | longp = this.weekdays(mom, '');
|
25133 | minPieces.push(minp);
|
25134 | shortPieces.push(shortp);
|
25135 | longPieces.push(longp);
|
25136 | mixedPieces.push(minp);
|
25137 | mixedPieces.push(shortp);
|
25138 | mixedPieces.push(longp);
|
25139 | }
|
25140 |
|
25141 |
|
25142 |
|
25143 | minPieces.sort(cmpLenRev);
|
25144 | shortPieces.sort(cmpLenRev);
|
25145 | longPieces.sort(cmpLenRev);
|
25146 | mixedPieces.sort(cmpLenRev);
|
25147 |
|
25148 | for (i = 0; i < 7; i++) {
|
25149 | shortPieces[i] = regexEscape(shortPieces[i]);
|
25150 | longPieces[i] = regexEscape(longPieces[i]);
|
25151 | mixedPieces[i] = regexEscape(mixedPieces[i]);
|
25152 | }
|
25153 |
|
25154 | this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
25155 | this._weekdaysShortRegex = this._weekdaysRegex;
|
25156 | this._weekdaysMinRegex = this._weekdaysRegex;
|
25157 | this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
25158 | this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
25159 | this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
|
25160 | }
|
25161 |
|
25162 |
|
25163 | function hFormat() {
|
25164 | return this.hours() % 12 || 12;
|
25165 | }
|
25166 |
|
25167 | function kFormat() {
|
25168 | return this.hours() || 24;
|
25169 | }
|
25170 |
|
25171 | addFormatToken('H', ['HH', 2], 0, 'hour');
|
25172 | addFormatToken('h', ['hh', 2], 0, hFormat);
|
25173 | addFormatToken('k', ['kk', 2], 0, kFormat);
|
25174 | addFormatToken('hmm', 0, 0, function () {
|
25175 | return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
|
25176 | });
|
25177 | addFormatToken('hmmss', 0, 0, function () {
|
25178 | return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
|
25179 | });
|
25180 | addFormatToken('Hmm', 0, 0, function () {
|
25181 | return '' + this.hours() + zeroFill(this.minutes(), 2);
|
25182 | });
|
25183 | addFormatToken('Hmmss', 0, 0, function () {
|
25184 | return '' + this.hours() + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
|
25185 | });
|
25186 |
|
25187 | function meridiem(token, lowercase) {
|
25188 | addFormatToken(token, 0, 0, function () {
|
25189 | return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
|
25190 | });
|
25191 | }
|
25192 |
|
25193 | meridiem('a', true);
|
25194 | meridiem('A', false);
|
25195 |
|
25196 | addUnitAlias('hour', 'h');
|
25197 |
|
25198 | addUnitPriority('hour', 13);
|
25199 |
|
25200 | function matchMeridiem(isStrict, locale) {
|
25201 | return locale._meridiemParse;
|
25202 | }
|
25203 |
|
25204 | addRegexToken('a', matchMeridiem);
|
25205 | addRegexToken('A', matchMeridiem);
|
25206 | addRegexToken('H', match1to2);
|
25207 | addRegexToken('h', match1to2);
|
25208 | addRegexToken('k', match1to2);
|
25209 | addRegexToken('HH', match1to2, match2);
|
25210 | addRegexToken('hh', match1to2, match2);
|
25211 | addRegexToken('kk', match1to2, match2);
|
25212 | addRegexToken('hmm', match3to4);
|
25213 | addRegexToken('hmmss', match5to6);
|
25214 | addRegexToken('Hmm', match3to4);
|
25215 | addRegexToken('Hmmss', match5to6);
|
25216 | addParseToken(['H', 'HH'], HOUR);
|
25217 | addParseToken(['k', 'kk'], function (input, array, config) {
|
25218 | var kInput = toInt(input);
|
25219 | array[HOUR] = kInput === 24 ? 0 : kInput;
|
25220 | });
|
25221 | addParseToken(['a', 'A'], function (input, array, config) {
|
25222 | config._isPm = config._locale.isPM(input);
|
25223 | config._meridiem = input;
|
25224 | });
|
25225 | addParseToken(['h', 'hh'], function (input, array, config) {
|
25226 | array[HOUR] = toInt(input);
|
25227 | getParsingFlags(config).bigHour = true;
|
25228 | });
|
25229 | addParseToken('hmm', function (input, array, config) {
|
25230 | var pos = input.length - 2;
|
25231 | array[HOUR] = toInt(input.substr(0, pos));
|
25232 | array[MINUTE] = toInt(input.substr(pos));
|
25233 | getParsingFlags(config).bigHour = true;
|
25234 | });
|
25235 | addParseToken('hmmss', function (input, array, config) {
|
25236 | var pos1 = input.length - 4;
|
25237 | var pos2 = input.length - 2;
|
25238 | array[HOUR] = toInt(input.substr(0, pos1));
|
25239 | array[MINUTE] = toInt(input.substr(pos1, 2));
|
25240 | array[SECOND] = toInt(input.substr(pos2));
|
25241 | getParsingFlags(config).bigHour = true;
|
25242 | });
|
25243 | addParseToken('Hmm', function (input, array, config) {
|
25244 | var pos = input.length - 2;
|
25245 | array[HOUR] = toInt(input.substr(0, pos));
|
25246 | array[MINUTE] = toInt(input.substr(pos));
|
25247 | });
|
25248 | addParseToken('Hmmss', function (input, array, config) {
|
25249 | var pos1 = input.length - 4;
|
25250 | var pos2 = input.length - 2;
|
25251 | array[HOUR] = toInt(input.substr(0, pos1));
|
25252 | array[MINUTE] = toInt(input.substr(pos1, 2));
|
25253 | array[SECOND] = toInt(input.substr(pos2));
|
25254 | });
|
25255 |
|
25256 | function localeIsPM(input) {
|
25257 |
|
25258 |
|
25259 | return (input + '').toLowerCase().charAt(0) === 'p';
|
25260 | }
|
25261 |
|
25262 | var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
|
25263 |
|
25264 | function localeMeridiem(hours, minutes, isLower) {
|
25265 | if (hours > 11) {
|
25266 | return isLower ? 'pm' : 'PM';
|
25267 | } else {
|
25268 | return isLower ? 'am' : 'AM';
|
25269 | }
|
25270 | }
|
25271 |
|
25272 |
|
25273 |
|
25274 |
|
25275 |
|
25276 |
|
25277 | var getSetHour = makeGetSet('Hours', true);
|
25278 | var baseConfig = {
|
25279 | calendar: defaultCalendar,
|
25280 | longDateFormat: defaultLongDateFormat,
|
25281 | invalidDate: defaultInvalidDate,
|
25282 | ordinal: defaultOrdinal,
|
25283 | dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
|
25284 | relativeTime: defaultRelativeTime,
|
25285 | months: defaultLocaleMonths,
|
25286 | monthsShort: defaultLocaleMonthsShort,
|
25287 | week: defaultLocaleWeek,
|
25288 | weekdays: defaultLocaleWeekdays,
|
25289 | weekdaysMin: defaultLocaleWeekdaysMin,
|
25290 | weekdaysShort: defaultLocaleWeekdaysShort,
|
25291 | meridiemParse: defaultLocaleMeridiemParse
|
25292 | };
|
25293 |
|
25294 | var locales = {};
|
25295 | var localeFamilies = {};
|
25296 | var globalLocale;
|
25297 |
|
25298 | function normalizeLocale(key) {
|
25299 | return key ? key.toLowerCase().replace('_', '-') : key;
|
25300 | }
|
25301 |
|
25302 |
|
25303 |
|
25304 |
|
25305 | function chooseLocale(names) {
|
25306 | var i = 0,
|
25307 | j,
|
25308 | next,
|
25309 | locale,
|
25310 | split;
|
25311 |
|
25312 | while (i < names.length) {
|
25313 | split = normalizeLocale(names[i]).split('-');
|
25314 | j = split.length;
|
25315 | next = normalizeLocale(names[i + 1]);
|
25316 | next = next ? next.split('-') : null;
|
25317 |
|
25318 | while (j > 0) {
|
25319 | locale = loadLocale(split.slice(0, j).join('-'));
|
25320 |
|
25321 | if (locale) {
|
25322 | return locale;
|
25323 | }
|
25324 |
|
25325 | if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
|
25326 |
|
25327 | break;
|
25328 | }
|
25329 |
|
25330 | j--;
|
25331 | }
|
25332 |
|
25333 | i++;
|
25334 | }
|
25335 |
|
25336 | return globalLocale;
|
25337 | }
|
25338 |
|
25339 | function loadLocale(name) {
|
25340 | var oldLocale = null;
|
25341 |
|
25342 | if (!locales[name] && 'object' !== 'undefined' && module && module.exports) {
|
25343 | try {
|
25344 | oldLocale = globalLocale._abbr;
|
25345 | var aliasedRequire = commonjsRequire$1;
|
25346 | aliasedRequire('./locale/' + name);
|
25347 | getSetGlobalLocale(oldLocale);
|
25348 | } catch (e) {}
|
25349 | }
|
25350 |
|
25351 | return locales[name];
|
25352 | }
|
25353 |
|
25354 |
|
25355 |
|
25356 |
|
25357 | function getSetGlobalLocale(key, values) {
|
25358 | var data;
|
25359 |
|
25360 | if (key) {
|
25361 | if (isUndefined(values)) {
|
25362 | data = getLocale(key);
|
25363 | } else {
|
25364 | data = defineLocale(key, values);
|
25365 | }
|
25366 |
|
25367 | if (data) {
|
25368 |
|
25369 | globalLocale = data;
|
25370 | } else {
|
25371 | if (typeof console !== 'undefined' && console.warn) {
|
25372 |
|
25373 | console.warn('Locale ' + key + ' not found. Did you forget to load it?');
|
25374 | }
|
25375 | }
|
25376 | }
|
25377 |
|
25378 | return globalLocale._abbr;
|
25379 | }
|
25380 |
|
25381 | function defineLocale(name, config) {
|
25382 | if (config !== null) {
|
25383 | var locale,
|
25384 | parentConfig = baseConfig;
|
25385 | config.abbr = name;
|
25386 |
|
25387 | if (locales[name] != null) {
|
25388 | deprecateSimple('defineLocaleOverride', 'use moment.updateLocale(localeName, config) to change ' + 'an existing locale. moment.defineLocale(localeName, ' + 'config) should only be used for creating a new locale ' + 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
|
25389 | parentConfig = locales[name]._config;
|
25390 | } else if (config.parentLocale != null) {
|
25391 | if (locales[config.parentLocale] != null) {
|
25392 | parentConfig = locales[config.parentLocale]._config;
|
25393 | } else {
|
25394 | locale = loadLocale(config.parentLocale);
|
25395 |
|
25396 | if (locale != null) {
|
25397 | parentConfig = locale._config;
|
25398 | } else {
|
25399 | if (!localeFamilies[config.parentLocale]) {
|
25400 | localeFamilies[config.parentLocale] = [];
|
25401 | }
|
25402 |
|
25403 | localeFamilies[config.parentLocale].push({
|
25404 | name: name,
|
25405 | config: config
|
25406 | });
|
25407 | return null;
|
25408 | }
|
25409 | }
|
25410 | }
|
25411 |
|
25412 | locales[name] = new Locale(mergeConfigs(parentConfig, config));
|
25413 |
|
25414 | if (localeFamilies[name]) {
|
25415 | localeFamilies[name].forEach(function (x) {
|
25416 | defineLocale(x.name, x.config);
|
25417 | });
|
25418 | }
|
25419 |
|
25420 |
|
25421 |
|
25422 |
|
25423 | getSetGlobalLocale(name);
|
25424 | return locales[name];
|
25425 | } else {
|
25426 |
|
25427 | delete locales[name];
|
25428 | return null;
|
25429 | }
|
25430 | }
|
25431 |
|
25432 | function updateLocale(name, config) {
|
25433 | if (config != null) {
|
25434 | var locale,
|
25435 | tmpLocale,
|
25436 | parentConfig = baseConfig;
|
25437 |
|
25438 | tmpLocale = loadLocale(name);
|
25439 |
|
25440 | if (tmpLocale != null) {
|
25441 | parentConfig = tmpLocale._config;
|
25442 | }
|
25443 |
|
25444 | config = mergeConfigs(parentConfig, config);
|
25445 | locale = new Locale(config);
|
25446 | locale.parentLocale = locales[name];
|
25447 | locales[name] = locale;
|
25448 |
|
25449 | getSetGlobalLocale(name);
|
25450 | } else {
|
25451 |
|
25452 | if (locales[name] != null) {
|
25453 | if (locales[name].parentLocale != null) {
|
25454 | locales[name] = locales[name].parentLocale;
|
25455 | } else if (locales[name] != null) {
|
25456 | delete locales[name];
|
25457 | }
|
25458 | }
|
25459 | }
|
25460 |
|
25461 | return locales[name];
|
25462 | }
|
25463 |
|
25464 |
|
25465 | function getLocale(key) {
|
25466 | var locale;
|
25467 |
|
25468 | if (key && key._locale && key._locale._abbr) {
|
25469 | key = key._locale._abbr;
|
25470 | }
|
25471 |
|
25472 | if (!key) {
|
25473 | return globalLocale;
|
25474 | }
|
25475 |
|
25476 | if (!isArray(key)) {
|
25477 |
|
25478 | locale = loadLocale(key);
|
25479 |
|
25480 | if (locale) {
|
25481 | return locale;
|
25482 | }
|
25483 |
|
25484 | key = [key];
|
25485 | }
|
25486 |
|
25487 | return chooseLocale(key);
|
25488 | }
|
25489 |
|
25490 | function listLocales() {
|
25491 | return keys(locales);
|
25492 | }
|
25493 |
|
25494 | function checkOverflow(m) {
|
25495 | var overflow;
|
25496 | var a = m._a;
|
25497 |
|
25498 | if (a && getParsingFlags(m).overflow === -2) {
|
25499 | overflow = a[MONTH] < 0 || a[MONTH] > 11 ? MONTH : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE : a[HOUR] < 0 || a[HOUR] > 24 || a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0) ? HOUR : a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE : a[SECOND] < 0 || a[SECOND] > 59 ? SECOND : a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND : -1;
|
25500 |
|
25501 | if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
|
25502 | overflow = DATE;
|
25503 | }
|
25504 |
|
25505 | if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
|
25506 | overflow = WEEK;
|
25507 | }
|
25508 |
|
25509 | if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
|
25510 | overflow = WEEKDAY;
|
25511 | }
|
25512 |
|
25513 | getParsingFlags(m).overflow = overflow;
|
25514 | }
|
25515 |
|
25516 | return m;
|
25517 | }
|
25518 |
|
25519 |
|
25520 | function defaults(a, b, c) {
|
25521 | if (a != null) {
|
25522 | return a;
|
25523 | }
|
25524 |
|
25525 | if (b != null) {
|
25526 | return b;
|
25527 | }
|
25528 |
|
25529 | return c;
|
25530 | }
|
25531 |
|
25532 | function currentDateArray(config) {
|
25533 |
|
25534 | var nowValue = new Date(hooks.now());
|
25535 |
|
25536 | if (config._useUTC) {
|
25537 | return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
|
25538 | }
|
25539 |
|
25540 | return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
|
25541 | }
|
25542 |
|
25543 |
|
25544 |
|
25545 |
|
25546 |
|
25547 | function configFromArray(config) {
|
25548 | var i,
|
25549 | date,
|
25550 | input = [],
|
25551 | currentDate,
|
25552 | expectedWeekday,
|
25553 | yearToUse;
|
25554 |
|
25555 | if (config._d) {
|
25556 | return;
|
25557 | }
|
25558 |
|
25559 | currentDate = currentDateArray(config);
|
25560 |
|
25561 | if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
|
25562 | dayOfYearFromWeekInfo(config);
|
25563 | }
|
25564 |
|
25565 |
|
25566 | if (config._dayOfYear != null) {
|
25567 | yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
|
25568 |
|
25569 | if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
|
25570 | getParsingFlags(config)._overflowDayOfYear = true;
|
25571 | }
|
25572 |
|
25573 | date = createUTCDate(yearToUse, 0, config._dayOfYear);
|
25574 | config._a[MONTH] = date.getUTCMonth();
|
25575 | config._a[DATE] = date.getUTCDate();
|
25576 | }
|
25577 |
|
25578 |
|
25579 |
|
25580 |
|
25581 |
|
25582 |
|
25583 | for (i = 0; i < 3 && config._a[i] == null; ++i) {
|
25584 | config._a[i] = input[i] = currentDate[i];
|
25585 | }
|
25586 |
|
25587 |
|
25588 | for (; i < 7; i++) {
|
25589 | config._a[i] = input[i] = config._a[i] == null ? i === 2 ? 1 : 0 : config._a[i];
|
25590 | }
|
25591 |
|
25592 |
|
25593 | if (config._a[HOUR] === 24 && config._a[MINUTE] === 0 && config._a[SECOND] === 0 && config._a[MILLISECOND] === 0) {
|
25594 | config._nextDay = true;
|
25595 | config._a[HOUR] = 0;
|
25596 | }
|
25597 |
|
25598 | config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
|
25599 | expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
|
25600 |
|
25601 |
|
25602 | if (config._tzm != null) {
|
25603 | config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
25604 | }
|
25605 |
|
25606 | if (config._nextDay) {
|
25607 | config._a[HOUR] = 24;
|
25608 | }
|
25609 |
|
25610 |
|
25611 | if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
|
25612 | getParsingFlags(config).weekdayMismatch = true;
|
25613 | }
|
25614 | }
|
25615 |
|
25616 | function dayOfYearFromWeekInfo(config) {
|
25617 | var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
|
25618 | w = config._w;
|
25619 |
|
25620 | if (w.GG != null || w.W != null || w.E != null) {
|
25621 | dow = 1;
|
25622 | doy = 4;
|
25623 |
|
25624 |
|
25625 |
|
25626 |
|
25627 | weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
|
25628 | week = defaults(w.W, 1);
|
25629 | weekday = defaults(w.E, 1);
|
25630 |
|
25631 | if (weekday < 1 || weekday > 7) {
|
25632 | weekdayOverflow = true;
|
25633 | }
|
25634 | } else {
|
25635 | dow = config._locale._week.dow;
|
25636 | doy = config._locale._week.doy;
|
25637 | var curWeek = weekOfYear(createLocal(), dow, doy);
|
25638 | weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
|
25639 |
|
25640 | week = defaults(w.w, curWeek.week);
|
25641 |
|
25642 | if (w.d != null) {
|
25643 |
|
25644 | weekday = w.d;
|
25645 |
|
25646 | if (weekday < 0 || weekday > 6) {
|
25647 | weekdayOverflow = true;
|
25648 | }
|
25649 | } else if (w.e != null) {
|
25650 |
|
25651 | weekday = w.e + dow;
|
25652 |
|
25653 | if (w.e < 0 || w.e > 6) {
|
25654 | weekdayOverflow = true;
|
25655 | }
|
25656 | } else {
|
25657 |
|
25658 | weekday = dow;
|
25659 | }
|
25660 | }
|
25661 |
|
25662 | if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
|
25663 | getParsingFlags(config)._overflowWeeks = true;
|
25664 | } else if (weekdayOverflow != null) {
|
25665 | getParsingFlags(config)._overflowWeekday = true;
|
25666 | } else {
|
25667 | temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
|
25668 | config._a[YEAR] = temp.year;
|
25669 | config._dayOfYear = temp.dayOfYear;
|
25670 | }
|
25671 | }
|
25672 |
|
25673 |
|
25674 |
|
25675 | 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)?)?$/;
|
25676 | 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)?)?$/;
|
25677 | var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
|
25678 | var isoDates = [['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], ['GGGG-[W]WW', /\d{4}-W\d\d/, false], ['YYYY-DDD', /\d{4}-\d{3}/], ['YYYY-MM', /\d{4}-\d\d/, false], ['YYYYYYMMDD', /[+-]\d{10}/], ['YYYYMMDD', /\d{8}/],
|
25679 | ['GGGG[W]WWE', /\d{4}W\d{3}/], ['GGGG[W]WW', /\d{4}W\d{2}/, false], ['YYYYDDD', /\d{7}/]];
|
25680 |
|
25681 | var isoTimes = [['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], ['HH:mm:ss', /\d\d:\d\d:\d\d/], ['HH:mm', /\d\d:\d\d/], ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], ['HHmmss', /\d\d\d\d\d\d/], ['HHmm', /\d\d\d\d/], ['HH', /\d\d/]];
|
25682 | var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
|
25683 |
|
25684 | function configFromISO(config) {
|
25685 | var i,
|
25686 | l,
|
25687 | string = config._i,
|
25688 | match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
|
25689 | allowTime,
|
25690 | dateFormat,
|
25691 | timeFormat,
|
25692 | tzFormat;
|
25693 |
|
25694 | if (match) {
|
25695 | getParsingFlags(config).iso = true;
|
25696 |
|
25697 | for (i = 0, l = isoDates.length; i < l; i++) {
|
25698 | if (isoDates[i][1].exec(match[1])) {
|
25699 | dateFormat = isoDates[i][0];
|
25700 | allowTime = isoDates[i][2] !== false;
|
25701 | break;
|
25702 | }
|
25703 | }
|
25704 |
|
25705 | if (dateFormat == null) {
|
25706 | config._isValid = false;
|
25707 | return;
|
25708 | }
|
25709 |
|
25710 | if (match[3]) {
|
25711 | for (i = 0, l = isoTimes.length; i < l; i++) {
|
25712 | if (isoTimes[i][1].exec(match[3])) {
|
25713 |
|
25714 | timeFormat = (match[2] || ' ') + isoTimes[i][0];
|
25715 | break;
|
25716 | }
|
25717 | }
|
25718 |
|
25719 | if (timeFormat == null) {
|
25720 | config._isValid = false;
|
25721 | return;
|
25722 | }
|
25723 | }
|
25724 |
|
25725 | if (!allowTime && timeFormat != null) {
|
25726 | config._isValid = false;
|
25727 | return;
|
25728 | }
|
25729 |
|
25730 | if (match[4]) {
|
25731 | if (tzRegex.exec(match[4])) {
|
25732 | tzFormat = 'Z';
|
25733 | } else {
|
25734 | config._isValid = false;
|
25735 | return;
|
25736 | }
|
25737 | }
|
25738 |
|
25739 | config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
|
25740 | configFromStringAndFormat(config);
|
25741 | } else {
|
25742 | config._isValid = false;
|
25743 | }
|
25744 | }
|
25745 |
|
25746 |
|
25747 | var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;
|
25748 |
|
25749 | function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
|
25750 | var result = [untruncateYear(yearStr), defaultLocaleMonthsShort.indexOf(monthStr), parseInt(dayStr, 10), parseInt(hourStr, 10), parseInt(minuteStr, 10)];
|
25751 |
|
25752 | if (secondStr) {
|
25753 | result.push(parseInt(secondStr, 10));
|
25754 | }
|
25755 |
|
25756 | return result;
|
25757 | }
|
25758 |
|
25759 | function untruncateYear(yearStr) {
|
25760 | var year = parseInt(yearStr, 10);
|
25761 |
|
25762 | if (year <= 49) {
|
25763 | return 2000 + year;
|
25764 | } else if (year <= 999) {
|
25765 | return 1900 + year;
|
25766 | }
|
25767 |
|
25768 | return year;
|
25769 | }
|
25770 |
|
25771 | function preprocessRFC2822(s) {
|
25772 |
|
25773 | return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
25774 | }
|
25775 |
|
25776 | function checkWeekday(weekdayStr, parsedInput, config) {
|
25777 | if (weekdayStr) {
|
25778 |
|
25779 | var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
|
25780 | weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
|
25781 |
|
25782 | if (weekdayProvided !== weekdayActual) {
|
25783 | getParsingFlags(config).weekdayMismatch = true;
|
25784 | config._isValid = false;
|
25785 | return false;
|
25786 | }
|
25787 | }
|
25788 |
|
25789 | return true;
|
25790 | }
|
25791 |
|
25792 | var obsOffsets = {
|
25793 | UT: 0,
|
25794 | GMT: 0,
|
25795 | EDT: -4 * 60,
|
25796 | EST: -5 * 60,
|
25797 | CDT: -5 * 60,
|
25798 | CST: -6 * 60,
|
25799 | MDT: -6 * 60,
|
25800 | MST: -7 * 60,
|
25801 | PDT: -7 * 60,
|
25802 | PST: -8 * 60
|
25803 | };
|
25804 |
|
25805 | function calculateOffset(obsOffset, militaryOffset, numOffset) {
|
25806 | if (obsOffset) {
|
25807 | return obsOffsets[obsOffset];
|
25808 | } else if (militaryOffset) {
|
25809 |
|
25810 | return 0;
|
25811 | } else {
|
25812 | var hm = parseInt(numOffset, 10);
|
25813 | var m = hm % 100,
|
25814 | h = (hm - m) / 100;
|
25815 | return h * 60 + m;
|
25816 | }
|
25817 | }
|
25818 |
|
25819 |
|
25820 | function configFromRFC2822(config) {
|
25821 | var match = rfc2822.exec(preprocessRFC2822(config._i));
|
25822 |
|
25823 | if (match) {
|
25824 | var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
|
25825 |
|
25826 | if (!checkWeekday(match[1], parsedArray, config)) {
|
25827 | return;
|
25828 | }
|
25829 |
|
25830 | config._a = parsedArray;
|
25831 | config._tzm = calculateOffset(match[8], match[9], match[10]);
|
25832 | config._d = createUTCDate.apply(null, config._a);
|
25833 |
|
25834 | config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
25835 |
|
25836 | getParsingFlags(config).rfc2822 = true;
|
25837 | } else {
|
25838 | config._isValid = false;
|
25839 | }
|
25840 | }
|
25841 |
|
25842 |
|
25843 | function configFromString(config) {
|
25844 | var matched = aspNetJsonRegex.exec(config._i);
|
25845 |
|
25846 | if (matched !== null) {
|
25847 | config._d = new Date(+matched[1]);
|
25848 | return;
|
25849 | }
|
25850 |
|
25851 | configFromISO(config);
|
25852 |
|
25853 | if (config._isValid === false) {
|
25854 | delete config._isValid;
|
25855 | } else {
|
25856 | return;
|
25857 | }
|
25858 |
|
25859 | configFromRFC2822(config);
|
25860 |
|
25861 | if (config._isValid === false) {
|
25862 | delete config._isValid;
|
25863 | } else {
|
25864 | return;
|
25865 | }
|
25866 |
|
25867 |
|
25868 | hooks.createFromInputFallback(config);
|
25869 | }
|
25870 |
|
25871 | hooks.createFromInputFallback = deprecate('value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' + 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' + 'discouraged and will be removed in an upcoming major release. Please refer to ' + 'http://momentjs.com/guides/#/warnings/js-date/ for more info.', function (config) {
|
25872 | config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
|
25873 | });
|
25874 |
|
25875 | hooks.ISO_8601 = function () {};
|
25876 |
|
25877 |
|
25878 | hooks.RFC_2822 = function () {};
|
25879 |
|
25880 |
|
25881 | function configFromStringAndFormat(config) {
|
25882 |
|
25883 | if (config._f === hooks.ISO_8601) {
|
25884 | configFromISO(config);
|
25885 | return;
|
25886 | }
|
25887 |
|
25888 | if (config._f === hooks.RFC_2822) {
|
25889 | configFromRFC2822(config);
|
25890 | return;
|
25891 | }
|
25892 |
|
25893 | config._a = [];
|
25894 | getParsingFlags(config).empty = true;
|
25895 |
|
25896 | var string = '' + config._i,
|
25897 | i,
|
25898 | parsedInput,
|
25899 | tokens,
|
25900 | token,
|
25901 | skipped,
|
25902 | stringLength = string.length,
|
25903 | totalParsedInputLength = 0;
|
25904 | tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
|
25905 |
|
25906 | for (i = 0; i < tokens.length; i++) {
|
25907 | token = tokens[i];
|
25908 | parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
|
25909 |
|
25910 |
|
25911 | if (parsedInput) {
|
25912 | skipped = string.substr(0, string.indexOf(parsedInput));
|
25913 |
|
25914 | if (skipped.length > 0) {
|
25915 | getParsingFlags(config).unusedInput.push(skipped);
|
25916 | }
|
25917 |
|
25918 | string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
|
25919 | totalParsedInputLength += parsedInput.length;
|
25920 | }
|
25921 |
|
25922 |
|
25923 | if (formatTokenFunctions[token]) {
|
25924 | if (parsedInput) {
|
25925 | getParsingFlags(config).empty = false;
|
25926 | } else {
|
25927 | getParsingFlags(config).unusedTokens.push(token);
|
25928 | }
|
25929 |
|
25930 | addTimeToArrayFromToken(token, parsedInput, config);
|
25931 | } else if (config._strict && !parsedInput) {
|
25932 | getParsingFlags(config).unusedTokens.push(token);
|
25933 | }
|
25934 | }
|
25935 |
|
25936 |
|
25937 | getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
|
25938 |
|
25939 | if (string.length > 0) {
|
25940 | getParsingFlags(config).unusedInput.push(string);
|
25941 | }
|
25942 |
|
25943 |
|
25944 | if (config._a[HOUR] <= 12 && getParsingFlags(config).bigHour === true && config._a[HOUR] > 0) {
|
25945 | getParsingFlags(config).bigHour = undefined;
|
25946 | }
|
25947 |
|
25948 | getParsingFlags(config).parsedDateParts = config._a.slice(0);
|
25949 | getParsingFlags(config).meridiem = config._meridiem;
|
25950 |
|
25951 | config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
25952 | configFromArray(config);
|
25953 | checkOverflow(config);
|
25954 | }
|
25955 |
|
25956 | function meridiemFixWrap(locale, hour, meridiem) {
|
25957 | var isPm;
|
25958 |
|
25959 | if (meridiem == null) {
|
25960 |
|
25961 | return hour;
|
25962 | }
|
25963 |
|
25964 | if (locale.meridiemHour != null) {
|
25965 | return locale.meridiemHour(hour, meridiem);
|
25966 | } else if (locale.isPM != null) {
|
25967 |
|
25968 | isPm = locale.isPM(meridiem);
|
25969 |
|
25970 | if (isPm && hour < 12) {
|
25971 | hour += 12;
|
25972 | }
|
25973 |
|
25974 | if (!isPm && hour === 12) {
|
25975 | hour = 0;
|
25976 | }
|
25977 |
|
25978 | return hour;
|
25979 | } else {
|
25980 |
|
25981 | return hour;
|
25982 | }
|
25983 | }
|
25984 |
|
25985 |
|
25986 | function configFromStringAndArray(config) {
|
25987 | var tempConfig, bestMoment, scoreToBeat, i, currentScore;
|
25988 |
|
25989 | if (config._f.length === 0) {
|
25990 | getParsingFlags(config).invalidFormat = true;
|
25991 | config._d = new Date(NaN);
|
25992 | return;
|
25993 | }
|
25994 |
|
25995 | for (i = 0; i < config._f.length; i++) {
|
25996 | currentScore = 0;
|
25997 | tempConfig = copyConfig({}, config);
|
25998 |
|
25999 | if (config._useUTC != null) {
|
26000 | tempConfig._useUTC = config._useUTC;
|
26001 | }
|
26002 |
|
26003 | tempConfig._f = config._f[i];
|
26004 | configFromStringAndFormat(tempConfig);
|
26005 |
|
26006 | if (!isValid(tempConfig)) {
|
26007 | continue;
|
26008 | }
|
26009 |
|
26010 |
|
26011 | currentScore += getParsingFlags(tempConfig).charsLeftOver;
|
26012 |
|
26013 | currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
|
26014 | getParsingFlags(tempConfig).score = currentScore;
|
26015 |
|
26016 | if (scoreToBeat == null || currentScore < scoreToBeat) {
|
26017 | scoreToBeat = currentScore;
|
26018 | bestMoment = tempConfig;
|
26019 | }
|
26020 | }
|
26021 |
|
26022 | extend(config, bestMoment || tempConfig);
|
26023 | }
|
26024 |
|
26025 | function configFromObject(config) {
|
26026 | if (config._d) {
|
26027 | return;
|
26028 | }
|
26029 |
|
26030 | var i = normalizeObjectUnits(config._i);
|
26031 | config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
|
26032 | return obj && parseInt(obj, 10);
|
26033 | });
|
26034 | configFromArray(config);
|
26035 | }
|
26036 |
|
26037 | function createFromConfig(config) {
|
26038 | var res = new Moment(checkOverflow(prepareConfig(config)));
|
26039 |
|
26040 | if (res._nextDay) {
|
26041 |
|
26042 | res.add(1, 'd');
|
26043 | res._nextDay = undefined;
|
26044 | }
|
26045 |
|
26046 | return res;
|
26047 | }
|
26048 |
|
26049 | function prepareConfig(config) {
|
26050 | var input = config._i,
|
26051 | format = config._f;
|
26052 | config._locale = config._locale || getLocale(config._l);
|
26053 |
|
26054 | if (input === null || format === undefined && input === '') {
|
26055 | return createInvalid({
|
26056 | nullInput: true
|
26057 | });
|
26058 | }
|
26059 |
|
26060 | if (typeof input === 'string') {
|
26061 | config._i = input = config._locale.preparse(input);
|
26062 | }
|
26063 |
|
26064 | if (isMoment(input)) {
|
26065 | return new Moment(checkOverflow(input));
|
26066 | } else if (isDate(input)) {
|
26067 | config._d = input;
|
26068 | } else if (isArray(format)) {
|
26069 | configFromStringAndArray(config);
|
26070 | } else if (format) {
|
26071 | configFromStringAndFormat(config);
|
26072 | } else {
|
26073 | configFromInput(config);
|
26074 | }
|
26075 |
|
26076 | if (!isValid(config)) {
|
26077 | config._d = null;
|
26078 | }
|
26079 |
|
26080 | return config;
|
26081 | }
|
26082 |
|
26083 | function configFromInput(config) {
|
26084 | var input = config._i;
|
26085 |
|
26086 | if (isUndefined(input)) {
|
26087 | config._d = new Date(hooks.now());
|
26088 | } else if (isDate(input)) {
|
26089 | config._d = new Date(input.valueOf());
|
26090 | } else if (typeof input === 'string') {
|
26091 | configFromString(config);
|
26092 | } else if (isArray(input)) {
|
26093 | config._a = map(input.slice(0), function (obj) {
|
26094 | return parseInt(obj, 10);
|
26095 | });
|
26096 | configFromArray(config);
|
26097 | } else if (isObject(input)) {
|
26098 | configFromObject(config);
|
26099 | } else if (isNumber(input)) {
|
26100 |
|
26101 | config._d = new Date(input);
|
26102 | } else {
|
26103 | hooks.createFromInputFallback(config);
|
26104 | }
|
26105 | }
|
26106 |
|
26107 | function createLocalOrUTC(input, format, locale, strict, isUTC) {
|
26108 | var c = {};
|
26109 |
|
26110 | if (locale === true || locale === false) {
|
26111 | strict = locale;
|
26112 | locale = undefined;
|
26113 | }
|
26114 |
|
26115 | if (isObject(input) && isObjectEmpty(input) || isArray(input) && input.length === 0) {
|
26116 | input = undefined;
|
26117 | }
|
26118 |
|
26119 |
|
26120 |
|
26121 | c._isAMomentObject = true;
|
26122 | c._useUTC = c._isUTC = isUTC;
|
26123 | c._l = locale;
|
26124 | c._i = input;
|
26125 | c._f = format;
|
26126 | c._strict = strict;
|
26127 | return createFromConfig(c);
|
26128 | }
|
26129 |
|
26130 | function createLocal(input, format, locale, strict) {
|
26131 | return createLocalOrUTC(input, format, locale, strict, false);
|
26132 | }
|
26133 |
|
26134 | var prototypeMin = deprecate('moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/', function () {
|
26135 | var other = createLocal.apply(null, arguments);
|
26136 |
|
26137 | if (this.isValid() && other.isValid()) {
|
26138 | return other < this ? this : other;
|
26139 | } else {
|
26140 | return createInvalid();
|
26141 | }
|
26142 | });
|
26143 | var prototypeMax = deprecate('moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', function () {
|
26144 | var other = createLocal.apply(null, arguments);
|
26145 |
|
26146 | if (this.isValid() && other.isValid()) {
|
26147 | return other > this ? this : other;
|
26148 | } else {
|
26149 | return createInvalid();
|
26150 | }
|
26151 | });
|
26152 |
|
26153 |
|
26154 |
|
26155 |
|
26156 |
|
26157 | function pickBy(fn, moments) {
|
26158 | var res, i;
|
26159 |
|
26160 | if (moments.length === 1 && isArray(moments[0])) {
|
26161 | moments = moments[0];
|
26162 | }
|
26163 |
|
26164 | if (!moments.length) {
|
26165 | return createLocal();
|
26166 | }
|
26167 |
|
26168 | res = moments[0];
|
26169 |
|
26170 | for (i = 1; i < moments.length; ++i) {
|
26171 | if (!moments[i].isValid() || moments[i][fn](res)) {
|
26172 | res = moments[i];
|
26173 | }
|
26174 | }
|
26175 |
|
26176 | return res;
|
26177 | }
|
26178 |
|
26179 |
|
26180 | function min() {
|
26181 | var args = [].slice.call(arguments, 0);
|
26182 | return pickBy('isBefore', args);
|
26183 | }
|
26184 |
|
26185 | function max() {
|
26186 | var args = [].slice.call(arguments, 0);
|
26187 | return pickBy('isAfter', args);
|
26188 | }
|
26189 |
|
26190 | var now = function () {
|
26191 | return Date.now ? Date.now() : +new Date();
|
26192 | };
|
26193 |
|
26194 | var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
|
26195 |
|
26196 | function isDurationValid(m) {
|
26197 | for (var key in m) {
|
26198 | if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
|
26199 | return false;
|
26200 | }
|
26201 | }
|
26202 |
|
26203 | var unitHasDecimal = false;
|
26204 |
|
26205 | for (var i = 0; i < ordering.length; ++i) {
|
26206 | if (m[ordering[i]]) {
|
26207 | if (unitHasDecimal) {
|
26208 | return false;
|
26209 | }
|
26210 |
|
26211 | if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
|
26212 | unitHasDecimal = true;
|
26213 | }
|
26214 | }
|
26215 | }
|
26216 |
|
26217 | return true;
|
26218 | }
|
26219 |
|
26220 | function isValid$1() {
|
26221 | return this._isValid;
|
26222 | }
|
26223 |
|
26224 | function createInvalid$1() {
|
26225 | return createDuration(NaN);
|
26226 | }
|
26227 |
|
26228 | function Duration(duration) {
|
26229 | var normalizedInput = normalizeObjectUnits(duration),
|
26230 | years = normalizedInput.year || 0,
|
26231 | quarters = normalizedInput.quarter || 0,
|
26232 | months = normalizedInput.month || 0,
|
26233 | weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
|
26234 | days = normalizedInput.day || 0,
|
26235 | hours = normalizedInput.hour || 0,
|
26236 | minutes = normalizedInput.minute || 0,
|
26237 | seconds = normalizedInput.second || 0,
|
26238 | milliseconds = normalizedInput.millisecond || 0;
|
26239 | this._isValid = isDurationValid(normalizedInput);
|
26240 |
|
26241 | this._milliseconds = +milliseconds + seconds * 1e3 +
|
26242 | minutes * 6e4 +
|
26243 | hours * 1000 * 60 * 60;
|
26244 |
|
26245 |
|
26246 |
|
26247 | this._days = +days + weeks * 7;
|
26248 |
|
26249 |
|
26250 |
|
26251 | this._months = +months + quarters * 3 + years * 12;
|
26252 | this._data = {};
|
26253 | this._locale = getLocale();
|
26254 |
|
26255 | this._bubble();
|
26256 | }
|
26257 |
|
26258 | function isDuration(obj) {
|
26259 | return obj instanceof Duration;
|
26260 | }
|
26261 |
|
26262 | function absRound(number) {
|
26263 | if (number < 0) {
|
26264 | return Math.round(-1 * number) * -1;
|
26265 | } else {
|
26266 | return Math.round(number);
|
26267 | }
|
26268 | }
|
26269 |
|
26270 |
|
26271 | function offset(token, separator) {
|
26272 | addFormatToken(token, 0, 0, function () {
|
26273 | var offset = this.utcOffset();
|
26274 | var sign = '+';
|
26275 |
|
26276 | if (offset < 0) {
|
26277 | offset = -offset;
|
26278 | sign = '-';
|
26279 | }
|
26280 |
|
26281 | return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~offset % 60, 2);
|
26282 | });
|
26283 | }
|
26284 |
|
26285 | offset('Z', ':');
|
26286 | offset('ZZ', '');
|
26287 |
|
26288 | addRegexToken('Z', matchShortOffset);
|
26289 | addRegexToken('ZZ', matchShortOffset);
|
26290 | addParseToken(['Z', 'ZZ'], function (input, array, config) {
|
26291 | config._useUTC = true;
|
26292 | config._tzm = offsetFromString(matchShortOffset, input);
|
26293 | });
|
26294 |
|
26295 |
|
26296 |
|
26297 |
|
26298 | var chunkOffset = /([\+\-]|\d\d)/gi;
|
26299 |
|
26300 | function offsetFromString(matcher, string) {
|
26301 | var matches = (string || '').match(matcher);
|
26302 |
|
26303 | if (matches === null) {
|
26304 | return null;
|
26305 | }
|
26306 |
|
26307 | var chunk = matches[matches.length - 1] || [];
|
26308 | var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
|
26309 | var minutes = +(parts[1] * 60) + toInt(parts[2]);
|
26310 | return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
|
26311 | }
|
26312 |
|
26313 |
|
26314 | function cloneWithOffset(input, model) {
|
26315 | var res, diff;
|
26316 |
|
26317 | if (model._isUTC) {
|
26318 | res = model.clone();
|
26319 | diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
|
26320 |
|
26321 | res._d.setTime(res._d.valueOf() + diff);
|
26322 |
|
26323 | hooks.updateOffset(res, false);
|
26324 | return res;
|
26325 | } else {
|
26326 | return createLocal(input).local();
|
26327 | }
|
26328 | }
|
26329 |
|
26330 | function getDateOffset(m) {
|
26331 |
|
26332 |
|
26333 | return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
|
26334 | }
|
26335 |
|
26336 |
|
26337 |
|
26338 |
|
26339 | hooks.updateOffset = function () {};
|
26340 |
|
26341 |
|
26342 |
|
26343 |
|
26344 |
|
26345 |
|
26346 |
|
26347 |
|
26348 |
|
26349 |
|
26350 |
|
26351 |
|
26352 | function getSetOffset(input, keepLocalTime, keepMinutes) {
|
26353 | var offset = this._offset || 0,
|
26354 | localAdjust;
|
26355 |
|
26356 | if (!this.isValid()) {
|
26357 | return input != null ? this : NaN;
|
26358 | }
|
26359 |
|
26360 | if (input != null) {
|
26361 | if (typeof input === 'string') {
|
26362 | input = offsetFromString(matchShortOffset, input);
|
26363 |
|
26364 | if (input === null) {
|
26365 | return this;
|
26366 | }
|
26367 | } else if (Math.abs(input) < 16 && !keepMinutes) {
|
26368 | input = input * 60;
|
26369 | }
|
26370 |
|
26371 | if (!this._isUTC && keepLocalTime) {
|
26372 | localAdjust = getDateOffset(this);
|
26373 | }
|
26374 |
|
26375 | this._offset = input;
|
26376 | this._isUTC = true;
|
26377 |
|
26378 | if (localAdjust != null) {
|
26379 | this.add(localAdjust, 'm');
|
26380 | }
|
26381 |
|
26382 | if (offset !== input) {
|
26383 | if (!keepLocalTime || this._changeInProgress) {
|
26384 | addSubtract(this, createDuration(input - offset, 'm'), 1, false);
|
26385 | } else if (!this._changeInProgress) {
|
26386 | this._changeInProgress = true;
|
26387 | hooks.updateOffset(this, true);
|
26388 | this._changeInProgress = null;
|
26389 | }
|
26390 | }
|
26391 |
|
26392 | return this;
|
26393 | } else {
|
26394 | return this._isUTC ? offset : getDateOffset(this);
|
26395 | }
|
26396 | }
|
26397 |
|
26398 | function getSetZone(input, keepLocalTime) {
|
26399 | if (input != null) {
|
26400 | if (typeof input !== 'string') {
|
26401 | input = -input;
|
26402 | }
|
26403 |
|
26404 | this.utcOffset(input, keepLocalTime);
|
26405 | return this;
|
26406 | } else {
|
26407 | return -this.utcOffset();
|
26408 | }
|
26409 | }
|
26410 |
|
26411 | function setOffsetToUTC(keepLocalTime) {
|
26412 | return this.utcOffset(0, keepLocalTime);
|
26413 | }
|
26414 |
|
26415 | function setOffsetToLocal(keepLocalTime) {
|
26416 | if (this._isUTC) {
|
26417 | this.utcOffset(0, keepLocalTime);
|
26418 | this._isUTC = false;
|
26419 |
|
26420 | if (keepLocalTime) {
|
26421 | this.subtract(getDateOffset(this), 'm');
|
26422 | }
|
26423 | }
|
26424 |
|
26425 | return this;
|
26426 | }
|
26427 |
|
26428 | function setOffsetToParsedOffset() {
|
26429 | if (this._tzm != null) {
|
26430 | this.utcOffset(this._tzm, false, true);
|
26431 | } else if (typeof this._i === 'string') {
|
26432 | var tZone = offsetFromString(matchOffset, this._i);
|
26433 |
|
26434 | if (tZone != null) {
|
26435 | this.utcOffset(tZone);
|
26436 | } else {
|
26437 | this.utcOffset(0, true);
|
26438 | }
|
26439 | }
|
26440 |
|
26441 | return this;
|
26442 | }
|
26443 |
|
26444 | function hasAlignedHourOffset(input) {
|
26445 | if (!this.isValid()) {
|
26446 | return false;
|
26447 | }
|
26448 |
|
26449 | input = input ? createLocal(input).utcOffset() : 0;
|
26450 | return (this.utcOffset() - input) % 60 === 0;
|
26451 | }
|
26452 |
|
26453 | function isDaylightSavingTime() {
|
26454 | return this.utcOffset() > this.clone().month(0).utcOffset() || this.utcOffset() > this.clone().month(5).utcOffset();
|
26455 | }
|
26456 |
|
26457 | function isDaylightSavingTimeShifted() {
|
26458 | if (!isUndefined(this._isDSTShifted)) {
|
26459 | return this._isDSTShifted;
|
26460 | }
|
26461 |
|
26462 | var c = {};
|
26463 | copyConfig(c, this);
|
26464 | c = prepareConfig(c);
|
26465 |
|
26466 | if (c._a) {
|
26467 | var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
|
26468 | this._isDSTShifted = this.isValid() && compareArrays(c._a, other.toArray()) > 0;
|
26469 | } else {
|
26470 | this._isDSTShifted = false;
|
26471 | }
|
26472 |
|
26473 | return this._isDSTShifted;
|
26474 | }
|
26475 |
|
26476 | function isLocal() {
|
26477 | return this.isValid() ? !this._isUTC : false;
|
26478 | }
|
26479 |
|
26480 | function isUtcOffset() {
|
26481 | return this.isValid() ? this._isUTC : false;
|
26482 | }
|
26483 |
|
26484 | function isUtc() {
|
26485 | return this.isValid() ? this._isUTC && this._offset === 0 : false;
|
26486 | }
|
26487 |
|
26488 |
|
26489 | var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
|
26490 |
|
26491 |
|
26492 |
|
26493 | var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
|
26494 |
|
26495 | function createDuration(input, key) {
|
26496 | var duration = input,
|
26497 |
|
26498 | match = null,
|
26499 | sign,
|
26500 | ret,
|
26501 | diffRes;
|
26502 |
|
26503 | if (isDuration(input)) {
|
26504 | duration = {
|
26505 | ms: input._milliseconds,
|
26506 | d: input._days,
|
26507 | M: input._months
|
26508 | };
|
26509 | } else if (isNumber(input)) {
|
26510 | duration = {};
|
26511 |
|
26512 | if (key) {
|
26513 | duration[key] = input;
|
26514 | } else {
|
26515 | duration.milliseconds = input;
|
26516 | }
|
26517 | } else if (!!(match = aspNetRegex.exec(input))) {
|
26518 | sign = match[1] === '-' ? -1 : 1;
|
26519 | duration = {
|
26520 | y: 0,
|
26521 | d: toInt(match[DATE]) * sign,
|
26522 | h: toInt(match[HOUR]) * sign,
|
26523 | m: toInt(match[MINUTE]) * sign,
|
26524 | s: toInt(match[SECOND]) * sign,
|
26525 | ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign
|
26526 |
|
26527 | };
|
26528 | } else if (!!(match = isoRegex.exec(input))) {
|
26529 | sign = match[1] === '-' ? -1 : 1;
|
26530 | duration = {
|
26531 | y: parseIso(match[2], sign),
|
26532 | M: parseIso(match[3], sign),
|
26533 | w: parseIso(match[4], sign),
|
26534 | d: parseIso(match[5], sign),
|
26535 | h: parseIso(match[6], sign),
|
26536 | m: parseIso(match[7], sign),
|
26537 | s: parseIso(match[8], sign)
|
26538 | };
|
26539 | } else if (duration == null) {
|
26540 |
|
26541 | duration = {};
|
26542 | } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
|
26543 | diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
|
26544 | duration = {};
|
26545 | duration.ms = diffRes.milliseconds;
|
26546 | duration.M = diffRes.months;
|
26547 | }
|
26548 |
|
26549 | ret = new Duration(duration);
|
26550 |
|
26551 | if (isDuration(input) && hasOwnProp(input, '_locale')) {
|
26552 | ret._locale = input._locale;
|
26553 | }
|
26554 |
|
26555 | return ret;
|
26556 | }
|
26557 |
|
26558 | createDuration.fn = Duration.prototype;
|
26559 | createDuration.invalid = createInvalid$1;
|
26560 |
|
26561 | function parseIso(inp, sign) {
|
26562 |
|
26563 |
|
26564 |
|
26565 | var res = inp && parseFloat(inp.replace(',', '.'));
|
26566 |
|
26567 | return (isNaN(res) ? 0 : res) * sign;
|
26568 | }
|
26569 |
|
26570 | function positiveMomentsDifference(base, other) {
|
26571 | var res = {};
|
26572 | res.months = other.month() - base.month() + (other.year() - base.year()) * 12;
|
26573 |
|
26574 | if (base.clone().add(res.months, 'M').isAfter(other)) {
|
26575 | --res.months;
|
26576 | }
|
26577 |
|
26578 | res.milliseconds = +other - +base.clone().add(res.months, 'M');
|
26579 | return res;
|
26580 | }
|
26581 |
|
26582 | function momentsDifference(base, other) {
|
26583 | var res;
|
26584 |
|
26585 | if (!(base.isValid() && other.isValid())) {
|
26586 | return {
|
26587 | milliseconds: 0,
|
26588 | months: 0
|
26589 | };
|
26590 | }
|
26591 |
|
26592 | other = cloneWithOffset(other, base);
|
26593 |
|
26594 | if (base.isBefore(other)) {
|
26595 | res = positiveMomentsDifference(base, other);
|
26596 | } else {
|
26597 | res = positiveMomentsDifference(other, base);
|
26598 | res.milliseconds = -res.milliseconds;
|
26599 | res.months = -res.months;
|
26600 | }
|
26601 |
|
26602 | return res;
|
26603 | }
|
26604 |
|
26605 |
|
26606 | function createAdder(direction, name) {
|
26607 | return function (val, period) {
|
26608 | var dur, tmp;
|
26609 |
|
26610 | if (period !== null && !isNaN(+period)) {
|
26611 | deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' + 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
|
26612 | tmp = val;
|
26613 | val = period;
|
26614 | period = tmp;
|
26615 | }
|
26616 |
|
26617 | val = typeof val === 'string' ? +val : val;
|
26618 | dur = createDuration(val, period);
|
26619 | addSubtract(this, dur, direction);
|
26620 | return this;
|
26621 | };
|
26622 | }
|
26623 |
|
26624 | function addSubtract(mom, duration, isAdding, updateOffset) {
|
26625 | var milliseconds = duration._milliseconds,
|
26626 | days = absRound(duration._days),
|
26627 | months = absRound(duration._months);
|
26628 |
|
26629 | if (!mom.isValid()) {
|
26630 |
|
26631 | return;
|
26632 | }
|
26633 |
|
26634 | updateOffset = updateOffset == null ? true : updateOffset;
|
26635 |
|
26636 | if (months) {
|
26637 | setMonth(mom, get(mom, 'Month') + months * isAdding);
|
26638 | }
|
26639 |
|
26640 | if (days) {
|
26641 | set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
|
26642 | }
|
26643 |
|
26644 | if (milliseconds) {
|
26645 | mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
|
26646 | }
|
26647 |
|
26648 | if (updateOffset) {
|
26649 | hooks.updateOffset(mom, days || months);
|
26650 | }
|
26651 | }
|
26652 |
|
26653 | var add = createAdder(1, 'add');
|
26654 | var subtract = createAdder(-1, 'subtract');
|
26655 |
|
26656 | function getCalendarFormat(myMoment, now) {
|
26657 | var diff = myMoment.diff(now, 'days', true);
|
26658 | return diff < -6 ? 'sameElse' : diff < -1 ? 'lastWeek' : diff < 0 ? 'lastDay' : diff < 1 ? 'sameDay' : diff < 2 ? 'nextDay' : diff < 7 ? 'nextWeek' : 'sameElse';
|
26659 | }
|
26660 |
|
26661 | function calendar$1(time, formats) {
|
26662 |
|
26663 |
|
26664 | var now = time || createLocal(),
|
26665 | sod = cloneWithOffset(now, this).startOf('day'),
|
26666 | format = hooks.calendarFormat(this, sod) || 'sameElse';
|
26667 | var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
|
26668 | return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
|
26669 | }
|
26670 |
|
26671 | function clone() {
|
26672 | return new Moment(this);
|
26673 | }
|
26674 |
|
26675 | function isAfter(input, units) {
|
26676 | var localInput = isMoment(input) ? input : createLocal(input);
|
26677 |
|
26678 | if (!(this.isValid() && localInput.isValid())) {
|
26679 | return false;
|
26680 | }
|
26681 |
|
26682 | units = normalizeUnits(units) || 'millisecond';
|
26683 |
|
26684 | if (units === 'millisecond') {
|
26685 | return this.valueOf() > localInput.valueOf();
|
26686 | } else {
|
26687 | return localInput.valueOf() < this.clone().startOf(units).valueOf();
|
26688 | }
|
26689 | }
|
26690 |
|
26691 | function isBefore(input, units) {
|
26692 | var localInput = isMoment(input) ? input : createLocal(input);
|
26693 |
|
26694 | if (!(this.isValid() && localInput.isValid())) {
|
26695 | return false;
|
26696 | }
|
26697 |
|
26698 | units = normalizeUnits(units) || 'millisecond';
|
26699 |
|
26700 | if (units === 'millisecond') {
|
26701 | return this.valueOf() < localInput.valueOf();
|
26702 | } else {
|
26703 | return this.clone().endOf(units).valueOf() < localInput.valueOf();
|
26704 | }
|
26705 | }
|
26706 |
|
26707 | function isBetween(from, to, units, inclusivity) {
|
26708 | var localFrom = isMoment(from) ? from : createLocal(from),
|
26709 | localTo = isMoment(to) ? to : createLocal(to);
|
26710 |
|
26711 | if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
|
26712 | return false;
|
26713 | }
|
26714 |
|
26715 | inclusivity = inclusivity || '()';
|
26716 | return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) && (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
|
26717 | }
|
26718 |
|
26719 | function isSame(input, units) {
|
26720 | var localInput = isMoment(input) ? input : createLocal(input),
|
26721 | inputMs;
|
26722 |
|
26723 | if (!(this.isValid() && localInput.isValid())) {
|
26724 | return false;
|
26725 | }
|
26726 |
|
26727 | units = normalizeUnits(units) || 'millisecond';
|
26728 |
|
26729 | if (units === 'millisecond') {
|
26730 | return this.valueOf() === localInput.valueOf();
|
26731 | } else {
|
26732 | inputMs = localInput.valueOf();
|
26733 | return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
|
26734 | }
|
26735 | }
|
26736 |
|
26737 | function isSameOrAfter(input, units) {
|
26738 | return this.isSame(input, units) || this.isAfter(input, units);
|
26739 | }
|
26740 |
|
26741 | function isSameOrBefore(input, units) {
|
26742 | return this.isSame(input, units) || this.isBefore(input, units);
|
26743 | }
|
26744 |
|
26745 | function diff(input, units, asFloat) {
|
26746 | var that, zoneDelta, output;
|
26747 |
|
26748 | if (!this.isValid()) {
|
26749 | return NaN;
|
26750 | }
|
26751 |
|
26752 | that = cloneWithOffset(input, this);
|
26753 |
|
26754 | if (!that.isValid()) {
|
26755 | return NaN;
|
26756 | }
|
26757 |
|
26758 | zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
|
26759 | units = normalizeUnits(units);
|
26760 |
|
26761 | switch (units) {
|
26762 | case 'year':
|
26763 | output = monthDiff(this, that) / 12;
|
26764 | break;
|
26765 |
|
26766 | case 'month':
|
26767 | output = monthDiff(this, that);
|
26768 | break;
|
26769 |
|
26770 | case 'quarter':
|
26771 | output = monthDiff(this, that) / 3;
|
26772 | break;
|
26773 |
|
26774 | case 'second':
|
26775 | output = (this - that) / 1e3;
|
26776 | break;
|
26777 |
|
26778 |
|
26779 | case 'minute':
|
26780 | output = (this - that) / 6e4;
|
26781 | break;
|
26782 |
|
26783 |
|
26784 | case 'hour':
|
26785 | output = (this - that) / 36e5;
|
26786 | break;
|
26787 |
|
26788 |
|
26789 | case 'day':
|
26790 | output = (this - that - zoneDelta) / 864e5;
|
26791 | break;
|
26792 |
|
26793 |
|
26794 | case 'week':
|
26795 | output = (this - that - zoneDelta) / 6048e5;
|
26796 | break;
|
26797 |
|
26798 |
|
26799 | default:
|
26800 | output = this - that;
|
26801 | }
|
26802 |
|
26803 | return asFloat ? output : absFloor(output);
|
26804 | }
|
26805 |
|
26806 | function monthDiff(a, b) {
|
26807 |
|
26808 | var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
|
26809 |
|
26810 | anchor = a.clone().add(wholeMonthDiff, 'months'),
|
26811 | anchor2,
|
26812 | adjust;
|
26813 |
|
26814 | if (b - anchor < 0) {
|
26815 | anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
|
26816 |
|
26817 | adjust = (b - anchor) / (anchor - anchor2);
|
26818 | } else {
|
26819 | anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
|
26820 |
|
26821 | adjust = (b - anchor) / (anchor2 - anchor);
|
26822 | }
|
26823 |
|
26824 |
|
26825 | return -(wholeMonthDiff + adjust) || 0;
|
26826 | }
|
26827 |
|
26828 | hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
|
26829 | hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
|
26830 |
|
26831 | function toString() {
|
26832 | return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
|
26833 | }
|
26834 |
|
26835 | function toISOString(keepOffset) {
|
26836 | if (!this.isValid()) {
|
26837 | return null;
|
26838 | }
|
26839 |
|
26840 | var utc = keepOffset !== true;
|
26841 | var m = utc ? this.clone().utc() : this;
|
26842 |
|
26843 | if (m.year() < 0 || m.year() > 9999) {
|
26844 | return formatMoment(m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
26845 | }
|
26846 |
|
26847 | if (isFunction(Date.prototype.toISOString)) {
|
26848 |
|
26849 | if (utc) {
|
26850 | return this.toDate().toISOString();
|
26851 | } else {
|
26852 | return new Date(this.valueOf() + this.utcOffset() * 60 * 1000).toISOString().replace('Z', formatMoment(m, 'Z'));
|
26853 | }
|
26854 | }
|
26855 |
|
26856 | return formatMoment(m, utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
26857 | }
|
26858 | |
26859 |
|
26860 |
|
26861 |
|
26862 |
|
26863 |
|
26864 |
|
26865 |
|
26866 | function inspect() {
|
26867 | if (!this.isValid()) {
|
26868 | return 'moment.invalid(/* ' + this._i + ' */)';
|
26869 | }
|
26870 |
|
26871 | var func = 'moment';
|
26872 | var zone = '';
|
26873 |
|
26874 | if (!this.isLocal()) {
|
26875 | func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
|
26876 | zone = 'Z';
|
26877 | }
|
26878 |
|
26879 | var prefix = '[' + func + '("]';
|
26880 | var year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
|
26881 | var datetime = '-MM-DD[T]HH:mm:ss.SSS';
|
26882 | var suffix = zone + '[")]';
|
26883 | return this.format(prefix + year + datetime + suffix);
|
26884 | }
|
26885 |
|
26886 | function format(inputString) {
|
26887 | if (!inputString) {
|
26888 | inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
|
26889 | }
|
26890 |
|
26891 | var output = formatMoment(this, inputString);
|
26892 | return this.localeData().postformat(output);
|
26893 | }
|
26894 |
|
26895 | function from(time, withoutSuffix) {
|
26896 | if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
|
26897 | return createDuration({
|
26898 | to: this,
|
26899 | from: time
|
26900 | }).locale(this.locale()).humanize(!withoutSuffix);
|
26901 | } else {
|
26902 | return this.localeData().invalidDate();
|
26903 | }
|
26904 | }
|
26905 |
|
26906 | function fromNow(withoutSuffix) {
|
26907 | return this.from(createLocal(), withoutSuffix);
|
26908 | }
|
26909 |
|
26910 | function to(time, withoutSuffix) {
|
26911 | if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
|
26912 | return createDuration({
|
26913 | from: this,
|
26914 | to: time
|
26915 | }).locale(this.locale()).humanize(!withoutSuffix);
|
26916 | } else {
|
26917 | return this.localeData().invalidDate();
|
26918 | }
|
26919 | }
|
26920 |
|
26921 | function toNow(withoutSuffix) {
|
26922 | return this.to(createLocal(), withoutSuffix);
|
26923 | }
|
26924 |
|
26925 |
|
26926 |
|
26927 |
|
26928 | function locale(key) {
|
26929 | var newLocaleData;
|
26930 |
|
26931 | if (key === undefined) {
|
26932 | return this._locale._abbr;
|
26933 | } else {
|
26934 | newLocaleData = getLocale(key);
|
26935 |
|
26936 | if (newLocaleData != null) {
|
26937 | this._locale = newLocaleData;
|
26938 | }
|
26939 |
|
26940 | return this;
|
26941 | }
|
26942 | }
|
26943 |
|
26944 | var lang = deprecate('moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', function (key) {
|
26945 | if (key === undefined) {
|
26946 | return this.localeData();
|
26947 | } else {
|
26948 | return this.locale(key);
|
26949 | }
|
26950 | });
|
26951 |
|
26952 | function localeData() {
|
26953 | return this._locale;
|
26954 | }
|
26955 |
|
26956 | var MS_PER_SECOND = 1000;
|
26957 | var MS_PER_MINUTE = 60 * MS_PER_SECOND;
|
26958 | var MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
26959 | var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
|
26960 |
|
26961 | function mod$1(dividend, divisor) {
|
26962 | return (dividend % divisor + divisor) % divisor;
|
26963 | }
|
26964 |
|
26965 | function localStartOfDate(y, m, d) {
|
26966 |
|
26967 | if (y < 100 && y >= 0) {
|
26968 |
|
26969 | return new Date(y + 400, m, d) - MS_PER_400_YEARS;
|
26970 | } else {
|
26971 | return new Date(y, m, d).valueOf();
|
26972 | }
|
26973 | }
|
26974 |
|
26975 | function utcStartOfDate(y, m, d) {
|
26976 |
|
26977 | if (y < 100 && y >= 0) {
|
26978 |
|
26979 | return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
|
26980 | } else {
|
26981 | return Date.UTC(y, m, d);
|
26982 | }
|
26983 | }
|
26984 |
|
26985 | function startOf(units) {
|
26986 | var time;
|
26987 | units = normalizeUnits(units);
|
26988 |
|
26989 | if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
26990 | return this;
|
26991 | }
|
26992 |
|
26993 | var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
26994 |
|
26995 | switch (units) {
|
26996 | case 'year':
|
26997 | time = startOfDate(this.year(), 0, 1);
|
26998 | break;
|
26999 |
|
27000 | case 'quarter':
|
27001 | time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
|
27002 | break;
|
27003 |
|
27004 | case 'month':
|
27005 | time = startOfDate(this.year(), this.month(), 1);
|
27006 | break;
|
27007 |
|
27008 | case 'week':
|
27009 | time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
|
27010 | break;
|
27011 |
|
27012 | case 'isoWeek':
|
27013 | time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
|
27014 | break;
|
27015 |
|
27016 | case 'day':
|
27017 | case 'date':
|
27018 | time = startOfDate(this.year(), this.month(), this.date());
|
27019 | break;
|
27020 |
|
27021 | case 'hour':
|
27022 | time = this._d.valueOf();
|
27023 | time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
|
27024 | break;
|
27025 |
|
27026 | case 'minute':
|
27027 | time = this._d.valueOf();
|
27028 | time -= mod$1(time, MS_PER_MINUTE);
|
27029 | break;
|
27030 |
|
27031 | case 'second':
|
27032 | time = this._d.valueOf();
|
27033 | time -= mod$1(time, MS_PER_SECOND);
|
27034 | break;
|
27035 | }
|
27036 |
|
27037 | this._d.setTime(time);
|
27038 |
|
27039 | hooks.updateOffset(this, true);
|
27040 | return this;
|
27041 | }
|
27042 |
|
27043 | function endOf(units) {
|
27044 | var time;
|
27045 | units = normalizeUnits(units);
|
27046 |
|
27047 | if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
27048 | return this;
|
27049 | }
|
27050 |
|
27051 | var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
27052 |
|
27053 | switch (units) {
|
27054 | case 'year':
|
27055 | time = startOfDate(this.year() + 1, 0, 1) - 1;
|
27056 | break;
|
27057 |
|
27058 | case 'quarter':
|
27059 | time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
|
27060 | break;
|
27061 |
|
27062 | case 'month':
|
27063 | time = startOfDate(this.year(), this.month() + 1, 1) - 1;
|
27064 | break;
|
27065 |
|
27066 | case 'week':
|
27067 | time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
|
27068 | break;
|
27069 |
|
27070 | case 'isoWeek':
|
27071 | time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
|
27072 | break;
|
27073 |
|
27074 | case 'day':
|
27075 | case 'date':
|
27076 | time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
|
27077 | break;
|
27078 |
|
27079 | case 'hour':
|
27080 | time = this._d.valueOf();
|
27081 | time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
|
27082 | break;
|
27083 |
|
27084 | case 'minute':
|
27085 | time = this._d.valueOf();
|
27086 | time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
|
27087 | break;
|
27088 |
|
27089 | case 'second':
|
27090 | time = this._d.valueOf();
|
27091 | time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
|
27092 | break;
|
27093 | }
|
27094 |
|
27095 | this._d.setTime(time);
|
27096 |
|
27097 | hooks.updateOffset(this, true);
|
27098 | return this;
|
27099 | }
|
27100 |
|
27101 | function valueOf() {
|
27102 | return this._d.valueOf() - (this._offset || 0) * 60000;
|
27103 | }
|
27104 |
|
27105 | function unix() {
|
27106 | return Math.floor(this.valueOf() / 1000);
|
27107 | }
|
27108 |
|
27109 | function toDate() {
|
27110 | return new Date(this.valueOf());
|
27111 | }
|
27112 |
|
27113 | function toArray() {
|
27114 | var m = this;
|
27115 | return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
|
27116 | }
|
27117 |
|
27118 | function toObject() {
|
27119 | var m = this;
|
27120 | return {
|
27121 | years: m.year(),
|
27122 | months: m.month(),
|
27123 | date: m.date(),
|
27124 | hours: m.hours(),
|
27125 | minutes: m.minutes(),
|
27126 | seconds: m.seconds(),
|
27127 | milliseconds: m.milliseconds()
|
27128 | };
|
27129 | }
|
27130 |
|
27131 | function toJSON() {
|
27132 |
|
27133 | return this.isValid() ? this.toISOString() : null;
|
27134 | }
|
27135 |
|
27136 | function isValid$2() {
|
27137 | return isValid(this);
|
27138 | }
|
27139 |
|
27140 | function parsingFlags() {
|
27141 | return extend({}, getParsingFlags(this));
|
27142 | }
|
27143 |
|
27144 | function invalidAt() {
|
27145 | return getParsingFlags(this).overflow;
|
27146 | }
|
27147 |
|
27148 | function creationData() {
|
27149 | return {
|
27150 | input: this._i,
|
27151 | format: this._f,
|
27152 | locale: this._locale,
|
27153 | isUTC: this._isUTC,
|
27154 | strict: this._strict
|
27155 | };
|
27156 | }
|
27157 |
|
27158 |
|
27159 | addFormatToken(0, ['gg', 2], 0, function () {
|
27160 | return this.weekYear() % 100;
|
27161 | });
|
27162 | addFormatToken(0, ['GG', 2], 0, function () {
|
27163 | return this.isoWeekYear() % 100;
|
27164 | });
|
27165 |
|
27166 | function addWeekYearFormatToken(token, getter) {
|
27167 | addFormatToken(0, [token, token.length], 0, getter);
|
27168 | }
|
27169 |
|
27170 | addWeekYearFormatToken('gggg', 'weekYear');
|
27171 | addWeekYearFormatToken('ggggg', 'weekYear');
|
27172 | addWeekYearFormatToken('GGGG', 'isoWeekYear');
|
27173 | addWeekYearFormatToken('GGGGG', 'isoWeekYear');
|
27174 |
|
27175 | addUnitAlias('weekYear', 'gg');
|
27176 | addUnitAlias('isoWeekYear', 'GG');
|
27177 |
|
27178 | addUnitPriority('weekYear', 1);
|
27179 | addUnitPriority('isoWeekYear', 1);
|
27180 |
|
27181 | addRegexToken('G', matchSigned);
|
27182 | addRegexToken('g', matchSigned);
|
27183 | addRegexToken('GG', match1to2, match2);
|
27184 | addRegexToken('gg', match1to2, match2);
|
27185 | addRegexToken('GGGG', match1to4, match4);
|
27186 | addRegexToken('gggg', match1to4, match4);
|
27187 | addRegexToken('GGGGG', match1to6, match6);
|
27188 | addRegexToken('ggggg', match1to6, match6);
|
27189 | addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
|
27190 | week[token.substr(0, 2)] = toInt(input);
|
27191 | });
|
27192 | addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
|
27193 | week[token] = hooks.parseTwoDigitYear(input);
|
27194 | });
|
27195 |
|
27196 | function getSetWeekYear(input) {
|
27197 | return getSetWeekYearHelper.call(this, input, this.week(), this.weekday(), this.localeData()._week.dow, this.localeData()._week.doy);
|
27198 | }
|
27199 |
|
27200 | function getSetISOWeekYear(input) {
|
27201 | return getSetWeekYearHelper.call(this, input, this.isoWeek(), this.isoWeekday(), 1, 4);
|
27202 | }
|
27203 |
|
27204 | function getISOWeeksInYear() {
|
27205 | return weeksInYear(this.year(), 1, 4);
|
27206 | }
|
27207 |
|
27208 | function getWeeksInYear() {
|
27209 | var weekInfo = this.localeData()._week;
|
27210 |
|
27211 | return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
|
27212 | }
|
27213 |
|
27214 | function getSetWeekYearHelper(input, week, weekday, dow, doy) {
|
27215 | var weeksTarget;
|
27216 |
|
27217 | if (input == null) {
|
27218 | return weekOfYear(this, dow, doy).year;
|
27219 | } else {
|
27220 | weeksTarget = weeksInYear(input, dow, doy);
|
27221 |
|
27222 | if (week > weeksTarget) {
|
27223 | week = weeksTarget;
|
27224 | }
|
27225 |
|
27226 | return setWeekAll.call(this, input, week, weekday, dow, doy);
|
27227 | }
|
27228 | }
|
27229 |
|
27230 | function setWeekAll(weekYear, week, weekday, dow, doy) {
|
27231 | var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
|
27232 | date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
|
27233 | this.year(date.getUTCFullYear());
|
27234 | this.month(date.getUTCMonth());
|
27235 | this.date(date.getUTCDate());
|
27236 | return this;
|
27237 | }
|
27238 |
|
27239 |
|
27240 | addFormatToken('Q', 0, 'Qo', 'quarter');
|
27241 |
|
27242 | addUnitAlias('quarter', 'Q');
|
27243 |
|
27244 | addUnitPriority('quarter', 7);
|
27245 |
|
27246 | addRegexToken('Q', match1);
|
27247 | addParseToken('Q', function (input, array) {
|
27248 | array[MONTH] = (toInt(input) - 1) * 3;
|
27249 | });
|
27250 |
|
27251 | function getSetQuarter(input) {
|
27252 | return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
|
27253 | }
|
27254 |
|
27255 |
|
27256 | addFormatToken('D', ['DD', 2], 'Do', 'date');
|
27257 |
|
27258 | addUnitAlias('date', 'D');
|
27259 |
|
27260 | addUnitPriority('date', 9);
|
27261 |
|
27262 | addRegexToken('D', match1to2);
|
27263 | addRegexToken('DD', match1to2, match2);
|
27264 | addRegexToken('Do', function (isStrict, locale) {
|
27265 |
|
27266 | return isStrict ? locale._dayOfMonthOrdinalParse || locale._ordinalParse : locale._dayOfMonthOrdinalParseLenient;
|
27267 | });
|
27268 | addParseToken(['D', 'DD'], DATE);
|
27269 | addParseToken('Do', function (input, array) {
|
27270 | array[DATE] = toInt(input.match(match1to2)[0]);
|
27271 | });
|
27272 |
|
27273 | var getSetDayOfMonth = makeGetSet('Date', true);
|
27274 |
|
27275 | addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
|
27276 |
|
27277 | addUnitAlias('dayOfYear', 'DDD');
|
27278 |
|
27279 | addUnitPriority('dayOfYear', 4);
|
27280 |
|
27281 | addRegexToken('DDD', match1to3);
|
27282 | addRegexToken('DDDD', match3);
|
27283 | addParseToken(['DDD', 'DDDD'], function (input, array, config) {
|
27284 | config._dayOfYear = toInt(input);
|
27285 | });
|
27286 |
|
27287 |
|
27288 | function getSetDayOfYear(input) {
|
27289 | var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
|
27290 | return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
|
27291 | }
|
27292 |
|
27293 |
|
27294 | addFormatToken('m', ['mm', 2], 0, 'minute');
|
27295 |
|
27296 | addUnitAlias('minute', 'm');
|
27297 |
|
27298 | addUnitPriority('minute', 14);
|
27299 |
|
27300 | addRegexToken('m', match1to2);
|
27301 | addRegexToken('mm', match1to2, match2);
|
27302 | addParseToken(['m', 'mm'], MINUTE);
|
27303 |
|
27304 | var getSetMinute = makeGetSet('Minutes', false);
|
27305 |
|
27306 | addFormatToken('s', ['ss', 2], 0, 'second');
|
27307 |
|
27308 | addUnitAlias('second', 's');
|
27309 |
|
27310 | addUnitPriority('second', 15);
|
27311 |
|
27312 | addRegexToken('s', match1to2);
|
27313 | addRegexToken('ss', match1to2, match2);
|
27314 | addParseToken(['s', 'ss'], SECOND);
|
27315 |
|
27316 | var getSetSecond = makeGetSet('Seconds', false);
|
27317 |
|
27318 | addFormatToken('S', 0, 0, function () {
|
27319 | return ~~(this.millisecond() / 100);
|
27320 | });
|
27321 | addFormatToken(0, ['SS', 2], 0, function () {
|
27322 | return ~~(this.millisecond() / 10);
|
27323 | });
|
27324 | addFormatToken(0, ['SSS', 3], 0, 'millisecond');
|
27325 | addFormatToken(0, ['SSSS', 4], 0, function () {
|
27326 | return this.millisecond() * 10;
|
27327 | });
|
27328 | addFormatToken(0, ['SSSSS', 5], 0, function () {
|
27329 | return this.millisecond() * 100;
|
27330 | });
|
27331 | addFormatToken(0, ['SSSSSS', 6], 0, function () {
|
27332 | return this.millisecond() * 1000;
|
27333 | });
|
27334 | addFormatToken(0, ['SSSSSSS', 7], 0, function () {
|
27335 | return this.millisecond() * 10000;
|
27336 | });
|
27337 | addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
|
27338 | return this.millisecond() * 100000;
|
27339 | });
|
27340 | addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
|
27341 | return this.millisecond() * 1000000;
|
27342 | });
|
27343 |
|
27344 | addUnitAlias('millisecond', 'ms');
|
27345 |
|
27346 | addUnitPriority('millisecond', 16);
|
27347 |
|
27348 | addRegexToken('S', match1to3, match1);
|
27349 | addRegexToken('SS', match1to3, match2);
|
27350 | addRegexToken('SSS', match1to3, match3);
|
27351 | var token;
|
27352 |
|
27353 | for (token = 'SSSS'; token.length <= 9; token += 'S') {
|
27354 | addRegexToken(token, matchUnsigned);
|
27355 | }
|
27356 |
|
27357 | function parseMs(input, array) {
|
27358 | array[MILLISECOND] = toInt(('0.' + input) * 1000);
|
27359 | }
|
27360 |
|
27361 | for (token = 'S'; token.length <= 9; token += 'S') {
|
27362 | addParseToken(token, parseMs);
|
27363 | }
|
27364 |
|
27365 |
|
27366 | var getSetMillisecond = makeGetSet('Milliseconds', false);
|
27367 |
|
27368 | addFormatToken('z', 0, 0, 'zoneAbbr');
|
27369 | addFormatToken('zz', 0, 0, 'zoneName');
|
27370 |
|
27371 | function getZoneAbbr() {
|
27372 | return this._isUTC ? 'UTC' : '';
|
27373 | }
|
27374 |
|
27375 | function getZoneName() {
|
27376 | return this._isUTC ? 'Coordinated Universal Time' : '';
|
27377 | }
|
27378 |
|
27379 | var proto = Moment.prototype;
|
27380 | proto.add = add;
|
27381 | proto.calendar = calendar$1;
|
27382 | proto.clone = clone;
|
27383 | proto.diff = diff;
|
27384 | proto.endOf = endOf;
|
27385 | proto.format = format;
|
27386 | proto.from = from;
|
27387 | proto.fromNow = fromNow;
|
27388 | proto.to = to;
|
27389 | proto.toNow = toNow;
|
27390 | proto.get = stringGet;
|
27391 | proto.invalidAt = invalidAt;
|
27392 | proto.isAfter = isAfter;
|
27393 | proto.isBefore = isBefore;
|
27394 | proto.isBetween = isBetween;
|
27395 | proto.isSame = isSame;
|
27396 | proto.isSameOrAfter = isSameOrAfter;
|
27397 | proto.isSameOrBefore = isSameOrBefore;
|
27398 | proto.isValid = isValid$2;
|
27399 | proto.lang = lang;
|
27400 | proto.locale = locale;
|
27401 | proto.localeData = localeData;
|
27402 | proto.max = prototypeMax;
|
27403 | proto.min = prototypeMin;
|
27404 | proto.parsingFlags = parsingFlags;
|
27405 | proto.set = stringSet;
|
27406 | proto.startOf = startOf;
|
27407 | proto.subtract = subtract;
|
27408 | proto.toArray = toArray;
|
27409 | proto.toObject = toObject;
|
27410 | proto.toDate = toDate;
|
27411 | proto.toISOString = toISOString;
|
27412 | proto.inspect = inspect;
|
27413 | proto.toJSON = toJSON;
|
27414 | proto.toString = toString;
|
27415 | proto.unix = unix;
|
27416 | proto.valueOf = valueOf;
|
27417 | proto.creationData = creationData;
|
27418 | proto.year = getSetYear;
|
27419 | proto.isLeapYear = getIsLeapYear;
|
27420 | proto.weekYear = getSetWeekYear;
|
27421 | proto.isoWeekYear = getSetISOWeekYear;
|
27422 | proto.quarter = proto.quarters = getSetQuarter;
|
27423 | proto.month = getSetMonth;
|
27424 | proto.daysInMonth = getDaysInMonth;
|
27425 | proto.week = proto.weeks = getSetWeek;
|
27426 | proto.isoWeek = proto.isoWeeks = getSetISOWeek;
|
27427 | proto.weeksInYear = getWeeksInYear;
|
27428 | proto.isoWeeksInYear = getISOWeeksInYear;
|
27429 | proto.date = getSetDayOfMonth;
|
27430 | proto.day = proto.days = getSetDayOfWeek;
|
27431 | proto.weekday = getSetLocaleDayOfWeek;
|
27432 | proto.isoWeekday = getSetISODayOfWeek;
|
27433 | proto.dayOfYear = getSetDayOfYear;
|
27434 | proto.hour = proto.hours = getSetHour;
|
27435 | proto.minute = proto.minutes = getSetMinute;
|
27436 | proto.second = proto.seconds = getSetSecond;
|
27437 | proto.millisecond = proto.milliseconds = getSetMillisecond;
|
27438 | proto.utcOffset = getSetOffset;
|
27439 | proto.utc = setOffsetToUTC;
|
27440 | proto.local = setOffsetToLocal;
|
27441 | proto.parseZone = setOffsetToParsedOffset;
|
27442 | proto.hasAlignedHourOffset = hasAlignedHourOffset;
|
27443 | proto.isDST = isDaylightSavingTime;
|
27444 | proto.isLocal = isLocal;
|
27445 | proto.isUtcOffset = isUtcOffset;
|
27446 | proto.isUtc = isUtc;
|
27447 | proto.isUTC = isUtc;
|
27448 | proto.zoneAbbr = getZoneAbbr;
|
27449 | proto.zoneName = getZoneName;
|
27450 | proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
|
27451 | proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
|
27452 | proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
|
27453 | proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
|
27454 | proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
|
27455 |
|
27456 | function createUnix(input) {
|
27457 | return createLocal(input * 1000);
|
27458 | }
|
27459 |
|
27460 | function createInZone() {
|
27461 | return createLocal.apply(null, arguments).parseZone();
|
27462 | }
|
27463 |
|
27464 | function preParsePostFormat(string) {
|
27465 | return string;
|
27466 | }
|
27467 |
|
27468 | var proto$1 = Locale.prototype;
|
27469 | proto$1.calendar = calendar;
|
27470 | proto$1.longDateFormat = longDateFormat;
|
27471 | proto$1.invalidDate = invalidDate;
|
27472 | proto$1.ordinal = ordinal;
|
27473 | proto$1.preparse = preParsePostFormat;
|
27474 | proto$1.postformat = preParsePostFormat;
|
27475 | proto$1.relativeTime = relativeTime;
|
27476 | proto$1.pastFuture = pastFuture;
|
27477 | proto$1.set = set;
|
27478 | proto$1.months = localeMonths;
|
27479 | proto$1.monthsShort = localeMonthsShort;
|
27480 | proto$1.monthsParse = localeMonthsParse;
|
27481 | proto$1.monthsRegex = monthsRegex;
|
27482 | proto$1.monthsShortRegex = monthsShortRegex;
|
27483 | proto$1.week = localeWeek;
|
27484 | proto$1.firstDayOfYear = localeFirstDayOfYear;
|
27485 | proto$1.firstDayOfWeek = localeFirstDayOfWeek;
|
27486 | proto$1.weekdays = localeWeekdays;
|
27487 | proto$1.weekdaysMin = localeWeekdaysMin;
|
27488 | proto$1.weekdaysShort = localeWeekdaysShort;
|
27489 | proto$1.weekdaysParse = localeWeekdaysParse;
|
27490 | proto$1.weekdaysRegex = weekdaysRegex;
|
27491 | proto$1.weekdaysShortRegex = weekdaysShortRegex;
|
27492 | proto$1.weekdaysMinRegex = weekdaysMinRegex;
|
27493 | proto$1.isPM = localeIsPM;
|
27494 | proto$1.meridiem = localeMeridiem;
|
27495 |
|
27496 | function get$1(format, index, field, setter) {
|
27497 | var locale = getLocale();
|
27498 | var utc = createUTC().set(setter, index);
|
27499 | return locale[field](utc, format);
|
27500 | }
|
27501 |
|
27502 | function listMonthsImpl(format, index, field) {
|
27503 | if (isNumber(format)) {
|
27504 | index = format;
|
27505 | format = undefined;
|
27506 | }
|
27507 |
|
27508 | format = format || '';
|
27509 |
|
27510 | if (index != null) {
|
27511 | return get$1(format, index, field, 'month');
|
27512 | }
|
27513 |
|
27514 | var i;
|
27515 | var out = [];
|
27516 |
|
27517 | for (i = 0; i < 12; i++) {
|
27518 | out[i] = get$1(format, i, field, 'month');
|
27519 | }
|
27520 |
|
27521 | return out;
|
27522 | } // ()
|
27523 | // (5)
|
27524 | // (fmt, 5)
|
27525 | // (fmt)
|
27526 | // (true)
|
27527 | // (true, 5)
|
27528 | // (true, fmt, 5)
|
27529 | // (true, fmt)
|
27530 |
|
27531 |
|
27532 | function listWeekdaysImpl(localeSorted, format, index, field) {
|
27533 | if (typeof localeSorted === 'boolean') {
|
27534 | if (isNumber(format)) {
|
27535 | index = format;
|
27536 | format = undefined;
|
27537 | }
|
27538 |
|
27539 | format = format || '';
|
27540 | } else {
|
27541 | format = localeSorted;
|
27542 | index = format;
|
27543 | localeSorted = false;
|
27544 |
|
27545 | if (isNumber(format)) {
|
27546 | index = format;
|
27547 | format = undefined;
|
27548 | }
|
27549 |
|
27550 | format = format || '';
|
27551 | }
|
27552 |
|
27553 | var locale = getLocale(),
|
27554 | shift = localeSorted ? locale._week.dow : 0;
|
27555 |
|
27556 | if (index != null) {
|
27557 | return get$1(format, (index + shift) % 7, field, 'day');
|
27558 | }
|
27559 |
|
27560 | var i;
|
27561 | var out = [];
|
27562 |
|
27563 | for (i = 0; i < 7; i++) {
|
27564 | out[i] = get$1(format, (i + shift) % 7, field, 'day');
|
27565 | }
|
27566 |
|
27567 | return out;
|
27568 | }
|
27569 |
|
27570 | function listMonths(format, index) {
|
27571 | return listMonthsImpl(format, index, 'months');
|
27572 | }
|
27573 |
|
27574 | function listMonthsShort(format, index) {
|
27575 | return listMonthsImpl(format, index, 'monthsShort');
|
27576 | }
|
27577 |
|
27578 | function listWeekdays(localeSorted, format, index) {
|
27579 | return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
|
27580 | }
|
27581 |
|
27582 | function listWeekdaysShort(localeSorted, format, index) {
|
27583 | return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
|
27584 | }
|
27585 |
|
27586 | function listWeekdaysMin(localeSorted, format, index) {
|
27587 | return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
|
27588 | }
|
27589 |
|
27590 | getSetGlobalLocale('en', {
|
27591 | dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
|
27592 | ordinal: function (number) {
|
27593 | var b = number % 10,
|
27594 | output = toInt(number % 100 / 10) === 1 ? 'th' : b === 1 ? 'st' : b === 2 ? 'nd' : b === 3 ? 'rd' : 'th';
|
27595 | return number + output;
|
27596 | }
|
27597 | });
|
27598 |
|
27599 | hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
|
27600 | hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
|
27601 | var mathAbs = Math.abs;
|
27602 |
|
27603 | function abs() {
|
27604 | var data = this._data;
|
27605 | this._milliseconds = mathAbs(this._milliseconds);
|
27606 | this._days = mathAbs(this._days);
|
27607 | this._months = mathAbs(this._months);
|
27608 | data.milliseconds = mathAbs(data.milliseconds);
|
27609 | data.seconds = mathAbs(data.seconds);
|
27610 | data.minutes = mathAbs(data.minutes);
|
27611 | data.hours = mathAbs(data.hours);
|
27612 | data.months = mathAbs(data.months);
|
27613 | data.years = mathAbs(data.years);
|
27614 | return this;
|
27615 | }
|
27616 |
|
27617 | function addSubtract$1(duration, input, value, direction) {
|
27618 | var other = createDuration(input, value);
|
27619 | duration._milliseconds += direction * other._milliseconds;
|
27620 | duration._days += direction * other._days;
|
27621 | duration._months += direction * other._months;
|
27622 | return duration._bubble();
|
27623 | }
|
27624 |
|
27625 |
|
27626 | function add$1(input, value) {
|
27627 | return addSubtract$1(this, input, value, 1);
|
27628 | }
|
27629 |
|
27630 |
|
27631 | function subtract$1(input, value) {
|
27632 | return addSubtract$1(this, input, value, -1);
|
27633 | }
|
27634 |
|
27635 | function absCeil(number) {
|
27636 | if (number < 0) {
|
27637 | return Math.floor(number);
|
27638 | } else {
|
27639 | return Math.ceil(number);
|
27640 | }
|
27641 | }
|
27642 |
|
27643 | function bubble() {
|
27644 | var milliseconds = this._milliseconds;
|
27645 | var days = this._days;
|
27646 | var months = this._months;
|
27647 | var data = this._data;
|
27648 | var seconds, minutes, hours, years, monthsFromDays;
|
27649 |
|
27650 |
|
27651 | if (!(milliseconds >= 0 && days >= 0 && months >= 0 || milliseconds <= 0 && days <= 0 && months <= 0)) {
|
27652 | milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
|
27653 | days = 0;
|
27654 | months = 0;
|
27655 | }
|
27656 |
|
27657 |
|
27658 |
|
27659 | data.milliseconds = milliseconds % 1000;
|
27660 | seconds = absFloor(milliseconds / 1000);
|
27661 | data.seconds = seconds % 60;
|
27662 | minutes = absFloor(seconds / 60);
|
27663 | data.minutes = minutes % 60;
|
27664 | hours = absFloor(minutes / 60);
|
27665 | data.hours = hours % 24;
|
27666 | days += absFloor(hours / 24);
|
27667 |
|
27668 | monthsFromDays = absFloor(daysToMonths(days));
|
27669 | months += monthsFromDays;
|
27670 | days -= absCeil(monthsToDays(monthsFromDays));
|
27671 |
|
27672 | years = absFloor(months / 12);
|
27673 | months %= 12;
|
27674 | data.days = days;
|
27675 | data.months = months;
|
27676 | data.years = years;
|
27677 | return this;
|
27678 | }
|
27679 |
|
27680 | function daysToMonths(days) {
|
27681 |
|
27682 |
|
27683 | return days * 4800 / 146097;
|
27684 | }
|
27685 |
|
27686 | function monthsToDays(months) {
|
27687 |
|
27688 | return months * 146097 / 4800;
|
27689 | }
|
27690 |
|
27691 | function as(units) {
|
27692 | if (!this.isValid()) {
|
27693 | return NaN;
|
27694 | }
|
27695 |
|
27696 | var days;
|
27697 | var months;
|
27698 | var milliseconds = this._milliseconds;
|
27699 | units = normalizeUnits(units);
|
27700 |
|
27701 | if (units === 'month' || units === 'quarter' || units === 'year') {
|
27702 | days = this._days + milliseconds / 864e5;
|
27703 | months = this._months + daysToMonths(days);
|
27704 |
|
27705 | switch (units) {
|
27706 | case 'month':
|
27707 | return months;
|
27708 |
|
27709 | case 'quarter':
|
27710 | return months / 3;
|
27711 |
|
27712 | case 'year':
|
27713 | return months / 12;
|
27714 | }
|
27715 | } else {
|
27716 |
|
27717 | days = this._days + Math.round(monthsToDays(this._months));
|
27718 |
|
27719 | switch (units) {
|
27720 | case 'week':
|
27721 | return days / 7 + milliseconds / 6048e5;
|
27722 |
|
27723 | case 'day':
|
27724 | return days + milliseconds / 864e5;
|
27725 |
|
27726 | case 'hour':
|
27727 | return days * 24 + milliseconds / 36e5;
|
27728 |
|
27729 | case 'minute':
|
27730 | return days * 1440 + milliseconds / 6e4;
|
27731 |
|
27732 | case 'second':
|
27733 | return days * 86400 + milliseconds / 1000;
|
27734 |
|
27735 |
|
27736 | case 'millisecond':
|
27737 | return Math.floor(days * 864e5) + milliseconds;
|
27738 |
|
27739 | default:
|
27740 | throw new Error('Unknown unit ' + units);
|
27741 | }
|
27742 | }
|
27743 | }
|
27744 |
|
27745 |
|
27746 | function valueOf$1() {
|
27747 | if (!this.isValid()) {
|
27748 | return NaN;
|
27749 | }
|
27750 |
|
27751 | return this._milliseconds + this._days * 864e5 + this._months % 12 * 2592e6 + toInt(this._months / 12) * 31536e6;
|
27752 | }
|
27753 |
|
27754 | function makeAs(alias) {
|
27755 | return function () {
|
27756 | return this.as(alias);
|
27757 | };
|
27758 | }
|
27759 |
|
27760 | var asMilliseconds = makeAs('ms');
|
27761 | var asSeconds = makeAs('s');
|
27762 | var asMinutes = makeAs('m');
|
27763 | var asHours = makeAs('h');
|
27764 | var asDays = makeAs('d');
|
27765 | var asWeeks = makeAs('w');
|
27766 | var asMonths = makeAs('M');
|
27767 | var asQuarters = makeAs('Q');
|
27768 | var asYears = makeAs('y');
|
27769 |
|
27770 | function clone$1() {
|
27771 | return createDuration(this);
|
27772 | }
|
27773 |
|
27774 | function get$2(units) {
|
27775 | units = normalizeUnits(units);
|
27776 | return this.isValid() ? this[units + 's']() : NaN;
|
27777 | }
|
27778 |
|
27779 | function makeGetter(name) {
|
27780 | return function () {
|
27781 | return this.isValid() ? this._data[name] : NaN;
|
27782 | };
|
27783 | }
|
27784 |
|
27785 | var milliseconds = makeGetter('milliseconds');
|
27786 | var seconds = makeGetter('seconds');
|
27787 | var minutes = makeGetter('minutes');
|
27788 | var hours = makeGetter('hours');
|
27789 | var days = makeGetter('days');
|
27790 | var months = makeGetter('months');
|
27791 | var years = makeGetter('years');
|
27792 |
|
27793 | function weeks() {
|
27794 | return absFloor(this.days() / 7);
|
27795 | }
|
27796 |
|
27797 | var round = Math.round;
|
27798 | var thresholds = {
|
27799 | ss: 44,
|
27800 |
|
27801 | s: 45,
|
27802 |
|
27803 | m: 45,
|
27804 |
|
27805 | h: 22,
|
27806 |
|
27807 | d: 26,
|
27808 |
|
27809 | M: 11
|
27810 |
|
27811 | };
|
27812 |
|
27813 | function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
|
27814 | return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
|
27815 | }
|
27816 |
|
27817 | function relativeTime$1(posNegDuration, withoutSuffix, locale) {
|
27818 | var duration = createDuration(posNegDuration).abs();
|
27819 | var seconds = round(duration.as('s'));
|
27820 | var minutes = round(duration.as('m'));
|
27821 | var hours = round(duration.as('h'));
|
27822 | var days = round(duration.as('d'));
|
27823 | var months = round(duration.as('M'));
|
27824 | var years = round(duration.as('y'));
|
27825 | var a = seconds <= thresholds.ss && ['s', seconds] || seconds < thresholds.s && ['ss', seconds] || minutes <= 1 && ['m'] || minutes < thresholds.m && ['mm', minutes] || hours <= 1 && ['h'] || hours < thresholds.h && ['hh', hours] || days <= 1 && ['d'] || days < thresholds.d && ['dd', days] || months <= 1 && ['M'] || months < thresholds.M && ['MM', months] || years <= 1 && ['y'] || ['yy', years];
|
27826 | a[2] = withoutSuffix;
|
27827 | a[3] = +posNegDuration > 0;
|
27828 | a[4] = locale;
|
27829 | return substituteTimeAgo.apply(null, a);
|
27830 | }
|
27831 |
|
27832 |
|
27833 | function getSetRelativeTimeRounding(roundingFunction) {
|
27834 | if (roundingFunction === undefined) {
|
27835 | return round;
|
27836 | }
|
27837 |
|
27838 | if (typeof roundingFunction === 'function') {
|
27839 | round = roundingFunction;
|
27840 | return true;
|
27841 | }
|
27842 |
|
27843 | return false;
|
27844 | }
|
27845 |
|
27846 |
|
27847 | function getSetRelativeTimeThreshold(threshold, limit) {
|
27848 | if (thresholds[threshold] === undefined) {
|
27849 | return false;
|
27850 | }
|
27851 |
|
27852 | if (limit === undefined) {
|
27853 | return thresholds[threshold];
|
27854 | }
|
27855 |
|
27856 | thresholds[threshold] = limit;
|
27857 |
|
27858 | if (threshold === 's') {
|
27859 | thresholds.ss = limit - 1;
|
27860 | }
|
27861 |
|
27862 | return true;
|
27863 | }
|
27864 |
|
27865 | function humanize(withSuffix) {
|
27866 | if (!this.isValid()) {
|
27867 | return this.localeData().invalidDate();
|
27868 | }
|
27869 |
|
27870 | var locale = this.localeData();
|
27871 | var output = relativeTime$1(this, !withSuffix, locale);
|
27872 |
|
27873 | if (withSuffix) {
|
27874 | output = locale.pastFuture(+this, output);
|
27875 | }
|
27876 |
|
27877 | return locale.postformat(output);
|
27878 | }
|
27879 |
|
27880 | var abs$1 = Math.abs;
|
27881 |
|
27882 | function sign(x) {
|
27883 | return (x > 0) - (x < 0) || +x;
|
27884 | }
|
27885 |
|
27886 | function toISOString$1() {
|
27887 |
|
27888 |
|
27889 |
|
27890 |
|
27891 |
|
27892 |
|
27893 |
|
27894 | if (!this.isValid()) {
|
27895 | return this.localeData().invalidDate();
|
27896 | }
|
27897 |
|
27898 | var seconds = abs$1(this._milliseconds) / 1000;
|
27899 | var days = abs$1(this._days);
|
27900 | var months = abs$1(this._months);
|
27901 | var minutes, hours, years;
|
27902 |
|
27903 | minutes = absFloor(seconds / 60);
|
27904 | hours = absFloor(minutes / 60);
|
27905 | seconds %= 60;
|
27906 | minutes %= 60;
|
27907 |
|
27908 | years = absFloor(months / 12);
|
27909 | months %= 12;
|
27910 |
|
27911 | var Y = years;
|
27912 | var M = months;
|
27913 | var D = days;
|
27914 | var h = hours;
|
27915 | var m = minutes;
|
27916 | var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
|
27917 | var total = this.asSeconds();
|
27918 |
|
27919 | if (!total) {
|
27920 |
|
27921 |
|
27922 | return 'P0D';
|
27923 | }
|
27924 |
|
27925 | var totalSign = total < 0 ? '-' : '';
|
27926 | var ymSign = sign(this._months) !== sign(total) ? '-' : '';
|
27927 | var daysSign = sign(this._days) !== sign(total) ? '-' : '';
|
27928 | var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
|
27929 | return totalSign + 'P' + (Y ? ymSign + Y + 'Y' : '') + (M ? ymSign + M + 'M' : '') + (D ? daysSign + D + 'D' : '') + (h || m || s ? 'T' : '') + (h ? hmsSign + h + 'H' : '') + (m ? hmsSign + m + 'M' : '') + (s ? hmsSign + s + 'S' : '');
|
27930 | }
|
27931 |
|
27932 | var proto$2 = Duration.prototype;
|
27933 | proto$2.isValid = isValid$1;
|
27934 | proto$2.abs = abs;
|
27935 | proto$2.add = add$1;
|
27936 | proto$2.subtract = subtract$1;
|
27937 | proto$2.as = as;
|
27938 | proto$2.asMilliseconds = asMilliseconds;
|
27939 | proto$2.asSeconds = asSeconds;
|
27940 | proto$2.asMinutes = asMinutes;
|
27941 | proto$2.asHours = asHours;
|
27942 | proto$2.asDays = asDays;
|
27943 | proto$2.asWeeks = asWeeks;
|
27944 | proto$2.asMonths = asMonths;
|
27945 | proto$2.asQuarters = asQuarters;
|
27946 | proto$2.asYears = asYears;
|
27947 | proto$2.valueOf = valueOf$1;
|
27948 | proto$2._bubble = bubble;
|
27949 | proto$2.clone = clone$1;
|
27950 | proto$2.get = get$2;
|
27951 | proto$2.milliseconds = milliseconds;
|
27952 | proto$2.seconds = seconds;
|
27953 | proto$2.minutes = minutes;
|
27954 | proto$2.hours = hours;
|
27955 | proto$2.days = days;
|
27956 | proto$2.weeks = weeks;
|
27957 | proto$2.months = months;
|
27958 | proto$2.years = years;
|
27959 | proto$2.humanize = humanize;
|
27960 | proto$2.toISOString = toISOString$1;
|
27961 | proto$2.toString = toISOString$1;
|
27962 | proto$2.toJSON = toISOString$1;
|
27963 | proto$2.locale = locale;
|
27964 | proto$2.localeData = localeData;
|
27965 | proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
|
27966 | proto$2.lang = lang; // Side effect imports
|
27967 | // FORMATTING
|
27968 |
|
27969 | addFormatToken('X', 0, 0, 'unix');
|
27970 | addFormatToken('x', 0, 0, 'valueOf'); // PARSING
|
27971 |
|
27972 | addRegexToken('x', matchSigned);
|
27973 | addRegexToken('X', matchTimestamp);
|
27974 | addParseToken('X', function (input, array, config) {
|
27975 | config._d = new Date(parseFloat(input, 10) * 1000);
|
27976 | });
|
27977 | addParseToken('x', function (input, array, config) {
|
27978 | config._d = new Date(toInt(input));
|
27979 | });
|
27980 |
|
27981 | hooks.version = '2.24.0';
|
27982 | setHookCallback(createLocal);
|
27983 | hooks.fn = proto;
|
27984 | hooks.min = min;
|
27985 | hooks.max = max;
|
27986 | hooks.now = now;
|
27987 | hooks.utc = createUTC;
|
27988 | hooks.unix = createUnix;
|
27989 | hooks.months = listMonths;
|
27990 | hooks.isDate = isDate;
|
27991 | hooks.locale = getSetGlobalLocale;
|
27992 | hooks.invalid = createInvalid;
|
27993 | hooks.duration = createDuration;
|
27994 | hooks.isMoment = isMoment;
|
27995 | hooks.weekdays = listWeekdays;
|
27996 | hooks.parseZone = createInZone;
|
27997 | hooks.localeData = getLocale;
|
27998 | hooks.isDuration = isDuration;
|
27999 | hooks.monthsShort = listMonthsShort;
|
28000 | hooks.weekdaysMin = listWeekdaysMin;
|
28001 | hooks.defineLocale = defineLocale;
|
28002 | hooks.updateLocale = updateLocale;
|
28003 | hooks.locales = listLocales;
|
28004 | hooks.weekdaysShort = listWeekdaysShort;
|
28005 | hooks.normalizeUnits = normalizeUnits;
|
28006 | hooks.relativeTimeRounding = getSetRelativeTimeRounding;
|
28007 | hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
|
28008 | hooks.calendarFormat = getCalendarFormat;
|
28009 | hooks.prototype = proto;
|
28010 |
|
28011 | hooks.HTML5_FMT = {
|
28012 | DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm',
|
28013 |
|
28014 | DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss',
|
28015 |
|
28016 | DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS',
|
28017 |
|
28018 | DATE: 'YYYY-MM-DD',
|
28019 |
|
28020 | TIME: 'HH:mm',
|
28021 |
|
28022 | TIME_SECONDS: 'HH:mm:ss',
|
28023 |
|
28024 | TIME_MS: 'HH:mm:ss.SSS',
|
28025 |
|
28026 | WEEK: 'GGGG-[W]WW',
|
28027 |
|
28028 | MONTH: 'YYYY-MM'
|
28029 |
|
28030 | };
|
28031 | return hooks;
|
28032 | });
|
28033 | });
|
28034 |
|
28035 |
|
28036 |
|
28037 | var moment$3 = typeof window !== 'undefined' && window['moment'] || moment$2;
|
28038 |
|
28039 | var propagating = createCommonjsModule$1(function (module, exports) {
|
28040 |
|
28041 | (function (factory) {
|
28042 | {
|
28043 |
|
28044 |
|
28045 |
|
28046 | module.exports = factory();
|
28047 | }
|
28048 | })(function () {
|
28049 | var _firstTarget = null;
|
28050 |
|
28051 | |
28052 |
|
28053 |
|
28054 |
|
28055 |
|
28056 |
|
28057 |
|
28058 |
|
28059 |
|
28060 |
|
28061 |
|
28062 |
|
28063 |
|
28064 |
|
28065 |
|
28066 |
|
28067 |
|
28068 |
|
28069 |
|
28070 |
|
28071 |
|
28072 |
|
28073 |
|
28074 | return function propagating(hammer, options) {
|
28075 | var _options = options || {
|
28076 | preventDefault: false
|
28077 | };
|
28078 |
|
28079 | if (hammer.Manager) {
|
28080 |
|
28081 |
|
28082 | var Hammer = hammer;
|
28083 |
|
28084 | var PropagatingHammer = function (element, options) {
|
28085 | var o = Object.create(_options);
|
28086 | if (options) Hammer.assign(o, options);
|
28087 | return propagating(new Hammer(element, o), o);
|
28088 | };
|
28089 |
|
28090 | Hammer.assign(PropagatingHammer, Hammer);
|
28091 |
|
28092 | PropagatingHammer.Manager = function (element, options) {
|
28093 | var o = Object.create(_options);
|
28094 | if (options) Hammer.assign(o, options);
|
28095 | return propagating(new Hammer.Manager(element, o), o);
|
28096 | };
|
28097 |
|
28098 | return PropagatingHammer;
|
28099 | }
|
28100 |
|
28101 |
|
28102 |
|
28103 | var wrapper = Object.create(hammer);
|
28104 |
|
28105 | var element = hammer.element;
|
28106 | if (!element.hammer) element.hammer = [];
|
28107 | element.hammer.push(wrapper);
|
28108 |
|
28109 |
|
28110 | hammer.on('hammer.input', function (event) {
|
28111 | if (_options.preventDefault === true || _options.preventDefault === event.pointerType) {
|
28112 | event.preventDefault();
|
28113 | }
|
28114 |
|
28115 | if (event.isFirst) {
|
28116 | _firstTarget = event.target;
|
28117 | }
|
28118 | });
|
28119 |
|
28120 |
|
28121 | wrapper._handlers = {};
|
28122 | |
28123 |
|
28124 |
|
28125 |
|
28126 |
|
28127 |
|
28128 |
|
28129 | wrapper.on = function (events, handler) {
|
28130 |
|
28131 | split(events).forEach(function (event) {
|
28132 | var _handlers = wrapper._handlers[event];
|
28133 |
|
28134 | if (!_handlers) {
|
28135 | wrapper._handlers[event] = _handlers = [];
|
28136 |
|
28137 | hammer.on(event, propagatedHandler);
|
28138 | }
|
28139 |
|
28140 | _handlers.push(handler);
|
28141 | });
|
28142 | return wrapper;
|
28143 | };
|
28144 | |
28145 |
|
28146 |
|
28147 |
|
28148 |
|
28149 |
|
28150 |
|
28151 |
|
28152 |
|
28153 |
|
28154 | wrapper.off = function (events, handler) {
|
28155 |
|
28156 | split(events).forEach(function (event) {
|
28157 | var _handlers = wrapper._handlers[event];
|
28158 |
|
28159 | if (_handlers) {
|
28160 | _handlers = handler ? _handlers.filter(function (h) {
|
28161 | return h !== handler;
|
28162 | }) : [];
|
28163 |
|
28164 | if (_handlers.length > 0) {
|
28165 | wrapper._handlers[event] = _handlers;
|
28166 | } else {
|
28167 |
|
28168 | hammer.off(event, propagatedHandler);
|
28169 | delete wrapper._handlers[event];
|
28170 | }
|
28171 | }
|
28172 | });
|
28173 | return wrapper;
|
28174 | };
|
28175 | |
28176 |
|
28177 |
|
28178 |
|
28179 |
|
28180 |
|
28181 |
|
28182 | wrapper.emit = function (eventType, event) {
|
28183 | _firstTarget = event.target;
|
28184 | hammer.emit(eventType, event);
|
28185 | };
|
28186 |
|
28187 | wrapper.destroy = function () {
|
28188 |
|
28189 | var hammers = hammer.element.hammer;
|
28190 | var idx = hammers.indexOf(wrapper);
|
28191 | if (idx !== -1) hammers.splice(idx, 1);
|
28192 | if (!hammers.length) delete hammer.element.hammer;
|
28193 |
|
28194 | wrapper._handlers = {};
|
28195 |
|
28196 | hammer.destroy();
|
28197 | };
|
28198 |
|
28199 |
|
28200 | function split(events) {
|
28201 | return events.match(/[^ ]+/g);
|
28202 | }
|
28203 | |
28204 |
|
28205 |
|
28206 |
|
28207 |
|
28208 |
|
28209 | function propagatedHandler(event) {
|
28210 |
|
28211 | if (event.type !== 'hammer.input') {
|
28212 |
|
28213 |
|
28214 | if (!event.srcEvent._handled) {
|
28215 | event.srcEvent._handled = {};
|
28216 | }
|
28217 |
|
28218 | if (event.srcEvent._handled[event.type]) {
|
28219 | return;
|
28220 | } else {
|
28221 | event.srcEvent._handled[event.type] = true;
|
28222 | }
|
28223 | }
|
28224 |
|
28225 |
|
28226 | var stopped = false;
|
28227 |
|
28228 | event.stopPropagation = function () {
|
28229 | stopped = true;
|
28230 | };
|
28231 |
|
28232 |
|
28233 | var srcStop = event.srcEvent.stopPropagation.bind(event.srcEvent);
|
28234 |
|
28235 | if (typeof srcStop == "function") {
|
28236 | event.srcEvent.stopPropagation = function () {
|
28237 | srcStop();
|
28238 | event.stopPropagation();
|
28239 | };
|
28240 | }
|
28241 |
|
28242 |
|
28243 | event.firstTarget = _firstTarget;
|
28244 |
|
28245 | var elem = _firstTarget;
|
28246 |
|
28247 | while (elem && !stopped) {
|
28248 | var elemHammer = elem.hammer;
|
28249 |
|
28250 | if (elemHammer) {
|
28251 | var _handlers;
|
28252 |
|
28253 | for (var k = 0; k < elemHammer.length; k++) {
|
28254 | _handlers = elemHammer[k]._handlers[event.type];
|
28255 | if (_handlers) for (var i = 0; i < _handlers.length && !stopped; i++) {
|
28256 | _handlers[i](event);
|
28257 | }
|
28258 | }
|
28259 | }
|
28260 |
|
28261 | elem = elem.parentNode;
|
28262 | }
|
28263 | }
|
28264 |
|
28265 | return wrapper;
|
28266 | };
|
28267 | });
|
28268 | });
|
28269 |
|
28270 | var hammer = createCommonjsModule$1(function (module) {
|
28271 | |
28272 |
|
28273 |
|
28274 |
|
28275 |
|
28276 | (function (window, document, exportName, undefined$1) {
|
28277 |
|
28278 | var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
|
28279 | var TEST_ELEMENT = document.createElement('div');
|
28280 | var TYPE_FUNCTION = 'function';
|
28281 | var round = Math.round;
|
28282 | var abs = Math.abs;
|
28283 | var now = Date.now;
|
28284 | |
28285 |
|
28286 |
|
28287 |
|
28288 |
|
28289 |
|
28290 |
|
28291 |
|
28292 | function setTimeoutContext(fn, timeout, context) {
|
28293 | return setTimeout(bindFn(fn, context), timeout);
|
28294 | }
|
28295 | |
28296 |
|
28297 |
|
28298 |
|
28299 |
|
28300 |
|
28301 |
|
28302 |
|
28303 |
|
28304 |
|
28305 |
|
28306 | function invokeArrayArg(arg, fn, context) {
|
28307 | if (Array.isArray(arg)) {
|
28308 | each(arg, context[fn], context);
|
28309 | return true;
|
28310 | }
|
28311 |
|
28312 | return false;
|
28313 | }
|
28314 | |
28315 |
|
28316 |
|
28317 |
|
28318 |
|
28319 |
|
28320 |
|
28321 |
|
28322 | function each(obj, iterator, context) {
|
28323 | var i;
|
28324 |
|
28325 | if (!obj) {
|
28326 | return;
|
28327 | }
|
28328 |
|
28329 | if (obj.forEach) {
|
28330 | obj.forEach(iterator, context);
|
28331 | } else if (obj.length !== undefined$1) {
|
28332 | i = 0;
|
28333 |
|
28334 | while (i < obj.length) {
|
28335 | iterator.call(context, obj[i], i, obj);
|
28336 | i++;
|
28337 | }
|
28338 | } else {
|
28339 | for (i in obj) {
|
28340 | obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
|
28341 | }
|
28342 | }
|
28343 | }
|
28344 | |
28345 |
|
28346 |
|
28347 |
|
28348 |
|
28349 |
|
28350 |
|
28351 |
|
28352 |
|
28353 | function deprecate(method, name, message) {
|
28354 | var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n';
|
28355 | return function () {
|
28356 | var e = new Error('get-stack-trace');
|
28357 | var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, '').replace(/^\s+at\s+/gm, '').replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') : 'Unknown Stack Trace';
|
28358 | var log = window.console && (window.console.warn || window.console.log);
|
28359 |
|
28360 | if (log) {
|
28361 | log.call(window.console, deprecationMessage, stack);
|
28362 | }
|
28363 |
|
28364 | return method.apply(this, arguments);
|
28365 | };
|
28366 | }
|
28367 | |
28368 |
|
28369 |
|
28370 |
|
28371 |
|
28372 |
|
28373 |
|
28374 |
|
28375 |
|
28376 | var assign;
|
28377 |
|
28378 | if (typeof Object.assign !== 'function') {
|
28379 | assign = function assign(target) {
|
28380 | if (target === undefined$1 || target === null) {
|
28381 | throw new TypeError('Cannot convert undefined or null to object');
|
28382 | }
|
28383 |
|
28384 | var output = Object(target);
|
28385 |
|
28386 | for (var index = 1; index < arguments.length; index++) {
|
28387 | var source = arguments[index];
|
28388 |
|
28389 | if (source !== undefined$1 && source !== null) {
|
28390 | for (var nextKey in source) {
|
28391 | if (source.hasOwnProperty(nextKey)) {
|
28392 | output[nextKey] = source[nextKey];
|
28393 | }
|
28394 | }
|
28395 | }
|
28396 | }
|
28397 |
|
28398 | return output;
|
28399 | };
|
28400 | } else {
|
28401 | assign = Object.assign;
|
28402 | }
|
28403 | |
28404 |
|
28405 |
|
28406 |
|
28407 |
|
28408 |
|
28409 |
|
28410 |
|
28411 |
|
28412 |
|
28413 | var extend = deprecate(function extend(dest, src, merge) {
|
28414 | var keys = Object.keys(src);
|
28415 | var i = 0;
|
28416 |
|
28417 | while (i < keys.length) {
|
28418 | if (!merge || merge && dest[keys[i]] === undefined$1) {
|
28419 | dest[keys[i]] = src[keys[i]];
|
28420 | }
|
28421 |
|
28422 | i++;
|
28423 | }
|
28424 |
|
28425 | return dest;
|
28426 | }, 'extend', 'Use `assign`.');
|
28427 | |
28428 |
|
28429 |
|
28430 |
|
28431 |
|
28432 |
|
28433 |
|
28434 |
|
28435 | var merge = deprecate(function merge(dest, src) {
|
28436 | return extend(dest, src, true);
|
28437 | }, 'merge', 'Use `assign`.');
|
28438 | |
28439 |
|
28440 |
|
28441 |
|
28442 |
|
28443 |
|
28444 |
|
28445 | function inherit(child, base, properties) {
|
28446 | var baseP = base.prototype,
|
28447 | childP;
|
28448 | childP = child.prototype = Object.create(baseP);
|
28449 | childP.constructor = child;
|
28450 | childP._super = baseP;
|
28451 |
|
28452 | if (properties) {
|
28453 | assign(childP, properties);
|
28454 | }
|
28455 | }
|
28456 | |
28457 |
|
28458 |
|
28459 |
|
28460 |
|
28461 |
|
28462 |
|
28463 |
|
28464 | function bindFn(fn, context) {
|
28465 | return function boundFn() {
|
28466 | return fn.apply(context, arguments);
|
28467 | };
|
28468 | }
|
28469 | |
28470 |
|
28471 |
|
28472 |
|
28473 |
|
28474 |
|
28475 |
|
28476 |
|
28477 |
|
28478 | function boolOrFn(val, args) {
|
28479 | if (typeof val == TYPE_FUNCTION) {
|
28480 | return val.apply(args ? args[0] || undefined$1 : undefined$1, args);
|
28481 | }
|
28482 |
|
28483 | return val;
|
28484 | }
|
28485 | |
28486 |
|
28487 |
|
28488 |
|
28489 |
|
28490 |
|
28491 |
|
28492 |
|
28493 | function ifUndefined(val1, val2) {
|
28494 | return val1 === undefined$1 ? val2 : val1;
|
28495 | }
|
28496 | |
28497 |
|
28498 |
|
28499 |
|
28500 |
|
28501 |
|
28502 |
|
28503 |
|
28504 | function addEventListeners(target, types, handler) {
|
28505 | each(splitStr(types), function (type) {
|
28506 | target.addEventListener(type, handler, false);
|
28507 | });
|
28508 | }
|
28509 | |
28510 |
|
28511 |
|
28512 |
|
28513 |
|
28514 |
|
28515 |
|
28516 |
|
28517 | function removeEventListeners(target, types, handler) {
|
28518 | each(splitStr(types), function (type) {
|
28519 | target.removeEventListener(type, handler, false);
|
28520 | });
|
28521 | }
|
28522 | |
28523 |
|
28524 |
|
28525 |
|
28526 |
|
28527 |
|
28528 |
|
28529 |
|
28530 |
|
28531 | function hasParent(node, parent) {
|
28532 | while (node) {
|
28533 | if (node == parent) {
|
28534 | return true;
|
28535 | }
|
28536 |
|
28537 | node = node.parentNode;
|
28538 | }
|
28539 |
|
28540 | return false;
|
28541 | }
|
28542 | |
28543 |
|
28544 |
|
28545 |
|
28546 |
|
28547 |
|
28548 |
|
28549 |
|
28550 | function inStr(str, find) {
|
28551 | return str.indexOf(find) > -1;
|
28552 | }
|
28553 | |
28554 |
|
28555 |
|
28556 |
|
28557 |
|
28558 |
|
28559 |
|
28560 | function splitStr(str) {
|
28561 | return str.trim().split(/\s+/g);
|
28562 | }
|
28563 | |
28564 |
|
28565 |
|
28566 |
|
28567 |
|
28568 |
|
28569 |
|
28570 |
|
28571 |
|
28572 | function inArray(src, find, findByKey) {
|
28573 | if (src.indexOf && !findByKey) {
|
28574 | return src.indexOf(find);
|
28575 | } else {
|
28576 | var i = 0;
|
28577 |
|
28578 | while (i < src.length) {
|
28579 | if (findByKey && src[i][findByKey] == find || !findByKey && src[i] === find) {
|
28580 | return i;
|
28581 | }
|
28582 |
|
28583 | i++;
|
28584 | }
|
28585 |
|
28586 | return -1;
|
28587 | }
|
28588 | }
|
28589 | |
28590 |
|
28591 |
|
28592 |
|
28593 |
|
28594 |
|
28595 |
|
28596 | function toArray(obj) {
|
28597 | return Array.prototype.slice.call(obj, 0);
|
28598 | }
|
28599 | |
28600 |
|
28601 |
|
28602 |
|
28603 |
|
28604 |
|
28605 |
|
28606 |
|
28607 |
|
28608 | function uniqueArray(src, key, sort) {
|
28609 | var results = [];
|
28610 | var values = [];
|
28611 | var i = 0;
|
28612 |
|
28613 | while (i < src.length) {
|
28614 | var val = key ? src[i][key] : src[i];
|
28615 |
|
28616 | if (inArray(values, val) < 0) {
|
28617 | results.push(src[i]);
|
28618 | }
|
28619 |
|
28620 | values[i] = val;
|
28621 | i++;
|
28622 | }
|
28623 |
|
28624 | if (sort) {
|
28625 | if (!key) {
|
28626 | results = results.sort();
|
28627 | } else {
|
28628 | results = results.sort(function sortUniqueArray(a, b) {
|
28629 | return a[key] > b[key];
|
28630 | });
|
28631 | }
|
28632 | }
|
28633 |
|
28634 | return results;
|
28635 | }
|
28636 | |
28637 |
|
28638 |
|
28639 |
|
28640 |
|
28641 |
|
28642 |
|
28643 |
|
28644 | function prefixed(obj, property) {
|
28645 | var prefix, prop;
|
28646 | var camelProp = property[0].toUpperCase() + property.slice(1);
|
28647 | var i = 0;
|
28648 |
|
28649 | while (i < VENDOR_PREFIXES.length) {
|
28650 | prefix = VENDOR_PREFIXES[i];
|
28651 | prop = prefix ? prefix + camelProp : property;
|
28652 |
|
28653 | if (prop in obj) {
|
28654 | return prop;
|
28655 | }
|
28656 |
|
28657 | i++;
|
28658 | }
|
28659 |
|
28660 | return undefined$1;
|
28661 | }
|
28662 | |
28663 |
|
28664 |
|
28665 |
|
28666 |
|
28667 |
|
28668 | var _uniqueId = 1;
|
28669 |
|
28670 | function uniqueId() {
|
28671 | return _uniqueId++;
|
28672 | }
|
28673 | |
28674 |
|
28675 |
|
28676 |
|
28677 |
|
28678 |
|
28679 |
|
28680 | function getWindowForElement(element) {
|
28681 | var doc = element.ownerDocument || element;
|
28682 | return doc.defaultView || doc.parentWindow || window;
|
28683 | }
|
28684 |
|
28685 | var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
28686 | var SUPPORT_TOUCH = 'ontouchstart' in window;
|
28687 | var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined$1;
|
28688 | var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
28689 | var INPUT_TYPE_TOUCH = 'touch';
|
28690 | var INPUT_TYPE_PEN = 'pen';
|
28691 | var INPUT_TYPE_MOUSE = 'mouse';
|
28692 | var INPUT_TYPE_KINECT = 'kinect';
|
28693 | var COMPUTE_INTERVAL = 25;
|
28694 | var INPUT_START = 1;
|
28695 | var INPUT_MOVE = 2;
|
28696 | var INPUT_END = 4;
|
28697 | var INPUT_CANCEL = 8;
|
28698 | var DIRECTION_NONE = 1;
|
28699 | var DIRECTION_LEFT = 2;
|
28700 | var DIRECTION_RIGHT = 4;
|
28701 | var DIRECTION_UP = 8;
|
28702 | var DIRECTION_DOWN = 16;
|
28703 | var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
28704 | var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
28705 | var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
28706 | var PROPS_XY = ['x', 'y'];
|
28707 | var PROPS_CLIENT_XY = ['clientX', 'clientY'];
|
28708 | |
28709 |
|
28710 |
|
28711 |
|
28712 |
|
28713 |
|
28714 |
|
28715 |
|
28716 | function Input(manager, callback) {
|
28717 | var self = this;
|
28718 | this.manager = manager;
|
28719 | this.callback = callback;
|
28720 | this.element = manager.element;
|
28721 | this.target = manager.options.inputTarget;
|
28722 |
|
28723 |
|
28724 | this.domHandler = function (ev) {
|
28725 | if (boolOrFn(manager.options.enable, [manager])) {
|
28726 | self.handler(ev);
|
28727 | }
|
28728 | };
|
28729 |
|
28730 | this.init();
|
28731 | }
|
28732 |
|
28733 | Input.prototype = {
|
28734 | |
28735 |
|
28736 |
|
28737 |
|
28738 | handler: function () {},
|
28739 |
|
28740 | |
28741 |
|
28742 |
|
28743 | init: function () {
|
28744 | this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
|
28745 | this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
|
28746 | this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
28747 | },
|
28748 |
|
28749 | |
28750 |
|
28751 |
|
28752 | destroy: function () {
|
28753 | this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
|
28754 | this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
|
28755 | this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
28756 | }
|
28757 | };
|
28758 | |
28759 |
|
28760 |
|
28761 |
|
28762 |
|
28763 |
|
28764 |
|
28765 | function createInputInstance(manager) {
|
28766 | var Type;
|
28767 | var inputClass = manager.options.inputClass;
|
28768 |
|
28769 | if (inputClass) {
|
28770 | Type = inputClass;
|
28771 | } else if (SUPPORT_POINTER_EVENTS) {
|
28772 | Type = PointerEventInput;
|
28773 | } else if (SUPPORT_ONLY_TOUCH) {
|
28774 | Type = TouchInput;
|
28775 | } else if (!SUPPORT_TOUCH) {
|
28776 | Type = MouseInput;
|
28777 | } else {
|
28778 | Type = TouchMouseInput;
|
28779 | }
|
28780 |
|
28781 | return new Type(manager, inputHandler);
|
28782 | }
|
28783 | |
28784 |
|
28785 |
|
28786 |
|
28787 |
|
28788 |
|
28789 |
|
28790 |
|
28791 | function inputHandler(manager, eventType, input) {
|
28792 | var pointersLen = input.pointers.length;
|
28793 | var changedPointersLen = input.changedPointers.length;
|
28794 | var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
|
28795 | var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && pointersLen - changedPointersLen === 0;
|
28796 | input.isFirst = !!isFirst;
|
28797 | input.isFinal = !!isFinal;
|
28798 |
|
28799 | if (isFirst) {
|
28800 | manager.session = {};
|
28801 | }
|
28802 |
|
28803 |
|
28804 |
|
28805 | input.eventType = eventType;
|
28806 |
|
28807 | computeInputData(manager, input);
|
28808 |
|
28809 | manager.emit('hammer.input', input);
|
28810 | manager.recognize(input);
|
28811 | manager.session.prevInput = input;
|
28812 | }
|
28813 | |
28814 |
|
28815 |
|
28816 |
|
28817 |
|
28818 |
|
28819 |
|
28820 | function computeInputData(manager, input) {
|
28821 | var session = manager.session;
|
28822 | var pointers = input.pointers;
|
28823 | var pointersLength = pointers.length;
|
28824 |
|
28825 | if (!session.firstInput) {
|
28826 | session.firstInput = simpleCloneInputData(input);
|
28827 | }
|
28828 |
|
28829 |
|
28830 | if (pointersLength > 1 && !session.firstMultiple) {
|
28831 | session.firstMultiple = simpleCloneInputData(input);
|
28832 | } else if (pointersLength === 1) {
|
28833 | session.firstMultiple = false;
|
28834 | }
|
28835 |
|
28836 | var firstInput = session.firstInput;
|
28837 | var firstMultiple = session.firstMultiple;
|
28838 | var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
|
28839 | var center = input.center = getCenter(pointers);
|
28840 | input.timeStamp = now();
|
28841 | input.deltaTime = input.timeStamp - firstInput.timeStamp;
|
28842 | input.angle = getAngle(offsetCenter, center);
|
28843 | input.distance = getDistance(offsetCenter, center);
|
28844 | computeDeltaXY(session, input);
|
28845 | input.offsetDirection = getDirection(input.deltaX, input.deltaY);
|
28846 | var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
|
28847 | input.overallVelocityX = overallVelocity.x;
|
28848 | input.overallVelocityY = overallVelocity.y;
|
28849 | input.overallVelocity = abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y;
|
28850 | input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
|
28851 | input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
|
28852 | input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers;
|
28853 | computeIntervalInputData(session, input);
|
28854 |
|
28855 | var target = manager.element;
|
28856 |
|
28857 | if (hasParent(input.srcEvent.target, target)) {
|
28858 | target = input.srcEvent.target;
|
28859 | }
|
28860 |
|
28861 | input.target = target;
|
28862 | }
|
28863 |
|
28864 | function computeDeltaXY(session, input) {
|
28865 | var center = input.center;
|
28866 | var offset = session.offsetDelta || {};
|
28867 | var prevDelta = session.prevDelta || {};
|
28868 | var prevInput = session.prevInput || {};
|
28869 |
|
28870 | if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
|
28871 | prevDelta = session.prevDelta = {
|
28872 | x: prevInput.deltaX || 0,
|
28873 | y: prevInput.deltaY || 0
|
28874 | };
|
28875 | offset = session.offsetDelta = {
|
28876 | x: center.x,
|
28877 | y: center.y
|
28878 | };
|
28879 | }
|
28880 |
|
28881 | input.deltaX = prevDelta.x + (center.x - offset.x);
|
28882 | input.deltaY = prevDelta.y + (center.y - offset.y);
|
28883 | }
|
28884 | |
28885 |
|
28886 |
|
28887 |
|
28888 |
|
28889 |
|
28890 |
|
28891 | function computeIntervalInputData(session, input) {
|
28892 | var last = session.lastInterval || input,
|
28893 | deltaTime = input.timeStamp - last.timeStamp,
|
28894 | velocity,
|
28895 | velocityX,
|
28896 | velocityY,
|
28897 | direction;
|
28898 |
|
28899 | if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined$1)) {
|
28900 | var deltaX = input.deltaX - last.deltaX;
|
28901 | var deltaY = input.deltaY - last.deltaY;
|
28902 | var v = getVelocity(deltaTime, deltaX, deltaY);
|
28903 | velocityX = v.x;
|
28904 | velocityY = v.y;
|
28905 | velocity = abs(v.x) > abs(v.y) ? v.x : v.y;
|
28906 | direction = getDirection(deltaX, deltaY);
|
28907 | session.lastInterval = input;
|
28908 | } else {
|
28909 |
|
28910 | velocity = last.velocity;
|
28911 | velocityX = last.velocityX;
|
28912 | velocityY = last.velocityY;
|
28913 | direction = last.direction;
|
28914 | }
|
28915 |
|
28916 | input.velocity = velocity;
|
28917 | input.velocityX = velocityX;
|
28918 | input.velocityY = velocityY;
|
28919 | input.direction = direction;
|
28920 | }
|
28921 | |
28922 |
|
28923 |
|
28924 |
|
28925 |
|
28926 |
|
28927 |
|
28928 | function simpleCloneInputData(input) {
|
28929 |
|
28930 |
|
28931 | var pointers = [];
|
28932 | var i = 0;
|
28933 |
|
28934 | while (i < input.pointers.length) {
|
28935 | pointers[i] = {
|
28936 | clientX: round(input.pointers[i].clientX),
|
28937 | clientY: round(input.pointers[i].clientY)
|
28938 | };
|
28939 | i++;
|
28940 | }
|
28941 |
|
28942 | return {
|
28943 | timeStamp: now(),
|
28944 | pointers: pointers,
|
28945 | center: getCenter(pointers),
|
28946 | deltaX: input.deltaX,
|
28947 | deltaY: input.deltaY
|
28948 | };
|
28949 | }
|
28950 | |
28951 |
|
28952 |
|
28953 |
|
28954 |
|
28955 |
|
28956 |
|
28957 | function getCenter(pointers) {
|
28958 | var pointersLength = pointers.length;
|
28959 |
|
28960 | if (pointersLength === 1) {
|
28961 | return {
|
28962 | x: round(pointers[0].clientX),
|
28963 | y: round(pointers[0].clientY)
|
28964 | };
|
28965 | }
|
28966 |
|
28967 | var x = 0,
|
28968 | y = 0,
|
28969 | i = 0;
|
28970 |
|
28971 | while (i < pointersLength) {
|
28972 | x += pointers[i].clientX;
|
28973 | y += pointers[i].clientY;
|
28974 | i++;
|
28975 | }
|
28976 |
|
28977 | return {
|
28978 | x: round(x / pointersLength),
|
28979 | y: round(y / pointersLength)
|
28980 | };
|
28981 | }
|
28982 | |
28983 |
|
28984 |
|
28985 |
|
28986 |
|
28987 |
|
28988 |
|
28989 |
|
28990 |
|
28991 | function getVelocity(deltaTime, x, y) {
|
28992 | return {
|
28993 | x: x / deltaTime || 0,
|
28994 | y: y / deltaTime || 0
|
28995 | };
|
28996 | }
|
28997 | |
28998 |
|
28999 |
|
29000 |
|
29001 |
|
29002 |
|
29003 |
|
29004 |
|
29005 | function getDirection(x, y) {
|
29006 | if (x === y) {
|
29007 | return DIRECTION_NONE;
|
29008 | }
|
29009 |
|
29010 | if (abs(x) >= abs(y)) {
|
29011 | return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
29012 | }
|
29013 |
|
29014 | return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
29015 | }
|
29016 | |
29017 |
|
29018 |
|
29019 |
|
29020 |
|
29021 |
|
29022 |
|
29023 |
|
29024 |
|
29025 | function getDistance(p1, p2, props) {
|
29026 | if (!props) {
|
29027 | props = PROPS_XY;
|
29028 | }
|
29029 |
|
29030 | var x = p2[props[0]] - p1[props[0]],
|
29031 | y = p2[props[1]] - p1[props[1]];
|
29032 | return Math.sqrt(x * x + y * y);
|
29033 | }
|
29034 | |
29035 |
|
29036 |
|
29037 |
|
29038 |
|
29039 |
|
29040 |
|
29041 |
|
29042 |
|
29043 | function getAngle(p1, p2, props) {
|
29044 | if (!props) {
|
29045 | props = PROPS_XY;
|
29046 | }
|
29047 |
|
29048 | var x = p2[props[0]] - p1[props[0]],
|
29049 | y = p2[props[1]] - p1[props[1]];
|
29050 | return Math.atan2(y, x) * 180 / Math.PI;
|
29051 | }
|
29052 | |
29053 |
|
29054 |
|
29055 |
|
29056 |
|
29057 |
|
29058 |
|
29059 |
|
29060 | function getRotation(start, end) {
|
29061 | return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
29062 | }
|
29063 | |
29064 |
|
29065 |
|
29066 |
|
29067 |
|
29068 |
|
29069 |
|
29070 |
|
29071 |
|
29072 | function getScale(start, end) {
|
29073 | return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
29074 | }
|
29075 |
|
29076 | var MOUSE_INPUT_MAP = {
|
29077 | mousedown: INPUT_START,
|
29078 | mousemove: INPUT_MOVE,
|
29079 | mouseup: INPUT_END
|
29080 | };
|
29081 | var MOUSE_ELEMENT_EVENTS = 'mousedown';
|
29082 | var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
|
29083 | |
29084 |
|
29085 |
|
29086 |
|
29087 |
|
29088 |
|
29089 | function MouseInput() {
|
29090 | this.evEl = MOUSE_ELEMENT_EVENTS;
|
29091 | this.evWin = MOUSE_WINDOW_EVENTS;
|
29092 | this.pressed = false;
|
29093 |
|
29094 | Input.apply(this, arguments);
|
29095 | }
|
29096 |
|
29097 | inherit(MouseInput, Input, {
|
29098 | |
29099 |
|
29100 |
|
29101 |
|
29102 | handler: function MEhandler(ev) {
|
29103 | var eventType = MOUSE_INPUT_MAP[ev.type];
|
29104 |
|
29105 | if (eventType & INPUT_START && ev.button === 0) {
|
29106 | this.pressed = true;
|
29107 | }
|
29108 |
|
29109 | if (eventType & INPUT_MOVE && ev.which !== 1) {
|
29110 | eventType = INPUT_END;
|
29111 | }
|
29112 |
|
29113 |
|
29114 | if (!this.pressed) {
|
29115 | return;
|
29116 | }
|
29117 |
|
29118 | if (eventType & INPUT_END) {
|
29119 | this.pressed = false;
|
29120 | }
|
29121 |
|
29122 | this.callback(this.manager, eventType, {
|
29123 | pointers: [ev],
|
29124 | changedPointers: [ev],
|
29125 | pointerType: INPUT_TYPE_MOUSE,
|
29126 | srcEvent: ev
|
29127 | });
|
29128 | }
|
29129 | });
|
29130 | var POINTER_INPUT_MAP = {
|
29131 | pointerdown: INPUT_START,
|
29132 | pointermove: INPUT_MOVE,
|
29133 | pointerup: INPUT_END,
|
29134 | pointercancel: INPUT_CANCEL,
|
29135 | pointerout: INPUT_CANCEL
|
29136 | };
|
29137 |
|
29138 | var IE10_POINTER_TYPE_ENUM = {
|
29139 | 2: INPUT_TYPE_TOUCH,
|
29140 | 3: INPUT_TYPE_PEN,
|
29141 | 4: INPUT_TYPE_MOUSE,
|
29142 | 5: INPUT_TYPE_KINECT
|
29143 |
|
29144 | };
|
29145 | var POINTER_ELEMENT_EVENTS = 'pointerdown';
|
29146 | var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
|
29147 |
|
29148 | if (window.MSPointerEvent && !window.PointerEvent) {
|
29149 | POINTER_ELEMENT_EVENTS = 'MSPointerDown';
|
29150 | POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
|
29151 | }
|
29152 | |
29153 |
|
29154 |
|
29155 |
|
29156 |
|
29157 |
|
29158 |
|
29159 | function PointerEventInput() {
|
29160 | this.evEl = POINTER_ELEMENT_EVENTS;
|
29161 | this.evWin = POINTER_WINDOW_EVENTS;
|
29162 | Input.apply(this, arguments);
|
29163 | this.store = this.manager.session.pointerEvents = [];
|
29164 | }
|
29165 |
|
29166 | inherit(PointerEventInput, Input, {
|
29167 | |
29168 |
|
29169 |
|
29170 |
|
29171 | handler: function PEhandler(ev) {
|
29172 | var store = this.store;
|
29173 | var removePointer = false;
|
29174 | var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
|
29175 | var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
|
29176 | var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
|
29177 | var isTouch = pointerType == INPUT_TYPE_TOUCH;
|
29178 |
|
29179 | var storeIndex = inArray(store, ev.pointerId, 'pointerId');
|
29180 |
|
29181 | if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
|
29182 | if (storeIndex < 0) {
|
29183 | store.push(ev);
|
29184 | storeIndex = store.length - 1;
|
29185 | }
|
29186 | } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
29187 | removePointer = true;
|
29188 | }
|
29189 |
|
29190 |
|
29191 | if (storeIndex < 0) {
|
29192 | return;
|
29193 | }
|
29194 |
|
29195 |
|
29196 | store[storeIndex] = ev;
|
29197 | this.callback(this.manager, eventType, {
|
29198 | pointers: store,
|
29199 | changedPointers: [ev],
|
29200 | pointerType: pointerType,
|
29201 | srcEvent: ev
|
29202 | });
|
29203 |
|
29204 | if (removePointer) {
|
29205 |
|
29206 | store.splice(storeIndex, 1);
|
29207 | }
|
29208 | }
|
29209 | });
|
29210 | var SINGLE_TOUCH_INPUT_MAP = {
|
29211 | touchstart: INPUT_START,
|
29212 | touchmove: INPUT_MOVE,
|
29213 | touchend: INPUT_END,
|
29214 | touchcancel: INPUT_CANCEL
|
29215 | };
|
29216 | var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
|
29217 | var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
|
29218 | |
29219 |
|
29220 |
|
29221 |
|
29222 |
|
29223 |
|
29224 | function SingleTouchInput() {
|
29225 | this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
|
29226 | this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
|
29227 | this.started = false;
|
29228 | Input.apply(this, arguments);
|
29229 | }
|
29230 |
|
29231 | inherit(SingleTouchInput, Input, {
|
29232 | handler: function TEhandler(ev) {
|
29233 | var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
29234 |
|
29235 | if (type === INPUT_START) {
|
29236 | this.started = true;
|
29237 | }
|
29238 |
|
29239 | if (!this.started) {
|
29240 | return;
|
29241 | }
|
29242 |
|
29243 | var touches = normalizeSingleTouches.call(this, ev, type);
|
29244 |
|
29245 | if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
|
29246 | this.started = false;
|
29247 | }
|
29248 |
|
29249 | this.callback(this.manager, type, {
|
29250 | pointers: touches[0],
|
29251 | changedPointers: touches[1],
|
29252 | pointerType: INPUT_TYPE_TOUCH,
|
29253 | srcEvent: ev
|
29254 | });
|
29255 | }
|
29256 | });
|
29257 | |
29258 |
|
29259 |
|
29260 |
|
29261 |
|
29262 |
|
29263 |
|
29264 | function normalizeSingleTouches(ev, type) {
|
29265 | var all = toArray(ev.touches);
|
29266 | var changed = toArray(ev.changedTouches);
|
29267 |
|
29268 | if (type & (INPUT_END | INPUT_CANCEL)) {
|
29269 | all = uniqueArray(all.concat(changed), 'identifier', true);
|
29270 | }
|
29271 |
|
29272 | return [all, changed];
|
29273 | }
|
29274 |
|
29275 | var TOUCH_INPUT_MAP = {
|
29276 | touchstart: INPUT_START,
|
29277 | touchmove: INPUT_MOVE,
|
29278 | touchend: INPUT_END,
|
29279 | touchcancel: INPUT_CANCEL
|
29280 | };
|
29281 | var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
|
29282 | |
29283 |
|
29284 |
|
29285 |
|
29286 |
|
29287 |
|
29288 | function TouchInput() {
|
29289 | this.evTarget = TOUCH_TARGET_EVENTS;
|
29290 | this.targetIds = {};
|
29291 | Input.apply(this, arguments);
|
29292 | }
|
29293 |
|
29294 | inherit(TouchInput, Input, {
|
29295 | handler: function MTEhandler(ev) {
|
29296 | var type = TOUCH_INPUT_MAP[ev.type];
|
29297 | var touches = getTouches.call(this, ev, type);
|
29298 |
|
29299 | if (!touches) {
|
29300 | return;
|
29301 | }
|
29302 |
|
29303 | this.callback(this.manager, type, {
|
29304 | pointers: touches[0],
|
29305 | changedPointers: touches[1],
|
29306 | pointerType: INPUT_TYPE_TOUCH,
|
29307 | srcEvent: ev
|
29308 | });
|
29309 | }
|
29310 | });
|
29311 | |
29312 |
|
29313 |
|
29314 |
|
29315 |
|
29316 |
|
29317 |
|
29318 | function getTouches(ev, type) {
|
29319 | var allTouches = toArray(ev.touches);
|
29320 | var targetIds = this.targetIds;
|
29321 |
|
29322 | if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
|
29323 | targetIds[allTouches[0].identifier] = true;
|
29324 | return [allTouches, allTouches];
|
29325 | }
|
29326 |
|
29327 | var i,
|
29328 | targetTouches,
|
29329 | changedTouches = toArray(ev.changedTouches),
|
29330 | changedTargetTouches = [],
|
29331 | target = this.target;
|
29332 |
|
29333 | targetTouches = allTouches.filter(function (touch) {
|
29334 | return hasParent(touch.target, target);
|
29335 | });
|
29336 |
|
29337 | if (type === INPUT_START) {
|
29338 | i = 0;
|
29339 |
|
29340 | while (i < targetTouches.length) {
|
29341 | targetIds[targetTouches[i].identifier] = true;
|
29342 | i++;
|
29343 | }
|
29344 | }
|
29345 |
|
29346 |
|
29347 | i = 0;
|
29348 |
|
29349 | while (i < changedTouches.length) {
|
29350 | if (targetIds[changedTouches[i].identifier]) {
|
29351 | changedTargetTouches.push(changedTouches[i]);
|
29352 | }
|
29353 |
|
29354 |
|
29355 | if (type & (INPUT_END | INPUT_CANCEL)) {
|
29356 | delete targetIds[changedTouches[i].identifier];
|
29357 | }
|
29358 |
|
29359 | i++;
|
29360 | }
|
29361 |
|
29362 | if (!changedTargetTouches.length) {
|
29363 | return;
|
29364 | }
|
29365 |
|
29366 | return [
|
29367 | uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true), changedTargetTouches];
|
29368 | }
|
29369 | |
29370 |
|
29371 |
|
29372 |
|
29373 |
|
29374 |
|
29375 |
|
29376 |
|
29377 |
|
29378 |
|
29379 |
|
29380 | var DEDUP_TIMEOUT = 2500;
|
29381 | var DEDUP_DISTANCE = 25;
|
29382 |
|
29383 | function TouchMouseInput() {
|
29384 | Input.apply(this, arguments);
|
29385 | var handler = bindFn(this.handler, this);
|
29386 | this.touch = new TouchInput(this.manager, handler);
|
29387 | this.mouse = new MouseInput(this.manager, handler);
|
29388 | this.primaryTouch = null;
|
29389 | this.lastTouches = [];
|
29390 | }
|
29391 |
|
29392 | inherit(TouchMouseInput, Input, {
|
29393 | |
29394 |
|
29395 |
|
29396 |
|
29397 |
|
29398 |
|
29399 | handler: function TMEhandler(manager, inputEvent, inputData) {
|
29400 | var isTouch = inputData.pointerType == INPUT_TYPE_TOUCH,
|
29401 | isMouse = inputData.pointerType == INPUT_TYPE_MOUSE;
|
29402 |
|
29403 | if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
|
29404 | return;
|
29405 | }
|
29406 |
|
29407 |
|
29408 | if (isTouch) {
|
29409 | recordTouches.call(this, inputEvent, inputData);
|
29410 | } else if (isMouse && isSyntheticEvent.call(this, inputData)) {
|
29411 | return;
|
29412 | }
|
29413 |
|
29414 | this.callback(manager, inputEvent, inputData);
|
29415 | },
|
29416 |
|
29417 | |
29418 |
|
29419 |
|
29420 | destroy: function destroy() {
|
29421 | this.touch.destroy();
|
29422 | this.mouse.destroy();
|
29423 | }
|
29424 | });
|
29425 |
|
29426 | function recordTouches(eventType, eventData) {
|
29427 | if (eventType & INPUT_START) {
|
29428 | this.primaryTouch = eventData.changedPointers[0].identifier;
|
29429 | setLastTouch.call(this, eventData);
|
29430 | } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
29431 | setLastTouch.call(this, eventData);
|
29432 | }
|
29433 | }
|
29434 |
|
29435 | function setLastTouch(eventData) {
|
29436 | var touch = eventData.changedPointers[0];
|
29437 |
|
29438 | if (touch.identifier === this.primaryTouch) {
|
29439 | var lastTouch = {
|
29440 | x: touch.clientX,
|
29441 | y: touch.clientY
|
29442 | };
|
29443 | this.lastTouches.push(lastTouch);
|
29444 | var lts = this.lastTouches;
|
29445 |
|
29446 | var removeLastTouch = function () {
|
29447 | var i = lts.indexOf(lastTouch);
|
29448 |
|
29449 | if (i > -1) {
|
29450 | lts.splice(i, 1);
|
29451 | }
|
29452 | };
|
29453 |
|
29454 | setTimeout(removeLastTouch, DEDUP_TIMEOUT);
|
29455 | }
|
29456 | }
|
29457 |
|
29458 | function isSyntheticEvent(eventData) {
|
29459 | var x = eventData.srcEvent.clientX,
|
29460 | y = eventData.srcEvent.clientY;
|
29461 |
|
29462 | for (var i = 0; i < this.lastTouches.length; i++) {
|
29463 | var t = this.lastTouches[i];
|
29464 | var dx = Math.abs(x - t.x),
|
29465 | dy = Math.abs(y - t.y);
|
29466 |
|
29467 | if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
|
29468 | return true;
|
29469 | }
|
29470 | }
|
29471 |
|
29472 | return false;
|
29473 | }
|
29474 |
|
29475 | var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
|
29476 | var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined$1;
|
29477 |
|
29478 | var TOUCH_ACTION_COMPUTE = 'compute';
|
29479 | var TOUCH_ACTION_AUTO = 'auto';
|
29480 | var TOUCH_ACTION_MANIPULATION = 'manipulation';
|
29481 |
|
29482 | var TOUCH_ACTION_NONE = 'none';
|
29483 | var TOUCH_ACTION_PAN_X = 'pan-x';
|
29484 | var TOUCH_ACTION_PAN_Y = 'pan-y';
|
29485 | var TOUCH_ACTION_MAP = getTouchActionProps();
|
29486 | |
29487 |
|
29488 |
|
29489 |
|
29490 |
|
29491 |
|
29492 |
|
29493 |
|
29494 | function TouchAction(manager, value) {
|
29495 | this.manager = manager;
|
29496 | this.set(value);
|
29497 | }
|
29498 |
|
29499 | TouchAction.prototype = {
|
29500 | |
29501 |
|
29502 |
|
29503 |
|
29504 | set: function (value) {
|
29505 |
|
29506 | if (value == TOUCH_ACTION_COMPUTE) {
|
29507 | value = this.compute();
|
29508 | }
|
29509 |
|
29510 | if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
|
29511 | this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
|
29512 | }
|
29513 |
|
29514 | this.actions = value.toLowerCase().trim();
|
29515 | },
|
29516 |
|
29517 | |
29518 |
|
29519 |
|
29520 | update: function () {
|
29521 | this.set(this.manager.options.touchAction);
|
29522 | },
|
29523 |
|
29524 | |
29525 |
|
29526 |
|
29527 |
|
29528 | compute: function () {
|
29529 | var actions = [];
|
29530 | each(this.manager.recognizers, function (recognizer) {
|
29531 | if (boolOrFn(recognizer.options.enable, [recognizer])) {
|
29532 | actions = actions.concat(recognizer.getTouchAction());
|
29533 | }
|
29534 | });
|
29535 | return cleanTouchActions(actions.join(' '));
|
29536 | },
|
29537 |
|
29538 | |
29539 |
|
29540 |
|
29541 |
|
29542 | preventDefaults: function (input) {
|
29543 | var srcEvent = input.srcEvent;
|
29544 | var direction = input.offsetDirection;
|
29545 |
|
29546 | if (this.manager.session.prevented) {
|
29547 | srcEvent.preventDefault();
|
29548 | return;
|
29549 | }
|
29550 |
|
29551 | var actions = this.actions;
|
29552 | var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
|
29553 | var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
|
29554 | var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
|
29555 |
|
29556 | if (hasNone) {
|
29557 |
|
29558 | var isTapPointer = input.pointers.length === 1;
|
29559 | var isTapMovement = input.distance < 2;
|
29560 | var isTapTouchTime = input.deltaTime < 250;
|
29561 |
|
29562 | if (isTapPointer && isTapMovement && isTapTouchTime) {
|
29563 | return;
|
29564 | }
|
29565 | }
|
29566 |
|
29567 | if (hasPanX && hasPanY) {
|
29568 |
|
29569 | return;
|
29570 | }
|
29571 |
|
29572 | if (hasNone || hasPanY && direction & DIRECTION_HORIZONTAL || hasPanX && direction & DIRECTION_VERTICAL) {
|
29573 | return this.preventSrc(srcEvent);
|
29574 | }
|
29575 | },
|
29576 |
|
29577 | |
29578 |
|
29579 |
|
29580 |
|
29581 | preventSrc: function (srcEvent) {
|
29582 | this.manager.session.prevented = true;
|
29583 | srcEvent.preventDefault();
|
29584 | }
|
29585 | };
|
29586 | |
29587 |
|
29588 |
|
29589 |
|
29590 |
|
29591 |
|
29592 | function cleanTouchActions(actions) {
|
29593 |
|
29594 | if (inStr(actions, TOUCH_ACTION_NONE)) {
|
29595 | return TOUCH_ACTION_NONE;
|
29596 | }
|
29597 |
|
29598 | var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
|
29599 | var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
|
29600 |
|
29601 |
|
29602 |
|
29603 |
|
29604 | if (hasPanX && hasPanY) {
|
29605 | return TOUCH_ACTION_NONE;
|
29606 | }
|
29607 |
|
29608 |
|
29609 | if (hasPanX || hasPanY) {
|
29610 | return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
|
29611 | }
|
29612 |
|
29613 |
|
29614 | if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
|
29615 | return TOUCH_ACTION_MANIPULATION;
|
29616 | }
|
29617 |
|
29618 | return TOUCH_ACTION_AUTO;
|
29619 | }
|
29620 |
|
29621 | function getTouchActionProps() {
|
29622 | if (!NATIVE_TOUCH_ACTION) {
|
29623 | return false;
|
29624 | }
|
29625 |
|
29626 | var touchMap = {};
|
29627 | var cssSupports = window.CSS && window.CSS.supports;
|
29628 | ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function (val) {
|
29629 |
|
29630 |
|
29631 | touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
|
29632 | });
|
29633 | return touchMap;
|
29634 | }
|
29635 | |
29636 |
|
29637 |
|
29638 |
|
29639 |
|
29640 |
|
29641 |
|
29642 |
|
29643 |
|
29644 |
|
29645 |
|
29646 |
|
29647 |
|
29648 |
|
29649 |
|
29650 |
|
29651 |
|
29652 |
|
29653 |
|
29654 |
|
29655 |
|
29656 |
|
29657 |
|
29658 |
|
29659 |
|
29660 |
|
29661 |
|
29662 |
|
29663 |
|
29664 | var STATE_POSSIBLE = 1;
|
29665 | var STATE_BEGAN = 2;
|
29666 | var STATE_CHANGED = 4;
|
29667 | var STATE_ENDED = 8;
|
29668 | var STATE_RECOGNIZED = STATE_ENDED;
|
29669 | var STATE_CANCELLED = 16;
|
29670 | var STATE_FAILED = 32;
|
29671 | |
29672 |
|
29673 |
|
29674 |
|
29675 |
|
29676 |
|
29677 |
|
29678 | function Recognizer(options) {
|
29679 | this.options = assign({}, this.defaults, options || {});
|
29680 | this.id = uniqueId();
|
29681 | this.manager = null;
|
29682 |
|
29683 | this.options.enable = ifUndefined(this.options.enable, true);
|
29684 | this.state = STATE_POSSIBLE;
|
29685 | this.simultaneous = {};
|
29686 | this.requireFail = [];
|
29687 | }
|
29688 |
|
29689 | Recognizer.prototype = {
|
29690 | |
29691 |
|
29692 |
|
29693 |
|
29694 | defaults: {},
|
29695 |
|
29696 | |
29697 |
|
29698 |
|
29699 |
|
29700 |
|
29701 | set: function (options) {
|
29702 | assign(this.options, options);
|
29703 |
|
29704 | this.manager && this.manager.touchAction.update();
|
29705 | return this;
|
29706 | },
|
29707 |
|
29708 | |
29709 |
|
29710 |
|
29711 |
|
29712 |
|
29713 | recognizeWith: function (otherRecognizer) {
|
29714 | if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
|
29715 | return this;
|
29716 | }
|
29717 |
|
29718 | var simultaneous = this.simultaneous;
|
29719 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
29720 |
|
29721 | if (!simultaneous[otherRecognizer.id]) {
|
29722 | simultaneous[otherRecognizer.id] = otherRecognizer;
|
29723 | otherRecognizer.recognizeWith(this);
|
29724 | }
|
29725 |
|
29726 | return this;
|
29727 | },
|
29728 |
|
29729 | |
29730 |
|
29731 |
|
29732 |
|
29733 |
|
29734 | dropRecognizeWith: function (otherRecognizer) {
|
29735 | if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
|
29736 | return this;
|
29737 | }
|
29738 |
|
29739 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
29740 | delete this.simultaneous[otherRecognizer.id];
|
29741 | return this;
|
29742 | },
|
29743 |
|
29744 | |
29745 |
|
29746 |
|
29747 |
|
29748 |
|
29749 | requireFailure: function (otherRecognizer) {
|
29750 | if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
|
29751 | return this;
|
29752 | }
|
29753 |
|
29754 | var requireFail = this.requireFail;
|
29755 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
29756 |
|
29757 | if (inArray(requireFail, otherRecognizer) === -1) {
|
29758 | requireFail.push(otherRecognizer);
|
29759 | otherRecognizer.requireFailure(this);
|
29760 | }
|
29761 |
|
29762 | return this;
|
29763 | },
|
29764 |
|
29765 | |
29766 |
|
29767 |
|
29768 |
|
29769 |
|
29770 | dropRequireFailure: function (otherRecognizer) {
|
29771 | if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
|
29772 | return this;
|
29773 | }
|
29774 |
|
29775 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
29776 | var index = inArray(this.requireFail, otherRecognizer);
|
29777 |
|
29778 | if (index > -1) {
|
29779 | this.requireFail.splice(index, 1);
|
29780 | }
|
29781 |
|
29782 | return this;
|
29783 | },
|
29784 |
|
29785 | |
29786 |
|
29787 |
|
29788 |
|
29789 | hasRequireFailures: function () {
|
29790 | return this.requireFail.length > 0;
|
29791 | },
|
29792 |
|
29793 | |
29794 |
|
29795 |
|
29796 |
|
29797 |
|
29798 | canRecognizeWith: function (otherRecognizer) {
|
29799 | return !!this.simultaneous[otherRecognizer.id];
|
29800 | },
|
29801 |
|
29802 | |
29803 |
|
29804 |
|
29805 |
|
29806 |
|
29807 | emit: function (input) {
|
29808 | var self = this;
|
29809 | var state = this.state;
|
29810 |
|
29811 | function emit(event) {
|
29812 | self.manager.emit(event, input);
|
29813 | }
|
29814 |
|
29815 |
|
29816 | if (state < STATE_ENDED) {
|
29817 | emit(self.options.event + stateStr(state));
|
29818 | }
|
29819 |
|
29820 | emit(self.options.event);
|
29821 |
|
29822 | if (input.additionalEvent) {
|
29823 |
|
29824 | emit(input.additionalEvent);
|
29825 | }
|
29826 |
|
29827 |
|
29828 | if (state >= STATE_ENDED) {
|
29829 | emit(self.options.event + stateStr(state));
|
29830 | }
|
29831 | },
|
29832 |
|
29833 | |
29834 |
|
29835 |
|
29836 |
|
29837 |
|
29838 |
|
29839 | tryEmit: function (input) {
|
29840 | if (this.canEmit()) {
|
29841 | return this.emit(input);
|
29842 | }
|
29843 |
|
29844 |
|
29845 | this.state = STATE_FAILED;
|
29846 | },
|
29847 |
|
29848 | |
29849 |
|
29850 |
|
29851 |
|
29852 | canEmit: function () {
|
29853 | var i = 0;
|
29854 |
|
29855 | while (i < this.requireFail.length) {
|
29856 | if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
|
29857 | return false;
|
29858 | }
|
29859 |
|
29860 | i++;
|
29861 | }
|
29862 |
|
29863 | return true;
|
29864 | },
|
29865 |
|
29866 | |
29867 |
|
29868 |
|
29869 |
|
29870 | recognize: function (inputData) {
|
29871 |
|
29872 |
|
29873 | var inputDataClone = assign({}, inputData);
|
29874 |
|
29875 | if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
|
29876 | this.reset();
|
29877 | this.state = STATE_FAILED;
|
29878 | return;
|
29879 | }
|
29880 |
|
29881 |
|
29882 | if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
|
29883 | this.state = STATE_POSSIBLE;
|
29884 | }
|
29885 |
|
29886 | this.state = this.process(inputDataClone);
|
29887 |
|
29888 |
|
29889 | if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
|
29890 | this.tryEmit(inputDataClone);
|
29891 | }
|
29892 | },
|
29893 |
|
29894 | |
29895 |
|
29896 |
|
29897 |
|
29898 |
|
29899 |
|
29900 |
|
29901 | process: function (inputData) {},
|
29902 |
|
29903 |
|
29904 | |
29905 |
|
29906 |
|
29907 |
|
29908 |
|
29909 | getTouchAction: function () {},
|
29910 |
|
29911 | |
29912 |
|
29913 |
|
29914 |
|
29915 |
|
29916 | reset: function () {}
|
29917 | };
|
29918 | |
29919 |
|
29920 |
|
29921 |
|
29922 |
|
29923 |
|
29924 | function stateStr(state) {
|
29925 | if (state & STATE_CANCELLED) {
|
29926 | return 'cancel';
|
29927 | } else if (state & STATE_ENDED) {
|
29928 | return 'end';
|
29929 | } else if (state & STATE_CHANGED) {
|
29930 | return 'move';
|
29931 | } else if (state & STATE_BEGAN) {
|
29932 | return 'start';
|
29933 | }
|
29934 |
|
29935 | return '';
|
29936 | }
|
29937 | |
29938 |
|
29939 |
|
29940 |
|
29941 |
|
29942 |
|
29943 |
|
29944 | function directionStr(direction) {
|
29945 | if (direction == DIRECTION_DOWN) {
|
29946 | return 'down';
|
29947 | } else if (direction == DIRECTION_UP) {
|
29948 | return 'up';
|
29949 | } else if (direction == DIRECTION_LEFT) {
|
29950 | return 'left';
|
29951 | } else if (direction == DIRECTION_RIGHT) {
|
29952 | return 'right';
|
29953 | }
|
29954 |
|
29955 | return '';
|
29956 | }
|
29957 | |
29958 |
|
29959 |
|
29960 |
|
29961 |
|
29962 |
|
29963 |
|
29964 |
|
29965 | function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
29966 | var manager = recognizer.manager;
|
29967 |
|
29968 | if (manager) {
|
29969 | return manager.get(otherRecognizer);
|
29970 | }
|
29971 |
|
29972 | return otherRecognizer;
|
29973 | }
|
29974 | |
29975 |
|
29976 |
|
29977 |
|
29978 |
|
29979 |
|
29980 |
|
29981 | function AttrRecognizer() {
|
29982 | Recognizer.apply(this, arguments);
|
29983 | }
|
29984 |
|
29985 | inherit(AttrRecognizer, Recognizer, {
|
29986 | |
29987 |
|
29988 |
|
29989 |
|
29990 | defaults: {
|
29991 | |
29992 |
|
29993 |
|
29994 |
|
29995 | pointers: 1
|
29996 | },
|
29997 |
|
29998 | |
29999 |
|
30000 |
|
30001 |
|
30002 |
|
30003 |
|
30004 | attrTest: function (input) {
|
30005 | var optionPointers = this.options.pointers;
|
30006 | return optionPointers === 0 || input.pointers.length === optionPointers;
|
30007 | },
|
30008 |
|
30009 | |
30010 |
|
30011 |
|
30012 |
|
30013 |
|
30014 |
|
30015 | process: function (input) {
|
30016 | var state = this.state;
|
30017 | var eventType = input.eventType;
|
30018 | var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
|
30019 | var isValid = this.attrTest(input);
|
30020 |
|
30021 | if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
|
30022 | return state | STATE_CANCELLED;
|
30023 | } else if (isRecognized || isValid) {
|
30024 | if (eventType & INPUT_END) {
|
30025 | return state | STATE_ENDED;
|
30026 | } else if (!(state & STATE_BEGAN)) {
|
30027 | return STATE_BEGAN;
|
30028 | }
|
30029 |
|
30030 | return state | STATE_CHANGED;
|
30031 | }
|
30032 |
|
30033 | return STATE_FAILED;
|
30034 | }
|
30035 | });
|
30036 | |
30037 |
|
30038 |
|
30039 |
|
30040 |
|
30041 |
|
30042 |
|
30043 | function PanRecognizer() {
|
30044 | AttrRecognizer.apply(this, arguments);
|
30045 | this.pX = null;
|
30046 | this.pY = null;
|
30047 | }
|
30048 |
|
30049 | inherit(PanRecognizer, AttrRecognizer, {
|
30050 | |
30051 |
|
30052 |
|
30053 |
|
30054 | defaults: {
|
30055 | event: 'pan',
|
30056 | threshold: 10,
|
30057 | pointers: 1,
|
30058 | direction: DIRECTION_ALL
|
30059 | },
|
30060 | getTouchAction: function () {
|
30061 | var direction = this.options.direction;
|
30062 | var actions = [];
|
30063 |
|
30064 | if (direction & DIRECTION_HORIZONTAL) {
|
30065 | actions.push(TOUCH_ACTION_PAN_Y);
|
30066 | }
|
30067 |
|
30068 | if (direction & DIRECTION_VERTICAL) {
|
30069 | actions.push(TOUCH_ACTION_PAN_X);
|
30070 | }
|
30071 |
|
30072 | return actions;
|
30073 | },
|
30074 | directionTest: function (input) {
|
30075 | var options = this.options;
|
30076 | var hasMoved = true;
|
30077 | var distance = input.distance;
|
30078 | var direction = input.direction;
|
30079 | var x = input.deltaX;
|
30080 | var y = input.deltaY;
|
30081 |
|
30082 | if (!(direction & options.direction)) {
|
30083 | if (options.direction & DIRECTION_HORIZONTAL) {
|
30084 | direction = x === 0 ? DIRECTION_NONE : x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
30085 | hasMoved = x != this.pX;
|
30086 | distance = Math.abs(input.deltaX);
|
30087 | } else {
|
30088 | direction = y === 0 ? DIRECTION_NONE : y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
30089 | hasMoved = y != this.pY;
|
30090 | distance = Math.abs(input.deltaY);
|
30091 | }
|
30092 | }
|
30093 |
|
30094 | input.direction = direction;
|
30095 | return hasMoved && distance > options.threshold && direction & options.direction;
|
30096 | },
|
30097 | attrTest: function (input) {
|
30098 | return AttrRecognizer.prototype.attrTest.call(this, input) && (this.state & STATE_BEGAN || !(this.state & STATE_BEGAN) && this.directionTest(input));
|
30099 | },
|
30100 | emit: function (input) {
|
30101 | this.pX = input.deltaX;
|
30102 | this.pY = input.deltaY;
|
30103 | var direction = directionStr(input.direction);
|
30104 |
|
30105 | if (direction) {
|
30106 | input.additionalEvent = this.options.event + direction;
|
30107 | }
|
30108 |
|
30109 | this._super.emit.call(this, input);
|
30110 | }
|
30111 | });
|
30112 | |
30113 |
|
30114 |
|
30115 |
|
30116 |
|
30117 |
|
30118 |
|
30119 | function PinchRecognizer() {
|
30120 | AttrRecognizer.apply(this, arguments);
|
30121 | }
|
30122 |
|
30123 | inherit(PinchRecognizer, AttrRecognizer, {
|
30124 | |
30125 |
|
30126 |
|
30127 |
|
30128 | defaults: {
|
30129 | event: 'pinch',
|
30130 | threshold: 0,
|
30131 | pointers: 2
|
30132 | },
|
30133 | getTouchAction: function () {
|
30134 | return [TOUCH_ACTION_NONE];
|
30135 | },
|
30136 | attrTest: function (input) {
|
30137 | return this._super.attrTest.call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
|
30138 | },
|
30139 | emit: function (input) {
|
30140 | if (input.scale !== 1) {
|
30141 | var inOut = input.scale < 1 ? 'in' : 'out';
|
30142 | input.additionalEvent = this.options.event + inOut;
|
30143 | }
|
30144 |
|
30145 | this._super.emit.call(this, input);
|
30146 | }
|
30147 | });
|
30148 | |
30149 |
|
30150 |
|
30151 |
|
30152 |
|
30153 |
|
30154 |
|
30155 | function PressRecognizer() {
|
30156 | Recognizer.apply(this, arguments);
|
30157 | this._timer = null;
|
30158 | this._input = null;
|
30159 | }
|
30160 |
|
30161 | inherit(PressRecognizer, Recognizer, {
|
30162 | |
30163 |
|
30164 |
|
30165 |
|
30166 | defaults: {
|
30167 | event: 'press',
|
30168 | pointers: 1,
|
30169 | time: 251,
|
30170 |
|
30171 | threshold: 9
|
30172 |
|
30173 | },
|
30174 | getTouchAction: function () {
|
30175 | return [TOUCH_ACTION_AUTO];
|
30176 | },
|
30177 | process: function (input) {
|
30178 | var options = this.options;
|
30179 | var validPointers = input.pointers.length === options.pointers;
|
30180 | var validMovement = input.distance < options.threshold;
|
30181 | var validTime = input.deltaTime > options.time;
|
30182 | this._input = input;
|
30183 |
|
30184 |
|
30185 | if (!validMovement || !validPointers || input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime) {
|
30186 | this.reset();
|
30187 | } else if (input.eventType & INPUT_START) {
|
30188 | this.reset();
|
30189 | this._timer = setTimeoutContext(function () {
|
30190 | this.state = STATE_RECOGNIZED;
|
30191 | this.tryEmit();
|
30192 | }, options.time, this);
|
30193 | } else if (input.eventType & INPUT_END) {
|
30194 | return STATE_RECOGNIZED;
|
30195 | }
|
30196 |
|
30197 | return STATE_FAILED;
|
30198 | },
|
30199 | reset: function () {
|
30200 | clearTimeout(this._timer);
|
30201 | },
|
30202 | emit: function (input) {
|
30203 | if (this.state !== STATE_RECOGNIZED) {
|
30204 | return;
|
30205 | }
|
30206 |
|
30207 | if (input && input.eventType & INPUT_END) {
|
30208 | this.manager.emit(this.options.event + 'up', input);
|
30209 | } else {
|
30210 | this._input.timeStamp = now();
|
30211 | this.manager.emit(this.options.event, this._input);
|
30212 | }
|
30213 | }
|
30214 | });
|
30215 | |
30216 |
|
30217 |
|
30218 |
|
30219 |
|
30220 |
|
30221 |
|
30222 | function RotateRecognizer() {
|
30223 | AttrRecognizer.apply(this, arguments);
|
30224 | }
|
30225 |
|
30226 | inherit(RotateRecognizer, AttrRecognizer, {
|
30227 | |
30228 |
|
30229 |
|
30230 |
|
30231 | defaults: {
|
30232 | event: 'rotate',
|
30233 | threshold: 0,
|
30234 | pointers: 2
|
30235 | },
|
30236 | getTouchAction: function () {
|
30237 | return [TOUCH_ACTION_NONE];
|
30238 | },
|
30239 | attrTest: function (input) {
|
30240 | return this._super.attrTest.call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
30241 | }
|
30242 | });
|
30243 | |
30244 |
|
30245 |
|
30246 |
|
30247 |
|
30248 |
|
30249 |
|
30250 | function SwipeRecognizer() {
|
30251 | AttrRecognizer.apply(this, arguments);
|
30252 | }
|
30253 |
|
30254 | inherit(SwipeRecognizer, AttrRecognizer, {
|
30255 | |
30256 |
|
30257 |
|
30258 |
|
30259 | defaults: {
|
30260 | event: 'swipe',
|
30261 | threshold: 10,
|
30262 | velocity: 0.3,
|
30263 | direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
|
30264 | pointers: 1
|
30265 | },
|
30266 | getTouchAction: function () {
|
30267 | return PanRecognizer.prototype.getTouchAction.call(this);
|
30268 | },
|
30269 | attrTest: function (input) {
|
30270 | var direction = this.options.direction;
|
30271 | var velocity;
|
30272 |
|
30273 | if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
|
30274 | velocity = input.overallVelocity;
|
30275 | } else if (direction & DIRECTION_HORIZONTAL) {
|
30276 | velocity = input.overallVelocityX;
|
30277 | } else if (direction & DIRECTION_VERTICAL) {
|
30278 | velocity = input.overallVelocityY;
|
30279 | }
|
30280 |
|
30281 | return this._super.attrTest.call(this, input) && direction & input.offsetDirection && input.distance > this.options.threshold && input.maxPointers == this.options.pointers && abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
|
30282 | },
|
30283 | emit: function (input) {
|
30284 | var direction = directionStr(input.offsetDirection);
|
30285 |
|
30286 | if (direction) {
|
30287 | this.manager.emit(this.options.event + direction, input);
|
30288 | }
|
30289 |
|
30290 | this.manager.emit(this.options.event, input);
|
30291 | }
|
30292 | });
|
30293 | |
30294 |
|
30295 |
|
30296 |
|
30297 |
|
30298 |
|
30299 |
|
30300 |
|
30301 |
|
30302 |
|
30303 |
|
30304 | function TapRecognizer() {
|
30305 | Recognizer.apply(this, arguments);
|
30306 |
|
30307 |
|
30308 | this.pTime = false;
|
30309 | this.pCenter = false;
|
30310 | this._timer = null;
|
30311 | this._input = null;
|
30312 | this.count = 0;
|
30313 | }
|
30314 |
|
30315 | inherit(TapRecognizer, Recognizer, {
|
30316 | |
30317 |
|
30318 |
|
30319 |
|
30320 | defaults: {
|
30321 | event: 'tap',
|
30322 | pointers: 1,
|
30323 | taps: 1,
|
30324 | interval: 300,
|
30325 |
|
30326 | time: 250,
|
30327 |
|
30328 | threshold: 9,
|
30329 |
|
30330 | posThreshold: 10
|
30331 |
|
30332 | },
|
30333 | getTouchAction: function () {
|
30334 | return [TOUCH_ACTION_MANIPULATION];
|
30335 | },
|
30336 | process: function (input) {
|
30337 | var options = this.options;
|
30338 | var validPointers = input.pointers.length === options.pointers;
|
30339 | var validMovement = input.distance < options.threshold;
|
30340 | var validTouchTime = input.deltaTime < options.time;
|
30341 | this.reset();
|
30342 |
|
30343 | if (input.eventType & INPUT_START && this.count === 0) {
|
30344 | return this.failTimeout();
|
30345 | }
|
30346 |
|
30347 |
|
30348 |
|
30349 | if (validMovement && validTouchTime && validPointers) {
|
30350 | if (input.eventType != INPUT_END) {
|
30351 | return this.failTimeout();
|
30352 | }
|
30353 |
|
30354 | var validInterval = this.pTime ? input.timeStamp - this.pTime < options.interval : true;
|
30355 | var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
|
30356 | this.pTime = input.timeStamp;
|
30357 | this.pCenter = input.center;
|
30358 |
|
30359 | if (!validMultiTap || !validInterval) {
|
30360 | this.count = 1;
|
30361 | } else {
|
30362 | this.count += 1;
|
30363 | }
|
30364 |
|
30365 | this._input = input;
|
30366 |
|
30367 |
|
30368 | var tapCount = this.count % options.taps;
|
30369 |
|
30370 | if (tapCount === 0) {
|
30371 |
|
30372 |
|
30373 | if (!this.hasRequireFailures()) {
|
30374 | return STATE_RECOGNIZED;
|
30375 | } else {
|
30376 | this._timer = setTimeoutContext(function () {
|
30377 | this.state = STATE_RECOGNIZED;
|
30378 | this.tryEmit();
|
30379 | }, options.interval, this);
|
30380 | return STATE_BEGAN;
|
30381 | }
|
30382 | }
|
30383 | }
|
30384 |
|
30385 | return STATE_FAILED;
|
30386 | },
|
30387 | failTimeout: function () {
|
30388 | this._timer = setTimeoutContext(function () {
|
30389 | this.state = STATE_FAILED;
|
30390 | }, this.options.interval, this);
|
30391 | return STATE_FAILED;
|
30392 | },
|
30393 | reset: function () {
|
30394 | clearTimeout(this._timer);
|
30395 | },
|
30396 | emit: function () {
|
30397 | if (this.state == STATE_RECOGNIZED) {
|
30398 | this._input.tapCount = this.count;
|
30399 | this.manager.emit(this.options.event, this._input);
|
30400 | }
|
30401 | }
|
30402 | });
|
30403 | |
30404 |
|
30405 |
|
30406 |
|
30407 |
|
30408 |
|
30409 |
|
30410 | function Hammer(element, options) {
|
30411 | options = options || {};
|
30412 | options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
|
30413 | return new Manager(element, options);
|
30414 | }
|
30415 | |
30416 |
|
30417 |
|
30418 |
|
30419 |
|
30420 | Hammer.VERSION = '2.0.7';
|
30421 | |
30422 |
|
30423 |
|
30424 |
|
30425 |
|
30426 | Hammer.defaults = {
|
30427 | |
30428 |
|
30429 |
|
30430 |
|
30431 |
|
30432 |
|
30433 | domEvents: false,
|
30434 |
|
30435 | |
30436 |
|
30437 |
|
30438 |
|
30439 |
|
30440 |
|
30441 | touchAction: TOUCH_ACTION_COMPUTE,
|
30442 |
|
30443 | |
30444 |
|
30445 |
|
30446 |
|
30447 | enable: true,
|
30448 |
|
30449 | |
30450 |
|
30451 |
|
30452 |
|
30453 |
|
30454 |
|
30455 |
|
30456 | inputTarget: null,
|
30457 |
|
30458 | |
30459 |
|
30460 |
|
30461 |
|
30462 |
|
30463 | inputClass: null,
|
30464 |
|
30465 | |
30466 |
|
30467 |
|
30468 |
|
30469 |
|
30470 | preset: [
|
30471 | [RotateRecognizer, {
|
30472 | enable: false
|
30473 | }], [PinchRecognizer, {
|
30474 | enable: false
|
30475 | }, ['rotate']], [SwipeRecognizer, {
|
30476 | direction: DIRECTION_HORIZONTAL
|
30477 | }], [PanRecognizer, {
|
30478 | direction: DIRECTION_HORIZONTAL
|
30479 | }, ['swipe']], [TapRecognizer], [TapRecognizer, {
|
30480 | event: 'doubletap',
|
30481 | taps: 2
|
30482 | }, ['tap']], [PressRecognizer]],
|
30483 |
|
30484 | |
30485 |
|
30486 |
|
30487 |
|
30488 |
|
30489 | cssProps: {
|
30490 | |
30491 |
|
30492 |
|
30493 |
|
30494 |
|
30495 | userSelect: 'none',
|
30496 |
|
30497 | |
30498 |
|
30499 |
|
30500 |
|
30501 |
|
30502 | touchSelect: 'none',
|
30503 |
|
30504 | |
30505 |
|
30506 |
|
30507 |
|
30508 |
|
30509 |
|
30510 |
|
30511 | touchCallout: 'none',
|
30512 |
|
30513 | |
30514 |
|
30515 |
|
30516 |
|
30517 |
|
30518 | contentZooming: 'none',
|
30519 |
|
30520 | |
30521 |
|
30522 |
|
30523 |
|
30524 |
|
30525 | userDrag: 'none',
|
30526 |
|
30527 | |
30528 |
|
30529 |
|
30530 |
|
30531 |
|
30532 |
|
30533 | tapHighlightColor: 'rgba(0,0,0,0)'
|
30534 | }
|
30535 | };
|
30536 | var STOP = 1;
|
30537 | var FORCED_STOP = 2;
|
30538 | |
30539 |
|
30540 |
|
30541 |
|
30542 |
|
30543 |
|
30544 |
|
30545 | function Manager(element, options) {
|
30546 | this.options = assign({}, Hammer.defaults, options || {});
|
30547 | this.options.inputTarget = this.options.inputTarget || element;
|
30548 | this.handlers = {};
|
30549 | this.session = {};
|
30550 | this.recognizers = [];
|
30551 | this.oldCssProps = {};
|
30552 | this.element = element;
|
30553 | this.input = createInputInstance(this);
|
30554 | this.touchAction = new TouchAction(this, this.options.touchAction);
|
30555 | toggleCssProps(this, true);
|
30556 | each(this.options.recognizers, function (item) {
|
30557 | var recognizer = this.add(new item[0](item[1]));
|
30558 | item[2] && recognizer.recognizeWith(item[2]);
|
30559 | item[3] && recognizer.requireFailure(item[3]);
|
30560 | }, this);
|
30561 | }
|
30562 |
|
30563 | Manager.prototype = {
|
30564 | |
30565 |
|
30566 |
|
30567 |
|
30568 |
|
30569 | set: function (options) {
|
30570 | assign(this.options, options);
|
30571 |
|
30572 | if (options.touchAction) {
|
30573 | this.touchAction.update();
|
30574 | }
|
30575 |
|
30576 | if (options.inputTarget) {
|
30577 |
|
30578 | this.input.destroy();
|
30579 | this.input.target = options.inputTarget;
|
30580 | this.input.init();
|
30581 | }
|
30582 |
|
30583 | return this;
|
30584 | },
|
30585 |
|
30586 | |
30587 |
|
30588 |
|
30589 |
|
30590 |
|
30591 |
|
30592 | stop: function (force) {
|
30593 | this.session.stopped = force ? FORCED_STOP : STOP;
|
30594 | },
|
30595 |
|
30596 | |
30597 |
|
30598 |
|
30599 |
|
30600 |
|
30601 |
|
30602 | recognize: function (inputData) {
|
30603 | var session = this.session;
|
30604 |
|
30605 | if (session.stopped) {
|
30606 | return;
|
30607 | }
|
30608 |
|
30609 |
|
30610 | this.touchAction.preventDefaults(inputData);
|
30611 | var recognizer;
|
30612 | var recognizers = this.recognizers;
|
30613 |
|
30614 |
|
30615 |
|
30616 | var curRecognizer = session.curRecognizer;
|
30617 |
|
30618 |
|
30619 | if (!curRecognizer || curRecognizer && curRecognizer.state & STATE_RECOGNIZED) {
|
30620 | curRecognizer = session.curRecognizer = null;
|
30621 | }
|
30622 |
|
30623 | var i = 0;
|
30624 |
|
30625 | while (i < recognizers.length) {
|
30626 | recognizer = recognizers[i];
|
30627 |
|
30628 |
|
30629 |
|
30630 |
|
30631 |
|
30632 |
|
30633 | if (session.stopped !== FORCED_STOP && (
|
30634 | !curRecognizer || recognizer == curRecognizer ||
|
30635 | recognizer.canRecognizeWith(curRecognizer))) {
|
30636 |
|
30637 | recognizer.recognize(inputData);
|
30638 | } else {
|
30639 | recognizer.reset();
|
30640 | }
|
30641 |
|
30642 |
|
30643 |
|
30644 | if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
|
30645 | curRecognizer = session.curRecognizer = recognizer;
|
30646 | }
|
30647 |
|
30648 | i++;
|
30649 | }
|
30650 | },
|
30651 |
|
30652 | |
30653 |
|
30654 |
|
30655 |
|
30656 |
|
30657 | get: function (recognizer) {
|
30658 | if (recognizer instanceof Recognizer) {
|
30659 | return recognizer;
|
30660 | }
|
30661 |
|
30662 | var recognizers = this.recognizers;
|
30663 |
|
30664 | for (var i = 0; i < recognizers.length; i++) {
|
30665 | if (recognizers[i].options.event == recognizer) {
|
30666 | return recognizers[i];
|
30667 | }
|
30668 | }
|
30669 |
|
30670 | return null;
|
30671 | },
|
30672 |
|
30673 | |
30674 |
|
30675 |
|
30676 |
|
30677 |
|
30678 |
|
30679 | add: function (recognizer) {
|
30680 | if (invokeArrayArg(recognizer, 'add', this)) {
|
30681 | return this;
|
30682 | }
|
30683 |
|
30684 |
|
30685 | var existing = this.get(recognizer.options.event);
|
30686 |
|
30687 | if (existing) {
|
30688 | this.remove(existing);
|
30689 | }
|
30690 |
|
30691 | this.recognizers.push(recognizer);
|
30692 | recognizer.manager = this;
|
30693 | this.touchAction.update();
|
30694 | return recognizer;
|
30695 | },
|
30696 |
|
30697 | |
30698 |
|
30699 |
|
30700 |
|
30701 |
|
30702 | remove: function (recognizer) {
|
30703 | if (invokeArrayArg(recognizer, 'remove', this)) {
|
30704 | return this;
|
30705 | }
|
30706 |
|
30707 | recognizer = this.get(recognizer);
|
30708 |
|
30709 | if (recognizer) {
|
30710 | var recognizers = this.recognizers;
|
30711 | var index = inArray(recognizers, recognizer);
|
30712 |
|
30713 | if (index !== -1) {
|
30714 | recognizers.splice(index, 1);
|
30715 | this.touchAction.update();
|
30716 | }
|
30717 | }
|
30718 |
|
30719 | return this;
|
30720 | },
|
30721 |
|
30722 | |
30723 |
|
30724 |
|
30725 |
|
30726 |
|
30727 |
|
30728 | on: function (events, handler) {
|
30729 | if (events === undefined$1) {
|
30730 | return;
|
30731 | }
|
30732 |
|
30733 | if (handler === undefined$1) {
|
30734 | return;
|
30735 | }
|
30736 |
|
30737 | var handlers = this.handlers;
|
30738 | each(splitStr(events), function (event) {
|
30739 | handlers[event] = handlers[event] || [];
|
30740 | handlers[event].push(handler);
|
30741 | });
|
30742 | return this;
|
30743 | },
|
30744 |
|
30745 | |
30746 |
|
30747 |
|
30748 |
|
30749 |
|
30750 |
|
30751 | off: function (events, handler) {
|
30752 | if (events === undefined$1) {
|
30753 | return;
|
30754 | }
|
30755 |
|
30756 | var handlers = this.handlers;
|
30757 | each(splitStr(events), function (event) {
|
30758 | if (!handler) {
|
30759 | delete handlers[event];
|
30760 | } else {
|
30761 | handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
|
30762 | }
|
30763 | });
|
30764 | return this;
|
30765 | },
|
30766 |
|
30767 | |
30768 |
|
30769 |
|
30770 |
|
30771 |
|
30772 | emit: function (event, data) {
|
30773 |
|
30774 | if (this.options.domEvents) {
|
30775 | triggerDomEvent(event, data);
|
30776 | }
|
30777 |
|
30778 |
|
30779 | var handlers = this.handlers[event] && this.handlers[event].slice();
|
30780 |
|
30781 | if (!handlers || !handlers.length) {
|
30782 | return;
|
30783 | }
|
30784 |
|
30785 | data.type = event;
|
30786 |
|
30787 | data.preventDefault = function () {
|
30788 | data.srcEvent.preventDefault();
|
30789 | };
|
30790 |
|
30791 | var i = 0;
|
30792 |
|
30793 | while (i < handlers.length) {
|
30794 | handlers[i](data);
|
30795 | i++;
|
30796 | }
|
30797 | },
|
30798 |
|
30799 | |
30800 |
|
30801 |
|
30802 |
|
30803 | destroy: function () {
|
30804 | this.element && toggleCssProps(this, false);
|
30805 | this.handlers = {};
|
30806 | this.session = {};
|
30807 | this.input.destroy();
|
30808 | this.element = null;
|
30809 | }
|
30810 | };
|
30811 | |
30812 |
|
30813 |
|
30814 |
|
30815 |
|
30816 |
|
30817 | function toggleCssProps(manager, add) {
|
30818 | var element = manager.element;
|
30819 |
|
30820 | if (!element.style) {
|
30821 | return;
|
30822 | }
|
30823 |
|
30824 | var prop;
|
30825 | each(manager.options.cssProps, function (value, name) {
|
30826 | prop = prefixed(element.style, name);
|
30827 |
|
30828 | if (add) {
|
30829 | manager.oldCssProps[prop] = element.style[prop];
|
30830 | element.style[prop] = value;
|
30831 | } else {
|
30832 | element.style[prop] = manager.oldCssProps[prop] || '';
|
30833 | }
|
30834 | });
|
30835 |
|
30836 | if (!add) {
|
30837 | manager.oldCssProps = {};
|
30838 | }
|
30839 | }
|
30840 | |
30841 |
|
30842 |
|
30843 |
|
30844 |
|
30845 |
|
30846 |
|
30847 | function triggerDomEvent(event, data) {
|
30848 | var gestureEvent = document.createEvent('Event');
|
30849 | gestureEvent.initEvent(event, true, true);
|
30850 | gestureEvent.gesture = data;
|
30851 | data.target.dispatchEvent(gestureEvent);
|
30852 | }
|
30853 |
|
30854 | assign(Hammer, {
|
30855 | INPUT_START: INPUT_START,
|
30856 | INPUT_MOVE: INPUT_MOVE,
|
30857 | INPUT_END: INPUT_END,
|
30858 | INPUT_CANCEL: INPUT_CANCEL,
|
30859 | STATE_POSSIBLE: STATE_POSSIBLE,
|
30860 | STATE_BEGAN: STATE_BEGAN,
|
30861 | STATE_CHANGED: STATE_CHANGED,
|
30862 | STATE_ENDED: STATE_ENDED,
|
30863 | STATE_RECOGNIZED: STATE_RECOGNIZED,
|
30864 | STATE_CANCELLED: STATE_CANCELLED,
|
30865 | STATE_FAILED: STATE_FAILED,
|
30866 | DIRECTION_NONE: DIRECTION_NONE,
|
30867 | DIRECTION_LEFT: DIRECTION_LEFT,
|
30868 | DIRECTION_RIGHT: DIRECTION_RIGHT,
|
30869 | DIRECTION_UP: DIRECTION_UP,
|
30870 | DIRECTION_DOWN: DIRECTION_DOWN,
|
30871 | DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
|
30872 | DIRECTION_VERTICAL: DIRECTION_VERTICAL,
|
30873 | DIRECTION_ALL: DIRECTION_ALL,
|
30874 | Manager: Manager,
|
30875 | Input: Input,
|
30876 | TouchAction: TouchAction,
|
30877 | TouchInput: TouchInput,
|
30878 | MouseInput: MouseInput,
|
30879 | PointerEventInput: PointerEventInput,
|
30880 | TouchMouseInput: TouchMouseInput,
|
30881 | SingleTouchInput: SingleTouchInput,
|
30882 | Recognizer: Recognizer,
|
30883 | AttrRecognizer: AttrRecognizer,
|
30884 | Tap: TapRecognizer,
|
30885 | Pan: PanRecognizer,
|
30886 | Swipe: SwipeRecognizer,
|
30887 | Pinch: PinchRecognizer,
|
30888 | Rotate: RotateRecognizer,
|
30889 | Press: PressRecognizer,
|
30890 | on: addEventListeners,
|
30891 | off: removeEventListeners,
|
30892 | each: each,
|
30893 | merge: merge,
|
30894 | extend: extend,
|
30895 | assign: assign,
|
30896 | inherit: inherit,
|
30897 | bindFn: bindFn,
|
30898 | prefixed: prefixed
|
30899 | });
|
30900 |
|
30901 |
|
30902 | var freeGlobal = typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {};
|
30903 |
|
30904 | freeGlobal.Hammer = Hammer;
|
30905 |
|
30906 | if (typeof undefined$1 === 'function' && undefined$1.amd) {
|
30907 | undefined$1(function () {
|
30908 | return Hammer;
|
30909 | });
|
30910 | } else if ( module.exports) {
|
30911 | module.exports = Hammer;
|
30912 | } else {
|
30913 | window[exportName] = Hammer;
|
30914 | }
|
30915 | })(window, document, 'Hammer');
|
30916 | });
|
30917 |
|
30918 | var hammer$1 = createCommonjsModule$1(function (module) {
|
30919 | |
30920 |
|
30921 |
|
30922 |
|
30923 |
|
30924 |
|
30925 |
|
30926 | function hammerMock() {
|
30927 | var noop = function noop() {};
|
30928 |
|
30929 | return {
|
30930 | on: noop,
|
30931 | off: noop,
|
30932 | destroy: noop,
|
30933 | emit: noop,
|
30934 | get: function get(m) {
|
30935 |
|
30936 | return {
|
30937 | set: noop
|
30938 | };
|
30939 | }
|
30940 | };
|
30941 | }
|
30942 |
|
30943 | if (typeof window !== 'undefined') {
|
30944 | var propagating$1 = propagating;
|
30945 | var Hammer = window['Hammer'] || hammer;
|
30946 | module.exports = propagating$1(Hammer, {
|
30947 | preventDefault: 'mouse'
|
30948 | });
|
30949 | } else {
|
30950 | module.exports = function () {
|
30951 |
|
30952 | return hammerMock();
|
30953 | };
|
30954 | }
|
30955 | });
|
30956 |
|
30957 | var keycharm = createCommonjsModule$1(function (module, exports) {
|
30958 | |
30959 |
|
30960 |
|
30961 |
|
30962 |
|
30963 |
|
30964 | (function (root, factory) {
|
30965 | {
|
30966 |
|
30967 |
|
30968 |
|
30969 | module.exports = factory();
|
30970 | }
|
30971 | })(commonjsGlobal$1, function () {
|
30972 | function keycharm(options) {
|
30973 | var preventDefault = options && options.preventDefault || false;
|
30974 | var container = options && options.container || window;
|
30975 | var _exportFunctions = {};
|
30976 | var _bound = {
|
30977 | keydown: {},
|
30978 | keyup: {}
|
30979 | };
|
30980 | var _keys = {};
|
30981 | var i;
|
30982 |
|
30983 | for (i = 97; i <= 122; i++) {
|
30984 | _keys[String.fromCharCode(i)] = {
|
30985 | code: 65 + (i - 97),
|
30986 | shift: false
|
30987 | };
|
30988 | }
|
30989 |
|
30990 |
|
30991 | for (i = 65; i <= 90; i++) {
|
30992 | _keys[String.fromCharCode(i)] = {
|
30993 | code: i,
|
30994 | shift: true
|
30995 | };
|
30996 | }
|
30997 |
|
30998 |
|
30999 | for (i = 0; i <= 9; i++) {
|
31000 | _keys['' + i] = {
|
31001 | code: 48 + i,
|
31002 | shift: false
|
31003 | };
|
31004 | }
|
31005 |
|
31006 |
|
31007 | for (i = 1; i <= 12; i++) {
|
31008 | _keys['F' + i] = {
|
31009 | code: 111 + i,
|
31010 | shift: false
|
31011 | };
|
31012 | }
|
31013 |
|
31014 |
|
31015 | for (i = 0; i <= 9; i++) {
|
31016 | _keys['num' + i] = {
|
31017 | code: 96 + i,
|
31018 | shift: false
|
31019 | };
|
31020 | }
|
31021 |
|
31022 |
|
31023 | _keys['num*'] = {
|
31024 | code: 106,
|
31025 | shift: false
|
31026 | };
|
31027 | _keys['num+'] = {
|
31028 | code: 107,
|
31029 | shift: false
|
31030 | };
|
31031 | _keys['num-'] = {
|
31032 | code: 109,
|
31033 | shift: false
|
31034 | };
|
31035 | _keys['num/'] = {
|
31036 | code: 111,
|
31037 | shift: false
|
31038 | };
|
31039 | _keys['num.'] = {
|
31040 | code: 110,
|
31041 | shift: false
|
31042 | };
|
31043 |
|
31044 | _keys['left'] = {
|
31045 | code: 37,
|
31046 | shift: false
|
31047 | };
|
31048 | _keys['up'] = {
|
31049 | code: 38,
|
31050 | shift: false
|
31051 | };
|
31052 | _keys['right'] = {
|
31053 | code: 39,
|
31054 | shift: false
|
31055 | };
|
31056 | _keys['down'] = {
|
31057 | code: 40,
|
31058 | shift: false
|
31059 | };
|
31060 |
|
31061 | _keys['space'] = {
|
31062 | code: 32,
|
31063 | shift: false
|
31064 | };
|
31065 | _keys['enter'] = {
|
31066 | code: 13,
|
31067 | shift: false
|
31068 | };
|
31069 | _keys['shift'] = {
|
31070 | code: 16,
|
31071 | shift: undefined
|
31072 | };
|
31073 | _keys['esc'] = {
|
31074 | code: 27,
|
31075 | shift: false
|
31076 | };
|
31077 | _keys['backspace'] = {
|
31078 | code: 8,
|
31079 | shift: false
|
31080 | };
|
31081 | _keys['tab'] = {
|
31082 | code: 9,
|
31083 | shift: false
|
31084 | };
|
31085 | _keys['ctrl'] = {
|
31086 | code: 17,
|
31087 | shift: false
|
31088 | };
|
31089 | _keys['alt'] = {
|
31090 | code: 18,
|
31091 | shift: false
|
31092 | };
|
31093 | _keys['delete'] = {
|
31094 | code: 46,
|
31095 | shift: false
|
31096 | };
|
31097 | _keys['pageup'] = {
|
31098 | code: 33,
|
31099 | shift: false
|
31100 | };
|
31101 | _keys['pagedown'] = {
|
31102 | code: 34,
|
31103 | shift: false
|
31104 | };
|
31105 |
|
31106 | _keys['='] = {
|
31107 | code: 187,
|
31108 | shift: false
|
31109 | };
|
31110 | _keys['-'] = {
|
31111 | code: 189,
|
31112 | shift: false
|
31113 | };
|
31114 | _keys[']'] = {
|
31115 | code: 221,
|
31116 | shift: false
|
31117 | };
|
31118 | _keys['['] = {
|
31119 | code: 219,
|
31120 | shift: false
|
31121 | };
|
31122 |
|
31123 | var down = function (event) {
|
31124 | handleEvent(event, 'keydown');
|
31125 | };
|
31126 |
|
31127 | var up = function (event) {
|
31128 | handleEvent(event, 'keyup');
|
31129 | };
|
31130 |
|
31131 |
|
31132 | var handleEvent = function (event, type) {
|
31133 | if (_bound[type][event.keyCode] !== undefined) {
|
31134 | var bound = _bound[type][event.keyCode];
|
31135 |
|
31136 | for (var i = 0; i < bound.length; i++) {
|
31137 | if (bound[i].shift === undefined) {
|
31138 | bound[i].fn(event);
|
31139 | } else if (bound[i].shift == true && event.shiftKey == true) {
|
31140 | bound[i].fn(event);
|
31141 | } else if (bound[i].shift == false && event.shiftKey == false) {
|
31142 | bound[i].fn(event);
|
31143 | }
|
31144 | }
|
31145 |
|
31146 | if (preventDefault == true) {
|
31147 | event.preventDefault();
|
31148 | }
|
31149 | }
|
31150 | };
|
31151 |
|
31152 |
|
31153 | _exportFunctions.bind = function (key, callback, type) {
|
31154 | if (type === undefined) {
|
31155 | type = 'keydown';
|
31156 | }
|
31157 |
|
31158 | if (_keys[key] === undefined) {
|
31159 | throw new Error("unsupported key: " + key);
|
31160 | }
|
31161 |
|
31162 | if (_bound[type][_keys[key].code] === undefined) {
|
31163 | _bound[type][_keys[key].code] = [];
|
31164 | }
|
31165 |
|
31166 | _bound[type][_keys[key].code].push({
|
31167 | fn: callback,
|
31168 | shift: _keys[key].shift
|
31169 | });
|
31170 | };
|
31171 |
|
31172 |
|
31173 | _exportFunctions.bindAll = function (callback, type) {
|
31174 | if (type === undefined) {
|
31175 | type = 'keydown';
|
31176 | }
|
31177 |
|
31178 | for (var key in _keys) {
|
31179 | if (_keys.hasOwnProperty(key)) {
|
31180 | _exportFunctions.bind(key, callback, type);
|
31181 | }
|
31182 | }
|
31183 | };
|
31184 |
|
31185 |
|
31186 | _exportFunctions.getKey = function (event) {
|
31187 | for (var key in _keys) {
|
31188 | if (_keys.hasOwnProperty(key)) {
|
31189 | if (event.shiftKey == true && _keys[key].shift == true && event.keyCode == _keys[key].code) {
|
31190 | return key;
|
31191 | } else if (event.shiftKey == false && _keys[key].shift == false && event.keyCode == _keys[key].code) {
|
31192 | return key;
|
31193 | } else if (event.keyCode == _keys[key].code && key == 'shift') {
|
31194 | return key;
|
31195 | }
|
31196 | }
|
31197 | }
|
31198 |
|
31199 | return "unknown key, currently not supported";
|
31200 | };
|
31201 |
|
31202 |
|
31203 | _exportFunctions.unbind = function (key, callback, type) {
|
31204 | if (type === undefined) {
|
31205 | type = 'keydown';
|
31206 | }
|
31207 |
|
31208 | if (_keys[key] === undefined) {
|
31209 | throw new Error("unsupported key: " + key);
|
31210 | }
|
31211 |
|
31212 | if (callback !== undefined) {
|
31213 | var newBindings = [];
|
31214 | var bound = _bound[type][_keys[key].code];
|
31215 |
|
31216 | if (bound !== undefined) {
|
31217 | for (var i = 0; i < bound.length; i++) {
|
31218 | if (!(bound[i].fn == callback && bound[i].shift == _keys[key].shift)) {
|
31219 | newBindings.push(_bound[type][_keys[key].code][i]);
|
31220 | }
|
31221 | }
|
31222 | }
|
31223 |
|
31224 | _bound[type][_keys[key].code] = newBindings;
|
31225 | } else {
|
31226 | _bound[type][_keys[key].code] = [];
|
31227 | }
|
31228 | };
|
31229 |
|
31230 |
|
31231 | _exportFunctions.reset = function () {
|
31232 | _bound = {
|
31233 | keydown: {},
|
31234 | keyup: {}
|
31235 | };
|
31236 | };
|
31237 |
|
31238 |
|
31239 | _exportFunctions.destroy = function () {
|
31240 | _bound = {
|
31241 | keydown: {},
|
31242 | keyup: {}
|
31243 | };
|
31244 | container.removeEventListener('keydown', down, true);
|
31245 | container.removeEventListener('keyup', up, true);
|
31246 | };
|
31247 |
|
31248 |
|
31249 | container.addEventListener('keydown', down, true);
|
31250 | container.addEventListener('keyup', up, true);
|
31251 |
|
31252 | return _exportFunctions;
|
31253 | }
|
31254 |
|
31255 | return keycharm;
|
31256 | });
|
31257 | });
|
31258 |
|
31259 | var util_1 = util;
|
31260 | var DOMutil$1 = DOMutil;
|
31261 |
|
31262 | var DataSet$2 = index.DataSet,
|
31263 | DataView$3 = index.DataView,
|
31264 | Queue$1 = index.Queue;
|
31265 | var DataSet_1 = DataSet$2;
|
31266 | var DataView_1 = DataView$3;
|
31267 | var Queue_1 = Queue$1;
|
31268 |
|
31269 | var Graph3d$1 = Graph3d_1;
|
31270 | var graph3d = {
|
31271 | Camera: Camera_1,
|
31272 | Filter: Filter_1,
|
31273 | Point2d: Point2d_1,
|
31274 | Point3d: Point3d_1,
|
31275 | Slider: Slider_1,
|
31276 | StepNumber: StepNumber_1
|
31277 | };
|
31278 |
|
31279 | var moment$4 = moment$3;
|
31280 | var Hammer = hammer$1;
|
31281 | var keycharm$1 = keycharm;
|
31282 | var repo = {
|
31283 | util: util_1,
|
31284 | DOMutil: DOMutil$1,
|
31285 | DataSet: DataSet_1,
|
31286 | DataView: DataView_1,
|
31287 | Queue: Queue_1,
|
31288 | Graph3d: Graph3d$1,
|
31289 | graph3d: graph3d,
|
31290 | moment: moment$4,
|
31291 | Hammer: Hammer,
|
31292 | keycharm: keycharm$1
|
31293 | };
|
31294 |
|
31295 | export default repo;
|
31296 | export { DOMutil$1 as DOMutil, DataSet_1 as DataSet, DataView_1 as DataView, Graph3d$1 as Graph3d, Hammer, Queue_1 as Queue, graph3d, keycharm$1 as keycharm, moment$4 as moment, util_1 as util };
|