1(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["common"],{ 2
vendor: 14,062 bytes, lines 3-463
3/***/ "./node_modules/a11y-dialog/a11y-dialog.js": 4/*!*************************************************!*\ 5 !*** ./node_modules/a11y-dialog/a11y-dialog.js ***! 6 \*************************************************/ 7/*! no static exports found */ 8/***/ (function(module, exports, __webpack_require__) { 9 10/* WEBPACK VAR INJECTION */(function(global) {var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* global NodeList, Element, Event, define */ 11 12(function(global) { 13 'use strict'; 14 15 var FOCUSABLE_ELEMENTS = [ 16 'a[href]:not([tabindex^="-"]):not([inert])', 17 'area[href]:not([tabindex^="-"]):not([inert])', 18 'input:not([disabled]):not([inert])', 19 'select:not([disabled]):not([inert])', 20 'textarea:not([disabled]):not([inert])', 21 'button:not([disabled]):not([inert])', 22 'iframe:not([tabindex^="-"]):not([inert])', 23 'audio:not([tabindex^="-"]):not([inert])', 24 'video:not([tabindex^="-"]):not([inert])', 25 '[contenteditable]:not([tabindex^="-"]):not([inert])', 26 '[tabindex]:not([tabindex^="-"]):not([inert])' 27 ]; 28 var TAB_KEY = 9; 29 var ESCAPE_KEY = 27; 30 var focusedBeforeDialog; 31 32 /** 33 * Define the constructor to instantiate a dialog 34 * 35 * @constructor 36 * @param {Element} node 37 * @param {(NodeList | Element | string)} targets 38 */ 39 function A11yDialog(node, targets) { 40 // Prebind the functions that will be bound in addEventListener and 41 // removeEventListener to avoid losing references 42 this._show = this.show.bind(this); 43 this._hide = this.hide.bind(this); 44 this._maintainFocus = this._maintainFocus.bind(this); 45 this._bindKeypress = this._bindKeypress.bind(this); 46 47 // Keep a reference of the node and the actual dialog on the instance 48 this.container = node; 49 this.dialog = node.querySelector('dialog, [role="dialog"]'); 50 this.useDialog = ( 51 'show' in document.createElement('dialog') && 52 this.dialog.nodeName === 'DIALOG' 53 ); 54 55 // Keep an object of listener types mapped to callback functions 56 this._listeners = {}; 57 58 // Initialise everything needed for the dialog to work properly 59 this.create(targets); 60 } 61 62 /** 63 * Set up everything necessary for the dialog to be functioning 64 * 65 * @param {(NodeList | Element | string)} targets 66 * @return {this} 67 */ 68 A11yDialog.prototype.create = function(targets) { 69 // Keep a collection of nodes to disable/enable when toggling the dialog 70 this._targets = 71 this._targets || collect(targets) || getSiblings(this.container); 72 73 // Set the `shown` property to match the status from the DOM 74 this.shown = this.dialog.hasAttribute('open'); 75 76 // Despite using a `<dialog>` element, `role="dialog"` is not necessarily 77 // implied by all screen-readers (yet) 78 // See: https://github.com/edenspiekermann/a11y-dialog/commit/6ba711a777aed0dbda0719a18a02f742098c64d9#commitcomment-28694166 79 this.dialog.setAttribute('role', 'dialog'); 80 81 if (!this.useDialog) { 82 if (this.shown) { 83 this.container.removeAttribute('aria-hidden'); 84 } else { 85 this.container.setAttribute('aria-hidden', true); 86 } 87 } else { 88 this.container.setAttribute('data-a11y-dialog-native', ''); 89 } 90 91 // Keep a collection of dialog openers, each of which will be bound a click 92 // event listener to open the dialog 93 this._openers = $$('[data-a11y-dialog-show="' + this.container.id + '"]'); 94 this._openers.forEach( 95 function(opener) { 96 opener.addEventListener('click', this._show); 97 }.bind(this) 98 ); 99 100 // Keep a collection of dialog closers, each of which will be bound a click 101 // event listener to close the dialog 102 this._closers = $$('[data-a11y-dialog-hide]', this.container).concat( 103 $$('[data-a11y-dialog-hide="' + this.container.id + '"]') 104 ); 105 this._closers.forEach( 106 function(closer) { 107 closer.addEventListener('click', this._hide); 108 }.bind(this) 109 ); 110 111 // Execute all callbacks registered for the `create` event 112 this._fire('create'); 113 114 return this; 115 }; 116 117 /** 118 * Show the dialog element, disable all the targets (siblings), trap the 119 * current focus within it, listen for some specific key presses and fire all 120 * registered callbacks for `show` event 121 * 122 * @param {Event} event 123 * @return {this} 124 */ 125 A11yDialog.prototype.show = function(event) { 126 // If the dialog is already open, abort 127 if (this.shown) { 128 return this; 129 } 130 131 this.shown = true; 132 133 // Keep a reference to the currently focused element to be able to restore 134 // it later 135 focusedBeforeDialog = document.activeElement; 136 137 if (this.useDialog) { 138 this.dialog.showModal(event instanceof Event ? void 0 : event); 139 } else { 140 this.dialog.setAttribute('open', ''); 141 this.container.removeAttribute('aria-hidden'); 142 143 // Iterate over the targets to disable them by setting their `aria-hidden` 144 // attribute to `true` 145 this._targets.forEach(function(target) { 146 target.setAttribute('aria-hidden', 'true'); 147 }); 148 } 149 150 // Set the focus to the first focusable child of the dialog element 151 setFocusToFirstItem(this.dialog); 152 153 // Bind a focus event listener to the body element to make sure the focus 154 // stays trapped inside the dialog while open, and start listening for some 155 // specific key presses (TAB and ESC) 156 document.body.addEventListener('focus', this._maintainFocus, true); 157 document.addEventListener('keydown', this._bindKeypress); 158 159 // Execute all callbacks registered for the `show` event 160 this._fire('show', event); 161 162 return this; 163 }; 164 165 /** 166 * Hide the dialog element, enable all the targets (siblings), restore the 167 * focus to the previously active element, stop listening for some specific 168 * key presses and fire all registered callbacks for `hide` event 169 * 170 * @param {Event} event 171 * @return {this} 172 */ 173 A11yDialog.prototype.hide = function(event) { 174 // If the dialog is already closed, abort 175 if (!this.shown) { 176 return this; 177 } 178 179 this.shown = false; 180 181 if (this.useDialog) { 182 this.dialog.close(event instanceof Event ? void 0 : event); 183 } else { 184 this.dialog.removeAttribute('open'); 185 this.container.setAttribute('aria-hidden', 'true'); 186 187 // Iterate over the targets to enable them by remove their `aria-hidden` 188 // attribute 189 this._targets.forEach(function(target) { 190 target.removeAttribute('aria-hidden'); 191 }); 192 } 193 194 // If their was a focused element before the dialog was opened, restore the 195 // focus back to it 196 if (focusedBeforeDialog) { 197 focusedBeforeDialog.focus(); 198 } 199 200 // Remove the focus event listener to the body element and stop listening 201 // for specific key presses 202 document.body.removeEventListener('focus', this._maintainFocus, true); 203 document.removeEventListener('keydown', this._bindKeypress); 204 205 // Execute all callbacks registered for the `hide` event 206 this._fire('hide', event); 207 208 return this; 209 }; 210 211 /** 212 * Destroy the current instance (after making sure the dialog has been hidden) 213 * and remove all associated listeners from dialog openers and closers 214 * 215 * @return {this} 216 */ 217 A11yDialog.prototype.destroy = function() { 218 // Hide the dialog to avoid destroying an open instance 219 this.hide(); 220 221 // Remove the click event listener from all dialog openers 222 this._openers.forEach( 223 function(opener) { 224 opener.removeEventListener('click', this._show); 225 }.bind(this) 226 ); 227 228 // Remove the click event listener from all dialog closers 229 this._closers.forEach( 230 function(closer) { 231 closer.removeEventListener('click', this._hide); 232 }.bind(this) 233 ); 234 235 // Execute all callbacks registered for the `destroy` event 236 this._fire('destroy'); 237 238 // Keep an object of listener types mapped to callback functions 239 this._listeners = {}; 240 241 return this; 242 }; 243 244 /** 245 * Register a new callback for the given event type 246 * 247 * @param {string} type 248 * @param {Function} handler 249 */ 250 A11yDialog.prototype.on = function(type, handler) { 251 if (typeof this._listeners[type] === 'undefined') { 252 this._listeners[type] = []; 253 } 254 255 this._listeners[type].push(handler); 256 257 return this; 258 }; 259 260 /** 261 * Unregister an existing callback for the given event type 262 * 263 * @param {string} type 264 * @param {Function} handler 265 */ 266 A11yDialog.prototype.off = function(type, handler) { 267 var index = this._listeners[type].indexOf(handler); 268 269 if (index > -1) { 270 this._listeners[type].splice(index, 1); 271 } 272 273 return this; 274 }; 275 276 /** 277 * Iterate over all registered handlers for given type and call them all with 278 * the dialog element as first argument, event as second argument (if any). 279 * 280 * @access private 281 * @param {string} type 282 * @param {Event} event 283 */ 284 A11yDialog.prototype._fire = function(type, event) { 285 var listeners = this._listeners[type] || []; 286 287 listeners.forEach( 288 function(listener) { 289 listener(this.container, event); 290 }.bind(this) 291 ); 292 }; 293 294 /** 295 * Private event handler used when listening to some specific key presses 296 * (namely ESCAPE and TAB) 297 * 298 * @access private 299 * @param {Event} event 300 */ 301 A11yDialog.prototype._bindKeypress = function(event) { 302 // If the dialog is shown and the ESCAPE key is being pressed, prevent any 303 // further effects from the ESCAPE key and hide the dialog 304 if (this.shown && event.which === ESCAPE_KEY) { 305 event.preventDefault(); 306 this.hide(); 307 } 308 309 // If the dialog is shown and the TAB key is being pressed, make sure the 310 // focus stays trapped within the dialog element 311 if (this.shown && event.which === TAB_KEY) { 312 trapTabKey(this.dialog, event); 313 } 314 }; 315 316 /** 317 * Private event handler used when making sure the focus stays within the 318 * currently open dialog 319 * 320 * @access private 321 * @param {Event} event 322 */ 323 A11yDialog.prototype._maintainFocus = function(event) { 324 // If the dialog is shown and the focus is not within the dialog element, 325 // move it back to its first focusable child 326 if (this.shown && !this.container.contains(event.target)) { 327 setFocusToFirstItem(this.dialog); 328 } 329 }; 330 331 /** 332 * Convert a NodeList into an array 333 * 334 * @param {NodeList} collection 335 * @return {Array<Element>} 336 */ 337 function toArray(collection) { 338 return Array.prototype.slice.call(collection); 339 } 340 341 /** 342 * Query the DOM for nodes matching the given selector, scoped to context (or 343 * the whole document) 344 * 345 * @param {String} selector 346 * @param {Element} [context = document] 347 * @return {Array<Element>} 348 */ 349 function $$(selector, context) { 350 return toArray((context || document).querySelectorAll(selector)); 351 } 352 353 /** 354 * Return an array of Element based on given argument (NodeList, Element or 355 * string representing a selector) 356 * 357 * @param {(NodeList | Element | string)} target 358 * @return {Array<Element>} 359 */ 360 function collect(target) { 361 if (NodeList.prototype.isPrototypeOf(target)) { 362 return toArray(target); 363 } 364 365 if (Element.prototype.isPrototypeOf(target)) { 366 return [target]; 367 } 368 369 if (typeof target === 'string') { 370 return $$(target); 371 } 372 } 373 374 /** 375 * Set the focus to the first element with `autofocus` or the first focusable 376 * child of the given element 377 * 378 * @param {Element} node 379 */ 380 function setFocusToFirstItem(node) { 381 var focusableChildren = getFocusableChildren(node); 382 var focused = node.querySelector('[autofocus]') || focusableChildren[0]; 383 384 if (focused) { 385 focused.focus(); 386 } 387 } 388 389 /** 390 * Get the focusable children of the given element 391 * 392 * @param {Element} node 393 * @return {Array<Element>} 394 */ 395 function getFocusableChildren(node) { 396 return $$(FOCUSABLE_ELEMENTS.join(','), node).filter(function(child) { 397 return !!( 398 child.offsetWidth || 399 child.offsetHeight || 400 child.getClientRects().length 401 ); 402 }); 403 } 404 405 /** 406 * Trap the focus inside the given element 407 * 408 * @param {Element} node 409 * @param {Event} event 410 */ 411 function trapTabKey(node, event) { 412 var focusableChildren = getFocusableChildren(node); 413 var focusedItemIndex = focusableChildren.indexOf(document.activeElement); 414 415 // If the SHIFT key is being pressed while tabbing (moving backwards) and 416 // the currently focused item is the first one, move the focus to the last 417 // focusable item from the dialog element 418 if (event.shiftKey && focusedItemIndex === 0) { 419 focusableChildren[focusableChildren.length - 1].focus(); 420 event.preventDefault(); 421 // If the SHIFT key is not being pressed (moving forwards) and the currently 422 // focused item is the last one, move the focus to the first focusable item 423 // from the dialog element 424 } else if ( 425 !event.shiftKey && 426 focusedItemIndex === focusableChildren.length - 1 427 ) { 428 focusableChildren[0].focus(); 429 event.preventDefault(); 430 } 431 } 432 433 /** 434 * Retrieve siblings from given element 435 * 436 * @param {Element} node 437 * @return {Array<Element>} 438 */ 439 function getSiblings(node) { 440 var nodes = toArray(node.parentNode.childNodes); 441 var siblings = nodes.filter(function(node) { 442 return node.nodeType === 1; 443 }); 444 445 siblings.splice(siblings.indexOf(node), 1); 446 447 return siblings; 448 } 449 450 if ( true && typeof module.exports !== 'undefined') { 451 module.exports = A11yDialog; 452 } else if (true) { 453 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() { 454 return A11yDialog; 455 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), 456 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 457 } else {} 458})(typeof global !== 'undefined' ? global : window); 459 460/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))) 461 462/***/ }), 463
vendor: 361 bytes, lines 464-474
464/***/ "./node_modules/axios/index.js": 465/*!*************************************!*\ 466 !*** ./node_modules/axios/index.js ***! 467 \*************************************/ 468/*! no static exports found */ 469/***/ (function(module, exports, __webpack_require__) { 470 471module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js"); 472 473/***/ }), 474
vendor: 8,070 bytes, lines 475-699
475/***/ "./node_modules/axios/lib/adapters/xhr.js": 476/*!************************************************!*\ 477 !*** ./node_modules/axios/lib/adapters/xhr.js ***! 478 \************************************************/ 479/*! no static exports found */ 480/***/ (function(module, exports, __webpack_require__) { 481 482"use strict"; 483/* WEBPACK VAR INJECTION */(function(Promise) { 484 485var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 486var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js"); 487var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js"); 488var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js"); 489var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js"); 490var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js"); 491var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js"); 492var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js"); 493var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js"); 494var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 495 496module.exports = function xhrAdapter(config) { 497 return new Promise(function dispatchXhrRequest(resolve, reject) { 498 var requestData = config.data; 499 var requestHeaders = config.headers; 500 var responseType = config.responseType; 501 var onCanceled; 502 function done() { 503 if (config.cancelToken) { 504 config.cancelToken.unsubscribe(onCanceled); 505 } 506 507 if (config.signal) { 508 config.signal.removeEventListener('abort', onCanceled); 509 } 510 } 511 512 if (utils.isFormData(requestData)) { 513 delete requestHeaders['Content-Type']; // Let the browser set it 514 } 515 516 var request = new XMLHttpRequest(); 517 518 // HTTP basic authentication 519 if (config.auth) { 520 var username = config.auth.username || ''; 521 var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; 522 requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); 523 } 524 525 var fullPath = buildFullPath(config.baseURL, config.url); 526 request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); 527 528 // Set the request timeout in MS 529 request.timeout = config.timeout; 530 531 function onloadend() { 532 if (!request) { 533 return; 534 } 535 // Prepare the response 536 var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; 537 var responseData = !responseType || responseType === 'text' || responseType === 'json' ? 538 request.responseText : request.response; 539 var response = { 540 data: responseData, 541 status: request.status, 542 statusText: request.statusText, 543 headers: responseHeaders, 544 config: config, 545 request: request 546 }; 547 548 settle(function _resolve(value) { 549 resolve(value); 550 done(); 551 }, function _reject(err) { 552 reject(err); 553 done(); 554 }, response); 555 556 // Clean up request 557 request = null; 558 } 559 560 if ('onloadend' in request) { 561 // Use onloadend if available 562 request.onloadend = onloadend; 563 } else { 564 // Listen for ready state to emulate onloadend 565 request.onreadystatechange = function handleLoad() { 566 if (!request || request.readyState !== 4) { 567 return; 568 } 569 570 // The request errored out and we didn't get a response, this will be 571 // handled by onerror instead 572 // With one exception: request that using file: protocol, most browsers 573 // will return status as 0 even though it's a successful request 574 if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { 575 return; 576 } 577 // readystate handler is calling before onerror or ontimeout handlers, 578 // so we should call onloadend on the next 'tick' 579 setTimeout(onloadend); 580 }; 581 } 582 583 // Handle browser request cancellation (as opposed to a manual cancellation) 584 request.onabort = function handleAbort() { 585 if (!request) { 586 return; 587 } 588 589 reject(createError('Request aborted', config, 'ECONNABORTED', request)); 590 591 // Clean up request 592 request = null; 593 }; 594 595 // Handle low level network errors 596 request.onerror = function handleError() { 597 // Real errors are hidden from us by the browser 598 // onerror should only fire if it's a network error 599 reject(createError('Network Error', config, null, request)); 600 601 // Clean up request 602 request = null; 603 }; 604 605 // Handle timeout 606 request.ontimeout = function handleTimeout() { 607 var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; 608 var transitional = config.transitional || defaults.transitional; 609 if (config.timeoutErrorMessage) { 610 timeoutErrorMessage = config.timeoutErrorMessage; 611 } 612 reject(createError( 613 timeoutErrorMessage, 614 config, 615 transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED', 616 request)); 617 618 // Clean up request 619 request = null; 620 }; 621 622 // Add xsrf header 623 // This is only done if running in a standard browser environment. 624 // Specifically not if we're in a web worker, or react-native. 625 if (utils.isStandardBrowserEnv()) { 626 // Add xsrf header 627 var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? 628 cookies.read(config.xsrfCookieName) : 629 undefined; 630 631 if (xsrfValue) { 632 requestHeaders[config.xsrfHeaderName] = xsrfValue; 633 } 634 } 635 636 // Add headers to the request 637 if ('setRequestHeader' in request) { 638 utils.forEach(requestHeaders, function setRequestHeader(val, key) { 639 if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { 640 // Remove Content-Type if data is undefined 641 delete requestHeaders[key]; 642 } else { 643 // Otherwise add header to the request 644 request.setRequestHeader(key, val); 645 } 646 }); 647 } 648 649 // Add withCredentials to request if needed 650 if (!utils.isUndefined(config.withCredentials)) { 651 request.withCredentials = !!config.withCredentials; 652 } 653 654 // Add responseType to request if needed 655 if (responseType && responseType !== 'json') { 656 request.responseType = config.responseType; 657 } 658 659 // Handle progress if needed 660 if (typeof config.onDownloadProgress === 'function') { 661 request.addEventListener('progress', config.onDownloadProgress); 662 } 663 664 // Not all browsers support upload events 665 if (typeof config.onUploadProgress === 'function' && request.upload) { 666 request.upload.addEventListener('progress', config.onUploadProgress); 667 } 668 669 if (config.cancelToken || config.signal) { 670 // Handle cancellation 671 // eslint-disable-next-line func-names 672 onCanceled = function(cancel) { 673 if (!request) { 674 return; 675 } 676 reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel); 677 request.abort(); 678 request = null; 679 }; 680 681 config.cancelToken && config.cancelToken.subscribe(onCanceled); 682 if (config.signal) { 683 config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled); 684 } 685 } 686 687 if (!requestData) { 688 requestData = null; 689 } 690 691 // Send the request 692 request.send(requestData); 693 }); 694}; 695 696/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! es6-promise */ "./node_modules/es6-promise/dist/es6-promise.js"))) 697 698/***/ }), 699
vendor: 2,690 bytes, lines 700-769
700/***/ "./node_modules/axios/lib/axios.js": 701/*!*****************************************!*\ 702 !*** ./node_modules/axios/lib/axios.js ***! 703 \*****************************************/ 704/*! no static exports found */ 705/***/ (function(module, exports, __webpack_require__) { 706 707"use strict"; 708/* WEBPACK VAR INJECTION */(function(Promise) { 709 710var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js"); 711var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js"); 712var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js"); 713var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js"); 714var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js"); 715 716/** 717 * Create an instance of Axios 718 * 719 * @param {Object} defaultConfig The default config for the instance 720 * @return {Axios} A new instance of Axios 721 */ 722function createInstance(defaultConfig) { 723 var context = new Axios(defaultConfig); 724 var instance = bind(Axios.prototype.request, context); 725 726 // Copy axios.prototype to instance 727 utils.extend(instance, Axios.prototype, context); 728 729 // Copy context to instance 730 utils.extend(instance, context); 731 732 // Factory for creating new instances 733 instance.create = function create(instanceConfig) { 734 return createInstance(mergeConfig(defaultConfig, instanceConfig)); 735 }; 736 737 return instance; 738} 739 740// Create the default instance to be exported 741var axios = createInstance(defaults); 742 743// Expose Axios class to allow class inheritance 744axios.Axios = Axios; 745 746// Expose Cancel & CancelToken 747axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 748axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js"); 749axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js"); 750axios.VERSION = __webpack_require__(/*! ./env/data */ "./node_modules/axios/lib/env/data.js").version; 751 752// Expose all/spread 753axios.all = function all(promises) { 754 return Promise.all(promises); 755}; 756axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js"); 757 758// Expose isAxiosError 759axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./node_modules/axios/lib/helpers/isAxiosError.js"); 760 761module.exports = axios; 762 763// Allow use of default import syntax in TypeScript 764module.exports.default = axios; 765 766/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! es6-promise */ "./node_modules/es6-promise/dist/es6-promise.js"))) 767 768/***/ }), 769
vendor: 702 bytes, lines 770-800
770/***/ "./node_modules/axios/lib/cancel/Cancel.js": 771/*!*************************************************!*\ 772 !*** ./node_modules/axios/lib/cancel/Cancel.js ***! 773 \*************************************************/ 774/*! no static exports found */ 775/***/ (function(module, exports, __webpack_require__) { 776 777"use strict"; 778 779 780/** 781 * A `Cancel` is an object that is thrown when an operation is canceled. 782 * 783 * @class 784 * @param {string=} message The message. 785 */ 786function Cancel(message) { 787 this.message = message; 788} 789 790Cancel.prototype.toString = function toString() { 791 return 'Cancel' + (this.message ? ': ' + this.message : ''); 792}; 793 794Cancel.prototype.__CANCEL__ = true; 795 796module.exports = Cancel; 797 798 799/***/ }), 800
vendor: 3,045 bytes, lines 801-932
801/***/ "./node_modules/axios/lib/cancel/CancelToken.js": 802/*!******************************************************!*\ 803 !*** ./node_modules/axios/lib/cancel/CancelToken.js ***! 804 \******************************************************/ 805/*! no static exports found */ 806/***/ (function(module, exports, __webpack_require__) { 807 808"use strict"; 809/* WEBPACK VAR INJECTION */(function(Promise) { 810 811var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 812 813/** 814 * A `CancelToken` is an object that can be used to request cancellation of an operation. 815 * 816 * @class 817 * @param {Function} executor The executor function. 818 */ 819function CancelToken(executor) { 820 if (typeof executor !== 'function') { 821 throw new TypeError('executor must be a function.'); 822 } 823 824 var resolvePromise; 825 826 this.promise = new Promise(function promiseExecutor(resolve) { 827 resolvePromise = resolve; 828 }); 829 830 var token = this; 831 832 // eslint-disable-next-line func-names 833 this.promise.then(function(cancel) { 834 if (!token._listeners) return; 835 836 var i; 837 var l = token._listeners.length; 838 839 for (i = 0; i < l; i++) { 840 token._listeners[i](cancel); 841 } 842 token._listeners = null; 843 }); 844 845 // eslint-disable-next-line func-names 846 this.promise.then = function(onfulfilled) { 847 var _resolve; 848 // eslint-disable-next-line func-names 849 var promise = new Promise(function(resolve) { 850 token.subscribe(resolve); 851 _resolve = resolve; 852 }).then(onfulfilled); 853 854 promise.cancel = function reject() { 855 token.unsubscribe(_resolve); 856 }; 857 858 return promise; 859 }; 860 861 executor(function cancel(message) { 862 if (token.reason) { 863 // Cancellation has already been requested 864 return; 865 } 866 867 token.reason = new Cancel(message); 868 resolvePromise(token.reason); 869 }); 870} 871 872/** 873 * Throws a `Cancel` if cancellation has been requested. 874 */ 875CancelToken.prototype.throwIfRequested = function throwIfRequested() { 876 if (this.reason) { 877 throw this.reason; 878 } 879}; 880 881/** 882 * Subscribe to the cancel signal 883 */ 884 885CancelToken.prototype.subscribe = function subscribe(listener) { 886 if (this.reason) { 887 listener(this.reason); 888 return; 889 } 890 891 if (this._listeners) { 892 this._listeners.push(listener); 893 } else { 894 this._listeners = [listener]; 895 } 896}; 897 898/** 899 * Unsubscribe from the cancel signal 900 */ 901 902CancelToken.prototype.unsubscribe = function unsubscribe(listener) { 903 if (!this._listeners) { 904 return; 905 } 906 var index = this._listeners.indexOf(listener); 907 if (index !== -1) { 908 this._listeners.splice(index, 1); 909 } 910}; 911 912/** 913 * Returns an object that contains a new `CancelToken` and a function that, when called, 914 * cancels the `CancelToken`. 915 */ 916CancelToken.source = function source() { 917 var cancel; 918 var token = new CancelToken(function executor(c) { 919 cancel = c; 920 }); 921 return { 922 token: token, 923 cancel: cancel 924 }; 925}; 926 927module.exports = CancelToken; 928 929/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! es6-promise */ "./node_modules/es6-promise/dist/es6-promise.js"))) 930 931/***/ }), 932
vendor: 427 bytes, lines 933-949
933/***/ "./node_modules/axios/lib/cancel/isCancel.js": 934/*!***************************************************!*\ 935 !*** ./node_modules/axios/lib/cancel/isCancel.js ***! 936 \***************************************************/ 937/*! no static exports found */ 938/***/ (function(module, exports, __webpack_require__) { 939 940"use strict"; 941 942 943module.exports = function isCancel(value) { 944 return !!(value && value.__CANCEL__); 945}; 946 947 948/***/ }), 949
vendor: 5,270 bytes, lines 950-1117
950/***/ "./node_modules/axios/lib/core/Axios.js": 951/*!**********************************************!*\ 952 !*** ./node_modules/axios/lib/core/Axios.js ***! 953 \**********************************************/ 954/*! no static exports found */ 955/***/ (function(module, exports, __webpack_require__) { 956 957"use strict"; 958/* WEBPACK VAR INJECTION */(function(Promise) { 959 960var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 961var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js"); 962var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js"); 963var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js"); 964var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js"); 965var validator = __webpack_require__(/*! ../helpers/validator */ "./node_modules/axios/lib/helpers/validator.js"); 966 967var validators = validator.validators; 968/** 969 * Create a new instance of Axios 970 * 971 * @param {Object} instanceConfig The default config for the instance 972 */ 973function Axios(instanceConfig) { 974 this.defaults = instanceConfig; 975 this.interceptors = { 976 request: new InterceptorManager(), 977 response: new InterceptorManager() 978 }; 979} 980 981/** 982 * Dispatch a request 983 * 984 * @param {Object} config The config specific for this request (merged with this.defaults) 985 */ 986Axios.prototype.request = function request(configOrUrl, config) { 987 /*eslint no-param-reassign:0*/ 988 // Allow for axios('example/url'[, config]) a la fetch API 989 if (typeof configOrUrl === 'string') { 990 config = config || {}; 991 config.url = configOrUrl; 992 } else { 993 config = configOrUrl || {}; 994 } 995 996 if (!config.url) { 997 throw new Error('Provided config url is not valid'); 998 } 999 1000 config = mergeConfig(this.defaults, config); 1001 1002 // Set config.method 1003 if (config.method) { 1004 config.method = config.method.toLowerCase(); 1005 } else if (this.defaults.method) { 1006 config.method = this.defaults.method.toLowerCase(); 1007 } else { 1008 config.method = 'get'; 1009 } 1010 1011 var transitional = config.transitional; 1012 1013 if (transitional !== undefined) { 1014 validator.assertOptions(transitional, { 1015 silentJSONParsing: validators.transitional(validators.boolean), 1016 forcedJSONParsing: validators.transitional(validators.boolean), 1017 clarifyTimeoutError: validators.transitional(validators.boolean) 1018 }, false); 1019 } 1020 1021 // filter out skipped interceptors 1022 var requestInterceptorChain = []; 1023 var synchronousRequestInterceptors = true; 1024 this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { 1025 if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) { 1026 return; 1027 } 1028 1029 synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; 1030 1031 requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); 1032 }); 1033 1034 var responseInterceptorChain = []; 1035 this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { 1036 responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); 1037 }); 1038 1039 var promise; 1040 1041 if (!synchronousRequestInterceptors) { 1042 var chain = [dispatchRequest, undefined]; 1043 1044 Array.prototype.unshift.apply(chain, requestInterceptorChain); 1045 chain = chain.concat(responseInterceptorChain); 1046 1047 promise = Promise.resolve(config); 1048 while (chain.length) { 1049 promise = promise.then(chain.shift(), chain.shift()); 1050 } 1051 1052 return promise; 1053 } 1054 1055 1056 var newConfig = config; 1057 while (requestInterceptorChain.length) { 1058 var onFulfilled = requestInterceptorChain.shift(); 1059 var onRejected = requestInterceptorChain.shift(); 1060 try { 1061 newConfig = onFulfilled(newConfig); 1062 } catch (error) { 1063 onRejected(error); 1064 break; 1065 } 1066 } 1067 1068 try { 1069 promise = dispatchRequest(newConfig); 1070 } catch (error) { 1071 return Promise.reject(error); 1072 } 1073 1074 while (responseInterceptorChain.length) { 1075 promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift()); 1076 } 1077 1078 return promise; 1079}; 1080 1081Axios.prototype.getUri = function getUri(config) { 1082 if (!config.url) { 1083 throw new Error('Provided config url is not valid'); 1084 } 1085 config = mergeConfig(this.defaults, config); 1086 return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); 1087}; 1088 1089// Provide aliases for supported request methods 1090utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { 1091 /*eslint func-names:0*/ 1092 Axios.prototype[method] = function(url, config) { 1093 return this.request(mergeConfig(config || {}, { 1094 method: method, 1095 url: url, 1096 data: (config || {}).data 1097 })); 1098 }; 1099}); 1100 1101utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 1102 /*eslint func-names:0*/ 1103 Axios.prototype[method] = function(url, data, config) { 1104 return this.request(mergeConfig(config || {}, { 1105 method: method, 1106 url: url, 1107 data: data 1108 })); 1109 }; 1110}); 1111 1112module.exports = Axios; 1113 1114/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! es6-promise */ "./node_modules/es6-promise/dist/es6-promise.js"))) 1115 1116/***/ }), 1117
vendor: 1,773 bytes, lines 1118-1183
1118/***/ "./node_modules/axios/lib/core/InterceptorManager.js": 1119/*!***********************************************************!*\ 1120 !*** ./node_modules/axios/lib/core/InterceptorManager.js ***! 1121 \***********************************************************/ 1122/*! no static exports found */ 1123/***/ (function(module, exports, __webpack_require__) { 1124 1125"use strict"; 1126 1127 1128var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1129 1130function InterceptorManager() { 1131 this.handlers = []; 1132} 1133 1134/** 1135 * Add a new interceptor to the stack 1136 * 1137 * @param {Function} fulfilled The function to handle `then` for a `Promise` 1138 * @param {Function} rejected The function to handle `reject` for a `Promise` 1139 * 1140 * @return {Number} An ID used to remove interceptor later 1141 */ 1142InterceptorManager.prototype.use = function use(fulfilled, rejected, options) { 1143 this.handlers.push({ 1144 fulfilled: fulfilled, 1145 rejected: rejected, 1146 synchronous: options ? options.synchronous : false, 1147 runWhen: options ? options.runWhen : null 1148 }); 1149 return this.handlers.length - 1; 1150}; 1151 1152/** 1153 * Remove an interceptor from the stack 1154 * 1155 * @param {Number} id The ID that was returned by `use` 1156 */ 1157InterceptorManager.prototype.eject = function eject(id) { 1158 if (this.handlers[id]) { 1159 this.handlers[id] = null; 1160 } 1161}; 1162 1163/** 1164 * Iterate over all the registered interceptors 1165 * 1166 * This method is particularly useful for skipping over any 1167 * interceptors that may have become `null` calling `eject`. 1168 * 1169 * @param {Function} fn The function to call for each interceptor 1170 */ 1171InterceptorManager.prototype.forEach = function forEach(fn) { 1172 utils.forEach(this.handlers, function forEachHandler(h) { 1173 if (h !== null) { 1174 fn(h); 1175 } 1176 }); 1177}; 1178 1179module.exports = InterceptorManager; 1180 1181 1182/***/ }), 1183
vendor: 1,168 bytes, lines 1184-1215
1184/***/ "./node_modules/axios/lib/core/buildFullPath.js": 1185/*!******************************************************!*\ 1186 !*** ./node_modules/axios/lib/core/buildFullPath.js ***! 1187 \******************************************************/ 1188/*! no static exports found */ 1189/***/ (function(module, exports, __webpack_require__) { 1190 1191"use strict"; 1192 1193 1194var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js"); 1195var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js"); 1196 1197/** 1198 * Creates a new URL by combining the baseURL with the requestedURL, 1199 * only when the requestedURL is not already an absolute URL. 1200 * If the requestURL is absolute, this function returns the requestedURL untouched. 1201 * 1202 * @param {string} baseURL The base URL 1203 * @param {string} requestedURL Absolute or relative URL to combine 1204 * @returns {string} The combined full path 1205 */ 1206module.exports = function buildFullPath(baseURL, requestedURL) { 1207 if (baseURL && !isAbsoluteURL(requestedURL)) { 1208 return combineURLs(baseURL, requestedURL); 1209 } 1210 return requestedURL; 1211}; 1212 1213 1214/***/ }), 1215
vendor: 1,019 bytes, lines 1216-1245
1216/***/ "./node_modules/axios/lib/core/createError.js": 1217/*!****************************************************!*\ 1218 !*** ./node_modules/axios/lib/core/createError.js ***! 1219 \****************************************************/ 1220/*! no static exports found */ 1221/***/ (function(module, exports, __webpack_require__) { 1222 1223"use strict"; 1224 1225 1226var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js"); 1227 1228/** 1229 * Create an Error with the specified message, config, error code, request and response. 1230 * 1231 * @param {string} message The error message. 1232 * @param {Object} config The config. 1233 * @param {string} [code] The error code (for example, 'ECONNABORTED'). 1234 * @param {Object} [request] The request. 1235 * @param {Object} [response] The response. 1236 * @returns {Error} The created error. 1237 */ 1238module.exports = function createError(message, config, code, request, response) { 1239 var error = new Error(message); 1240 return enhanceError(error, config, code, request, response); 1241}; 1242 1243 1244/***/ }), 1245
vendor: 2,944 bytes, lines 1246-1345
1246/***/ "./node_modules/axios/lib/core/dispatchRequest.js": 1247/*!********************************************************!*\ 1248 !*** ./node_modules/axios/lib/core/dispatchRequest.js ***! 1249 \********************************************************/ 1250/*! no static exports found */ 1251/***/ (function(module, exports, __webpack_require__) { 1252 1253"use strict"; 1254/* WEBPACK VAR INJECTION */(function(Promise) { 1255 1256var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1257var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js"); 1258var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js"); 1259var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js"); 1260var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 1261 1262/** 1263 * Throws a `Cancel` if cancellation has been requested. 1264 */ 1265function throwIfCancellationRequested(config) { 1266 if (config.cancelToken) { 1267 config.cancelToken.throwIfRequested(); 1268 } 1269 1270 if (config.signal && config.signal.aborted) { 1271 throw new Cancel('canceled'); 1272 } 1273} 1274 1275/** 1276 * Dispatch a request to the server using the configured adapter. 1277 * 1278 * @param {object} config The config that is to be used for the request 1279 * @returns {Promise} The Promise to be fulfilled 1280 */ 1281module.exports = function dispatchRequest(config) { 1282 throwIfCancellationRequested(config); 1283 1284 // Ensure headers exist 1285 config.headers = config.headers || {}; 1286 1287 // Transform request data 1288 config.data = transformData.call( 1289 config, 1290 config.data, 1291 config.headers, 1292 config.transformRequest 1293 ); 1294 1295 // Flatten headers 1296 config.headers = utils.merge( 1297 config.headers.common || {}, 1298 config.headers[config.method] || {}, 1299 config.headers 1300 ); 1301 1302 utils.forEach( 1303 ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], 1304 function cleanHeaderConfig(method) { 1305 delete config.headers[method]; 1306 } 1307 ); 1308 1309 var adapter = config.adapter || defaults.adapter; 1310 1311 return adapter(config).then(function onAdapterResolution(response) { 1312 throwIfCancellationRequested(config); 1313 1314 // Transform response data 1315 response.data = transformData.call( 1316 config, 1317 response.data, 1318 response.headers, 1319 config.transformResponse 1320 ); 1321 1322 return response; 1323 }, function onAdapterRejection(reason) { 1324 if (!isCancel(reason)) { 1325 throwIfCancellationRequested(config); 1326 1327 // Transform response data 1328 if (reason && reason.response) { 1329 reason.response.data = transformData.call( 1330 config, 1331 reason.response.data, 1332 reason.response.headers, 1333 config.transformResponse 1334 ); 1335 } 1336 } 1337 1338 return Promise.reject(reason); 1339 }); 1340}; 1341 1342/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! es6-promise */ "./node_modules/es6-promise/dist/es6-promise.js"))) 1343 1344/***/ }), 1345
vendor: 1,465 bytes, lines 1346-1400
1346/***/ "./node_modules/axios/lib/core/enhanceError.js": 1347/*!*****************************************************!*\ 1348 !*** ./node_modules/axios/lib/core/enhanceError.js ***! 1349 \*****************************************************/ 1350/*! no static exports found */ 1351/***/ (function(module, exports, __webpack_require__) { 1352 1353"use strict"; 1354 1355 1356/** 1357 * Update an Error with the specified config, error code, and response. 1358 * 1359 * @param {Error} error The error to update. 1360 * @param {Object} config The config. 1361 * @param {string} [code] The error code (for example, 'ECONNABORTED'). 1362 * @param {Object} [request] The request. 1363 * @param {Object} [response] The response. 1364 * @returns {Error} The error. 1365 */ 1366module.exports = function enhanceError(error, config, code, request, response) { 1367 error.config = config; 1368 if (code) { 1369 error.code = code; 1370 } 1371 1372 error.request = request; 1373 error.response = response; 1374 error.isAxiosError = true; 1375 1376 error.toJSON = function toJSON() { 1377 return { 1378 // Standard 1379 message: this.message, 1380 name: this.name, 1381 // Microsoft 1382 description: this.description, 1383 number: this.number, 1384 // Mozilla 1385 fileName: this.fileName, 1386 lineNumber: this.lineNumber, 1387 columnNumber: this.columnNumber, 1388 stack: this.stack, 1389 // Axios 1390 config: this.config, 1391 code: this.code, 1392 status: this.response && this.response.status ? this.response.status : null 1393 }; 1394 }; 1395 return error; 1396}; 1397 1398 1399/***/ }), 1400
vendor: 3,577 bytes, lines 1401-1511
1401/***/ "./node_modules/axios/lib/core/mergeConfig.js": 1402/*!****************************************************!*\ 1403 !*** ./node_modules/axios/lib/core/mergeConfig.js ***! 1404 \****************************************************/ 1405/*! no static exports found */ 1406/***/ (function(module, exports, __webpack_require__) { 1407 1408"use strict"; 1409 1410 1411var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js"); 1412 1413/** 1414 * Config-specific merge-function which creates a new config-object 1415 * by merging two configuration objects together. 1416 * 1417 * @param {Object} config1 1418 * @param {Object} config2 1419 * @returns {Object} New object resulting from merging config2 to config1 1420 */ 1421module.exports = function mergeConfig(config1, config2) { 1422 // eslint-disable-next-line no-param-reassign 1423 config2 = config2 || {}; 1424 var config = {}; 1425 1426 function getMergedValue(target, source) { 1427 if (utils.isPlainObject(target) && utils.isPlainObject(source)) { 1428 return utils.merge(target, source); 1429 } else if (utils.isPlainObject(source)) { 1430 return utils.merge({}, source); 1431 } else if (utils.isArray(source)) { 1432 return source.slice(); 1433 } 1434 return source; 1435 } 1436 1437 // eslint-disable-next-line consistent-return 1438 function mergeDeepProperties(prop) { 1439 if (!utils.isUndefined(config2[prop])) { 1440 return getMergedValue(config1[prop], config2[prop]); 1441 } else if (!utils.isUndefined(config1[prop])) { 1442 return getMergedValue(undefined, config1[prop]); 1443 } 1444 } 1445 1446 // eslint-disable-next-line consistent-return 1447 function valueFromConfig2(prop) { 1448 if (!utils.isUndefined(config2[prop])) { 1449 return getMergedValue(undefined, config2[prop]); 1450 } 1451 } 1452 1453 // eslint-disable-next-line consistent-return 1454 function defaultToConfig2(prop) { 1455 if (!utils.isUndefined(config2[prop])) { 1456 return getMergedValue(undefined, config2[prop]); 1457 } else if (!utils.isUndefined(config1[prop])) { 1458 return getMergedValue(undefined, config1[prop]); 1459 } 1460 } 1461 1462 // eslint-disable-next-line consistent-return 1463 function mergeDirectKeys(prop) { 1464 if (prop in config2) { 1465 return getMergedValue(config1[prop], config2[prop]); 1466 } else if (prop in config1) { 1467 return getMergedValue(undefined, config1[prop]); 1468 } 1469 } 1470 1471 var mergeMap = { 1472 'url': valueFromConfig2, 1473 'method': valueFromConfig2, 1474 'data': valueFromConfig2, 1475 'baseURL': defaultToConfig2, 1476 'transformRequest': defaultToConfig2, 1477 'transformResponse': defaultToConfig2, 1478 'paramsSerializer': defaultToConfig2, 1479 'timeout': defaultToConfig2, 1480 'timeoutMessage': defaultToConfig2, 1481 'withCredentials': defaultToConfig2, 1482 'adapter': defaultToConfig2, 1483 'responseType': defaultToConfig2, 1484 'xsrfCookieName': defaultToConfig2, 1485 'xsrfHeaderName': defaultToConfig2, 1486 'onUploadProgress': defaultToConfig2, 1487 'onDownloadProgress': defaultToConfig2, 1488 'decompress': defaultToConfig2, 1489 'maxContentLength': defaultToConfig2, 1490 'maxBodyLength': defaultToConfig2, 1491 'transport': defaultToConfig2, 1492 'httpAgent': defaultToConfig2, 1493 'httpsAgent': defaultToConfig2, 1494 'cancelToken': defaultToConfig2, 1495 'socketPath': defaultToConfig2, 1496 'responseEncoding': defaultToConfig2, 1497 'validateStatus': mergeDirectKeys 1498 }; 1499 1500 utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) { 1501 var merge = mergeMap[prop] || mergeDeepProperties; 1502 var configValue = merge(prop); 1503 (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); 1504 }); 1505 1506 return config; 1507}; 1508 1509 1510/***/ }), 1511
vendor: 1,079 bytes, lines 1512-1548
1512/***/ "./node_modules/axios/lib/core/settle.js": 1513/*!***********************************************!*\ 1514 !*** ./node_modules/axios/lib/core/settle.js ***! 1515 \***********************************************/ 1516/*! no static exports found */ 1517/***/ (function(module, exports, __webpack_require__) { 1518 1519"use strict"; 1520 1521 1522var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js"); 1523 1524/** 1525 * Resolve or reject a Promise based on response status. 1526 * 1527 * @param {Function} resolve A function that resolves the promise. 1528 * @param {Function} reject A function that rejects the promise. 1529 * @param {object} response The response. 1530 */ 1531module.exports = function settle(resolve, reject, response) { 1532 var validateStatus = response.config.validateStatus; 1533 if (!response.status || !validateStatus || validateStatus(response.status)) { 1534 resolve(response); 1535 } else { 1536 reject(createError( 1537 'Request failed with status code ' + response.status, 1538 response.config, 1539 null, 1540 response.request, 1541 response 1542 )); 1543 } 1544}; 1545 1546 1547/***/ }), 1548
vendor: 1,085 bytes, lines 1549-1582
1549/***/ "./node_modules/axios/lib/core/transformData.js": 1550/*!******************************************************!*\ 1551 !*** ./node_modules/axios/lib/core/transformData.js ***! 1552 \******************************************************/ 1553/*! no static exports found */ 1554/***/ (function(module, exports, __webpack_require__) { 1555 1556"use strict"; 1557 1558 1559var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1560var defaults = __webpack_require__(/*! ./../defaults */ "./node_modules/axios/lib/defaults.js"); 1561 1562/** 1563 * Transform the data for a request or a response 1564 * 1565 * @param {Object|String} data The data to be transformed 1566 * @param {Array} headers The headers for the request or response 1567 * @param {Array|Function} fns A single function or Array of functions 1568 * @returns {*} The resulting transformed data 1569 */ 1570module.exports = function transformData(data, headers, fns) { 1571 var context = this || defaults; 1572 /*eslint no-param-reassign:0*/ 1573 utils.forEach(fns, function transform(fn) { 1574 data = fn.call(context, data, headers); 1575 }); 1576 1577 return data; 1578}; 1579 1580 1581/***/ }), 1582
vendor: 4,372 bytes, lines 1583-1729
1583/***/ "./node_modules/axios/lib/defaults.js": 1584/*!********************************************!*\ 1585 !*** ./node_modules/axios/lib/defaults.js ***! 1586 \********************************************/ 1587/*! no static exports found */ 1588/***/ (function(module, exports, __webpack_require__) { 1589 1590"use strict"; 1591/* WEBPACK VAR INJECTION */(function(process) { 1592 1593var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js"); 1594var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js"); 1595var enhanceError = __webpack_require__(/*! ./core/enhanceError */ "./node_modules/axios/lib/core/enhanceError.js"); 1596 1597var DEFAULT_CONTENT_TYPE = { 1598 'Content-Type': 'application/x-www-form-urlencoded' 1599}; 1600 1601function setContentTypeIfUnset(headers, value) { 1602 if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { 1603 headers['Content-Type'] = value; 1604 } 1605} 1606 1607function getDefaultAdapter() { 1608 var adapter; 1609 if (typeof XMLHttpRequest !== 'undefined') { 1610 // For browsers use XHR adapter 1611 adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js"); 1612 } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { 1613 // For node use HTTP adapter 1614 adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js"); 1615 } 1616 return adapter; 1617} 1618 1619function stringifySafely(rawValue, parser, encoder) { 1620 if (utils.isString(rawValue)) { 1621 try { 1622 (parser || JSON.parse)(rawValue); 1623 return utils.trim(rawValue); 1624 } catch (e) { 1625 if (e.name !== 'SyntaxError') { 1626 throw e; 1627 } 1628 } 1629 } 1630 1631 return (encoder || JSON.stringify)(rawValue); 1632} 1633 1634var defaults = { 1635 1636 transitional: { 1637 silentJSONParsing: true, 1638 forcedJSONParsing: true, 1639 clarifyTimeoutError: false 1640 }, 1641 1642 adapter: getDefaultAdapter(), 1643 1644 transformRequest: [function transformRequest(data, headers) { 1645 normalizeHeaderName(headers, 'Accept'); 1646 normalizeHeaderName(headers, 'Content-Type'); 1647 1648 if (utils.isFormData(data) || 1649 utils.isArrayBuffer(data) || 1650 utils.isBuffer(data) || 1651 utils.isStream(data) || 1652 utils.isFile(data) || 1653 utils.isBlob(data) 1654 ) { 1655 return data; 1656 } 1657 if (utils.isArrayBufferView(data)) { 1658 return data.buffer; 1659 } 1660 if (utils.isURLSearchParams(data)) { 1661 setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); 1662 return data.toString(); 1663 } 1664 if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) { 1665 setContentTypeIfUnset(headers, 'application/json'); 1666 return stringifySafely(data); 1667 } 1668 return data; 1669 }], 1670 1671 transformResponse: [function transformResponse(data) { 1672 var transitional = this.transitional || defaults.transitional; 1673 var silentJSONParsing = transitional && transitional.silentJSONParsing; 1674 var forcedJSONParsing = transitional && transitional.forcedJSONParsing; 1675 var strictJSONParsing = !silentJSONParsing && this.responseType === 'json'; 1676 1677 if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) { 1678 try { 1679 return JSON.parse(data); 1680 } catch (e) { 1681 if (strictJSONParsing) { 1682 if (e.name === 'SyntaxError') { 1683 throw enhanceError(e, this, 'E_JSON_PARSE'); 1684 } 1685 throw e; 1686 } 1687 } 1688 } 1689 1690 return data; 1691 }], 1692 1693 /** 1694 * A timeout in milliseconds to abort a request. If set to 0 (default) a 1695 * timeout is not created. 1696 */ 1697 timeout: 0, 1698 1699 xsrfCookieName: 'XSRF-TOKEN', 1700 xsrfHeaderName: 'X-XSRF-TOKEN', 1701 1702 maxContentLength: -1, 1703 maxBodyLength: -1, 1704 1705 validateStatus: function validateStatus(status) { 1706 return status >= 200 && status < 300; 1707 }, 1708 1709 headers: { 1710 common: { 1711 'Accept': 'application/json, text/plain, */*' 1712 } 1713 } 1714}; 1715 1716utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { 1717 defaults.headers[method] = {}; 1718}); 1719 1720utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 1721 defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); 1722}); 1723 1724module.exports = defaults; 1725 1726/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js"))) 1727 1728/***/ }), 1729
vendor: 318 bytes, lines 1730-1742
1730/***/ "./node_modules/axios/lib/env/data.js": 1731/*!********************************************!*\ 1732 !*** ./node_modules/axios/lib/env/data.js ***! 1733 \********************************************/ 1734/*! no static exports found */ 1735/***/ (function(module, exports) { 1736 1737module.exports = { 1738 "version": "0.25.0" 1739}; 1740 1741/***/ }), 1742
vendor: 569 bytes, lines 1743-1765
1743/***/ "./node_modules/axios/lib/helpers/bind.js": 1744/*!************************************************!*\ 1745 !*** ./node_modules/axios/lib/helpers/bind.js ***! 1746 \************************************************/ 1747/*! no static exports found */ 1748/***/ (function(module, exports, __webpack_require__) { 1749 1750"use strict"; 1751 1752 1753module.exports = function bind(fn, thisArg) { 1754 return function wrap() { 1755 var args = new Array(arguments.length); 1756 for (var i = 0; i < args.length; i++) { 1757 args[i] = arguments[i]; 1758 } 1759 return fn.apply(thisArg, args); 1760 }; 1761}; 1762 1763 1764/***/ }), 1765
vendor: 2,026 bytes, lines 1766-1847
1766/***/ "./node_modules/axios/lib/helpers/buildURL.js": 1767/*!****************************************************!*\ 1768 !*** ./node_modules/axios/lib/helpers/buildURL.js ***! 1769 \****************************************************/ 1770/*! no static exports found */ 1771/***/ (function(module, exports, __webpack_require__) { 1772 1773"use strict"; 1774 1775 1776var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1777 1778function encode(val) { 1779 return encodeURIComponent(val). 1780 replace(/%3A/gi, ':'). 1781 replace(/%24/g, '$'). 1782 replace(/%2C/gi, ','). 1783 replace(/%20/g, '+'). 1784 replace(/%5B/gi, '['). 1785 replace(/%5D/gi, ']'); 1786} 1787 1788/** 1789 * Build a URL by appending params to the end 1790 * 1791 * @param {string} url The base of the url (e.g., http://www.google.com) 1792 * @param {object} [params] The params to be appended 1793 * @returns {string} The formatted url 1794 */ 1795module.exports = function buildURL(url, params, paramsSerializer) { 1796 /*eslint no-param-reassign:0*/ 1797 if (!params) { 1798 return url; 1799 } 1800 1801 var serializedParams; 1802 if (paramsSerializer) { 1803 serializedParams = paramsSerializer(params); 1804 } else if (utils.isURLSearchParams(params)) { 1805 serializedParams = params.toString(); 1806 } else { 1807 var parts = []; 1808 1809 utils.forEach(params, function serialize(val, key) { 1810 if (val === null || typeof val === 'undefined') { 1811 return; 1812 } 1813 1814 if (utils.isArray(val)) { 1815 key = key + '[]'; 1816 } else { 1817 val = [val]; 1818 } 1819 1820 utils.forEach(val, function parseValue(v) { 1821 if (utils.isDate(v)) { 1822 v = v.toISOString(); 1823 } else if (utils.isObject(v)) { 1824 v = JSON.stringify(v); 1825 } 1826 parts.push(encode(key) + '=' + encode(v)); 1827 }); 1828 }); 1829 1830 serializedParams = parts.join('&'); 1831 } 1832 1833 if (serializedParams) { 1834 var hashmarkIndex = url.indexOf('#'); 1835 if (hashmarkIndex !== -1) { 1836 url = url.slice(0, hashmarkIndex); 1837 } 1838 1839 url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; 1840 } 1841 1842 return url; 1843}; 1844 1845 1846/***/ }), 1847
vendor: 721 bytes, lines 1848-1873
1848/***/ "./node_modules/axios/lib/helpers/combineURLs.js": 1849/*!*******************************************************!*\ 1850 !*** ./node_modules/axios/lib/helpers/combineURLs.js ***! 1851 \*******************************************************/ 1852/*! no static exports found */ 1853/***/ (function(module, exports, __webpack_require__) { 1854 1855"use strict"; 1856 1857 1858/** 1859 * Creates a new URL by combining the specified URLs 1860 * 1861 * @param {string} baseURL The base URL 1862 * @param {string} relativeURL The relative URL 1863 * @returns {string} The combined URL 1864 */ 1865module.exports = function combineURLs(baseURL, relativeURL) { 1866 return relativeURL 1867 ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') 1868 : baseURL; 1869}; 1870 1871 1872/***/ }), 1873
vendor: 1,813 bytes, lines 1874-1938
1874/***/ "./node_modules/axios/lib/helpers/cookies.js": 1875/*!***************************************************!*\ 1876 !*** ./node_modules/axios/lib/helpers/cookies.js ***! 1877 \***************************************************/ 1878/*! no static exports found */ 1879/***/ (function(module, exports, __webpack_require__) { 1880 1881"use strict"; 1882 1883 1884var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1885 1886module.exports = ( 1887 utils.isStandardBrowserEnv() ? 1888 1889 // Standard browser envs support document.cookie 1890 (function standardBrowserEnv() { 1891 return { 1892 write: function write(name, value, expires, path, domain, secure) { 1893 var cookie = []; 1894 cookie.push(name + '=' + encodeURIComponent(value)); 1895 1896 if (utils.isNumber(expires)) { 1897 cookie.push('expires=' + new Date(expires).toGMTString()); 1898 } 1899 1900 if (utils.isString(path)) { 1901 cookie.push('path=' + path); 1902 } 1903 1904 if (utils.isString(domain)) { 1905 cookie.push('domain=' + domain); 1906 } 1907 1908 if (secure === true) { 1909 cookie.push('secure'); 1910 } 1911 1912 document.cookie = cookie.join('; '); 1913 }, 1914 1915 read: function read(name) { 1916 var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); 1917 return (match ? decodeURIComponent(match[3]) : null); 1918 }, 1919 1920 remove: function remove(name) { 1921 this.write(name, '', Date.now() - 86400000); 1922 } 1923 }; 1924 })() : 1925 1926 // Non standard browser env (web workers, react-native) lack needed support. 1927 (function nonStandardBrowserEnv() { 1928 return { 1929 write: function write() {}, 1930 read: function read() { return null; }, 1931 remove: function remove() {} 1932 }; 1933 })() 1934); 1935 1936 1937/***/ }), 1938
vendor: 910 bytes, lines 1939-1964
1939/***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js": 1940/*!*********************************************************!*\ 1941 !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***! 1942 \*********************************************************/ 1943/*! no static exports found */ 1944/***/ (function(module, exports, __webpack_require__) { 1945 1946"use strict"; 1947 1948 1949/** 1950 * Determines whether the specified URL is absolute 1951 * 1952 * @param {string} url The URL to test 1953 * @returns {boolean} True if the specified URL is absolute, otherwise false 1954 */ 1955module.exports = function isAbsoluteURL(url) { 1956 // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL). 1957 // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed 1958 // by any combination of letters, digits, plus, period, or hyphen. 1959 return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); 1960}; 1961 1962 1963/***/ }), 1964
vendor: 771 bytes, lines 1965-1989
1965/***/ "./node_modules/axios/lib/helpers/isAxiosError.js": 1966/*!********************************************************!*\ 1967 !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***! 1968 \********************************************************/ 1969/*! no static exports found */ 1970/***/ (function(module, exports, __webpack_require__) { 1971 1972"use strict"; 1973 1974 1975var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1976 1977/** 1978 * Determines whether the payload is an error thrown by Axios 1979 * 1980 * @param {*} payload The value to test 1981 * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false 1982 */ 1983module.exports = function isAxiosError(payload) { 1984 return utils.isObject(payload) && (payload.isAxiosError === true); 1985}; 1986 1987 1988/***/ }), 1989
vendor: 2,715 bytes, lines 1990-2069
1990/***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js": 1991/*!***********************************************************!*\ 1992 !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***! 1993 \***********************************************************/ 1994/*! no static exports found */ 1995/***/ (function(module, exports, __webpack_require__) { 1996 1997"use strict"; 1998 1999 2000var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 2001 2002module.exports = ( 2003 utils.isStandardBrowserEnv() ? 2004 2005 // Standard browser envs have full support of the APIs needed to test 2006 // whether the request URL is of the same origin as current location. 2007 (function standardBrowserEnv() { 2008 var msie = /(msie|trident)/i.test(navigator.userAgent); 2009 var urlParsingNode = document.createElement('a'); 2010 var originURL; 2011 2012 /** 2013 * Parse a URL to discover it's components 2014 * 2015 * @param {String} url The URL to be parsed 2016 * @returns {Object} 2017 */ 2018 function resolveURL(url) { 2019 var href = url; 2020 2021 if (msie) { 2022 // IE needs attribute set twice to normalize properties 2023 urlParsingNode.setAttribute('href', href); 2024 href = urlParsingNode.href; 2025 } 2026 2027 urlParsingNode.setAttribute('href', href); 2028 2029 // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 2030 return { 2031 href: urlParsingNode.href, 2032 protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 2033 host: urlParsingNode.host, 2034 search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 2035 hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 2036 hostname: urlParsingNode.hostname, 2037 port: urlParsingNode.port, 2038 pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 2039 urlParsingNode.pathname : 2040 '/' + urlParsingNode.pathname 2041 }; 2042 } 2043 2044 originURL = resolveURL(window.location.href); 2045 2046 /** 2047 * Determine if a URL shares the same origin as the current location 2048 * 2049 * @param {String} requestURL The URL to test 2050 * @returns {boolean} True if URL shares the same origin, otherwise false 2051 */ 2052 return function isURLSameOrigin(requestURL) { 2053 var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; 2054 return (parsed.protocol === originURL.protocol && 2055 parsed.host === originURL.host); 2056 }; 2057 })() : 2058 2059 // Non standard browser envs (web workers, react-native) lack needed support. 2060 (function nonStandardBrowserEnv() { 2061 return function isURLSameOrigin() { 2062 return true; 2063 }; 2064 })() 2065); 2066 2067 2068/***/ }), 2069
vendor: 783 bytes, lines 2070-2093
2070/***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js": 2071/*!***************************************************************!*\ 2072 !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***! 2073 \***************************************************************/ 2074/*! no static exports found */ 2075/***/ (function(module, exports, __webpack_require__) { 2076 2077"use strict"; 2078 2079 2080var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js"); 2081 2082module.exports = function normalizeHeaderName(headers, normalizedName) { 2083 utils.forEach(headers, function processHeader(value, name) { 2084 if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { 2085 headers[normalizedName] = value; 2086 delete headers[name]; 2087 } 2088 }); 2089}; 2090 2091 2092/***/ }), 2093
vendor: 1,791 bytes, lines 2094-2158
2094/***/ "./node_modules/axios/lib/helpers/parseHeaders.js": 2095/*!********************************************************!*\ 2096 !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***! 2097 \********************************************************/ 2098/*! no static exports found */ 2099/***/ (function(module, exports, __webpack_require__) { 2100 2101"use strict"; 2102 2103 2104var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 2105 2106// Headers whose duplicates are ignored by node 2107// c.f. https://nodejs.org/api/http.html#http_message_headers 2108var ignoreDuplicateOf = [ 2109 'age', 'authorization', 'content-length', 'content-type', 'etag', 2110 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 2111 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 2112 'referer', 'retry-after', 'user-agent' 2113]; 2114 2115/** 2116 * Parse headers into an object 2117 * 2118 * ``` 2119 * Date: Wed, 27 Aug 2014 08:58:49 GMT 2120 * Content-Type: application/json 2121 * Connection: keep-alive 2122 * Transfer-Encoding: chunked 2123 * ``` 2124 * 2125 * @param {String} headers Headers needing to be parsed 2126 * @returns {Object} Headers parsed into an object 2127 */ 2128module.exports = function parseHeaders(headers) { 2129 var parsed = {}; 2130 var key; 2131 var val; 2132 var i; 2133 2134 if (!headers) { return parsed; } 2135 2136 utils.forEach(headers.split('\n'), function parser(line) { 2137 i = line.indexOf(':'); 2138 key = utils.trim(line.substr(0, i)).toLowerCase(); 2139 val = utils.trim(line.substr(i + 1)); 2140 2141 if (key) { 2142 if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { 2143 return; 2144 } 2145 if (key === 'set-cookie') { 2146 parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); 2147 } else { 2148 parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 2149 } 2150 } 2151 }); 2152 2153 return parsed; 2154}; 2155 2156 2157/***/ }), 2158
vendor: 885 bytes, lines 2159-2197
2159/***/ "./node_modules/axios/lib/helpers/spread.js": 2160/*!**************************************************!*\ 2161 !*** ./node_modules/axios/lib/helpers/spread.js ***! 2162 \**************************************************/ 2163/*! no static exports found */ 2164/***/ (function(module, exports, __webpack_require__) { 2165 2166"use strict"; 2167 2168 2169/** 2170 * Syntactic sugar for invoking a function and expanding an array for arguments. 2171 * 2172 * Common use case would be to use `Function.prototype.apply`. 2173 * 2174 * ```js 2175 * function f(x, y, z) {} 2176 * var args = [1, 2, 3]; 2177 * f.apply(null, args); 2178 * ``` 2179 * 2180 * With `spread` this example can be re-written. 2181 * 2182 * ```js 2183 * spread(function(x, y, z) {})([1, 2, 3]); 2184 * ``` 2185 * 2186 * @param {Function} callback 2187 * @returns {Function} 2188 */ 2189module.exports = function spread(callback) { 2190 return function wrap(arr) { 2191 return callback.apply(null, arr); 2192 }; 2193}; 2194 2195 2196/***/ }), 2197
vendor: 2,736 bytes, lines 2198-2291
2198/***/ "./node_modules/axios/lib/helpers/validator.js": 2199/*!*****************************************************!*\ 2200 !*** ./node_modules/axios/lib/helpers/validator.js ***! 2201 \*****************************************************/ 2202/*! no static exports found */ 2203/***/ (function(module, exports, __webpack_require__) { 2204 2205"use strict"; 2206 2207 2208var VERSION = __webpack_require__(/*! ../env/data */ "./node_modules/axios/lib/env/data.js").version; 2209 2210var validators = {}; 2211 2212// eslint-disable-next-line func-names 2213['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) { 2214 validators[type] = function validator(thing) { 2215 return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type; 2216 }; 2217}); 2218 2219var deprecatedWarnings = {}; 2220 2221/** 2222 * Transitional option validator 2223 * @param {function|boolean?} validator - set to false if the transitional option has been removed 2224 * @param {string?} version - deprecated version / removed since version 2225 * @param {string?} message - some message with additional info 2226 * @returns {function} 2227 */ 2228validators.transitional = function transitional(validator, version, message) { 2229 function formatMessage(opt, desc) { 2230 return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : ''); 2231 } 2232 2233 // eslint-disable-next-line func-names 2234 return function(value, opt, opts) { 2235 if (validator === false) { 2236 throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : ''))); 2237 } 2238 2239 if (version && !deprecatedWarnings[opt]) { 2240 deprecatedWarnings[opt] = true; 2241 // eslint-disable-next-line no-console 2242 console.warn( 2243 formatMessage( 2244 opt, 2245 ' has been deprecated since v' + version + ' and will be removed in the near future' 2246 ) 2247 ); 2248 } 2249 2250 return validator ? validator(value, opt, opts) : true; 2251 }; 2252}; 2253 2254/** 2255 * Assert object's properties type 2256 * @param {object} options 2257 * @param {object} schema 2258 * @param {boolean?} allowUnknown 2259 */ 2260 2261function assertOptions(options, schema, allowUnknown) { 2262 if (typeof options !== 'object') { 2263 throw new TypeError('options must be an object'); 2264 } 2265 var keys = Object.keys(options); 2266 var i = keys.length; 2267 while (i-- > 0) { 2268 var opt = keys[i]; 2269 var validator = schema[opt]; 2270 if (validator) { 2271 var value = options[opt]; 2272 var result = value === undefined || validator(value, opt, options); 2273 if (result !== true) { 2274 throw new TypeError('option ' + opt + ' must be ' + result); 2275 } 2276 continue; 2277 } 2278 if (allowUnknown !== true) { 2279 throw Error('Unknown option ' + opt); 2280 } 2281 } 2282} 2283 2284module.exports = { 2285 assertOptions: assertOptions, 2286 validators: validators 2287}; 2288 2289 2290/***/ }), 2291
vendor: 9,204 bytes, lines 2292-2652
2292/***/ "./node_modules/axios/lib/utils.js": 2293/*!*****************************************!*\ 2294 !*** ./node_modules/axios/lib/utils.js ***! 2295 \*****************************************/ 2296/*! no static exports found */ 2297/***/ (function(module, exports, __webpack_require__) { 2298 2299"use strict"; 2300 2301 2302var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js"); 2303 2304// utils is a library of generic helper functions non-specific to axios 2305 2306var toString = Object.prototype.toString; 2307 2308/** 2309 * Determine if a value is an Array 2310 * 2311 * @param {Object} val The value to test 2312 * @returns {boolean} True if value is an Array, otherwise false 2313 */ 2314function isArray(val) { 2315 return Array.isArray(val); 2316} 2317 2318/** 2319 * Determine if a value is undefined 2320 * 2321 * @param {Object} val The value to test 2322 * @returns {boolean} True if the value is undefined, otherwise false 2323 */ 2324function isUndefined(val) { 2325 return typeof val === 'undefined'; 2326} 2327 2328/** 2329 * Determine if a value is a Buffer 2330 * 2331 * @param {Object} val The value to test 2332 * @returns {boolean} True if value is a Buffer, otherwise false 2333 */ 2334function isBuffer(val) { 2335 return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) 2336 && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); 2337} 2338 2339/** 2340 * Determine if a value is an ArrayBuffer 2341 * 2342 * @param {Object} val The value to test 2343 * @returns {boolean} True if value is an ArrayBuffer, otherwise false 2344 */ 2345function isArrayBuffer(val) { 2346 return toString.call(val) === '[object ArrayBuffer]'; 2347} 2348 2349/** 2350 * Determine if a value is a FormData 2351 * 2352 * @param {Object} val The value to test 2353 * @returns {boolean} True if value is an FormData, otherwise false 2354 */ 2355function isFormData(val) { 2356 return toString.call(val) === '[object FormData]'; 2357} 2358 2359/** 2360 * Determine if a value is a view on an ArrayBuffer 2361 * 2362 * @param {Object} val The value to test 2363 * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false 2364 */ 2365function isArrayBufferView(val) { 2366 var result; 2367 if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { 2368 result = ArrayBuffer.isView(val); 2369 } else { 2370 result = (val) && (val.buffer) && (isArrayBuffer(val.buffer)); 2371 } 2372 return result; 2373} 2374 2375/** 2376 * Determine if a value is a String 2377 * 2378 * @param {Object} val The value to test 2379 * @returns {boolean} True if value is a String, otherwise false 2380 */ 2381function isString(val) { 2382 return typeof val === 'string'; 2383} 2384 2385/** 2386 * Determine if a value is a Number 2387 * 2388 * @param {Object} val The value to test 2389 * @returns {boolean} True if value is a Number, otherwise false 2390 */ 2391function isNumber(val) { 2392 return typeof val === 'number'; 2393} 2394 2395/** 2396 * Determine if a value is an Object 2397 * 2398 * @param {Object} val The value to test 2399 * @returns {boolean} True if value is an Object, otherwise false 2400 */ 2401function isObject(val) { 2402 return val !== null && typeof val === 'object'; 2403} 2404 2405/** 2406 * Determine if a value is a plain Object 2407 * 2408 * @param {Object} val The value to test 2409 * @return {boolean} True if value is a plain Object, otherwise false 2410 */ 2411function isPlainObject(val) { 2412 if (toString.call(val) !== '[object Object]') { 2413 return false; 2414 } 2415 2416 var prototype = Object.getPrototypeOf(val); 2417 return prototype === null || prototype === Object.prototype; 2418} 2419 2420/** 2421 * Determine if a value is a Date 2422 * 2423 * @param {Object} val The value to test 2424 * @returns {boolean} True if value is a Date, otherwise false 2425 */ 2426function isDate(val) { 2427 return toString.call(val) === '[object Date]'; 2428} 2429 2430/** 2431 * Determine if a value is a File 2432 * 2433 * @param {Object} val The value to test 2434 * @returns {boolean} True if value is a File, otherwise false 2435 */ 2436function isFile(val) { 2437 return toString.call(val) === '[object File]'; 2438} 2439 2440/** 2441 * Determine if a value is a Blob 2442 * 2443 * @param {Object} val The value to test 2444 * @returns {boolean} True if value is a Blob, otherwise false 2445 */ 2446function isBlob(val) { 2447 return toString.call(val) === '[object Blob]'; 2448} 2449 2450/** 2451 * Determine if a value is a Function 2452 * 2453 * @param {Object} val The value to test 2454 * @returns {boolean} True if value is a Function, otherwise false 2455 */ 2456function isFunction(val) { 2457 return toString.call(val) === '[object Function]'; 2458} 2459 2460/** 2461 * Determine if a value is a Stream 2462 * 2463 * @param {Object} val The value to test 2464 * @returns {boolean} True if value is a Stream, otherwise false 2465 */ 2466function isStream(val) { 2467 return isObject(val) && isFunction(val.pipe); 2468} 2469 2470/** 2471 * Determine if a value is a URLSearchParams object 2472 * 2473 * @param {Object} val The value to test 2474 * @returns {boolean} True if value is a URLSearchParams object, otherwise false 2475 */ 2476function isURLSearchParams(val) { 2477 return toString.call(val) === '[object URLSearchParams]'; 2478} 2479 2480/** 2481 * Trim excess whitespace off the beginning and end of a string 2482 * 2483 * @param {String} str The String to trim 2484 * @returns {String} The String freed of excess whitespace 2485 */ 2486function trim(str) { 2487 return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); 2488} 2489 2490/** 2491 * Determine if we're running in a standard browser environment 2492 * 2493 * This allows axios to run in a web worker, and react-native. 2494 * Both environments support XMLHttpRequest, but not fully standard globals. 2495 * 2496 * web workers: 2497 * typeof window -> undefined 2498 * typeof document -> undefined 2499 * 2500 * react-native: 2501 * navigator.product -> 'ReactNative' 2502 * nativescript 2503 * navigator.product -> 'NativeScript' or 'NS' 2504 */ 2505function isStandardBrowserEnv() { 2506 if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || 2507 navigator.product === 'NativeScript' || 2508 navigator.product === 'NS')) { 2509 return false; 2510 } 2511 return ( 2512 typeof window !== 'undefined' && 2513 typeof document !== 'undefined' 2514 ); 2515} 2516 2517/** 2518 * Iterate over an Array or an Object invoking a function for each item. 2519 * 2520 * If `obj` is an Array callback will be called passing 2521 * the value, index, and complete array for each item. 2522 * 2523 * If 'obj' is an Object callback will be called passing 2524 * the value, key, and complete object for each property. 2525 * 2526 * @param {Object|Array} obj The object to iterate 2527 * @param {Function} fn The callback to invoke for each item 2528 */ 2529function forEach(obj, fn) { 2530 // Don't bother if no value provided 2531 if (obj === null || typeof obj === 'undefined') { 2532 return; 2533 } 2534 2535 // Force an array if not already something iterable 2536 if (typeof obj !== 'object') { 2537 /*eslint no-param-reassign:0*/ 2538 obj = [obj]; 2539 } 2540 2541 if (isArray(obj)) { 2542 // Iterate over array values 2543 for (var i = 0, l = obj.length; i < l; i++) { 2544 fn.call(null, obj[i], i, obj); 2545 } 2546 } else { 2547 // Iterate over object keys 2548 for (var key in obj) { 2549 if (Object.prototype.hasOwnProperty.call(obj, key)) { 2550 fn.call(null, obj[key], key, obj); 2551 } 2552 } 2553 } 2554} 2555 2556/** 2557 * Accepts varargs expecting each argument to be an object, then 2558 * immutably merges the properties of each object and returns result. 2559 * 2560 * When multiple objects contain the same key the later object in 2561 * the arguments list will take precedence. 2562 * 2563 * Example: 2564 * 2565 * ```js 2566 * var result = merge({foo: 123}, {foo: 456}); 2567 * console.log(result.foo); // outputs 456 2568 * ``` 2569 * 2570 * @param {Object} obj1 Object to merge 2571 * @returns {Object} Result of all merge properties 2572 */ 2573function merge(/* obj1, obj2, obj3, ... */) { 2574 var result = {}; 2575 function assignValue(val, key) { 2576 if (isPlainObject(result[key]) && isPlainObject(val)) { 2577 result[key] = merge(result[key], val); 2578 } else if (isPlainObject(val)) { 2579 result[key] = merge({}, val); 2580 } else if (isArray(val)) { 2581 result[key] = val.slice(); 2582 } else { 2583 result[key] = val; 2584 } 2585 } 2586 2587 for (var i = 0, l = arguments.length; i < l; i++) { 2588 forEach(arguments[i], assignValue); 2589 } 2590 return result; 2591} 2592 2593/** 2594 * Extends object a by mutably adding to it the properties of object b. 2595 * 2596 * @param {Object} a The object to be extended 2597 * @param {Object} b The object to copy properties from 2598 * @param {Object} thisArg The object to bind function to 2599 * @return {Object} The resulting value of object a 2600 */ 2601function extend(a, b, thisArg) { 2602 forEach(b, function assignValue(val, key) { 2603 if (thisArg && typeof val === 'function') { 2604 a[key] = bind(val, thisArg); 2605 } else { 2606 a[key] = val; 2607 } 2608 }); 2609 return a; 2610} 2611 2612/** 2613 * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) 2614 * 2615 * @param {string} content with BOM 2616 * @return {string} content value without BOM 2617 */ 2618function stripBOM(content) { 2619 if (content.charCodeAt(0) === 0xFEFF) { 2620 content = content.slice(1); 2621 } 2622 return content; 2623} 2624 2625module.exports = { 2626 isArray: isArray, 2627 isArrayBuffer: isArrayBuffer, 2628 isBuffer: isBuffer, 2629 isFormData: isFormData, 2630 isArrayBufferView: isArrayBufferView, 2631 isString: isString, 2632 isNumber: isNumber, 2633 isObject: isObject, 2634 isPlainObject: isPlainObject, 2635 isUndefined: isUndefined, 2636 isDate: isDate, 2637 isFile: isFile, 2638 isBlob: isBlob, 2639 isFunction: isFunction, 2640 isStream: isStream, 2641 isURLSearchParams: isURLSearchParams, 2642 isStandardBrowserEnv: isStandardBrowserEnv, 2643 forEach: forEach, 2644 merge: merge, 2645 extend: extend, 2646 trim: trim, 2647 stripBOM: stripBOM 2648}; 2649 2650 2651/***/ }), 2652
vendor: 29,773 bytes, lines 2653-3842
2653/***/ "./node_modules/es6-promise/dist/es6-promise.js": 2654/*!******************************************************!*\ 2655 !*** ./node_modules/es6-promise/dist/es6-promise.js ***! 2656 \******************************************************/ 2657/*! no static exports found */ 2658/***/ (function(module, exports, __webpack_require__) { 2659 2660/* WEBPACK VAR INJECTION */(function(process, global) {/*! 2661 * @overview es6-promise - a tiny implementation of Promises/A+. 2662 * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) 2663 * @license Licensed under MIT license 2664 * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE 2665 * @version v4.2.4+314e4831 2666 */ 2667 2668(function (global, factory) { 2669 true ? module.exports = factory() : 2670 undefined; 2671}(this, (function () { 'use strict'; 2672 2673function objectOrFunction(x) { 2674 var type = typeof x; 2675 return x !== null && (type === 'object' || type === 'function'); 2676} 2677 2678function isFunction(x) { 2679 return typeof x === 'function'; 2680} 2681 2682 2683 2684var _isArray = void 0; 2685if (Array.isArray) { 2686 _isArray = Array.isArray; 2687} else { 2688 _isArray = function (x) { 2689 return Object.prototype.toString.call(x) === '[object Array]'; 2690 }; 2691} 2692 2693var isArray = _isArray; 2694 2695var len = 0; 2696var vertxNext = void 0; 2697var customSchedulerFn = void 0; 2698 2699var asap = function asap(callback, arg) { 2700 queue[len] = callback; 2701 queue[len + 1] = arg; 2702 len += 2; 2703 if (len === 2) { 2704 // If len is 2, that means that we need to schedule an async flush. 2705 // If additional callbacks are queued before the queue is flushed, they 2706 // will be processed by this flush that we are scheduling. 2707 if (customSchedulerFn) { 2708 customSchedulerFn(flush); 2709 } else { 2710 scheduleFlush(); 2711 } 2712 } 2713}; 2714 2715function setScheduler(scheduleFn) { 2716 customSchedulerFn = scheduleFn; 2717} 2718 2719function setAsap(asapFn) { 2720 asap = asapFn; 2721} 2722 2723var browserWindow = typeof window !== 'undefined' ? window : undefined; 2724var browserGlobal = browserWindow || {}; 2725var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; 2726var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; 2727 2728// test for web worker but not in IE10 2729var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; 2730 2731// node 2732function useNextTick() { 2733 // node version 0.10.x displays a deprecation warning when nextTick is used recursively 2734 // see https://github.com/cujojs/when/issues/410 for details 2735 return function () { 2736 return process.nextTick(flush); 2737 }; 2738} 2739 2740// vertx 2741function useVertxTimer() { 2742 if (typeof vertxNext !== 'undefined') { 2743 return function () { 2744 vertxNext(flush); 2745 }; 2746 } 2747 2748 return useSetTimeout(); 2749} 2750 2751function useMutationObserver() { 2752 var iterations = 0; 2753 var observer = new BrowserMutationObserver(flush); 2754 var node = document.createTextNode(''); 2755 observer.observe(node, { characterData: true }); 2756 2757 return function () { 2758 node.data = iterations = ++iterations % 2; 2759 }; 2760} 2761 2762// web worker 2763function useMessageChannel() { 2764 var channel = new MessageChannel(); 2765 channel.port1.onmessage = flush; 2766 return function () { 2767 return channel.port2.postMessage(0); 2768 }; 2769} 2770 2771function useSetTimeout() { 2772 // Store setTimeout reference so es6-promise will be unaffected by 2773 // other code modifying setTimeout (like sinon.useFakeTimers()) 2774 var globalSetTimeout = setTimeout; 2775 return function () { 2776 return globalSetTimeout(flush, 1); 2777 }; 2778} 2779 2780var queue = new Array(1000); 2781function flush() { 2782 for (var i = 0; i < len; i += 2) { 2783 var callback = queue[i]; 2784 var arg = queue[i + 1]; 2785 2786 callback(arg); 2787 2788 queue[i] = undefined; 2789 queue[i + 1] = undefined; 2790 } 2791 2792 len = 0; 2793} 2794 2795function attemptVertx() { 2796 try { 2797 var vertx = Function('return this')().require('vertx'); 2798 vertxNext = vertx.runOnLoop || vertx.runOnContext; 2799 return useVertxTimer(); 2800 } catch (e) { 2801 return useSetTimeout(); 2802 } 2803} 2804 2805var scheduleFlush = void 0; 2806// Decide what async method to use to triggering processing of queued callbacks: 2807if (isNode) { 2808 scheduleFlush = useNextTick(); 2809} else if (BrowserMutationObserver) { 2810 scheduleFlush = useMutationObserver(); 2811} else if (isWorker) { 2812 scheduleFlush = useMessageChannel(); 2813} else if (browserWindow === undefined && "function" === 'function') { 2814 scheduleFlush = attemptVertx(); 2815} else { 2816 scheduleFlush = useSetTimeout(); 2817} 2818 2819function then(onFulfillment, onRejection) { 2820 var parent = this; 2821 2822 var child = new this.constructor(noop); 2823 2824 if (child[PROMISE_ID] === undefined) { 2825 makePromise(child); 2826 } 2827 2828 var _state = parent._state; 2829 2830 2831 if (_state) { 2832 var callback = arguments[_state - 1]; 2833 asap(function () { 2834 return invokeCallback(_state, child, callback, parent._result); 2835 }); 2836 } else { 2837 subscribe(parent, child, onFulfillment, onRejection); 2838 } 2839 2840 return child; 2841} 2842 2843/** 2844 `Promise.resolve` returns a promise that will become resolved with the 2845 passed `value`. It is shorthand for the following: 2846 2847 ```javascript 2848 let promise = new Promise(function(resolve, reject){ 2849 resolve(1); 2850 }); 2851 2852 promise.then(function(value){ 2853 // value === 1 2854 }); 2855 ``` 2856 2857 Instead of writing the above, your code now simply becomes the following: 2858 2859 ```javascript 2860 let promise = Promise.resolve(1); 2861 2862 promise.then(function(value){ 2863 // value === 1 2864 }); 2865 ``` 2866 2867 @method resolve 2868 @static 2869 @param {Any} value value that the returned promise will be resolved with 2870 Useful for tooling. 2871 @return {Promise} a promise that will become fulfilled with the given 2872 `value` 2873*/ 2874function resolve$1(object) { 2875 /*jshint validthis:true */ 2876 var Constructor = this; 2877 2878 if (object && typeof object === 'object' && object.constructor === Constructor) { 2879 return object; 2880 } 2881 2882 var promise = new Constructor(noop); 2883 resolve(promise, object); 2884 return promise; 2885} 2886 2887var PROMISE_ID = Math.random().toString(36).substring(2); 2888 2889function noop() {} 2890 2891var PENDING = void 0; 2892var FULFILLED = 1; 2893var REJECTED = 2; 2894 2895var TRY_CATCH_ERROR = { error: null }; 2896 2897function selfFulfillment() { 2898 return new TypeError("You cannot resolve a promise with itself"); 2899} 2900 2901function cannotReturnOwn() { 2902 return new TypeError('A promises callback cannot return that same promise.'); 2903} 2904 2905function getThen(promise) { 2906 try { 2907 return promise.then; 2908 } catch (error) { 2909 TRY_CATCH_ERROR.error = error; 2910 return TRY_CATCH_ERROR; 2911 } 2912} 2913 2914function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) { 2915 try { 2916 then$$1.call(value, fulfillmentHandler, rejectionHandler); 2917 } catch (e) { 2918 return e; 2919 } 2920} 2921 2922function handleForeignThenable(promise, thenable, then$$1) { 2923 asap(function (promise) { 2924 var sealed = false; 2925 var error = tryThen(then$$1, thenable, function (value) { 2926 if (sealed) { 2927 return; 2928 } 2929 sealed = true; 2930 if (thenable !== value) { 2931 resolve(promise, value); 2932 } else { 2933 fulfill(promise, value); 2934 } 2935 }, function (reason) { 2936 if (sealed) { 2937 return; 2938 } 2939 sealed = true; 2940 2941 reject(promise, reason); 2942 }, 'Settle: ' + (promise._label || ' unknown promise')); 2943 2944 if (!sealed && error) { 2945 sealed = true; 2946 reject(promise, error); 2947 } 2948 }, promise); 2949} 2950 2951function handleOwnThenable(promise, thenable) { 2952 if (thenable._state === FULFILLED) { 2953 fulfill(promise, thenable._result); 2954 } else if (thenable._state === REJECTED) { 2955 reject(promise, thenable._result); 2956 } else { 2957 subscribe(thenable, undefined, function (value) { 2958 return resolve(promise, value); 2959 }, function (reason) { 2960 return reject(promise, reason); 2961 }); 2962 } 2963} 2964 2965function handleMaybeThenable(promise, maybeThenable, then$$1) { 2966 if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) { 2967 handleOwnThenable(promise, maybeThenable); 2968 } else { 2969 if (then$$1 === TRY_CATCH_ERROR) { 2970 reject(promise, TRY_CATCH_ERROR.error); 2971 TRY_CATCH_ERROR.error = null; 2972 } else if (then$$1 === undefined) { 2973 fulfill(promise, maybeThenable); 2974 } else if (isFunction(then$$1)) { 2975 handleForeignThenable(promise, maybeThenable, then$$1); 2976 } else { 2977 fulfill(promise, maybeThenable); 2978 } 2979 } 2980} 2981 2982function resolve(promise, value) { 2983 if (promise === value) { 2984 reject(promise, selfFulfillment()); 2985 } else if (objectOrFunction(value)) { 2986 handleMaybeThenable(promise, value, getThen(value)); 2987 } else { 2988 fulfill(promise, value); 2989 } 2990} 2991 2992function publishRejection(promise) { 2993 if (promise._onerror) { 2994 promise._onerror(promise._result); 2995 } 2996 2997 publish(promise); 2998} 2999 3000function fulfill(promise, value) { 3001 if (promise._state !== PENDING) { 3002 return; 3003 } 3004 3005 promise._result = value; 3006 promise._state = FULFILLED; 3007 3008 if (promise._subscribers.length !== 0) { 3009 asap(publish, promise); 3010 } 3011} 3012 3013function reject(promise, reason) { 3014 if (promise._state !== PENDING) { 3015 return; 3016 } 3017 promise._state = REJECTED; 3018 promise._result = reason; 3019 3020 asap(publishRejection, promise); 3021} 3022 3023function subscribe(parent, child, onFulfillment, onRejection) { 3024 var _subscribers = parent._subscribers; 3025 var length = _subscribers.length; 3026 3027 3028 parent._onerror = null; 3029 3030 _subscribers[length] = child; 3031 _subscribers[length + FULFILLED] = onFulfillment; 3032 _subscribers[length + REJECTED] = onRejection; 3033 3034 if (length === 0 && parent._state) { 3035 asap(publish, parent); 3036 } 3037} 3038 3039function publish(promise) { 3040 var subscribers = promise._subscribers; 3041 var settled = promise._state; 3042 3043 if (subscribers.length === 0) { 3044 return; 3045 } 3046 3047 var child = void 0, 3048 callback = void 0, 3049 detail = promise._result; 3050 3051 for (var i = 0; i < subscribers.length; i += 3) { 3052 child = subscribers[i]; 3053 callback = subscribers[i + settled]; 3054 3055 if (child) { 3056 invokeCallback(settled, child, callback, detail); 3057 } else { 3058 callback(detail); 3059 } 3060 } 3061 3062 promise._subscribers.length = 0; 3063} 3064 3065function tryCatch(callback, detail) { 3066 try { 3067 return callback(detail); 3068 } catch (e) { 3069 TRY_CATCH_ERROR.error = e; 3070 return TRY_CATCH_ERROR; 3071 } 3072} 3073 3074function invokeCallback(settled, promise, callback, detail) { 3075 var hasCallback = isFunction(callback), 3076 value = void 0, 3077 error = void 0, 3078 succeeded = void 0, 3079 failed = void 0; 3080 3081 if (hasCallback) { 3082 value = tryCatch(callback, detail); 3083 3084 if (value === TRY_CATCH_ERROR) { 3085 failed = true; 3086 error = value.error; 3087 value.error = null; 3088 } else { 3089 succeeded = true; 3090 } 3091 3092 if (promise === value) { 3093 reject(promise, cannotReturnOwn()); 3094 return; 3095 } 3096 } else { 3097 value = detail; 3098 succeeded = true; 3099 } 3100 3101 if (promise._state !== PENDING) { 3102 // noop 3103 } else if (hasCallback && succeeded) { 3104 resolve(promise, value); 3105 } else if (failed) { 3106 reject(promise, error); 3107 } else if (settled === FULFILLED) { 3108 fulfill(promise, value); 3109 } else if (settled === REJECTED) { 3110 reject(promise, value); 3111 } 3112} 3113 3114function initializePromise(promise, resolver) { 3115 try { 3116 resolver(function resolvePromise(value) { 3117 resolve(promise, value); 3118 }, function rejectPromise(reason) { 3119 reject(promise, reason); 3120 }); 3121 } catch (e) { 3122 reject(promise, e); 3123 } 3124} 3125 3126var id = 0; 3127function nextId() { 3128 return id++; 3129} 3130 3131function makePromise(promise) { 3132 promise[PROMISE_ID] = id++; 3133 promise._state = undefined; 3134 promise._result = undefined; 3135 promise._subscribers = []; 3136} 3137 3138function validationError() { 3139 return new Error('Array Methods must be provided an Array'); 3140} 3141 3142var Enumerator = function () { 3143 function Enumerator(Constructor, input) { 3144 this._instanceConstructor = Constructor; 3145 this.promise = new Constructor(noop); 3146 3147 if (!this.promise[PROMISE_ID]) { 3148 makePromise(this.promise); 3149 } 3150 3151 if (isArray(input)) { 3152 this.length = input.length; 3153 this._remaining = input.length; 3154 3155 this._result = new Array(this.length); 3156 3157 if (this.length === 0) { 3158 fulfill(this.promise, this._result); 3159 } else { 3160 this.length = this.length || 0; 3161 this._enumerate(input); 3162 if (this._remaining === 0) { 3163 fulfill(this.promise, this._result); 3164 } 3165 } 3166 } else { 3167 reject(this.promise, validationError()); 3168 } 3169 } 3170 3171 Enumerator.prototype._enumerate = function _enumerate(input) { 3172 for (var i = 0; this._state === PENDING && i < input.length; i++) { 3173 this._eachEntry(input[i], i); 3174 } 3175 }; 3176 3177 Enumerator.prototype._eachEntry = function _eachEntry(entry, i) { 3178 var c = this._instanceConstructor; 3179 var resolve$$1 = c.resolve; 3180 3181 3182 if (resolve$$1 === resolve$1) { 3183 var _then = getThen(entry); 3184 3185 if (_then === then && entry._state !== PENDING) { 3186 this._settledAt(entry._state, i, entry._result); 3187 } else if (typeof _then !== 'function') { 3188 this._remaining--; 3189 this._result[i] = entry; 3190 } else if (c === Promise$1) { 3191 var promise = new c(noop); 3192 handleMaybeThenable(promise, entry, _then); 3193 this._willSettleAt(promise, i); 3194 } else { 3195 this._willSettleAt(new c(function (resolve$$1) { 3196 return resolve$$1(entry); 3197 }), i); 3198 } 3199 } else { 3200 this._willSettleAt(resolve$$1(entry), i); 3201 } 3202 }; 3203 3204 Enumerator.prototype._settledAt = function _settledAt(state, i, value) { 3205 var promise = this.promise; 3206 3207 3208 if (promise._state === PENDING) { 3209 this._remaining--; 3210 3211 if (state === REJECTED) { 3212 reject(promise, value); 3213 } else { 3214 this._result[i] = value; 3215 } 3216 } 3217 3218 if (this._remaining === 0) { 3219 fulfill(promise, this._result); 3220 } 3221 }; 3222 3223 Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) { 3224 var enumerator = this; 3225 3226 subscribe(promise, undefined, function (value) { 3227 return enumerator._settledAt(FULFILLED, i, value); 3228 }, function (reason) { 3229 return enumerator._settledAt(REJECTED, i, reason); 3230 }); 3231 }; 3232 3233 return Enumerator; 3234}(); 3235 3236/** 3237 `Promise.all` accepts an array of promises, and returns a new promise which 3238 is fulfilled with an array of fulfillment values for the passed promises, or 3239 rejected with the reason of the first passed promise to be rejected. It casts all 3240 elements of the passed iterable to promises as it runs this algorithm. 3241 3242 Example: 3243 3244 ```javascript 3245 let promise1 = resolve(1); 3246 let promise2 = resolve(2); 3247 let promise3 = resolve(3); 3248 let promises = [ promise1, promise2, promise3 ]; 3249 3250 Promise.all(promises).then(function(array){ 3251 // The array here would be [ 1, 2, 3 ]; 3252 }); 3253 ``` 3254 3255 If any of the `promises` given to `all` are rejected, the first promise 3256 that is rejected will be given as an argument to the returned promises's 3257 rejection handler. For example: 3258 3259 Example: 3260 3261 ```javascript 3262 let promise1 = resolve(1); 3263 let promise2 = reject(new Error("2")); 3264 let promise3 = reject(new Error("3")); 3265 let promises = [ promise1, promise2, promise3 ]; 3266 3267 Promise.all(promises).then(function(array){ 3268 // Code here never runs because there are rejected promises! 3269 }, function(error) { 3270 // error.message === "2" 3271 }); 3272 ``` 3273 3274 @method all 3275 @static 3276 @param {Array} entries array of promises 3277 @param {String} label optional string for labeling the promise. 3278 Useful for tooling. 3279 @return {Promise} promise that is fulfilled when all `promises` have been 3280 fulfilled, or rejected if any of them become rejected. 3281 @static 3282*/ 3283function all(entries) { 3284 return new Enumerator(this, entries).promise; 3285} 3286 3287/** 3288 `Promise.race` returns a new promise which is settled in the same way as the 3289 first passed promise to settle. 3290 3291 Example: 3292 3293 ```javascript 3294 let promise1 = new Promise(function(resolve, reject){ 3295 setTimeout(function(){ 3296 resolve('promise 1'); 3297 }, 200); 3298 }); 3299 3300 let promise2 = new Promise(function(resolve, reject){ 3301 setTimeout(function(){ 3302 resolve('promise 2'); 3303 }, 100); 3304 }); 3305 3306 Promise.race([promise1, promise2]).then(function(result){ 3307 // result === 'promise 2' because it was resolved before promise1 3308 // was resolved. 3309 }); 3310 ``` 3311 3312 `Promise.race` is deterministic in that only the state of the first 3313 settled promise matters. For example, even if other promises given to the 3314 `promises` array argument are resolved, but the first settled promise has 3315 become rejected before the other promises became fulfilled, the returned 3316 promise will become rejected: 3317 3318 ```javascript 3319 let promise1 = new Promise(function(resolve, reject){ 3320 setTimeout(function(){ 3321 resolve('promise 1'); 3322 }, 200); 3323 }); 3324 3325 let promise2 = new Promise(function(resolve, reject){ 3326 setTimeout(function(){ 3327 reject(new Error('promise 2')); 3328 }, 100); 3329 }); 3330 3331 Promise.race([promise1, promise2]).then(function(result){ 3332 // Code here never runs 3333 }, function(reason){ 3334 // reason.message === 'promise 2' because promise 2 became rejected before 3335 // promise 1 became fulfilled 3336 }); 3337 ``` 3338 3339 An example real-world use case is implementing timeouts: 3340 3341 ```javascript 3342 Promise.race([ajax('foo.json'), timeout(5000)]) 3343 ``` 3344 3345 @method race 3346 @static 3347 @param {Array} promises array of promises to observe 3348 Useful for tooling. 3349 @return {Promise} a promise which settles in the same way as the first passed 3350 promise to settle. 3351*/ 3352function race(entries) { 3353 /*jshint validthis:true */ 3354 var Constructor = this; 3355 3356 if (!isArray(entries)) { 3357 return new Constructor(function (_, reject) { 3358 return reject(new TypeError('You must pass an array to race.')); 3359 }); 3360 } else { 3361 return new Constructor(function (resolve, reject) { 3362 var length = entries.length; 3363 for (var i = 0; i < length; i++) { 3364 Constructor.resolve(entries[i]).then(resolve, reject); 3365 } 3366 }); 3367 } 3368} 3369 3370/** 3371 `Promise.reject` returns a promise rejected with the passed `reason`. 3372 It is shorthand for the following: 3373 3374 ```javascript 3375 let promise = new Promise(function(resolve, reject){ 3376 reject(new Error('WHOOPS')); 3377 }); 3378 3379 promise.then(function(value){ 3380 // Code here doesn't run because the promise is rejected! 3381 }, function(reason){ 3382 // reason.message === 'WHOOPS' 3383 }); 3384 ``` 3385 3386 Instead of writing the above, your code now simply becomes the following: 3387 3388 ```javascript 3389 let promise = Promise.reject(new Error('WHOOPS')); 3390 3391 promise.then(function(value){ 3392 // Code here doesn't run because the promise is rejected! 3393 }, function(reason){ 3394 // reason.message === 'WHOOPS' 3395 }); 3396 ``` 3397 3398 @method reject 3399 @static 3400 @param {Any} reason value that the returned promise will be rejected with. 3401 Useful for tooling. 3402 @return {Promise} a promise rejected with the given `reason`. 3403*/ 3404function reject$1(reason) { 3405 /*jshint validthis:true */ 3406 var Constructor = this; 3407 var promise = new Constructor(noop); 3408 reject(promise, reason); 3409 return promise; 3410} 3411 3412function needsResolver() { 3413 throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); 3414} 3415 3416function needsNew() { 3417 throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); 3418} 3419 3420/** 3421 Promise objects represent the eventual result of an asynchronous operation. The 3422 primary way of interacting with a promise is through its `then` method, which 3423 registers callbacks to receive either a promise's eventual value or the reason 3424 why the promise cannot be fulfilled. 3425 3426 Terminology 3427 ----------- 3428 3429 - `promise` is an object or function with a `then` method whose behavior conforms to this specification. 3430 - `thenable` is an object or function that defines a `then` method. 3431 - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). 3432 - `exception` is a value that is thrown using the throw statement. 3433 - `reason` is a value that indicates why a promise was rejected. 3434 - `settled` the final resting state of a promise, fulfilled or rejected. 3435 3436 A promise can be in one of three states: pending, fulfilled, or rejected. 3437 3438 Promises that are fulfilled have a fulfillment value and are in the fulfilled 3439 state. Promises that are rejected have a rejection reason and are in the 3440 rejected state. A fulfillment value is never a thenable. 3441 3442 Promises can also be said to *resolve* a value. If this value is also a 3443 promise, then the original promise's settled state will match the value's 3444 settled state. So a promise that *resolves* a promise that rejects will 3445 itself reject, and a promise that *resolves* a promise that fulfills will 3446 itself fulfill. 3447 3448 3449 Basic Usage: 3450 ------------ 3451 3452 ```js 3453 let promise = new Promise(function(resolve, reject) { 3454 // on success 3455 resolve(value); 3456 3457 // on failure 3458 reject(reason); 3459 }); 3460 3461 promise.then(function(value) { 3462 // on fulfillment 3463 }, function(reason) { 3464 // on rejection 3465 }); 3466 ``` 3467 3468 Advanced Usage: 3469 --------------- 3470 3471 Promises shine when abstracting away asynchronous interactions such as 3472 `XMLHttpRequest`s. 3473 3474 ```js 3475 function getJSON(url) { 3476 return new Promise(function(resolve, reject){ 3477 let xhr = new XMLHttpRequest(); 3478 3479 xhr.open('GET', url); 3480 xhr.onreadystatechange = handler; 3481 xhr.responseType = 'json'; 3482 xhr.setRequestHeader('Accept', 'application/json'); 3483 xhr.send(); 3484 3485 function handler() { 3486 if (this.readyState === this.DONE) { 3487 if (this.status === 200) { 3488 resolve(this.response); 3489 } else { 3490 reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); 3491 } 3492 } 3493 }; 3494 }); 3495 } 3496 3497 getJSON('/posts.json').then(function(json) { 3498 // on fulfillment 3499 }, function(reason) { 3500 // on rejection 3501 }); 3502 ``` 3503 3504 Unlike callbacks, promises are great composable primitives. 3505 3506 ```js 3507 Promise.all([ 3508 getJSON('/posts'), 3509 getJSON('/comments') 3510 ]).then(function(values){ 3511 values[0] // => postsJSON 3512 values[1] // => commentsJSON 3513 3514 return values; 3515 }); 3516 ``` 3517 3518 @class Promise 3519 @param {Function} resolver 3520 Useful for tooling. 3521 @constructor 3522*/ 3523 3524var Promise$1 = function () { 3525 function Promise(resolver) { 3526 this[PROMISE_ID] = nextId(); 3527 this._result = this._state = undefined; 3528 this._subscribers = []; 3529 3530 if (noop !== resolver) { 3531 typeof resolver !== 'function' && needsResolver(); 3532 this instanceof Promise ? initializePromise(this, resolver) : needsNew(); 3533 } 3534 } 3535 3536 /** 3537 The primary way of interacting with a promise is through its `then` method, 3538 which registers callbacks to receive either a promise's eventual value or the 3539 reason why the promise cannot be fulfilled. 3540 ```js 3541 findUser().then(function(user){ 3542 // user is available 3543 }, function(reason){ 3544 // user is unavailable, and you are given the reason why 3545 }); 3546 ``` 3547 Chaining 3548 -------- 3549 The return value of `then` is itself a promise. This second, 'downstream' 3550 promise is resolved with the return value of the first promise's fulfillment 3551 or rejection handler, or rejected if the handler throws an exception. 3552 ```js 3553 findUser().then(function (user) { 3554 return user.name; 3555 }, function (reason) { 3556 return 'default name'; 3557 }).then(function (userName) { 3558 // If `findUser` fulfilled, `userName` will be the user's name, otherwise it 3559 // will be `'default name'` 3560 }); 3561 findUser().then(function (user) { 3562 throw new Error('Found user, but still unhappy'); 3563 }, function (reason) { 3564 throw new Error('`findUser` rejected and we're unhappy'); 3565 }).then(function (value) { 3566 // never reached 3567 }, function (reason) { 3568 // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. 3569 // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. 3570 }); 3571 ``` 3572 If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. 3573 ```js 3574 findUser().then(function (user) { 3575 throw new PedagogicalException('Upstream error'); 3576 }).then(function (value) { 3577 // never reached 3578 }).then(function (value) { 3579 // never reached 3580 }, function (reason) { 3581 // The `PedgagocialException` is propagated all the way down to here 3582 }); 3583 ``` 3584 Assimilation 3585 ------------ 3586 Sometimes the value you want to propagate to a downstream promise can only be 3587 retrieved asynchronously. This can be achieved by returning a promise in the 3588 fulfillment or rejection handler. The downstream promise will then be pending 3589 until the returned promise is settled. This is called *assimilation*. 3590 ```js 3591 findUser().then(function (user) { 3592 return findCommentsByAuthor(user); 3593 }).then(function (comments) { 3594 // The user's comments are now available 3595 }); 3596 ``` 3597 If the assimliated promise rejects, then the downstream promise will also reject. 3598 ```js 3599 findUser().then(function (user) { 3600 return findCommentsByAuthor(user); 3601 }).then(function (comments) { 3602 // If `findCommentsByAuthor` fulfills, we'll have the value here 3603 }, function (reason) { 3604 // If `findCommentsByAuthor` rejects, we'll have the reason here 3605 }); 3606 ``` 3607 Simple Example 3608 -------------- 3609 Synchronous Example 3610 ```javascript 3611 let result; 3612 try { 3613 result = findResult(); 3614 // success 3615 } catch(reason) { 3616 // failure 3617 } 3618 ``` 3619 Errback Example 3620 ```js 3621 findResult(function(result, err){ 3622 if (err) { 3623 // failure 3624 } else { 3625 // success 3626 } 3627 }); 3628 ``` 3629 Promise Example; 3630 ```javascript 3631 findResult().then(function(result){ 3632 // success 3633 }, function(reason){ 3634 // failure 3635 }); 3636 ``` 3637 Advanced Example 3638 -------------- 3639 Synchronous Example 3640 ```javascript 3641 let author, books; 3642 try { 3643 author = findAuthor(); 3644 books = findBooksByAuthor(author); 3645 // success 3646 } catch(reason) { 3647 // failure 3648 } 3649 ``` 3650 Errback Example 3651 ```js 3652 function foundBooks(books) { 3653 } 3654 function failure(reason) { 3655 } 3656 findAuthor(function(author, err){ 3657 if (err) { 3658 failure(err); 3659 // failure 3660 } else { 3661 try { 3662 findBoooksByAuthor(author, function(books, err) { 3663 if (err) { 3664 failure(err); 3665 } else { 3666 try { 3667 foundBooks(books); 3668 } catch(reason) { 3669 failure(reason); 3670 } 3671 } 3672 }); 3673 } catch(error) { 3674 failure(err); 3675 } 3676 // success 3677 } 3678 }); 3679 ``` 3680 Promise Example; 3681 ```javascript 3682 findAuthor(). 3683 then(findBooksByAuthor). 3684 then(function(books){ 3685 // found books 3686 }).catch(function(reason){ 3687 // something went wrong 3688 }); 3689 ``` 3690 @method then 3691 @param {Function} onFulfilled 3692 @param {Function} onRejected 3693 Useful for tooling. 3694 @return {Promise} 3695 */ 3696 3697 /** 3698 `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same 3699 as the catch block of a try/catch statement. 3700 ```js 3701 function findAuthor(){ 3702 throw new Error('couldn't find that author'); 3703 } 3704 // synchronous 3705 try { 3706 findAuthor(); 3707 } catch(reason) { 3708 // something went wrong 3709 } 3710 // async with promises 3711 findAuthor().catch(function(reason){ 3712 // something went wrong 3713 }); 3714 ``` 3715 @method catch 3716 @param {Function} onRejection 3717 Useful for tooling. 3718 @return {Promise} 3719 */ 3720 3721 3722 Promise.prototype.catch = function _catch(onRejection) { 3723 return this.then(null, onRejection); 3724 }; 3725 3726 /** 3727 `finally` will be invoked regardless of the promise's fate just as native 3728 try/catch/finally behaves 3729 3730 Synchronous example: 3731 3732 ```js 3733 findAuthor() { 3734 if (Math.random() > 0.5) { 3735 throw new Error(); 3736 } 3737 return new Author(); 3738 } 3739 3740 try { 3741 return findAuthor(); // succeed or fail 3742 } catch(error) { 3743 return findOtherAuther(); 3744 } finally { 3745 // always runs 3746 // doesn't affect the return value 3747 } 3748 ``` 3749 3750 Asynchronous example: 3751 3752 ```js 3753 findAuthor().catch(function(reason){ 3754 return findOtherAuther(); 3755 }).finally(function(){ 3756 // author was either found, or not 3757 }); 3758 ``` 3759 3760 @method finally 3761 @param {Function} callback 3762 @return {Promise} 3763 */ 3764 3765 3766 Promise.prototype.finally = function _finally(callback) { 3767 var promise = this; 3768 var constructor = promise.constructor; 3769 3770 return promise.then(function (value) { 3771 return constructor.resolve(callback()).then(function () { 3772 return value; 3773 }); 3774 }, function (reason) { 3775 return constructor.resolve(callback()).then(function () { 3776 throw reason; 3777 }); 3778 }); 3779 }; 3780 3781 return Promise; 3782}(); 3783 3784Promise$1.prototype.then = then; 3785Promise$1.all = all; 3786Promise$1.race = race; 3787Promise$1.resolve = resolve$1; 3788Promise$1.reject = reject$1; 3789Promise$1._setScheduler = setScheduler; 3790Promise$1._setAsap = setAsap; 3791Promise$1._asap = asap; 3792 3793/*global self*/ 3794function polyfill() { 3795 var local = void 0; 3796 3797 if (typeof global !== 'undefined') { 3798 local = global; 3799 } else if (typeof self !== 'undefined') { 3800 local = self; 3801 } else { 3802 try { 3803 local = Function('return this')(); 3804 } catch (e) { 3805 throw new Error('polyfill failed because global object is unavailable in this environment'); 3806 } 3807 } 3808 3809 var P = local.Promise; 3810 3811 if (P) { 3812 var promiseToString = null; 3813 try { 3814 promiseToString = Object.prototype.toString.call(P.resolve()); 3815 } catch (e) { 3816 // silently ignored 3817 } 3818 3819 if (promiseToString === '[object Promise]' && !P.cast) { 3820 return; 3821 } 3822 } 3823 3824 local.Promise = Promise$1; 3825} 3826 3827// Strange compat.. 3828Promise$1.polyfill = polyfill; 3829Promise$1.Promise = Promise$1; 3830 3831return Promise$1; 3832 3833}))); 3834 3835 3836 3837//# sourceMappingURL=es6-promise.map 3838 3839/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js"), __webpack_require__(/*! ./../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))) 3840 3841/***/ }), 3842
vendor: 1,276 bytes, lines 3843-3886
3843/***/ "./node_modules/fbjs/lib/ExecutionEnvironment.js": 3844/*!*******************************************************!*\ 3845 !*** ./node_modules/fbjs/lib/ExecutionEnvironment.js ***! 3846 \*******************************************************/ 3847/*! no static exports found */ 3848/***/ (function(module, exports, __webpack_require__) { 3849 3850"use strict"; 3851/** 3852 * Copyright (c) 2013-present, Facebook, Inc. 3853 * 3854 * This source code is licensed under the MIT license found in the 3855 * LICENSE file in the root directory of this source tree. 3856 * 3857 */ 3858 3859 3860 3861var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); 3862 3863/** 3864 * Simple, lightweight module assisting with the detection and context of 3865 * Worker. Helps avoid circular dependencies and allows code to reason about 3866 * whether or not they are in a Worker, even if they never include the main 3867 * `ReactWorker` dependency. 3868 */ 3869var ExecutionEnvironment = { 3870 3871 canUseDOM: canUseDOM, 3872 3873 canUseWorkers: typeof Worker !== 'undefined', 3874 3875 canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent), 3876 3877 canUseViewport: canUseDOM && !!window.screen, 3878 3879 isInWorker: !canUseDOM // For now, this is true - might change in the future. 3880 3881}; 3882 3883module.exports = ExecutionEnvironment; 3884 3885/***/ }), 3886
vendor: 875 bytes, lines 3887-3926
3887/***/ "./node_modules/fbjs/lib/camelize.js": 3888/*!*******************************************!*\ 3889 !*** ./node_modules/fbjs/lib/camelize.js ***! 3890 \*******************************************/ 3891/*! no static exports found */ 3892/***/ (function(module, exports, __webpack_require__) { 3893 3894"use strict"; 3895 3896 3897/** 3898 * Copyright (c) 2013-present, Facebook, Inc. 3899 * 3900 * This source code is licensed under the MIT license found in the 3901 * LICENSE file in the root directory of this source tree. 3902 * 3903 * @typechecks 3904 */ 3905 3906var _hyphenPattern = /-(.)/g; 3907 3908/** 3909 * Camelcases a hyphenated string, for example: 3910 * 3911 * > camelize('background-color') 3912 * < "backgroundColor" 3913 * 3914 * @param {string} string 3915 * @return {string} 3916 */ 3917function camelize(string) { 3918 return string.replace(_hyphenPattern, function (_, character) { 3919 return character.toUpperCase(); 3920 }); 3921} 3922 3923module.exports = camelize; 3924 3925/***/ }), 3926
vendor: 1,259 bytes, lines 3927-3974
3927/***/ "./node_modules/fbjs/lib/camelizeStyleName.js": 3928/*!****************************************************!*\ 3929 !*** ./node_modules/fbjs/lib/camelizeStyleName.js ***! 3930 \****************************************************/ 3931/*! no static exports found */ 3932/***/ (function(module, exports, __webpack_require__) { 3933 3934"use strict"; 3935/** 3936 * Copyright (c) 2013-present, Facebook, Inc. 3937 * 3938 * This source code is licensed under the MIT license found in the 3939 * LICENSE file in the root directory of this source tree. 3940 * 3941 * @typechecks 3942 */ 3943 3944 3945 3946var camelize = __webpack_require__(/*! ./camelize */ "./node_modules/fbjs/lib/camelize.js"); 3947 3948var msPattern = /^-ms-/; 3949 3950/** 3951 * Camelcases a hyphenated CSS property name, for example: 3952 * 3953 * > camelizeStyleName('background-color') 3954 * < "backgroundColor" 3955 * > camelizeStyleName('-moz-transition') 3956 * < "MozTransition" 3957 * > camelizeStyleName('-ms-transition') 3958 * < "msTransition" 3959 * 3960 * As Andi Smith suggests 3961 * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix 3962 * is converted to lowercase `ms`. 3963 * 3964 * @param {string} string 3965 * @return {string} 3966 */ 3967function camelizeStyleName(string) { 3968 return camelize(string.replace(msPattern, 'ms-')); 3969} 3970 3971module.exports = camelizeStyleName; 3972 3973/***/ }), 3974
vendor: 1,289 bytes, lines 3975-4022
3975/***/ "./node_modules/fbjs/lib/containsNode.js": 3976/*!***********************************************!*\ 3977 !*** ./node_modules/fbjs/lib/containsNode.js ***! 3978 \***********************************************/ 3979/*! no static exports found */ 3980/***/ (function(module, exports, __webpack_require__) { 3981 3982"use strict"; 3983 3984 3985/** 3986 * Copyright (c) 2013-present, Facebook, Inc. 3987 * 3988 * This source code is licensed under the MIT license found in the 3989 * LICENSE file in the root directory of this source tree. 3990 * 3991 * 3992 */ 3993 3994var isTextNode = __webpack_require__(/*! ./isTextNode */ "./node_modules/fbjs/lib/isTextNode.js"); 3995 3996/*eslint-disable no-bitwise */ 3997 3998/** 3999 * Checks if a given DOM node contains or is another DOM node. 4000 */ 4001function containsNode(outerNode, innerNode) { 4002 if (!outerNode || !innerNode) { 4003 return false; 4004 } else if (outerNode === innerNode) { 4005 return true; 4006 } else if (isTextNode(outerNode)) { 4007 return false; 4008 } else if (isTextNode(innerNode)) { 4009 return containsNode(outerNode, innerNode.parentNode); 4010 } else if ('contains' in outerNode) { 4011 return outerNode.contains(innerNode); 4012 } else if (outerNode.compareDocumentPosition) { 4013 return !!(outerNode.compareDocumentPosition(innerNode) & 16); 4014 } else { 4015 return false; 4016 } 4017} 4018 4019module.exports = containsNode; 4020 4021/***/ }), 4022
vendor: 1,272 bytes, lines 4023-4069
4023/***/ "./node_modules/fbjs/lib/emptyFunction.js": 4024/*!************************************************!*\ 4025 !*** ./node_modules/fbjs/lib/emptyFunction.js ***! 4026 \************************************************/ 4027/*! no static exports found */ 4028/***/ (function(module, exports, __webpack_require__) { 4029 4030"use strict"; 4031 4032 4033/** 4034 * Copyright (c) 2013-present, Facebook, Inc. 4035 * 4036 * This source code is licensed under the MIT license found in the 4037 * LICENSE file in the root directory of this source tree. 4038 * 4039 * 4040 */ 4041 4042function makeEmptyFunction(arg) { 4043 return function () { 4044 return arg; 4045 }; 4046} 4047 4048/** 4049 * This function accepts and discards inputs; it has no side effects. This is 4050 * primarily useful idiomatically for overridable function endpoints which 4051 * always need to be callable, since JS lacks a null-call idiom ala Cocoa. 4052 */ 4053var emptyFunction = function emptyFunction() {}; 4054 4055emptyFunction.thatReturns = makeEmptyFunction; 4056emptyFunction.thatReturnsFalse = makeEmptyFunction(false); 4057emptyFunction.thatReturnsTrue = makeEmptyFunction(true); 4058emptyFunction.thatReturnsNull = makeEmptyFunction(null); 4059emptyFunction.thatReturnsThis = function () { 4060 return this; 4061}; 4062emptyFunction.thatReturnsArgument = function (arg) { 4063 return arg; 4064}; 4065 4066module.exports = emptyFunction; 4067 4068/***/ }), 4069
vendor: 604 bytes, lines 4070-4097
4070/***/ "./node_modules/fbjs/lib/emptyObject.js": 4071/*!**********************************************!*\ 4072 !*** ./node_modules/fbjs/lib/emptyObject.js ***! 4073 \**********************************************/ 4074/*! no static exports found */ 4075/***/ (function(module, exports, __webpack_require__) { 4076 4077"use strict"; 4078/** 4079 * Copyright (c) 2013-present, Facebook, Inc. 4080 * 4081 * This source code is licensed under the MIT license found in the 4082 * LICENSE file in the root directory of this source tree. 4083 * 4084 */ 4085 4086 4087 4088var emptyObject = {}; 4089 4090if (true) { 4091 Object.freeze(emptyObject); 4092} 4093 4094module.exports = emptyObject; 4095 4096/***/ }), 4097
vendor: 1,237 bytes, lines 4098-4144
4098/***/ "./node_modules/fbjs/lib/getActiveElement.js": 4099/*!***************************************************!*\ 4100 !*** ./node_modules/fbjs/lib/getActiveElement.js ***! 4101 \***************************************************/ 4102/*! no static exports found */ 4103/***/ (function(module, exports, __webpack_require__) { 4104 4105"use strict"; 4106 4107 4108/** 4109 * Copyright (c) 2013-present, Facebook, Inc. 4110 * 4111 * This source code is licensed under the MIT license found in the 4112 * LICENSE file in the root directory of this source tree. 4113 * 4114 * @typechecks 4115 */ 4116 4117/* eslint-disable fb-www/typeof-undefined */ 4118 4119/** 4120 * Same as document.activeElement but wraps in a try-catch block. In IE it is 4121 * not safe to call document.activeElement if there is nothing focused. 4122 * 4123 * The activeElement will be null only if the document or document body is not 4124 * yet defined. 4125 * 4126 * @param {?DOMDocument} doc Defaults to current document. 4127 * @return {?DOMElement} 4128 */ 4129function getActiveElement(doc) /*?DOMElement*/{ 4130 doc = doc || (typeof document !== 'undefined' ? document : undefined); 4131 if (typeof doc === 'undefined') { 4132 return null; 4133 } 4134 try { 4135 return doc.activeElement || doc.body; 4136 } catch (e) { 4137 return doc.body; 4138 } 4139} 4140 4141module.exports = getActiveElement; 4142 4143/***/ }), 4144
vendor: 971 bytes, lines 4145-4185
4145/***/ "./node_modules/fbjs/lib/hyphenate.js": 4146/*!********************************************!*\ 4147 !*** ./node_modules/fbjs/lib/hyphenate.js ***! 4148 \********************************************/ 4149/*! no static exports found */ 4150/***/ (function(module, exports, __webpack_require__) { 4151 4152"use strict"; 4153 4154 4155/** 4156 * Copyright (c) 2013-present, Facebook, Inc. 4157 * 4158 * This source code is licensed under the MIT license found in the 4159 * LICENSE file in the root directory of this source tree. 4160 * 4161 * @typechecks 4162 */ 4163 4164var _uppercasePattern = /([A-Z])/g; 4165 4166/** 4167 * Hyphenates a camelcased string, for example: 4168 * 4169 * > hyphenate('backgroundColor') 4170 * < "background-color" 4171 * 4172 * For CSS style names, use `hyphenateStyleName` instead which works properly 4173 * with all vendor prefixes, including `ms`. 4174 * 4175 * @param {string} string 4176 * @return {string} 4177 */ 4178function hyphenate(string) { 4179 return string.replace(_uppercasePattern, '-$1').toLowerCase(); 4180} 4181 4182module.exports = hyphenate; 4183 4184/***/ }), 4185
vendor: 1,237 bytes, lines 4186-4232
4186/***/ "./node_modules/fbjs/lib/hyphenateStyleName.js": 4187/*!*****************************************************!*\ 4188 !*** ./node_modules/fbjs/lib/hyphenateStyleName.js ***! 4189 \*****************************************************/ 4190/*! no static exports found */ 4191/***/ (function(module, exports, __webpack_require__) { 4192 4193"use strict"; 4194/** 4195 * Copyright (c) 2013-present, Facebook, Inc. 4196 * 4197 * This source code is licensed under the MIT license found in the 4198 * LICENSE file in the root directory of this source tree. 4199 * 4200 * @typechecks 4201 */ 4202 4203 4204 4205var hyphenate = __webpack_require__(/*! ./hyphenate */ "./node_modules/fbjs/lib/hyphenate.js"); 4206 4207var msPattern = /^ms-/; 4208 4209/** 4210 * Hyphenates a camelcased CSS property name, for example: 4211 * 4212 * > hyphenateStyleName('backgroundColor') 4213 * < "background-color" 4214 * > hyphenateStyleName('MozTransition') 4215 * < "-moz-transition" 4216 * > hyphenateStyleName('msTransition') 4217 * < "-ms-transition" 4218 * 4219 * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix 4220 * is converted to `-ms-`. 4221 * 4222 * @param {string} string 4223 * @return {string} 4224 */ 4225function hyphenateStyleName(string) { 4226 return hyphenate(string).replace(msPattern, '-ms-'); 4227} 4228 4229module.exports = hyphenateStyleName; 4230 4231/***/ }), 4232
vendor: 1,770 bytes, lines 4233-4296
4233/***/ "./node_modules/fbjs/lib/invariant.js": 4234/*!********************************************!*\ 4235 !*** ./node_modules/fbjs/lib/invariant.js ***! 4236 \********************************************/ 4237/*! no static exports found */ 4238/***/ (function(module, exports, __webpack_require__) { 4239 4240"use strict"; 4241/** 4242 * Copyright (c) 2013-present, Facebook, Inc. 4243 * 4244 * This source code is licensed under the MIT license found in the 4245 * LICENSE file in the root directory of this source tree. 4246 * 4247 */ 4248 4249 4250 4251/** 4252 * Use invariant() to assert state which your program assumes to be true. 4253 * 4254 * Provide sprintf-style format (only %s is supported) and arguments 4255 * to provide information about what broke and what you were 4256 * expecting. 4257 * 4258 * The invariant message will be stripped in production, but the invariant 4259 * will remain to ensure logic does not differ in production. 4260 */ 4261 4262var validateFormat = function validateFormat(format) {}; 4263 4264if (true) { 4265 validateFormat = function validateFormat(format) { 4266 if (format === undefined) { 4267 throw new Error('invariant requires an error message argument'); 4268 } 4269 }; 4270} 4271 4272function invariant(condition, format, a, b, c, d, e, f) { 4273 validateFormat(format); 4274 4275 if (!condition) { 4276 var error; 4277 if (format === undefined) { 4278 error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); 4279 } else { 4280 var args = [a, b, c, d, e, f]; 4281 var argIndex = 0; 4282 error = new Error(format.replace(/%s/g, function () { 4283 return args[argIndex++]; 4284 })); 4285 error.name = 'Invariant Violation'; 4286 } 4287 4288 error.framesToPop = 1; // we don't care about invariant's own frame 4289 throw error; 4290 } 4291} 4292 4293module.exports = invariant; 4294 4295/***/ }), 4296
vendor: 987 bytes, lines 4297-4329
4297/***/ "./node_modules/fbjs/lib/isNode.js": 4298/*!*****************************************!*\ 4299 !*** ./node_modules/fbjs/lib/isNode.js ***! 4300 \*****************************************/ 4301/*! no static exports found */ 4302/***/ (function(module, exports, __webpack_require__) { 4303 4304"use strict"; 4305 4306 4307/** 4308 * Copyright (c) 2013-present, Facebook, Inc. 4309 * 4310 * This source code is licensed under the MIT license found in the 4311 * LICENSE file in the root directory of this source tree. 4312 * 4313 * @typechecks 4314 */ 4315 4316/** 4317 * @param {*} object The object to check. 4318 * @return {boolean} Whether or not the object is a DOM node. 4319 */ 4320function isNode(object) { 4321 var doc = object ? object.ownerDocument || object : document; 4322 var defaultView = doc.defaultView || window; 4323 return !!(object && (typeof defaultView.Node === 'function' ? object instanceof defaultView.Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string')); 4324} 4325 4326module.exports = isNode; 4327 4328/***/ }), 4329
vendor: 833 bytes, lines 4330-4362
4330/***/ "./node_modules/fbjs/lib/isTextNode.js": 4331/*!*********************************************!*\ 4332 !*** ./node_modules/fbjs/lib/isTextNode.js ***! 4333 \*********************************************/ 4334/*! no static exports found */ 4335/***/ (function(module, exports, __webpack_require__) { 4336 4337"use strict"; 4338 4339 4340/** 4341 * Copyright (c) 2013-present, Facebook, Inc. 4342 * 4343 * This source code is licensed under the MIT license found in the 4344 * LICENSE file in the root directory of this source tree. 4345 * 4346 * @typechecks 4347 */ 4348 4349var isNode = __webpack_require__(/*! ./isNode */ "./node_modules/fbjs/lib/isNode.js"); 4350 4351/** 4352 * @param {*} object The object to check. 4353 * @return {boolean} Whether or not the object is a DOM text node. 4354 */ 4355function isTextNode(object) { 4356 return isNode(object) && object.nodeType == 3; 4357} 4358 4359module.exports = isTextNode; 4360 4361/***/ }), 4362
vendor: 1,925 bytes, lines 4363-4438
4363/***/ "./node_modules/fbjs/lib/shallowEqual.js": 4364/*!***********************************************!*\ 4365 !*** ./node_modules/fbjs/lib/shallowEqual.js ***! 4366 \***********************************************/ 4367/*! no static exports found */ 4368/***/ (function(module, exports, __webpack_require__) { 4369 4370"use strict"; 4371/** 4372 * Copyright (c) 2013-present, Facebook, Inc. 4373 * 4374 * This source code is licensed under the MIT license found in the 4375 * LICENSE file in the root directory of this source tree. 4376 * 4377 * @typechecks 4378 * 4379 */ 4380 4381/*eslint-disable no-self-compare */ 4382 4383 4384 4385var hasOwnProperty = Object.prototype.hasOwnProperty; 4386 4387/** 4388 * inlined Object.is polyfill to avoid requiring consumers ship their own 4389 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is 4390 */ 4391function is(x, y) { 4392 // SameValue algorithm 4393 if (x === y) { 4394 // Steps 1-5, 7-10 4395 // Steps 6.b-6.e: +0 != -0 4396 // Added the nonzero y check to make Flow happy, but it is redundant 4397 return x !== 0 || y !== 0 || 1 / x === 1 / y; 4398 } else { 4399 // Step 6.a: NaN == NaN 4400 return x !== x && y !== y; 4401 } 4402} 4403 4404/** 4405 * Performs equality by iterating through keys on an object and returning false 4406 * when any key has values which are not strictly equal between the arguments. 4407 * Returns true when the values of all keys are strictly equal. 4408 */ 4409function shallowEqual(objA, objB) { 4410 if (is(objA, objB)) { 4411 return true; 4412 } 4413 4414 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { 4415 return false; 4416 } 4417 4418 var keysA = Object.keys(objA); 4419 var keysB = Object.keys(objB); 4420 4421 if (keysA.length !== keysB.length) { 4422 return false; 4423 } 4424 4425 // Test for A's keys different from B. 4426 for (var i = 0; i < keysA.length; i++) { 4427 if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) { 4428 return false; 4429 } 4430 } 4431 4432 return true; 4433} 4434 4435module.exports = shallowEqual; 4436 4437/***/ }), 4438
vendor: 2,213 bytes, lines 4439-4511
4439/***/ "./node_modules/fbjs/lib/warning.js": 4440/*!******************************************!*\ 4441 !*** ./node_modules/fbjs/lib/warning.js ***! 4442 \******************************************/ 4443/*! no static exports found */ 4444/***/ (function(module, exports, __webpack_require__) { 4445 4446"use strict"; 4447/** 4448 * Copyright (c) 2014-present, Facebook, Inc. 4449 * 4450 * This source code is licensed under the MIT license found in the 4451 * LICENSE file in the root directory of this source tree. 4452 * 4453 */ 4454 4455 4456 4457var emptyFunction = __webpack_require__(/*! ./emptyFunction */ "./node_modules/fbjs/lib/emptyFunction.js"); 4458 4459/** 4460 * Similar to invariant but only logs a warning if the condition is not met. 4461 * This can be used to log issues in development environments in critical 4462 * paths. Removing the logging code for production environments will keep the 4463 * same logic and follow the same code paths. 4464 */ 4465 4466var warning = emptyFunction; 4467 4468if (true) { 4469 var printWarning = function printWarning(format) { 4470 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 4471 args[_key - 1] = arguments[_key]; 4472 } 4473 4474 var argIndex = 0; 4475 var message = 'Warning: ' + format.replace(/%s/g, function () { 4476 return args[argIndex++]; 4477 }); 4478 if (typeof console !== 'undefined') { 4479 console.error(message); 4480 } 4481 try { 4482 // --- Welcome to debugging React --- 4483 // This error was thrown as a convenience so that you can use this stack 4484 // to find the callsite that caused this warning to fire. 4485 throw new Error(message); 4486 } catch (x) {} 4487 }; 4488 4489 warning = function warning(condition, format) { 4490 if (format === undefined) { 4491 throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); 4492 } 4493 4494 if (format.indexOf('Failed Composite propType: ') === 0) { 4495 return; // Ignore CompositeComponent proptype check. 4496 } 4497 4498 if (!condition) { 4499 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { 4500 args[_key2 - 2] = arguments[_key2]; 4501 } 4502 4503 printWarning.apply(undefined, [format].concat(args)); 4504 } 4505 }; 4506} 4507 4508module.exports = warning; 4509 4510/***/ }), 4511
vendor: 2,522 bytes, lines 4512-4591
4512/***/ "./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js": 4513/*!**********************************************************************************!*\ 4514 !*** ./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js ***! 4515 \**********************************************************************************/ 4516/*! no static exports found */ 4517/***/ (function(module, exports, __webpack_require__) { 4518 4519"use strict"; 4520 4521 4522/** 4523 * Copyright 2015, Yahoo! Inc. 4524 * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. 4525 */ 4526var REACT_STATICS = { 4527 childContextTypes: true, 4528 contextTypes: true, 4529 defaultProps: true, 4530 displayName: true, 4531 getDefaultProps: true, 4532 getDerivedStateFromProps: true, 4533 mixins: true, 4534 propTypes: true, 4535 type: true 4536}; 4537 4538var KNOWN_STATICS = { 4539 name: true, 4540 length: true, 4541 prototype: true, 4542 caller: true, 4543 callee: true, 4544 arguments: true, 4545 arity: true 4546}; 4547 4548var defineProperty = Object.defineProperty; 4549var getOwnPropertyNames = Object.getOwnPropertyNames; 4550var getOwnPropertySymbols = Object.getOwnPropertySymbols; 4551var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 4552var getPrototypeOf = Object.getPrototypeOf; 4553var objectPrototype = getPrototypeOf && getPrototypeOf(Object); 4554 4555function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) { 4556 if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components 4557 4558 if (objectPrototype) { 4559 var inheritedComponent = getPrototypeOf(sourceComponent); 4560 if (inheritedComponent && inheritedComponent !== objectPrototype) { 4561 hoistNonReactStatics(targetComponent, inheritedComponent, blacklist); 4562 } 4563 } 4564 4565 var keys = getOwnPropertyNames(sourceComponent); 4566 4567 if (getOwnPropertySymbols) { 4568 keys = keys.concat(getOwnPropertySymbols(sourceComponent)); 4569 } 4570 4571 for (var i = 0; i < keys.length; ++i) { 4572 var key = keys[i]; 4573 if (!REACT_STATICS[key] && !KNOWN_STATICS[key] && (!blacklist || !blacklist[key])) { 4574 var descriptor = getOwnPropertyDescriptor(sourceComponent, key); 4575 try { // Avoid failures from read-only properties 4576 defineProperty(targetComponent, key, descriptor); 4577 } catch (e) {} 4578 } 4579 } 4580 4581 return targetComponent; 4582 } 4583 4584 return targetComponent; 4585} 4586 4587module.exports = hoistNonReactStatics; 4588 4589 4590/***/ }), 4591
vendor: 1,657 bytes, lines 4592-4652
4592/***/ "./node_modules/invariant/browser.js": 4593/*!*******************************************!*\ 4594 !*** ./node_modules/invariant/browser.js ***! 4595 \*******************************************/ 4596/*! no static exports found */ 4597/***/ (function(module, exports, __webpack_require__) { 4598 4599"use strict"; 4600/** 4601 * Copyright (c) 2013-present, Facebook, Inc. 4602 * 4603 * This source code is licensed under the MIT license found in the 4604 * LICENSE file in the root directory of this source tree. 4605 */ 4606 4607 4608 4609/** 4610 * Use invariant() to assert state which your program assumes to be true. 4611 * 4612 * Provide sprintf-style format (only %s is supported) and arguments 4613 * to provide information about what broke and what you were 4614 * expecting. 4615 * 4616 * The invariant message will be stripped in production, but the invariant 4617 * will remain to ensure logic does not differ in production. 4618 */ 4619 4620var invariant = function(condition, format, a, b, c, d, e, f) { 4621 if (true) { 4622 if (format === undefined) { 4623 throw new Error('invariant requires an error message argument'); 4624 } 4625 } 4626 4627 if (!condition) { 4628 var error; 4629 if (format === undefined) { 4630 error = new Error( 4631 'Minified exception occurred; use the non-minified dev environment ' + 4632 'for the full error message and additional helpful warnings.' 4633 ); 4634 } else { 4635 var args = [a, b, c, d, e, f]; 4636 var argIndex = 0; 4637 error = new Error( 4638 format.replace(/%s/g, function() { return args[argIndex++]; }) 4639 ); 4640 error.name = 'Invariant Violation'; 4641 } 4642 4643 error.framesToPop = 1; // we don't care about invariant's own frame 4644 throw error; 4645 } 4646}; 4647 4648module.exports = invariant; 4649 4650 4651/***/ }), 4652
vendor: 684 bytes, lines 4653-4672
4653/***/ "./node_modules/lodash-es/_Symbol.js": 4654/*!*******************************************!*\ 4655 !*** ./node_modules/lodash-es/_Symbol.js ***! 4656 \*******************************************/ 4657/*! exports provided: default */ 4658/***/ (function(module, __webpack_exports__, __webpack_require__) { 4659 4660"use strict"; 4661__webpack_require__.r(__webpack_exports__); 4662/* harmony import */ var _root_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_root.js */ "./node_modules/lodash-es/_root.js"); 4663 4664 4665/** Built-in value references. */ 4666var Symbol = _root_js__WEBPACK_IMPORTED_MODULE_0__["default"].Symbol; 4667 4668/* harmony default export */ __webpack_exports__["default"] = (Symbol); 4669 4670 4671/***/ }), 4672
vendor: 1,761 bytes, lines 4673-4716
4673/***/ "./node_modules/lodash-es/_baseGetTag.js": 4674/*!***********************************************!*\ 4675 !*** ./node_modules/lodash-es/_baseGetTag.js ***! 4676 \***********************************************/ 4677/*! exports provided: default */ 4678/***/ (function(module, __webpack_exports__, __webpack_require__) { 4679 4680"use strict"; 4681__webpack_require__.r(__webpack_exports__); 4682/* harmony import */ var _Symbol_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_Symbol.js */ "./node_modules/lodash-es/_Symbol.js"); 4683/* harmony import */ var _getRawTag_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_getRawTag.js */ "./node_modules/lodash-es/_getRawTag.js"); 4684/* harmony import */ var _objectToString_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_objectToString.js */ "./node_modules/lodash-es/_objectToString.js"); 4685 4686 4687 4688 4689/** `Object#toString` result references. */ 4690var nullTag = '[object Null]', 4691 undefinedTag = '[object Undefined]'; 4692 4693/** Built-in value references. */ 4694var symToStringTag = _Symbol_js__WEBPACK_IMPORTED_MODULE_0__["default"] ? _Symbol_js__WEBPACK_IMPORTED_MODULE_0__["default"].toStringTag : undefined; 4695 4696/** 4697 * The base implementation of `getTag` without fallbacks for buggy environments. 4698 * 4699 * @private 4700 * @param {*} value The value to query. 4701 * @returns {string} Returns the `toStringTag`. 4702 */ 4703function baseGetTag(value) { 4704 if (value == null) { 4705 return value === undefined ? undefinedTag : nullTag; 4706 } 4707 return (symToStringTag && symToStringTag in Object(value)) 4708 ? Object(_getRawTag_js__WEBPACK_IMPORTED_MODULE_1__["default"])(value) 4709 : Object(_objectToString_js__WEBPACK_IMPORTED_MODULE_2__["default"])(value); 4710} 4711 4712/* harmony default export */ __webpack_exports__["default"] = (baseGetTag); 4713 4714 4715/***/ }), 4716
vendor: 790 bytes, lines 4717-4734
4717/***/ "./node_modules/lodash-es/_freeGlobal.js": 4718/*!***********************************************!*\ 4719 !*** ./node_modules/lodash-es/_freeGlobal.js ***! 4720 \***********************************************/ 4721/*! exports provided: default */ 4722/***/ (function(module, __webpack_exports__, __webpack_require__) { 4723 4724"use strict"; 4725__webpack_require__.r(__webpack_exports__); 4726/* WEBPACK VAR INJECTION */(function(global) {/** Detect free variable `global` from Node.js. */ 4727var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; 4728 4729/* harmony default export */ __webpack_exports__["default"] = (freeGlobal); 4730 4731/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))) 4732 4733/***/ }), 4734
vendor: 764 bytes, lines 4735-4754
4735/***/ "./node_modules/lodash-es/_getPrototype.js": 4736/*!*************************************************!*\ 4737 !*** ./node_modules/lodash-es/_getPrototype.js ***! 4738 \*************************************************/ 4739/*! exports provided: default */ 4740/***/ (function(module, __webpack_exports__, __webpack_require__) { 4741 4742"use strict"; 4743__webpack_require__.r(__webpack_exports__); 4744/* harmony import */ var _overArg_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_overArg.js */ "./node_modules/lodash-es/_overArg.js"); 4745 4746 4747/** Built-in value references. */ 4748var getPrototype = Object(_overArg_js__WEBPACK_IMPORTED_MODULE_0__["default"])(Object.getPrototypeOf, Object); 4749 4750/* harmony default export */ __webpack_exports__["default"] = (getPrototype); 4751 4752 4753/***/ }), 4754
vendor: 1,763 bytes, lines 4755-4814
4755/***/ "./node_modules/lodash-es/_getRawTag.js": 4756/*!**********************************************!*\ 4757 !*** ./node_modules/lodash-es/_getRawTag.js ***! 4758 \**********************************************/ 4759/*! exports provided: default */ 4760/***/ (function(module, __webpack_exports__, __webpack_require__) { 4761 4762"use strict"; 4763__webpack_require__.r(__webpack_exports__); 4764/* harmony import */ var _Symbol_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_Symbol.js */ "./node_modules/lodash-es/_Symbol.js"); 4765 4766 4767/** Used for built-in method references. */ 4768var objectProto = Object.prototype; 4769 4770/** Used to check objects for own properties. */ 4771var hasOwnProperty = objectProto.hasOwnProperty; 4772 4773/** 4774 * Used to resolve the 4775 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 4776 * of values. 4777 */ 4778var nativeObjectToString = objectProto.toString; 4779 4780/** Built-in value references. */ 4781var symToStringTag = _Symbol_js__WEBPACK_IMPORTED_MODULE_0__["default"] ? _Symbol_js__WEBPACK_IMPORTED_MODULE_0__["default"].toStringTag : undefined; 4782 4783/** 4784 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 4785 * 4786 * @private 4787 * @param {*} value The value to query. 4788 * @returns {string} Returns the raw `toStringTag`. 4789 */ 4790function getRawTag(value) { 4791 var isOwn = hasOwnProperty.call(value, symToStringTag), 4792 tag = value[symToStringTag]; 4793 4794 try { 4795 value[symToStringTag] = undefined; 4796 var unmasked = true; 4797 } catch (e) {} 4798 4799 var result = nativeObjectToString.call(value); 4800 if (unmasked) { 4801 if (isOwn) { 4802 value[symToStringTag] = tag; 4803 } else { 4804 delete value[symToStringTag]; 4805 } 4806 } 4807 return result; 4808} 4809 4810/* harmony default export */ __webpack_exports__["default"] = (getRawTag); 4811 4812 4813/***/ }), 4814
vendor: 1,008 bytes, lines 4815-4849
4815/***/ "./node_modules/lodash-es/_objectToString.js": 4816/*!***************************************************!*\ 4817 !*** ./node_modules/lodash-es/_objectToString.js ***! 4818 \***************************************************/ 4819/*! exports provided: default */ 4820/***/ (function(module, __webpack_exports__, __webpack_require__) { 4821 4822"use strict"; 4823__webpack_require__.r(__webpack_exports__); 4824/** Used for built-in method references. */ 4825var objectProto = Object.prototype; 4826 4827/** 4828 * Used to resolve the 4829 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 4830 * of values. 4831 */ 4832var nativeObjectToString = objectProto.toString; 4833 4834/** 4835 * Converts `value` to a string using `Object.prototype.toString`. 4836 * 4837 * @private 4838 * @param {*} value The value to convert. 4839 * @returns {string} Returns the converted string. 4840 */ 4841function objectToString(value) { 4842 return nativeObjectToString.call(value); 4843} 4844 4845/* harmony default export */ __webpack_exports__["default"] = (objectToString); 4846 4847 4848/***/ }), 4849
vendor: 797 bytes, lines 4850-4877
4850/***/ "./node_modules/lodash-es/_overArg.js": 4851/*!********************************************!*\ 4852 !*** ./node_modules/lodash-es/_overArg.js ***! 4853 \********************************************/ 4854/*! exports provided: default */ 4855/***/ (function(module, __webpack_exports__, __webpack_require__) { 4856 4857"use strict"; 4858__webpack_require__.r(__webpack_exports__); 4859/** 4860 * Creates a unary function that invokes `func` with its argument transformed. 4861 * 4862 * @private 4863 * @param {Function} func The function to wrap. 4864 * @param {Function} transform The argument transform. 4865 * @returns {Function} Returns the new function. 4866 */ 4867function overArg(func, transform) { 4868 return function(arg) { 4869 return func(transform(arg)); 4870 }; 4871} 4872 4873/* harmony default export */ __webpack_exports__["default"] = (overArg); 4874 4875 4876/***/ }), 4877
vendor: 864 bytes, lines 4878-4900
4878/***/ "./node_modules/lodash-es/_root.js": 4879/*!*****************************************!*\ 4880 !*** ./node_modules/lodash-es/_root.js ***! 4881 \*****************************************/ 4882/*! exports provided: default */ 4883/***/ (function(module, __webpack_exports__, __webpack_require__) { 4884 4885"use strict"; 4886__webpack_require__.r(__webpack_exports__); 4887/* harmony import */ var _freeGlobal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_freeGlobal.js */ "./node_modules/lodash-es/_freeGlobal.js"); 4888 4889 4890/** Detect free variable `self`. */ 4891var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 4892 4893/** Used as a reference to the global object. */ 4894var root = _freeGlobal_js__WEBPACK_IMPORTED_MODULE_0__["default"] || freeSelf || Function('return this')(); 4895 4896/* harmony default export */ __webpack_exports__["default"] = (root); 4897 4898 4899/***/ }), 4900
vendor: 1,045 bytes, lines 4901-4942
4901/***/ "./node_modules/lodash-es/isObjectLike.js": 4902/*!************************************************!*\ 4903 !*** ./node_modules/lodash-es/isObjectLike.js ***! 4904 \************************************************/ 4905/*! exports provided: default */ 4906/***/ (function(module, __webpack_exports__, __webpack_require__) { 4907 4908"use strict"; 4909__webpack_require__.r(__webpack_exports__); 4910/** 4911 * Checks if `value` is object-like. A value is object-like if it's not `null` 4912 * and has a `typeof` result of "object". 4913 * 4914 * @static 4915 * @memberOf _ 4916 * @since 4.0.0 4917 * @category Lang 4918 * @param {*} value The value to check. 4919 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 4920 * @example 4921 * 4922 * _.isObjectLike({}); 4923 * // => true 4924 * 4925 * _.isObjectLike([1, 2, 3]); 4926 * // => true 4927 * 4928 * _.isObjectLike(_.noop); 4929 * // => false 4930 * 4931 * _.isObjectLike(null); 4932 * // => false 4933 */ 4934function isObjectLike(value) { 4935 return value != null && typeof value == 'object'; 4936} 4937 4938/* harmony default export */ __webpack_exports__["default"] = (isObjectLike); 4939 4940 4941/***/ }), 4942
vendor: 2,595 bytes, lines 4943-5020
4943/***/ "./node_modules/lodash-es/isPlainObject.js": 4944/*!*************************************************!*\ 4945 !*** ./node_modules/lodash-es/isPlainObject.js ***! 4946 \*************************************************/ 4947/*! exports provided: default */ 4948/***/ (function(module, __webpack_exports__, __webpack_require__) { 4949 4950"use strict"; 4951__webpack_require__.r(__webpack_exports__); 4952/* harmony import */ var _baseGetTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_baseGetTag.js */ "./node_modules/lodash-es/_baseGetTag.js"); 4953/* harmony import */ var _getPrototype_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_getPrototype.js */ "./node_modules/lodash-es/_getPrototype.js"); 4954/* harmony import */ var _isObjectLike_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./isObjectLike.js */ "./node_modules/lodash-es/isObjectLike.js"); 4955 4956 4957 4958 4959/** `Object#toString` result references. */ 4960var objectTag = '[object Object]'; 4961 4962/** Used for built-in method references. */ 4963var funcProto = Function.prototype, 4964 objectProto = Object.prototype; 4965 4966/** Used to resolve the decompiled source of functions. */ 4967var funcToString = funcProto.toString; 4968 4969/** Used to check objects for own properties. */ 4970var hasOwnProperty = objectProto.hasOwnProperty; 4971 4972/** Used to infer the `Object` constructor. */ 4973var objectCtorString = funcToString.call(Object); 4974 4975/** 4976 * Checks if `value` is a plain object, that is, an object created by the 4977 * `Object` constructor or one with a `[[Prototype]]` of `null`. 4978 * 4979 * @static 4980 * @memberOf _ 4981 * @since 0.8.0 4982 * @category Lang 4983 * @param {*} value The value to check. 4984 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 4985 * @example 4986 * 4987 * function Foo() { 4988 * this.a = 1; 4989 * } 4990 * 4991 * _.isPlainObject(new Foo); 4992 * // => false 4993 * 4994 * _.isPlainObject([1, 2, 3]); 4995 * // => false 4996 * 4997 * _.isPlainObject({ 'x': 0, 'y': 0 }); 4998 * // => true 4999 * 5000 * _.isPlainObject(Object.create(null)); 5001 * // => true 5002 */ 5003function isPlainObject(value) { 5004 if (!Object(_isObjectLike_js__WEBPACK_IMPORTED_MODULE_2__["default"])(value) || Object(_baseGetTag_js__WEBPACK_IMPORTED_MODULE_0__["default"])(value) != objectTag) { 5005 return false; 5006 } 5007 var proto = Object(_getPrototype_js__WEBPACK_IMPORTED_MODULE_1__["default"])(value); 5008 if (proto === null) { 5009 return true; 5010 } 5011 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 5012 return typeof Ctor == 'function' && Ctor instanceof Ctor && 5013 funcToString.call(Ctor) == objectCtorString; 5014} 5015 5016/* harmony default export */ __webpack_exports__["default"] = (isPlainObject); 5017 5018 5019/***/ }), 5020
vendor: 546,115 bytes, lines 5021-22277
5021/***/ "./node_modules/lodash/lodash.js": 5022/*!***************************************!*\ 5023 !*** ./node_modules/lodash/lodash.js ***! 5024 \***************************************/ 5025/*! no static exports found */ 5026/***/ (function(module, exports, __webpack_require__) { 5027 5028/* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/** 5029 * @license 5030 * Lodash <https://lodash.com/> 5031 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> 5032 * Released under MIT license <https://lodash.com/license> 5033 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> 5034 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 5035 */ 5036;(function() { 5037 5038 /** Used as a safe reference for `undefined` in pre-ES5 environments. */ 5039 var undefined; 5040 5041 /** Used as the semantic version number. */ 5042 var VERSION = '4.17.21'; 5043 5044 /** Used as the size to enable large array optimizations. */ 5045 var LARGE_ARRAY_SIZE = 200; 5046 5047 /** Error message constants. */ 5048 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', 5049 FUNC_ERROR_TEXT = 'Expected a function', 5050 INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`'; 5051 5052 /** Used to stand-in for `undefined` hash values. */ 5053 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 5054 5055 /** Used as the maximum memoize cache size. */ 5056 var MAX_MEMOIZE_SIZE = 500; 5057 5058 /** Used as the internal argument placeholder. */ 5059 var PLACEHOLDER = '__lodash_placeholder__'; 5060 5061 /** Used to compose bitmasks for cloning. */ 5062 var CLONE_DEEP_FLAG = 1, 5063 CLONE_FLAT_FLAG = 2, 5064 CLONE_SYMBOLS_FLAG = 4; 5065 5066 /** Used to compose bitmasks for value comparisons. */ 5067 var COMPARE_PARTIAL_FLAG = 1, 5068 COMPARE_UNORDERED_FLAG = 2; 5069 5070 /** Used to compose bitmasks for function metadata. */ 5071 var WRAP_BIND_FLAG = 1, 5072 WRAP_BIND_KEY_FLAG = 2, 5073 WRAP_CURRY_BOUND_FLAG = 4, 5074 WRAP_CURRY_FLAG = 8, 5075 WRAP_CURRY_RIGHT_FLAG = 16, 5076 WRAP_PARTIAL_FLAG = 32, 5077 WRAP_PARTIAL_RIGHT_FLAG = 64, 5078 WRAP_ARY_FLAG = 128, 5079 WRAP_REARG_FLAG = 256, 5080 WRAP_FLIP_FLAG = 512; 5081 5082 /** Used as default options for `_.truncate`. */ 5083 var DEFAULT_TRUNC_LENGTH = 30, 5084 DEFAULT_TRUNC_OMISSION = '...'; 5085 5086 /** Used to detect hot functions by number of calls within a span of milliseconds. */ 5087 var HOT_COUNT = 800, 5088 HOT_SPAN = 16; 5089 5090 /** Used to indicate the type of lazy iteratees. */ 5091 var LAZY_FILTER_FLAG = 1, 5092 LAZY_MAP_FLAG = 2, 5093 LAZY_WHILE_FLAG = 3; 5094 5095 /** Used as references for various `Number` constants. */ 5096 var INFINITY = 1 / 0, 5097 MAX_SAFE_INTEGER = 9007199254740991, 5098 MAX_INTEGER = 1.7976931348623157e+308, 5099 NAN = 0 / 0; 5100 5101 /** Used as references for the maximum length and index of an array. */ 5102 var MAX_ARRAY_LENGTH = 4294967295, 5103 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, 5104 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; 5105 5106 /** Used to associate wrap methods with their bit flags. */ 5107 var wrapFlags = [ 5108 ['ary', WRAP_ARY_FLAG], 5109 ['bind', WRAP_BIND_FLAG], 5110 ['bindKey', WRAP_BIND_KEY_FLAG], 5111 ['curry', WRAP_CURRY_FLAG], 5112 ['curryRight', WRAP_CURRY_RIGHT_FLAG], 5113 ['flip', WRAP_FLIP_FLAG], 5114 ['partial', WRAP_PARTIAL_FLAG], 5115 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], 5116 ['rearg', WRAP_REARG_FLAG] 5117 ]; 5118 5119 /** `Object#toString` result references. */ 5120 var argsTag = '[object Arguments]', 5121 arrayTag = '[object Array]', 5122 asyncTag = '[object AsyncFunction]', 5123 boolTag = '[object Boolean]', 5124 dateTag = '[object Date]', 5125 domExcTag = '[object DOMException]', 5126 errorTag = '[object Error]', 5127 funcTag = '[object Function]', 5128 genTag = '[object GeneratorFunction]', 5129 mapTag = '[object Map]', 5130 numberTag = '[object Number]', 5131 nullTag = '[object Null]', 5132 objectTag = '[object Object]', 5133 promiseTag = '[object Promise]', 5134 proxyTag = '[object Proxy]', 5135 regexpTag = '[object RegExp]', 5136 setTag = '[object Set]', 5137 stringTag = '[object String]', 5138 symbolTag = '[object Symbol]', 5139 undefinedTag = '[object Undefined]', 5140 weakMapTag = '[object WeakMap]', 5141 weakSetTag = '[object WeakSet]'; 5142 5143 var arrayBufferTag = '[object ArrayBuffer]', 5144 dataViewTag = '[object DataView]', 5145 float32Tag = '[object Float32Array]', 5146 float64Tag = '[object Float64Array]', 5147 int8Tag = '[object Int8Array]', 5148 int16Tag = '[object Int16Array]', 5149 int32Tag = '[object Int32Array]', 5150 uint8Tag = '[object Uint8Array]', 5151 uint8ClampedTag = '[object Uint8ClampedArray]', 5152 uint16Tag = '[object Uint16Array]', 5153 uint32Tag = '[object Uint32Array]'; 5154 5155 /** Used to match empty string literals in compiled template source. */ 5156 var reEmptyStringLeading = /\b__p \+= '';/g, 5157 reEmptyStringMiddle = /\b(__p \+=) '' \+/g, 5158 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; 5159 5160 /** Used to match HTML entities and HTML characters. */ 5161 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, 5162 reUnescapedHtml = /[&<>"']/g, 5163 reHasEscapedHtml = RegExp(reEscapedHtml.source), 5164 reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 5165 5166 /** Used to match template delimiters. */ 5167 var reEscape = /<%-([\s\S]+?)%>/g, 5168 reEvaluate = /<%([\s\S]+?)%>/g, 5169 reInterpolate = /<%=([\s\S]+?)%>/g; 5170 5171 /** Used to match property names within property paths. */ 5172 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, 5173 reIsPlainProp = /^\w*$/, 5174 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; 5175 5176 /** 5177 * Used to match `RegExp` 5178 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 5179 */ 5180 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, 5181 reHasRegExpChar = RegExp(reRegExpChar.source); 5182 5183 /** Used to match leading whitespace. */ 5184 var reTrimStart = /^\s+/; 5185 5186 /** Used to match a single whitespace character. */ 5187 var reWhitespace = /\s/; 5188 5189 /** Used to match wrap detail comments. */ 5190 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, 5191 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, 5192 reSplitDetails = /,? & /; 5193 5194 /** Used to match words composed of alphanumeric characters. */ 5195 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 5196 5197 /** 5198 * Used to validate the `validate` option in `_.template` variable. 5199 * 5200 * Forbids characters which could potentially change the meaning of the function argument definition: 5201 * - "()," (modification of function parameters) 5202 * - "=" (default value) 5203 * - "[]{}" (destructuring of function parameters) 5204 * - "/" (beginning of a comment) 5205 * - whitespace 5206 */ 5207 var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; 5208 5209 /** Used to match backslashes in property paths. */ 5210 var reEscapeChar = /\\(\\)?/g; 5211 5212 /** 5213 * Used to match 5214 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). 5215 */ 5216 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; 5217 5218 /** Used to match `RegExp` flags from their coerced string values. */ 5219 var reFlags = /\w*$/; 5220 5221 /** Used to detect bad signed hexadecimal string values. */ 5222 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 5223 5224 /** Used to detect binary string values. */ 5225 var reIsBinary = /^0b[01]+$/i; 5226 5227 /** Used to detect host constructors (Safari). */ 5228 var reIsHostCtor = /^\[object .+?Constructor\]$/; 5229 5230 /** Used to detect octal string values. */ 5231 var reIsOctal = /^0o[0-7]+$/i; 5232 5233 /** Used to detect unsigned integer values. */ 5234 var reIsUint = /^(?:0|[1-9]\d*)$/; 5235 5236 /** Used to match Latin Unicode letters (excluding mathematical operators). */ 5237 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 5238 5239 /** Used to ensure capturing order of template delimiters. */ 5240 var reNoMatch = /($^)/; 5241 5242 /** Used to match unescaped characters in compiled string literals. */ 5243 var reUnescapedString = /['\n\r\u2028\u2029\\]/g; 5244 5245 /** Used to compose unicode character classes. */ 5246 var rsAstralRange = '\\ud800-\\udfff', 5247 rsComboMarksRange = '\\u0300-\\u036f', 5248 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 5249 rsComboSymbolsRange = '\\u20d0-\\u20ff', 5250 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 5251 rsDingbatRange = '\\u2700-\\u27bf', 5252 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 5253 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 5254 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 5255 rsPunctuationRange = '\\u2000-\\u206f', 5256 rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', 5257 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 5258 rsVarRange = '\\ufe0e\\ufe0f', 5259 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 5260 5261 /** Used to compose unicode capture groups. */ 5262 var rsApos = "['\u2019]", 5263 rsAstral = '[' + rsAstralRange + ']', 5264 rsBreak = '[' + rsBreakRange + ']', 5265 rsCombo = '[' + rsComboRange + ']', 5266 rsDigits = '\\d+', 5267 rsDingbat = '[' + rsDingbatRange + ']', 5268 rsLower = '[' + rsLowerRange + ']', 5269 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 5270 rsFitz = '\\ud83c[\\udffb-\\udfff]', 5271 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 5272 rsNonAstral = '[^' + rsAstralRange + ']', 5273 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 5274 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 5275 rsUpper = '[' + rsUpperRange + ']', 5276 rsZWJ = '\\u200d'; 5277 5278 /** Used to compose unicode regexes. */ 5279 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 5280 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 5281 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', 5282 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', 5283 reOptMod = rsModifier + '?', 5284 rsOptVar = '[' + rsVarRange + ']?', 5285 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 5286 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', 5287 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', 5288 rsSeq = rsOptVar + reOptMod + rsOptJoin, 5289 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, 5290 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; 5291 5292 /** Used to match apostrophes. */ 5293 var reApos = RegExp(rsApos, 'g'); 5294 5295 /** 5296 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 5297 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 5298 */ 5299 var reComboMark = RegExp(rsCombo, 'g'); 5300 5301 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 5302 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); 5303 5304 /** Used to match complex or compound words. */ 5305 var reUnicodeWord = RegExp([ 5306 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 5307 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 5308 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 5309 rsUpper + '+' + rsOptContrUpper, 5310 rsOrdUpper, 5311 rsOrdLower, 5312 rsDigits, 5313 rsEmoji 5314 ].join('|'), 'g'); 5315 5316 /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ 5317 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); 5318 5319 /** Used to detect strings that need a more robust regexp to match words. */ 5320 var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; 5321 5322 /** Used to assign default `context` object properties. */ 5323 var contextProps = [ 5324 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 5325 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', 5326 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 5327 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 5328 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' 5329 ]; 5330 5331 /** Used to make template sourceURLs easier to identify. */ 5332 var templateCounter = -1; 5333 5334 /** Used to identify `toStringTag` values of typed arrays. */ 5335 var typedArrayTags = {}; 5336 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 5337 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 5338 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 5339 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 5340 typedArrayTags[uint32Tag] = true; 5341 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 5342 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = 5343 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = 5344 typedArrayTags[errorTag] = typedArrayTags[funcTag] = 5345 typedArrayTags[mapTag] = typedArrayTags[numberTag] = 5346 typedArrayTags[objectTag] = typedArrayTags[regexpTag] = 5347 typedArrayTags[setTag] = typedArrayTags[stringTag] = 5348 typedArrayTags[weakMapTag] = false; 5349 5350 /** Used to identify `toStringTag` values supported by `_.clone`. */ 5351 var cloneableTags = {}; 5352 cloneableTags[argsTag] = cloneableTags[arrayTag] = 5353 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 5354 cloneableTags[boolTag] = cloneableTags[dateTag] = 5355 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 5356 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 5357 cloneableTags[int32Tag] = cloneableTags[mapTag] = 5358 cloneableTags[numberTag] = cloneableTags[objectTag] = 5359 cloneableTags[regexpTag] = cloneableTags[setTag] = 5360 cloneableTags[stringTag] = cloneableTags[symbolTag] = 5361 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 5362 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 5363 cloneableTags[errorTag] = cloneableTags[funcTag] = 5364 cloneableTags[weakMapTag] = false; 5365 5366 /** Used to map Latin Unicode letters to basic Latin letters. */ 5367 var deburredLetters = { 5368 // Latin-1 Supplement block. 5369 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 5370 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 5371 '\xc7': 'C', '\xe7': 'c', 5372 '\xd0': 'D', '\xf0': 'd', 5373 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 5374 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 5375 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 5376 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 5377 '\xd1': 'N', '\xf1': 'n', 5378 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 5379 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 5380 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 5381 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 5382 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 5383 '\xc6': 'Ae', '\xe6': 'ae', 5384 '\xde': 'Th', '\xfe': 'th', 5385 '\xdf': 'ss', 5386 // Latin Extended-A block. 5387 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 5388 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 5389 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 5390 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 5391 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 5392 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 5393 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 5394 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 5395 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 5396 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 5397 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 5398 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 5399 '\u0134': 'J', '\u0135': 'j', 5400 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 5401 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 5402 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 5403 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 5404 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 5405 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', 5406 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 5407 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 5408 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 5409 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 5410 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 5411 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 5412 '\u0163': 't', '\u0165': 't', '\u0167': 't', 5413 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 5414 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 5415 '\u0174': 'W', '\u0175': 'w', 5416 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 5417 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 5418 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 5419 '\u0132': 'IJ', '\u0133': 'ij', 5420 '\u0152': 'Oe', '\u0153': 'oe', 5421 '\u0149': "'n", '\u017f': 's' 5422 }; 5423 5424 /** Used to map characters to HTML entities. */ 5425 var htmlEscapes = { 5426 '&': '&', 5427 '<': '<', 5428 '>': '>', 5429 '"': '"', 5430 "'": ''' 5431 }; 5432 5433 /** Used to map HTML entities to characters. */ 5434 var htmlUnescapes = { 5435 '&': '&', 5436 '<': '<', 5437 '>': '>', 5438 '"': '"', 5439 ''': "'" 5440 }; 5441 5442 /** Used to escape characters for inclusion in compiled string literals. */ 5443 var stringEscapes = { 5444 '\\': '\\', 5445 "'": "'", 5446 '\n': 'n', 5447 '\r': 'r', 5448 '\u2028': 'u2028', 5449 '\u2029': 'u2029' 5450 }; 5451 5452 /** Built-in method references without a dependency on `root`. */ 5453 var freeParseFloat = parseFloat, 5454 freeParseInt = parseInt; 5455 5456 /** Detect free variable `global` from Node.js. */ 5457 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; 5458 5459 /** Detect free variable `self`. */ 5460 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 5461 5462 /** Used as a reference to the global object. */ 5463 var root = freeGlobal || freeSelf || Function('return this')(); 5464 5465 /** Detect free variable `exports`. */ 5466 var freeExports = true && exports && !exports.nodeType && exports; 5467 5468 /** Detect free variable `module`. */ 5469 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; 5470 5471 /** Detect the popular CommonJS extension `module.exports`. */ 5472 var moduleExports = freeModule && freeModule.exports === freeExports; 5473 5474 /** Detect free variable `process` from Node.js. */ 5475 var freeProcess = moduleExports && freeGlobal.process; 5476 5477 /** Used to access faster Node.js helpers. */ 5478 var nodeUtil = (function() { 5479 try { 5480 // Use `util.types` for Node.js 10+. 5481 var types = freeModule && freeModule.require && freeModule.require('util').types; 5482 5483 if (types) { 5484 return types; 5485 } 5486 5487 // Legacy `process.binding('util')` for Node.js < 10. 5488 return freeProcess && freeProcess.binding && freeProcess.binding('util'); 5489 } catch (e) {} 5490 }()); 5491 5492 /* Node.js helper references. */ 5493 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, 5494 nodeIsDate = nodeUtil && nodeUtil.isDate, 5495 nodeIsMap = nodeUtil && nodeUtil.isMap, 5496 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, 5497 nodeIsSet = nodeUtil && nodeUtil.isSet, 5498 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; 5499 5500 /*--------------------------------------------------------------------------*/ 5501 5502 /** 5503 * A faster alternative to `Function#apply`, this function invokes `func` 5504 * with the `this` binding of `thisArg` and the arguments of `args`. 5505 * 5506 * @private 5507 * @param {Function} func The function to invoke. 5508 * @param {*} thisArg The `this` binding of `func`. 5509 * @param {Array} args The arguments to invoke `func` with. 5510 * @returns {*} Returns the result of `func`. 5511 */ 5512 function apply(func, thisArg, args) { 5513 switch (args.length) { 5514 case 0: return func.call(thisArg); 5515 case 1: return func.call(thisArg, args[0]); 5516 case 2: return func.call(thisArg, args[0], args[1]); 5517 case 3: return func.call(thisArg, args[0], args[1], args[2]); 5518 } 5519 return func.apply(thisArg, args); 5520 } 5521 5522 /** 5523 * A specialized version of `baseAggregator` for arrays. 5524 * 5525 * @private 5526 * @param {Array} [array] The array to iterate over. 5527 * @param {Function} setter The function to set `accumulator` values. 5528 * @param {Function} iteratee The iteratee to transform keys. 5529 * @param {Object} accumulator The initial aggregated object. 5530 * @returns {Function} Returns `accumulator`. 5531 */ 5532 function arrayAggregator(array, setter, iteratee, accumulator) { 5533 var index = -1, 5534 length = array == null ? 0 : array.length; 5535 5536 while (++index < length) { 5537 var value = array[index]; 5538 setter(accumulator, value, iteratee(value), array); 5539 } 5540 return accumulator; 5541 } 5542 5543 /** 5544 * A specialized version of `_.forEach` for arrays without support for 5545 * iteratee shorthands. 5546 * 5547 * @private 5548 * @param {Array} [array] The array to iterate over. 5549 * @param {Function} iteratee The function invoked per iteration. 5550 * @returns {Array} Returns `array`. 5551 */ 5552 function arrayEach(array, iteratee) { 5553 var index = -1, 5554 length = array == null ? 0 : array.length; 5555 5556 while (++index < length) { 5557 if (iteratee(array[index], index, array) === false) { 5558 break; 5559 } 5560 } 5561 return array; 5562 } 5563 5564 /** 5565 * A specialized version of `_.forEachRight` for arrays without support for 5566 * iteratee shorthands. 5567 * 5568 * @private 5569 * @param {Array} [array] The array to iterate over. 5570 * @param {Function} iteratee The function invoked per iteration. 5571 * @returns {Array} Returns `array`. 5572 */ 5573 function arrayEachRight(array, iteratee) { 5574 var length = array == null ? 0 : array.length; 5575 5576 while (length--) { 5577 if (iteratee(array[length], length, array) === false) { 5578 break; 5579 } 5580 } 5581 return array; 5582 } 5583 5584 /** 5585 * A specialized version of `_.every` for arrays without support for 5586 * iteratee shorthands. 5587 * 5588 * @private 5589 * @param {Array} [array] The array to iterate over. 5590 * @param {Function} predicate The function invoked per iteration. 5591 * @returns {boolean} Returns `true` if all elements pass the predicate check, 5592 * else `false`. 5593 */ 5594 function arrayEvery(array, predicate) { 5595 var index = -1, 5596 length = array == null ? 0 : array.length; 5597 5598 while (++index < length) { 5599 if (!predicate(array[index], index, array)) { 5600 return false; 5601 } 5602 } 5603 return true; 5604 } 5605 5606 /** 5607 * A specialized version of `_.filter` for arrays without support for 5608 * iteratee shorthands. 5609 * 5610 * @private 5611 * @param {Array} [array] The array to iterate over. 5612 * @param {Function} predicate The function invoked per iteration. 5613 * @returns {Array} Returns the new filtered array. 5614 */ 5615 function arrayFilter(array, predicate) { 5616 var index = -1, 5617 length = array == null ? 0 : array.length, 5618 resIndex = 0, 5619 result = []; 5620 5621 while (++index < length) { 5622 var value = array[index]; 5623 if (predicate(value, index, array)) { 5624 result[resIndex++] = value; 5625 } 5626 } 5627 return result; 5628 } 5629 5630 /** 5631 * A specialized version of `_.includes` for arrays without support for 5632 * specifying an index to search from. 5633 * 5634 * @private 5635 * @param {Array} [array] The array to inspect. 5636 * @param {*} target The value to search for. 5637 * @returns {boolean} Returns `true` if `target` is found, else `false`. 5638 */ 5639 function arrayIncludes(array, value) { 5640 var length = array == null ? 0 : array.length; 5641 return !!length && baseIndexOf(array, value, 0) > -1; 5642 } 5643 5644 /** 5645 * This function is like `arrayIncludes` except that it accepts a comparator. 5646 * 5647 * @private 5648 * @param {Array} [array] The array to inspect. 5649 * @param {*} target The value to search for. 5650 * @param {Function} comparator The comparator invoked per element. 5651 * @returns {boolean} Returns `true` if `target` is found, else `false`. 5652 */ 5653 function arrayIncludesWith(array, value, comparator) { 5654 var index = -1, 5655 length = array == null ? 0 : array.length; 5656 5657 while (++index < length) { 5658 if (comparator(value, array[index])) { 5659 return true; 5660 } 5661 } 5662 return false; 5663 } 5664 5665 /** 5666 * A specialized version of `_.map` for arrays without support for iteratee 5667 * shorthands. 5668 * 5669 * @private 5670 * @param {Array} [array] The array to iterate over. 5671 * @param {Function} iteratee The function invoked per iteration. 5672 * @returns {Array} Returns the new mapped array. 5673 */ 5674 function arrayMap(array, iteratee) { 5675 var index = -1, 5676 length = array == null ? 0 : array.length, 5677 result = Array(length); 5678 5679 while (++index < length) { 5680 result[index] = iteratee(array[index], index, array); 5681 } 5682 return result; 5683 } 5684 5685 /** 5686 * Appends the elements of `values` to `array`. 5687 * 5688 * @private 5689 * @param {Array} array The array to modify. 5690 * @param {Array} values The values to append. 5691 * @returns {Array} Returns `array`. 5692 */ 5693 function arrayPush(array, values) { 5694 var index = -1, 5695 length = values.length, 5696 offset = array.length; 5697 5698 while (++index < length) { 5699 array[offset + index] = values[index]; 5700 } 5701 return array; 5702 } 5703 5704 /** 5705 * A specialized version of `_.reduce` for arrays without support for 5706 * iteratee shorthands. 5707 * 5708 * @private 5709 * @param {Array} [array] The array to iterate over. 5710 * @param {Function} iteratee The function invoked per iteration. 5711 * @param {*} [accumulator] The initial value. 5712 * @param {boolean} [initAccum] Specify using the first element of `array` as 5713 * the initial value. 5714 * @returns {*} Returns the accumulated value. 5715 */ 5716 function arrayReduce(array, iteratee, accumulator, initAccum) { 5717 var index = -1, 5718 length = array == null ? 0 : array.length; 5719 5720 if (initAccum && length) { 5721 accumulator = array[++index]; 5722 } 5723 while (++index < length) { 5724 accumulator = iteratee(accumulator, array[index], index, array); 5725 } 5726 return accumulator; 5727 } 5728 5729 /** 5730 * A specialized version of `_.reduceRight` for arrays without support for 5731 * iteratee shorthands. 5732 * 5733 * @private 5734 * @param {Array} [array] The array to iterate over. 5735 * @param {Function} iteratee The function invoked per iteration. 5736 * @param {*} [accumulator] The initial value. 5737 * @param {boolean} [initAccum] Specify using the last element of `array` as 5738 * the initial value. 5739 * @returns {*} Returns the accumulated value. 5740 */ 5741 function arrayReduceRight(array, iteratee, accumulator, initAccum) { 5742 var length = array == null ? 0 : array.length; 5743 if (initAccum && length) { 5744 accumulator = array[--length]; 5745 } 5746 while (length--) { 5747 accumulator = iteratee(accumulator, array[length], length, array); 5748 } 5749 return accumulator; 5750 } 5751 5752 /** 5753 * A specialized version of `_.some` for arrays without support for iteratee 5754 * shorthands. 5755 * 5756 * @private 5757 * @param {Array} [array] The array to iterate over. 5758 * @param {Function} predicate The function invoked per iteration. 5759 * @returns {boolean} Returns `true` if any element passes the predicate check, 5760 * else `false`. 5761 */ 5762 function arraySome(array, predicate) { 5763 var index = -1, 5764 length = array == null ? 0 : array.length; 5765 5766 while (++index < length) { 5767 if (predicate(array[index], index, array)) { 5768 return true; 5769 } 5770 } 5771 return false; 5772 } 5773 5774 /** 5775 * Gets the size of an ASCII `string`. 5776 * 5777 * @private 5778 * @param {string} string The string inspect. 5779 * @returns {number} Returns the string size. 5780 */ 5781 var asciiSize = baseProperty('length'); 5782 5783 /** 5784 * Converts an ASCII `string` to an array. 5785 * 5786 * @private 5787 * @param {string} string The string to convert. 5788 * @returns {Array} Returns the converted array. 5789 */ 5790 function asciiToArray(string) { 5791 return string.split(''); 5792 } 5793 5794 /** 5795 * Splits an ASCII `string` into an array of its words. 5796 * 5797 * @private 5798 * @param {string} The string to inspect. 5799 * @returns {Array} Returns the words of `string`. 5800 */ 5801 function asciiWords(string) { 5802 return string.match(reAsciiWord) || []; 5803 } 5804 5805 /** 5806 * The base implementation of methods like `_.findKey` and `_.findLastKey`, 5807 * without support for iteratee shorthands, which iterates over `collection` 5808 * using `eachFunc`. 5809 * 5810 * @private 5811 * @param {Array|Object} collection The collection to inspect. 5812 * @param {Function} predicate The function invoked per iteration. 5813 * @param {Function} eachFunc The function to iterate over `collection`. 5814 * @returns {*} Returns the found element or its key, else `undefined`. 5815 */ 5816 function baseFindKey(collection, predicate, eachFunc) { 5817 var result; 5818 eachFunc(collection, function(value, key, collection) { 5819 if (predicate(value, key, collection)) { 5820 result = key; 5821 return false; 5822 } 5823 }); 5824 return result; 5825 } 5826 5827 /** 5828 * The base implementation of `_.findIndex` and `_.findLastIndex` without 5829 * support for iteratee shorthands. 5830 * 5831 * @private 5832 * @param {Array} array The array to inspect. 5833 * @param {Function} predicate The function invoked per iteration. 5834 * @param {number} fromIndex The index to search from. 5835 * @param {boolean} [fromRight] Specify iterating from right to left. 5836 * @returns {number} Returns the index of the matched value, else `-1`. 5837 */ 5838 function baseFindIndex(array, predicate, fromIndex, fromRight) { 5839 var length = array.length, 5840 index = fromIndex + (fromRight ? 1 : -1); 5841 5842 while ((fromRight ? index-- : ++index < length)) { 5843 if (predicate(array[index], index, array)) { 5844 return index; 5845 } 5846 } 5847 return -1; 5848 } 5849 5850 /** 5851 * The base implementation of `_.indexOf` without `fromIndex` bounds checks. 5852 * 5853 * @private 5854 * @param {Array} array The array to inspect. 5855 * @param {*} value The value to search for. 5856 * @param {number} fromIndex The index to search from. 5857 * @returns {number} Returns the index of the matched value, else `-1`. 5858 */ 5859 function baseIndexOf(array, value, fromIndex) { 5860 return value === value 5861 ? strictIndexOf(array, value, fromIndex) 5862 : baseFindIndex(array, baseIsNaN, fromIndex); 5863 } 5864 5865 /** 5866 * This function is like `baseIndexOf` except that it accepts a comparator. 5867 * 5868 * @private 5869 * @param {Array} array The array to inspect. 5870 * @param {*} value The value to search for. 5871 * @param {number} fromIndex The index to search from. 5872 * @param {Function} comparator The comparator invoked per element. 5873 * @returns {number} Returns the index of the matched value, else `-1`. 5874 */ 5875 function baseIndexOfWith(array, value, fromIndex, comparator) { 5876 var index = fromIndex - 1, 5877 length = array.length; 5878 5879 while (++index < length) { 5880 if (comparator(array[index], value)) { 5881 return index; 5882 } 5883 } 5884 return -1; 5885 } 5886 5887 /** 5888 * The base implementation of `_.isNaN` without support for number objects. 5889 * 5890 * @private 5891 * @param {*} value The value to check. 5892 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 5893 */ 5894 function baseIsNaN(value) { 5895 return value !== value; 5896 } 5897 5898 /** 5899 * The base implementation of `_.mean` and `_.meanBy` without support for 5900 * iteratee shorthands. 5901 * 5902 * @private 5903 * @param {Array} array The array to iterate over. 5904 * @param {Function} iteratee The function invoked per iteration. 5905 * @returns {number} Returns the mean. 5906 */ 5907 function baseMean(array, iteratee) { 5908 var length = array == null ? 0 : array.length; 5909 return length ? (baseSum(array, iteratee) / length) : NAN; 5910 } 5911 5912 /** 5913 * The base implementation of `_.property` without support for deep paths. 5914 * 5915 * @private 5916 * @param {string} key The key of the property to get. 5917 * @returns {Function} Returns the new accessor function. 5918 */ 5919 function baseProperty(key) { 5920 return function(object) { 5921 return object == null ? undefined : object[key]; 5922 }; 5923 } 5924 5925 /** 5926 * The base implementation of `_.propertyOf` without support for deep paths. 5927 * 5928 * @private 5929 * @param {Object} object The object to query. 5930 * @returns {Function} Returns the new accessor function. 5931 */ 5932 function basePropertyOf(object) { 5933 return function(key) { 5934 return object == null ? undefined : object[key]; 5935 }; 5936 } 5937 5938 /** 5939 * The base implementation of `_.reduce` and `_.reduceRight`, without support 5940 * for iteratee shorthands, which iterates over `collection` using `eachFunc`. 5941 * 5942 * @private 5943 * @param {Array|Object} collection The collection to iterate over. 5944 * @param {Function} iteratee The function invoked per iteration. 5945 * @param {*} accumulator The initial value. 5946 * @param {boolean} initAccum Specify using the first or last element of 5947 * `collection` as the initial value. 5948 * @param {Function} eachFunc The function to iterate over `collection`. 5949 * @returns {*} Returns the accumulated value. 5950 */ 5951 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { 5952 eachFunc(collection, function(value, index, collection) { 5953 accumulator = initAccum 5954 ? (initAccum = false, value) 5955 : iteratee(accumulator, value, index, collection); 5956 }); 5957 return accumulator; 5958 } 5959 5960 /** 5961 * The base implementation of `_.sortBy` which uses `comparer` to define the 5962 * sort order of `array` and replaces criteria objects with their corresponding 5963 * values. 5964 * 5965 * @private 5966 * @param {Array} array The array to sort. 5967 * @param {Function} comparer The function to define sort order. 5968 * @returns {Array} Returns `array`. 5969 */ 5970 function baseSortBy(array, comparer) { 5971 var length = array.length; 5972 5973 array.sort(comparer); 5974 while (length--) { 5975 array[length] = array[length].value; 5976 } 5977 return array; 5978 } 5979 5980 /** 5981 * The base implementation of `_.sum` and `_.sumBy` without support for 5982 * iteratee shorthands. 5983 * 5984 * @private 5985 * @param {Array} array The array to iterate over. 5986 * @param {Function} iteratee The function invoked per iteration. 5987 * @returns {number} Returns the sum. 5988 */ 5989 function baseSum(array, iteratee) { 5990 var result, 5991 index = -1, 5992 length = array.length; 5993 5994 while (++index < length) { 5995 var current = iteratee(array[index]); 5996 if (current !== undefined) { 5997 result = result === undefined ? current : (result + current); 5998 } 5999 } 6000 return result; 6001 } 6002 6003 /** 6004 * The base implementation of `_.times` without support for iteratee shorthands 6005 * or max array length checks. 6006 * 6007 * @private 6008 * @param {number} n The number of times to invoke `iteratee`. 6009 * @param {Function} iteratee The function invoked per iteration. 6010 * @returns {Array} Returns the array of results. 6011 */ 6012 function baseTimes(n, iteratee) { 6013 var index = -1, 6014 result = Array(n); 6015 6016 while (++index < n) { 6017 result[index] = iteratee(index); 6018 } 6019 return result; 6020 } 6021 6022 /** 6023 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array 6024 * of key-value pairs for `object` corresponding to the property names of `props`. 6025 * 6026 * @private 6027 * @param {Object} object The object to query. 6028 * @param {Array} props The property names to get values for. 6029 * @returns {Object} Returns the key-value pairs. 6030 */ 6031 function baseToPairs(object, props) { 6032 return arrayMap(props, function(key) { 6033 return [key, object[key]]; 6034 }); 6035 } 6036 6037 /** 6038 * The base implementation of `_.trim`. 6039 * 6040 * @private 6041 * @param {string} string The string to trim. 6042 * @returns {string} Returns the trimmed string. 6043 */ 6044 function baseTrim(string) { 6045 return string 6046 ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') 6047 : string; 6048 } 6049 6050 /** 6051 * The base implementation of `_.unary` without support for storing metadata. 6052 * 6053 * @private 6054 * @param {Function} func The function to cap arguments for. 6055 * @returns {Function} Returns the new capped function. 6056 */ 6057 function baseUnary(func) { 6058 return function(value) { 6059 return func(value); 6060 }; 6061 } 6062 6063 /** 6064 * The base implementation of `_.values` and `_.valuesIn` which creates an 6065 * array of `object` property values corresponding to the property names 6066 * of `props`. 6067 * 6068 * @private 6069 * @param {Object} object The object to query. 6070 * @param {Array} props The property names to get values for. 6071 * @returns {Object} Returns the array of property values. 6072 */ 6073 function baseValues(object, props) { 6074 return arrayMap(props, function(key) { 6075 return object[key]; 6076 }); 6077 } 6078 6079 /** 6080 * Checks if a `cache` value for `key` exists. 6081 * 6082 * @private 6083 * @param {Object} cache The cache to query. 6084 * @param {string} key The key of the entry to check. 6085 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 6086 */ 6087 function cacheHas(cache, key) { 6088 return cache.has(key); 6089 } 6090 6091 /** 6092 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol 6093 * that is not found in the character symbols. 6094 * 6095 * @private 6096 * @param {Array} strSymbols The string symbols to inspect. 6097 * @param {Array} chrSymbols The character symbols to find. 6098 * @returns {number} Returns the index of the first unmatched string symbol. 6099 */ 6100 function charsStartIndex(strSymbols, chrSymbols) { 6101 var index = -1, 6102 length = strSymbols.length; 6103 6104 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 6105 return index; 6106 } 6107 6108 /** 6109 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol 6110 * that is not found in the character symbols. 6111 * 6112 * @private 6113 * @param {Array} strSymbols The string symbols to inspect. 6114 * @param {Array} chrSymbols The character symbols to find. 6115 * @returns {number} Returns the index of the last unmatched string symbol. 6116 */ 6117 function charsEndIndex(strSymbols, chrSymbols) { 6118 var index = strSymbols.length; 6119 6120 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 6121 return index; 6122 } 6123 6124 /** 6125 * Gets the number of `placeholder` occurrences in `array`. 6126 * 6127 * @private 6128 * @param {Array} array The array to inspect. 6129 * @param {*} placeholder The placeholder to search for. 6130 * @returns {number} Returns the placeholder count. 6131 */ 6132 function countHolders(array, placeholder) { 6133 var length = array.length, 6134 result = 0; 6135 6136 while (length--) { 6137 if (array[length] === placeholder) { 6138 ++result; 6139 } 6140 } 6141 return result; 6142 } 6143 6144 /** 6145 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 6146 * letters to basic Latin letters. 6147 * 6148 * @private 6149 * @param {string} letter The matched letter to deburr. 6150 * @returns {string} Returns the deburred letter. 6151 */ 6152 var deburrLetter = basePropertyOf(deburredLetters); 6153 6154 /** 6155 * Used by `_.escape` to convert characters to HTML entities. 6156 * 6157 * @private 6158 * @param {string} chr The matched character to escape. 6159 * @returns {string} Returns the escaped character. 6160 */ 6161 var escapeHtmlChar = basePropertyOf(htmlEscapes); 6162 6163 /** 6164 * Used by `_.template` to escape characters for inclusion in compiled string literals. 6165 * 6166 * @private 6167 * @param {string} chr The matched character to escape. 6168 * @returns {string} Returns the escaped character. 6169 */ 6170 function escapeStringChar(chr) { 6171 return '\\' + stringEscapes[chr]; 6172 } 6173 6174 /** 6175 * Gets the value at `key` of `object`. 6176 * 6177 * @private 6178 * @param {Object} [object] The object to query. 6179 * @param {string} key The key of the property to get. 6180 * @returns {*} Returns the property value. 6181 */ 6182 function getValue(object, key) { 6183 return object == null ? undefined : object[key]; 6184 } 6185 6186 /** 6187 * Checks if `string` contains Unicode symbols. 6188 * 6189 * @private 6190 * @param {string} string The string to inspect. 6191 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 6192 */ 6193 function hasUnicode(string) { 6194 return reHasUnicode.test(string); 6195 } 6196 6197 /** 6198 * Checks if `string` contains a word composed of Unicode symbols. 6199 * 6200 * @private 6201 * @param {string} string The string to inspect. 6202 * @returns {boolean} Returns `true` if a word is found, else `false`. 6203 */ 6204 function hasUnicodeWord(string) { 6205 return reHasUnicodeWord.test(string); 6206 } 6207 6208 /** 6209 * Converts `iterator` to an array. 6210 * 6211 * @private 6212 * @param {Object} iterator The iterator to convert. 6213 * @returns {Array} Returns the converted array. 6214 */ 6215 function iteratorToArray(iterator) { 6216 var data, 6217 result = []; 6218 6219 while (!(data = iterator.next()).done) { 6220 result.push(data.value); 6221 } 6222 return result; 6223 } 6224 6225 /** 6226 * Converts `map` to its key-value pairs. 6227 * 6228 * @private 6229 * @param {Object} map The map to convert. 6230 * @returns {Array} Returns the key-value pairs. 6231 */ 6232 function mapToArray(map) { 6233 var index = -1, 6234 result = Array(map.size); 6235 6236 map.forEach(function(value, key) { 6237 result[++index] = [key, value]; 6238 }); 6239 return result; 6240 } 6241 6242 /** 6243 * Creates a unary function that invokes `func` with its argument transformed. 6244 * 6245 * @private 6246 * @param {Function} func The function to wrap. 6247 * @param {Function} transform The argument transform. 6248 * @returns {Function} Returns the new function. 6249 */ 6250 function overArg(func, transform) { 6251 return function(arg) { 6252 return func(transform(arg)); 6253 }; 6254 } 6255 6256 /** 6257 * Replaces all `placeholder` elements in `array` with an internal placeholder 6258 * and returns an array of their indexes. 6259 * 6260 * @private 6261 * @param {Array} array The array to modify. 6262 * @param {*} placeholder The placeholder to replace. 6263 * @returns {Array} Returns the new array of placeholder indexes. 6264 */ 6265 function replaceHolders(array, placeholder) { 6266 var index = -1, 6267 length = array.length, 6268 resIndex = 0, 6269 result = []; 6270 6271 while (++index < length) { 6272 var value = array[index]; 6273 if (value === placeholder || value === PLACEHOLDER) { 6274 array[index] = PLACEHOLDER; 6275 result[resIndex++] = index; 6276 } 6277 } 6278 return result; 6279 } 6280 6281 /** 6282 * Converts `set` to an array of its values. 6283 * 6284 * @private 6285 * @param {Object} set The set to convert. 6286 * @returns {Array} Returns the values. 6287 */ 6288 function setToArray(set) { 6289 var index = -1, 6290 result = Array(set.size); 6291 6292 set.forEach(function(value) { 6293 result[++index] = value; 6294 }); 6295 return result; 6296 } 6297 6298 /** 6299 * Converts `set` to its value-value pairs. 6300 * 6301 * @private 6302 * @param {Object} set The set to convert. 6303 * @returns {Array} Returns the value-value pairs. 6304 */ 6305 function setToPairs(set) { 6306 var index = -1, 6307 result = Array(set.size); 6308 6309 set.forEach(function(value) { 6310 result[++index] = [value, value]; 6311 }); 6312 return result; 6313 } 6314 6315 /** 6316 * A specialized version of `_.indexOf` which performs strict equality 6317 * comparisons of values, i.e. `===`. 6318 * 6319 * @private 6320 * @param {Array} array The array to inspect. 6321 * @param {*} value The value to search for. 6322 * @param {number} fromIndex The index to search from. 6323 * @returns {number} Returns the index of the matched value, else `-1`. 6324 */ 6325 function strictIndexOf(array, value, fromIndex) { 6326 var index = fromIndex - 1, 6327 length = array.length; 6328 6329 while (++index < length) { 6330 if (array[index] === value) { 6331 return index; 6332 } 6333 } 6334 return -1; 6335 } 6336 6337 /** 6338 * A specialized version of `_.lastIndexOf` which performs strict equality 6339 * comparisons of values, i.e. `===`. 6340 * 6341 * @private 6342 * @param {Array} array The array to inspect. 6343 * @param {*} value The value to search for. 6344 * @param {number} fromIndex The index to search from. 6345 * @returns {number} Returns the index of the matched value, else `-1`. 6346 */ 6347 function strictLastIndexOf(array, value, fromIndex) { 6348 var index = fromIndex + 1; 6349 while (index--) { 6350 if (array[index] === value) { 6351 return index; 6352 } 6353 } 6354 return index; 6355 } 6356 6357 /** 6358 * Gets the number of symbols in `string`. 6359 * 6360 * @private 6361 * @param {string} string The string to inspect. 6362 * @returns {number} Returns the string size. 6363 */ 6364 function stringSize(string) { 6365 return hasUnicode(string) 6366 ? unicodeSize(string) 6367 : asciiSize(string); 6368 } 6369 6370 /** 6371 * Converts `string` to an array. 6372 * 6373 * @private 6374 * @param {string} string The string to convert. 6375 * @returns {Array} Returns the converted array. 6376 */ 6377 function stringToArray(string) { 6378 return hasUnicode(string) 6379 ? unicodeToArray(string) 6380 : asciiToArray(string); 6381 } 6382 6383 /** 6384 * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace 6385 * character of `string`. 6386 * 6387 * @private 6388 * @param {string} string The string to inspect. 6389 * @returns {number} Returns the index of the last non-whitespace character. 6390 */ 6391 function trimmedEndIndex(string) { 6392 var index = string.length; 6393 6394 while (index-- && reWhitespace.test(string.charAt(index))) {} 6395 return index; 6396 } 6397 6398 /** 6399 * Used by `_.unescape` to convert HTML entities to characters. 6400 * 6401 * @private 6402 * @param {string} chr The matched character to unescape. 6403 * @returns {string} Returns the unescaped character. 6404 */ 6405 var unescapeHtmlChar = basePropertyOf(htmlUnescapes); 6406 6407 /** 6408 * Gets the size of a Unicode `string`. 6409 * 6410 * @private 6411 * @param {string} string The string inspect. 6412 * @returns {number} Returns the string size. 6413 */ 6414 function unicodeSize(string) { 6415 var result = reUnicode.lastIndex = 0; 6416 while (reUnicode.test(string)) { 6417 ++result; 6418 } 6419 return result; 6420 } 6421 6422 /** 6423 * Converts a Unicode `string` to an array. 6424 * 6425 * @private 6426 * @param {string} string The string to convert. 6427 * @returns {Array} Returns the converted array. 6428 */ 6429 function unicodeToArray(string) { 6430 return string.match(reUnicode) || []; 6431 } 6432 6433 /** 6434 * Splits a Unicode `string` into an array of its words. 6435 * 6436 * @private 6437 * @param {string} The string to inspect. 6438 * @returns {Array} Returns the words of `string`. 6439 */ 6440 function unicodeWords(string) { 6441 return string.match(reUnicodeWord) || []; 6442 } 6443 6444 /*--------------------------------------------------------------------------*/ 6445 6446 /** 6447 * Create a new pristine `lodash` function using the `context` object. 6448 * 6449 * @static 6450 * @memberOf _ 6451 * @since 1.1.0 6452 * @category Util 6453 * @param {Object} [context=root] The context object. 6454 * @returns {Function} Returns a new `lodash` function. 6455 * @example 6456 * 6457 * _.mixin({ 'foo': _.constant('foo') }); 6458 * 6459 * var lodash = _.runInContext(); 6460 * lodash.mixin({ 'bar': lodash.constant('bar') }); 6461 * 6462 * _.isFunction(_.foo); 6463 * // => true 6464 * _.isFunction(_.bar); 6465 * // => false 6466 * 6467 * lodash.isFunction(lodash.foo); 6468 * // => false 6469 * lodash.isFunction(lodash.bar); 6470 * // => true 6471 * 6472 * // Create a suped-up `defer` in Node.js. 6473 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; 6474 */ 6475 var runInContext = (function runInContext(context) { 6476 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); 6477 6478 /** Built-in constructor references. */ 6479 var Array = context.Array, 6480 Date = context.Date, 6481 Error = context.Error, 6482 Function = context.Function, 6483 Math = context.Math, 6484 Object = context.Object, 6485 RegExp = context.RegExp, 6486 String = context.String, 6487 TypeError = context.TypeError; 6488 6489 /** Used for built-in method references. */ 6490 var arrayProto = Array.prototype, 6491 funcProto = Function.prototype, 6492 objectProto = Object.prototype; 6493 6494 /** Used to detect overreaching core-js shims. */ 6495 var coreJsData = context['__core-js_shared__']; 6496 6497 /** Used to resolve the decompiled source of functions. */ 6498 var funcToString = funcProto.toString; 6499 6500 /** Used to check objects for own properties. */ 6501 var hasOwnProperty = objectProto.hasOwnProperty; 6502 6503 /** Used to generate unique IDs. */ 6504 var idCounter = 0; 6505 6506 /** Used to detect methods masquerading as native. */ 6507 var maskSrcKey = (function() { 6508 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); 6509 return uid ? ('Symbol(src)_1.' + uid) : ''; 6510 }()); 6511 6512 /** 6513 * Used to resolve the 6514 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 6515 * of values. 6516 */ 6517 var nativeObjectToString = objectProto.toString; 6518 6519 /** Used to infer the `Object` constructor. */ 6520 var objectCtorString = funcToString.call(Object); 6521 6522 /** Used to restore the original `_` reference in `_.noConflict`. */ 6523 var oldDash = root._; 6524 6525 /** Used to detect if a method is native. */ 6526 var reIsNative = RegExp('^' + 6527 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') 6528 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 6529 ); 6530 6531 /** Built-in value references. */ 6532 var Buffer = moduleExports ? context.Buffer : undefined, 6533 Symbol = context.Symbol, 6534 Uint8Array = context.Uint8Array, 6535 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, 6536 getPrototype = overArg(Object.getPrototypeOf, Object), 6537 objectCreate = Object.create, 6538 propertyIsEnumerable = objectProto.propertyIsEnumerable, 6539 splice = arrayProto.splice, 6540 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, 6541 symIterator = Symbol ? Symbol.iterator : undefined, 6542 symToStringTag = Symbol ? Symbol.toStringTag : undefined; 6543 6544 var defineProperty = (function() { 6545 try { 6546 var func = getNative(Object, 'defineProperty'); 6547 func({}, '', {}); 6548 return func; 6549 } catch (e) {} 6550 }()); 6551 6552 /** Mocked built-ins. */ 6553 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, 6554 ctxNow = Date && Date.now !== root.Date.now && Date.now, 6555 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; 6556 6557 /* Built-in method references for those with the same name as other `lodash` methods. */ 6558 var nativeCeil = Math.ceil, 6559 nativeFloor = Math.floor, 6560 nativeGetSymbols = Object.getOwnPropertySymbols, 6561 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, 6562 nativeIsFinite = context.isFinite, 6563 nativeJoin = arrayProto.join, 6564 nativeKeys = overArg(Object.keys, Object), 6565 nativeMax = Math.max, 6566 nativeMin = Math.min, 6567 nativeNow = Date.now, 6568 nativeParseInt = context.parseInt, 6569 nativeRandom = Math.random, 6570 nativeReverse = arrayProto.reverse; 6571 6572 /* Built-in method references that are verified to be native. */ 6573 var DataView = getNative(context, 'DataView'), 6574 Map = getNative(context, 'Map'), 6575 Promise = getNative(context, 'Promise'), 6576 Set = getNative(context, 'Set'), 6577 WeakMap = getNative(context, 'WeakMap'), 6578 nativeCreate = getNative(Object, 'create'); 6579 6580 /** Used to store function metadata. */ 6581 var metaMap = WeakMap && new WeakMap; 6582 6583 /** Used to lookup unminified function names. */ 6584 var realNames = {}; 6585 6586 /** Used to detect maps, sets, and weakmaps. */ 6587 var dataViewCtorString = toSource(DataView), 6588 mapCtorString = toSource(Map), 6589 promiseCtorString = toSource(Promise), 6590 setCtorString = toSource(Set), 6591 weakMapCtorString = toSource(WeakMap); 6592 6593 /** Used to convert symbols to primitives and strings. */ 6594 var symbolProto = Symbol ? Symbol.prototype : undefined, 6595 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, 6596 symbolToString = symbolProto ? symbolProto.toString : undefined; 6597 6598 /*------------------------------------------------------------------------*/ 6599 6600 /** 6601 * Creates a `lodash` object which wraps `value` to enable implicit method 6602 * chain sequences. Methods that operate on and return arrays, collections, 6603 * and functions can be chained together. Methods that retrieve a single value 6604 * or may return a primitive value will automatically end the chain sequence 6605 * and return the unwrapped value. Otherwise, the value must be unwrapped 6606 * with `_#value`. 6607 * 6608 * Explicit chain sequences, which must be unwrapped with `_#value`, may be 6609 * enabled using `_.chain`. 6610 * 6611 * The execution of chained methods is lazy, that is, it's deferred until 6612 * `_#value` is implicitly or explicitly called. 6613 * 6614 * Lazy evaluation allows several methods to support shortcut fusion. 6615 * Shortcut fusion is an optimization to merge iteratee calls; this avoids 6616 * the creation of intermediate arrays and can greatly reduce the number of 6617 * iteratee executions. Sections of a chain sequence qualify for shortcut 6618 * fusion if the section is applied to an array and iteratees accept only 6619 * one argument. The heuristic for whether a section qualifies for shortcut 6620 * fusion is subject to change. 6621 * 6622 * Chaining is supported in custom builds as long as the `_#value` method is 6623 * directly or indirectly included in the build. 6624 * 6625 * In addition to lodash methods, wrappers have `Array` and `String` methods. 6626 * 6627 * The wrapper `Array` methods are: 6628 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` 6629 * 6630 * The wrapper `String` methods are: 6631 * `replace` and `split` 6632 * 6633 * The wrapper methods that support shortcut fusion are: 6634 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, 6635 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, 6636 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` 6637 * 6638 * The chainable wrapper methods are: 6639 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, 6640 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, 6641 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, 6642 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, 6643 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, 6644 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, 6645 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, 6646 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, 6647 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, 6648 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, 6649 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, 6650 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, 6651 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, 6652 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, 6653 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, 6654 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, 6655 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, 6656 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, 6657 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, 6658 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, 6659 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, 6660 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, 6661 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, 6662 * `zipObject`, `zipObjectDeep`, and `zipWith` 6663 * 6664 * The wrapper methods that are **not** chainable by default are: 6665 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, 6666 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, 6667 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, 6668 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, 6669 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, 6670 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, 6671 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, 6672 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, 6673 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, 6674 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, 6675 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, 6676 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, 6677 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, 6678 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, 6679 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, 6680 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, 6681 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, 6682 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, 6683 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, 6684 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, 6685 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, 6686 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, 6687 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, 6688 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, 6689 * `upperFirst`, `value`, and `words` 6690 * 6691 * @name _ 6692 * @constructor 6693 * @category Seq 6694 * @param {*} value The value to wrap in a `lodash` instance. 6695 * @returns {Object} Returns the new `lodash` wrapper instance. 6696 * @example 6697 * 6698 * function square(n) { 6699 * return n * n; 6700 * } 6701 * 6702 * var wrapped = _([1, 2, 3]); 6703 * 6704 * // Returns an unwrapped value. 6705 * wrapped.reduce(_.add); 6706 * // => 6 6707 * 6708 * // Returns a wrapped value. 6709 * var squares = wrapped.map(square); 6710 * 6711 * _.isArray(squares); 6712 * // => false 6713 * 6714 * _.isArray(squares.value()); 6715 * // => true 6716 */ 6717 function lodash(value) { 6718 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { 6719 if (value instanceof LodashWrapper) { 6720 return value; 6721 } 6722 if (hasOwnProperty.call(value, '__wrapped__')) { 6723 return wrapperClone(value); 6724 } 6725 } 6726 return new LodashWrapper(value); 6727 } 6728 6729 /** 6730 * The base implementation of `_.create` without support for assigning 6731 * properties to the created object. 6732 * 6733 * @private 6734 * @param {Object} proto The object to inherit from. 6735 * @returns {Object} Returns the new object. 6736 */ 6737 var baseCreate = (function() { 6738 function object() {} 6739 return function(proto) { 6740 if (!isObject(proto)) { 6741 return {}; 6742 } 6743 if (objectCreate) { 6744 return objectCreate(proto); 6745 } 6746 object.prototype = proto; 6747 var result = new object; 6748 object.prototype = undefined; 6749 return result; 6750 }; 6751 }()); 6752 6753 /** 6754 * The function whose prototype chain sequence wrappers inherit from. 6755 * 6756 * @private 6757 */ 6758 function baseLodash() { 6759 // No operation performed. 6760 } 6761 6762 /** 6763 * The base constructor for creating `lodash` wrapper objects. 6764 * 6765 * @private 6766 * @param {*} value The value to wrap. 6767 * @param {boolean} [chainAll] Enable explicit method chain sequences. 6768 */ 6769 function LodashWrapper(value, chainAll) { 6770 this.__wrapped__ = value; 6771 this.__actions__ = []; 6772 this.__chain__ = !!chainAll; 6773 this.__index__ = 0; 6774 this.__values__ = undefined; 6775 } 6776 6777 /** 6778 * By default, the template delimiters used by lodash are like those in 6779 * embedded Ruby (ERB) as well as ES2015 template strings. Change the 6780 * following template settings to use alternative delimiters. 6781 * 6782 * @static 6783 * @memberOf _ 6784 * @type {Object} 6785 */ 6786 lodash.templateSettings = { 6787 6788 /** 6789 * Used to detect `data` property values to be HTML-escaped. 6790 * 6791 * @memberOf _.templateSettings 6792 * @type {RegExp} 6793 */ 6794 'escape': reEscape, 6795 6796 /** 6797 * Used to detect code to be evaluated. 6798 * 6799 * @memberOf _.templateSettings 6800 * @type {RegExp} 6801 */ 6802 'evaluate': reEvaluate, 6803 6804 /** 6805 * Used to detect `data` property values to inject. 6806 * 6807 * @memberOf _.templateSettings 6808 * @type {RegExp} 6809 */ 6810 'interpolate': reInterpolate, 6811 6812 /** 6813 * Used to reference the data object in the template text. 6814 * 6815 * @memberOf _.templateSettings 6816 * @type {string} 6817 */ 6818 'variable': '', 6819 6820 /** 6821 * Used to import variables into the compiled template. 6822 * 6823 * @memberOf _.templateSettings 6824 * @type {Object} 6825 */ 6826 'imports': { 6827 6828 /** 6829 * A reference to the `lodash` function. 6830 * 6831 * @memberOf _.templateSettings.imports 6832 * @type {Function} 6833 */ 6834 '_': lodash 6835 } 6836 }; 6837 6838 // Ensure wrappers are instances of `baseLodash`. 6839 lodash.prototype = baseLodash.prototype; 6840 lodash.prototype.constructor = lodash; 6841 6842 LodashWrapper.prototype = baseCreate(baseLodash.prototype); 6843 LodashWrapper.prototype.constructor = LodashWrapper; 6844 6845 /*------------------------------------------------------------------------*/ 6846 6847 /** 6848 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. 6849 * 6850 * @private 6851 * @constructor 6852 * @param {*} value The value to wrap. 6853 */ 6854 function LazyWrapper(value) { 6855 this.__wrapped__ = value; 6856 this.__actions__ = []; 6857 this.__dir__ = 1; 6858 this.__filtered__ = false; 6859 this.__iteratees__ = []; 6860 this.__takeCount__ = MAX_ARRAY_LENGTH; 6861 this.__views__ = []; 6862 } 6863 6864 /** 6865 * Creates a clone of the lazy wrapper object. 6866 * 6867 * @private 6868 * @name clone 6869 * @memberOf LazyWrapper 6870 * @returns {Object} Returns the cloned `LazyWrapper` object. 6871 */ 6872 function lazyClone() { 6873 var result = new LazyWrapper(this.__wrapped__); 6874 result.__actions__ = copyArray(this.__actions__); 6875 result.__dir__ = this.__dir__; 6876 result.__filtered__ = this.__filtered__; 6877 result.__iteratees__ = copyArray(this.__iteratees__); 6878 result.__takeCount__ = this.__takeCount__; 6879 result.__views__ = copyArray(this.__views__); 6880 return result; 6881 } 6882 6883 /** 6884 * Reverses the direction of lazy iteration. 6885 * 6886 * @private 6887 * @name reverse 6888 * @memberOf LazyWrapper 6889 * @returns {Object} Returns the new reversed `LazyWrapper` object. 6890 */ 6891 function lazyReverse() { 6892 if (this.__filtered__) { 6893 var result = new LazyWrapper(this); 6894 result.__dir__ = -1; 6895 result.__filtered__ = true; 6896 } else { 6897 result = this.clone(); 6898 result.__dir__ *= -1; 6899 } 6900 return result; 6901 } 6902 6903 /** 6904 * Extracts the unwrapped value from its lazy wrapper. 6905 * 6906 * @private 6907 * @name value 6908 * @memberOf LazyWrapper 6909 * @returns {*} Returns the unwrapped value. 6910 */ 6911 function lazyValue() { 6912 var array = this.__wrapped__.value(), 6913 dir = this.__dir__, 6914 isArr = isArray(array), 6915 isRight = dir < 0, 6916 arrLength = isArr ? array.length : 0, 6917 view = getView(0, arrLength, this.__views__), 6918 start = view.start, 6919 end = view.end, 6920 length = end - start, 6921 index = isRight ? end : (start - 1), 6922 iteratees = this.__iteratees__, 6923 iterLength = iteratees.length, 6924 resIndex = 0, 6925 takeCount = nativeMin(length, this.__takeCount__); 6926 6927 if (!isArr || (!isRight && arrLength == length && takeCount == length)) { 6928 return baseWrapperValue(array, this.__actions__); 6929 } 6930 var result = []; 6931 6932 outer: 6933 while (length-- && resIndex < takeCount) { 6934 index += dir; 6935 6936 var iterIndex = -1, 6937 value = array[index]; 6938 6939 while (++iterIndex < iterLength) { 6940 var data = iteratees[iterIndex], 6941 iteratee = data.iteratee, 6942 type = data.type, 6943 computed = iteratee(value); 6944 6945 if (type == LAZY_MAP_FLAG) { 6946 value = computed; 6947 } else if (!computed) { 6948 if (type == LAZY_FILTER_FLAG) { 6949 continue outer; 6950 } else { 6951 break outer; 6952 } 6953 } 6954 } 6955 result[resIndex++] = value; 6956 } 6957 return result; 6958 } 6959 6960 // Ensure `LazyWrapper` is an instance of `baseLodash`. 6961 LazyWrapper.prototype = baseCreate(baseLodash.prototype); 6962 LazyWrapper.prototype.constructor = LazyWrapper; 6963 6964 /*------------------------------------------------------------------------*/ 6965 6966 /** 6967 * Creates a hash object. 6968 * 6969 * @private 6970 * @constructor 6971 * @param {Array} [entries] The key-value pairs to cache. 6972 */ 6973 function Hash(entries) { 6974 var index = -1, 6975 length = entries == null ? 0 : entries.length; 6976 6977 this.clear(); 6978 while (++index < length) { 6979 var entry = entries[index]; 6980 this.set(entry[0], entry[1]); 6981 } 6982 } 6983 6984 /** 6985 * Removes all key-value entries from the hash. 6986 * 6987 * @private 6988 * @name clear 6989 * @memberOf Hash 6990 */ 6991 function hashClear() { 6992 this.__data__ = nativeCreate ? nativeCreate(null) : {}; 6993 this.size = 0; 6994 } 6995 6996 /** 6997 * Removes `key` and its value from the hash. 6998 * 6999 * @private 7000 * @name delete 7001 * @memberOf Hash 7002 * @param {Object} hash The hash to modify. 7003 * @param {string} key The key of the value to remove. 7004 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 7005 */ 7006 function hashDelete(key) { 7007 var result = this.has(key) && delete this.__data__[key]; 7008 this.size -= result ? 1 : 0; 7009 return result; 7010 } 7011 7012 /** 7013 * Gets the hash value for `key`. 7014 * 7015 * @private 7016 * @name get 7017 * @memberOf Hash 7018 * @param {string} key The key of the value to get. 7019 * @returns {*} Returns the entry value. 7020 */ 7021 function hashGet(key) { 7022 var data = this.__data__; 7023 if (nativeCreate) { 7024 var result = data[key]; 7025 return result === HASH_UNDEFINED ? undefined : result; 7026 } 7027 return hasOwnProperty.call(data, key) ? data[key] : undefined; 7028 } 7029 7030 /** 7031 * Checks if a hash value for `key` exists. 7032 * 7033 * @private 7034 * @name has 7035 * @memberOf Hash 7036 * @param {string} key The key of the entry to check. 7037 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 7038 */ 7039 function hashHas(key) { 7040 var data = this.__data__; 7041 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); 7042 } 7043 7044 /** 7045 * Sets the hash `key` to `value`. 7046 * 7047 * @private 7048 * @name set 7049 * @memberOf Hash 7050 * @param {string} key The key of the value to set. 7051 * @param {*} value The value to set. 7052 * @returns {Object} Returns the hash instance. 7053 */ 7054 function hashSet(key, value) { 7055 var data = this.__data__; 7056 this.size += this.has(key) ? 0 : 1; 7057 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; 7058 return this; 7059 } 7060 7061 // Add methods to `Hash`. 7062 Hash.prototype.clear = hashClear; 7063 Hash.prototype['delete'] = hashDelete; 7064 Hash.prototype.get = hashGet; 7065 Hash.prototype.has = hashHas; 7066 Hash.prototype.set = hashSet; 7067 7068 /*------------------------------------------------------------------------*/ 7069 7070 /** 7071 * Creates an list cache object. 7072 * 7073 * @private 7074 * @constructor 7075 * @param {Array} [entries] The key-value pairs to cache. 7076 */ 7077 function ListCache(entries) { 7078 var index = -1, 7079 length = entries == null ? 0 : entries.length; 7080 7081 this.clear(); 7082 while (++index < length) { 7083 var entry = entries[index]; 7084 this.set(entry[0], entry[1]); 7085 } 7086 } 7087 7088 /** 7089 * Removes all key-value entries from the list cache. 7090 * 7091 * @private 7092 * @name clear 7093 * @memberOf ListCache 7094 */ 7095 function listCacheClear() { 7096 this.__data__ = []; 7097 this.size = 0; 7098 } 7099 7100 /** 7101 * Removes `key` and its value from the list cache. 7102 * 7103 * @private 7104 * @name delete 7105 * @memberOf ListCache 7106 * @param {string} key The key of the value to remove. 7107 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 7108 */ 7109 function listCacheDelete(key) { 7110 var data = this.__data__, 7111 index = assocIndexOf(data, key); 7112 7113 if (index < 0) { 7114 return false; 7115 } 7116 var lastIndex = data.length - 1; 7117 if (index == lastIndex) { 7118 data.pop(); 7119 } else { 7120 splice.call(data, index, 1); 7121 } 7122 --this.size; 7123 return true; 7124 } 7125 7126 /** 7127 * Gets the list cache value for `key`. 7128 * 7129 * @private 7130 * @name get 7131 * @memberOf ListCache 7132 * @param {string} key The key of the value to get. 7133 * @returns {*} Returns the entry value. 7134 */ 7135 function listCacheGet(key) { 7136 var data = this.__data__, 7137 index = assocIndexOf(data, key); 7138 7139 return index < 0 ? undefined : data[index][1]; 7140 } 7141 7142 /** 7143 * Checks if a list cache value for `key` exists. 7144 * 7145 * @private 7146 * @name has 7147 * @memberOf ListCache 7148 * @param {string} key The key of the entry to check. 7149 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 7150 */ 7151 function listCacheHas(key) { 7152 return assocIndexOf(this.__data__, key) > -1; 7153 } 7154 7155 /** 7156 * Sets the list cache `key` to `value`. 7157 * 7158 * @private 7159 * @name set 7160 * @memberOf ListCache 7161 * @param {string} key The key of the value to set. 7162 * @param {*} value The value to set. 7163 * @returns {Object} Returns the list cache instance. 7164 */ 7165 function listCacheSet(key, value) { 7166 var data = this.__data__, 7167 index = assocIndexOf(data, key); 7168 7169 if (index < 0) { 7170 ++this.size; 7171 data.push([key, value]); 7172 } else { 7173 data[index][1] = value; 7174 } 7175 return this; 7176 } 7177 7178 // Add methods to `ListCache`. 7179 ListCache.prototype.clear = listCacheClear; 7180 ListCache.prototype['delete'] = listCacheDelete; 7181 ListCache.prototype.get = listCacheGet; 7182 ListCache.prototype.has = listCacheHas; 7183 ListCache.prototype.set = listCacheSet; 7184 7185 /*------------------------------------------------------------------------*/ 7186 7187 /** 7188 * Creates a map cache object to store key-value pairs. 7189 * 7190 * @private 7191 * @constructor 7192 * @param {Array} [entries] The key-value pairs to cache. 7193 */ 7194 function MapCache(entries) { 7195 var index = -1, 7196 length = entries == null ? 0 : entries.length; 7197 7198 this.clear(); 7199 while (++index < length) { 7200 var entry = entries[index]; 7201 this.set(entry[0], entry[1]); 7202 } 7203 } 7204 7205 /** 7206 * Removes all key-value entries from the map. 7207 * 7208 * @private 7209 * @name clear 7210 * @memberOf MapCache 7211 */ 7212 function mapCacheClear() { 7213 this.size = 0; 7214 this.__data__ = { 7215 'hash': new Hash, 7216 'map': new (Map || ListCache), 7217 'string': new Hash 7218 }; 7219 } 7220 7221 /** 7222 * Removes `key` and its value from the map. 7223 * 7224 * @private 7225 * @name delete 7226 * @memberOf MapCache 7227 * @param {string} key The key of the value to remove. 7228 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 7229 */ 7230 function mapCacheDelete(key) { 7231 var result = getMapData(this, key)['delete'](key); 7232 this.size -= result ? 1 : 0; 7233 return result; 7234 } 7235 7236 /** 7237 * Gets the map value for `key`. 7238 * 7239 * @private 7240 * @name get 7241 * @memberOf MapCache 7242 * @param {string} key The key of the value to get. 7243 * @returns {*} Returns the entry value. 7244 */ 7245 function mapCacheGet(key) { 7246 return getMapData(this, key).get(key); 7247 } 7248 7249 /** 7250 * Checks if a map value for `key` exists. 7251 * 7252 * @private 7253 * @name has 7254 * @memberOf MapCache 7255 * @param {string} key The key of the entry to check. 7256 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 7257 */ 7258 function mapCacheHas(key) { 7259 return getMapData(this, key).has(key); 7260 } 7261 7262 /** 7263 * Sets the map `key` to `value`. 7264 * 7265 * @private 7266 * @name set 7267 * @memberOf MapCache 7268 * @param {string} key The key of the value to set. 7269 * @param {*} value The value to set. 7270 * @returns {Object} Returns the map cache instance. 7271 */ 7272 function mapCacheSet(key, value) { 7273 var data = getMapData(this, key), 7274 size = data.size; 7275 7276 data.set(key, value); 7277 this.size += data.size == size ? 0 : 1; 7278 return this; 7279 } 7280 7281 // Add methods to `MapCache`. 7282 MapCache.prototype.clear = mapCacheClear; 7283 MapCache.prototype['delete'] = mapCacheDelete; 7284 MapCache.prototype.get = mapCacheGet; 7285 MapCache.prototype.has = mapCacheHas; 7286 MapCache.prototype.set = mapCacheSet; 7287 7288 /*------------------------------------------------------------------------*/ 7289 7290 /** 7291 * 7292 * Creates an array cache object to store unique values. 7293 * 7294 * @private 7295 * @constructor 7296 * @param {Array} [values] The values to cache. 7297 */ 7298 function SetCache(values) { 7299 var index = -1, 7300 length = values == null ? 0 : values.length; 7301 7302 this.__data__ = new MapCache; 7303 while (++index < length) { 7304 this.add(values[index]); 7305 } 7306 } 7307 7308 /** 7309 * Adds `value` to the array cache. 7310 * 7311 * @private 7312 * @name add 7313 * @memberOf SetCache 7314 * @alias push 7315 * @param {*} value The value to cache. 7316 * @returns {Object} Returns the cache instance. 7317 */ 7318 function setCacheAdd(value) { 7319 this.__data__.set(value, HASH_UNDEFINED); 7320 return this; 7321 } 7322 7323 /** 7324 * Checks if `value` is in the array cache. 7325 * 7326 * @private 7327 * @name has 7328 * @memberOf SetCache 7329 * @param {*} value The value to search for. 7330 * @returns {number} Returns `true` if `value` is found, else `false`. 7331 */ 7332 function setCacheHas(value) { 7333 return this.__data__.has(value); 7334 } 7335 7336 // Add methods to `SetCache`. 7337 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; 7338 SetCache.prototype.has = setCacheHas; 7339 7340 /*------------------------------------------------------------------------*/ 7341 7342 /** 7343 * Creates a stack cache object to store key-value pairs. 7344 * 7345 * @private 7346 * @constructor 7347 * @param {Array} [entries] The key-value pairs to cache. 7348 */ 7349 function Stack(entries) { 7350 var data = this.__data__ = new ListCache(entries); 7351 this.size = data.size; 7352 } 7353 7354 /** 7355 * Removes all key-value entries from the stack. 7356 * 7357 * @private 7358 * @name clear 7359 * @memberOf Stack 7360 */ 7361 function stackClear() { 7362 this.__data__ = new ListCache; 7363 this.size = 0; 7364 } 7365 7366 /** 7367 * Removes `key` and its value from the stack. 7368 * 7369 * @private 7370 * @name delete 7371 * @memberOf Stack 7372 * @param {string} key The key of the value to remove. 7373 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 7374 */ 7375 function stackDelete(key) { 7376 var data = this.__data__, 7377 result = data['delete'](key); 7378 7379 this.size = data.size; 7380 return result; 7381 } 7382 7383 /** 7384 * Gets the stack value for `key`. 7385 * 7386 * @private 7387 * @name get 7388 * @memberOf Stack 7389 * @param {string} key The key of the value to get. 7390 * @returns {*} Returns the entry value. 7391 */ 7392 function stackGet(key) { 7393 return this.__data__.get(key); 7394 } 7395 7396 /** 7397 * Checks if a stack value for `key` exists. 7398 * 7399 * @private 7400 * @name has 7401 * @memberOf Stack 7402 * @param {string} key The key of the entry to check. 7403 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 7404 */ 7405 function stackHas(key) { 7406 return this.__data__.has(key); 7407 } 7408 7409 /** 7410 * Sets the stack `key` to `value`. 7411 * 7412 * @private 7413 * @name set 7414 * @memberOf Stack 7415 * @param {string} key The key of the value to set. 7416 * @param {*} value The value to set. 7417 * @returns {Object} Returns the stack cache instance. 7418 */ 7419 function stackSet(key, value) { 7420 var data = this.__data__; 7421 if (data instanceof ListCache) { 7422 var pairs = data.__data__; 7423 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 7424 pairs.push([key, value]); 7425 this.size = ++data.size; 7426 return this; 7427 } 7428 data = this.__data__ = new MapCache(pairs); 7429 } 7430 data.set(key, value); 7431 this.size = data.size; 7432 return this; 7433 } 7434 7435 // Add methods to `Stack`. 7436 Stack.prototype.clear = stackClear; 7437 Stack.prototype['delete'] = stackDelete; 7438 Stack.prototype.get = stackGet; 7439 Stack.prototype.has = stackHas; 7440 Stack.prototype.set = stackSet; 7441 7442 /*------------------------------------------------------------------------*/ 7443 7444 /** 7445 * Creates an array of the enumerable property names of the array-like `value`. 7446 * 7447 * @private 7448 * @param {*} value The value to query. 7449 * @param {boolean} inherited Specify returning inherited property names. 7450 * @returns {Array} Returns the array of property names. 7451 */ 7452 function arrayLikeKeys(value, inherited) { 7453 var isArr = isArray(value), 7454 isArg = !isArr && isArguments(value), 7455 isBuff = !isArr && !isArg && isBuffer(value), 7456 isType = !isArr && !isArg && !isBuff && isTypedArray(value), 7457 skipIndexes = isArr || isArg || isBuff || isType, 7458 result = skipIndexes ? baseTimes(value.length, String) : [], 7459 length = result.length; 7460 7461 for (var key in value) { 7462 if ((inherited || hasOwnProperty.call(value, key)) && 7463 !(skipIndexes && ( 7464 // Safari 9 has enumerable `arguments.length` in strict mode. 7465 key == 'length' || 7466 // Node.js 0.10 has enumerable non-index properties on buffers. 7467 (isBuff && (key == 'offset' || key == 'parent')) || 7468 // PhantomJS 2 has enumerable non-index properties on typed arrays. 7469 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 7470 // Skip index properties. 7471 isIndex(key, length) 7472 ))) { 7473 result.push(key); 7474 } 7475 } 7476 return result; 7477 } 7478 7479 /** 7480 * A specialized version of `_.sample` for arrays. 7481 * 7482 * @private 7483 * @param {Array} array The array to sample. 7484 * @returns {*} Returns the random element. 7485 */ 7486 function arraySample(array) { 7487 var length = array.length; 7488 return length ? array[baseRandom(0, length - 1)] : undefined; 7489 } 7490 7491 /** 7492 * A specialized version of `_.sampleSize` for arrays. 7493 * 7494 * @private 7495 * @param {Array} array The array to sample. 7496 * @param {number} n The number of elements to sample. 7497 * @returns {Array} Returns the random elements. 7498 */ 7499 function arraySampleSize(array, n) { 7500 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); 7501 } 7502 7503 /** 7504 * A specialized version of `_.shuffle` for arrays. 7505 * 7506 * @private 7507 * @param {Array} array The array to shuffle. 7508 * @returns {Array} Returns the new shuffled array. 7509 */ 7510 function arrayShuffle(array) { 7511 return shuffleSelf(copyArray(array)); 7512 } 7513 7514 /** 7515 * This function is like `assignValue` except that it doesn't assign 7516 * `undefined` values. 7517 * 7518 * @private 7519 * @param {Object} object The object to modify. 7520 * @param {string} key The key of the property to assign. 7521 * @param {*} value The value to assign. 7522 */ 7523 function assignMergeValue(object, key, value) { 7524 if ((value !== undefined && !eq(object[key], value)) || 7525 (value === undefined && !(key in object))) { 7526 baseAssignValue(object, key, value); 7527 } 7528 } 7529 7530 /** 7531 * Assigns `value` to `key` of `object` if the existing value is not equivalent 7532 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 7533 * for equality comparisons. 7534 * 7535 * @private 7536 * @param {Object} object The object to modify. 7537 * @param {string} key The key of the property to assign. 7538 * @param {*} value The value to assign. 7539 */ 7540 function assignValue(object, key, value) { 7541 var objValue = object[key]; 7542 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || 7543 (value === undefined && !(key in object))) { 7544 baseAssignValue(object, key, value); 7545 } 7546 } 7547 7548 /** 7549 * Gets the index at which the `key` is found in `array` of key-value pairs. 7550 * 7551 * @private 7552 * @param {Array} array The array to inspect. 7553 * @param {*} key The key to search for. 7554 * @returns {number} Returns the index of the matched value, else `-1`. 7555 */ 7556 function assocIndexOf(array, key) { 7557 var length = array.length; 7558 while (length--) { 7559 if (eq(array[length][0], key)) { 7560 return length; 7561 } 7562 } 7563 return -1; 7564 } 7565 7566 /** 7567 * Aggregates elements of `collection` on `accumulator` with keys transformed 7568 * by `iteratee` and values set by `setter`. 7569 * 7570 * @private 7571 * @param {Array|Object} collection The collection to iterate over. 7572 * @param {Function} setter The function to set `accumulator` values. 7573 * @param {Function} iteratee The iteratee to transform keys. 7574 * @param {Object} accumulator The initial aggregated object. 7575 * @returns {Function} Returns `accumulator`. 7576 */ 7577 function baseAggregator(collection, setter, iteratee, accumulator) { 7578 baseEach(collection, function(value, key, collection) { 7579 setter(accumulator, value, iteratee(value), collection); 7580 }); 7581 return accumulator; 7582 } 7583 7584 /** 7585 * The base implementation of `_.assign` without support for multiple sources 7586 * or `customizer` functions. 7587 * 7588 * @private 7589 * @param {Object} object The destination object. 7590 * @param {Object} source The source object. 7591 * @returns {Object} Returns `object`. 7592 */ 7593 function baseAssign(object, source) { 7594 return object && copyObject(source, keys(source), object); 7595 } 7596 7597 /** 7598 * The base implementation of `_.assignIn` without support for multiple sources 7599 * or `customizer` functions. 7600 * 7601 * @private 7602 * @param {Object} object The destination object. 7603 * @param {Object} source The source object. 7604 * @returns {Object} Returns `object`. 7605 */ 7606 function baseAssignIn(object, source) { 7607 return object && copyObject(source, keysIn(source), object); 7608 } 7609 7610 /** 7611 * The base implementation of `assignValue` and `assignMergeValue` without 7612 * value checks. 7613 * 7614 * @private 7615 * @param {Object} object The object to modify. 7616 * @param {string} key The key of the property to assign. 7617 * @param {*} value The value to assign. 7618 */ 7619 function baseAssignValue(object, key, value) { 7620 if (key == '__proto__' && defineProperty) { 7621 defineProperty(object, key, { 7622 'configurable': true, 7623 'enumerable': true, 7624 'value': value, 7625 'writable': true 7626 }); 7627 } else { 7628 object[key] = value; 7629 } 7630 } 7631 7632 /** 7633 * The base implementation of `_.at` without support for individual paths. 7634 * 7635 * @private 7636 * @param {Object} object The object to iterate over. 7637 * @param {string[]} paths The property paths to pick. 7638 * @returns {Array} Returns the picked elements. 7639 */ 7640 function baseAt(object, paths) { 7641 var index = -1, 7642 length = paths.length, 7643 result = Array(length), 7644 skip = object == null; 7645 7646 while (++index < length) { 7647 result[index] = skip ? undefined : get(object, paths[index]); 7648 } 7649 return result; 7650 } 7651 7652 /** 7653 * The base implementation of `_.clamp` which doesn't coerce arguments. 7654 * 7655 * @private 7656 * @param {number} number The number to clamp. 7657 * @param {number} [lower] The lower bound. 7658 * @param {number} upper The upper bound. 7659 * @returns {number} Returns the clamped number. 7660 */ 7661 function baseClamp(number, lower, upper) { 7662 if (number === number) { 7663 if (upper !== undefined) { 7664 number = number <= upper ? number : upper; 7665 } 7666 if (lower !== undefined) { 7667 number = number >= lower ? number : lower; 7668 } 7669 } 7670 return number; 7671 } 7672 7673 /** 7674 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 7675 * traversed objects. 7676 * 7677 * @private 7678 * @param {*} value The value to clone. 7679 * @param {boolean} bitmask The bitmask flags. 7680 * 1 - Deep clone 7681 * 2 - Flatten inherited properties 7682 * 4 - Clone symbols 7683 * @param {Function} [customizer] The function to customize cloning. 7684 * @param {string} [key] The key of `value`. 7685 * @param {Object} [object] The parent object of `value`. 7686 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 7687 * @returns {*} Returns the cloned value. 7688 */ 7689 function baseClone(value, bitmask, customizer, key, object, stack) { 7690 var result, 7691 isDeep = bitmask & CLONE_DEEP_FLAG, 7692 isFlat = bitmask & CLONE_FLAT_FLAG, 7693 isFull = bitmask & CLONE_SYMBOLS_FLAG; 7694 7695 if (customizer) { 7696 result = object ? customizer(value, key, object, stack) : customizer(value); 7697 } 7698 if (result !== undefined) { 7699 return result; 7700 } 7701 if (!isObject(value)) { 7702 return value; 7703 } 7704 var isArr = isArray(value); 7705 if (isArr) { 7706 result = initCloneArray(value); 7707 if (!isDeep) { 7708 return copyArray(value, result); 7709 } 7710 } else { 7711 var tag = getTag(value), 7712 isFunc = tag == funcTag || tag == genTag; 7713 7714 if (isBuffer(value)) { 7715 return cloneBuffer(value, isDeep); 7716 } 7717 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 7718 result = (isFlat || isFunc) ? {} : initCloneObject(value); 7719 if (!isDeep) { 7720 return isFlat 7721 ? copySymbolsIn(value, baseAssignIn(result, value)) 7722 : copySymbols(value, baseAssign(result, value)); 7723 } 7724 } else { 7725 if (!cloneableTags[tag]) { 7726 return object ? value : {}; 7727 } 7728 result = initCloneByTag(value, tag, isDeep); 7729 } 7730 } 7731 // Check for circular references and return its corresponding clone. 7732 stack || (stack = new Stack); 7733 var stacked = stack.get(value); 7734 if (stacked) { 7735 return stacked; 7736 } 7737 stack.set(value, result); 7738 7739 if (isSet(value)) { 7740 value.forEach(function(subValue) { 7741 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); 7742 }); 7743 } else if (isMap(value)) { 7744 value.forEach(function(subValue, key) { 7745 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); 7746 }); 7747 } 7748 7749 var keysFunc = isFull 7750 ? (isFlat ? getAllKeysIn : getAllKeys) 7751 : (isFlat ? keysIn : keys); 7752 7753 var props = isArr ? undefined : keysFunc(value); 7754 arrayEach(props || value, function(subValue, key) { 7755 if (props) { 7756 key = subValue; 7757 subValue = value[key]; 7758 } 7759 // Recursively populate clone (susceptible to call stack limits). 7760 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 7761 }); 7762 return result; 7763 } 7764 7765 /** 7766 * The base implementation of `_.conforms` which doesn't clone `source`. 7767 * 7768 * @private 7769 * @param {Object} source The object of property predicates to conform to. 7770 * @returns {Function} Returns the new spec function. 7771 */ 7772 function baseConforms(source) { 7773 var props = keys(source); 7774 return function(object) { 7775 return baseConformsTo(object, source, props); 7776 }; 7777 } 7778 7779 /** 7780 * The base implementation of `_.conformsTo` which accepts `props` to check. 7781 * 7782 * @private 7783 * @param {Object} object The object to inspect. 7784 * @param {Object} source The object of property predicates to conform to. 7785 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 7786 */ 7787 function baseConformsTo(object, source, props) { 7788 var length = props.length; 7789 if (object == null) { 7790 return !length; 7791 } 7792 object = Object(object); 7793 while (length--) { 7794 var key = props[length], 7795 predicate = source[key], 7796 value = object[key]; 7797 7798 if ((value === undefined && !(key in object)) || !predicate(value)) { 7799 return false; 7800 } 7801 } 7802 return true; 7803 } 7804 7805 /** 7806 * The base implementation of `_.delay` and `_.defer` which accepts `args` 7807 * to provide to `func`. 7808 * 7809 * @private 7810 * @param {Function} func The function to delay. 7811 * @param {number} wait The number of milliseconds to delay invocation. 7812 * @param {Array} args The arguments to provide to `func`. 7813 * @returns {number|Object} Returns the timer id or timeout object. 7814 */ 7815 function baseDelay(func, wait, args) { 7816 if (typeof func != 'function') { 7817 throw new TypeError(FUNC_ERROR_TEXT); 7818 } 7819 return setTimeout(function() { func.apply(undefined, args); }, wait); 7820 } 7821 7822 /** 7823 * The base implementation of methods like `_.difference` without support 7824 * for excluding multiple arrays or iteratee shorthands. 7825 * 7826 * @private 7827 * @param {Array} array The array to inspect. 7828 * @param {Array} values The values to exclude. 7829 * @param {Function} [iteratee] The iteratee invoked per element. 7830 * @param {Function} [comparator] The comparator invoked per element. 7831 * @returns {Array} Returns the new array of filtered values. 7832 */ 7833 function baseDifference(array, values, iteratee, comparator) { 7834 var index = -1, 7835 includes = arrayIncludes, 7836 isCommon = true, 7837 length = array.length, 7838 result = [], 7839 valuesLength = values.length; 7840 7841 if (!length) { 7842 return result; 7843 } 7844 if (iteratee) { 7845 values = arrayMap(values, baseUnary(iteratee)); 7846 } 7847 if (comparator) { 7848 includes = arrayIncludesWith; 7849 isCommon = false; 7850 } 7851 else if (values.length >= LARGE_ARRAY_SIZE) { 7852 includes = cacheHas; 7853 isCommon = false; 7854 values = new SetCache(values); 7855 } 7856 outer: 7857 while (++index < length) { 7858 var value = array[index], 7859 computed = iteratee == null ? value : iteratee(value); 7860 7861 value = (comparator || value !== 0) ? value : 0; 7862 if (isCommon && computed === computed) { 7863 var valuesIndex = valuesLength; 7864 while (valuesIndex--) { 7865 if (values[valuesIndex] === computed) { 7866 continue outer; 7867 } 7868 } 7869 result.push(value); 7870 } 7871 else if (!includes(values, computed, comparator)) { 7872 result.push(value); 7873 } 7874 } 7875 return result; 7876 } 7877 7878 /** 7879 * The base implementation of `_.forEach` without support for iteratee shorthands. 7880 * 7881 * @private 7882 * @param {Array|Object} collection The collection to iterate over. 7883 * @param {Function} iteratee The function invoked per iteration. 7884 * @returns {Array|Object} Returns `collection`. 7885 */ 7886 var baseEach = createBaseEach(baseForOwn); 7887 7888 /** 7889 * The base implementation of `_.forEachRight` without support for iteratee shorthands. 7890 * 7891 * @private 7892 * @param {Array|Object} collection The collection to iterate over. 7893 * @param {Function} iteratee The function invoked per iteration. 7894 * @returns {Array|Object} Returns `collection`. 7895 */ 7896 var baseEachRight = createBaseEach(baseForOwnRight, true); 7897 7898 /** 7899 * The base implementation of `_.every` without support for iteratee shorthands. 7900 * 7901 * @private 7902 * @param {Array|Object} collection The collection to iterate over. 7903 * @param {Function} predicate The function invoked per iteration. 7904 * @returns {boolean} Returns `true` if all elements pass the predicate check, 7905 * else `false` 7906 */ 7907 function baseEvery(collection, predicate) { 7908 var result = true; 7909 baseEach(collection, function(value, index, collection) { 7910 result = !!predicate(value, index, collection); 7911 return result; 7912 }); 7913 return result; 7914 } 7915 7916 /** 7917 * The base implementation of methods like `_.max` and `_.min` which accepts a 7918 * `comparator` to determine the extremum value. 7919 * 7920 * @private 7921 * @param {Array} array The array to iterate over. 7922 * @param {Function} iteratee The iteratee invoked per iteration. 7923 * @param {Function} comparator The comparator used to compare values. 7924 * @returns {*} Returns the extremum value. 7925 */ 7926 function baseExtremum(array, iteratee, comparator) { 7927 var index = -1, 7928 length = array.length; 7929 7930 while (++index < length) { 7931 var value = array[index], 7932 current = iteratee(value); 7933 7934 if (current != null && (computed === undefined 7935 ? (current === current && !isSymbol(current)) 7936 : comparator(current, computed) 7937 )) { 7938 var computed = current, 7939 result = value; 7940 } 7941 } 7942 return result; 7943 } 7944 7945 /** 7946 * The base implementation of `_.fill` without an iteratee call guard. 7947 * 7948 * @private 7949 * @param {Array} array The array to fill. 7950 * @param {*} value The value to fill `array` with. 7951 * @param {number} [start=0] The start position. 7952 * @param {number} [end=array.length] The end position. 7953 * @returns {Array} Returns `array`. 7954 */ 7955 function baseFill(array, value, start, end) { 7956 var length = array.length; 7957 7958 start = toInteger(start); 7959 if (start < 0) { 7960 start = -start > length ? 0 : (length + start); 7961 } 7962 end = (end === undefined || end > length) ? length : toInteger(end); 7963 if (end < 0) { 7964 end += length; 7965 } 7966 end = start > end ? 0 : toLength(end); 7967 while (start < end) { 7968 array[start++] = value; 7969 } 7970 return array; 7971 } 7972 7973 /** 7974 * The base implementation of `_.filter` without support for iteratee shorthands. 7975 * 7976 * @private 7977 * @param {Array|Object} collection The collection to iterate over. 7978 * @param {Function} predicate The function invoked per iteration. 7979 * @returns {Array} Returns the new filtered array. 7980 */ 7981 function baseFilter(collection, predicate) { 7982 var result = []; 7983 baseEach(collection, function(value, index, collection) { 7984 if (predicate(value, index, collection)) { 7985 result.push(value); 7986 } 7987 }); 7988 return result; 7989 } 7990 7991 /** 7992 * The base implementation of `_.flatten` with support for restricting flattening. 7993 * 7994 * @private 7995 * @param {Array} array The array to flatten. 7996 * @param {number} depth The maximum recursion depth. 7997 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. 7998 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. 7999 * @param {Array} [result=[]] The initial result value. 8000 * @returns {Array} Returns the new flattened array. 8001 */ 8002 function baseFlatten(array, depth, predicate, isStrict, result) { 8003 var index = -1, 8004 length = array.length; 8005 8006 predicate || (predicate = isFlattenable); 8007 result || (result = []); 8008 8009 while (++index < length) { 8010 var value = array[index]; 8011 if (depth > 0 && predicate(value)) { 8012 if (depth > 1) { 8013 // Recursively flatten arrays (susceptible to call stack limits). 8014 baseFlatten(value, depth - 1, predicate, isStrict, result); 8015 } else { 8016 arrayPush(result, value); 8017 } 8018 } else if (!isStrict) { 8019 result[result.length] = value; 8020 } 8021 } 8022 return result; 8023 } 8024 8025 /** 8026 * The base implementation of `baseForOwn` which iterates over `object` 8027 * properties returned by `keysFunc` and invokes `iteratee` for each property. 8028 * Iteratee functions may exit iteration early by explicitly returning `false`. 8029 * 8030 * @private 8031 * @param {Object} object The object to iterate over. 8032 * @param {Function} iteratee The function invoked per iteration. 8033 * @param {Function} keysFunc The function to get the keys of `object`. 8034 * @returns {Object} Returns `object`. 8035 */ 8036 var baseFor = createBaseFor(); 8037 8038 /** 8039 * This function is like `baseFor` except that it iterates over properties 8040 * in the opposite order. 8041 * 8042 * @private 8043 * @param {Object} object The object to iterate over. 8044 * @param {Function} iteratee The function invoked per iteration. 8045 * @param {Function} keysFunc The function to get the keys of `object`. 8046 * @returns {Object} Returns `object`. 8047 */ 8048 var baseForRight = createBaseFor(true); 8049 8050 /** 8051 * The base implementation of `_.forOwn` without support for iteratee shorthands. 8052 * 8053 * @private 8054 * @param {Object} object The object to iterate over. 8055 * @param {Function} iteratee The function invoked per iteration. 8056 * @returns {Object} Returns `object`. 8057 */ 8058 function baseForOwn(object, iteratee) { 8059 return object && baseFor(object, iteratee, keys); 8060 } 8061 8062 /** 8063 * The base implementation of `_.forOwnRight` without support for iteratee shorthands. 8064 * 8065 * @private 8066 * @param {Object} object The object to iterate over. 8067 * @param {Function} iteratee The function invoked per iteration. 8068 * @returns {Object} Returns `object`. 8069 */ 8070 function baseForOwnRight(object, iteratee) { 8071 return object && baseForRight(object, iteratee, keys); 8072 } 8073 8074 /** 8075 * The base implementation of `_.functions` which creates an array of 8076 * `object` function property names filtered from `props`. 8077 * 8078 * @private 8079 * @param {Object} object The object to inspect. 8080 * @param {Array} props The property names to filter. 8081 * @returns {Array} Returns the function names. 8082 */ 8083 function baseFunctions(object, props) { 8084 return arrayFilter(props, function(key) { 8085 return isFunction(object[key]); 8086 }); 8087 } 8088 8089 /** 8090 * The base implementation of `_.get` without support for default values. 8091 * 8092 * @private 8093 * @param {Object} object The object to query. 8094 * @param {Array|string} path The path of the property to get. 8095 * @returns {*} Returns the resolved value. 8096 */ 8097 function baseGet(object, path) { 8098 path = castPath(path, object); 8099 8100 var index = 0, 8101 length = path.length; 8102 8103 while (object != null && index < length) { 8104 object = object[toKey(path[index++])]; 8105 } 8106 return (index && index == length) ? object : undefined; 8107 } 8108 8109 /** 8110 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 8111 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 8112 * symbols of `object`. 8113 * 8114 * @private 8115 * @param {Object} object The object to query. 8116 * @param {Function} keysFunc The function to get the keys of `object`. 8117 * @param {Function} symbolsFunc The function to get the symbols of `object`. 8118 * @returns {Array} Returns the array of property names and symbols. 8119 */ 8120 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 8121 var result = keysFunc(object); 8122 return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); 8123 } 8124 8125 /** 8126 * The base implementation of `getTag` without fallbacks for buggy environments. 8127 * 8128 * @private 8129 * @param {*} value The value to query. 8130 * @returns {string} Returns the `toStringTag`. 8131 */ 8132 function baseGetTag(value) { 8133 if (value == null) { 8134 return value === undefined ? undefinedTag : nullTag; 8135 } 8136 return (symToStringTag && symToStringTag in Object(value)) 8137 ? getRawTag(value) 8138 : objectToString(value); 8139 } 8140 8141 /** 8142 * The base implementation of `_.gt` which doesn't coerce arguments. 8143 * 8144 * @private 8145 * @param {*} value The value to compare. 8146 * @param {*} other The other value to compare. 8147 * @returns {boolean} Returns `true` if `value` is greater than `other`, 8148 * else `false`. 8149 */ 8150 function baseGt(value, other) { 8151 return value > other; 8152 } 8153 8154 /** 8155 * The base implementation of `_.has` without support for deep paths. 8156 * 8157 * @private 8158 * @param {Object} [object] The object to query. 8159 * @param {Array|string} key The key to check. 8160 * @returns {boolean} Returns `true` if `key` exists, else `false`. 8161 */ 8162 function baseHas(object, key) { 8163 return object != null && hasOwnProperty.call(object, key); 8164 } 8165 8166 /** 8167 * The base implementation of `_.hasIn` without support for deep paths. 8168 * 8169 * @private 8170 * @param {Object} [object] The object to query. 8171 * @param {Array|string} key The key to check. 8172 * @returns {boolean} Returns `true` if `key` exists, else `false`. 8173 */ 8174 function baseHasIn(object, key) { 8175 return object != null && key in Object(object); 8176 } 8177 8178 /** 8179 * The base implementation of `_.inRange` which doesn't coerce arguments. 8180 * 8181 * @private 8182 * @param {number} number The number to check. 8183 * @param {number} start The start of the range. 8184 * @param {number} end The end of the range. 8185 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 8186 */ 8187 function baseInRange(number, start, end) { 8188 return number >= nativeMin(start, end) && number < nativeMax(start, end); 8189 } 8190 8191 /** 8192 * The base implementation of methods like `_.intersection`, without support 8193 * for iteratee shorthands, that accepts an array of arrays to inspect. 8194 * 8195 * @private 8196 * @param {Array} arrays The arrays to inspect. 8197 * @param {Function} [iteratee] The iteratee invoked per element. 8198 * @param {Function} [comparator] The comparator invoked per element. 8199 * @returns {Array} Returns the new array of shared values. 8200 */ 8201 function baseIntersection(arrays, iteratee, comparator) { 8202 var includes = comparator ? arrayIncludesWith : arrayIncludes, 8203 length = arrays[0].length, 8204 othLength = arrays.length, 8205 othIndex = othLength, 8206 caches = Array(othLength), 8207 maxLength = Infinity, 8208 result = []; 8209 8210 while (othIndex--) { 8211 var array = arrays[othIndex]; 8212 if (othIndex && iteratee) { 8213 array = arrayMap(array, baseUnary(iteratee)); 8214 } 8215 maxLength = nativeMin(array.length, maxLength); 8216 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) 8217 ? new SetCache(othIndex && array) 8218 : undefined; 8219 } 8220 array = arrays[0]; 8221 8222 var index = -1, 8223 seen = caches[0]; 8224 8225 outer: 8226 while (++index < length && result.length < maxLength) { 8227 var value = array[index], 8228 computed = iteratee ? iteratee(value) : value; 8229 8230 value = (comparator || value !== 0) ? value : 0; 8231 if (!(seen 8232 ? cacheHas(seen, computed) 8233 : includes(result, computed, comparator) 8234 )) { 8235 othIndex = othLength; 8236 while (--othIndex) { 8237 var cache = caches[othIndex]; 8238 if (!(cache 8239 ? cacheHas(cache, computed) 8240 : includes(arrays[othIndex], computed, comparator)) 8241 ) { 8242 continue outer; 8243 } 8244 } 8245 if (seen) { 8246 seen.push(computed); 8247 } 8248 result.push(value); 8249 } 8250 } 8251 return result; 8252 } 8253 8254 /** 8255 * The base implementation of `_.invert` and `_.invertBy` which inverts 8256 * `object` with values transformed by `iteratee` and set by `setter`. 8257 * 8258 * @private 8259 * @param {Object} object The object to iterate over. 8260 * @param {Function} setter The function to set `accumulator` values. 8261 * @param {Function} iteratee The iteratee to transform values. 8262 * @param {Object} accumulator The initial inverted object. 8263 * @returns {Function} Returns `accumulator`. 8264 */ 8265 function baseInverter(object, setter, iteratee, accumulator) { 8266 baseForOwn(object, function(value, key, object) { 8267 setter(accumulator, iteratee(value), key, object); 8268 }); 8269 return accumulator; 8270 } 8271 8272 /** 8273 * The base implementation of `_.invoke` without support for individual 8274 * method arguments. 8275 * 8276 * @private 8277 * @param {Object} object The object to query. 8278 * @param {Array|string} path The path of the method to invoke. 8279 * @param {Array} args The arguments to invoke the method with. 8280 * @returns {*} Returns the result of the invoked method. 8281 */ 8282 function baseInvoke(object, path, args) { 8283 path = castPath(path, object); 8284 object = parent(object, path); 8285 var func = object == null ? object : object[toKey(last(path))]; 8286 return func == null ? undefined : apply(func, object, args); 8287 } 8288 8289 /** 8290 * The base implementation of `_.isArguments`. 8291 * 8292 * @private 8293 * @param {*} value The value to check. 8294 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 8295 */ 8296 function baseIsArguments(value) { 8297 return isObjectLike(value) && baseGetTag(value) == argsTag; 8298 } 8299 8300 /** 8301 * The base implementation of `_.isArrayBuffer` without Node.js optimizations. 8302 * 8303 * @private 8304 * @param {*} value The value to check. 8305 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 8306 */ 8307 function baseIsArrayBuffer(value) { 8308 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; 8309 } 8310 8311 /** 8312 * The base implementation of `_.isDate` without Node.js optimizations. 8313 * 8314 * @private 8315 * @param {*} value The value to check. 8316 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 8317 */ 8318 function baseIsDate(value) { 8319 return isObjectLike(value) && baseGetTag(value) == dateTag; 8320 } 8321 8322 /** 8323 * The base implementation of `_.isEqual` which supports partial comparisons 8324 * and tracks traversed objects. 8325 * 8326 * @private 8327 * @param {*} value The value to compare. 8328 * @param {*} other The other value to compare. 8329 * @param {boolean} bitmask The bitmask flags. 8330 * 1 - Unordered comparison 8331 * 2 - Partial comparison 8332 * @param {Function} [customizer] The function to customize comparisons. 8333 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 8334 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 8335 */ 8336 function baseIsEqual(value, other, bitmask, customizer, stack) { 8337 if (value === other) { 8338 return true; 8339 } 8340 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 8341 return value !== value && other !== other; 8342 } 8343 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 8344 } 8345 8346 /** 8347 * A specialized version of `baseIsEqual` for arrays and objects which performs 8348 * deep comparisons and tracks traversed objects enabling objects with circular 8349 * references to be compared. 8350 * 8351 * @private 8352 * @param {Object} object The object to compare. 8353 * @param {Object} other The other object to compare. 8354 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 8355 * @param {Function} customizer The function to customize comparisons. 8356 * @param {Function} equalFunc The function to determine equivalents of values. 8357 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 8358 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 8359 */ 8360 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 8361 var objIsArr = isArray(object), 8362 othIsArr = isArray(other), 8363 objTag = objIsArr ? arrayTag : getTag(object), 8364 othTag = othIsArr ? arrayTag : getTag(other); 8365 8366 objTag = objTag == argsTag ? objectTag : objTag; 8367 othTag = othTag == argsTag ? objectTag : othTag; 8368 8369 var objIsObj = objTag == objectTag, 8370 othIsObj = othTag == objectTag, 8371 isSameTag = objTag == othTag; 8372 8373 if (isSameTag && isBuffer(object)) { 8374 if (!isBuffer(other)) { 8375 return false; 8376 } 8377 objIsArr = true; 8378 objIsObj = false; 8379 } 8380 if (isSameTag && !objIsObj) { 8381 stack || (stack = new Stack); 8382 return (objIsArr || isTypedArray(object)) 8383 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) 8384 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 8385 } 8386 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 8387 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 8388 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 8389 8390 if (objIsWrapped || othIsWrapped) { 8391 var objUnwrapped = objIsWrapped ? object.value() : object, 8392 othUnwrapped = othIsWrapped ? other.value() : other; 8393 8394 stack || (stack = new Stack); 8395 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 8396 } 8397 } 8398 if (!isSameTag) { 8399 return false; 8400 } 8401 stack || (stack = new Stack); 8402 return equalObjects(object, other, bitmask, customizer, equalFunc, stack); 8403 } 8404 8405 /** 8406 * The base implementation of `_.isMap` without Node.js optimizations. 8407 * 8408 * @private 8409 * @param {*} value The value to check. 8410 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 8411 */ 8412 function baseIsMap(value) { 8413 return isObjectLike(value) && getTag(value) == mapTag; 8414 } 8415 8416 /** 8417 * The base implementation of `_.isMatch` without support for iteratee shorthands. 8418 * 8419 * @private 8420 * @param {Object} object The object to inspect. 8421 * @param {Object} source The object of property values to match. 8422 * @param {Array} matchData The property names, values, and compare flags to match. 8423 * @param {Function} [customizer] The function to customize comparisons. 8424 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 8425 */ 8426 function baseIsMatch(object, source, matchData, customizer) { 8427 var index = matchData.length, 8428 length = index, 8429 noCustomizer = !customizer; 8430 8431 if (object == null) { 8432 return !length; 8433 } 8434 object = Object(object); 8435 while (index--) { 8436 var data = matchData[index]; 8437 if ((noCustomizer && data[2]) 8438 ? data[1] !== object[data[0]] 8439 : !(data[0] in object) 8440 ) { 8441 return false; 8442 } 8443 } 8444 while (++index < length) { 8445 data = matchData[index]; 8446 var key = data[0], 8447 objValue = object[key], 8448 srcValue = data[1]; 8449 8450 if (noCustomizer && data[2]) { 8451 if (objValue === undefined && !(key in object)) { 8452 return false; 8453 } 8454 } else { 8455 var stack = new Stack; 8456 if (customizer) { 8457 var result = customizer(objValue, srcValue, key, object, source, stack); 8458 } 8459 if (!(result === undefined 8460 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) 8461 : result 8462 )) { 8463 return false; 8464 } 8465 } 8466 } 8467 return true; 8468 } 8469 8470 /** 8471 * The base implementation of `_.isNative` without bad shim checks. 8472 * 8473 * @private 8474 * @param {*} value The value to check. 8475 * @returns {boolean} Returns `true` if `value` is a native function, 8476 * else `false`. 8477 */ 8478 function baseIsNative(value) { 8479 if (!isObject(value) || isMasked(value)) { 8480 return false; 8481 } 8482 var pattern = isFunction(value) ? reIsNative : reIsHostCtor; 8483 return pattern.test(toSource(value)); 8484 } 8485 8486 /** 8487 * The base implementation of `_.isRegExp` without Node.js optimizations. 8488 * 8489 * @private 8490 * @param {*} value The value to check. 8491 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 8492 */ 8493 function baseIsRegExp(value) { 8494 return isObjectLike(value) && baseGetTag(value) == regexpTag; 8495 } 8496 8497 /** 8498 * The base implementation of `_.isSet` without Node.js optimizations. 8499 * 8500 * @private 8501 * @param {*} value The value to check. 8502 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 8503 */ 8504 function baseIsSet(value) { 8505 return isObjectLike(value) && getTag(value) == setTag; 8506 } 8507 8508 /** 8509 * The base implementation of `_.isTypedArray` without Node.js optimizations. 8510 * 8511 * @private 8512 * @param {*} value The value to check. 8513 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 8514 */ 8515 function baseIsTypedArray(value) { 8516 return isObjectLike(value) && 8517 isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; 8518 } 8519 8520 /** 8521 * The base implementation of `_.iteratee`. 8522 * 8523 * @private 8524 * @param {*} [value=_.identity] The value to convert to an iteratee. 8525 * @returns {Function} Returns the iteratee. 8526 */ 8527 function baseIteratee(value) { 8528 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 8529 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 8530 if (typeof value == 'function') { 8531 return value; 8532 } 8533 if (value == null) { 8534 return identity; 8535 } 8536 if (typeof value == 'object') { 8537 return isArray(value) 8538 ? baseMatchesProperty(value[0], value[1]) 8539 : baseMatches(value); 8540 } 8541 return property(value); 8542 } 8543 8544 /** 8545 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 8546 * 8547 * @private 8548 * @param {Object} object The object to query. 8549 * @returns {Array} Returns the array of property names. 8550 */ 8551 function baseKeys(object) { 8552 if (!isPrototype(object)) { 8553 return nativeKeys(object); 8554 } 8555 var result = []; 8556 for (var key in Object(object)) { 8557 if (hasOwnProperty.call(object, key) && key != 'constructor') { 8558 result.push(key); 8559 } 8560 } 8561 return result; 8562 } 8563 8564 /** 8565 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 8566 * 8567 * @private 8568 * @param {Object} object The object to query. 8569 * @returns {Array} Returns the array of property names. 8570 */ 8571 function baseKeysIn(object) { 8572 if (!isObject(object)) { 8573 return nativeKeysIn(object); 8574 } 8575 var isProto = isPrototype(object), 8576 result = []; 8577 8578 for (var key in object) { 8579 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 8580 result.push(key); 8581 } 8582 } 8583 return result; 8584 } 8585 8586 /** 8587 * The base implementation of `_.lt` which doesn't coerce arguments. 8588 * 8589 * @private 8590 * @param {*} value The value to compare. 8591 * @param {*} other The other value to compare. 8592 * @returns {boolean} Returns `true` if `value` is less than `other`, 8593 * else `false`. 8594 */ 8595 function baseLt(value, other) { 8596 return value < other; 8597 } 8598 8599 /** 8600 * The base implementation of `_.map` without support for iteratee shorthands. 8601 * 8602 * @private 8603 * @param {Array|Object} collection The collection to iterate over. 8604 * @param {Function} iteratee The function invoked per iteration. 8605 * @returns {Array} Returns the new mapped array. 8606 */ 8607 function baseMap(collection, iteratee) { 8608 var index = -1, 8609 result = isArrayLike(collection) ? Array(collection.length) : []; 8610 8611 baseEach(collection, function(value, key, collection) { 8612 result[++index] = iteratee(value, key, collection); 8613 }); 8614 return result; 8615 } 8616 8617 /** 8618 * The base implementation of `_.matches` which doesn't clone `source`. 8619 * 8620 * @private 8621 * @param {Object} source The object of property values to match. 8622 * @returns {Function} Returns the new spec function. 8623 */ 8624 function baseMatches(source) { 8625 var matchData = getMatchData(source); 8626 if (matchData.length == 1 && matchData[0][2]) { 8627 return matchesStrictComparable(matchData[0][0], matchData[0][1]); 8628 } 8629 return function(object) { 8630 return object === source || baseIsMatch(object, source, matchData); 8631 }; 8632 } 8633 8634 /** 8635 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. 8636 * 8637 * @private 8638 * @param {string} path The path of the property to get. 8639 * @param {*} srcValue The value to match. 8640 * @returns {Function} Returns the new spec function. 8641 */ 8642 function baseMatchesProperty(path, srcValue) { 8643 if (isKey(path) && isStrictComparable(srcValue)) { 8644 return matchesStrictComparable(toKey(path), srcValue); 8645 } 8646 return function(object) { 8647 var objValue = get(object, path); 8648 return (objValue === undefined && objValue === srcValue) 8649 ? hasIn(object, path) 8650 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); 8651 }; 8652 } 8653 8654 /** 8655 * The base implementation of `_.merge` without support for multiple sources. 8656 * 8657 * @private 8658 * @param {Object} object The destination object. 8659 * @param {Object} source The source object. 8660 * @param {number} srcIndex The index of `source`. 8661 * @param {Function} [customizer] The function to customize merged values. 8662 * @param {Object} [stack] Tracks traversed source values and their merged 8663 * counterparts. 8664 */ 8665 function baseMerge(object, source, srcIndex, customizer, stack) { 8666 if (object === source) { 8667 return; 8668 } 8669 baseFor(source, function(srcValue, key) { 8670 stack || (stack = new Stack); 8671 if (isObject(srcValue)) { 8672 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 8673 } 8674 else { 8675 var newValue = customizer 8676 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) 8677 : undefined; 8678 8679 if (newValue === undefined) { 8680 newValue = srcValue; 8681 } 8682 assignMergeValue(object, key, newValue); 8683 } 8684 }, keysIn); 8685 } 8686 8687 /** 8688 * A specialized version of `baseMerge` for arrays and objects which performs 8689 * deep merges and tracks traversed objects enabling objects with circular 8690 * references to be merged. 8691 * 8692 * @private 8693 * @param {Object} object The destination object. 8694 * @param {Object} source The source object. 8695 * @param {string} key The key of the value to merge. 8696 * @param {number} srcIndex The index of `source`. 8697 * @param {Function} mergeFunc The function to merge values. 8698 * @param {Function} [customizer] The function to customize assigned values. 8699 * @param {Object} [stack] Tracks traversed source values and their merged 8700 * counterparts. 8701 */ 8702 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 8703 var objValue = safeGet(object, key), 8704 srcValue = safeGet(source, key), 8705 stacked = stack.get(srcValue); 8706 8707 if (stacked) { 8708 assignMergeValue(object, key, stacked); 8709 return; 8710 } 8711 var newValue = customizer 8712 ? customizer(objValue, srcValue, (key + ''), object, source, stack) 8713 : undefined; 8714 8715 var isCommon = newValue === undefined; 8716 8717 if (isCommon) { 8718 var isArr = isArray(srcValue), 8719 isBuff = !isArr && isBuffer(srcValue), 8720 isTyped = !isArr && !isBuff && isTypedArray(srcValue); 8721 8722 newValue = srcValue; 8723 if (isArr || isBuff || isTyped) { 8724 if (isArray(objValue)) { 8725 newValue = objValue; 8726 } 8727 else if (isArrayLikeObject(objValue)) { 8728 newValue = copyArray(objValue); 8729 } 8730 else if (isBuff) { 8731 isCommon = false; 8732 newValue = cloneBuffer(srcValue, true); 8733 } 8734 else if (isTyped) { 8735 isCommon = false; 8736 newValue = cloneTypedArray(srcValue, true); 8737 } 8738 else { 8739 newValue = []; 8740 } 8741 } 8742 else if (isPlainObject(srcValue) || isArguments(srcValue)) { 8743 newValue = objValue; 8744 if (isArguments(objValue)) { 8745 newValue = toPlainObject(objValue); 8746 } 8747 else if (!isObject(objValue) || isFunction(objValue)) { 8748 newValue = initCloneObject(srcValue); 8749 } 8750 } 8751 else { 8752 isCommon = false; 8753 } 8754 } 8755 if (isCommon) { 8756 // Recursively merge objects and arrays (susceptible to call stack limits). 8757 stack.set(srcValue, newValue); 8758 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 8759 stack['delete'](srcValue); 8760 } 8761 assignMergeValue(object, key, newValue); 8762 } 8763 8764 /** 8765 * The base implementation of `_.nth` which doesn't coerce arguments. 8766 * 8767 * @private 8768 * @param {Array} array The array to query. 8769 * @param {number} n The index of the element to return. 8770 * @returns {*} Returns the nth element of `array`. 8771 */ 8772 function baseNth(array, n) { 8773 var length = array.length; 8774 if (!length) { 8775 return; 8776 } 8777 n += n < 0 ? length : 0; 8778 return isIndex(n, length) ? array[n] : undefined; 8779 } 8780 8781 /** 8782 * The base implementation of `_.orderBy` without param guards. 8783 * 8784 * @private 8785 * @param {Array|Object} collection The collection to iterate over. 8786 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. 8787 * @param {string[]} orders The sort orders of `iteratees`. 8788 * @returns {Array} Returns the new sorted array. 8789 */ 8790 function baseOrderBy(collection, iteratees, orders) { 8791 if (iteratees.length) { 8792 iteratees = arrayMap(iteratees, function(iteratee) { 8793 if (isArray(iteratee)) { 8794 return function(value) { 8795 return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); 8796 } 8797 } 8798 return iteratee; 8799 }); 8800 } else { 8801 iteratees = [identity]; 8802 } 8803 8804 var index = -1; 8805 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 8806 8807 var result = baseMap(collection, function(value, key, collection) { 8808 var criteria = arrayMap(iteratees, function(iteratee) { 8809 return iteratee(value); 8810 }); 8811 return { 'criteria': criteria, 'index': ++index, 'value': value }; 8812 }); 8813 8814 return baseSortBy(result, function(object, other) { 8815 return compareMultiple(object, other, orders); 8816 }); 8817 } 8818 8819 /** 8820 * The base implementation of `_.pick` without support for individual 8821 * property identifiers. 8822 * 8823 * @private 8824 * @param {Object} object The source object. 8825 * @param {string[]} paths The property paths to pick. 8826 * @returns {Object} Returns the new object. 8827 */ 8828 function basePick(object, paths) { 8829 return basePickBy(object, paths, function(value, path) { 8830 return hasIn(object, path); 8831 }); 8832 } 8833 8834 /** 8835 * The base implementation of `_.pickBy` without support for iteratee shorthands. 8836 * 8837 * @private 8838 * @param {Object} object The source object. 8839 * @param {string[]} paths The property paths to pick. 8840 * @param {Function} predicate The function invoked per property. 8841 * @returns {Object} Returns the new object. 8842 */ 8843 function basePickBy(object, paths, predicate) { 8844 var index = -1, 8845 length = paths.length, 8846 result = {}; 8847 8848 while (++index < length) { 8849 var path = paths[index], 8850 value = baseGet(object, path); 8851 8852 if (predicate(value, path)) { 8853 baseSet(result, castPath(path, object), value); 8854 } 8855 } 8856 return result; 8857 } 8858 8859 /** 8860 * A specialized version of `baseProperty` which supports deep paths. 8861 * 8862 * @private 8863 * @param {Array|string} path The path of the property to get. 8864 * @returns {Function} Returns the new accessor function. 8865 */ 8866 function basePropertyDeep(path) { 8867 return function(object) { 8868 return baseGet(object, path); 8869 }; 8870 } 8871 8872 /** 8873 * The base implementation of `_.pullAllBy` without support for iteratee 8874 * shorthands. 8875 * 8876 * @private 8877 * @param {Array} array The array to modify. 8878 * @param {Array} values The values to remove. 8879 * @param {Function} [iteratee] The iteratee invoked per element. 8880 * @param {Function} [comparator] The comparator invoked per element. 8881 * @returns {Array} Returns `array`. 8882 */ 8883 function basePullAll(array, values, iteratee, comparator) { 8884 var indexOf = comparator ? baseIndexOfWith : baseIndexOf, 8885 index = -1, 8886 length = values.length, 8887 seen = array; 8888 8889 if (array === values) { 8890 values = copyArray(values); 8891 } 8892 if (iteratee) { 8893 seen = arrayMap(array, baseUnary(iteratee)); 8894 } 8895 while (++index < length) { 8896 var fromIndex = 0, 8897 value = values[index], 8898 computed = iteratee ? iteratee(value) : value; 8899 8900 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { 8901 if (seen !== array) { 8902 splice.call(seen, fromIndex, 1); 8903 } 8904 splice.call(array, fromIndex, 1); 8905 } 8906 } 8907 return array; 8908 } 8909 8910 /** 8911 * The base implementation of `_.pullAt` without support for individual 8912 * indexes or capturing the removed elements. 8913 * 8914 * @private 8915 * @param {Array} array The array to modify. 8916 * @param {number[]} indexes The indexes of elements to remove. 8917 * @returns {Array} Returns `array`. 8918 */ 8919 function basePullAt(array, indexes) { 8920 var length = array ? indexes.length : 0, 8921 lastIndex = length - 1; 8922 8923 while (length--) { 8924 var index = indexes[length]; 8925 if (length == lastIndex || index !== previous) { 8926 var previous = index; 8927 if (isIndex(index)) { 8928 splice.call(array, index, 1); 8929 } else { 8930 baseUnset(array, index); 8931 } 8932 } 8933 } 8934 return array; 8935 } 8936 8937 /** 8938 * The base implementation of `_.random` without support for returning 8939 * floating-point numbers. 8940 * 8941 * @private 8942 * @param {number} lower The lower bound. 8943 * @param {number} upper The upper bound. 8944 * @returns {number} Returns the random number. 8945 */ 8946 function baseRandom(lower, upper) { 8947 return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); 8948 } 8949 8950 /** 8951 * The base implementation of `_.range` and `_.rangeRight` which doesn't 8952 * coerce arguments. 8953 * 8954 * @private 8955 * @param {number} start The start of the range. 8956 * @param {number} end The end of the range. 8957 * @param {number} step The value to increment or decrement by. 8958 * @param {boolean} [fromRight] Specify iterating from right to left. 8959 * @returns {Array} Returns the range of numbers. 8960 */ 8961 function baseRange(start, end, step, fromRight) { 8962 var index = -1, 8963 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), 8964 result = Array(length); 8965 8966 while (length--) { 8967 result[fromRight ? length : ++index] = start; 8968 start += step; 8969 } 8970 return result; 8971 } 8972 8973 /** 8974 * The base implementation of `_.repeat` which doesn't coerce arguments. 8975 * 8976 * @private 8977 * @param {string} string The string to repeat. 8978 * @param {number} n The number of times to repeat the string. 8979 * @returns {string} Returns the repeated string. 8980 */ 8981 function baseRepeat(string, n) { 8982 var result = ''; 8983 if (!string || n < 1 || n > MAX_SAFE_INTEGER) { 8984 return result; 8985 } 8986 // Leverage the exponentiation by squaring algorithm for a faster repeat. 8987 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. 8988 do { 8989 if (n % 2) { 8990 result += string; 8991 } 8992 n = nativeFloor(n / 2); 8993 if (n) { 8994 string += string; 8995 } 8996 } while (n); 8997 8998 return result; 8999 } 9000 9001 /** 9002 * The base implementation of `_.rest` which doesn't validate or coerce arguments. 9003 * 9004 * @private 9005 * @param {Function} func The function to apply a rest parameter to. 9006 * @param {number} [start=func.length-1] The start position of the rest parameter. 9007 * @returns {Function} Returns the new function. 9008 */ 9009 function baseRest(func, start) { 9010 return setToString(overRest(func, start, identity), func + ''); 9011 } 9012 9013 /** 9014 * The base implementation of `_.sample`. 9015 * 9016 * @private 9017 * @param {Array|Object} collection The collection to sample. 9018 * @returns {*} Returns the random element. 9019 */ 9020 function baseSample(collection) { 9021 return arraySample(values(collection)); 9022 } 9023 9024 /** 9025 * The base implementation of `_.sampleSize` without param guards. 9026 * 9027 * @private 9028 * @param {Array|Object} collection The collection to sample. 9029 * @param {number} n The number of elements to sample. 9030 * @returns {Array} Returns the random elements. 9031 */ 9032 function baseSampleSize(collection, n) { 9033 var array = values(collection); 9034 return shuffleSelf(array, baseClamp(n, 0, array.length)); 9035 } 9036 9037 /** 9038 * The base implementation of `_.set`. 9039 * 9040 * @private 9041 * @param {Object} object The object to modify. 9042 * @param {Array|string} path The path of the property to set. 9043 * @param {*} value The value to set. 9044 * @param {Function} [customizer] The function to customize path creation. 9045 * @returns {Object} Returns `object`. 9046 */ 9047 function baseSet(object, path, value, customizer) { 9048 if (!isObject(object)) { 9049 return object; 9050 } 9051 path = castPath(path, object); 9052 9053 var index = -1, 9054 length = path.length, 9055 lastIndex = length - 1, 9056 nested = object; 9057 9058 while (nested != null && ++index < length) { 9059 var key = toKey(path[index]), 9060 newValue = value; 9061 9062 if (key === '__proto__' || key === 'constructor' || key === 'prototype') { 9063 return object; 9064 } 9065 9066 if (index != lastIndex) { 9067 var objValue = nested[key]; 9068 newValue = customizer ? customizer(objValue, key, nested) : undefined; 9069 if (newValue === undefined) { 9070 newValue = isObject(objValue) 9071 ? objValue 9072 : (isIndex(path[index + 1]) ? [] : {}); 9073 } 9074 } 9075 assignValue(nested, key, newValue); 9076 nested = nested[key]; 9077 } 9078 return object; 9079 } 9080 9081 /** 9082 * The base implementation of `setData` without support for hot loop shorting. 9083 * 9084 * @private 9085 * @param {Function} func The function to associate metadata with. 9086 * @param {*} data The metadata. 9087 * @returns {Function} Returns `func`. 9088 */ 9089 var baseSetData = !metaMap ? identity : function(func, data) { 9090 metaMap.set(func, data); 9091 return func; 9092 }; 9093 9094 /** 9095 * The base implementation of `setToString` without support for hot loop shorting. 9096 * 9097 * @private 9098 * @param {Function} func The function to modify. 9099 * @param {Function} string The `toString` result. 9100 * @returns {Function} Returns `func`. 9101 */ 9102 var baseSetToString = !defineProperty ? identity : function(func, string) { 9103 return defineProperty(func, 'toString', { 9104 'configurable': true, 9105 'enumerable': false, 9106 'value': constant(string), 9107 'writable': true 9108 }); 9109 }; 9110 9111 /** 9112 * The base implementation of `_.shuffle`. 9113 * 9114 * @private 9115 * @param {Array|Object} collection The collection to shuffle. 9116 * @returns {Array} Returns the new shuffled array. 9117 */ 9118 function baseShuffle(collection) { 9119 return shuffleSelf(values(collection)); 9120 } 9121 9122 /** 9123 * The base implementation of `_.slice` without an iteratee call guard. 9124 * 9125 * @private 9126 * @param {Array} array The array to slice. 9127 * @param {number} [start=0] The start position. 9128 * @param {number} [end=array.length] The end position. 9129 * @returns {Array} Returns the slice of `array`. 9130 */ 9131 function baseSlice(array, start, end) { 9132 var index = -1, 9133 length = array.length; 9134 9135 if (start < 0) { 9136 start = -start > length ? 0 : (length + start); 9137 } 9138 end = end > length ? length : end; 9139 if (end < 0) { 9140 end += length; 9141 } 9142 length = start > end ? 0 : ((end - start) >>> 0); 9143 start >>>= 0; 9144 9145 var result = Array(length); 9146 while (++index < length) { 9147 result[index] = array[index + start]; 9148 } 9149 return result; 9150 } 9151 9152 /** 9153 * The base implementation of `_.some` without support for iteratee shorthands. 9154 * 9155 * @private 9156 * @param {Array|Object} collection The collection to iterate over. 9157 * @param {Function} predicate The function invoked per iteration. 9158 * @returns {boolean} Returns `true` if any element passes the predicate check, 9159 * else `false`. 9160 */ 9161 function baseSome(collection, predicate) { 9162 var result; 9163 9164 baseEach(collection, function(value, index, collection) { 9165 result = predicate(value, index, collection); 9166 return !result; 9167 }); 9168 return !!result; 9169 } 9170 9171 /** 9172 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which 9173 * performs a binary search of `array` to determine the index at which `value` 9174 * should be inserted into `array` in order to maintain its sort order. 9175 * 9176 * @private 9177 * @param {Array} array The sorted array to inspect. 9178 * @param {*} value The value to evaluate. 9179 * @param {boolean} [retHighest] Specify returning the highest qualified index. 9180 * @returns {number} Returns the index at which `value` should be inserted 9181 * into `array`. 9182 */ 9183 function baseSortedIndex(array, value, retHighest) { 9184 var low = 0, 9185 high = array == null ? low : array.length; 9186 9187 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { 9188 while (low < high) { 9189 var mid = (low + high) >>> 1, 9190 computed = array[mid]; 9191 9192 if (computed !== null && !isSymbol(computed) && 9193 (retHighest ? (computed <= value) : (computed < value))) { 9194 low = mid + 1; 9195 } else { 9196 high = mid; 9197 } 9198 } 9199 return high; 9200 } 9201 return baseSortedIndexBy(array, value, identity, retHighest); 9202 } 9203 9204 /** 9205 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` 9206 * which invokes `iteratee` for `value` and each element of `array` to compute 9207 * their sort ranking. The iteratee is invoked with one argument; (value). 9208 * 9209 * @private 9210 * @param {Array} array The sorted array to inspect. 9211 * @param {*} value The value to evaluate. 9212 * @param {Function} iteratee The iteratee invoked per element. 9213 * @param {boolean} [retHighest] Specify returning the highest qualified index. 9214 * @returns {number} Returns the index at which `value` should be inserted 9215 * into `array`. 9216 */ 9217 function baseSortedIndexBy(array, value, iteratee, retHighest) { 9218 var low = 0, 9219 high = array == null ? 0 : array.length; 9220 if (high === 0) { 9221 return 0; 9222 } 9223 9224 value = iteratee(value); 9225 var valIsNaN = value !== value, 9226 valIsNull = value === null, 9227 valIsSymbol = isSymbol(value), 9228 valIsUndefined = value === undefined; 9229 9230 while (low < high) { 9231 var mid = nativeFloor((low + high) / 2), 9232 computed = iteratee(array[mid]), 9233 othIsDefined = computed !== undefined, 9234 othIsNull = computed === null, 9235 othIsReflexive = computed === computed, 9236 othIsSymbol = isSymbol(computed); 9237 9238 if (valIsNaN) { 9239 var setLow = retHighest || othIsReflexive; 9240 } else if (valIsUndefined) { 9241 setLow = othIsReflexive && (retHighest || othIsDefined); 9242 } else if (valIsNull) { 9243 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); 9244 } else if (valIsSymbol) { 9245 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); 9246 } else if (othIsNull || othIsSymbol) { 9247 setLow = false; 9248 } else { 9249 setLow = retHighest ? (computed <= value) : (computed < value); 9250 } 9251 if (setLow) { 9252 low = mid + 1; 9253 } else { 9254 high = mid; 9255 } 9256 } 9257 return nativeMin(high, MAX_ARRAY_INDEX); 9258 } 9259 9260 /** 9261 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without 9262 * support for iteratee shorthands. 9263 * 9264 * @private 9265 * @param {Array} array The array to inspect. 9266 * @param {Function} [iteratee] The iteratee invoked per element. 9267 * @returns {Array} Returns the new duplicate free array. 9268 */ 9269 function baseSortedUniq(array, iteratee) { 9270 var index = -1, 9271 length = array.length, 9272 resIndex = 0, 9273 result = []; 9274 9275 while (++index < length) { 9276 var value = array[index], 9277 computed = iteratee ? iteratee(value) : value; 9278 9279 if (!index || !eq(computed, seen)) { 9280 var seen = computed; 9281 result[resIndex++] = value === 0 ? 0 : value; 9282 } 9283 } 9284 return result; 9285 } 9286 9287 /** 9288 * The base implementation of `_.toNumber` which doesn't ensure correct 9289 * conversions of binary, hexadecimal, or octal string values. 9290 * 9291 * @private 9292 * @param {*} value The value to process. 9293 * @returns {number} Returns the number. 9294 */ 9295 function baseToNumber(value) { 9296 if (typeof value == 'number') { 9297 return value; 9298 } 9299 if (isSymbol(value)) { 9300 return NAN; 9301 } 9302 return +value; 9303 } 9304 9305 /** 9306 * The base implementation of `_.toString` which doesn't convert nullish 9307 * values to empty strings. 9308 * 9309 * @private 9310 * @param {*} value The value to process. 9311 * @returns {string} Returns the string. 9312 */ 9313 function baseToString(value) { 9314 // Exit early for strings to avoid a performance hit in some environments. 9315 if (typeof value == 'string') { 9316 return value; 9317 } 9318 if (isArray(value)) { 9319 // Recursively convert values (susceptible to call stack limits). 9320 return arrayMap(value, baseToString) + ''; 9321 } 9322 if (isSymbol(value)) { 9323 return symbolToString ? symbolToString.call(value) : ''; 9324 } 9325 var result = (value + ''); 9326 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 9327 } 9328 9329 /** 9330 * The base implementation of `_.uniqBy` without support for iteratee shorthands. 9331 * 9332 * @private 9333 * @param {Array} array The array to inspect. 9334 * @param {Function} [iteratee] The iteratee invoked per element. 9335 * @param {Function} [comparator] The comparator invoked per element. 9336 * @returns {Array} Returns the new duplicate free array. 9337 */ 9338 function baseUniq(array, iteratee, comparator) { 9339 var index = -1, 9340 includes = arrayIncludes, 9341 length = array.length, 9342 isCommon = true, 9343 result = [], 9344 seen = result; 9345 9346 if (comparator) { 9347 isCommon = false; 9348 includes = arrayIncludesWith; 9349 } 9350 else if (length >= LARGE_ARRAY_SIZE) { 9351 var set = iteratee ? null : createSet(array); 9352 if (set) { 9353 return setToArray(set); 9354 } 9355 isCommon = false; 9356 includes = cacheHas; 9357 seen = new SetCache; 9358 } 9359 else { 9360 seen = iteratee ? [] : result; 9361 } 9362 outer: 9363 while (++index < length) { 9364 var value = array[index], 9365 computed = iteratee ? iteratee(value) : value; 9366 9367 value = (comparator || value !== 0) ? value : 0; 9368 if (isCommon && computed === computed) { 9369 var seenIndex = seen.length; 9370 while (seenIndex--) { 9371 if (seen[seenIndex] === computed) { 9372 continue outer; 9373 } 9374 } 9375 if (iteratee) { 9376 seen.push(computed); 9377 } 9378 result.push(value); 9379 } 9380 else if (!includes(seen, computed, comparator)) { 9381 if (seen !== result) { 9382 seen.push(computed); 9383 } 9384 result.push(value); 9385 } 9386 } 9387 return result; 9388 } 9389 9390 /** 9391 * The base implementation of `_.unset`. 9392 * 9393 * @private 9394 * @param {Object} object The object to modify. 9395 * @param {Array|string} path The property path to unset. 9396 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 9397 */ 9398 function baseUnset(object, path) { 9399 path = castPath(path, object); 9400 object = parent(object, path); 9401 return object == null || delete object[toKey(last(path))]; 9402 } 9403 9404 /** 9405 * The base implementation of `_.update`. 9406 * 9407 * @private 9408 * @param {Object} object The object to modify. 9409 * @param {Array|string} path The path of the property to update. 9410 * @param {Function} updater The function to produce the updated value. 9411 * @param {Function} [customizer] The function to customize path creation. 9412 * @returns {Object} Returns `object`. 9413 */ 9414 function baseUpdate(object, path, updater, customizer) { 9415 return baseSet(object, path, updater(baseGet(object, path)), customizer); 9416 } 9417 9418 /** 9419 * The base implementation of methods like `_.dropWhile` and `_.takeWhile` 9420 * without support for iteratee shorthands. 9421 * 9422 * @private 9423 * @param {Array} array The array to query. 9424 * @param {Function} predicate The function invoked per iteration. 9425 * @param {boolean} [isDrop] Specify dropping elements instead of taking them. 9426 * @param {boolean} [fromRight] Specify iterating from right to left. 9427 * @returns {Array} Returns the slice of `array`. 9428 */ 9429 function baseWhile(array, predicate, isDrop, fromRight) { 9430 var length = array.length, 9431 index = fromRight ? length : -1; 9432 9433 while ((fromRight ? index-- : ++index < length) && 9434 predicate(array[index], index, array)) {} 9435 9436 return isDrop 9437 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 9438 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); 9439 } 9440 9441 /** 9442 * The base implementation of `wrapperValue` which returns the result of 9443 * performing a sequence of actions on the unwrapped `value`, where each 9444 * successive action is supplied the return value of the previous. 9445 * 9446 * @private 9447 * @param {*} value The unwrapped value. 9448 * @param {Array} actions Actions to perform to resolve the unwrapped value. 9449 * @returns {*} Returns the resolved value. 9450 */ 9451 function baseWrapperValue(value, actions) { 9452 var result = value; 9453 if (result instanceof LazyWrapper) { 9454 result = result.value(); 9455 } 9456 return arrayReduce(actions, function(result, action) { 9457 return action.func.apply(action.thisArg, arrayPush([result], action.args)); 9458 }, result); 9459 } 9460 9461 /** 9462 * The base implementation of methods like `_.xor`, without support for 9463 * iteratee shorthands, that accepts an array of arrays to inspect. 9464 * 9465 * @private 9466 * @param {Array} arrays The arrays to inspect. 9467 * @param {Function} [iteratee] The iteratee invoked per element. 9468 * @param {Function} [comparator] The comparator invoked per element. 9469 * @returns {Array} Returns the new array of values. 9470 */ 9471 function baseXor(arrays, iteratee, comparator) { 9472 var length = arrays.length; 9473 if (length < 2) { 9474 return length ? baseUniq(arrays[0]) : []; 9475 } 9476 var index = -1, 9477 result = Array(length); 9478 9479 while (++index < length) { 9480 var array = arrays[index], 9481 othIndex = -1; 9482 9483 while (++othIndex < length) { 9484 if (othIndex != index) { 9485 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); 9486 } 9487 } 9488 } 9489 return baseUniq(baseFlatten(result, 1), iteratee, comparator); 9490 } 9491 9492 /** 9493 * This base implementation of `_.zipObject` which assigns values using `assignFunc`. 9494 * 9495 * @private 9496 * @param {Array} props The property identifiers. 9497 * @param {Array} values The property values. 9498 * @param {Function} assignFunc The function to assign values. 9499 * @returns {Object} Returns the new object. 9500 */ 9501 function baseZipObject(props, values, assignFunc) { 9502 var index = -1, 9503 length = props.length, 9504 valsLength = values.length, 9505 result = {}; 9506 9507 while (++index < length) { 9508 var value = index < valsLength ? values[index] : undefined; 9509 assignFunc(result, props[index], value); 9510 } 9511 return result; 9512 } 9513 9514 /** 9515 * Casts `value` to an empty array if it's not an array like object. 9516 * 9517 * @private 9518 * @param {*} value The value to inspect. 9519 * @returns {Array|Object} Returns the cast array-like object. 9520 */ 9521 function castArrayLikeObject(value) { 9522 return isArrayLikeObject(value) ? value : []; 9523 } 9524 9525 /** 9526 * Casts `value` to `identity` if it's not a function. 9527 * 9528 * @private 9529 * @param {*} value The value to inspect. 9530 * @returns {Function} Returns cast function. 9531 */ 9532 function castFunction(value) { 9533 return typeof value == 'function' ? value : identity; 9534 } 9535 9536 /** 9537 * Casts `value` to a path array if it's not one. 9538 * 9539 * @private 9540 * @param {*} value The value to inspect. 9541 * @param {Object} [object] The object to query keys on. 9542 * @returns {Array} Returns the cast property path array. 9543 */ 9544 function castPath(value, object) { 9545 if (isArray(value)) { 9546 return value; 9547 } 9548 return isKey(value, object) ? [value] : stringToPath(toString(value)); 9549 } 9550 9551 /** 9552 * A `baseRest` alias which can be replaced with `identity` by module 9553 * replacement plugins. 9554 * 9555 * @private 9556 * @type {Function} 9557 * @param {Function} func The function to apply a rest parameter to. 9558 * @returns {Function} Returns the new function. 9559 */ 9560 var castRest = baseRest; 9561 9562 /** 9563 * Casts `array` to a slice if it's needed. 9564 * 9565 * @private 9566 * @param {Array} array The array to inspect. 9567 * @param {number} start The start position. 9568 * @param {number} [end=array.length] The end position. 9569 * @returns {Array} Returns the cast slice. 9570 */ 9571 function castSlice(array, start, end) { 9572 var length = array.length; 9573 end = end === undefined ? length : end; 9574 return (!start && end >= length) ? array : baseSlice(array, start, end); 9575 } 9576 9577 /** 9578 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). 9579 * 9580 * @private 9581 * @param {number|Object} id The timer id or timeout object of the timer to clear. 9582 */ 9583 var clearTimeout = ctxClearTimeout || function(id) { 9584 return root.clearTimeout(id); 9585 }; 9586 9587 /** 9588 * Creates a clone of `buffer`. 9589 * 9590 * @private 9591 * @param {Buffer} buffer The buffer to clone. 9592 * @param {boolean} [isDeep] Specify a deep clone. 9593 * @returns {Buffer} Returns the cloned buffer. 9594 */ 9595 function cloneBuffer(buffer, isDeep) { 9596 if (isDeep) { 9597 return buffer.slice(); 9598 } 9599 var length = buffer.length, 9600 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 9601 9602 buffer.copy(result); 9603 return result; 9604 } 9605 9606 /** 9607 * Creates a clone of `arrayBuffer`. 9608 * 9609 * @private 9610 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 9611 * @returns {ArrayBuffer} Returns the cloned array buffer. 9612 */ 9613 function cloneArrayBuffer(arrayBuffer) { 9614 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 9615 new Uint8Array(result).set(new Uint8Array(arrayBuffer)); 9616 return result; 9617 } 9618 9619 /** 9620 * Creates a clone of `dataView`. 9621 * 9622 * @private 9623 * @param {Object} dataView The data view to clone. 9624 * @param {boolean} [isDeep] Specify a deep clone. 9625 * @returns {Object} Returns the cloned data view. 9626 */ 9627 function cloneDataView(dataView, isDeep) { 9628 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; 9629 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 9630 } 9631 9632 /** 9633 * Creates a clone of `regexp`. 9634 * 9635 * @private 9636 * @param {Object} regexp The regexp to clone. 9637 * @returns {Object} Returns the cloned regexp. 9638 */ 9639 function cloneRegExp(regexp) { 9640 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 9641 result.lastIndex = regexp.lastIndex; 9642 return result; 9643 } 9644 9645 /** 9646 * Creates a clone of the `symbol` object. 9647 * 9648 * @private 9649 * @param {Object} symbol The symbol object to clone. 9650 * @returns {Object} Returns the cloned symbol object. 9651 */ 9652 function cloneSymbol(symbol) { 9653 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 9654 } 9655 9656 /** 9657 * Creates a clone of `typedArray`. 9658 * 9659 * @private 9660 * @param {Object} typedArray The typed array to clone. 9661 * @param {boolean} [isDeep] Specify a deep clone. 9662 * @returns {Object} Returns the cloned typed array. 9663 */ 9664 function cloneTypedArray(typedArray, isDeep) { 9665 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 9666 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 9667 } 9668 9669 /** 9670 * Compares values to sort them in ascending order. 9671 * 9672 * @private 9673 * @param {*} value The value to compare. 9674 * @param {*} other The other value to compare. 9675 * @returns {number} Returns the sort order indicator for `value`. 9676 */ 9677 function compareAscending(value, other) { 9678 if (value !== other) { 9679 var valIsDefined = value !== undefined, 9680 valIsNull = value === null, 9681 valIsReflexive = value === value, 9682 valIsSymbol = isSymbol(value); 9683 9684 var othIsDefined = other !== undefined, 9685 othIsNull = other === null, 9686 othIsReflexive = other === other, 9687 othIsSymbol = isSymbol(other); 9688 9689 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || 9690 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || 9691 (valIsNull && othIsDefined && othIsReflexive) || 9692 (!valIsDefined && othIsReflexive) || 9693 !valIsReflexive) { 9694 return 1; 9695 } 9696 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || 9697 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || 9698 (othIsNull && valIsDefined && valIsReflexive) || 9699 (!othIsDefined && valIsReflexive) || 9700 !othIsReflexive) { 9701 return -1; 9702 } 9703 } 9704 return 0; 9705 } 9706 9707 /** 9708 * Used by `_.orderBy` to compare multiple properties of a value to another 9709 * and stable sort them. 9710 * 9711 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, 9712 * specify an order of "desc" for descending or "asc" for ascending sort order 9713 * of corresponding values. 9714 * 9715 * @private 9716 * @param {Object} object The object to compare. 9717 * @param {Object} other The other object to compare. 9718 * @param {boolean[]|string[]} orders The order to sort by for each property. 9719 * @returns {number} Returns the sort order indicator for `object`. 9720 */ 9721 function compareMultiple(object, other, orders) { 9722 var index = -1, 9723 objCriteria = object.criteria, 9724 othCriteria = other.criteria, 9725 length = objCriteria.length, 9726 ordersLength = orders.length; 9727 9728 while (++index < length) { 9729 var result = compareAscending(objCriteria[index], othCriteria[index]); 9730 if (result) { 9731 if (index >= ordersLength) { 9732 return result; 9733 } 9734 var order = orders[index]; 9735 return result * (order == 'desc' ? -1 : 1); 9736 } 9737 } 9738 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications 9739 // that causes it, under certain circumstances, to provide the same value for 9740 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 9741 // for more details. 9742 // 9743 // This also ensures a stable sort in V8 and other engines. 9744 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. 9745 return object.index - other.index; 9746 } 9747 9748 /** 9749 * Creates an array that is the composition of partially applied arguments, 9750 * placeholders, and provided arguments into a single array of arguments. 9751 * 9752 * @private 9753 * @param {Array} args The provided arguments. 9754 * @param {Array} partials The arguments to prepend to those provided. 9755 * @param {Array} holders The `partials` placeholder indexes. 9756 * @params {boolean} [isCurried] Specify composing for a curried function. 9757 * @returns {Array} Returns the new array of composed arguments. 9758 */ 9759 function composeArgs(args, partials, holders, isCurried) { 9760 var argsIndex = -1, 9761 argsLength = args.length, 9762 holdersLength = holders.length, 9763 leftIndex = -1, 9764 leftLength = partials.length, 9765 rangeLength = nativeMax(argsLength - holdersLength, 0), 9766 result = Array(leftLength + rangeLength), 9767 isUncurried = !isCurried; 9768 9769 while (++leftIndex < leftLength) { 9770 result[leftIndex] = partials[leftIndex]; 9771 } 9772 while (++argsIndex < holdersLength) { 9773 if (isUncurried || argsIndex < argsLength) { 9774 result[holders[argsIndex]] = args[argsIndex]; 9775 } 9776 } 9777 while (rangeLength--) { 9778 result[leftIndex++] = args[argsIndex++]; 9779 } 9780 return result; 9781 } 9782 9783 /** 9784 * This function is like `composeArgs` except that the arguments composition 9785 * is tailored for `_.partialRight`. 9786 * 9787 * @private 9788 * @param {Array} args The provided arguments. 9789 * @param {Array} partials The arguments to append to those provided. 9790 * @param {Array} holders The `partials` placeholder indexes. 9791 * @params {boolean} [isCurried] Specify composing for a curried function. 9792 * @returns {Array} Returns the new array of composed arguments. 9793 */ 9794 function composeArgsRight(args, partials, holders, isCurried) { 9795 var argsIndex = -1, 9796 argsLength = args.length, 9797 holdersIndex = -1, 9798 holdersLength = holders.length, 9799 rightIndex = -1, 9800 rightLength = partials.length, 9801 rangeLength = nativeMax(argsLength - holdersLength, 0), 9802 result = Array(rangeLength + rightLength), 9803 isUncurried = !isCurried; 9804 9805 while (++argsIndex < rangeLength) { 9806 result[argsIndex] = args[argsIndex]; 9807 } 9808 var offset = argsIndex; 9809 while (++rightIndex < rightLength) { 9810 result[offset + rightIndex] = partials[rightIndex]; 9811 } 9812 while (++holdersIndex < holdersLength) { 9813 if (isUncurried || argsIndex < argsLength) { 9814 result[offset + holders[holdersIndex]] = args[argsIndex++]; 9815 } 9816 } 9817 return result; 9818 } 9819 9820 /** 9821 * Copies the values of `source` to `array`. 9822 * 9823 * @private 9824 * @param {Array} source The array to copy values from. 9825 * @param {Array} [array=[]] The array to copy values to. 9826 * @returns {Array} Returns `array`. 9827 */ 9828 function copyArray(source, array) { 9829 var index = -1, 9830 length = source.length; 9831 9832 array || (array = Array(length)); 9833 while (++index < length) { 9834 array[index] = source[index]; 9835 } 9836 return array; 9837 } 9838 9839 /** 9840 * Copies properties of `source` to `object`. 9841 * 9842 * @private 9843 * @param {Object} source The object to copy properties from. 9844 * @param {Array} props The property identifiers to copy. 9845 * @param {Object} [object={}] The object to copy properties to. 9846 * @param {Function} [customizer] The function to customize copied values. 9847 * @returns {Object} Returns `object`. 9848 */ 9849 function copyObject(source, props, object, customizer) { 9850 var isNew = !object; 9851 object || (object = {}); 9852 9853 var index = -1, 9854 length = props.length; 9855 9856 while (++index < length) { 9857 var key = props[index]; 9858 9859 var newValue = customizer 9860 ? customizer(object[key], source[key], key, object, source) 9861 : undefined; 9862 9863 if (newValue === undefined) { 9864 newValue = source[key]; 9865 } 9866 if (isNew) { 9867 baseAssignValue(object, key, newValue); 9868 } else { 9869 assignValue(object, key, newValue); 9870 } 9871 } 9872 return object; 9873 } 9874 9875 /** 9876 * Copies own symbols of `source` to `object`. 9877 * 9878 * @private 9879 * @param {Object} source The object to copy symbols from. 9880 * @param {Object} [object={}] The object to copy symbols to. 9881 * @returns {Object} Returns `object`. 9882 */ 9883 function copySymbols(source, object) { 9884 return copyObject(source, getSymbols(source), object); 9885 } 9886 9887 /** 9888 * Copies own and inherited symbols of `source` to `object`. 9889 * 9890 * @private 9891 * @param {Object} source The object to copy symbols from. 9892 * @param {Object} [object={}] The object to copy symbols to. 9893 * @returns {Object} Returns `object`. 9894 */ 9895 function copySymbolsIn(source, object) { 9896 return copyObject(source, getSymbolsIn(source), object); 9897 } 9898 9899 /** 9900 * Creates a function like `_.groupBy`. 9901 * 9902 * @private 9903 * @param {Function} setter The function to set accumulator values. 9904 * @param {Function} [initializer] The accumulator object initializer. 9905 * @returns {Function} Returns the new aggregator function. 9906 */ 9907 function createAggregator(setter, initializer) { 9908 return function(collection, iteratee) { 9909 var func = isArray(collection) ? arrayAggregator : baseAggregator, 9910 accumulator = initializer ? initializer() : {}; 9911 9912 return func(collection, setter, getIteratee(iteratee, 2), accumulator); 9913 }; 9914 } 9915 9916 /** 9917 * Creates a function like `_.assign`. 9918 * 9919 * @private 9920 * @param {Function} assigner The function to assign values. 9921 * @returns {Function} Returns the new assigner function. 9922 */ 9923 function createAssigner(assigner) { 9924 return baseRest(function(object, sources) { 9925 var index = -1, 9926 length = sources.length, 9927 customizer = length > 1 ? sources[length - 1] : undefined, 9928 guard = length > 2 ? sources[2] : undefined; 9929 9930 customizer = (assigner.length > 3 && typeof customizer == 'function') 9931 ? (length--, customizer) 9932 : undefined; 9933 9934 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 9935 customizer = length < 3 ? undefined : customizer; 9936 length = 1; 9937 } 9938 object = Object(object); 9939 while (++index < length) { 9940 var source = sources[index]; 9941 if (source) { 9942 assigner(object, source, index, customizer); 9943 } 9944 } 9945 return object; 9946 }); 9947 } 9948 9949 /** 9950 * Creates a `baseEach` or `baseEachRight` function. 9951 * 9952 * @private 9953 * @param {Function} eachFunc The function to iterate over a collection. 9954 * @param {boolean} [fromRight] Specify iterating from right to left. 9955 * @returns {Function} Returns the new base function. 9956 */ 9957 function createBaseEach(eachFunc, fromRight) { 9958 return function(collection, iteratee) { 9959 if (collection == null) { 9960 return collection; 9961 } 9962 if (!isArrayLike(collection)) { 9963 return eachFunc(collection, iteratee); 9964 } 9965 var length = collection.length, 9966 index = fromRight ? length : -1, 9967 iterable = Object(collection); 9968 9969 while ((fromRight ? index-- : ++index < length)) { 9970 if (iteratee(iterable[index], index, iterable) === false) { 9971 break; 9972 } 9973 } 9974 return collection; 9975 }; 9976 } 9977 9978 /** 9979 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 9980 * 9981 * @private 9982 * @param {boolean} [fromRight] Specify iterating from right to left. 9983 * @returns {Function} Returns the new base function. 9984 */ 9985 function createBaseFor(fromRight) { 9986 return function(object, iteratee, keysFunc) { 9987 var index = -1, 9988 iterable = Object(object), 9989 props = keysFunc(object), 9990 length = props.length; 9991 9992 while (length--) { 9993 var key = props[fromRight ? length : ++index]; 9994 if (iteratee(iterable[key], key, iterable) === false) { 9995 break; 9996 } 9997 } 9998 return object; 9999 }; 10000 } 10001 10002 /** 10003 * Creates a function that wraps `func` to invoke it with the optional `this` 10004 * binding of `thisArg`. 10005 * 10006 * @private 10007 * @param {Function} func The function to wrap. 10008 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 10009 * @param {*} [thisArg] The `this` binding of `func`. 10010 * @returns {Function} Returns the new wrapped function. 10011 */ 10012 function createBind(func, bitmask, thisArg) { 10013 var isBind = bitmask & WRAP_BIND_FLAG, 10014 Ctor = createCtor(func); 10015 10016 function wrapper() { 10017 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 10018 return fn.apply(isBind ? thisArg : this, arguments); 10019 } 10020 return wrapper; 10021 } 10022 10023 /** 10024 * Creates a function like `_.lowerFirst`. 10025 * 10026 * @private 10027 * @param {string} methodName The name of the `String` case method to use. 10028 * @returns {Function} Returns the new case function. 10029 */ 10030 function createCaseFirst(methodName) { 10031 return function(string) { 10032 string = toString(string); 10033 10034 var strSymbols = hasUnicode(string) 10035 ? stringToArray(string) 10036 : undefined; 10037 10038 var chr = strSymbols 10039 ? strSymbols[0] 10040 : string.charAt(0); 10041 10042 var trailing = strSymbols 10043 ? castSlice(strSymbols, 1).join('') 10044 : string.slice(1); 10045 10046 return chr[methodName]() + trailing; 10047 }; 10048 } 10049 10050 /** 10051 * Creates a function like `_.camelCase`. 10052 * 10053 * @private 10054 * @param {Function} callback The function to combine each word. 10055 * @returns {Function} Returns the new compounder function. 10056 */ 10057 function createCompounder(callback) { 10058 return function(string) { 10059 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); 10060 }; 10061 } 10062 10063 /** 10064 * Creates a function that produces an instance of `Ctor` regardless of 10065 * whether it was invoked as part of a `new` expression or by `call` or `apply`. 10066 * 10067 * @private 10068 * @param {Function} Ctor The constructor to wrap. 10069 * @returns {Function} Returns the new wrapped function. 10070 */ 10071 function createCtor(Ctor) { 10072 return function() { 10073 // Use a `switch` statement to work with class constructors. See 10074 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist 10075 // for more details. 10076 var args = arguments; 10077 switch (args.length) { 10078 case 0: return new Ctor; 10079 case 1: return new Ctor(args[0]); 10080 case 2: return new Ctor(args[0], args[1]); 10081 case 3: return new Ctor(args[0], args[1], args[2]); 10082 case 4: return new Ctor(args[0], args[1], args[2], args[3]); 10083 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); 10084 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); 10085 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); 10086 } 10087 var thisBinding = baseCreate(Ctor.prototype), 10088 result = Ctor.apply(thisBinding, args); 10089 10090 // Mimic the constructor's `return` behavior. 10091 // See https://es5.github.io/#x13.2.2 for more details. 10092 return isObject(result) ? result : thisBinding; 10093 }; 10094 } 10095 10096 /** 10097 * Creates a function that wraps `func` to enable currying. 10098 * 10099 * @private 10100 * @param {Function} func The function to wrap. 10101 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 10102 * @param {number} arity The arity of `func`. 10103 * @returns {Function} Returns the new wrapped function. 10104 */ 10105 function createCurry(func, bitmask, arity) { 10106 var Ctor = createCtor(func); 10107 10108 function wrapper() { 10109 var length = arguments.length, 10110 args = Array(length), 10111 index = length, 10112 placeholder = getHolder(wrapper); 10113 10114 while (index--) { 10115 args[index] = arguments[index]; 10116 } 10117 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) 10118 ? [] 10119 : replaceHolders(args, placeholder); 10120 10121 length -= holders.length; 10122 if (length < arity) { 10123 return createRecurry( 10124 func, bitmask, createHybrid, wrapper.placeholder, undefined, 10125 args, holders, undefined, undefined, arity - length); 10126 } 10127 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 10128 return apply(fn, this, args); 10129 } 10130 return wrapper; 10131 } 10132 10133 /** 10134 * Creates a `_.find` or `_.findLast` function. 10135 * 10136 * @private 10137 * @param {Function} findIndexFunc The function to find the collection index. 10138 * @returns {Function} Returns the new find function. 10139 */ 10140 function createFind(findIndexFunc) { 10141 return function(collection, predicate, fromIndex) { 10142 var iterable = Object(collection); 10143 if (!isArrayLike(collection)) { 10144 var iteratee = getIteratee(predicate, 3); 10145 collection = keys(collection); 10146 predicate = function(key) { return iteratee(iterable[key], key, iterable); }; 10147 } 10148 var index = findIndexFunc(collection, predicate, fromIndex); 10149 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; 10150 }; 10151 } 10152 10153 /** 10154 * Creates a `_.flow` or `_.flowRight` function. 10155 * 10156 * @private 10157 * @param {boolean} [fromRight] Specify iterating from right to left. 10158 * @returns {Function} Returns the new flow function. 10159 */ 10160 function createFlow(fromRight) { 10161 return flatRest(function(funcs) { 10162 var length = funcs.length, 10163 index = length, 10164 prereq = LodashWrapper.prototype.thru; 10165 10166 if (fromRight) { 10167 funcs.reverse(); 10168 } 10169 while (index--) { 10170 var func = funcs[index]; 10171 if (typeof func != 'function') { 10172 throw new TypeError(FUNC_ERROR_TEXT); 10173 } 10174 if (prereq && !wrapper && getFuncName(func) == 'wrapper') { 10175 var wrapper = new LodashWrapper([], true); 10176 } 10177 } 10178 index = wrapper ? index : length; 10179 while (++index < length) { 10180 func = funcs[index]; 10181 10182 var funcName = getFuncName(func), 10183 data = funcName == 'wrapper' ? getData(func) : undefined; 10184 10185 if (data && isLaziable(data[0]) && 10186 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && 10187 !data[4].length && data[9] == 1 10188 ) { 10189 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); 10190 } else { 10191 wrapper = (func.length == 1 && isLaziable(func)) 10192 ? wrapper[funcName]() 10193 : wrapper.thru(func); 10194 } 10195 } 10196 return function() { 10197 var args = arguments, 10198 value = args[0]; 10199 10200 if (wrapper && args.length == 1 && isArray(value)) { 10201 return wrapper.plant(value).value(); 10202 } 10203 var index = 0, 10204 result = length ? funcs[index].apply(this, args) : value; 10205 10206 while (++index < length) { 10207 result = funcs[index].call(this, result); 10208 } 10209 return result; 10210 }; 10211 }); 10212 } 10213 10214 /** 10215 * Creates a function that wraps `func` to invoke it with optional `this` 10216 * binding of `thisArg`, partial application, and currying. 10217 * 10218 * @private 10219 * @param {Function|string} func The function or method name to wrap. 10220 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 10221 * @param {*} [thisArg] The `this` binding of `func`. 10222 * @param {Array} [partials] The arguments to prepend to those provided to 10223 * the new function. 10224 * @param {Array} [holders] The `partials` placeholder indexes. 10225 * @param {Array} [partialsRight] The arguments to append to those provided 10226 * to the new function. 10227 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. 10228 * @param {Array} [argPos] The argument positions of the new function. 10229 * @param {number} [ary] The arity cap of `func`. 10230 * @param {number} [arity] The arity of `func`. 10231 * @returns {Function} Returns the new wrapped function. 10232 */ 10233 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { 10234 var isAry = bitmask & WRAP_ARY_FLAG, 10235 isBind = bitmask & WRAP_BIND_FLAG, 10236 isBindKey = bitmask & WRAP_BIND_KEY_FLAG, 10237 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), 10238 isFlip = bitmask & WRAP_FLIP_FLAG, 10239 Ctor = isBindKey ? undefined : createCtor(func); 10240 10241 function wrapper() { 10242 var length = arguments.length, 10243 args = Array(length), 10244 index = length; 10245 10246 while (index--) { 10247 args[index] = arguments[index]; 10248 } 10249 if (isCurried) { 10250 var placeholder = getHolder(wrapper), 10251 holdersCount = countHolders(args, placeholder); 10252 } 10253 if (partials) { 10254 args = composeArgs(args, partials, holders, isCurried); 10255 } 10256 if (partialsRight) { 10257 args = composeArgsRight(args, partialsRight, holdersRight, isCurried); 10258 } 10259 length -= holdersCount; 10260 if (isCurried && length < arity) { 10261 var newHolders = replaceHolders(args, placeholder); 10262 return createRecurry( 10263 func, bitmask, createHybrid, wrapper.placeholder, thisArg, 10264 args, newHolders, argPos, ary, arity - length 10265 ); 10266 } 10267 var thisBinding = isBind ? thisArg : this, 10268 fn = isBindKey ? thisBinding[func] : func; 10269 10270 length = args.length; 10271 if (argPos) { 10272 args = reorder(args, argPos); 10273 } else if (isFlip && length > 1) { 10274 args.reverse(); 10275 } 10276 if (isAry && ary < length) { 10277 args.length = ary; 10278 } 10279 if (this && this !== root && this instanceof wrapper) { 10280 fn = Ctor || createCtor(fn); 10281 } 10282 return fn.apply(thisBinding, args); 10283 } 10284 return wrapper; 10285 } 10286 10287 /** 10288 * Creates a function like `_.invertBy`. 10289 * 10290 * @private 10291 * @param {Function} setter The function to set accumulator values. 10292 * @param {Function} toIteratee The function to resolve iteratees. 10293 * @returns {Function} Returns the new inverter function. 10294 */ 10295 function createInverter(setter, toIteratee) { 10296 return function(object, iteratee) { 10297 return baseInverter(object, setter, toIteratee(iteratee), {}); 10298 }; 10299 } 10300 10301 /** 10302 * Creates a function that performs a mathematical operation on two values. 10303 * 10304 * @private 10305 * @param {Function} operator The function to perform the operation. 10306 * @param {number} [defaultValue] The value used for `undefined` arguments. 10307 * @returns {Function} Returns the new mathematical operation function. 10308 */ 10309 function createMathOperation(operator, defaultValue) { 10310 return function(value, other) { 10311 var result; 10312 if (value === undefined && other === undefined) { 10313 return defaultValue; 10314 } 10315 if (value !== undefined) { 10316 result = value; 10317 } 10318 if (other !== undefined) { 10319 if (result === undefined) { 10320 return other; 10321 } 10322 if (typeof value == 'string' || typeof other == 'string') { 10323 value = baseToString(value); 10324 other = baseToString(other); 10325 } else { 10326 value = baseToNumber(value); 10327 other = baseToNumber(other); 10328 } 10329 result = operator(value, other); 10330 } 10331 return result; 10332 }; 10333 } 10334 10335 /** 10336 * Creates a function like `_.over`. 10337 * 10338 * @private 10339 * @param {Function} arrayFunc The function to iterate over iteratees. 10340 * @returns {Function} Returns the new over function. 10341 */ 10342 function createOver(arrayFunc) { 10343 return flatRest(function(iteratees) { 10344 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 10345 return baseRest(function(args) { 10346 var thisArg = this; 10347 return arrayFunc(iteratees, function(iteratee) { 10348 return apply(iteratee, thisArg, args); 10349 }); 10350 }); 10351 }); 10352 } 10353 10354 /** 10355 * Creates the padding for `string` based on `length`. The `chars` string 10356 * is truncated if the number of characters exceeds `length`. 10357 * 10358 * @private 10359 * @param {number} length The padding length. 10360 * @param {string} [chars=' '] The string used as padding. 10361 * @returns {string} Returns the padding for `string`. 10362 */ 10363 function createPadding(length, chars) { 10364 chars = chars === undefined ? ' ' : baseToString(chars); 10365 10366 var charsLength = chars.length; 10367 if (charsLength < 2) { 10368 return charsLength ? baseRepeat(chars, length) : chars; 10369 } 10370 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); 10371 return hasUnicode(chars) 10372 ? castSlice(stringToArray(result), 0, length).join('') 10373 : result.slice(0, length); 10374 } 10375 10376 /** 10377 * Creates a function that wraps `func` to invoke it with the `this` binding 10378 * of `thisArg` and `partials` prepended to the arguments it receives. 10379 * 10380 * @private 10381 * @param {Function} func The function to wrap. 10382 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 10383 * @param {*} thisArg The `this` binding of `func`. 10384 * @param {Array} partials The arguments to prepend to those provided to 10385 * the new function. 10386 * @returns {Function} Returns the new wrapped function. 10387 */ 10388 function createPartial(func, bitmask, thisArg, partials) { 10389 var isBind = bitmask & WRAP_BIND_FLAG, 10390 Ctor = createCtor(func); 10391 10392 function wrapper() { 10393 var argsIndex = -1, 10394 argsLength = arguments.length, 10395 leftIndex = -1, 10396 leftLength = partials.length, 10397 args = Array(leftLength + argsLength), 10398 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 10399 10400 while (++leftIndex < leftLength) { 10401 args[leftIndex] = partials[leftIndex]; 10402 } 10403 while (argsLength--) { 10404 args[leftIndex++] = arguments[++argsIndex]; 10405 } 10406 return apply(fn, isBind ? thisArg : this, args); 10407 } 10408 return wrapper; 10409 } 10410 10411 /** 10412 * Creates a `_.range` or `_.rangeRight` function. 10413 * 10414 * @private 10415 * @param {boolean} [fromRight] Specify iterating from right to left. 10416 * @returns {Function} Returns the new range function. 10417 */ 10418 function createRange(fromRight) { 10419 return function(start, end, step) { 10420 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { 10421 end = step = undefined; 10422 } 10423 // Ensure the sign of `-0` is preserved. 10424 start = toFinite(start); 10425 if (end === undefined) { 10426 end = start; 10427 start = 0; 10428 } else { 10429 end = toFinite(end); 10430 } 10431 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); 10432 return baseRange(start, end, step, fromRight); 10433 }; 10434 } 10435 10436 /** 10437 * Creates a function that performs a relational operation on two values. 10438 * 10439 * @private 10440 * @param {Function} operator The function to perform the operation. 10441 * @returns {Function} Returns the new relational operation function. 10442 */ 10443 function createRelationalOperation(operator) { 10444 return function(value, other) { 10445 if (!(typeof value == 'string' && typeof other == 'string')) { 10446 value = toNumber(value); 10447 other = toNumber(other); 10448 } 10449 return operator(value, other); 10450 }; 10451 } 10452 10453 /** 10454 * Creates a function that wraps `func` to continue currying. 10455 * 10456 * @private 10457 * @param {Function} func The function to wrap. 10458 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 10459 * @param {Function} wrapFunc The function to create the `func` wrapper. 10460 * @param {*} placeholder The placeholder value. 10461 * @param {*} [thisArg] The `this` binding of `func`. 10462 * @param {Array} [partials] The arguments to prepend to those provided to 10463 * the new function. 10464 * @param {Array} [holders] The `partials` placeholder indexes. 10465 * @param {Array} [argPos] The argument positions of the new function. 10466 * @param {number} [ary] The arity cap of `func`. 10467 * @param {number} [arity] The arity of `func`. 10468 * @returns {Function} Returns the new wrapped function. 10469 */ 10470 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { 10471 var isCurry = bitmask & WRAP_CURRY_FLAG, 10472 newHolders = isCurry ? holders : undefined, 10473 newHoldersRight = isCurry ? undefined : holders, 10474 newPartials = isCurry ? partials : undefined, 10475 newPartialsRight = isCurry ? undefined : partials; 10476 10477 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); 10478 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); 10479 10480 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { 10481 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); 10482 } 10483 var newData = [ 10484 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, 10485 newHoldersRight, argPos, ary, arity 10486 ]; 10487 10488 var result = wrapFunc.apply(undefined, newData); 10489 if (isLaziable(func)) { 10490 setData(result, newData); 10491 } 10492 result.placeholder = placeholder; 10493 return setWrapToString(result, func, bitmask); 10494 } 10495 10496 /** 10497 * Creates a function like `_.round`. 10498 * 10499 * @private 10500 * @param {string} methodName The name of the `Math` method to use when rounding. 10501 * @returns {Function} Returns the new round function. 10502 */ 10503 function createRound(methodName) { 10504 var func = Math[methodName]; 10505 return function(number, precision) { 10506 number = toNumber(number); 10507 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); 10508 if (precision && nativeIsFinite(number)) { 10509 // Shift with exponential notation to avoid floating-point issues. 10510 // See [MDN](https://mdn.io/round#Examples) for more details. 10511 var pair = (toString(number) + 'e').split('e'), 10512 value = func(pair[0] + 'e' + (+pair[1] + precision)); 10513 10514 pair = (toString(value) + 'e').split('e'); 10515 return +(pair[0] + 'e' + (+pair[1] - precision)); 10516 } 10517 return func(number); 10518 }; 10519 } 10520 10521 /** 10522 * Creates a set object of `values`. 10523 * 10524 * @private 10525 * @param {Array} values The values to add to the set. 10526 * @returns {Object} Returns the new set. 10527 */ 10528 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { 10529 return new Set(values); 10530 }; 10531 10532 /** 10533 * Creates a `_.toPairs` or `_.toPairsIn` function. 10534 * 10535 * @private 10536 * @param {Function} keysFunc The function to get the keys of a given object. 10537 * @returns {Function} Returns the new pairs function. 10538 */ 10539 function createToPairs(keysFunc) { 10540 return function(object) { 10541 var tag = getTag(object); 10542 if (tag == mapTag) { 10543 return mapToArray(object); 10544 } 10545 if (tag == setTag) { 10546 return setToPairs(object); 10547 } 10548 return baseToPairs(object, keysFunc(object)); 10549 }; 10550 } 10551 10552 /** 10553 * Creates a function that either curries or invokes `func` with optional 10554 * `this` binding and partially applied arguments. 10555 * 10556 * @private 10557 * @param {Function|string} func The function or method name to wrap. 10558 * @param {number} bitmask The bitmask flags. 10559 * 1 - `_.bind` 10560 * 2 - `_.bindKey` 10561 * 4 - `_.curry` or `_.curryRight` of a bound function 10562 * 8 - `_.curry` 10563 * 16 - `_.curryRight` 10564 * 32 - `_.partial` 10565 * 64 - `_.partialRight` 10566 * 128 - `_.rearg` 10567 * 256 - `_.ary` 10568 * 512 - `_.flip` 10569 * @param {*} [thisArg] The `this` binding of `func`. 10570 * @param {Array} [partials] The arguments to be partially applied. 10571 * @param {Array} [holders] The `partials` placeholder indexes. 10572 * @param {Array} [argPos] The argument positions of the new function. 10573 * @param {number} [ary] The arity cap of `func`. 10574 * @param {number} [arity] The arity of `func`. 10575 * @returns {Function} Returns the new wrapped function. 10576 */ 10577 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { 10578 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; 10579 if (!isBindKey && typeof func != 'function') { 10580 throw new TypeError(FUNC_ERROR_TEXT); 10581 } 10582 var length = partials ? partials.length : 0; 10583 if (!length) { 10584 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); 10585 partials = holders = undefined; 10586 } 10587 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); 10588 arity = arity === undefined ? arity : toInteger(arity); 10589 length -= holders ? holders.length : 0; 10590 10591 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { 10592 var partialsRight = partials, 10593 holdersRight = holders; 10594 10595 partials = holders = undefined; 10596 } 10597 var data = isBindKey ? undefined : getData(func); 10598 10599 var newData = [ 10600 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, 10601 argPos, ary, arity 10602 ]; 10603 10604 if (data) { 10605 mergeData(newData, data); 10606 } 10607 func = newData[0]; 10608 bitmask = newData[1]; 10609 thisArg = newData[2]; 10610 partials = newData[3]; 10611 holders = newData[4]; 10612 arity = newData[9] = newData[9] === undefined 10613 ? (isBindKey ? 0 : func.length) 10614 : nativeMax(newData[9] - length, 0); 10615 10616 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { 10617 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); 10618 } 10619 if (!bitmask || bitmask == WRAP_BIND_FLAG) { 10620 var result = createBind(func, bitmask, thisArg); 10621 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { 10622 result = createCurry(func, bitmask, arity); 10623 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { 10624 result = createPartial(func, bitmask, thisArg, partials); 10625 } else { 10626 result = createHybrid.apply(undefined, newData); 10627 } 10628 var setter = data ? baseSetData : setData; 10629 return setWrapToString(setter(result, newData), func, bitmask); 10630 } 10631 10632 /** 10633 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties 10634 * of source objects to the destination object for all destination properties 10635 * that resolve to `undefined`. 10636 * 10637 * @private 10638 * @param {*} objValue The destination value. 10639 * @param {*} srcValue The source value. 10640 * @param {string} key The key of the property to assign. 10641 * @param {Object} object The parent object of `objValue`. 10642 * @returns {*} Returns the value to assign. 10643 */ 10644 function customDefaultsAssignIn(objValue, srcValue, key, object) { 10645 if (objValue === undefined || 10646 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { 10647 return srcValue; 10648 } 10649 return objValue; 10650 } 10651 10652 /** 10653 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source 10654 * objects into destination objects that are passed thru. 10655 * 10656 * @private 10657 * @param {*} objValue The destination value. 10658 * @param {*} srcValue The source value. 10659 * @param {string} key The key of the property to merge. 10660 * @param {Object} object The parent object of `objValue`. 10661 * @param {Object} source The parent object of `srcValue`. 10662 * @param {Object} [stack] Tracks traversed source values and their merged 10663 * counterparts. 10664 * @returns {*} Returns the value to assign. 10665 */ 10666 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { 10667 if (isObject(objValue) && isObject(srcValue)) { 10668 // Recursively merge objects and arrays (susceptible to call stack limits). 10669 stack.set(srcValue, objValue); 10670 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); 10671 stack['delete'](srcValue); 10672 } 10673 return objValue; 10674 } 10675 10676 /** 10677 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain 10678 * objects. 10679 * 10680 * @private 10681 * @param {*} value The value to inspect. 10682 * @param {string} key The key of the property to inspect. 10683 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. 10684 */ 10685 function customOmitClone(value) { 10686 return isPlainObject(value) ? undefined : value; 10687 } 10688 10689 /** 10690 * A specialized version of `baseIsEqualDeep` for arrays with support for 10691 * partial deep comparisons. 10692 * 10693 * @private 10694 * @param {Array} array The array to compare. 10695 * @param {Array} other The other array to compare. 10696 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 10697 * @param {Function} customizer The function to customize comparisons. 10698 * @param {Function} equalFunc The function to determine equivalents of values. 10699 * @param {Object} stack Tracks traversed `array` and `other` objects. 10700 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 10701 */ 10702 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 10703 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 10704 arrLength = array.length, 10705 othLength = other.length; 10706 10707 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 10708 return false; 10709 } 10710 // Check that cyclic values are equal. 10711 var arrStacked = stack.get(array); 10712 var othStacked = stack.get(other); 10713 if (arrStacked && othStacked) { 10714 return arrStacked == other && othStacked == array; 10715 } 10716 var index = -1, 10717 result = true, 10718 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; 10719 10720 stack.set(array, other); 10721 stack.set(other, array); 10722 10723 // Ignore non-index properties. 10724 while (++index < arrLength) { 10725 var arrValue = array[index], 10726 othValue = other[index]; 10727 10728 if (customizer) { 10729 var compared = isPartial 10730 ? customizer(othValue, arrValue, index, other, array, stack) 10731 : customizer(arrValue, othValue, index, array, other, stack); 10732 } 10733 if (compared !== undefined) { 10734 if (compared) { 10735 continue; 10736 } 10737 result = false; 10738 break; 10739 } 10740 // Recursively compare arrays (susceptible to call stack limits). 10741 if (seen) { 10742 if (!arraySome(other, function(othValue, othIndex) { 10743 if (!cacheHas(seen, othIndex) && 10744 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 10745 return seen.push(othIndex); 10746 } 10747 })) { 10748 result = false; 10749 break; 10750 } 10751 } else if (!( 10752 arrValue === othValue || 10753 equalFunc(arrValue, othValue, bitmask, customizer, stack) 10754 )) { 10755 result = false; 10756 break; 10757 } 10758 } 10759 stack['delete'](array); 10760 stack['delete'](other); 10761 return result; 10762 } 10763 10764 /** 10765 * A specialized version of `baseIsEqualDeep` for comparing objects of 10766 * the same `toStringTag`. 10767 * 10768 * **Note:** This function only supports comparing values with tags of 10769 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 10770 * 10771 * @private 10772 * @param {Object} object The object to compare. 10773 * @param {Object} other The other object to compare. 10774 * @param {string} tag The `toStringTag` of the objects to compare. 10775 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 10776 * @param {Function} customizer The function to customize comparisons. 10777 * @param {Function} equalFunc The function to determine equivalents of values. 10778 * @param {Object} stack Tracks traversed `object` and `other` objects. 10779 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 10780 */ 10781 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 10782 switch (tag) { 10783 case dataViewTag: 10784 if ((object.byteLength != other.byteLength) || 10785 (object.byteOffset != other.byteOffset)) { 10786 return false; 10787 } 10788 object = object.buffer; 10789 other = other.buffer; 10790 10791 case arrayBufferTag: 10792 if ((object.byteLength != other.byteLength) || 10793 !equalFunc(new Uint8Array(object), new Uint8Array(other))) { 10794 return false; 10795 } 10796 return true; 10797 10798 case boolTag: 10799 case dateTag: 10800 case numberTag: 10801 // Coerce booleans to `1` or `0` and dates to milliseconds. 10802 // Invalid dates are coerced to `NaN`. 10803 return eq(+object, +other); 10804 10805 case errorTag: 10806 return object.name == other.name && object.message == other.message; 10807 10808 case regexpTag: 10809 case stringTag: 10810 // Coerce regexes to strings and treat strings, primitives and objects, 10811 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 10812 // for more details. 10813 return object == (other + ''); 10814 10815 case mapTag: 10816 var convert = mapToArray; 10817 10818 case setTag: 10819 var isPartial = bitmask & COMPARE_PARTIAL_FLAG; 10820 convert || (convert = setToArray); 10821 10822 if (object.size != other.size && !isPartial) { 10823 return false; 10824 } 10825 // Assume cyclic values are equal. 10826 var stacked = stack.get(object); 10827 if (stacked) { 10828 return stacked == other; 10829 } 10830 bitmask |= COMPARE_UNORDERED_FLAG; 10831 10832 // Recursively compare objects (susceptible to call stack limits). 10833 stack.set(object, other); 10834 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 10835 stack['delete'](object); 10836 return result; 10837 10838 case symbolTag: 10839 if (symbolValueOf) { 10840 return symbolValueOf.call(object) == symbolValueOf.call(other); 10841 } 10842 } 10843 return false; 10844 } 10845 10846 /** 10847 * A specialized version of `baseIsEqualDeep` for objects with support for 10848 * partial deep comparisons. 10849 * 10850 * @private 10851 * @param {Object} object The object to compare. 10852 * @param {Object} other The other object to compare. 10853 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 10854 * @param {Function} customizer The function to customize comparisons. 10855 * @param {Function} equalFunc The function to determine equivalents of values. 10856 * @param {Object} stack Tracks traversed `object` and `other` objects. 10857 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 10858 */ 10859 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 10860 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 10861 objProps = getAllKeys(object), 10862 objLength = objProps.length, 10863 othProps = getAllKeys(other), 10864 othLength = othProps.length; 10865 10866 if (objLength != othLength && !isPartial) { 10867 return false; 10868 } 10869 var index = objLength; 10870 while (index--) { 10871 var key = objProps[index]; 10872 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { 10873 return false; 10874 } 10875 } 10876 // Check that cyclic values are equal. 10877 var objStacked = stack.get(object); 10878 var othStacked = stack.get(other); 10879 if (objStacked && othStacked) { 10880 return objStacked == other && othStacked == object; 10881 } 10882 var result = true; 10883 stack.set(object, other); 10884 stack.set(other, object); 10885 10886 var skipCtor = isPartial; 10887 while (++index < objLength) { 10888 key = objProps[index]; 10889 var objValue = object[key], 10890 othValue = other[key]; 10891 10892 if (customizer) { 10893 var compared = isPartial 10894 ? customizer(othValue, objValue, key, other, object, stack) 10895 : customizer(objValue, othValue, key, object, other, stack); 10896 } 10897 // Recursively compare objects (susceptible to call stack limits). 10898 if (!(compared === undefined 10899 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 10900 : compared 10901 )) { 10902 result = false; 10903 break; 10904 } 10905 skipCtor || (skipCtor = key == 'constructor'); 10906 } 10907 if (result && !skipCtor) { 10908 var objCtor = object.constructor, 10909 othCtor = other.constructor; 10910 10911 // Non `Object` object instances with different constructors are not equal. 10912 if (objCtor != othCtor && 10913 ('constructor' in object && 'constructor' in other) && 10914 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 10915 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 10916 result = false; 10917 } 10918 } 10919 stack['delete'](object); 10920 stack['delete'](other); 10921 return result; 10922 } 10923 10924 /** 10925 * A specialized version of `baseRest` which flattens the rest array. 10926 * 10927 * @private 10928 * @param {Function} func The function to apply a rest parameter to. 10929 * @returns {Function} Returns the new function. 10930 */ 10931 function flatRest(func) { 10932 return setToString(overRest(func, undefined, flatten), func + ''); 10933 } 10934 10935 /** 10936 * Creates an array of own enumerable property names and symbols of `object`. 10937 * 10938 * @private 10939 * @param {Object} object The object to query. 10940 * @returns {Array} Returns the array of property names and symbols. 10941 */ 10942 function getAllKeys(object) { 10943 return baseGetAllKeys(object, keys, getSymbols); 10944 } 10945 10946 /** 10947 * Creates an array of own and inherited enumerable property names and 10948 * symbols of `object`. 10949 * 10950 * @private 10951 * @param {Object} object The object to query. 10952 * @returns {Array} Returns the array of property names and symbols. 10953 */ 10954 function getAllKeysIn(object) { 10955 return baseGetAllKeys(object, keysIn, getSymbolsIn); 10956 } 10957 10958 /** 10959 * Gets metadata for `func`. 10960 * 10961 * @private 10962 * @param {Function} func The function to query. 10963 * @returns {*} Returns the metadata for `func`. 10964 */ 10965 var getData = !metaMap ? noop : function(func) { 10966 return metaMap.get(func); 10967 }; 10968 10969 /** 10970 * Gets the name of `func`. 10971 * 10972 * @private 10973 * @param {Function} func The function to query. 10974 * @returns {string} Returns the function name. 10975 */ 10976 function getFuncName(func) { 10977 var result = (func.name + ''), 10978 array = realNames[result], 10979 length = hasOwnProperty.call(realNames, result) ? array.length : 0; 10980 10981 while (length--) { 10982 var data = array[length], 10983 otherFunc = data.func; 10984 if (otherFunc == null || otherFunc == func) { 10985 return data.name; 10986 } 10987 } 10988 return result; 10989 } 10990 10991 /** 10992 * Gets the argument placeholder value for `func`. 10993 * 10994 * @private 10995 * @param {Function} func The function to inspect. 10996 * @returns {*} Returns the placeholder value. 10997 */ 10998 function getHolder(func) { 10999 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; 11000 return object.placeholder; 11001 } 11002 11003 /** 11004 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, 11005 * this function returns the custom method, otherwise it returns `baseIteratee`. 11006 * If arguments are provided, the chosen function is invoked with them and 11007 * its result is returned. 11008 * 11009 * @private 11010 * @param {*} [value] The value to convert to an iteratee. 11011 * @param {number} [arity] The arity of the created iteratee. 11012 * @returns {Function} Returns the chosen function or its result. 11013 */ 11014 function getIteratee() { 11015 var result = lodash.iteratee || iteratee; 11016 result = result === iteratee ? baseIteratee : result; 11017 return arguments.length ? result(arguments[0], arguments[1]) : result; 11018 } 11019 11020 /** 11021 * Gets the data for `map`. 11022 * 11023 * @private 11024 * @param {Object} map The map to query. 11025 * @param {string} key The reference key. 11026 * @returns {*} Returns the map data. 11027 */ 11028 function getMapData(map, key) { 11029 var data = map.__data__; 11030 return isKeyable(key) 11031 ? data[typeof key == 'string' ? 'string' : 'hash'] 11032 : data.map; 11033 } 11034 11035 /** 11036 * Gets the property names, values, and compare flags of `object`. 11037 * 11038 * @private 11039 * @param {Object} object The object to query. 11040 * @returns {Array} Returns the match data of `object`. 11041 */ 11042 function getMatchData(object) { 11043 var result = keys(object), 11044 length = result.length; 11045 11046 while (length--) { 11047 var key = result[length], 11048 value = object[key]; 11049 11050 result[length] = [key, value, isStrictComparable(value)]; 11051 } 11052 return result; 11053 } 11054 11055 /** 11056 * Gets the native function at `key` of `object`. 11057 * 11058 * @private 11059 * @param {Object} object The object to query. 11060 * @param {string} key The key of the method to get. 11061 * @returns {*} Returns the function if it's native, else `undefined`. 11062 */ 11063 function getNative(object, key) { 11064 var value = getValue(object, key); 11065 return baseIsNative(value) ? value : undefined; 11066 } 11067 11068 /** 11069 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 11070 * 11071 * @private 11072 * @param {*} value The value to query. 11073 * @returns {string} Returns the raw `toStringTag`. 11074 */ 11075 function getRawTag(value) { 11076 var isOwn = hasOwnProperty.call(value, symToStringTag), 11077 tag = value[symToStringTag]; 11078 11079 try { 11080 value[symToStringTag] = undefined; 11081 var unmasked = true; 11082 } catch (e) {} 11083 11084 var result = nativeObjectToString.call(value); 11085 if (unmasked) { 11086 if (isOwn) { 11087 value[symToStringTag] = tag; 11088 } else { 11089 delete value[symToStringTag]; 11090 } 11091 } 11092 return result; 11093 } 11094 11095 /** 11096 * Creates an array of the own enumerable symbols of `object`. 11097 * 11098 * @private 11099 * @param {Object} object The object to query. 11100 * @returns {Array} Returns the array of symbols. 11101 */ 11102 var getSymbols = !nativeGetSymbols ? stubArray : function(object) { 11103 if (object == null) { 11104 return []; 11105 } 11106 object = Object(object); 11107 return arrayFilter(nativeGetSymbols(object), function(symbol) { 11108 return propertyIsEnumerable.call(object, symbol); 11109 }); 11110 }; 11111 11112 /** 11113 * Creates an array of the own and inherited enumerable symbols of `object`. 11114 * 11115 * @private 11116 * @param {Object} object The object to query. 11117 * @returns {Array} Returns the array of symbols. 11118 */ 11119 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { 11120 var result = []; 11121 while (object) { 11122 arrayPush(result, getSymbols(object)); 11123 object = getPrototype(object); 11124 } 11125 return result; 11126 }; 11127 11128 /** 11129 * Gets the `toStringTag` of `value`. 11130 * 11131 * @private 11132 * @param {*} value The value to query. 11133 * @returns {string} Returns the `toStringTag`. 11134 */ 11135 var getTag = baseGetTag; 11136 11137 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 11138 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || 11139 (Map && getTag(new Map) != mapTag) || 11140 (Promise && getTag(Promise.resolve()) != promiseTag) || 11141 (Set && getTag(new Set) != setTag) || 11142 (WeakMap && getTag(new WeakMap) != weakMapTag)) { 11143 getTag = function(value) { 11144 var result = baseGetTag(value), 11145 Ctor = result == objectTag ? value.constructor : undefined, 11146 ctorString = Ctor ? toSource(Ctor) : ''; 11147 11148 if (ctorString) { 11149 switch (ctorString) { 11150 case dataViewCtorString: return dataViewTag; 11151 case mapCtorString: return mapTag; 11152 case promiseCtorString: return promiseTag; 11153 case setCtorString: return setTag; 11154 case weakMapCtorString: return weakMapTag; 11155 } 11156 } 11157 return result; 11158 }; 11159 } 11160 11161 /** 11162 * Gets the view, applying any `transforms` to the `start` and `end` positions. 11163 * 11164 * @private 11165 * @param {number} start The start of the view. 11166 * @param {number} end The end of the view. 11167 * @param {Array} transforms The transformations to apply to the view. 11168 * @returns {Object} Returns an object containing the `start` and `end` 11169 * positions of the view. 11170 */ 11171 function getView(start, end, transforms) { 11172 var index = -1, 11173 length = transforms.length; 11174 11175 while (++index < length) { 11176 var data = transforms[index], 11177 size = data.size; 11178 11179 switch (data.type) { 11180 case 'drop': start += size; break; 11181 case 'dropRight': end -= size; break; 11182 case 'take': end = nativeMin(end, start + size); break; 11183 case 'takeRight': start = nativeMax(start, end - size); break; 11184 } 11185 } 11186 return { 'start': start, 'end': end }; 11187 } 11188 11189 /** 11190 * Extracts wrapper details from the `source` body comment. 11191 * 11192 * @private 11193 * @param {string} source The source to inspect. 11194 * @returns {Array} Returns the wrapper details. 11195 */ 11196 function getWrapDetails(source) { 11197 var match = source.match(reWrapDetails); 11198 return match ? match[1].split(reSplitDetails) : []; 11199 } 11200 11201 /** 11202 * Checks if `path` exists on `object`. 11203 * 11204 * @private 11205 * @param {Object} object The object to query. 11206 * @param {Array|string} path The path to check. 11207 * @param {Function} hasFunc The function to check properties. 11208 * @returns {boolean} Returns `true` if `path` exists, else `false`. 11209 */ 11210 function hasPath(object, path, hasFunc) { 11211 path = castPath(path, object); 11212 11213 var index = -1, 11214 length = path.length, 11215 result = false; 11216 11217 while (++index < length) { 11218 var key = toKey(path[index]); 11219 if (!(result = object != null && hasFunc(object, key))) { 11220 break; 11221 } 11222 object = object[key]; 11223 } 11224 if (result || ++index != length) { 11225 return result; 11226 } 11227 length = object == null ? 0 : object.length; 11228 return !!length && isLength(length) && isIndex(key, length) && 11229 (isArray(object) || isArguments(object)); 11230 } 11231 11232 /** 11233 * Initializes an array clone. 11234 * 11235 * @private 11236 * @param {Array} array The array to clone. 11237 * @returns {Array} Returns the initialized clone. 11238 */ 11239 function initCloneArray(array) { 11240 var length = array.length, 11241 result = new array.constructor(length); 11242 11243 // Add properties assigned by `RegExp#exec`. 11244 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 11245 result.index = array.index; 11246 result.input = array.input; 11247 } 11248 return result; 11249 } 11250 11251 /** 11252 * Initializes an object clone. 11253 * 11254 * @private 11255 * @param {Object} object The object to clone. 11256 * @returns {Object} Returns the initialized clone. 11257 */ 11258 function initCloneObject(object) { 11259 return (typeof object.constructor == 'function' && !isPrototype(object)) 11260 ? baseCreate(getPrototype(object)) 11261 : {}; 11262 } 11263 11264 /** 11265 * Initializes an object clone based on its `toStringTag`. 11266 * 11267 * **Note:** This function only supports cloning values with tags of 11268 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. 11269 * 11270 * @private 11271 * @param {Object} object The object to clone. 11272 * @param {string} tag The `toStringTag` of the object to clone. 11273 * @param {boolean} [isDeep] Specify a deep clone. 11274 * @returns {Object} Returns the initialized clone. 11275 */ 11276 function initCloneByTag(object, tag, isDeep) { 11277 var Ctor = object.constructor; 11278 switch (tag) { 11279 case arrayBufferTag: 11280 return cloneArrayBuffer(object); 11281 11282 case boolTag: 11283 case dateTag: 11284 return new Ctor(+object); 11285 11286 case dataViewTag: 11287 return cloneDataView(object, isDeep); 11288 11289 case float32Tag: case float64Tag: 11290 case int8Tag: case int16Tag: case int32Tag: 11291 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: 11292 return cloneTypedArray(object, isDeep); 11293 11294 case mapTag: 11295 return new Ctor; 11296 11297 case numberTag: 11298 case stringTag: 11299 return new Ctor(object); 11300 11301 case regexpTag: 11302 return cloneRegExp(object); 11303 11304 case setTag: 11305 return new Ctor; 11306 11307 case symbolTag: 11308 return cloneSymbol(object); 11309 } 11310 } 11311 11312 /** 11313 * Inserts wrapper `details` in a comment at the top of the `source` body. 11314 * 11315 * @private 11316 * @param {string} source The source to modify. 11317 * @returns {Array} details The details to insert. 11318 * @returns {string} Returns the modified source. 11319 */ 11320 function insertWrapDetails(source, details) { 11321 var length = details.length; 11322 if (!length) { 11323 return source; 11324 } 11325 var lastIndex = length - 1; 11326 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; 11327 details = details.join(length > 2 ? ', ' : ' '); 11328 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); 11329 } 11330 11331 /** 11332 * Checks if `value` is a flattenable `arguments` object or array. 11333 * 11334 * @private 11335 * @param {*} value The value to check. 11336 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. 11337 */ 11338 function isFlattenable(value) { 11339 return isArray(value) || isArguments(value) || 11340 !!(spreadableSymbol && value && value[spreadableSymbol]); 11341 } 11342 11343 /** 11344 * Checks if `value` is a valid array-like index. 11345 * 11346 * @private 11347 * @param {*} value The value to check. 11348 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 11349 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 11350 */ 11351 function isIndex(value, length) { 11352 var type = typeof value; 11353 length = length == null ? MAX_SAFE_INTEGER : length; 11354 11355 return !!length && 11356 (type == 'number' || 11357 (type != 'symbol' && reIsUint.test(value))) && 11358 (value > -1 && value % 1 == 0 && value < length); 11359 } 11360 11361 /** 11362 * Checks if the given arguments are from an iteratee call. 11363 * 11364 * @private 11365 * @param {*} value The potential iteratee value argument. 11366 * @param {*} index The potential iteratee index or key argument. 11367 * @param {*} object The potential iteratee object argument. 11368 * @returns {boolean} Returns `true` if the arguments are from an iteratee call, 11369 * else `false`. 11370 */ 11371 function isIterateeCall(value, index, object) { 11372 if (!isObject(object)) { 11373 return false; 11374 } 11375 var type = typeof index; 11376 if (type == 'number' 11377 ? (isArrayLike(object) && isIndex(index, object.length)) 11378 : (type == 'string' && index in object) 11379 ) { 11380 return eq(object[index], value); 11381 } 11382 return false; 11383 } 11384 11385 /** 11386 * Checks if `value` is a property name and not a property path. 11387 * 11388 * @private 11389 * @param {*} value The value to check. 11390 * @param {Object} [object] The object to query keys on. 11391 * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 11392 */ 11393 function isKey(value, object) { 11394 if (isArray(value)) { 11395 return false; 11396 } 11397 var type = typeof value; 11398 if (type == 'number' || type == 'symbol' || type == 'boolean' || 11399 value == null || isSymbol(value)) { 11400 return true; 11401 } 11402 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 11403 (object != null && value in Object(object)); 11404 } 11405 11406 /** 11407 * Checks if `value` is suitable for use as unique object key. 11408 * 11409 * @private 11410 * @param {*} value The value to check. 11411 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 11412 */ 11413 function isKeyable(value) { 11414 var type = typeof value; 11415 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 11416 ? (value !== '__proto__') 11417 : (value === null); 11418 } 11419 11420 /** 11421 * Checks if `func` has a lazy counterpart. 11422 * 11423 * @private 11424 * @param {Function} func The function to check. 11425 * @returns {boolean} Returns `true` if `func` has a lazy counterpart, 11426 * else `false`. 11427 */ 11428 function isLaziable(func) { 11429 var funcName = getFuncName(func), 11430 other = lodash[funcName]; 11431 11432 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { 11433 return false; 11434 } 11435 if (func === other) { 11436 return true; 11437 } 11438 var data = getData(other); 11439 return !!data && func === data[0]; 11440 } 11441 11442 /** 11443 * Checks if `func` has its source masked. 11444 * 11445 * @private 11446 * @param {Function} func The function to check. 11447 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 11448 */ 11449 function isMasked(func) { 11450 return !!maskSrcKey && (maskSrcKey in func); 11451 } 11452 11453 /** 11454 * Checks if `func` is capable of being masked. 11455 * 11456 * @private 11457 * @param {*} value The value to check. 11458 * @returns {boolean} Returns `true` if `func` is maskable, else `false`. 11459 */ 11460 var isMaskable = coreJsData ? isFunction : stubFalse; 11461 11462 /** 11463 * Checks if `value` is likely a prototype object. 11464 * 11465 * @private 11466 * @param {*} value The value to check. 11467 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 11468 */ 11469 function isPrototype(value) { 11470 var Ctor = value && value.constructor, 11471 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; 11472 11473 return value === proto; 11474 } 11475 11476 /** 11477 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 11478 * 11479 * @private 11480 * @param {*} value The value to check. 11481 * @returns {boolean} Returns `true` if `value` if suitable for strict 11482 * equality comparisons, else `false`. 11483 */ 11484 function isStrictComparable(value) { 11485 return value === value && !isObject(value); 11486 } 11487 11488 /** 11489 * A specialized version of `matchesProperty` for source values suitable 11490 * for strict equality comparisons, i.e. `===`. 11491 * 11492 * @private 11493 * @param {string} key The key of the property to get. 11494 * @param {*} srcValue The value to match. 11495 * @returns {Function} Returns the new spec function. 11496 */ 11497 function matchesStrictComparable(key, srcValue) { 11498 return function(object) { 11499 if (object == null) { 11500 return false; 11501 } 11502 return object[key] === srcValue && 11503 (srcValue !== undefined || (key in Object(object))); 11504 }; 11505 } 11506 11507 /** 11508 * A specialized version of `_.memoize` which clears the memoized function's 11509 * cache when it exceeds `MAX_MEMOIZE_SIZE`. 11510 * 11511 * @private 11512 * @param {Function} func The function to have its output memoized. 11513 * @returns {Function} Returns the new memoized function. 11514 */ 11515 function memoizeCapped(func) { 11516 var result = memoize(func, function(key) { 11517 if (cache.size === MAX_MEMOIZE_SIZE) { 11518 cache.clear(); 11519 } 11520 return key; 11521 }); 11522 11523 var cache = result.cache; 11524 return result; 11525 } 11526 11527 /** 11528 * Merges the function metadata of `source` into `data`. 11529 * 11530 * Merging metadata reduces the number of wrappers used to invoke a function. 11531 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` 11532 * may be applied regardless of execution order. Methods like `_.ary` and 11533 * `_.rearg` modify function arguments, making the order in which they are 11534 * executed important, preventing the merging of metadata. However, we make 11535 * an exception for a safe combined case where curried functions have `_.ary` 11536 * and or `_.rearg` applied. 11537 * 11538 * @private 11539 * @param {Array} data The destination metadata. 11540 * @param {Array} source The source metadata. 11541 * @returns {Array} Returns `data`. 11542 */ 11543 function mergeData(data, source) { 11544 var bitmask = data[1], 11545 srcBitmask = source[1], 11546 newBitmask = bitmask | srcBitmask, 11547 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); 11548 11549 var isCombo = 11550 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || 11551 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || 11552 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); 11553 11554 // Exit early if metadata can't be merged. 11555 if (!(isCommon || isCombo)) { 11556 return data; 11557 } 11558 // Use source `thisArg` if available. 11559 if (srcBitmask & WRAP_BIND_FLAG) { 11560 data[2] = source[2]; 11561 // Set when currying a bound function. 11562 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; 11563 } 11564 // Compose partial arguments. 11565 var value = source[3]; 11566 if (value) { 11567 var partials = data[3]; 11568 data[3] = partials ? composeArgs(partials, value, source[4]) : value; 11569 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; 11570 } 11571 // Compose partial right arguments. 11572 value = source[5]; 11573 if (value) { 11574 partials = data[5]; 11575 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; 11576 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; 11577 } 11578 // Use source `argPos` if available. 11579 value = source[7]; 11580 if (value) { 11581 data[7] = value; 11582 } 11583 // Use source `ary` if it's smaller. 11584 if (srcBitmask & WRAP_ARY_FLAG) { 11585 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); 11586 } 11587 // Use source `arity` if one is not provided. 11588 if (data[9] == null) { 11589 data[9] = source[9]; 11590 } 11591 // Use source `func` and merge bitmasks. 11592 data[0] = source[0]; 11593 data[1] = newBitmask; 11594 11595 return data; 11596 } 11597 11598 /** 11599 * This function is like 11600 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 11601 * except that it includes inherited enumerable properties. 11602 * 11603 * @private 11604 * @param {Object} object The object to query. 11605 * @returns {Array} Returns the array of property names. 11606 */ 11607 function nativeKeysIn(object) { 11608 var result = []; 11609 if (object != null) { 11610 for (var key in Object(object)) { 11611 result.push(key); 11612 } 11613 } 11614 return result; 11615 } 11616 11617 /** 11618 * Converts `value` to a string using `Object.prototype.toString`. 11619 * 11620 * @private 11621 * @param {*} value The value to convert. 11622 * @returns {string} Returns the converted string. 11623 */ 11624 function objectToString(value) { 11625 return nativeObjectToString.call(value); 11626 } 11627 11628 /** 11629 * A specialized version of `baseRest` which transforms the rest array. 11630 * 11631 * @private 11632 * @param {Function} func The function to apply a rest parameter to. 11633 * @param {number} [start=func.length-1] The start position of the rest parameter. 11634 * @param {Function} transform The rest array transform. 11635 * @returns {Function} Returns the new function. 11636 */ 11637 function overRest(func, start, transform) { 11638 start = nativeMax(start === undefined ? (func.length - 1) : start, 0); 11639 return function() { 11640 var args = arguments, 11641 index = -1, 11642 length = nativeMax(args.length - start, 0), 11643 array = Array(length); 11644 11645 while (++index < length) { 11646 array[index] = args[start + index]; 11647 } 11648 index = -1; 11649 var otherArgs = Array(start + 1); 11650 while (++index < start) { 11651 otherArgs[index] = args[index]; 11652 } 11653 otherArgs[start] = transform(array); 11654 return apply(func, this, otherArgs); 11655 }; 11656 } 11657 11658 /** 11659 * Gets the parent value at `path` of `object`. 11660 * 11661 * @private 11662 * @param {Object} object The object to query. 11663 * @param {Array} path The path to get the parent value of. 11664 * @returns {*} Returns the parent value. 11665 */ 11666 function parent(object, path) { 11667 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); 11668 } 11669 11670 /** 11671 * Reorder `array` according to the specified indexes where the element at 11672 * the first index is assigned as the first element, the element at 11673 * the second index is assigned as the second element, and so on. 11674 * 11675 * @private 11676 * @param {Array} array The array to reorder. 11677 * @param {Array} indexes The arranged array indexes. 11678 * @returns {Array} Returns `array`. 11679 */ 11680 function reorder(array, indexes) { 11681 var arrLength = array.length, 11682 length = nativeMin(indexes.length, arrLength), 11683 oldArray = copyArray(array); 11684 11685 while (length--) { 11686 var index = indexes[length]; 11687 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; 11688 } 11689 return array; 11690 } 11691 11692 /** 11693 * Gets the value at `key`, unless `key` is "__proto__" or "constructor". 11694 * 11695 * @private 11696 * @param {Object} object The object to query. 11697 * @param {string} key The key of the property to get. 11698 * @returns {*} Returns the property value. 11699 */ 11700 function safeGet(object, key) { 11701 if (key === 'constructor' && typeof object[key] === 'function') { 11702 return; 11703 } 11704 11705 if (key == '__proto__') { 11706 return; 11707 } 11708 11709 return object[key]; 11710 } 11711 11712 /** 11713 * Sets metadata for `func`. 11714 * 11715 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short 11716 * period of time, it will trip its breaker and transition to an identity 11717 * function to avoid garbage collection pauses in V8. See 11718 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) 11719 * for more details. 11720 * 11721 * @private 11722 * @param {Function} func The function to associate metadata with. 11723 * @param {*} data The metadata. 11724 * @returns {Function} Returns `func`. 11725 */ 11726 var setData = shortOut(baseSetData); 11727 11728 /** 11729 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). 11730 * 11731 * @private 11732 * @param {Function} func The function to delay. 11733 * @param {number} wait The number of milliseconds to delay invocation. 11734 * @returns {number|Object} Returns the timer id or timeout object. 11735 */ 11736 var setTimeout = ctxSetTimeout || function(func, wait) { 11737 return root.setTimeout(func, wait); 11738 }; 11739 11740 /** 11741 * Sets the `toString` method of `func` to return `string`. 11742 * 11743 * @private 11744 * @param {Function} func The function to modify. 11745 * @param {Function} string The `toString` result. 11746 * @returns {Function} Returns `func`. 11747 */ 11748 var setToString = shortOut(baseSetToString); 11749 11750 /** 11751 * Sets the `toString` method of `wrapper` to mimic the source of `reference` 11752 * with wrapper details in a comment at the top of the source body. 11753 * 11754 * @private 11755 * @param {Function} wrapper The function to modify. 11756 * @param {Function} reference The reference function. 11757 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 11758 * @returns {Function} Returns `wrapper`. 11759 */ 11760 function setWrapToString(wrapper, reference, bitmask) { 11761 var source = (reference + ''); 11762 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); 11763 } 11764 11765 /** 11766 * Creates a function that'll short out and invoke `identity` instead 11767 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` 11768 * milliseconds. 11769 * 11770 * @private 11771 * @param {Function} func The function to restrict. 11772 * @returns {Function} Returns the new shortable function. 11773 */ 11774 function shortOut(func) { 11775 var count = 0, 11776 lastCalled = 0; 11777 11778 return function() { 11779 var stamp = nativeNow(), 11780 remaining = HOT_SPAN - (stamp - lastCalled); 11781 11782 lastCalled = stamp; 11783 if (remaining > 0) { 11784 if (++count >= HOT_COUNT) { 11785 return arguments[0]; 11786 } 11787 } else { 11788 count = 0; 11789 } 11790 return func.apply(undefined, arguments); 11791 }; 11792 } 11793 11794 /** 11795 * A specialized version of `_.shuffle` which mutates and sets the size of `array`. 11796 * 11797 * @private 11798 * @param {Array} array The array to shuffle. 11799 * @param {number} [size=array.length] The size of `array`. 11800 * @returns {Array} Returns `array`. 11801 */ 11802 function shuffleSelf(array, size) { 11803 var index = -1, 11804 length = array.length, 11805 lastIndex = length - 1; 11806 11807 size = size === undefined ? length : size; 11808 while (++index < size) { 11809 var rand = baseRandom(index, lastIndex), 11810 value = array[rand]; 11811 11812 array[rand] = array[index]; 11813 array[index] = value; 11814 } 11815 array.length = size; 11816 return array; 11817 } 11818 11819 /** 11820 * Converts `string` to a property path array. 11821 * 11822 * @private 11823 * @param {string} string The string to convert. 11824 * @returns {Array} Returns the property path array. 11825 */ 11826 var stringToPath = memoizeCapped(function(string) { 11827 var result = []; 11828 if (string.charCodeAt(0) === 46 /* . */) { 11829 result.push(''); 11830 } 11831 string.replace(rePropName, function(match, number, quote, subString) { 11832 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); 11833 }); 11834 return result; 11835 }); 11836 11837 /** 11838 * Converts `value` to a string key if it's not a string or symbol. 11839 * 11840 * @private 11841 * @param {*} value The value to inspect. 11842 * @returns {string|symbol} Returns the key. 11843 */ 11844 function toKey(value) { 11845 if (typeof value == 'string' || isSymbol(value)) { 11846 return value; 11847 } 11848 var result = (value + ''); 11849 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 11850 } 11851 11852 /** 11853 * Converts `func` to its source code. 11854 * 11855 * @private 11856 * @param {Function} func The function to convert. 11857 * @returns {string} Returns the source code. 11858 */ 11859 function toSource(func) { 11860 if (func != null) { 11861 try { 11862 return funcToString.call(func); 11863 } catch (e) {} 11864 try { 11865 return (func + ''); 11866 } catch (e) {} 11867 } 11868 return ''; 11869 } 11870 11871 /** 11872 * Updates wrapper `details` based on `bitmask` flags. 11873 * 11874 * @private 11875 * @returns {Array} details The details to modify. 11876 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 11877 * @returns {Array} Returns `details`. 11878 */ 11879 function updateWrapDetails(details, bitmask) { 11880 arrayEach(wrapFlags, function(pair) { 11881 var value = '_.' + pair[0]; 11882 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { 11883 details.push(value); 11884 } 11885 }); 11886 return details.sort(); 11887 } 11888 11889 /** 11890 * Creates a clone of `wrapper`. 11891 * 11892 * @private 11893 * @param {Object} wrapper The wrapper to clone. 11894 * @returns {Object} Returns the cloned wrapper. 11895 */ 11896 function wrapperClone(wrapper) { 11897 if (wrapper instanceof LazyWrapper) { 11898 return wrapper.clone(); 11899 } 11900 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); 11901 result.__actions__ = copyArray(wrapper.__actions__); 11902 result.__index__ = wrapper.__index__; 11903 result.__values__ = wrapper.__values__; 11904 return result; 11905 } 11906 11907 /*------------------------------------------------------------------------*/ 11908 11909 /** 11910 * Creates an array of elements split into groups the length of `size`. 11911 * If `array` can't be split evenly, the final chunk will be the remaining 11912 * elements. 11913 * 11914 * @static 11915 * @memberOf _ 11916 * @since 3.0.0 11917 * @category Array 11918 * @param {Array} array The array to process. 11919 * @param {number} [size=1] The length of each chunk 11920 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 11921 * @returns {Array} Returns the new array of chunks. 11922 * @example 11923 * 11924 * _.chunk(['a', 'b', 'c', 'd'], 2); 11925 * // => [['a', 'b'], ['c', 'd']] 11926 * 11927 * _.chunk(['a', 'b', 'c', 'd'], 3); 11928 * // => [['a', 'b', 'c'], ['d']] 11929 */ 11930 function chunk(array, size, guard) { 11931 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { 11932 size = 1; 11933 } else { 11934 size = nativeMax(toInteger(size), 0); 11935 } 11936 var length = array == null ? 0 : array.length; 11937 if (!length || size < 1) { 11938 return []; 11939 } 11940 var index = 0, 11941 resIndex = 0, 11942 result = Array(nativeCeil(length / size)); 11943 11944 while (index < length) { 11945 result[resIndex++] = baseSlice(array, index, (index += size)); 11946 } 11947 return result; 11948 } 11949 11950 /** 11951 * Creates an array with all falsey values removed. The values `false`, `null`, 11952 * `0`, `""`, `undefined`, and `NaN` are falsey. 11953 * 11954 * @static 11955 * @memberOf _ 11956 * @since 0.1.0 11957 * @category Array 11958 * @param {Array} array The array to compact. 11959 * @returns {Array} Returns the new array of filtered values. 11960 * @example 11961 * 11962 * _.compact([0, 1, false, 2, '', 3]); 11963 * // => [1, 2, 3] 11964 */ 11965 function compact(array) { 11966 var index = -1, 11967 length = array == null ? 0 : array.length, 11968 resIndex = 0, 11969 result = []; 11970 11971 while (++index < length) { 11972 var value = array[index]; 11973 if (value) { 11974 result[resIndex++] = value; 11975 } 11976 } 11977 return result; 11978 } 11979 11980 /** 11981 * Creates a new array concatenating `array` with any additional arrays 11982 * and/or values. 11983 * 11984 * @static 11985 * @memberOf _ 11986 * @since 4.0.0 11987 * @category Array 11988 * @param {Array} array The array to concatenate. 11989 * @param {...*} [values] The values to concatenate. 11990 * @returns {Array} Returns the new concatenated array. 11991 * @example 11992 * 11993 * var array = [1]; 11994 * var other = _.concat(array, 2, [3], [[4]]); 11995 * 11996 * console.log(other); 11997 * // => [1, 2, 3, [4]] 11998 * 11999 * console.log(array); 12000 * // => [1] 12001 */ 12002 function concat() { 12003 var length = arguments.length; 12004 if (!length) { 12005 return []; 12006 } 12007 var args = Array(length - 1), 12008 array = arguments[0], 12009 index = length; 12010 12011 while (index--) { 12012 args[index - 1] = arguments[index]; 12013 } 12014 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); 12015 } 12016 12017 /** 12018 * Creates an array of `array` values not included in the other given arrays 12019 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 12020 * for equality comparisons. The order and references of result values are 12021 * determined by the first array. 12022 * 12023 * **Note:** Unlike `_.pullAll`, this method returns a new array. 12024 * 12025 * @static 12026 * @memberOf _ 12027 * @since 0.1.0 12028 * @category Array 12029 * @param {Array} array The array to inspect. 12030 * @param {...Array} [values] The values to exclude. 12031 * @returns {Array} Returns the new array of filtered values. 12032 * @see _.without, _.xor 12033 * @example 12034 * 12035 * _.difference([2, 1], [2, 3]); 12036 * // => [1] 12037 */ 12038 var difference = baseRest(function(array, values) { 12039 return isArrayLikeObject(array) 12040 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) 12041 : []; 12042 }); 12043 12044 /** 12045 * This method is like `_.difference` except that it accepts `iteratee` which 12046 * is invoked for each element of `array` and `values` to generate the criterion 12047 * by which they're compared. The order and references of result values are 12048 * determined by the first array. The iteratee is invoked with one argument: 12049 * (value). 12050 * 12051 * **Note:** Unlike `_.pullAllBy`, this method returns a new array. 12052 * 12053 * @static 12054 * @memberOf _ 12055 * @since 4.0.0 12056 * @category Array 12057 * @param {Array} array The array to inspect. 12058 * @param {...Array} [values] The values to exclude. 12059 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 12060 * @returns {Array} Returns the new array of filtered values. 12061 * @example 12062 * 12063 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); 12064 * // => [1.2] 12065 * 12066 * // The `_.property` iteratee shorthand. 12067 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 12068 * // => [{ 'x': 2 }] 12069 */ 12070 var differenceBy = baseRest(function(array, values) { 12071 var iteratee = last(values); 12072 if (isArrayLikeObject(iteratee)) { 12073 iteratee = undefined; 12074 } 12075 return isArrayLikeObject(array) 12076 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) 12077 : []; 12078 }); 12079 12080 /** 12081 * This method is like `_.difference` except that it accepts `comparator` 12082 * which is invoked to compare elements of `array` to `values`. The order and 12083 * references of result values are determined by the first array. The comparator 12084 * is invoked with two arguments: (arrVal, othVal). 12085 * 12086 * **Note:** Unlike `_.pullAllWith`, this method returns a new array. 12087 * 12088 * @static 12089 * @memberOf _ 12090 * @since 4.0.0 12091 * @category Array 12092 * @param {Array} array The array to inspect. 12093 * @param {...Array} [values] The values to exclude. 12094 * @param {Function} [comparator] The comparator invoked per element. 12095 * @returns {Array} Returns the new array of filtered values. 12096 * @example 12097 * 12098 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 12099 * 12100 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); 12101 * // => [{ 'x': 2, 'y': 1 }] 12102 */ 12103 var differenceWith = baseRest(function(array, values) { 12104 var comparator = last(values); 12105 if (isArrayLikeObject(comparator)) { 12106 comparator = undefined; 12107 } 12108 return isArrayLikeObject(array) 12109 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) 12110 : []; 12111 }); 12112 12113 /** 12114 * Creates a slice of `array` with `n` elements dropped from the beginning. 12115 * 12116 * @static 12117 * @memberOf _ 12118 * @since 0.5.0 12119 * @category Array 12120 * @param {Array} array The array to query. 12121 * @param {number} [n=1] The number of elements to drop. 12122 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12123 * @returns {Array} Returns the slice of `array`. 12124 * @example 12125 * 12126 * _.drop([1, 2, 3]); 12127 * // => [2, 3] 12128 * 12129 * _.drop([1, 2, 3], 2); 12130 * // => [3] 12131 * 12132 * _.drop([1, 2, 3], 5); 12133 * // => [] 12134 * 12135 * _.drop([1, 2, 3], 0); 12136 * // => [1, 2, 3] 12137 */ 12138 function drop(array, n, guard) { 12139 var length = array == null ? 0 : array.length; 12140 if (!length) { 12141 return []; 12142 } 12143 n = (guard || n === undefined) ? 1 : toInteger(n); 12144 return baseSlice(array, n < 0 ? 0 : n, length); 12145 } 12146 12147 /** 12148 * Creates a slice of `array` with `n` elements dropped from the end. 12149 * 12150 * @static 12151 * @memberOf _ 12152 * @since 3.0.0 12153 * @category Array 12154 * @param {Array} array The array to query. 12155 * @param {number} [n=1] The number of elements to drop. 12156 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12157 * @returns {Array} Returns the slice of `array`. 12158 * @example 12159 * 12160 * _.dropRight([1, 2, 3]); 12161 * // => [1, 2] 12162 * 12163 * _.dropRight([1, 2, 3], 2); 12164 * // => [1] 12165 * 12166 * _.dropRight([1, 2, 3], 5); 12167 * // => [] 12168 * 12169 * _.dropRight([1, 2, 3], 0); 12170 * // => [1, 2, 3] 12171 */ 12172 function dropRight(array, n, guard) { 12173 var length = array == null ? 0 : array.length; 12174 if (!length) { 12175 return []; 12176 } 12177 n = (guard || n === undefined) ? 1 : toInteger(n); 12178 n = length - n; 12179 return baseSlice(array, 0, n < 0 ? 0 : n); 12180 } 12181 12182 /** 12183 * Creates a slice of `array` excluding elements dropped from the end. 12184 * Elements are dropped until `predicate` returns falsey. The predicate is 12185 * invoked with three arguments: (value, index, array). 12186 * 12187 * @static 12188 * @memberOf _ 12189 * @since 3.0.0 12190 * @category Array 12191 * @param {Array} array The array to query. 12192 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12193 * @returns {Array} Returns the slice of `array`. 12194 * @example 12195 * 12196 * var users = [ 12197 * { 'user': 'barney', 'active': true }, 12198 * { 'user': 'fred', 'active': false }, 12199 * { 'user': 'pebbles', 'active': false } 12200 * ]; 12201 * 12202 * _.dropRightWhile(users, function(o) { return !o.active; }); 12203 * // => objects for ['barney'] 12204 * 12205 * // The `_.matches` iteratee shorthand. 12206 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); 12207 * // => objects for ['barney', 'fred'] 12208 * 12209 * // The `_.matchesProperty` iteratee shorthand. 12210 * _.dropRightWhile(users, ['active', false]); 12211 * // => objects for ['barney'] 12212 * 12213 * // The `_.property` iteratee shorthand. 12214 * _.dropRightWhile(users, 'active'); 12215 * // => objects for ['barney', 'fred', 'pebbles'] 12216 */ 12217 function dropRightWhile(array, predicate) { 12218 return (array && array.length) 12219 ? baseWhile(array, getIteratee(predicate, 3), true, true) 12220 : []; 12221 } 12222 12223 /** 12224 * Creates a slice of `array` excluding elements dropped from the beginning. 12225 * Elements are dropped until `predicate` returns falsey. The predicate is 12226 * invoked with three arguments: (value, index, array). 12227 * 12228 * @static 12229 * @memberOf _ 12230 * @since 3.0.0 12231 * @category Array 12232 * @param {Array} array The array to query. 12233 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12234 * @returns {Array} Returns the slice of `array`. 12235 * @example 12236 * 12237 * var users = [ 12238 * { 'user': 'barney', 'active': false }, 12239 * { 'user': 'fred', 'active': false }, 12240 * { 'user': 'pebbles', 'active': true } 12241 * ]; 12242 * 12243 * _.dropWhile(users, function(o) { return !o.active; }); 12244 * // => objects for ['pebbles'] 12245 * 12246 * // The `_.matches` iteratee shorthand. 12247 * _.dropWhile(users, { 'user': 'barney', 'active': false }); 12248 * // => objects for ['fred', 'pebbles'] 12249 * 12250 * // The `_.matchesProperty` iteratee shorthand. 12251 * _.dropWhile(users, ['active', false]); 12252 * // => objects for ['pebbles'] 12253 * 12254 * // The `_.property` iteratee shorthand. 12255 * _.dropWhile(users, 'active'); 12256 * // => objects for ['barney', 'fred', 'pebbles'] 12257 */ 12258 function dropWhile(array, predicate) { 12259 return (array && array.length) 12260 ? baseWhile(array, getIteratee(predicate, 3), true) 12261 : []; 12262 } 12263 12264 /** 12265 * Fills elements of `array` with `value` from `start` up to, but not 12266 * including, `end`. 12267 * 12268 * **Note:** This method mutates `array`. 12269 * 12270 * @static 12271 * @memberOf _ 12272 * @since 3.2.0 12273 * @category Array 12274 * @param {Array} array The array to fill. 12275 * @param {*} value The value to fill `array` with. 12276 * @param {number} [start=0] The start position. 12277 * @param {number} [end=array.length] The end position. 12278 * @returns {Array} Returns `array`. 12279 * @example 12280 * 12281 * var array = [1, 2, 3]; 12282 * 12283 * _.fill(array, 'a'); 12284 * console.log(array); 12285 * // => ['a', 'a', 'a'] 12286 * 12287 * _.fill(Array(3), 2); 12288 * // => [2, 2, 2] 12289 * 12290 * _.fill([4, 6, 8, 10], '*', 1, 3); 12291 * // => [4, '*', '*', 10] 12292 */ 12293 function fill(array, value, start, end) { 12294 var length = array == null ? 0 : array.length; 12295 if (!length) { 12296 return []; 12297 } 12298 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { 12299 start = 0; 12300 end = length; 12301 } 12302 return baseFill(array, value, start, end); 12303 } 12304 12305 /** 12306 * This method is like `_.find` except that it returns the index of the first 12307 * element `predicate` returns truthy for instead of the element itself. 12308 * 12309 * @static 12310 * @memberOf _ 12311 * @since 1.1.0 12312 * @category Array 12313 * @param {Array} array The array to inspect. 12314 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12315 * @param {number} [fromIndex=0] The index to search from. 12316 * @returns {number} Returns the index of the found element, else `-1`. 12317 * @example 12318 * 12319 * var users = [ 12320 * { 'user': 'barney', 'active': false }, 12321 * { 'user': 'fred', 'active': false }, 12322 * { 'user': 'pebbles', 'active': true } 12323 * ]; 12324 * 12325 * _.findIndex(users, function(o) { return o.user == 'barney'; }); 12326 * // => 0 12327 * 12328 * // The `_.matches` iteratee shorthand. 12329 * _.findIndex(users, { 'user': 'fred', 'active': false }); 12330 * // => 1 12331 * 12332 * // The `_.matchesProperty` iteratee shorthand. 12333 * _.findIndex(users, ['active', false]); 12334 * // => 0 12335 * 12336 * // The `_.property` iteratee shorthand. 12337 * _.findIndex(users, 'active'); 12338 * // => 2 12339 */ 12340 function findIndex(array, predicate, fromIndex) { 12341 var length = array == null ? 0 : array.length; 12342 if (!length) { 12343 return -1; 12344 } 12345 var index = fromIndex == null ? 0 : toInteger(fromIndex); 12346 if (index < 0) { 12347 index = nativeMax(length + index, 0); 12348 } 12349 return baseFindIndex(array, getIteratee(predicate, 3), index); 12350 } 12351 12352 /** 12353 * This method is like `_.findIndex` except that it iterates over elements 12354 * of `collection` from right to left. 12355 * 12356 * @static 12357 * @memberOf _ 12358 * @since 2.0.0 12359 * @category Array 12360 * @param {Array} array The array to inspect. 12361 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12362 * @param {number} [fromIndex=array.length-1] The index to search from. 12363 * @returns {number} Returns the index of the found element, else `-1`. 12364 * @example 12365 * 12366 * var users = [ 12367 * { 'user': 'barney', 'active': true }, 12368 * { 'user': 'fred', 'active': false }, 12369 * { 'user': 'pebbles', 'active': false } 12370 * ]; 12371 * 12372 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); 12373 * // => 2 12374 * 12375 * // The `_.matches` iteratee shorthand. 12376 * _.findLastIndex(users, { 'user': 'barney', 'active': true }); 12377 * // => 0 12378 * 12379 * // The `_.matchesProperty` iteratee shorthand. 12380 * _.findLastIndex(users, ['active', false]); 12381 * // => 2 12382 * 12383 * // The `_.property` iteratee shorthand. 12384 * _.findLastIndex(users, 'active'); 12385 * // => 0 12386 */ 12387 function findLastIndex(array, predicate, fromIndex) { 12388 var length = array == null ? 0 : array.length; 12389 if (!length) { 12390 return -1; 12391 } 12392 var index = length - 1; 12393 if (fromIndex !== undefined) { 12394 index = toInteger(fromIndex); 12395 index = fromIndex < 0 12396 ? nativeMax(length + index, 0) 12397 : nativeMin(index, length - 1); 12398 } 12399 return baseFindIndex(array, getIteratee(predicate, 3), index, true); 12400 } 12401 12402 /** 12403 * Flattens `array` a single level deep. 12404 * 12405 * @static 12406 * @memberOf _ 12407 * @since 0.1.0 12408 * @category Array 12409 * @param {Array} array The array to flatten. 12410 * @returns {Array} Returns the new flattened array. 12411 * @example 12412 * 12413 * _.flatten([1, [2, [3, [4]], 5]]); 12414 * // => [1, 2, [3, [4]], 5] 12415 */ 12416 function flatten(array) { 12417 var length = array == null ? 0 : array.length; 12418 return length ? baseFlatten(array, 1) : []; 12419 } 12420 12421 /** 12422 * Recursively flattens `array`. 12423 * 12424 * @static 12425 * @memberOf _ 12426 * @since 3.0.0 12427 * @category Array 12428 * @param {Array} array The array to flatten. 12429 * @returns {Array} Returns the new flattened array. 12430 * @example 12431 * 12432 * _.flattenDeep([1, [2, [3, [4]], 5]]); 12433 * // => [1, 2, 3, 4, 5] 12434 */ 12435 function flattenDeep(array) { 12436 var length = array == null ? 0 : array.length; 12437 return length ? baseFlatten(array, INFINITY) : []; 12438 } 12439 12440 /** 12441 * Recursively flatten `array` up to `depth` times. 12442 * 12443 * @static 12444 * @memberOf _ 12445 * @since 4.4.0 12446 * @category Array 12447 * @param {Array} array The array to flatten. 12448 * @param {number} [depth=1] The maximum recursion depth. 12449 * @returns {Array} Returns the new flattened array. 12450 * @example 12451 * 12452 * var array = [1, [2, [3, [4]], 5]]; 12453 * 12454 * _.flattenDepth(array, 1); 12455 * // => [1, 2, [3, [4]], 5] 12456 * 12457 * _.flattenDepth(array, 2); 12458 * // => [1, 2, 3, [4], 5] 12459 */ 12460 function flattenDepth(array, depth) { 12461 var length = array == null ? 0 : array.length; 12462 if (!length) { 12463 return []; 12464 } 12465 depth = depth === undefined ? 1 : toInteger(depth); 12466 return baseFlatten(array, depth); 12467 } 12468 12469 /** 12470 * The inverse of `_.toPairs`; this method returns an object composed 12471 * from key-value `pairs`. 12472 * 12473 * @static 12474 * @memberOf _ 12475 * @since 4.0.0 12476 * @category Array 12477 * @param {Array} pairs The key-value pairs. 12478 * @returns {Object} Returns the new object. 12479 * @example 12480 * 12481 * _.fromPairs([['a', 1], ['b', 2]]); 12482 * // => { 'a': 1, 'b': 2 } 12483 */ 12484 function fromPairs(pairs) { 12485 var index = -1, 12486 length = pairs == null ? 0 : pairs.length, 12487 result = {}; 12488 12489 while (++index < length) { 12490 var pair = pairs[index]; 12491 result[pair[0]] = pair[1]; 12492 } 12493 return result; 12494 } 12495 12496 /** 12497 * Gets the first element of `array`. 12498 * 12499 * @static 12500 * @memberOf _ 12501 * @since 0.1.0 12502 * @alias first 12503 * @category Array 12504 * @param {Array} array The array to query. 12505 * @returns {*} Returns the first element of `array`. 12506 * @example 12507 * 12508 * _.head([1, 2, 3]); 12509 * // => 1 12510 * 12511 * _.head([]); 12512 * // => undefined 12513 */ 12514 function head(array) { 12515 return (array && array.length) ? array[0] : undefined; 12516 } 12517 12518 /** 12519 * Gets the index at which the first occurrence of `value` is found in `array` 12520 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 12521 * for equality comparisons. If `fromIndex` is negative, it's used as the 12522 * offset from the end of `array`. 12523 * 12524 * @static 12525 * @memberOf _ 12526 * @since 0.1.0 12527 * @category Array 12528 * @param {Array} array The array to inspect. 12529 * @param {*} value The value to search for. 12530 * @param {number} [fromIndex=0] The index to search from. 12531 * @returns {number} Returns the index of the matched value, else `-1`. 12532 * @example 12533 * 12534 * _.indexOf([1, 2, 1, 2], 2); 12535 * // => 1 12536 * 12537 * // Search from the `fromIndex`. 12538 * _.indexOf([1, 2, 1, 2], 2, 2); 12539 * // => 3 12540 */ 12541 function indexOf(array, value, fromIndex) { 12542 var length = array == null ? 0 : array.length; 12543 if (!length) { 12544 return -1; 12545 } 12546 var index = fromIndex == null ? 0 : toInteger(fromIndex); 12547 if (index < 0) { 12548 index = nativeMax(length + index, 0); 12549 } 12550 return baseIndexOf(array, value, index); 12551 } 12552 12553 /** 12554 * Gets all but the last element of `array`. 12555 * 12556 * @static 12557 * @memberOf _ 12558 * @since 0.1.0 12559 * @category Array 12560 * @param {Array} array The array to query. 12561 * @returns {Array} Returns the slice of `array`. 12562 * @example 12563 * 12564 * _.initial([1, 2, 3]); 12565 * // => [1, 2] 12566 */ 12567 function initial(array) { 12568 var length = array == null ? 0 : array.length; 12569 return length ? baseSlice(array, 0, -1) : []; 12570 } 12571 12572 /** 12573 * Creates an array of unique values that are included in all given arrays 12574 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 12575 * for equality comparisons. The order and references of result values are 12576 * determined by the first array. 12577 * 12578 * @static 12579 * @memberOf _ 12580 * @since 0.1.0 12581 * @category Array 12582 * @param {...Array} [arrays] The arrays to inspect. 12583 * @returns {Array} Returns the new array of intersecting values. 12584 * @example 12585 * 12586 * _.intersection([2, 1], [2, 3]); 12587 * // => [2] 12588 */ 12589 var intersection = baseRest(function(arrays) { 12590 var mapped = arrayMap(arrays, castArrayLikeObject); 12591 return (mapped.length && mapped[0] === arrays[0]) 12592 ? baseIntersection(mapped) 12593 : []; 12594 }); 12595 12596 /** 12597 * This method is like `_.intersection` except that it accepts `iteratee` 12598 * which is invoked for each element of each `arrays` to generate the criterion 12599 * by which they're compared. The order and references of result values are 12600 * determined by the first array. The iteratee is invoked with one argument: 12601 * (value). 12602 * 12603 * @static 12604 * @memberOf _ 12605 * @since 4.0.0 12606 * @category Array 12607 * @param {...Array} [arrays] The arrays to inspect. 12608 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 12609 * @returns {Array} Returns the new array of intersecting values. 12610 * @example 12611 * 12612 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); 12613 * // => [2.1] 12614 * 12615 * // The `_.property` iteratee shorthand. 12616 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 12617 * // => [{ 'x': 1 }] 12618 */ 12619 var intersectionBy = baseRest(function(arrays) { 12620 var iteratee = last(arrays), 12621 mapped = arrayMap(arrays, castArrayLikeObject); 12622 12623 if (iteratee === last(mapped)) { 12624 iteratee = undefined; 12625 } else { 12626 mapped.pop(); 12627 } 12628 return (mapped.length && mapped[0] === arrays[0]) 12629 ? baseIntersection(mapped, getIteratee(iteratee, 2)) 12630 : []; 12631 }); 12632 12633 /** 12634 * This method is like `_.intersection` except that it accepts `comparator` 12635 * which is invoked to compare elements of `arrays`. The order and references 12636 * of result values are determined by the first array. The comparator is 12637 * invoked with two arguments: (arrVal, othVal). 12638 * 12639 * @static 12640 * @memberOf _ 12641 * @since 4.0.0 12642 * @category Array 12643 * @param {...Array} [arrays] The arrays to inspect. 12644 * @param {Function} [comparator] The comparator invoked per element. 12645 * @returns {Array} Returns the new array of intersecting values. 12646 * @example 12647 * 12648 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 12649 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 12650 * 12651 * _.intersectionWith(objects, others, _.isEqual); 12652 * // => [{ 'x': 1, 'y': 2 }] 12653 */ 12654 var intersectionWith = baseRest(function(arrays) { 12655 var comparator = last(arrays), 12656 mapped = arrayMap(arrays, castArrayLikeObject); 12657 12658 comparator = typeof comparator == 'function' ? comparator : undefined; 12659 if (comparator) { 12660 mapped.pop(); 12661 } 12662 return (mapped.length && mapped[0] === arrays[0]) 12663 ? baseIntersection(mapped, undefined, comparator) 12664 : []; 12665 }); 12666 12667 /** 12668 * Converts all elements in `array` into a string separated by `separator`. 12669 * 12670 * @static 12671 * @memberOf _ 12672 * @since 4.0.0 12673 * @category Array 12674 * @param {Array} array The array to convert. 12675 * @param {string} [separator=','] The element separator. 12676 * @returns {string} Returns the joined string. 12677 * @example 12678 * 12679 * _.join(['a', 'b', 'c'], '~'); 12680 * // => 'a~b~c' 12681 */ 12682 function join(array, separator) { 12683 return array == null ? '' : nativeJoin.call(array, separator); 12684 } 12685 12686 /** 12687 * Gets the last element of `array`. 12688 * 12689 * @static 12690 * @memberOf _ 12691 * @since 0.1.0 12692 * @category Array 12693 * @param {Array} array The array to query. 12694 * @returns {*} Returns the last element of `array`. 12695 * @example 12696 * 12697 * _.last([1, 2, 3]); 12698 * // => 3 12699 */ 12700 function last(array) { 12701 var length = array == null ? 0 : array.length; 12702 return length ? array[length - 1] : undefined; 12703 } 12704 12705 /** 12706 * This method is like `_.indexOf` except that it iterates over elements of 12707 * `array` from right to left. 12708 * 12709 * @static 12710 * @memberOf _ 12711 * @since 0.1.0 12712 * @category Array 12713 * @param {Array} array The array to inspect. 12714 * @param {*} value The value to search for. 12715 * @param {number} [fromIndex=array.length-1] The index to search from. 12716 * @returns {number} Returns the index of the matched value, else `-1`. 12717 * @example 12718 * 12719 * _.lastIndexOf([1, 2, 1, 2], 2); 12720 * // => 3 12721 * 12722 * // Search from the `fromIndex`. 12723 * _.lastIndexOf([1, 2, 1, 2], 2, 2); 12724 * // => 1 12725 */ 12726 function lastIndexOf(array, value, fromIndex) { 12727 var length = array == null ? 0 : array.length; 12728 if (!length) { 12729 return -1; 12730 } 12731 var index = length; 12732 if (fromIndex !== undefined) { 12733 index = toInteger(fromIndex); 12734 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); 12735 } 12736 return value === value 12737 ? strictLastIndexOf(array, value, index) 12738 : baseFindIndex(array, baseIsNaN, index, true); 12739 } 12740 12741 /** 12742 * Gets the element at index `n` of `array`. If `n` is negative, the nth 12743 * element from the end is returned. 12744 * 12745 * @static 12746 * @memberOf _ 12747 * @since 4.11.0 12748 * @category Array 12749 * @param {Array} array The array to query. 12750 * @param {number} [n=0] The index of the element to return. 12751 * @returns {*} Returns the nth element of `array`. 12752 * @example 12753 * 12754 * var array = ['a', 'b', 'c', 'd']; 12755 * 12756 * _.nth(array, 1); 12757 * // => 'b' 12758 * 12759 * _.nth(array, -2); 12760 * // => 'c'; 12761 */ 12762 function nth(array, n) { 12763 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; 12764 } 12765 12766 /** 12767 * Removes all given values from `array` using 12768 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 12769 * for equality comparisons. 12770 * 12771 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` 12772 * to remove elements from an array by predicate. 12773 * 12774 * @static 12775 * @memberOf _ 12776 * @since 2.0.0 12777 * @category Array 12778 * @param {Array} array The array to modify. 12779 * @param {...*} [values] The values to remove. 12780 * @returns {Array} Returns `array`. 12781 * @example 12782 * 12783 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 12784 * 12785 * _.pull(array, 'a', 'c'); 12786 * console.log(array); 12787 * // => ['b', 'b'] 12788 */ 12789 var pull = baseRest(pullAll); 12790 12791 /** 12792 * This method is like `_.pull` except that it accepts an array of values to remove. 12793 * 12794 * **Note:** Unlike `_.difference`, this method mutates `array`. 12795 * 12796 * @static 12797 * @memberOf _ 12798 * @since 4.0.0 12799 * @category Array 12800 * @param {Array} array The array to modify. 12801 * @param {Array} values The values to remove. 12802 * @returns {Array} Returns `array`. 12803 * @example 12804 * 12805 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 12806 * 12807 * _.pullAll(array, ['a', 'c']); 12808 * console.log(array); 12809 * // => ['b', 'b'] 12810 */ 12811 function pullAll(array, values) { 12812 return (array && array.length && values && values.length) 12813 ? basePullAll(array, values) 12814 : array; 12815 } 12816 12817 /** 12818 * This method is like `_.pullAll` except that it accepts `iteratee` which is 12819 * invoked for each element of `array` and `values` to generate the criterion 12820 * by which they're compared. The iteratee is invoked with one argument: (value). 12821 * 12822 * **Note:** Unlike `_.differenceBy`, this method mutates `array`. 12823 * 12824 * @static 12825 * @memberOf _ 12826 * @since 4.0.0 12827 * @category Array 12828 * @param {Array} array The array to modify. 12829 * @param {Array} values The values to remove. 12830 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 12831 * @returns {Array} Returns `array`. 12832 * @example 12833 * 12834 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; 12835 * 12836 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); 12837 * console.log(array); 12838 * // => [{ 'x': 2 }] 12839 */ 12840 function pullAllBy(array, values, iteratee) { 12841 return (array && array.length && values && values.length) 12842 ? basePullAll(array, values, getIteratee(iteratee, 2)) 12843 : array; 12844 } 12845 12846 /** 12847 * This method is like `_.pullAll` except that it accepts `comparator` which 12848 * is invoked to compare elements of `array` to `values`. The comparator is 12849 * invoked with two arguments: (arrVal, othVal). 12850 * 12851 * **Note:** Unlike `_.differenceWith`, this method mutates `array`. 12852 * 12853 * @static 12854 * @memberOf _ 12855 * @since 4.6.0 12856 * @category Array 12857 * @param {Array} array The array to modify. 12858 * @param {Array} values The values to remove. 12859 * @param {Function} [comparator] The comparator invoked per element. 12860 * @returns {Array} Returns `array`. 12861 * @example 12862 * 12863 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; 12864 * 12865 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); 12866 * console.log(array); 12867 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] 12868 */ 12869 function pullAllWith(array, values, comparator) { 12870 return (array && array.length && values && values.length) 12871 ? basePullAll(array, values, undefined, comparator) 12872 : array; 12873 } 12874 12875 /** 12876 * Removes elements from `array` corresponding to `indexes` and returns an 12877 * array of removed elements. 12878 * 12879 * **Note:** Unlike `_.at`, this method mutates `array`. 12880 * 12881 * @static 12882 * @memberOf _ 12883 * @since 3.0.0 12884 * @category Array 12885 * @param {Array} array The array to modify. 12886 * @param {...(number|number[])} [indexes] The indexes of elements to remove. 12887 * @returns {Array} Returns the new array of removed elements. 12888 * @example 12889 * 12890 * var array = ['a', 'b', 'c', 'd']; 12891 * var pulled = _.pullAt(array, [1, 3]); 12892 * 12893 * console.log(array); 12894 * // => ['a', 'c'] 12895 * 12896 * console.log(pulled); 12897 * // => ['b', 'd'] 12898 */ 12899 var pullAt = flatRest(function(array, indexes) { 12900 var length = array == null ? 0 : array.length, 12901 result = baseAt(array, indexes); 12902 12903 basePullAt(array, arrayMap(indexes, function(index) { 12904 return isIndex(index, length) ? +index : index; 12905 }).sort(compareAscending)); 12906 12907 return result; 12908 }); 12909 12910 /** 12911 * Removes all elements from `array` that `predicate` returns truthy for 12912 * and returns an array of the removed elements. The predicate is invoked 12913 * with three arguments: (value, index, array). 12914 * 12915 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` 12916 * to pull elements from an array by value. 12917 * 12918 * @static 12919 * @memberOf _ 12920 * @since 2.0.0 12921 * @category Array 12922 * @param {Array} array The array to modify. 12923 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12924 * @returns {Array} Returns the new array of removed elements. 12925 * @example 12926 * 12927 * var array = [1, 2, 3, 4]; 12928 * var evens = _.remove(array, function(n) { 12929 * return n % 2 == 0; 12930 * }); 12931 * 12932 * console.log(array); 12933 * // => [1, 3] 12934 * 12935 * console.log(evens); 12936 * // => [2, 4] 12937 */ 12938 function remove(array, predicate) { 12939 var result = []; 12940 if (!(array && array.length)) { 12941 return result; 12942 } 12943 var index = -1, 12944 indexes = [], 12945 length = array.length; 12946 12947 predicate = getIteratee(predicate, 3); 12948 while (++index < length) { 12949 var value = array[index]; 12950 if (predicate(value, index, array)) { 12951 result.push(value); 12952 indexes.push(index); 12953 } 12954 } 12955 basePullAt(array, indexes); 12956 return result; 12957 } 12958 12959 /** 12960 * Reverses `array` so that the first element becomes the last, the second 12961 * element becomes the second to last, and so on. 12962 * 12963 * **Note:** This method mutates `array` and is based on 12964 * [`Array#reverse`](https://mdn.io/Array/reverse). 12965 * 12966 * @static 12967 * @memberOf _ 12968 * @since 4.0.0 12969 * @category Array 12970 * @param {Array} array The array to modify. 12971 * @returns {Array} Returns `array`. 12972 * @example 12973 * 12974 * var array = [1, 2, 3]; 12975 * 12976 * _.reverse(array); 12977 * // => [3, 2, 1] 12978 * 12979 * console.log(array); 12980 * // => [3, 2, 1] 12981 */ 12982 function reverse(array) { 12983 return array == null ? array : nativeReverse.call(array); 12984 } 12985 12986 /** 12987 * Creates a slice of `array` from `start` up to, but not including, `end`. 12988 * 12989 * **Note:** This method is used instead of 12990 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are 12991 * returned. 12992 * 12993 * @static 12994 * @memberOf _ 12995 * @since 3.0.0 12996 * @category Array 12997 * @param {Array} array The array to slice. 12998 * @param {number} [start=0] The start position. 12999 * @param {number} [end=array.length] The end position. 13000 * @returns {Array} Returns the slice of `array`. 13001 */ 13002 function slice(array, start, end) { 13003 var length = array == null ? 0 : array.length; 13004 if (!length) { 13005 return []; 13006 } 13007 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { 13008 start = 0; 13009 end = length; 13010 } 13011 else { 13012 start = start == null ? 0 : toInteger(start); 13013 end = end === undefined ? length : toInteger(end); 13014 } 13015 return baseSlice(array, start, end); 13016 } 13017 13018 /** 13019 * Uses a binary search to determine the lowest index at which `value` 13020 * should be inserted into `array` in order to maintain its sort order. 13021 * 13022 * @static 13023 * @memberOf _ 13024 * @since 0.1.0 13025 * @category Array 13026 * @param {Array} array The sorted array to inspect. 13027 * @param {*} value The value to evaluate. 13028 * @returns {number} Returns the index at which `value` should be inserted 13029 * into `array`. 13030 * @example 13031 * 13032 * _.sortedIndex([30, 50], 40); 13033 * // => 1 13034 */ 13035 function sortedIndex(array, value) { 13036 return baseSortedIndex(array, value); 13037 } 13038 13039 /** 13040 * This method is like `_.sortedIndex` except that it accepts `iteratee` 13041 * which is invoked for `value` and each element of `array` to compute their 13042 * sort ranking. The iteratee is invoked with one argument: (value). 13043 * 13044 * @static 13045 * @memberOf _ 13046 * @since 4.0.0 13047 * @category Array 13048 * @param {Array} array The sorted array to inspect. 13049 * @param {*} value The value to evaluate. 13050 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13051 * @returns {number} Returns the index at which `value` should be inserted 13052 * into `array`. 13053 * @example 13054 * 13055 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 13056 * 13057 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 13058 * // => 0 13059 * 13060 * // The `_.property` iteratee shorthand. 13061 * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); 13062 * // => 0 13063 */ 13064 function sortedIndexBy(array, value, iteratee) { 13065 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); 13066 } 13067 13068 /** 13069 * This method is like `_.indexOf` except that it performs a binary 13070 * search on a sorted `array`. 13071 * 13072 * @static 13073 * @memberOf _ 13074 * @since 4.0.0 13075 * @category Array 13076 * @param {Array} array The array to inspect. 13077 * @param {*} value The value to search for. 13078 * @returns {number} Returns the index of the matched value, else `-1`. 13079 * @example 13080 * 13081 * _.sortedIndexOf([4, 5, 5, 5, 6], 5); 13082 * // => 1 13083 */ 13084 function sortedIndexOf(array, value) { 13085 var length = array == null ? 0 : array.length; 13086 if (length) { 13087 var index = baseSortedIndex(array, value); 13088 if (index < length && eq(array[index], value)) { 13089 return index; 13090 } 13091 } 13092 return -1; 13093 } 13094 13095 /** 13096 * This method is like `_.sortedIndex` except that it returns the highest 13097 * index at which `value` should be inserted into `array` in order to 13098 * maintain its sort order. 13099 * 13100 * @static 13101 * @memberOf _ 13102 * @since 3.0.0 13103 * @category Array 13104 * @param {Array} array The sorted array to inspect. 13105 * @param {*} value The value to evaluate. 13106 * @returns {number} Returns the index at which `value` should be inserted 13107 * into `array`. 13108 * @example 13109 * 13110 * _.sortedLastIndex([4, 5, 5, 5, 6], 5); 13111 * // => 4 13112 */ 13113 function sortedLastIndex(array, value) { 13114 return baseSortedIndex(array, value, true); 13115 } 13116 13117 /** 13118 * This method is like `_.sortedLastIndex` except that it accepts `iteratee` 13119 * which is invoked for `value` and each element of `array` to compute their 13120 * sort ranking. The iteratee is invoked with one argument: (value). 13121 * 13122 * @static 13123 * @memberOf _ 13124 * @since 4.0.0 13125 * @category Array 13126 * @param {Array} array The sorted array to inspect. 13127 * @param {*} value The value to evaluate. 13128 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13129 * @returns {number} Returns the index at which `value` should be inserted 13130 * into `array`. 13131 * @example 13132 * 13133 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 13134 * 13135 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 13136 * // => 1 13137 * 13138 * // The `_.property` iteratee shorthand. 13139 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); 13140 * // => 1 13141 */ 13142 function sortedLastIndexBy(array, value, iteratee) { 13143 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); 13144 } 13145 13146 /** 13147 * This method is like `_.lastIndexOf` except that it performs a binary 13148 * search on a sorted `array`. 13149 * 13150 * @static 13151 * @memberOf _ 13152 * @since 4.0.0 13153 * @category Array 13154 * @param {Array} array The array to inspect. 13155 * @param {*} value The value to search for. 13156 * @returns {number} Returns the index of the matched value, else `-1`. 13157 * @example 13158 * 13159 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); 13160 * // => 3 13161 */ 13162 function sortedLastIndexOf(array, value) { 13163 var length = array == null ? 0 : array.length; 13164 if (length) { 13165 var index = baseSortedIndex(array, value, true) - 1; 13166 if (eq(array[index], value)) { 13167 return index; 13168 } 13169 } 13170 return -1; 13171 } 13172 13173 /** 13174 * This method is like `_.uniq` except that it's designed and optimized 13175 * for sorted arrays. 13176 * 13177 * @static 13178 * @memberOf _ 13179 * @since 4.0.0 13180 * @category Array 13181 * @param {Array} array The array to inspect. 13182 * @returns {Array} Returns the new duplicate free array. 13183 * @example 13184 * 13185 * _.sortedUniq([1, 1, 2]); 13186 * // => [1, 2] 13187 */ 13188 function sortedUniq(array) { 13189 return (array && array.length) 13190 ? baseSortedUniq(array) 13191 : []; 13192 } 13193 13194 /** 13195 * This method is like `_.uniqBy` except that it's designed and optimized 13196 * for sorted arrays. 13197 * 13198 * @static 13199 * @memberOf _ 13200 * @since 4.0.0 13201 * @category Array 13202 * @param {Array} array The array to inspect. 13203 * @param {Function} [iteratee] The iteratee invoked per element. 13204 * @returns {Array} Returns the new duplicate free array. 13205 * @example 13206 * 13207 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); 13208 * // => [1.1, 2.3] 13209 */ 13210 function sortedUniqBy(array, iteratee) { 13211 return (array && array.length) 13212 ? baseSortedUniq(array, getIteratee(iteratee, 2)) 13213 : []; 13214 } 13215 13216 /** 13217 * Gets all but the first element of `array`. 13218 * 13219 * @static 13220 * @memberOf _ 13221 * @since 4.0.0 13222 * @category Array 13223 * @param {Array} array The array to query. 13224 * @returns {Array} Returns the slice of `array`. 13225 * @example 13226 * 13227 * _.tail([1, 2, 3]); 13228 * // => [2, 3] 13229 */ 13230 function tail(array) { 13231 var length = array == null ? 0 : array.length; 13232 return length ? baseSlice(array, 1, length) : []; 13233 } 13234 13235 /** 13236 * Creates a slice of `array` with `n` elements taken from the beginning. 13237 * 13238 * @static 13239 * @memberOf _ 13240 * @since 0.1.0 13241 * @category Array 13242 * @param {Array} array The array to query. 13243 * @param {number} [n=1] The number of elements to take. 13244 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 13245 * @returns {Array} Returns the slice of `array`. 13246 * @example 13247 * 13248 * _.take([1, 2, 3]); 13249 * // => [1] 13250 * 13251 * _.take([1, 2, 3], 2); 13252 * // => [1, 2] 13253 * 13254 * _.take([1, 2, 3], 5); 13255 * // => [1, 2, 3] 13256 * 13257 * _.take([1, 2, 3], 0); 13258 * // => [] 13259 */ 13260 function take(array, n, guard) { 13261 if (!(array && array.length)) { 13262 return []; 13263 } 13264 n = (guard || n === undefined) ? 1 : toInteger(n); 13265 return baseSlice(array, 0, n < 0 ? 0 : n); 13266 } 13267 13268 /** 13269 * Creates a slice of `array` with `n` elements taken from the end. 13270 * 13271 * @static 13272 * @memberOf _ 13273 * @since 3.0.0 13274 * @category Array 13275 * @param {Array} array The array to query. 13276 * @param {number} [n=1] The number of elements to take. 13277 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 13278 * @returns {Array} Returns the slice of `array`. 13279 * @example 13280 * 13281 * _.takeRight([1, 2, 3]); 13282 * // => [3] 13283 * 13284 * _.takeRight([1, 2, 3], 2); 13285 * // => [2, 3] 13286 * 13287 * _.takeRight([1, 2, 3], 5); 13288 * // => [1, 2, 3] 13289 * 13290 * _.takeRight([1, 2, 3], 0); 13291 * // => [] 13292 */ 13293 function takeRight(array, n, guard) { 13294 var length = array == null ? 0 : array.length; 13295 if (!length) { 13296 return []; 13297 } 13298 n = (guard || n === undefined) ? 1 : toInteger(n); 13299 n = length - n; 13300 return baseSlice(array, n < 0 ? 0 : n, length); 13301 } 13302 13303 /** 13304 * Creates a slice of `array` with elements taken from the end. Elements are 13305 * taken until `predicate` returns falsey. The predicate is invoked with 13306 * three arguments: (value, index, array). 13307 * 13308 * @static 13309 * @memberOf _ 13310 * @since 3.0.0 13311 * @category Array 13312 * @param {Array} array The array to query. 13313 * @param {Function} [predicate=_.identity] The function invoked per iteration. 13314 * @returns {Array} Returns the slice of `array`. 13315 * @example 13316 * 13317 * var users = [ 13318 * { 'user': 'barney', 'active': true }, 13319 * { 'user': 'fred', 'active': false }, 13320 * { 'user': 'pebbles', 'active': false } 13321 * ]; 13322 * 13323 * _.takeRightWhile(users, function(o) { return !o.active; }); 13324 * // => objects for ['fred', 'pebbles'] 13325 * 13326 * // The `_.matches` iteratee shorthand. 13327 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); 13328 * // => objects for ['pebbles'] 13329 * 13330 * // The `_.matchesProperty` iteratee shorthand. 13331 * _.takeRightWhile(users, ['active', false]); 13332 * // => objects for ['fred', 'pebbles'] 13333 * 13334 * // The `_.property` iteratee shorthand. 13335 * _.takeRightWhile(users, 'active'); 13336 * // => [] 13337 */ 13338 function takeRightWhile(array, predicate) { 13339 return (array && array.length) 13340 ? baseWhile(array, getIteratee(predicate, 3), false, true) 13341 : []; 13342 } 13343 13344 /** 13345 * Creates a slice of `array` with elements taken from the beginning. Elements 13346 * are taken until `predicate` returns falsey. The predicate is invoked with 13347 * three arguments: (value, index, array). 13348 * 13349 * @static 13350 * @memberOf _ 13351 * @since 3.0.0 13352 * @category Array 13353 * @param {Array} array The array to query. 13354 * @param {Function} [predicate=_.identity] The function invoked per iteration. 13355 * @returns {Array} Returns the slice of `array`. 13356 * @example 13357 * 13358 * var users = [ 13359 * { 'user': 'barney', 'active': false }, 13360 * { 'user': 'fred', 'active': false }, 13361 * { 'user': 'pebbles', 'active': true } 13362 * ]; 13363 * 13364 * _.takeWhile(users, function(o) { return !o.active; }); 13365 * // => objects for ['barney', 'fred'] 13366 * 13367 * // The `_.matches` iteratee shorthand. 13368 * _.takeWhile(users, { 'user': 'barney', 'active': false }); 13369 * // => objects for ['barney'] 13370 * 13371 * // The `_.matchesProperty` iteratee shorthand. 13372 * _.takeWhile(users, ['active', false]); 13373 * // => objects for ['barney', 'fred'] 13374 * 13375 * // The `_.property` iteratee shorthand. 13376 * _.takeWhile(users, 'active'); 13377 * // => [] 13378 */ 13379 function takeWhile(array, predicate) { 13380 return (array && array.length) 13381 ? baseWhile(array, getIteratee(predicate, 3)) 13382 : []; 13383 } 13384 13385 /** 13386 * Creates an array of unique values, in order, from all given arrays using 13387 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 13388 * for equality comparisons. 13389 * 13390 * @static 13391 * @memberOf _ 13392 * @since 0.1.0 13393 * @category Array 13394 * @param {...Array} [arrays] The arrays to inspect. 13395 * @returns {Array} Returns the new array of combined values. 13396 * @example 13397 * 13398 * _.union([2], [1, 2]); 13399 * // => [2, 1] 13400 */ 13401 var union = baseRest(function(arrays) { 13402 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); 13403 }); 13404 13405 /** 13406 * This method is like `_.union` except that it accepts `iteratee` which is 13407 * invoked for each element of each `arrays` to generate the criterion by 13408 * which uniqueness is computed. Result values are chosen from the first 13409 * array in which the value occurs. The iteratee is invoked with one argument: 13410 * (value). 13411 * 13412 * @static 13413 * @memberOf _ 13414 * @since 4.0.0 13415 * @category Array 13416 * @param {...Array} [arrays] The arrays to inspect. 13417 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13418 * @returns {Array} Returns the new array of combined values. 13419 * @example 13420 * 13421 * _.unionBy([2.1], [1.2, 2.3], Math.floor); 13422 * // => [2.1, 1.2] 13423 * 13424 * // The `_.property` iteratee shorthand. 13425 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 13426 * // => [{ 'x': 1 }, { 'x': 2 }] 13427 */ 13428 var unionBy = baseRest(function(arrays) { 13429 var iteratee = last(arrays); 13430 if (isArrayLikeObject(iteratee)) { 13431 iteratee = undefined; 13432 } 13433 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); 13434 }); 13435 13436 /** 13437 * This method is like `_.union` except that it accepts `comparator` which 13438 * is invoked to compare elements of `arrays`. Result values are chosen from 13439 * the first array in which the value occurs. The comparator is invoked 13440 * with two arguments: (arrVal, othVal). 13441 * 13442 * @static 13443 * @memberOf _ 13444 * @since 4.0.0 13445 * @category Array 13446 * @param {...Array} [arrays] The arrays to inspect. 13447 * @param {Function} [comparator] The comparator invoked per element. 13448 * @returns {Array} Returns the new array of combined values. 13449 * @example 13450 * 13451 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 13452 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 13453 * 13454 * _.unionWith(objects, others, _.isEqual); 13455 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 13456 */ 13457 var unionWith = baseRest(function(arrays) { 13458 var comparator = last(arrays); 13459 comparator = typeof comparator == 'function' ? comparator : undefined; 13460 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); 13461 }); 13462 13463 /** 13464 * Creates a duplicate-free version of an array, using 13465 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 13466 * for equality comparisons, in which only the first occurrence of each element 13467 * is kept. The order of result values is determined by the order they occur 13468 * in the array. 13469 * 13470 * @static 13471 * @memberOf _ 13472 * @since 0.1.0 13473 * @category Array 13474 * @param {Array} array The array to inspect. 13475 * @returns {Array} Returns the new duplicate free array. 13476 * @example 13477 * 13478 * _.uniq([2, 1, 2]); 13479 * // => [2, 1] 13480 */ 13481 function uniq(array) { 13482 return (array && array.length) ? baseUniq(array) : []; 13483 } 13484 13485 /** 13486 * This method is like `_.uniq` except that it accepts `iteratee` which is 13487 * invoked for each element in `array` to generate the criterion by which 13488 * uniqueness is computed. The order of result values is determined by the 13489 * order they occur in the array. The iteratee is invoked with one argument: 13490 * (value). 13491 * 13492 * @static 13493 * @memberOf _ 13494 * @since 4.0.0 13495 * @category Array 13496 * @param {Array} array The array to inspect. 13497 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13498 * @returns {Array} Returns the new duplicate free array. 13499 * @example 13500 * 13501 * _.uniqBy([2.1, 1.2, 2.3], Math.floor); 13502 * // => [2.1, 1.2] 13503 * 13504 * // The `_.property` iteratee shorthand. 13505 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); 13506 * // => [{ 'x': 1 }, { 'x': 2 }] 13507 */ 13508 function uniqBy(array, iteratee) { 13509 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; 13510 } 13511 13512 /** 13513 * This method is like `_.uniq` except that it accepts `comparator` which 13514 * is invoked to compare elements of `array`. The order of result values is 13515 * determined by the order they occur in the array.The comparator is invoked 13516 * with two arguments: (arrVal, othVal). 13517 * 13518 * @static 13519 * @memberOf _ 13520 * @since 4.0.0 13521 * @category Array 13522 * @param {Array} array The array to inspect. 13523 * @param {Function} [comparator] The comparator invoked per element. 13524 * @returns {Array} Returns the new duplicate free array. 13525 * @example 13526 * 13527 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; 13528 * 13529 * _.uniqWith(objects, _.isEqual); 13530 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] 13531 */ 13532 function uniqWith(array, comparator) { 13533 comparator = typeof comparator == 'function' ? comparator : undefined; 13534 return (array && array.length) ? baseUniq(array, undefined, comparator) : []; 13535 } 13536 13537 /** 13538 * This method is like `_.zip` except that it accepts an array of grouped 13539 * elements and creates an array regrouping the elements to their pre-zip 13540 * configuration. 13541 * 13542 * @static 13543 * @memberOf _ 13544 * @since 1.2.0 13545 * @category Array 13546 * @param {Array} array The array of grouped elements to process. 13547 * @returns {Array} Returns the new array of regrouped elements. 13548 * @example 13549 * 13550 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); 13551 * // => [['a', 1, true], ['b', 2, false]] 13552 * 13553 * _.unzip(zipped); 13554 * // => [['a', 'b'], [1, 2], [true, false]] 13555 */ 13556 function unzip(array) { 13557 if (!(array && array.length)) { 13558 return []; 13559 } 13560 var length = 0; 13561 array = arrayFilter(array, function(group) { 13562 if (isArrayLikeObject(group)) { 13563 length = nativeMax(group.length, length); 13564 return true; 13565 } 13566 }); 13567 return baseTimes(length, function(index) { 13568 return arrayMap(array, baseProperty(index)); 13569 }); 13570 } 13571 13572 /** 13573 * This method is like `_.unzip` except that it accepts `iteratee` to specify 13574 * how regrouped values should be combined. The iteratee is invoked with the 13575 * elements of each group: (...group). 13576 * 13577 * @static 13578 * @memberOf _ 13579 * @since 3.8.0 13580 * @category Array 13581 * @param {Array} array The array of grouped elements to process. 13582 * @param {Function} [iteratee=_.identity] The function to combine 13583 * regrouped values. 13584 * @returns {Array} Returns the new array of regrouped elements. 13585 * @example 13586 * 13587 * var zipped = _.zip([1, 2], [10, 20], [100, 200]); 13588 * // => [[1, 10, 100], [2, 20, 200]] 13589 * 13590 * _.unzipWith(zipped, _.add); 13591 * // => [3, 30, 300] 13592 */ 13593 function unzipWith(array, iteratee) { 13594 if (!(array && array.length)) { 13595 return []; 13596 } 13597 var result = unzip(array); 13598 if (iteratee == null) { 13599 return result; 13600 } 13601 return arrayMap(result, function(group) { 13602 return apply(iteratee, undefined, group); 13603 }); 13604 } 13605 13606 /** 13607 * Creates an array excluding all given values using 13608 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 13609 * for equality comparisons. 13610 * 13611 * **Note:** Unlike `_.pull`, this method returns a new array. 13612 * 13613 * @static 13614 * @memberOf _ 13615 * @since 0.1.0 13616 * @category Array 13617 * @param {Array} array The array to inspect. 13618 * @param {...*} [values] The values to exclude. 13619 * @returns {Array} Returns the new array of filtered values. 13620 * @see _.difference, _.xor 13621 * @example 13622 * 13623 * _.without([2, 1, 2, 3], 1, 2); 13624 * // => [3] 13625 */ 13626 var without = baseRest(function(array, values) { 13627 return isArrayLikeObject(array) 13628 ? baseDifference(array, values) 13629 : []; 13630 }); 13631 13632 /** 13633 * Creates an array of unique values that is the 13634 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) 13635 * of the given arrays. The order of result values is determined by the order 13636 * they occur in the arrays. 13637 * 13638 * @static 13639 * @memberOf _ 13640 * @since 2.4.0 13641 * @category Array 13642 * @param {...Array} [arrays] The arrays to inspect. 13643 * @returns {Array} Returns the new array of filtered values. 13644 * @see _.difference, _.without 13645 * @example 13646 * 13647 * _.xor([2, 1], [2, 3]); 13648 * // => [1, 3] 13649 */ 13650 var xor = baseRest(function(arrays) { 13651 return baseXor(arrayFilter(arrays, isArrayLikeObject)); 13652 }); 13653 13654 /** 13655 * This method is like `_.xor` except that it accepts `iteratee` which is 13656 * invoked for each element of each `arrays` to generate the criterion by 13657 * which by which they're compared. The order of result values is determined 13658 * by the order they occur in the arrays. The iteratee is invoked with one 13659 * argument: (value). 13660 * 13661 * @static 13662 * @memberOf _ 13663 * @since 4.0.0 13664 * @category Array 13665 * @param {...Array} [arrays] The arrays to inspect. 13666 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13667 * @returns {Array} Returns the new array of filtered values. 13668 * @example 13669 * 13670 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); 13671 * // => [1.2, 3.4] 13672 * 13673 * // The `_.property` iteratee shorthand. 13674 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 13675 * // => [{ 'x': 2 }] 13676 */ 13677 var xorBy = baseRest(function(arrays) { 13678 var iteratee = last(arrays); 13679 if (isArrayLikeObject(iteratee)) { 13680 iteratee = undefined; 13681 } 13682 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); 13683 }); 13684 13685 /** 13686 * This method is like `_.xor` except that it accepts `comparator` which is 13687 * invoked to compare elements of `arrays`. The order of result values is 13688 * determined by the order they occur in the arrays. The comparator is invoked 13689 * with two arguments: (arrVal, othVal). 13690 * 13691 * @static 13692 * @memberOf _ 13693 * @since 4.0.0 13694 * @category Array 13695 * @param {...Array} [arrays] The arrays to inspect. 13696 * @param {Function} [comparator] The comparator invoked per element. 13697 * @returns {Array} Returns the new array of filtered values. 13698 * @example 13699 * 13700 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 13701 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 13702 * 13703 * _.xorWith(objects, others, _.isEqual); 13704 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 13705 */ 13706 var xorWith = baseRest(function(arrays) { 13707 var comparator = last(arrays); 13708 comparator = typeof comparator == 'function' ? comparator : undefined; 13709 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); 13710 }); 13711 13712 /** 13713 * Creates an array of grouped elements, the first of which contains the 13714 * first elements of the given arrays, the second of which contains the 13715 * second elements of the given arrays, and so on. 13716 * 13717 * @static 13718 * @memberOf _ 13719 * @since 0.1.0 13720 * @category Array 13721 * @param {...Array} [arrays] The arrays to process. 13722 * @returns {Array} Returns the new array of grouped elements. 13723 * @example 13724 * 13725 * _.zip(['a', 'b'], [1, 2], [true, false]); 13726 * // => [['a', 1, true], ['b', 2, false]] 13727 */ 13728 var zip = baseRest(unzip); 13729 13730 /** 13731 * This method is like `_.fromPairs` except that it accepts two arrays, 13732 * one of property identifiers and one of corresponding values. 13733 * 13734 * @static 13735 * @memberOf _ 13736 * @since 0.4.0 13737 * @category Array 13738 * @param {Array} [props=[]] The property identifiers. 13739 * @param {Array} [values=[]] The property values. 13740 * @returns {Object} Returns the new object. 13741 * @example 13742 * 13743 * _.zipObject(['a', 'b'], [1, 2]); 13744 * // => { 'a': 1, 'b': 2 } 13745 */ 13746 function zipObject(props, values) { 13747 return baseZipObject(props || [], values || [], assignValue); 13748 } 13749 13750 /** 13751 * This method is like `_.zipObject` except that it supports property paths. 13752 * 13753 * @static 13754 * @memberOf _ 13755 * @since 4.1.0 13756 * @category Array 13757 * @param {Array} [props=[]] The property identifiers. 13758 * @param {Array} [values=[]] The property values. 13759 * @returns {Object} Returns the new object. 13760 * @example 13761 * 13762 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); 13763 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } 13764 */ 13765 function zipObjectDeep(props, values) { 13766 return baseZipObject(props || [], values || [], baseSet); 13767 } 13768 13769 /** 13770 * This method is like `_.zip` except that it accepts `iteratee` to specify 13771 * how grouped values should be combined. The iteratee is invoked with the 13772 * elements of each group: (...group). 13773 * 13774 * @static 13775 * @memberOf _ 13776 * @since 3.8.0 13777 * @category Array 13778 * @param {...Array} [arrays] The arrays to process. 13779 * @param {Function} [iteratee=_.identity] The function to combine 13780 * grouped values. 13781 * @returns {Array} Returns the new array of grouped elements. 13782 * @example 13783 * 13784 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { 13785 * return a + b + c; 13786 * }); 13787 * // => [111, 222] 13788 */ 13789 var zipWith = baseRest(function(arrays) { 13790 var length = arrays.length, 13791 iteratee = length > 1 ? arrays[length - 1] : undefined; 13792 13793 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; 13794 return unzipWith(arrays, iteratee); 13795 }); 13796 13797 /*------------------------------------------------------------------------*/ 13798 13799 /** 13800 * Creates a `lodash` wrapper instance that wraps `value` with explicit method 13801 * chain sequences enabled. The result of such sequences must be unwrapped 13802 * with `_#value`. 13803 * 13804 * @static 13805 * @memberOf _ 13806 * @since 1.3.0 13807 * @category Seq 13808 * @param {*} value The value to wrap. 13809 * @returns {Object} Returns the new `lodash` wrapper instance. 13810 * @example 13811 * 13812 * var users = [ 13813 * { 'user': 'barney', 'age': 36 }, 13814 * { 'user': 'fred', 'age': 40 }, 13815 * { 'user': 'pebbles', 'age': 1 } 13816 * ]; 13817 * 13818 * var youngest = _ 13819 * .chain(users) 13820 * .sortBy('age') 13821 * .map(function(o) { 13822 * return o.user + ' is ' + o.age; 13823 * }) 13824 * .head() 13825 * .value(); 13826 * // => 'pebbles is 1' 13827 */ 13828 function chain(value) { 13829 var result = lodash(value); 13830 result.__chain__ = true; 13831 return result; 13832 } 13833 13834 /** 13835 * This method invokes `interceptor` and returns `value`. The interceptor 13836 * is invoked with one argument; (value). The purpose of this method is to 13837 * "tap into" a method chain sequence in order to modify intermediate results. 13838 * 13839 * @static 13840 * @memberOf _ 13841 * @since 0.1.0 13842 * @category Seq 13843 * @param {*} value The value to provide to `interceptor`. 13844 * @param {Function} interceptor The function to invoke. 13845 * @returns {*} Returns `value`. 13846 * @example 13847 * 13848 * _([1, 2, 3]) 13849 * .tap(function(array) { 13850 * // Mutate input array. 13851 * array.pop(); 13852 * }) 13853 * .reverse() 13854 * .value(); 13855 * // => [2, 1] 13856 */ 13857 function tap(value, interceptor) { 13858 interceptor(value); 13859 return value; 13860 } 13861 13862 /** 13863 * This method is like `_.tap` except that it returns the result of `interceptor`. 13864 * The purpose of this method is to "pass thru" values replacing intermediate 13865 * results in a method chain sequence. 13866 * 13867 * @static 13868 * @memberOf _ 13869 * @since 3.0.0 13870 * @category Seq 13871 * @param {*} value The value to provide to `interceptor`. 13872 * @param {Function} interceptor The function to invoke. 13873 * @returns {*} Returns the result of `interceptor`. 13874 * @example 13875 * 13876 * _(' abc ') 13877 * .chain() 13878 * .trim() 13879 * .thru(function(value) { 13880 * return [value]; 13881 * }) 13882 * .value(); 13883 * // => ['abc'] 13884 */ 13885 function thru(value, interceptor) { 13886 return interceptor(value); 13887 } 13888 13889 /** 13890 * This method is the wrapper version of `_.at`. 13891 * 13892 * @name at 13893 * @memberOf _ 13894 * @since 1.0.0 13895 * @category Seq 13896 * @param {...(string|string[])} [paths] The property paths to pick. 13897 * @returns {Object} Returns the new `lodash` wrapper instance. 13898 * @example 13899 * 13900 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 13901 * 13902 * _(object).at(['a[0].b.c', 'a[1]']).value(); 13903 * // => [3, 4] 13904 */ 13905 var wrapperAt = flatRest(function(paths) { 13906 var length = paths.length, 13907 start = length ? paths[0] : 0, 13908 value = this.__wrapped__, 13909 interceptor = function(object) { return baseAt(object, paths); }; 13910 13911 if (length > 1 || this.__actions__.length || 13912 !(value instanceof LazyWrapper) || !isIndex(start)) { 13913 return this.thru(interceptor); 13914 } 13915 value = value.slice(start, +start + (length ? 1 : 0)); 13916 value.__actions__.push({ 13917 'func': thru, 13918 'args': [interceptor], 13919 'thisArg': undefined 13920 }); 13921 return new LodashWrapper(value, this.__chain__).thru(function(array) { 13922 if (length && !array.length) { 13923 array.push(undefined); 13924 } 13925 return array; 13926 }); 13927 }); 13928 13929 /** 13930 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. 13931 * 13932 * @name chain 13933 * @memberOf _ 13934 * @since 0.1.0 13935 * @category Seq 13936 * @returns {Object} Returns the new `lodash` wrapper instance. 13937 * @example 13938 * 13939 * var users = [ 13940 * { 'user': 'barney', 'age': 36 }, 13941 * { 'user': 'fred', 'age': 40 } 13942 * ]; 13943 * 13944 * // A sequence without explicit chaining. 13945 * _(users).head(); 13946 * // => { 'user': 'barney', 'age': 36 } 13947 * 13948 * // A sequence with explicit chaining. 13949 * _(users) 13950 * .chain() 13951 * .head() 13952 * .pick('user') 13953 * .value(); 13954 * // => { 'user': 'barney' } 13955 */ 13956 function wrapperChain() { 13957 return chain(this); 13958 } 13959 13960 /** 13961 * Executes the chain sequence and returns the wrapped result. 13962 * 13963 * @name commit 13964 * @memberOf _ 13965 * @since 3.2.0 13966 * @category Seq 13967 * @returns {Object} Returns the new `lodash` wrapper instance. 13968 * @example 13969 * 13970 * var array = [1, 2]; 13971 * var wrapped = _(array).push(3); 13972 * 13973 * console.log(array); 13974 * // => [1, 2] 13975 * 13976 * wrapped = wrapped.commit(); 13977 * console.log(array); 13978 * // => [1, 2, 3] 13979 * 13980 * wrapped.last(); 13981 * // => 3 13982 * 13983 * console.log(array); 13984 * // => [1, 2, 3] 13985 */ 13986 function wrapperCommit() { 13987 return new LodashWrapper(this.value(), this.__chain__); 13988 } 13989 13990 /** 13991 * Gets the next value on a wrapped object following the 13992 * [iterator protocol](https://mdn.io/iteration_protocols#iterator). 13993 * 13994 * @name next 13995 * @memberOf _ 13996 * @since 4.0.0 13997 * @category Seq 13998 * @returns {Object} Returns the next iterator value. 13999 * @example 14000 * 14001 * var wrapped = _([1, 2]); 14002 * 14003 * wrapped.next(); 14004 * // => { 'done': false, 'value': 1 } 14005 * 14006 * wrapped.next(); 14007 * // => { 'done': false, 'value': 2 } 14008 * 14009 * wrapped.next(); 14010 * // => { 'done': true, 'value': undefined } 14011 */ 14012 function wrapperNext() { 14013 if (this.__values__ === undefined) { 14014 this.__values__ = toArray(this.value()); 14015 } 14016 var done = this.__index__ >= this.__values__.length, 14017 value = done ? undefined : this.__values__[this.__index__++]; 14018 14019 return { 'done': done, 'value': value }; 14020 } 14021 14022 /** 14023 * Enables the wrapper to be iterable. 14024 * 14025 * @name Symbol.iterator 14026 * @memberOf _ 14027 * @since 4.0.0 14028 * @category Seq 14029 * @returns {Object} Returns the wrapper object. 14030 * @example 14031 * 14032 * var wrapped = _([1, 2]); 14033 * 14034 * wrapped[Symbol.iterator]() === wrapped; 14035 * // => true 14036 * 14037 * Array.from(wrapped); 14038 * // => [1, 2] 14039 */ 14040 function wrapperToIterator() { 14041 return this; 14042 } 14043 14044 /** 14045 * Creates a clone of the chain sequence planting `value` as the wrapped value. 14046 * 14047 * @name plant 14048 * @memberOf _ 14049 * @since 3.2.0 14050 * @category Seq 14051 * @param {*} value The value to plant. 14052 * @returns {Object} Returns the new `lodash` wrapper instance. 14053 * @example 14054 * 14055 * function square(n) { 14056 * return n * n; 14057 * } 14058 * 14059 * var wrapped = _([1, 2]).map(square); 14060 * var other = wrapped.plant([3, 4]); 14061 * 14062 * other.value(); 14063 * // => [9, 16] 14064 * 14065 * wrapped.value(); 14066 * // => [1, 4] 14067 */ 14068 function wrapperPlant(value) { 14069 var result, 14070 parent = this; 14071 14072 while (parent instanceof baseLodash) { 14073 var clone = wrapperClone(parent); 14074 clone.__index__ = 0; 14075 clone.__values__ = undefined; 14076 if (result) { 14077 previous.__wrapped__ = clone; 14078 } else { 14079 result = clone; 14080 } 14081 var previous = clone; 14082 parent = parent.__wrapped__; 14083 } 14084 previous.__wrapped__ = value; 14085 return result; 14086 } 14087 14088 /** 14089 * This method is the wrapper version of `_.reverse`. 14090 * 14091 * **Note:** This method mutates the wrapped array. 14092 * 14093 * @name reverse 14094 * @memberOf _ 14095 * @since 0.1.0 14096 * @category Seq 14097 * @returns {Object} Returns the new `lodash` wrapper instance. 14098 * @example 14099 * 14100 * var array = [1, 2, 3]; 14101 * 14102 * _(array).reverse().value() 14103 * // => [3, 2, 1] 14104 * 14105 * console.log(array); 14106 * // => [3, 2, 1] 14107 */ 14108 function wrapperReverse() { 14109 var value = this.__wrapped__; 14110 if (value instanceof LazyWrapper) { 14111 var wrapped = value; 14112 if (this.__actions__.length) { 14113 wrapped = new LazyWrapper(this); 14114 } 14115 wrapped = wrapped.reverse(); 14116 wrapped.__actions__.push({ 14117 'func': thru, 14118 'args': [reverse], 14119 'thisArg': undefined 14120 }); 14121 return new LodashWrapper(wrapped, this.__chain__); 14122 } 14123 return this.thru(reverse); 14124 } 14125 14126 /** 14127 * Executes the chain sequence to resolve the unwrapped value. 14128 * 14129 * @name value 14130 * @memberOf _ 14131 * @since 0.1.0 14132 * @alias toJSON, valueOf 14133 * @category Seq 14134 * @returns {*} Returns the resolved unwrapped value. 14135 * @example 14136 * 14137 * _([1, 2, 3]).value(); 14138 * // => [1, 2, 3] 14139 */ 14140 function wrapperValue() { 14141 return baseWrapperValue(this.__wrapped__, this.__actions__); 14142 } 14143 14144 /*------------------------------------------------------------------------*/ 14145 14146 /** 14147 * Creates an object composed of keys generated from the results of running 14148 * each element of `collection` thru `iteratee`. The corresponding value of 14149 * each key is the number of times the key was returned by `iteratee`. The 14150 * iteratee is invoked with one argument: (value). 14151 * 14152 * @static 14153 * @memberOf _ 14154 * @since 0.5.0 14155 * @category Collection 14156 * @param {Array|Object} collection The collection to iterate over. 14157 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 14158 * @returns {Object} Returns the composed aggregate object. 14159 * @example 14160 * 14161 * _.countBy([6.1, 4.2, 6.3], Math.floor); 14162 * // => { '4': 1, '6': 2 } 14163 * 14164 * // The `_.property` iteratee shorthand. 14165 * _.countBy(['one', 'two', 'three'], 'length'); 14166 * // => { '3': 2, '5': 1 } 14167 */ 14168 var countBy = createAggregator(function(result, value, key) { 14169 if (hasOwnProperty.call(result, key)) { 14170 ++result[key]; 14171 } else { 14172 baseAssignValue(result, key, 1); 14173 } 14174 }); 14175 14176 /** 14177 * Checks if `predicate` returns truthy for **all** elements of `collection`. 14178 * Iteration is stopped once `predicate` returns falsey. The predicate is 14179 * invoked with three arguments: (value, index|key, collection). 14180 * 14181 * **Note:** This method returns `true` for 14182 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because 14183 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of 14184 * elements of empty collections. 14185 * 14186 * @static 14187 * @memberOf _ 14188 * @since 0.1.0 14189 * @category Collection 14190 * @param {Array|Object} collection The collection to iterate over. 14191 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14192 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14193 * @returns {boolean} Returns `true` if all elements pass the predicate check, 14194 * else `false`. 14195 * @example 14196 * 14197 * _.every([true, 1, null, 'yes'], Boolean); 14198 * // => false 14199 * 14200 * var users = [ 14201 * { 'user': 'barney', 'age': 36, 'active': false }, 14202 * { 'user': 'fred', 'age': 40, 'active': false } 14203 * ]; 14204 * 14205 * // The `_.matches` iteratee shorthand. 14206 * _.every(users, { 'user': 'barney', 'active': false }); 14207 * // => false 14208 * 14209 * // The `_.matchesProperty` iteratee shorthand. 14210 * _.every(users, ['active', false]); 14211 * // => true 14212 * 14213 * // The `_.property` iteratee shorthand. 14214 * _.every(users, 'active'); 14215 * // => false 14216 */ 14217 function every(collection, predicate, guard) { 14218 var func = isArray(collection) ? arrayEvery : baseEvery; 14219 if (guard && isIterateeCall(collection, predicate, guard)) { 14220 predicate = undefined; 14221 } 14222 return func(collection, getIteratee(predicate, 3)); 14223 } 14224 14225 /** 14226 * Iterates over elements of `collection`, returning an array of all elements 14227 * `predicate` returns truthy for. The predicate is invoked with three 14228 * arguments: (value, index|key, collection). 14229 * 14230 * **Note:** Unlike `_.remove`, this method returns a new array. 14231 * 14232 * @static 14233 * @memberOf _ 14234 * @since 0.1.0 14235 * @category Collection 14236 * @param {Array|Object} collection The collection to iterate over. 14237 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14238 * @returns {Array} Returns the new filtered array. 14239 * @see _.reject 14240 * @example 14241 * 14242 * var users = [ 14243 * { 'user': 'barney', 'age': 36, 'active': true }, 14244 * { 'user': 'fred', 'age': 40, 'active': false } 14245 * ]; 14246 * 14247 * _.filter(users, function(o) { return !o.active; }); 14248 * // => objects for ['fred'] 14249 * 14250 * // The `_.matches` iteratee shorthand. 14251 * _.filter(users, { 'age': 36, 'active': true }); 14252 * // => objects for ['barney'] 14253 * 14254 * // The `_.matchesProperty` iteratee shorthand. 14255 * _.filter(users, ['active', false]); 14256 * // => objects for ['fred'] 14257 * 14258 * // The `_.property` iteratee shorthand. 14259 * _.filter(users, 'active'); 14260 * // => objects for ['barney'] 14261 * 14262 * // Combining several predicates using `_.overEvery` or `_.overSome`. 14263 * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); 14264 * // => objects for ['fred', 'barney'] 14265 */ 14266 function filter(collection, predicate) { 14267 var func = isArray(collection) ? arrayFilter : baseFilter; 14268 return func(collection, getIteratee(predicate, 3)); 14269 } 14270 14271 /** 14272 * Iterates over elements of `collection`, returning the first element 14273 * `predicate` returns truthy for. The predicate is invoked with three 14274 * arguments: (value, index|key, collection). 14275 * 14276 * @static 14277 * @memberOf _ 14278 * @since 0.1.0 14279 * @category Collection 14280 * @param {Array|Object} collection The collection to inspect. 14281 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14282 * @param {number} [fromIndex=0] The index to search from. 14283 * @returns {*} Returns the matched element, else `undefined`. 14284 * @example 14285 * 14286 * var users = [ 14287 * { 'user': 'barney', 'age': 36, 'active': true }, 14288 * { 'user': 'fred', 'age': 40, 'active': false }, 14289 * { 'user': 'pebbles', 'age': 1, 'active': true } 14290 * ]; 14291 * 14292 * _.find(users, function(o) { return o.age < 40; }); 14293 * // => object for 'barney' 14294 * 14295 * // The `_.matches` iteratee shorthand. 14296 * _.find(users, { 'age': 1, 'active': true }); 14297 * // => object for 'pebbles' 14298 * 14299 * // The `_.matchesProperty` iteratee shorthand. 14300 * _.find(users, ['active', false]); 14301 * // => object for 'fred' 14302 * 14303 * // The `_.property` iteratee shorthand. 14304 * _.find(users, 'active'); 14305 * // => object for 'barney' 14306 */ 14307 var find = createFind(findIndex); 14308 14309 /** 14310 * This method is like `_.find` except that it iterates over elements of 14311 * `collection` from right to left. 14312 * 14313 * @static 14314 * @memberOf _ 14315 * @since 2.0.0 14316 * @category Collection 14317 * @param {Array|Object} collection The collection to inspect. 14318 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14319 * @param {number} [fromIndex=collection.length-1] The index to search from. 14320 * @returns {*} Returns the matched element, else `undefined`. 14321 * @example 14322 * 14323 * _.findLast([1, 2, 3, 4], function(n) { 14324 * return n % 2 == 1; 14325 * }); 14326 * // => 3 14327 */ 14328 var findLast = createFind(findLastIndex); 14329 14330 /** 14331 * Creates a flattened array of values by running each element in `collection` 14332 * thru `iteratee` and flattening the mapped results. The iteratee is invoked 14333 * with three arguments: (value, index|key, collection). 14334 * 14335 * @static 14336 * @memberOf _ 14337 * @since 4.0.0 14338 * @category Collection 14339 * @param {Array|Object} collection The collection to iterate over. 14340 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14341 * @returns {Array} Returns the new flattened array. 14342 * @example 14343 * 14344 * function duplicate(n) { 14345 * return [n, n]; 14346 * } 14347 * 14348 * _.flatMap([1, 2], duplicate); 14349 * // => [1, 1, 2, 2] 14350 */ 14351 function flatMap(collection, iteratee) { 14352 return baseFlatten(map(collection, iteratee), 1); 14353 } 14354 14355 /** 14356 * This method is like `_.flatMap` except that it recursively flattens the 14357 * mapped results. 14358 * 14359 * @static 14360 * @memberOf _ 14361 * @since 4.7.0 14362 * @category Collection 14363 * @param {Array|Object} collection The collection to iterate over. 14364 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14365 * @returns {Array} Returns the new flattened array. 14366 * @example 14367 * 14368 * function duplicate(n) { 14369 * return [[[n, n]]]; 14370 * } 14371 * 14372 * _.flatMapDeep([1, 2], duplicate); 14373 * // => [1, 1, 2, 2] 14374 */ 14375 function flatMapDeep(collection, iteratee) { 14376 return baseFlatten(map(collection, iteratee), INFINITY); 14377 } 14378 14379 /** 14380 * This method is like `_.flatMap` except that it recursively flattens the 14381 * mapped results up to `depth` times. 14382 * 14383 * @static 14384 * @memberOf _ 14385 * @since 4.7.0 14386 * @category Collection 14387 * @param {Array|Object} collection The collection to iterate over. 14388 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14389 * @param {number} [depth=1] The maximum recursion depth. 14390 * @returns {Array} Returns the new flattened array. 14391 * @example 14392 * 14393 * function duplicate(n) { 14394 * return [[[n, n]]]; 14395 * } 14396 * 14397 * _.flatMapDepth([1, 2], duplicate, 2); 14398 * // => [[1, 1], [2, 2]] 14399 */ 14400 function flatMapDepth(collection, iteratee, depth) { 14401 depth = depth === undefined ? 1 : toInteger(depth); 14402 return baseFlatten(map(collection, iteratee), depth); 14403 } 14404 14405 /** 14406 * Iterates over elements of `collection` and invokes `iteratee` for each element. 14407 * The iteratee is invoked with three arguments: (value, index|key, collection). 14408 * Iteratee functions may exit iteration early by explicitly returning `false`. 14409 * 14410 * **Note:** As with other "Collections" methods, objects with a "length" 14411 * property are iterated like arrays. To avoid this behavior use `_.forIn` 14412 * or `_.forOwn` for object iteration. 14413 * 14414 * @static 14415 * @memberOf _ 14416 * @since 0.1.0 14417 * @alias each 14418 * @category Collection 14419 * @param {Array|Object} collection The collection to iterate over. 14420 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14421 * @returns {Array|Object} Returns `collection`. 14422 * @see _.forEachRight 14423 * @example 14424 * 14425 * _.forEach([1, 2], function(value) { 14426 * console.log(value); 14427 * }); 14428 * // => Logs `1` then `2`. 14429 * 14430 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 14431 * console.log(key); 14432 * }); 14433 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 14434 */ 14435 function forEach(collection, iteratee) { 14436 var func = isArray(collection) ? arrayEach : baseEach; 14437 return func(collection, getIteratee(iteratee, 3)); 14438 } 14439 14440 /** 14441 * This method is like `_.forEach` except that it iterates over elements of 14442 * `collection` from right to left. 14443 * 14444 * @static 14445 * @memberOf _ 14446 * @since 2.0.0 14447 * @alias eachRight 14448 * @category Collection 14449 * @param {Array|Object} collection The collection to iterate over. 14450 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14451 * @returns {Array|Object} Returns `collection`. 14452 * @see _.forEach 14453 * @example 14454 * 14455 * _.forEachRight([1, 2], function(value) { 14456 * console.log(value); 14457 * }); 14458 * // => Logs `2` then `1`. 14459 */ 14460 function forEachRight(collection, iteratee) { 14461 var func = isArray(collection) ? arrayEachRight : baseEachRight; 14462 return func(collection, getIteratee(iteratee, 3)); 14463 } 14464 14465 /** 14466 * Creates an object composed of keys generated from the results of running 14467 * each element of `collection` thru `iteratee`. The order of grouped values 14468 * is determined by the order they occur in `collection`. The corresponding 14469 * value of each key is an array of elements responsible for generating the 14470 * key. The iteratee is invoked with one argument: (value). 14471 * 14472 * @static 14473 * @memberOf _ 14474 * @since 0.1.0 14475 * @category Collection 14476 * @param {Array|Object} collection The collection to iterate over. 14477 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 14478 * @returns {Object} Returns the composed aggregate object. 14479 * @example 14480 * 14481 * _.groupBy([6.1, 4.2, 6.3], Math.floor); 14482 * // => { '4': [4.2], '6': [6.1, 6.3] } 14483 * 14484 * // The `_.property` iteratee shorthand. 14485 * _.groupBy(['one', 'two', 'three'], 'length'); 14486 * // => { '3': ['one', 'two'], '5': ['three'] } 14487 */ 14488 var groupBy = createAggregator(function(result, value, key) { 14489 if (hasOwnProperty.call(result, key)) { 14490 result[key].push(value); 14491 } else { 14492 baseAssignValue(result, key, [value]); 14493 } 14494 }); 14495 14496 /** 14497 * Checks if `value` is in `collection`. If `collection` is a string, it's 14498 * checked for a substring of `value`, otherwise 14499 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 14500 * is used for equality comparisons. If `fromIndex` is negative, it's used as 14501 * the offset from the end of `collection`. 14502 * 14503 * @static 14504 * @memberOf _ 14505 * @since 0.1.0 14506 * @category Collection 14507 * @param {Array|Object|string} collection The collection to inspect. 14508 * @param {*} value The value to search for. 14509 * @param {number} [fromIndex=0] The index to search from. 14510 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 14511 * @returns {boolean} Returns `true` if `value` is found, else `false`. 14512 * @example 14513 * 14514 * _.includes([1, 2, 3], 1); 14515 * // => true 14516 * 14517 * _.includes([1, 2, 3], 1, 2); 14518 * // => false 14519 * 14520 * _.includes({ 'a': 1, 'b': 2 }, 1); 14521 * // => true 14522 * 14523 * _.includes('abcd', 'bc'); 14524 * // => true 14525 */ 14526 function includes(collection, value, fromIndex, guard) { 14527 collection = isArrayLike(collection) ? collection : values(collection); 14528 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; 14529 14530 var length = collection.length; 14531 if (fromIndex < 0) { 14532 fromIndex = nativeMax(length + fromIndex, 0); 14533 } 14534 return isString(collection) 14535 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) 14536 : (!!length && baseIndexOf(collection, value, fromIndex) > -1); 14537 } 14538 14539 /** 14540 * Invokes the method at `path` of each element in `collection`, returning 14541 * an array of the results of each invoked method. Any additional arguments 14542 * are provided to each invoked method. If `path` is a function, it's invoked 14543 * for, and `this` bound to, each element in `collection`. 14544 * 14545 * @static 14546 * @memberOf _ 14547 * @since 4.0.0 14548 * @category Collection 14549 * @param {Array|Object} collection The collection to iterate over. 14550 * @param {Array|Function|string} path The path of the method to invoke or 14551 * the function invoked per iteration. 14552 * @param {...*} [args] The arguments to invoke each method with. 14553 * @returns {Array} Returns the array of results. 14554 * @example 14555 * 14556 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); 14557 * // => [[1, 5, 7], [1, 2, 3]] 14558 * 14559 * _.invokeMap([123, 456], String.prototype.split, ''); 14560 * // => [['1', '2', '3'], ['4', '5', '6']] 14561 */ 14562 var invokeMap = baseRest(function(collection, path, args) { 14563 var index = -1, 14564 isFunc = typeof path == 'function', 14565 result = isArrayLike(collection) ? Array(collection.length) : []; 14566 14567 baseEach(collection, function(value) { 14568 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); 14569 }); 14570 return result; 14571 }); 14572 14573 /** 14574 * Creates an object composed of keys generated from the results of running 14575 * each element of `collection` thru `iteratee`. The corresponding value of 14576 * each key is the last element responsible for generating the key. The 14577 * iteratee is invoked with one argument: (value). 14578 * 14579 * @static 14580 * @memberOf _ 14581 * @since 4.0.0 14582 * @category Collection 14583 * @param {Array|Object} collection The collection to iterate over. 14584 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 14585 * @returns {Object} Returns the composed aggregate object. 14586 * @example 14587 * 14588 * var array = [ 14589 * { 'dir': 'left', 'code': 97 }, 14590 * { 'dir': 'right', 'code': 100 } 14591 * ]; 14592 * 14593 * _.keyBy(array, function(o) { 14594 * return String.fromCharCode(o.code); 14595 * }); 14596 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } 14597 * 14598 * _.keyBy(array, 'dir'); 14599 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } 14600 */ 14601 var keyBy = createAggregator(function(result, value, key) { 14602 baseAssignValue(result, key, value); 14603 }); 14604 14605 /** 14606 * Creates an array of values by running each element in `collection` thru 14607 * `iteratee`. The iteratee is invoked with three arguments: 14608 * (value, index|key, collection). 14609 * 14610 * Many lodash methods are guarded to work as iteratees for methods like 14611 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. 14612 * 14613 * The guarded methods are: 14614 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, 14615 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, 14616 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, 14617 * `template`, `trim`, `trimEnd`, `trimStart`, and `words` 14618 * 14619 * @static 14620 * @memberOf _ 14621 * @since 0.1.0 14622 * @category Collection 14623 * @param {Array|Object} collection The collection to iterate over. 14624 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14625 * @returns {Array} Returns the new mapped array. 14626 * @example 14627 * 14628 * function square(n) { 14629 * return n * n; 14630 * } 14631 * 14632 * _.map([4, 8], square); 14633 * // => [16, 64] 14634 * 14635 * _.map({ 'a': 4, 'b': 8 }, square); 14636 * // => [16, 64] (iteration order is not guaranteed) 14637 * 14638 * var users = [ 14639 * { 'user': 'barney' }, 14640 * { 'user': 'fred' } 14641 * ]; 14642 * 14643 * // The `_.property` iteratee shorthand. 14644 * _.map(users, 'user'); 14645 * // => ['barney', 'fred'] 14646 */ 14647 function map(collection, iteratee) { 14648 var func = isArray(collection) ? arrayMap : baseMap; 14649 return func(collection, getIteratee(iteratee, 3)); 14650 } 14651 14652 /** 14653 * This method is like `_.sortBy` except that it allows specifying the sort 14654 * orders of the iteratees to sort by. If `orders` is unspecified, all values 14655 * are sorted in ascending order. Otherwise, specify an order of "desc" for 14656 * descending or "asc" for ascending sort order of corresponding values. 14657 * 14658 * @static 14659 * @memberOf _ 14660 * @since 4.0.0 14661 * @category Collection 14662 * @param {Array|Object} collection The collection to iterate over. 14663 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] 14664 * The iteratees to sort by. 14665 * @param {string[]} [orders] The sort orders of `iteratees`. 14666 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 14667 * @returns {Array} Returns the new sorted array. 14668 * @example 14669 * 14670 * var users = [ 14671 * { 'user': 'fred', 'age': 48 }, 14672 * { 'user': 'barney', 'age': 34 }, 14673 * { 'user': 'fred', 'age': 40 }, 14674 * { 'user': 'barney', 'age': 36 } 14675 * ]; 14676 * 14677 * // Sort by `user` in ascending order and by `age` in descending order. 14678 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); 14679 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 14680 */ 14681 function orderBy(collection, iteratees, orders, guard) { 14682 if (collection == null) { 14683 return []; 14684 } 14685 if (!isArray(iteratees)) { 14686 iteratees = iteratees == null ? [] : [iteratees]; 14687 } 14688 orders = guard ? undefined : orders; 14689 if (!isArray(orders)) { 14690 orders = orders == null ? [] : [orders]; 14691 } 14692 return baseOrderBy(collection, iteratees, orders); 14693 } 14694 14695 /** 14696 * Creates an array of elements split into two groups, the first of which 14697 * contains elements `predicate` returns truthy for, the second of which 14698 * contains elements `predicate` returns falsey for. The predicate is 14699 * invoked with one argument: (value). 14700 * 14701 * @static 14702 * @memberOf _ 14703 * @since 3.0.0 14704 * @category Collection 14705 * @param {Array|Object} collection The collection to iterate over. 14706 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14707 * @returns {Array} Returns the array of grouped elements. 14708 * @example 14709 * 14710 * var users = [ 14711 * { 'user': 'barney', 'age': 36, 'active': false }, 14712 * { 'user': 'fred', 'age': 40, 'active': true }, 14713 * { 'user': 'pebbles', 'age': 1, 'active': false } 14714 * ]; 14715 * 14716 * _.partition(users, function(o) { return o.active; }); 14717 * // => objects for [['fred'], ['barney', 'pebbles']] 14718 * 14719 * // The `_.matches` iteratee shorthand. 14720 * _.partition(users, { 'age': 1, 'active': false }); 14721 * // => objects for [['pebbles'], ['barney', 'fred']] 14722 * 14723 * // The `_.matchesProperty` iteratee shorthand. 14724 * _.partition(users, ['active', false]); 14725 * // => objects for [['barney', 'pebbles'], ['fred']] 14726 * 14727 * // The `_.property` iteratee shorthand. 14728 * _.partition(users, 'active'); 14729 * // => objects for [['fred'], ['barney', 'pebbles']] 14730 */ 14731 var partition = createAggregator(function(result, value, key) { 14732 result[key ? 0 : 1].push(value); 14733 }, function() { return [[], []]; }); 14734 14735 /** 14736 * Reduces `collection` to a value which is the accumulated result of running 14737 * each element in `collection` thru `iteratee`, where each successive 14738 * invocation is supplied the return value of the previous. If `accumulator` 14739 * is not given, the first element of `collection` is used as the initial 14740 * value. The iteratee is invoked with four arguments: 14741 * (accumulator, value, index|key, collection). 14742 * 14743 * Many lodash methods are guarded to work as iteratees for methods like 14744 * `_.reduce`, `_.reduceRight`, and `_.transform`. 14745 * 14746 * The guarded methods are: 14747 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, 14748 * and `sortBy` 14749 * 14750 * @static 14751 * @memberOf _ 14752 * @since 0.1.0 14753 * @category Collection 14754 * @param {Array|Object} collection The collection to iterate over. 14755 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14756 * @param {*} [accumulator] The initial value. 14757 * @returns {*} Returns the accumulated value. 14758 * @see _.reduceRight 14759 * @example 14760 * 14761 * _.reduce([1, 2], function(sum, n) { 14762 * return sum + n; 14763 * }, 0); 14764 * // => 3 14765 * 14766 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 14767 * (result[value] || (result[value] = [])).push(key); 14768 * return result; 14769 * }, {}); 14770 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) 14771 */ 14772 function reduce(collection, iteratee, accumulator) { 14773 var func = isArray(collection) ? arrayReduce : baseReduce, 14774 initAccum = arguments.length < 3; 14775 14776 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); 14777 } 14778 14779 /** 14780 * This method is like `_.reduce` except that it iterates over elements of 14781 * `collection` from right to left. 14782 * 14783 * @static 14784 * @memberOf _ 14785 * @since 0.1.0 14786 * @category Collection 14787 * @param {Array|Object} collection The collection to iterate over. 14788 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14789 * @param {*} [accumulator] The initial value. 14790 * @returns {*} Returns the accumulated value. 14791 * @see _.reduce 14792 * @example 14793 * 14794 * var array = [[0, 1], [2, 3], [4, 5]]; 14795 * 14796 * _.reduceRight(array, function(flattened, other) { 14797 * return flattened.concat(other); 14798 * }, []); 14799 * // => [4, 5, 2, 3, 0, 1] 14800 */ 14801 function reduceRight(collection, iteratee, accumulator) { 14802 var func = isArray(collection) ? arrayReduceRight : baseReduce, 14803 initAccum = arguments.length < 3; 14804 14805 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); 14806 } 14807 14808 /** 14809 * The opposite of `_.filter`; this method returns the elements of `collection` 14810 * that `predicate` does **not** return truthy for. 14811 * 14812 * @static 14813 * @memberOf _ 14814 * @since 0.1.0 14815 * @category Collection 14816 * @param {Array|Object} collection The collection to iterate over. 14817 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14818 * @returns {Array} Returns the new filtered array. 14819 * @see _.filter 14820 * @example 14821 * 14822 * var users = [ 14823 * { 'user': 'barney', 'age': 36, 'active': false }, 14824 * { 'user': 'fred', 'age': 40, 'active': true } 14825 * ]; 14826 * 14827 * _.reject(users, function(o) { return !o.active; }); 14828 * // => objects for ['fred'] 14829 * 14830 * // The `_.matches` iteratee shorthand. 14831 * _.reject(users, { 'age': 40, 'active': true }); 14832 * // => objects for ['barney'] 14833 * 14834 * // The `_.matchesProperty` iteratee shorthand. 14835 * _.reject(users, ['active', false]); 14836 * // => objects for ['fred'] 14837 * 14838 * // The `_.property` iteratee shorthand. 14839 * _.reject(users, 'active'); 14840 * // => objects for ['barney'] 14841 */ 14842 function reject(collection, predicate) { 14843 var func = isArray(collection) ? arrayFilter : baseFilter; 14844 return func(collection, negate(getIteratee(predicate, 3))); 14845 } 14846 14847 /** 14848 * Gets a random element from `collection`. 14849 * 14850 * @static 14851 * @memberOf _ 14852 * @since 2.0.0 14853 * @category Collection 14854 * @param {Array|Object} collection The collection to sample. 14855 * @returns {*} Returns the random element. 14856 * @example 14857 * 14858 * _.sample([1, 2, 3, 4]); 14859 * // => 2 14860 */ 14861 function sample(collection) { 14862 var func = isArray(collection) ? arraySample : baseSample; 14863 return func(collection); 14864 } 14865 14866 /** 14867 * Gets `n` random elements at unique keys from `collection` up to the 14868 * size of `collection`. 14869 * 14870 * @static 14871 * @memberOf _ 14872 * @since 4.0.0 14873 * @category Collection 14874 * @param {Array|Object} collection The collection to sample. 14875 * @param {number} [n=1] The number of elements to sample. 14876 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14877 * @returns {Array} Returns the random elements. 14878 * @example 14879 * 14880 * _.sampleSize([1, 2, 3], 2); 14881 * // => [3, 1] 14882 * 14883 * _.sampleSize([1, 2, 3], 4); 14884 * // => [2, 3, 1] 14885 */ 14886 function sampleSize(collection, n, guard) { 14887 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { 14888 n = 1; 14889 } else { 14890 n = toInteger(n); 14891 } 14892 var func = isArray(collection) ? arraySampleSize : baseSampleSize; 14893 return func(collection, n); 14894 } 14895 14896 /** 14897 * Creates an array of shuffled values, using a version of the 14898 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). 14899 * 14900 * @static 14901 * @memberOf _ 14902 * @since 0.1.0 14903 * @category Collection 14904 * @param {Array|Object} collection The collection to shuffle. 14905 * @returns {Array} Returns the new shuffled array. 14906 * @example 14907 * 14908 * _.shuffle([1, 2, 3, 4]); 14909 * // => [4, 1, 3, 2] 14910 */ 14911 function shuffle(collection) { 14912 var func = isArray(collection) ? arrayShuffle : baseShuffle; 14913 return func(collection); 14914 } 14915 14916 /** 14917 * Gets the size of `collection` by returning its length for array-like 14918 * values or the number of own enumerable string keyed properties for objects. 14919 * 14920 * @static 14921 * @memberOf _ 14922 * @since 0.1.0 14923 * @category Collection 14924 * @param {Array|Object|string} collection The collection to inspect. 14925 * @returns {number} Returns the collection size. 14926 * @example 14927 * 14928 * _.size([1, 2, 3]); 14929 * // => 3 14930 * 14931 * _.size({ 'a': 1, 'b': 2 }); 14932 * // => 2 14933 * 14934 * _.size('pebbles'); 14935 * // => 7 14936 */ 14937 function size(collection) { 14938 if (collection == null) { 14939 return 0; 14940 } 14941 if (isArrayLike(collection)) { 14942 return isString(collection) ? stringSize(collection) : collection.length; 14943 } 14944 var tag = getTag(collection); 14945 if (tag == mapTag || tag == setTag) { 14946 return collection.size; 14947 } 14948 return baseKeys(collection).length; 14949 } 14950 14951 /** 14952 * Checks if `predicate` returns truthy for **any** element of `collection`. 14953 * Iteration is stopped once `predicate` returns truthy. The predicate is 14954 * invoked with three arguments: (value, index|key, collection). 14955 * 14956 * @static 14957 * @memberOf _ 14958 * @since 0.1.0 14959 * @category Collection 14960 * @param {Array|Object} collection The collection to iterate over. 14961 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14962 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14963 * @returns {boolean} Returns `true` if any element passes the predicate check, 14964 * else `false`. 14965 * @example 14966 * 14967 * _.some([null, 0, 'yes', false], Boolean); 14968 * // => true 14969 * 14970 * var users = [ 14971 * { 'user': 'barney', 'active': true }, 14972 * { 'user': 'fred', 'active': false } 14973 * ]; 14974 * 14975 * // The `_.matches` iteratee shorthand. 14976 * _.some(users, { 'user': 'barney', 'active': false }); 14977 * // => false 14978 * 14979 * // The `_.matchesProperty` iteratee shorthand. 14980 * _.some(users, ['active', false]); 14981 * // => true 14982 * 14983 * // The `_.property` iteratee shorthand. 14984 * _.some(users, 'active'); 14985 * // => true 14986 */ 14987 function some(collection, predicate, guard) { 14988 var func = isArray(collection) ? arraySome : baseSome; 14989 if (guard && isIterateeCall(collection, predicate, guard)) { 14990 predicate = undefined; 14991 } 14992 return func(collection, getIteratee(predicate, 3)); 14993 } 14994 14995 /** 14996 * Creates an array of elements, sorted in ascending order by the results of 14997 * running each element in a collection thru each iteratee. This method 14998 * performs a stable sort, that is, it preserves the original sort order of 14999 * equal elements. The iteratees are invoked with one argument: (value). 15000 * 15001 * @static 15002 * @memberOf _ 15003 * @since 0.1.0 15004 * @category Collection 15005 * @param {Array|Object} collection The collection to iterate over. 15006 * @param {...(Function|Function[])} [iteratees=[_.identity]] 15007 * The iteratees to sort by. 15008 * @returns {Array} Returns the new sorted array. 15009 * @example 15010 * 15011 * var users = [ 15012 * { 'user': 'fred', 'age': 48 }, 15013 * { 'user': 'barney', 'age': 36 }, 15014 * { 'user': 'fred', 'age': 30 }, 15015 * { 'user': 'barney', 'age': 34 } 15016 * ]; 15017 * 15018 * _.sortBy(users, [function(o) { return o.user; }]); 15019 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] 15020 * 15021 * _.sortBy(users, ['user', 'age']); 15022 * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] 15023 */ 15024 var sortBy = baseRest(function(collection, iteratees) { 15025 if (collection == null) { 15026 return []; 15027 } 15028 var length = iteratees.length; 15029 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { 15030 iteratees = []; 15031 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { 15032 iteratees = [iteratees[0]]; 15033 } 15034 return baseOrderBy(collection, baseFlatten(iteratees, 1), []); 15035 }); 15036 15037 /*------------------------------------------------------------------------*/ 15038 15039 /** 15040 * Gets the timestamp of the number of milliseconds that have elapsed since 15041 * the Unix epoch (1 January 1970 00:00:00 UTC). 15042 * 15043 * @static 15044 * @memberOf _ 15045 * @since 2.4.0 15046 * @category Date 15047 * @returns {number} Returns the timestamp. 15048 * @example 15049 * 15050 * _.defer(function(stamp) { 15051 * console.log(_.now() - stamp); 15052 * }, _.now()); 15053 * // => Logs the number of milliseconds it took for the deferred invocation. 15054 */ 15055 var now = ctxNow || function() { 15056 return root.Date.now(); 15057 }; 15058 15059 /*------------------------------------------------------------------------*/ 15060 15061 /** 15062 * The opposite of `_.before`; this method creates a function that invokes 15063 * `func` once it's called `n` or more times. 15064 * 15065 * @static 15066 * @memberOf _ 15067 * @since 0.1.0 15068 * @category Function 15069 * @param {number} n The number of calls before `func` is invoked. 15070 * @param {Function} func The function to restrict. 15071 * @returns {Function} Returns the new restricted function. 15072 * @example 15073 * 15074 * var saves = ['profile', 'settings']; 15075 * 15076 * var done = _.after(saves.length, function() { 15077 * console.log('done saving!'); 15078 * }); 15079 * 15080 * _.forEach(saves, function(type) { 15081 * asyncSave({ 'type': type, 'complete': done }); 15082 * }); 15083 * // => Logs 'done saving!' after the two async saves have completed. 15084 */ 15085 function after(n, func) { 15086 if (typeof func != 'function') { 15087 throw new TypeError(FUNC_ERROR_TEXT); 15088 } 15089 n = toInteger(n); 15090 return function() { 15091 if (--n < 1) { 15092 return func.apply(this, arguments); 15093 } 15094 }; 15095 } 15096 15097 /** 15098 * Creates a function that invokes `func`, with up to `n` arguments, 15099 * ignoring any additional arguments. 15100 * 15101 * @static 15102 * @memberOf _ 15103 * @since 3.0.0 15104 * @category Function 15105 * @param {Function} func The function to cap arguments for. 15106 * @param {number} [n=func.length] The arity cap. 15107 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15108 * @returns {Function} Returns the new capped function. 15109 * @example 15110 * 15111 * _.map(['6', '8', '10'], _.ary(parseInt, 1)); 15112 * // => [6, 8, 10] 15113 */ 15114 function ary(func, n, guard) { 15115 n = guard ? undefined : n; 15116 n = (func && n == null) ? func.length : n; 15117 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); 15118 } 15119 15120 /** 15121 * Creates a function that invokes `func`, with the `this` binding and arguments 15122 * of the created function, while it's called less than `n` times. Subsequent 15123 * calls to the created function return the result of the last `func` invocation. 15124 * 15125 * @static 15126 * @memberOf _ 15127 * @since 3.0.0 15128 * @category Function 15129 * @param {number} n The number of calls at which `func` is no longer invoked. 15130 * @param {Function} func The function to restrict. 15131 * @returns {Function} Returns the new restricted function. 15132 * @example 15133 * 15134 * jQuery(element).on('click', _.before(5, addContactToList)); 15135 * // => Allows adding up to 4 contacts to the list. 15136 */ 15137 function before(n, func) { 15138 var result; 15139 if (typeof func != 'function') { 15140 throw new TypeError(FUNC_ERROR_TEXT); 15141 } 15142 n = toInteger(n); 15143 return function() { 15144 if (--n > 0) { 15145 result = func.apply(this, arguments); 15146 } 15147 if (n <= 1) { 15148 func = undefined; 15149 } 15150 return result; 15151 }; 15152 } 15153 15154 /** 15155 * Creates a function that invokes `func` with the `this` binding of `thisArg` 15156 * and `partials` prepended to the arguments it receives. 15157 * 15158 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, 15159 * may be used as a placeholder for partially applied arguments. 15160 * 15161 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" 15162 * property of bound functions. 15163 * 15164 * @static 15165 * @memberOf _ 15166 * @since 0.1.0 15167 * @category Function 15168 * @param {Function} func The function to bind. 15169 * @param {*} thisArg The `this` binding of `func`. 15170 * @param {...*} [partials] The arguments to be partially applied. 15171 * @returns {Function} Returns the new bound function. 15172 * @example 15173 * 15174 * function greet(greeting, punctuation) { 15175 * return greeting + ' ' + this.user + punctuation; 15176 * } 15177 * 15178 * var object = { 'user': 'fred' }; 15179 * 15180 * var bound = _.bind(greet, object, 'hi'); 15181 * bound('!'); 15182 * // => 'hi fred!' 15183 * 15184 * // Bound with placeholders. 15185 * var bound = _.bind(greet, object, _, '!'); 15186 * bound('hi'); 15187 * // => 'hi fred!' 15188 */ 15189 var bind = baseRest(function(func, thisArg, partials) { 15190 var bitmask = WRAP_BIND_FLAG; 15191 if (partials.length) { 15192 var holders = replaceHolders(partials, getHolder(bind)); 15193 bitmask |= WRAP_PARTIAL_FLAG; 15194 } 15195 return createWrap(func, bitmask, thisArg, partials, holders); 15196 }); 15197 15198 /** 15199 * Creates a function that invokes the method at `object[key]` with `partials` 15200 * prepended to the arguments it receives. 15201 * 15202 * This method differs from `_.bind` by allowing bound functions to reference 15203 * methods that may be redefined or don't yet exist. See 15204 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) 15205 * for more details. 15206 * 15207 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic 15208 * builds, may be used as a placeholder for partially applied arguments. 15209 * 15210 * @static 15211 * @memberOf _ 15212 * @since 0.10.0 15213 * @category Function 15214 * @param {Object} object The object to invoke the method on. 15215 * @param {string} key The key of the method. 15216 * @param {...*} [partials] The arguments to be partially applied. 15217 * @returns {Function} Returns the new bound function. 15218 * @example 15219 * 15220 * var object = { 15221 * 'user': 'fred', 15222 * 'greet': function(greeting, punctuation) { 15223 * return greeting + ' ' + this.user + punctuation; 15224 * } 15225 * }; 15226 * 15227 * var bound = _.bindKey(object, 'greet', 'hi'); 15228 * bound('!'); 15229 * // => 'hi fred!' 15230 * 15231 * object.greet = function(greeting, punctuation) { 15232 * return greeting + 'ya ' + this.user + punctuation; 15233 * }; 15234 * 15235 * bound('!'); 15236 * // => 'hiya fred!' 15237 * 15238 * // Bound with placeholders. 15239 * var bound = _.bindKey(object, 'greet', _, '!'); 15240 * bound('hi'); 15241 * // => 'hiya fred!' 15242 */ 15243 var bindKey = baseRest(function(object, key, partials) { 15244 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; 15245 if (partials.length) { 15246 var holders = replaceHolders(partials, getHolder(bindKey)); 15247 bitmask |= WRAP_PARTIAL_FLAG; 15248 } 15249 return createWrap(key, bitmask, object, partials, holders); 15250 }); 15251 15252 /** 15253 * Creates a function that accepts arguments of `func` and either invokes 15254 * `func` returning its result, if at least `arity` number of arguments have 15255 * been provided, or returns a function that accepts the remaining `func` 15256 * arguments, and so on. The arity of `func` may be specified if `func.length` 15257 * is not sufficient. 15258 * 15259 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, 15260 * may be used as a placeholder for provided arguments. 15261 * 15262 * **Note:** This method doesn't set the "length" property of curried functions. 15263 * 15264 * @static 15265 * @memberOf _ 15266 * @since 2.0.0 15267 * @category Function 15268 * @param {Function} func The function to curry. 15269 * @param {number} [arity=func.length] The arity of `func`. 15270 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15271 * @returns {Function} Returns the new curried function. 15272 * @example 15273 * 15274 * var abc = function(a, b, c) { 15275 * return [a, b, c]; 15276 * }; 15277 * 15278 * var curried = _.curry(abc); 15279 * 15280 * curried(1)(2)(3); 15281 * // => [1, 2, 3] 15282 * 15283 * curried(1, 2)(3); 15284 * // => [1, 2, 3] 15285 * 15286 * curried(1, 2, 3); 15287 * // => [1, 2, 3] 15288 * 15289 * // Curried with placeholders. 15290 * curried(1)(_, 3)(2); 15291 * // => [1, 2, 3] 15292 */ 15293 function curry(func, arity, guard) { 15294 arity = guard ? undefined : arity; 15295 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 15296 result.placeholder = curry.placeholder; 15297 return result; 15298 } 15299 15300 /** 15301 * This method is like `_.curry` except that arguments are applied to `func` 15302 * in the manner of `_.partialRight` instead of `_.partial`. 15303 * 15304 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic 15305 * builds, may be used as a placeholder for provided arguments. 15306 * 15307 * **Note:** This method doesn't set the "length" property of curried functions. 15308 * 15309 * @static 15310 * @memberOf _ 15311 * @since 3.0.0 15312 * @category Function 15313 * @param {Function} func The function to curry. 15314 * @param {number} [arity=func.length] The arity of `func`. 15315 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15316 * @returns {Function} Returns the new curried function. 15317 * @example 15318 * 15319 * var abc = function(a, b, c) { 15320 * return [a, b, c]; 15321 * }; 15322 * 15323 * var curried = _.curryRight(abc); 15324 * 15325 * curried(3)(2)(1); 15326 * // => [1, 2, 3] 15327 * 15328 * curried(2, 3)(1); 15329 * // => [1, 2, 3] 15330 * 15331 * curried(1, 2, 3); 15332 * // => [1, 2, 3] 15333 * 15334 * // Curried with placeholders. 15335 * curried(3)(1, _)(2); 15336 * // => [1, 2, 3] 15337 */ 15338 function curryRight(func, arity, guard) { 15339 arity = guard ? undefined : arity; 15340 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 15341 result.placeholder = curryRight.placeholder; 15342 return result; 15343 } 15344 15345 /** 15346 * Creates a debounced function that delays invoking `func` until after `wait` 15347 * milliseconds have elapsed since the last time the debounced function was 15348 * invoked. The debounced function comes with a `cancel` method to cancel 15349 * delayed `func` invocations and a `flush` method to immediately invoke them. 15350 * Provide `options` to indicate whether `func` should be invoked on the 15351 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 15352 * with the last arguments provided to the debounced function. Subsequent 15353 * calls to the debounced function return the result of the last `func` 15354 * invocation. 15355 * 15356 * **Note:** If `leading` and `trailing` options are `true`, `func` is 15357 * invoked on the trailing edge of the timeout only if the debounced function 15358 * is invoked more than once during the `wait` timeout. 15359 * 15360 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 15361 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 15362 * 15363 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 15364 * for details over the differences between `_.debounce` and `_.throttle`. 15365 * 15366 * @static 15367 * @memberOf _ 15368 * @since 0.1.0 15369 * @category Function 15370 * @param {Function} func The function to debounce. 15371 * @param {number} [wait=0] The number of milliseconds to delay. 15372 * @param {Object} [options={}] The options object. 15373 * @param {boolean} [options.leading=false] 15374 * Specify invoking on the leading edge of the timeout. 15375 * @param {number} [options.maxWait] 15376 * The maximum time `func` is allowed to be delayed before it's invoked. 15377 * @param {boolean} [options.trailing=true] 15378 * Specify invoking on the trailing edge of the timeout. 15379 * @returns {Function} Returns the new debounced function. 15380 * @example 15381 * 15382 * // Avoid costly calculations while the window size is in flux. 15383 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 15384 * 15385 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 15386 * jQuery(element).on('click', _.debounce(sendMail, 300, { 15387 * 'leading': true, 15388 * 'trailing': false 15389 * })); 15390 * 15391 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 15392 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 15393 * var source = new EventSource('/stream'); 15394 * jQuery(source).on('message', debounced); 15395 * 15396 * // Cancel the trailing debounced invocation. 15397 * jQuery(window).on('popstate', debounced.cancel); 15398 */ 15399 function debounce(func, wait, options) { 15400 var lastArgs, 15401 lastThis, 15402 maxWait, 15403 result, 15404 timerId, 15405 lastCallTime, 15406 lastInvokeTime = 0, 15407 leading = false, 15408 maxing = false, 15409 trailing = true; 15410 15411 if (typeof func != 'function') { 15412 throw new TypeError(FUNC_ERROR_TEXT); 15413 } 15414 wait = toNumber(wait) || 0; 15415 if (isObject(options)) { 15416 leading = !!options.leading; 15417 maxing = 'maxWait' in options; 15418 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 15419 trailing = 'trailing' in options ? !!options.trailing : trailing; 15420 } 15421 15422 function invokeFunc(time) { 15423 var args = lastArgs, 15424 thisArg = lastThis; 15425 15426 lastArgs = lastThis = undefined; 15427 lastInvokeTime = time; 15428 result = func.apply(thisArg, args); 15429 return result; 15430 } 15431 15432 function leadingEdge(time) { 15433 // Reset any `maxWait` timer. 15434 lastInvokeTime = time; 15435 // Start the timer for the trailing edge. 15436 timerId = setTimeout(timerExpired, wait); 15437 // Invoke the leading edge. 15438 return leading ? invokeFunc(time) : result; 15439 } 15440 15441 function remainingWait(time) { 15442 var timeSinceLastCall = time - lastCallTime, 15443 timeSinceLastInvoke = time - lastInvokeTime, 15444 timeWaiting = wait - timeSinceLastCall; 15445 15446 return maxing 15447 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 15448 : timeWaiting; 15449 } 15450 15451 function shouldInvoke(time) { 15452 var timeSinceLastCall = time - lastCallTime, 15453 timeSinceLastInvoke = time - lastInvokeTime; 15454 15455 // Either this is the first call, activity has stopped and we're at the 15456 // trailing edge, the system time has gone backwards and we're treating 15457 // it as the trailing edge, or we've hit the `maxWait` limit. 15458 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 15459 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 15460 } 15461 15462 function timerExpired() { 15463 var time = now(); 15464 if (shouldInvoke(time)) { 15465 return trailingEdge(time); 15466 } 15467 // Restart the timer. 15468 timerId = setTimeout(timerExpired, remainingWait(time)); 15469 } 15470 15471 function trailingEdge(time) { 15472 timerId = undefined; 15473 15474 // Only invoke if we have `lastArgs` which means `func` has been 15475 // debounced at least once. 15476 if (trailing && lastArgs) { 15477 return invokeFunc(time); 15478 } 15479 lastArgs = lastThis = undefined; 15480 return result; 15481 } 15482 15483 function cancel() { 15484 if (timerId !== undefined) { 15485 clearTimeout(timerId); 15486 } 15487 lastInvokeTime = 0; 15488 lastArgs = lastCallTime = lastThis = timerId = undefined; 15489 } 15490 15491 function flush() { 15492 return timerId === undefined ? result : trailingEdge(now()); 15493 } 15494 15495 function debounced() { 15496 var time = now(), 15497 isInvoking = shouldInvoke(time); 15498 15499 lastArgs = arguments; 15500 lastThis = this; 15501 lastCallTime = time; 15502 15503 if (isInvoking) { 15504 if (timerId === undefined) { 15505 return leadingEdge(lastCallTime); 15506 } 15507 if (maxing) { 15508 // Handle invocations in a tight loop. 15509 clearTimeout(timerId); 15510 timerId = setTimeout(timerExpired, wait); 15511 return invokeFunc(lastCallTime); 15512 } 15513 } 15514 if (timerId === undefined) { 15515 timerId = setTimeout(timerExpired, wait); 15516 } 15517 return result; 15518 } 15519 debounced.cancel = cancel; 15520 debounced.flush = flush; 15521 return debounced; 15522 } 15523 15524 /** 15525 * Defers invoking the `func` until the current call stack has cleared. Any 15526 * additional arguments are provided to `func` when it's invoked. 15527 * 15528 * @static 15529 * @memberOf _ 15530 * @since 0.1.0 15531 * @category Function 15532 * @param {Function} func The function to defer. 15533 * @param {...*} [args] The arguments to invoke `func` with. 15534 * @returns {number} Returns the timer id. 15535 * @example 15536 * 15537 * _.defer(function(text) { 15538 * console.log(text); 15539 * }, 'deferred'); 15540 * // => Logs 'deferred' after one millisecond. 15541 */ 15542 var defer = baseRest(function(func, args) { 15543 return baseDelay(func, 1, args); 15544 }); 15545 15546 /** 15547 * Invokes `func` after `wait` milliseconds. Any additional arguments are 15548 * provided to `func` when it's invoked. 15549 * 15550 * @static 15551 * @memberOf _ 15552 * @since 0.1.0 15553 * @category Function 15554 * @param {Function} func The function to delay. 15555 * @param {number} wait The number of milliseconds to delay invocation. 15556 * @param {...*} [args] The arguments to invoke `func` with. 15557 * @returns {number} Returns the timer id. 15558 * @example 15559 * 15560 * _.delay(function(text) { 15561 * console.log(text); 15562 * }, 1000, 'later'); 15563 * // => Logs 'later' after one second. 15564 */ 15565 var delay = baseRest(function(func, wait, args) { 15566 return baseDelay(func, toNumber(wait) || 0, args); 15567 }); 15568 15569 /** 15570 * Creates a function that invokes `func` with arguments reversed. 15571 * 15572 * @static 15573 * @memberOf _ 15574 * @since 4.0.0 15575 * @category Function 15576 * @param {Function} func The function to flip arguments for. 15577 * @returns {Function} Returns the new flipped function. 15578 * @example 15579 * 15580 * var flipped = _.flip(function() { 15581 * return _.toArray(arguments); 15582 * }); 15583 * 15584 * flipped('a', 'b', 'c', 'd'); 15585 * // => ['d', 'c', 'b', 'a'] 15586 */ 15587 function flip(func) { 15588 return createWrap(func, WRAP_FLIP_FLAG); 15589 } 15590 15591 /** 15592 * Creates a function that memoizes the result of `func`. If `resolver` is 15593 * provided, it determines the cache key for storing the result based on the 15594 * arguments provided to the memoized function. By default, the first argument 15595 * provided to the memoized function is used as the map cache key. The `func` 15596 * is invoked with the `this` binding of the memoized function. 15597 * 15598 * **Note:** The cache is exposed as the `cache` property on the memoized 15599 * function. Its creation may be customized by replacing the `_.memoize.Cache` 15600 * constructor with one whose instances implement the 15601 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) 15602 * method interface of `clear`, `delete`, `get`, `has`, and `set`. 15603 * 15604 * @static 15605 * @memberOf _ 15606 * @since 0.1.0 15607 * @category Function 15608 * @param {Function} func The function to have its output memoized. 15609 * @param {Function} [resolver] The function to resolve the cache key. 15610 * @returns {Function} Returns the new memoized function. 15611 * @example 15612 * 15613 * var object = { 'a': 1, 'b': 2 }; 15614 * var other = { 'c': 3, 'd': 4 }; 15615 * 15616 * var values = _.memoize(_.values); 15617 * values(object); 15618 * // => [1, 2] 15619 * 15620 * values(other); 15621 * // => [3, 4] 15622 * 15623 * object.a = 2; 15624 * values(object); 15625 * // => [1, 2] 15626 * 15627 * // Modify the result cache. 15628 * values.cache.set(object, ['a', 'b']); 15629 * values(object); 15630 * // => ['a', 'b'] 15631 * 15632 * // Replace `_.memoize.Cache`. 15633 * _.memoize.Cache = WeakMap; 15634 */ 15635 function memoize(func, resolver) { 15636 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 15637 throw new TypeError(FUNC_ERROR_TEXT); 15638 } 15639 var memoized = function() { 15640 var args = arguments, 15641 key = resolver ? resolver.apply(this, args) : args[0], 15642 cache = memoized.cache; 15643 15644 if (cache.has(key)) { 15645 return cache.get(key); 15646 } 15647 var result = func.apply(this, args); 15648 memoized.cache = cache.set(key, result) || cache; 15649 return result; 15650 }; 15651 memoized.cache = new (memoize.Cache || MapCache); 15652 return memoized; 15653 } 15654 15655 // Expose `MapCache`. 15656 memoize.Cache = MapCache; 15657 15658 /** 15659 * Creates a function that negates the result of the predicate `func`. The 15660 * `func` predicate is invoked with the `this` binding and arguments of the 15661 * created function. 15662 * 15663 * @static 15664 * @memberOf _ 15665 * @since 3.0.0 15666 * @category Function 15667 * @param {Function} predicate The predicate to negate. 15668 * @returns {Function} Returns the new negated function. 15669 * @example 15670 * 15671 * function isEven(n) { 15672 * return n % 2 == 0; 15673 * } 15674 * 15675 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); 15676 * // => [1, 3, 5] 15677 */ 15678 function negate(predicate) { 15679 if (typeof predicate != 'function') { 15680 throw new TypeError(FUNC_ERROR_TEXT); 15681 } 15682 return function() { 15683 var args = arguments; 15684 switch (args.length) { 15685 case 0: return !predicate.call(this); 15686 case 1: return !predicate.call(this, args[0]); 15687 case 2: return !predicate.call(this, args[0], args[1]); 15688 case 3: return !predicate.call(this, args[0], args[1], args[2]); 15689 } 15690 return !predicate.apply(this, args); 15691 }; 15692 } 15693 15694 /** 15695 * Creates a function that is restricted to invoking `func` once. Repeat calls 15696 * to the function return the value of the first invocation. The `func` is 15697 * invoked with the `this` binding and arguments of the created function. 15698 * 15699 * @static 15700 * @memberOf _ 15701 * @since 0.1.0 15702 * @category Function 15703 * @param {Function} func The function to restrict. 15704 * @returns {Function} Returns the new restricted function. 15705 * @example 15706 * 15707 * var initialize = _.once(createApplication); 15708 * initialize(); 15709 * initialize(); 15710 * // => `createApplication` is invoked once 15711 */ 15712 function once(func) { 15713 return before(2, func); 15714 } 15715 15716 /** 15717 * Creates a function that invokes `func` with its arguments transformed. 15718 * 15719 * @static 15720 * @since 4.0.0 15721 * @memberOf _ 15722 * @category Function 15723 * @param {Function} func The function to wrap. 15724 * @param {...(Function|Function[])} [transforms=[_.identity]] 15725 * The argument transforms. 15726 * @returns {Function} Returns the new function. 15727 * @example 15728 * 15729 * function doubled(n) { 15730 * return n * 2; 15731 * } 15732 * 15733 * function square(n) { 15734 * return n * n; 15735 * } 15736 * 15737 * var func = _.overArgs(function(x, y) { 15738 * return [x, y]; 15739 * }, [square, doubled]); 15740 * 15741 * func(9, 3); 15742 * // => [81, 6] 15743 * 15744 * func(10, 5); 15745 * // => [100, 10] 15746 */ 15747 var overArgs = castRest(function(func, transforms) { 15748 transforms = (transforms.length == 1 && isArray(transforms[0])) 15749 ? arrayMap(transforms[0], baseUnary(getIteratee())) 15750 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); 15751 15752 var funcsLength = transforms.length; 15753 return baseRest(function(args) { 15754 var index = -1, 15755 length = nativeMin(args.length, funcsLength); 15756 15757 while (++index < length) { 15758 args[index] = transforms[index].call(this, args[index]); 15759 } 15760 return apply(func, this, args); 15761 }); 15762 }); 15763 15764 /** 15765 * Creates a function that invokes `func` with `partials` prepended to the 15766 * arguments it receives. This method is like `_.bind` except it does **not** 15767 * alter the `this` binding. 15768 * 15769 * The `_.partial.placeholder` value, which defaults to `_` in monolithic 15770 * builds, may be used as a placeholder for partially applied arguments. 15771 * 15772 * **Note:** This method doesn't set the "length" property of partially 15773 * applied functions. 15774 * 15775 * @static 15776 * @memberOf _ 15777 * @since 0.2.0 15778 * @category Function 15779 * @param {Function} func The function to partially apply arguments to. 15780 * @param {...*} [partials] The arguments to be partially applied. 15781 * @returns {Function} Returns the new partially applied function. 15782 * @example 15783 * 15784 * function greet(greeting, name) { 15785 * return greeting + ' ' + name; 15786 * } 15787 * 15788 * var sayHelloTo = _.partial(greet, 'hello'); 15789 * sayHelloTo('fred'); 15790 * // => 'hello fred' 15791 * 15792 * // Partially applied with placeholders. 15793 * var greetFred = _.partial(greet, _, 'fred'); 15794 * greetFred('hi'); 15795 * // => 'hi fred' 15796 */ 15797 var partial = baseRest(function(func, partials) { 15798 var holders = replaceHolders(partials, getHolder(partial)); 15799 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); 15800 }); 15801 15802 /** 15803 * This method is like `_.partial` except that partially applied arguments 15804 * are appended to the arguments it receives. 15805 * 15806 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic 15807 * builds, may be used as a placeholder for partially applied arguments. 15808 * 15809 * **Note:** This method doesn't set the "length" property of partially 15810 * applied functions. 15811 * 15812 * @static 15813 * @memberOf _ 15814 * @since 1.0.0 15815 * @category Function 15816 * @param {Function} func The function to partially apply arguments to. 15817 * @param {...*} [partials] The arguments to be partially applied. 15818 * @returns {Function} Returns the new partially applied function. 15819 * @example 15820 * 15821 * function greet(greeting, name) { 15822 * return greeting + ' ' + name; 15823 * } 15824 * 15825 * var greetFred = _.partialRight(greet, 'fred'); 15826 * greetFred('hi'); 15827 * // => 'hi fred' 15828 * 15829 * // Partially applied with placeholders. 15830 * var sayHelloTo = _.partialRight(greet, 'hello', _); 15831 * sayHelloTo('fred'); 15832 * // => 'hello fred' 15833 */ 15834 var partialRight = baseRest(function(func, partials) { 15835 var holders = replaceHolders(partials, getHolder(partialRight)); 15836 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); 15837 }); 15838 15839 /** 15840 * Creates a function that invokes `func` with arguments arranged according 15841 * to the specified `indexes` where the argument value at the first index is 15842 * provided as the first argument, the argument value at the second index is 15843 * provided as the second argument, and so on. 15844 * 15845 * @static 15846 * @memberOf _ 15847 * @since 3.0.0 15848 * @category Function 15849 * @param {Function} func The function to rearrange arguments for. 15850 * @param {...(number|number[])} indexes The arranged argument indexes. 15851 * @returns {Function} Returns the new function. 15852 * @example 15853 * 15854 * var rearged = _.rearg(function(a, b, c) { 15855 * return [a, b, c]; 15856 * }, [2, 0, 1]); 15857 * 15858 * rearged('b', 'c', 'a') 15859 * // => ['a', 'b', 'c'] 15860 */ 15861 var rearg = flatRest(function(func, indexes) { 15862 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); 15863 }); 15864 15865 /** 15866 * Creates a function that invokes `func` with the `this` binding of the 15867 * created function and arguments from `start` and beyond provided as 15868 * an array. 15869 * 15870 * **Note:** This method is based on the 15871 * [rest parameter](https://mdn.io/rest_parameters). 15872 * 15873 * @static 15874 * @memberOf _ 15875 * @since 4.0.0 15876 * @category Function 15877 * @param {Function} func The function to apply a rest parameter to. 15878 * @param {number} [start=func.length-1] The start position of the rest parameter. 15879 * @returns {Function} Returns the new function. 15880 * @example 15881 * 15882 * var say = _.rest(function(what, names) { 15883 * return what + ' ' + _.initial(names).join(', ') + 15884 * (_.size(names) > 1 ? ', & ' : '') + _.last(names); 15885 * }); 15886 * 15887 * say('hello', 'fred', 'barney', 'pebbles'); 15888 * // => 'hello fred, barney, & pebbles' 15889 */ 15890 function rest(func, start) { 15891 if (typeof func != 'function') { 15892 throw new TypeError(FUNC_ERROR_TEXT); 15893 } 15894 start = start === undefined ? start : toInteger(start); 15895 return baseRest(func, start); 15896 } 15897 15898 /** 15899 * Creates a function that invokes `func` with the `this` binding of the 15900 * create function and an array of arguments much like 15901 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). 15902 * 15903 * **Note:** This method is based on the 15904 * [spread operator](https://mdn.io/spread_operator). 15905 * 15906 * @static 15907 * @memberOf _ 15908 * @since 3.2.0 15909 * @category Function 15910 * @param {Function} func The function to spread arguments over. 15911 * @param {number} [start=0] The start position of the spread. 15912 * @returns {Function} Returns the new function. 15913 * @example 15914 * 15915 * var say = _.spread(function(who, what) { 15916 * return who + ' says ' + what; 15917 * }); 15918 * 15919 * say(['fred', 'hello']); 15920 * // => 'fred says hello' 15921 * 15922 * var numbers = Promise.all([ 15923 * Promise.resolve(40), 15924 * Promise.resolve(36) 15925 * ]); 15926 * 15927 * numbers.then(_.spread(function(x, y) { 15928 * return x + y; 15929 * })); 15930 * // => a Promise of 76 15931 */ 15932 function spread(func, start) { 15933 if (typeof func != 'function') { 15934 throw new TypeError(FUNC_ERROR_TEXT); 15935 } 15936 start = start == null ? 0 : nativeMax(toInteger(start), 0); 15937 return baseRest(function(args) { 15938 var array = args[start], 15939 otherArgs = castSlice(args, 0, start); 15940 15941 if (array) { 15942 arrayPush(otherArgs, array); 15943 } 15944 return apply(func, this, otherArgs); 15945 }); 15946 } 15947 15948 /** 15949 * Creates a throttled function that only invokes `func` at most once per 15950 * every `wait` milliseconds. The throttled function comes with a `cancel` 15951 * method to cancel delayed `func` invocations and a `flush` method to 15952 * immediately invoke them. Provide `options` to indicate whether `func` 15953 * should be invoked on the leading and/or trailing edge of the `wait` 15954 * timeout. The `func` is invoked with the last arguments provided to the 15955 * throttled function. Subsequent calls to the throttled function return the 15956 * result of the last `func` invocation. 15957 * 15958 * **Note:** If `leading` and `trailing` options are `true`, `func` is 15959 * invoked on the trailing edge of the timeout only if the throttled function 15960 * is invoked more than once during the `wait` timeout. 15961 * 15962 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 15963 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 15964 * 15965 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 15966 * for details over the differences between `_.throttle` and `_.debounce`. 15967 * 15968 * @static 15969 * @memberOf _ 15970 * @since 0.1.0 15971 * @category Function 15972 * @param {Function} func The function to throttle. 15973 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 15974 * @param {Object} [options={}] The options object. 15975 * @param {boolean} [options.leading=true] 15976 * Specify invoking on the leading edge of the timeout. 15977 * @param {boolean} [options.trailing=true] 15978 * Specify invoking on the trailing edge of the timeout. 15979 * @returns {Function} Returns the new throttled function. 15980 * @example 15981 * 15982 * // Avoid excessively updating the position while scrolling. 15983 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 15984 * 15985 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 15986 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 15987 * jQuery(element).on('click', throttled); 15988 * 15989 * // Cancel the trailing throttled invocation. 15990 * jQuery(window).on('popstate', throttled.cancel); 15991 */ 15992 function throttle(func, wait, options) { 15993 var leading = true, 15994 trailing = true; 15995 15996 if (typeof func != 'function') { 15997 throw new TypeError(FUNC_ERROR_TEXT); 15998 } 15999 if (isObject(options)) { 16000 leading = 'leading' in options ? !!options.leading : leading; 16001 trailing = 'trailing' in options ? !!options.trailing : trailing; 16002 } 16003 return debounce(func, wait, { 16004 'leading': leading, 16005 'maxWait': wait, 16006 'trailing': trailing 16007 }); 16008 } 16009 16010 /** 16011 * Creates a function that accepts up to one argument, ignoring any 16012 * additional arguments. 16013 * 16014 * @static 16015 * @memberOf _ 16016 * @since 4.0.0 16017 * @category Function 16018 * @param {Function} func The function to cap arguments for. 16019 * @returns {Function} Returns the new capped function. 16020 * @example 16021 * 16022 * _.map(['6', '8', '10'], _.unary(parseInt)); 16023 * // => [6, 8, 10] 16024 */ 16025 function unary(func) { 16026 return ary(func, 1); 16027 } 16028 16029 /** 16030 * Creates a function that provides `value` to `wrapper` as its first 16031 * argument. Any additional arguments provided to the function are appended 16032 * to those provided to the `wrapper`. The wrapper is invoked with the `this` 16033 * binding of the created function. 16034 * 16035 * @static 16036 * @memberOf _ 16037 * @since 0.1.0 16038 * @category Function 16039 * @param {*} value The value to wrap. 16040 * @param {Function} [wrapper=identity] The wrapper function. 16041 * @returns {Function} Returns the new function. 16042 * @example 16043 * 16044 * var p = _.wrap(_.escape, function(func, text) { 16045 * return '<p>' + func(text) + '</p>'; 16046 * }); 16047 * 16048 * p('fred, barney, & pebbles'); 16049 * // => '<p>fred, barney, & pebbles</p>' 16050 */ 16051 function wrap(value, wrapper) { 16052 return partial(castFunction(wrapper), value); 16053 } 16054 16055 /*------------------------------------------------------------------------*/ 16056 16057 /** 16058 * Casts `value` as an array if it's not one. 16059 * 16060 * @static 16061 * @memberOf _ 16062 * @since 4.4.0 16063 * @category Lang 16064 * @param {*} value The value to inspect. 16065 * @returns {Array} Returns the cast array. 16066 * @example 16067 * 16068 * _.castArray(1); 16069 * // => [1] 16070 * 16071 * _.castArray({ 'a': 1 }); 16072 * // => [{ 'a': 1 }] 16073 * 16074 * _.castArray('abc'); 16075 * // => ['abc'] 16076 * 16077 * _.castArray(null); 16078 * // => [null] 16079 * 16080 * _.castArray(undefined); 16081 * // => [undefined] 16082 * 16083 * _.castArray(); 16084 * // => [] 16085 * 16086 * var array = [1, 2, 3]; 16087 * console.log(_.castArray(array) === array); 16088 * // => true 16089 */ 16090 function castArray() { 16091 if (!arguments.length) { 16092 return []; 16093 } 16094 var value = arguments[0]; 16095 return isArray(value) ? value : [value]; 16096 } 16097 16098 /** 16099 * Creates a shallow clone of `value`. 16100 * 16101 * **Note:** This method is loosely based on the 16102 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) 16103 * and supports cloning arrays, array buffers, booleans, date objects, maps, 16104 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed 16105 * arrays. The own enumerable properties of `arguments` objects are cloned 16106 * as plain objects. An empty object is returned for uncloneable values such 16107 * as error objects, functions, DOM nodes, and WeakMaps. 16108 * 16109 * @static 16110 * @memberOf _ 16111 * @since 0.1.0 16112 * @category Lang 16113 * @param {*} value The value to clone. 16114 * @returns {*} Returns the cloned value. 16115 * @see _.cloneDeep 16116 * @example 16117 * 16118 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 16119 * 16120 * var shallow = _.clone(objects); 16121 * console.log(shallow[0] === objects[0]); 16122 * // => true 16123 */ 16124 function clone(value) { 16125 return baseClone(value, CLONE_SYMBOLS_FLAG); 16126 } 16127 16128 /** 16129 * This method is like `_.clone` except that it accepts `customizer` which 16130 * is invoked to produce the cloned value. If `customizer` returns `undefined`, 16131 * cloning is handled by the method instead. The `customizer` is invoked with 16132 * up to four arguments; (value [, index|key, object, stack]). 16133 * 16134 * @static 16135 * @memberOf _ 16136 * @since 4.0.0 16137 * @category Lang 16138 * @param {*} value The value to clone. 16139 * @param {Function} [customizer] The function to customize cloning. 16140 * @returns {*} Returns the cloned value. 16141 * @see _.cloneDeepWith 16142 * @example 16143 * 16144 * function customizer(value) { 16145 * if (_.isElement(value)) { 16146 * return value.cloneNode(false); 16147 * } 16148 * } 16149 * 16150 * var el = _.cloneWith(document.body, customizer); 16151 * 16152 * console.log(el === document.body); 16153 * // => false 16154 * console.log(el.nodeName); 16155 * // => 'BODY' 16156 * console.log(el.childNodes.length); 16157 * // => 0 16158 */ 16159 function cloneWith(value, customizer) { 16160 customizer = typeof customizer == 'function' ? customizer : undefined; 16161 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); 16162 } 16163 16164 /** 16165 * This method is like `_.clone` except that it recursively clones `value`. 16166 * 16167 * @static 16168 * @memberOf _ 16169 * @since 1.0.0 16170 * @category Lang 16171 * @param {*} value The value to recursively clone. 16172 * @returns {*} Returns the deep cloned value. 16173 * @see _.clone 16174 * @example 16175 * 16176 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 16177 * 16178 * var deep = _.cloneDeep(objects); 16179 * console.log(deep[0] === objects[0]); 16180 * // => false 16181 */ 16182 function cloneDeep(value) { 16183 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 16184 } 16185 16186 /** 16187 * This method is like `_.cloneWith` except that it recursively clones `value`. 16188 * 16189 * @static 16190 * @memberOf _ 16191 * @since 4.0.0 16192 * @category Lang 16193 * @param {*} value The value to recursively clone. 16194 * @param {Function} [customizer] The function to customize cloning. 16195 * @returns {*} Returns the deep cloned value. 16196 * @see _.cloneWith 16197 * @example 16198 * 16199 * function customizer(value) { 16200 * if (_.isElement(value)) { 16201 * return value.cloneNode(true); 16202 * } 16203 * } 16204 * 16205 * var el = _.cloneDeepWith(document.body, customizer); 16206 * 16207 * console.log(el === document.body); 16208 * // => false 16209 * console.log(el.nodeName); 16210 * // => 'BODY' 16211 * console.log(el.childNodes.length); 16212 * // => 20 16213 */ 16214 function cloneDeepWith(value, customizer) { 16215 customizer = typeof customizer == 'function' ? customizer : undefined; 16216 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); 16217 } 16218 16219 /** 16220 * Checks if `object` conforms to `source` by invoking the predicate 16221 * properties of `source` with the corresponding property values of `object`. 16222 * 16223 * **Note:** This method is equivalent to `_.conforms` when `source` is 16224 * partially applied. 16225 * 16226 * @static 16227 * @memberOf _ 16228 * @since 4.14.0 16229 * @category Lang 16230 * @param {Object} object The object to inspect. 16231 * @param {Object} source The object of property predicates to conform to. 16232 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 16233 * @example 16234 * 16235 * var object = { 'a': 1, 'b': 2 }; 16236 * 16237 * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); 16238 * // => true 16239 * 16240 * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); 16241 * // => false 16242 */ 16243 function conformsTo(object, source) { 16244 return source == null || baseConformsTo(object, source, keys(source)); 16245 } 16246 16247 /** 16248 * Performs a 16249 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 16250 * comparison between two values to determine if they are equivalent. 16251 * 16252 * @static 16253 * @memberOf _ 16254 * @since 4.0.0 16255 * @category Lang 16256 * @param {*} value The value to compare. 16257 * @param {*} other The other value to compare. 16258 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 16259 * @example 16260 * 16261 * var object = { 'a': 1 }; 16262 * var other = { 'a': 1 }; 16263 * 16264 * _.eq(object, object); 16265 * // => true 16266 * 16267 * _.eq(object, other); 16268 * // => false 16269 * 16270 * _.eq('a', 'a'); 16271 * // => true 16272 * 16273 * _.eq('a', Object('a')); 16274 * // => false 16275 * 16276 * _.eq(NaN, NaN); 16277 * // => true 16278 */ 16279 function eq(value, other) { 16280 return value === other || (value !== value && other !== other); 16281 } 16282 16283 /** 16284 * Checks if `value` is greater than `other`. 16285 * 16286 * @static 16287 * @memberOf _ 16288 * @since 3.9.0 16289 * @category Lang 16290 * @param {*} value The value to compare. 16291 * @param {*} other The other value to compare. 16292 * @returns {boolean} Returns `true` if `value` is greater than `other`, 16293 * else `false`. 16294 * @see _.lt 16295 * @example 16296 * 16297 * _.gt(3, 1); 16298 * // => true 16299 * 16300 * _.gt(3, 3); 16301 * // => false 16302 * 16303 * _.gt(1, 3); 16304 * // => false 16305 */ 16306 var gt = createRelationalOperation(baseGt); 16307 16308 /** 16309 * Checks if `value` is greater than or equal to `other`. 16310 * 16311 * @static 16312 * @memberOf _ 16313 * @since 3.9.0 16314 * @category Lang 16315 * @param {*} value The value to compare. 16316 * @param {*} other The other value to compare. 16317 * @returns {boolean} Returns `true` if `value` is greater than or equal to 16318 * `other`, else `false`. 16319 * @see _.lte 16320 * @example 16321 * 16322 * _.gte(3, 1); 16323 * // => true 16324 * 16325 * _.gte(3, 3); 16326 * // => true 16327 * 16328 * _.gte(1, 3); 16329 * // => false 16330 */ 16331 var gte = createRelationalOperation(function(value, other) { 16332 return value >= other; 16333 }); 16334 16335 /** 16336 * Checks if `value` is likely an `arguments` object. 16337 * 16338 * @static 16339 * @memberOf _ 16340 * @since 0.1.0 16341 * @category Lang 16342 * @param {*} value The value to check. 16343 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 16344 * else `false`. 16345 * @example 16346 * 16347 * _.isArguments(function() { return arguments; }()); 16348 * // => true 16349 * 16350 * _.isArguments([1, 2, 3]); 16351 * // => false 16352 */ 16353 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { 16354 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && 16355 !propertyIsEnumerable.call(value, 'callee'); 16356 }; 16357 16358 /** 16359 * Checks if `value` is classified as an `Array` object. 16360 * 16361 * @static 16362 * @memberOf _ 16363 * @since 0.1.0 16364 * @category Lang 16365 * @param {*} value The value to check. 16366 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 16367 * @example 16368 * 16369 * _.isArray([1, 2, 3]); 16370 * // => true 16371 * 16372 * _.isArray(document.body.children); 16373 * // => false 16374 * 16375 * _.isArray('abc'); 16376 * // => false 16377 * 16378 * _.isArray(_.noop); 16379 * // => false 16380 */ 16381 var isArray = Array.isArray; 16382 16383 /** 16384 * Checks if `value` is classified as an `ArrayBuffer` object. 16385 * 16386 * @static 16387 * @memberOf _ 16388 * @since 4.3.0 16389 * @category Lang 16390 * @param {*} value The value to check. 16391 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 16392 * @example 16393 * 16394 * _.isArrayBuffer(new ArrayBuffer(2)); 16395 * // => true 16396 * 16397 * _.isArrayBuffer(new Array(2)); 16398 * // => false 16399 */ 16400 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; 16401 16402 /** 16403 * Checks if `value` is array-like. A value is considered array-like if it's 16404 * not a function and has a `value.length` that's an integer greater than or 16405 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 16406 * 16407 * @static 16408 * @memberOf _ 16409 * @since 4.0.0 16410 * @category Lang 16411 * @param {*} value The value to check. 16412 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 16413 * @example 16414 * 16415 * _.isArrayLike([1, 2, 3]); 16416 * // => true 16417 * 16418 * _.isArrayLike(document.body.children); 16419 * // => true 16420 * 16421 * _.isArrayLike('abc'); 16422 * // => true 16423 * 16424 * _.isArrayLike(_.noop); 16425 * // => false 16426 */ 16427 function isArrayLike(value) { 16428 return value != null && isLength(value.length) && !isFunction(value); 16429 } 16430 16431 /** 16432 * This method is like `_.isArrayLike` except that it also checks if `value` 16433 * is an object. 16434 * 16435 * @static 16436 * @memberOf _ 16437 * @since 4.0.0 16438 * @category Lang 16439 * @param {*} value The value to check. 16440 * @returns {boolean} Returns `true` if `value` is an array-like object, 16441 * else `false`. 16442 * @example 16443 * 16444 * _.isArrayLikeObject([1, 2, 3]); 16445 * // => true 16446 * 16447 * _.isArrayLikeObject(document.body.children); 16448 * // => true 16449 * 16450 * _.isArrayLikeObject('abc'); 16451 * // => false 16452 * 16453 * _.isArrayLikeObject(_.noop); 16454 * // => false 16455 */ 16456 function isArrayLikeObject(value) { 16457 return isObjectLike(value) && isArrayLike(value); 16458 } 16459 16460 /** 16461 * Checks if `value` is classified as a boolean primitive or object. 16462 * 16463 * @static 16464 * @memberOf _ 16465 * @since 0.1.0 16466 * @category Lang 16467 * @param {*} value The value to check. 16468 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. 16469 * @example 16470 * 16471 * _.isBoolean(false); 16472 * // => true 16473 * 16474 * _.isBoolean(null); 16475 * // => false 16476 */ 16477 function isBoolean(value) { 16478 return value === true || value === false || 16479 (isObjectLike(value) && baseGetTag(value) == boolTag); 16480 } 16481 16482 /** 16483 * Checks if `value` is a buffer. 16484 * 16485 * @static 16486 * @memberOf _ 16487 * @since 4.3.0 16488 * @category Lang 16489 * @param {*} value The value to check. 16490 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 16491 * @example 16492 * 16493 * _.isBuffer(new Buffer(2)); 16494 * // => true 16495 * 16496 * _.isBuffer(new Uint8Array(2)); 16497 * // => false 16498 */ 16499 var isBuffer = nativeIsBuffer || stubFalse; 16500 16501 /** 16502 * Checks if `value` is classified as a `Date` object. 16503 * 16504 * @static 16505 * @memberOf _ 16506 * @since 0.1.0 16507 * @category Lang 16508 * @param {*} value The value to check. 16509 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 16510 * @example 16511 * 16512 * _.isDate(new Date); 16513 * // => true 16514 * 16515 * _.isDate('Mon April 23 2012'); 16516 * // => false 16517 */ 16518 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; 16519 16520 /** 16521 * Checks if `value` is likely a DOM element. 16522 * 16523 * @static 16524 * @memberOf _ 16525 * @since 0.1.0 16526 * @category Lang 16527 * @param {*} value The value to check. 16528 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. 16529 * @example 16530 * 16531 * _.isElement(document.body); 16532 * // => true 16533 * 16534 * _.isElement('<body>'); 16535 * // => false 16536 */ 16537 function isElement(value) { 16538 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); 16539 } 16540 16541 /** 16542 * Checks if `value` is an empty object, collection, map, or set. 16543 * 16544 * Objects are considered empty if they have no own enumerable string keyed 16545 * properties. 16546 * 16547 * Array-like values such as `arguments` objects, arrays, buffers, strings, or 16548 * jQuery-like collections are considered empty if they have a `length` of `0`. 16549 * Similarly, maps and sets are considered empty if they have a `size` of `0`. 16550 * 16551 * @static 16552 * @memberOf _ 16553 * @since 0.1.0 16554 * @category Lang 16555 * @param {*} value The value to check. 16556 * @returns {boolean} Returns `true` if `value` is empty, else `false`. 16557 * @example 16558 * 16559 * _.isEmpty(null); 16560 * // => true 16561 * 16562 * _.isEmpty(true); 16563 * // => true 16564 * 16565 * _.isEmpty(1); 16566 * // => true 16567 * 16568 * _.isEmpty([1, 2, 3]); 16569 * // => false 16570 * 16571 * _.isEmpty({ 'a': 1 }); 16572 * // => false 16573 */ 16574 function isEmpty(value) { 16575 if (value == null) { 16576 return true; 16577 } 16578 if (isArrayLike(value) && 16579 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || 16580 isBuffer(value) || isTypedArray(value) || isArguments(value))) { 16581 return !value.length; 16582 } 16583 var tag = getTag(value); 16584 if (tag == mapTag || tag == setTag) { 16585 return !value.size; 16586 } 16587 if (isPrototype(value)) { 16588 return !baseKeys(value).length; 16589 } 16590 for (var key in value) { 16591 if (hasOwnProperty.call(value, key)) { 16592 return false; 16593 } 16594 } 16595 return true; 16596 } 16597 16598 /** 16599 * Performs a deep comparison between two values to determine if they are 16600 * equivalent. 16601 * 16602 * **Note:** This method supports comparing arrays, array buffers, booleans, 16603 * date objects, error objects, maps, numbers, `Object` objects, regexes, 16604 * sets, strings, symbols, and typed arrays. `Object` objects are compared 16605 * by their own, not inherited, enumerable properties. Functions and DOM 16606 * nodes are compared by strict equality, i.e. `===`. 16607 * 16608 * @static 16609 * @memberOf _ 16610 * @since 0.1.0 16611 * @category Lang 16612 * @param {*} value The value to compare. 16613 * @param {*} other The other value to compare. 16614 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 16615 * @example 16616 * 16617 * var object = { 'a': 1 }; 16618 * var other = { 'a': 1 }; 16619 * 16620 * _.isEqual(object, other); 16621 * // => true 16622 * 16623 * object === other; 16624 * // => false 16625 */ 16626 function isEqual(value, other) { 16627 return baseIsEqual(value, other); 16628 } 16629 16630 /** 16631 * This method is like `_.isEqual` except that it accepts `customizer` which 16632 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 16633 * are handled by the method instead. The `customizer` is invoked with up to 16634 * six arguments: (objValue, othValue [, index|key, object, other, stack]). 16635 * 16636 * @static 16637 * @memberOf _ 16638 * @since 4.0.0 16639 * @category Lang 16640 * @param {*} value The value to compare. 16641 * @param {*} other The other value to compare. 16642 * @param {Function} [customizer] The function to customize comparisons. 16643 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 16644 * @example 16645 * 16646 * function isGreeting(value) { 16647 * return /^h(?:i|ello)$/.test(value); 16648 * } 16649 * 16650 * function customizer(objValue, othValue) { 16651 * if (isGreeting(objValue) && isGreeting(othValue)) { 16652 * return true; 16653 * } 16654 * } 16655 * 16656 * var array = ['hello', 'goodbye']; 16657 * var other = ['hi', 'goodbye']; 16658 * 16659 * _.isEqualWith(array, other, customizer); 16660 * // => true 16661 */ 16662 function isEqualWith(value, other, customizer) { 16663 customizer = typeof customizer == 'function' ? customizer : undefined; 16664 var result = customizer ? customizer(value, other) : undefined; 16665 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; 16666 } 16667 16668 /** 16669 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, 16670 * `SyntaxError`, `TypeError`, or `URIError` object. 16671 * 16672 * @static 16673 * @memberOf _ 16674 * @since 3.0.0 16675 * @category Lang 16676 * @param {*} value The value to check. 16677 * @returns {boolean} Returns `true` if `value` is an error object, else `false`. 16678 * @example 16679 * 16680 * _.isError(new Error); 16681 * // => true 16682 * 16683 * _.isError(Error); 16684 * // => false 16685 */ 16686 function isError(value) { 16687 if (!isObjectLike(value)) { 16688 return false; 16689 } 16690 var tag = baseGetTag(value); 16691 return tag == errorTag || tag == domExcTag || 16692 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); 16693 } 16694 16695 /** 16696 * Checks if `value` is a finite primitive number. 16697 * 16698 * **Note:** This method is based on 16699 * [`Number.isFinite`](https://mdn.io/Number/isFinite). 16700 * 16701 * @static 16702 * @memberOf _ 16703 * @since 0.1.0 16704 * @category Lang 16705 * @param {*} value The value to check. 16706 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. 16707 * @example 16708 * 16709 * _.isFinite(3); 16710 * // => true 16711 * 16712 * _.isFinite(Number.MIN_VALUE); 16713 * // => true 16714 * 16715 * _.isFinite(Infinity); 16716 * // => false 16717 * 16718 * _.isFinite('3'); 16719 * // => false 16720 */ 16721 function isFinite(value) { 16722 return typeof value == 'number' && nativeIsFinite(value); 16723 } 16724 16725 /** 16726 * Checks if `value` is classified as a `Function` object. 16727 * 16728 * @static 16729 * @memberOf _ 16730 * @since 0.1.0 16731 * @category Lang 16732 * @param {*} value The value to check. 16733 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 16734 * @example 16735 * 16736 * _.isFunction(_); 16737 * // => true 16738 * 16739 * _.isFunction(/abc/); 16740 * // => false 16741 */ 16742 function isFunction(value) { 16743 if (!isObject(value)) { 16744 return false; 16745 } 16746 // The use of `Object#toString` avoids issues with the `typeof` operator 16747 // in Safari 9 which returns 'object' for typed arrays and other constructors. 16748 var tag = baseGetTag(value); 16749 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; 16750 } 16751 16752 /** 16753 * Checks if `value` is an integer. 16754 * 16755 * **Note:** This method is based on 16756 * [`Number.isInteger`](https://mdn.io/Number/isInteger). 16757 * 16758 * @static 16759 * @memberOf _ 16760 * @since 4.0.0 16761 * @category Lang 16762 * @param {*} value The value to check. 16763 * @returns {boolean} Returns `true` if `value` is an integer, else `false`. 16764 * @example 16765 * 16766 * _.isInteger(3); 16767 * // => true 16768 * 16769 * _.isInteger(Number.MIN_VALUE); 16770 * // => false 16771 * 16772 * _.isInteger(Infinity); 16773 * // => false 16774 * 16775 * _.isInteger('3'); 16776 * // => false 16777 */ 16778 function isInteger(value) { 16779 return typeof value == 'number' && value == toInteger(value); 16780 } 16781 16782 /** 16783 * Checks if `value` is a valid array-like length. 16784 * 16785 * **Note:** This method is loosely based on 16786 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 16787 * 16788 * @static 16789 * @memberOf _ 16790 * @since 4.0.0 16791 * @category Lang 16792 * @param {*} value The value to check. 16793 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 16794 * @example 16795 * 16796 * _.isLength(3); 16797 * // => true 16798 * 16799 * _.isLength(Number.MIN_VALUE); 16800 * // => false 16801 * 16802 * _.isLength(Infinity); 16803 * // => false 16804 * 16805 * _.isLength('3'); 16806 * // => false 16807 */ 16808 function isLength(value) { 16809 return typeof value == 'number' && 16810 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 16811 } 16812 16813 /** 16814 * Checks if `value` is the 16815 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 16816 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 16817 * 16818 * @static 16819 * @memberOf _ 16820 * @since 0.1.0 16821 * @category Lang 16822 * @param {*} value The value to check. 16823 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 16824 * @example 16825 * 16826 * _.isObject({}); 16827 * // => true 16828 * 16829 * _.isObject([1, 2, 3]); 16830 * // => true 16831 * 16832 * _.isObject(_.noop); 16833 * // => true 16834 * 16835 * _.isObject(null); 16836 * // => false 16837 */ 16838 function isObject(value) { 16839 var type = typeof value; 16840 return value != null && (type == 'object' || type == 'function'); 16841 } 16842 16843 /** 16844 * Checks if `value` is object-like. A value is object-like if it's not `null` 16845 * and has a `typeof` result of "object". 16846 * 16847 * @static 16848 * @memberOf _ 16849 * @since 4.0.0 16850 * @category Lang 16851 * @param {*} value The value to check. 16852 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 16853 * @example 16854 * 16855 * _.isObjectLike({}); 16856 * // => true 16857 * 16858 * _.isObjectLike([1, 2, 3]); 16859 * // => true 16860 * 16861 * _.isObjectLike(_.noop); 16862 * // => false 16863 * 16864 * _.isObjectLike(null); 16865 * // => false 16866 */ 16867 function isObjectLike(value) { 16868 return value != null && typeof value == 'object'; 16869 } 16870 16871 /** 16872 * Checks if `value` is classified as a `Map` object. 16873 * 16874 * @static 16875 * @memberOf _ 16876 * @since 4.3.0 16877 * @category Lang 16878 * @param {*} value The value to check. 16879 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 16880 * @example 16881 * 16882 * _.isMap(new Map); 16883 * // => true 16884 * 16885 * _.isMap(new WeakMap); 16886 * // => false 16887 */ 16888 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; 16889 16890 /** 16891 * Performs a partial deep comparison between `object` and `source` to 16892 * determine if `object` contains equivalent property values. 16893 * 16894 * **Note:** This method is equivalent to `_.matches` when `source` is 16895 * partially applied. 16896 * 16897 * Partial comparisons will match empty array and empty object `source` 16898 * values against any array or object value, respectively. See `_.isEqual` 16899 * for a list of supported value comparisons. 16900 * 16901 * @static 16902 * @memberOf _ 16903 * @since 3.0.0 16904 * @category Lang 16905 * @param {Object} object The object to inspect. 16906 * @param {Object} source The object of property values to match. 16907 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 16908 * @example 16909 * 16910 * var object = { 'a': 1, 'b': 2 }; 16911 * 16912 * _.isMatch(object, { 'b': 2 }); 16913 * // => true 16914 * 16915 * _.isMatch(object, { 'b': 1 }); 16916 * // => false 16917 */ 16918 function isMatch(object, source) { 16919 return object === source || baseIsMatch(object, source, getMatchData(source)); 16920 } 16921 16922 /** 16923 * This method is like `_.isMatch` except that it accepts `customizer` which 16924 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 16925 * are handled by the method instead. The `customizer` is invoked with five 16926 * arguments: (objValue, srcValue, index|key, object, source). 16927 * 16928 * @static 16929 * @memberOf _ 16930 * @since 4.0.0 16931 * @category Lang 16932 * @param {Object} object The object to inspect. 16933 * @param {Object} source The object of property values to match. 16934 * @param {Function} [customizer] The function to customize comparisons. 16935 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 16936 * @example 16937 * 16938 * function isGreeting(value) { 16939 * return /^h(?:i|ello)$/.test(value); 16940 * } 16941 * 16942 * function customizer(objValue, srcValue) { 16943 * if (isGreeting(objValue) && isGreeting(srcValue)) { 16944 * return true; 16945 * } 16946 * } 16947 * 16948 * var object = { 'greeting': 'hello' }; 16949 * var source = { 'greeting': 'hi' }; 16950 * 16951 * _.isMatchWith(object, source, customizer); 16952 * // => true 16953 */ 16954 function isMatchWith(object, source, customizer) { 16955 customizer = typeof customizer == 'function' ? customizer : undefined; 16956 return baseIsMatch(object, source, getMatchData(source), customizer); 16957 } 16958 16959 /** 16960 * Checks if `value` is `NaN`. 16961 * 16962 * **Note:** This method is based on 16963 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as 16964 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for 16965 * `undefined` and other non-number values. 16966 * 16967 * @static 16968 * @memberOf _ 16969 * @since 0.1.0 16970 * @category Lang 16971 * @param {*} value The value to check. 16972 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 16973 * @example 16974 * 16975 * _.isNaN(NaN); 16976 * // => true 16977 * 16978 * _.isNaN(new Number(NaN)); 16979 * // => true 16980 * 16981 * isNaN(undefined); 16982 * // => true 16983 * 16984 * _.isNaN(undefined); 16985 * // => false 16986 */ 16987 function isNaN(value) { 16988 // An `NaN` primitive is the only value that is not equal to itself. 16989 // Perform the `toStringTag` check first to avoid errors with some 16990 // ActiveX objects in IE. 16991 return isNumber(value) && value != +value; 16992 } 16993 16994 /** 16995 * Checks if `value` is a pristine native function. 16996 * 16997 * **Note:** This method can't reliably detect native functions in the presence 16998 * of the core-js package because core-js circumvents this kind of detection. 16999 * Despite multiple requests, the core-js maintainer has made it clear: any 17000 * attempt to fix the detection will be obstructed. As a result, we're left 17001 * with little choice but to throw an error. Unfortunately, this also affects 17002 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), 17003 * which rely on core-js. 17004 * 17005 * @static 17006 * @memberOf _ 17007 * @since 3.0.0 17008 * @category Lang 17009 * @param {*} value The value to check. 17010 * @returns {boolean} Returns `true` if `value` is a native function, 17011 * else `false`. 17012 * @example 17013 * 17014 * _.isNative(Array.prototype.push); 17015 * // => true 17016 * 17017 * _.isNative(_); 17018 * // => false 17019 */ 17020 function isNative(value) { 17021 if (isMaskable(value)) { 17022 throw new Error(CORE_ERROR_TEXT); 17023 } 17024 return baseIsNative(value); 17025 } 17026 17027 /** 17028 * Checks if `value` is `null`. 17029 * 17030 * @static 17031 * @memberOf _ 17032 * @since 0.1.0 17033 * @category Lang 17034 * @param {*} value The value to check. 17035 * @returns {boolean} Returns `true` if `value` is `null`, else `false`. 17036 * @example 17037 * 17038 * _.isNull(null); 17039 * // => true 17040 * 17041 * _.isNull(void 0); 17042 * // => false 17043 */ 17044 function isNull(value) { 17045 return value === null; 17046 } 17047 17048 /** 17049 * Checks if `value` is `null` or `undefined`. 17050 * 17051 * @static 17052 * @memberOf _ 17053 * @since 4.0.0 17054 * @category Lang 17055 * @param {*} value The value to check. 17056 * @returns {boolean} Returns `true` if `value` is nullish, else `false`. 17057 * @example 17058 * 17059 * _.isNil(null); 17060 * // => true 17061 * 17062 * _.isNil(void 0); 17063 * // => true 17064 * 17065 * _.isNil(NaN); 17066 * // => false 17067 */ 17068 function isNil(value) { 17069 return value == null; 17070 } 17071 17072 /** 17073 * Checks if `value` is classified as a `Number` primitive or object. 17074 * 17075 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are 17076 * classified as numbers, use the `_.isFinite` method. 17077 * 17078 * @static 17079 * @memberOf _ 17080 * @since 0.1.0 17081 * @category Lang 17082 * @param {*} value The value to check. 17083 * @returns {boolean} Returns `true` if `value` is a number, else `false`. 17084 * @example 17085 * 17086 * _.isNumber(3); 17087 * // => true 17088 * 17089 * _.isNumber(Number.MIN_VALUE); 17090 * // => true 17091 * 17092 * _.isNumber(Infinity); 17093 * // => true 17094 * 17095 * _.isNumber('3'); 17096 * // => false 17097 */ 17098 function isNumber(value) { 17099 return typeof value == 'number' || 17100 (isObjectLike(value) && baseGetTag(value) == numberTag); 17101 } 17102 17103 /** 17104 * Checks if `value` is a plain object, that is, an object created by the 17105 * `Object` constructor or one with a `[[Prototype]]` of `null`. 17106 * 17107 * @static 17108 * @memberOf _ 17109 * @since 0.8.0 17110 * @category Lang 17111 * @param {*} value The value to check. 17112 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 17113 * @example 17114 * 17115 * function Foo() { 17116 * this.a = 1; 17117 * } 17118 * 17119 * _.isPlainObject(new Foo); 17120 * // => false 17121 * 17122 * _.isPlainObject([1, 2, 3]); 17123 * // => false 17124 * 17125 * _.isPlainObject({ 'x': 0, 'y': 0 }); 17126 * // => true 17127 * 17128 * _.isPlainObject(Object.create(null)); 17129 * // => true 17130 */ 17131 function isPlainObject(value) { 17132 if (!isObjectLike(value) || baseGetTag(value) != objectTag) { 17133 return false; 17134 } 17135 var proto = getPrototype(value); 17136 if (proto === null) { 17137 return true; 17138 } 17139 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 17140 return typeof Ctor == 'function' && Ctor instanceof Ctor && 17141 funcToString.call(Ctor) == objectCtorString; 17142 } 17143 17144 /** 17145 * Checks if `value` is classified as a `RegExp` object. 17146 * 17147 * @static 17148 * @memberOf _ 17149 * @since 0.1.0 17150 * @category Lang 17151 * @param {*} value The value to check. 17152 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 17153 * @example 17154 * 17155 * _.isRegExp(/abc/); 17156 * // => true 17157 * 17158 * _.isRegExp('/abc/'); 17159 * // => false 17160 */ 17161 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; 17162 17163 /** 17164 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 17165 * double precision number which isn't the result of a rounded unsafe integer. 17166 * 17167 * **Note:** This method is based on 17168 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). 17169 * 17170 * @static 17171 * @memberOf _ 17172 * @since 4.0.0 17173 * @category Lang 17174 * @param {*} value The value to check. 17175 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. 17176 * @example 17177 * 17178 * _.isSafeInteger(3); 17179 * // => true 17180 * 17181 * _.isSafeInteger(Number.MIN_VALUE); 17182 * // => false 17183 * 17184 * _.isSafeInteger(Infinity); 17185 * // => false 17186 * 17187 * _.isSafeInteger('3'); 17188 * // => false 17189 */ 17190 function isSafeInteger(value) { 17191 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; 17192 } 17193 17194 /** 17195 * Checks if `value` is classified as a `Set` object. 17196 * 17197 * @static 17198 * @memberOf _ 17199 * @since 4.3.0 17200 * @category Lang 17201 * @param {*} value The value to check. 17202 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 17203 * @example 17204 * 17205 * _.isSet(new Set); 17206 * // => true 17207 * 17208 * _.isSet(new WeakSet); 17209 * // => false 17210 */ 17211 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; 17212 17213 /** 17214 * Checks if `value` is classified as a `String` primitive or object. 17215 * 17216 * @static 17217 * @since 0.1.0 17218 * @memberOf _ 17219 * @category Lang 17220 * @param {*} value The value to check. 17221 * @returns {boolean} Returns `true` if `value` is a string, else `false`. 17222 * @example 17223 * 17224 * _.isString('abc'); 17225 * // => true 17226 * 17227 * _.isString(1); 17228 * // => false 17229 */ 17230 function isString(value) { 17231 return typeof value == 'string' || 17232 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); 17233 } 17234 17235 /** 17236 * Checks if `value` is classified as a `Symbol` primitive or object. 17237 * 17238 * @static 17239 * @memberOf _ 17240 * @since 4.0.0 17241 * @category Lang 17242 * @param {*} value The value to check. 17243 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 17244 * @example 17245 * 17246 * _.isSymbol(Symbol.iterator); 17247 * // => true 17248 * 17249 * _.isSymbol('abc'); 17250 * // => false 17251 */ 17252 function isSymbol(value) { 17253 return typeof value == 'symbol' || 17254 (isObjectLike(value) && baseGetTag(value) == symbolTag); 17255 } 17256 17257 /** 17258 * Checks if `value` is classified as a typed array. 17259 * 17260 * @static 17261 * @memberOf _ 17262 * @since 3.0.0 17263 * @category Lang 17264 * @param {*} value The value to check. 17265 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 17266 * @example 17267 * 17268 * _.isTypedArray(new Uint8Array); 17269 * // => true 17270 * 17271 * _.isTypedArray([]); 17272 * // => false 17273 */ 17274 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; 17275 17276 /** 17277 * Checks if `value` is `undefined`. 17278 * 17279 * @static 17280 * @since 0.1.0 17281 * @memberOf _ 17282 * @category Lang 17283 * @param {*} value The value to check. 17284 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 17285 * @example 17286 * 17287 * _.isUndefined(void 0); 17288 * // => true 17289 * 17290 * _.isUndefined(null); 17291 * // => false 17292 */ 17293 function isUndefined(value) { 17294 return value === undefined; 17295 } 17296 17297 /** 17298 * Checks if `value` is classified as a `WeakMap` object. 17299 * 17300 * @static 17301 * @memberOf _ 17302 * @since 4.3.0 17303 * @category Lang 17304 * @param {*} value The value to check. 17305 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. 17306 * @example 17307 * 17308 * _.isWeakMap(new WeakMap); 17309 * // => true 17310 * 17311 * _.isWeakMap(new Map); 17312 * // => false 17313 */ 17314 function isWeakMap(value) { 17315 return isObjectLike(value) && getTag(value) == weakMapTag; 17316 } 17317 17318 /** 17319 * Checks if `value` is classified as a `WeakSet` object. 17320 * 17321 * @static 17322 * @memberOf _ 17323 * @since 4.3.0 17324 * @category Lang 17325 * @param {*} value The value to check. 17326 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. 17327 * @example 17328 * 17329 * _.isWeakSet(new WeakSet); 17330 * // => true 17331 * 17332 * _.isWeakSet(new Set); 17333 * // => false 17334 */ 17335 function isWeakSet(value) { 17336 return isObjectLike(value) && baseGetTag(value) == weakSetTag; 17337 } 17338 17339 /** 17340 * Checks if `value` is less than `other`. 17341 * 17342 * @static 17343 * @memberOf _ 17344 * @since 3.9.0 17345 * @category Lang 17346 * @param {*} value The value to compare. 17347 * @param {*} other The other value to compare. 17348 * @returns {boolean} Returns `true` if `value` is less than `other`, 17349 * else `false`. 17350 * @see _.gt 17351 * @example 17352 * 17353 * _.lt(1, 3); 17354 * // => true 17355 * 17356 * _.lt(3, 3); 17357 * // => false 17358 * 17359 * _.lt(3, 1); 17360 * // => false 17361 */ 17362 var lt = createRelationalOperation(baseLt); 17363 17364 /** 17365 * Checks if `value` is less than or equal to `other`. 17366 * 17367 * @static 17368 * @memberOf _ 17369 * @since 3.9.0 17370 * @category Lang 17371 * @param {*} value The value to compare. 17372 * @param {*} other The other value to compare. 17373 * @returns {boolean} Returns `true` if `value` is less than or equal to 17374 * `other`, else `false`. 17375 * @see _.gte 17376 * @example 17377 * 17378 * _.lte(1, 3); 17379 * // => true 17380 * 17381 * _.lte(3, 3); 17382 * // => true 17383 * 17384 * _.lte(3, 1); 17385 * // => false 17386 */ 17387 var lte = createRelationalOperation(function(value, other) { 17388 return value <= other; 17389 }); 17390 17391 /** 17392 * Converts `value` to an array. 17393 * 17394 * @static 17395 * @since 0.1.0 17396 * @memberOf _ 17397 * @category Lang 17398 * @param {*} value The value to convert. 17399 * @returns {Array} Returns the converted array. 17400 * @example 17401 * 17402 * _.toArray({ 'a': 1, 'b': 2 }); 17403 * // => [1, 2] 17404 * 17405 * _.toArray('abc'); 17406 * // => ['a', 'b', 'c'] 17407 * 17408 * _.toArray(1); 17409 * // => [] 17410 * 17411 * _.toArray(null); 17412 * // => [] 17413 */ 17414 function toArray(value) { 17415 if (!value) { 17416 return []; 17417 } 17418 if (isArrayLike(value)) { 17419 return isString(value) ? stringToArray(value) : copyArray(value); 17420 } 17421 if (symIterator && value[symIterator]) { 17422 return iteratorToArray(value[symIterator]()); 17423 } 17424 var tag = getTag(value), 17425 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); 17426 17427 return func(value); 17428 } 17429 17430 /** 17431 * Converts `value` to a finite number. 17432 * 17433 * @static 17434 * @memberOf _ 17435 * @since 4.12.0 17436 * @category Lang 17437 * @param {*} value The value to convert. 17438 * @returns {number} Returns the converted number. 17439 * @example 17440 * 17441 * _.toFinite(3.2); 17442 * // => 3.2 17443 * 17444 * _.toFinite(Number.MIN_VALUE); 17445 * // => 5e-324 17446 * 17447 * _.toFinite(Infinity); 17448 * // => 1.7976931348623157e+308 17449 * 17450 * _.toFinite('3.2'); 17451 * // => 3.2 17452 */ 17453 function toFinite(value) { 17454 if (!value) { 17455 return value === 0 ? value : 0; 17456 } 17457 value = toNumber(value); 17458 if (value === INFINITY || value === -INFINITY) { 17459 var sign = (value < 0 ? -1 : 1); 17460 return sign * MAX_INTEGER; 17461 } 17462 return value === value ? value : 0; 17463 } 17464 17465 /** 17466 * Converts `value` to an integer. 17467 * 17468 * **Note:** This method is loosely based on 17469 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). 17470 * 17471 * @static 17472 * @memberOf _ 17473 * @since 4.0.0 17474 * @category Lang 17475 * @param {*} value The value to convert. 17476 * @returns {number} Returns the converted integer. 17477 * @example 17478 * 17479 * _.toInteger(3.2); 17480 * // => 3 17481 * 17482 * _.toInteger(Number.MIN_VALUE); 17483 * // => 0 17484 * 17485 * _.toInteger(Infinity); 17486 * // => 1.7976931348623157e+308 17487 * 17488 * _.toInteger('3.2'); 17489 * // => 3 17490 */ 17491 function toInteger(value) { 17492 var result = toFinite(value), 17493 remainder = result % 1; 17494 17495 return result === result ? (remainder ? result - remainder : result) : 0; 17496 } 17497 17498 /** 17499 * Converts `value` to an integer suitable for use as the length of an 17500 * array-like object. 17501 * 17502 * **Note:** This method is based on 17503 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 17504 * 17505 * @static 17506 * @memberOf _ 17507 * @since 4.0.0 17508 * @category Lang 17509 * @param {*} value The value to convert. 17510 * @returns {number} Returns the converted integer. 17511 * @example 17512 * 17513 * _.toLength(3.2); 17514 * // => 3 17515 * 17516 * _.toLength(Number.MIN_VALUE); 17517 * // => 0 17518 * 17519 * _.toLength(Infinity); 17520 * // => 4294967295 17521 * 17522 * _.toLength('3.2'); 17523 * // => 3 17524 */ 17525 function toLength(value) { 17526 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; 17527 } 17528 17529 /** 17530 * Converts `value` to a number. 17531 * 17532 * @static 17533 * @memberOf _ 17534 * @since 4.0.0 17535 * @category Lang 17536 * @param {*} value The value to process. 17537 * @returns {number} Returns the number. 17538 * @example 17539 * 17540 * _.toNumber(3.2); 17541 * // => 3.2 17542 * 17543 * _.toNumber(Number.MIN_VALUE); 17544 * // => 5e-324 17545 * 17546 * _.toNumber(Infinity); 17547 * // => Infinity 17548 * 17549 * _.toNumber('3.2'); 17550 * // => 3.2 17551 */ 17552 function toNumber(value) { 17553 if (typeof value == 'number') { 17554 return value; 17555 } 17556 if (isSymbol(value)) { 17557 return NAN; 17558 } 17559 if (isObject(value)) { 17560 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 17561 value = isObject(other) ? (other + '') : other; 17562 } 17563 if (typeof value != 'string') { 17564 return value === 0 ? value : +value; 17565 } 17566 value = baseTrim(value); 17567 var isBinary = reIsBinary.test(value); 17568 return (isBinary || reIsOctal.test(value)) 17569 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 17570 : (reIsBadHex.test(value) ? NAN : +value); 17571 } 17572 17573 /** 17574 * Converts `value` to a plain object flattening inherited enumerable string 17575 * keyed properties of `value` to own properties of the plain object. 17576 * 17577 * @static 17578 * @memberOf _ 17579 * @since 3.0.0 17580 * @category Lang 17581 * @param {*} value The value to convert. 17582 * @returns {Object} Returns the converted plain object. 17583 * @example 17584 * 17585 * function Foo() { 17586 * this.b = 2; 17587 * } 17588 * 17589 * Foo.prototype.c = 3; 17590 * 17591 * _.assign({ 'a': 1 }, new Foo); 17592 * // => { 'a': 1, 'b': 2 } 17593 * 17594 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 17595 * // => { 'a': 1, 'b': 2, 'c': 3 } 17596 */ 17597 function toPlainObject(value) { 17598 return copyObject(value, keysIn(value)); 17599 } 17600 17601 /** 17602 * Converts `value` to a safe integer. A safe integer can be compared and 17603 * represented correctly. 17604 * 17605 * @static 17606 * @memberOf _ 17607 * @since 4.0.0 17608 * @category Lang 17609 * @param {*} value The value to convert. 17610 * @returns {number} Returns the converted integer. 17611 * @example 17612 * 17613 * _.toSafeInteger(3.2); 17614 * // => 3 17615 * 17616 * _.toSafeInteger(Number.MIN_VALUE); 17617 * // => 0 17618 * 17619 * _.toSafeInteger(Infinity); 17620 * // => 9007199254740991 17621 * 17622 * _.toSafeInteger('3.2'); 17623 * // => 3 17624 */ 17625 function toSafeInteger(value) { 17626 return value 17627 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) 17628 : (value === 0 ? value : 0); 17629 } 17630 17631 /** 17632 * Converts `value` to a string. An empty string is returned for `null` 17633 * and `undefined` values. The sign of `-0` is preserved. 17634 * 17635 * @static 17636 * @memberOf _ 17637 * @since 4.0.0 17638 * @category Lang 17639 * @param {*} value The value to convert. 17640 * @returns {string} Returns the converted string. 17641 * @example 17642 * 17643 * _.toString(null); 17644 * // => '' 17645 * 17646 * _.toString(-0); 17647 * // => '-0' 17648 * 17649 * _.toString([1, 2, 3]); 17650 * // => '1,2,3' 17651 */ 17652 function toString(value) { 17653 return value == null ? '' : baseToString(value); 17654 } 17655 17656 /*------------------------------------------------------------------------*/ 17657 17658 /** 17659 * Assigns own enumerable string keyed properties of source objects to the 17660 * destination object. Source objects are applied from left to right. 17661 * Subsequent sources overwrite property assignments of previous sources. 17662 * 17663 * **Note:** This method mutates `object` and is loosely based on 17664 * [`Object.assign`](https://mdn.io/Object/assign). 17665 * 17666 * @static 17667 * @memberOf _ 17668 * @since 0.10.0 17669 * @category Object 17670 * @param {Object} object The destination object. 17671 * @param {...Object} [sources] The source objects. 17672 * @returns {Object} Returns `object`. 17673 * @see _.assignIn 17674 * @example 17675 * 17676 * function Foo() { 17677 * this.a = 1; 17678 * } 17679 * 17680 * function Bar() { 17681 * this.c = 3; 17682 * } 17683 * 17684 * Foo.prototype.b = 2; 17685 * Bar.prototype.d = 4; 17686 * 17687 * _.assign({ 'a': 0 }, new Foo, new Bar); 17688 * // => { 'a': 1, 'c': 3 } 17689 */ 17690 var assign = createAssigner(function(object, source) { 17691 if (isPrototype(source) || isArrayLike(source)) { 17692 copyObject(source, keys(source), object); 17693 return; 17694 } 17695 for (var key in source) { 17696 if (hasOwnProperty.call(source, key)) { 17697 assignValue(object, key, source[key]); 17698 } 17699 } 17700 }); 17701 17702 /** 17703 * This method is like `_.assign` except that it iterates over own and 17704 * inherited source properties. 17705 * 17706 * **Note:** This method mutates `object`. 17707 * 17708 * @static 17709 * @memberOf _ 17710 * @since 4.0.0 17711 * @alias extend 17712 * @category Object 17713 * @param {Object} object The destination object. 17714 * @param {...Object} [sources] The source objects. 17715 * @returns {Object} Returns `object`. 17716 * @see _.assign 17717 * @example 17718 * 17719 * function Foo() { 17720 * this.a = 1; 17721 * } 17722 * 17723 * function Bar() { 17724 * this.c = 3; 17725 * } 17726 * 17727 * Foo.prototype.b = 2; 17728 * Bar.prototype.d = 4; 17729 * 17730 * _.assignIn({ 'a': 0 }, new Foo, new Bar); 17731 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } 17732 */ 17733 var assignIn = createAssigner(function(object, source) { 17734 copyObject(source, keysIn(source), object); 17735 }); 17736 17737 /** 17738 * This method is like `_.assignIn` except that it accepts `customizer` 17739 * which is invoked to produce the assigned values. If `customizer` returns 17740 * `undefined`, assignment is handled by the method instead. The `customizer` 17741 * is invoked with five arguments: (objValue, srcValue, key, object, source). 17742 * 17743 * **Note:** This method mutates `object`. 17744 * 17745 * @static 17746 * @memberOf _ 17747 * @since 4.0.0 17748 * @alias extendWith 17749 * @category Object 17750 * @param {Object} object The destination object. 17751 * @param {...Object} sources The source objects. 17752 * @param {Function} [customizer] The function to customize assigned values. 17753 * @returns {Object} Returns `object`. 17754 * @see _.assignWith 17755 * @example 17756 * 17757 * function customizer(objValue, srcValue) { 17758 * return _.isUndefined(objValue) ? srcValue : objValue; 17759 * } 17760 * 17761 * var defaults = _.partialRight(_.assignInWith, customizer); 17762 * 17763 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 17764 * // => { 'a': 1, 'b': 2 } 17765 */ 17766 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { 17767 copyObject(source, keysIn(source), object, customizer); 17768 }); 17769 17770 /** 17771 * This method is like `_.assign` except that it accepts `customizer` 17772 * which is invoked to produce the assigned values. If `customizer` returns 17773 * `undefined`, assignment is handled by the method instead. The `customizer` 17774 * is invoked with five arguments: (objValue, srcValue, key, object, source). 17775 * 17776 * **Note:** This method mutates `object`. 17777 * 17778 * @static 17779 * @memberOf _ 17780 * @since 4.0.0 17781 * @category Object 17782 * @param {Object} object The destination object. 17783 * @param {...Object} sources The source objects. 17784 * @param {Function} [customizer] The function to customize assigned values. 17785 * @returns {Object} Returns `object`. 17786 * @see _.assignInWith 17787 * @example 17788 * 17789 * function customizer(objValue, srcValue) { 17790 * return _.isUndefined(objValue) ? srcValue : objValue; 17791 * } 17792 * 17793 * var defaults = _.partialRight(_.assignWith, customizer); 17794 * 17795 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 17796 * // => { 'a': 1, 'b': 2 } 17797 */ 17798 var assignWith = createAssigner(function(object, source, srcIndex, customizer) { 17799 copyObject(source, keys(source), object, customizer); 17800 }); 17801 17802 /** 17803 * Creates an array of values corresponding to `paths` of `object`. 17804 * 17805 * @static 17806 * @memberOf _ 17807 * @since 1.0.0 17808 * @category Object 17809 * @param {Object} object The object to iterate over. 17810 * @param {...(string|string[])} [paths] The property paths to pick. 17811 * @returns {Array} Returns the picked values. 17812 * @example 17813 * 17814 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 17815 * 17816 * _.at(object, ['a[0].b.c', 'a[1]']); 17817 * // => [3, 4] 17818 */ 17819 var at = flatRest(baseAt); 17820 17821 /** 17822 * Creates an object that inherits from the `prototype` object. If a 17823 * `properties` object is given, its own enumerable string keyed properties 17824 * are assigned to the created object. 17825 * 17826 * @static 17827 * @memberOf _ 17828 * @since 2.3.0 17829 * @category Object 17830 * @param {Object} prototype The object to inherit from. 17831 * @param {Object} [properties] The properties to assign to the object. 17832 * @returns {Object} Returns the new object. 17833 * @example 17834 * 17835 * function Shape() { 17836 * this.x = 0; 17837 * this.y = 0; 17838 * } 17839 * 17840 * function Circle() { 17841 * Shape.call(this); 17842 * } 17843 * 17844 * Circle.prototype = _.create(Shape.prototype, { 17845 * 'constructor': Circle 17846 * }); 17847 * 17848 * var circle = new Circle; 17849 * circle instanceof Circle; 17850 * // => true 17851 * 17852 * circle instanceof Shape; 17853 * // => true 17854 */ 17855 function create(prototype, properties) { 17856 var result = baseCreate(prototype); 17857 return properties == null ? result : baseAssign(result, properties); 17858 } 17859 17860 /** 17861 * Assigns own and inherited enumerable string keyed properties of source 17862 * objects to the destination object for all destination properties that 17863 * resolve to `undefined`. Source objects are applied from left to right. 17864 * Once a property is set, additional values of the same property are ignored. 17865 * 17866 * **Note:** This method mutates `object`. 17867 * 17868 * @static 17869 * @since 0.1.0 17870 * @memberOf _ 17871 * @category Object 17872 * @param {Object} object The destination object. 17873 * @param {...Object} [sources] The source objects. 17874 * @returns {Object} Returns `object`. 17875 * @see _.defaultsDeep 17876 * @example 17877 * 17878 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 17879 * // => { 'a': 1, 'b': 2 } 17880 */ 17881 var defaults = baseRest(function(object, sources) { 17882 object = Object(object); 17883 17884 var index = -1; 17885 var length = sources.length; 17886 var guard = length > 2 ? sources[2] : undefined; 17887 17888 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 17889 length = 1; 17890 } 17891 17892 while (++index < length) { 17893 var source = sources[index]; 17894 var props = keysIn(source); 17895 var propsIndex = -1; 17896 var propsLength = props.length; 17897 17898 while (++propsIndex < propsLength) { 17899 var key = props[propsIndex]; 17900 var value = object[key]; 17901 17902 if (value === undefined || 17903 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { 17904 object[key] = source[key]; 17905 } 17906 } 17907 } 17908 17909 return object; 17910 }); 17911 17912 /** 17913 * This method is like `_.defaults` except that it recursively assigns 17914 * default properties. 17915 * 17916 * **Note:** This method mutates `object`. 17917 * 17918 * @static 17919 * @memberOf _ 17920 * @since 3.10.0 17921 * @category Object 17922 * @param {Object} object The destination object. 17923 * @param {...Object} [sources] The source objects. 17924 * @returns {Object} Returns `object`. 17925 * @see _.defaults 17926 * @example 17927 * 17928 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); 17929 * // => { 'a': { 'b': 2, 'c': 3 } } 17930 */ 17931 var defaultsDeep = baseRest(function(args) { 17932 args.push(undefined, customDefaultsMerge); 17933 return apply(mergeWith, undefined, args); 17934 }); 17935 17936 /** 17937 * This method is like `_.find` except that it returns the key of the first 17938 * element `predicate` returns truthy for instead of the element itself. 17939 * 17940 * @static 17941 * @memberOf _ 17942 * @since 1.1.0 17943 * @category Object 17944 * @param {Object} object The object to inspect. 17945 * @param {Function} [predicate=_.identity] The function invoked per iteration. 17946 * @returns {string|undefined} Returns the key of the matched element, 17947 * else `undefined`. 17948 * @example 17949 * 17950 * var users = { 17951 * 'barney': { 'age': 36, 'active': true }, 17952 * 'fred': { 'age': 40, 'active': false }, 17953 * 'pebbles': { 'age': 1, 'active': true } 17954 * }; 17955 * 17956 * _.findKey(users, function(o) { return o.age < 40; }); 17957 * // => 'barney' (iteration order is not guaranteed) 17958 * 17959 * // The `_.matches` iteratee shorthand. 17960 * _.findKey(users, { 'age': 1, 'active': true }); 17961 * // => 'pebbles' 17962 * 17963 * // The `_.matchesProperty` iteratee shorthand. 17964 * _.findKey(users, ['active', false]); 17965 * // => 'fred' 17966 * 17967 * // The `_.property` iteratee shorthand. 17968 * _.findKey(users, 'active'); 17969 * // => 'barney' 17970 */ 17971 function findKey(object, predicate) { 17972 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); 17973 } 17974 17975 /** 17976 * This method is like `_.findKey` except that it iterates over elements of 17977 * a collection in the opposite order. 17978 * 17979 * @static 17980 * @memberOf _ 17981 * @since 2.0.0 17982 * @category Object 17983 * @param {Object} object The object to inspect. 17984 * @param {Function} [predicate=_.identity] The function invoked per iteration. 17985 * @returns {string|undefined} Returns the key of the matched element, 17986 * else `undefined`. 17987 * @example 17988 * 17989 * var users = { 17990 * 'barney': { 'age': 36, 'active': true }, 17991 * 'fred': { 'age': 40, 'active': false }, 17992 * 'pebbles': { 'age': 1, 'active': true } 17993 * }; 17994 * 17995 * _.findLastKey(users, function(o) { return o.age < 40; }); 17996 * // => returns 'pebbles' assuming `_.findKey` returns 'barney' 17997 * 17998 * // The `_.matches` iteratee shorthand. 17999 * _.findLastKey(users, { 'age': 36, 'active': true }); 18000 * // => 'barney' 18001 * 18002 * // The `_.matchesProperty` iteratee shorthand. 18003 * _.findLastKey(users, ['active', false]); 18004 * // => 'fred' 18005 * 18006 * // The `_.property` iteratee shorthand. 18007 * _.findLastKey(users, 'active'); 18008 * // => 'pebbles' 18009 */ 18010 function findLastKey(object, predicate) { 18011 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); 18012 } 18013 18014 /** 18015 * Iterates over own and inherited enumerable string keyed properties of an 18016 * object and invokes `iteratee` for each property. The iteratee is invoked 18017 * with three arguments: (value, key, object). Iteratee functions may exit 18018 * iteration early by explicitly returning `false`. 18019 * 18020 * @static 18021 * @memberOf _ 18022 * @since 0.3.0 18023 * @category Object 18024 * @param {Object} object The object to iterate over. 18025 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18026 * @returns {Object} Returns `object`. 18027 * @see _.forInRight 18028 * @example 18029 * 18030 * function Foo() { 18031 * this.a = 1; 18032 * this.b = 2; 18033 * } 18034 * 18035 * Foo.prototype.c = 3; 18036 * 18037 * _.forIn(new Foo, function(value, key) { 18038 * console.log(key); 18039 * }); 18040 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). 18041 */ 18042 function forIn(object, iteratee) { 18043 return object == null 18044 ? object 18045 : baseFor(object, getIteratee(iteratee, 3), keysIn); 18046 } 18047 18048 /** 18049 * This method is like `_.forIn` except that it iterates over properties of 18050 * `object` in the opposite order. 18051 * 18052 * @static 18053 * @memberOf _ 18054 * @since 2.0.0 18055 * @category Object 18056 * @param {Object} object The object to iterate over. 18057 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18058 * @returns {Object} Returns `object`. 18059 * @see _.forIn 18060 * @example 18061 * 18062 * function Foo() { 18063 * this.a = 1; 18064 * this.b = 2; 18065 * } 18066 * 18067 * Foo.prototype.c = 3; 18068 * 18069 * _.forInRight(new Foo, function(value, key) { 18070 * console.log(key); 18071 * }); 18072 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. 18073 */ 18074 function forInRight(object, iteratee) { 18075 return object == null 18076 ? object 18077 : baseForRight(object, getIteratee(iteratee, 3), keysIn); 18078 } 18079 18080 /** 18081 * Iterates over own enumerable string keyed properties of an object and 18082 * invokes `iteratee` for each property. The iteratee is invoked with three 18083 * arguments: (value, key, object). Iteratee functions may exit iteration 18084 * early by explicitly returning `false`. 18085 * 18086 * @static 18087 * @memberOf _ 18088 * @since 0.3.0 18089 * @category Object 18090 * @param {Object} object The object to iterate over. 18091 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18092 * @returns {Object} Returns `object`. 18093 * @see _.forOwnRight 18094 * @example 18095 * 18096 * function Foo() { 18097 * this.a = 1; 18098 * this.b = 2; 18099 * } 18100 * 18101 * Foo.prototype.c = 3; 18102 * 18103 * _.forOwn(new Foo, function(value, key) { 18104 * console.log(key); 18105 * }); 18106 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 18107 */ 18108 function forOwn(object, iteratee) { 18109 return object && baseForOwn(object, getIteratee(iteratee, 3)); 18110 } 18111 18112 /** 18113 * This method is like `_.forOwn` except that it iterates over properties of 18114 * `object` in the opposite order. 18115 * 18116 * @static 18117 * @memberOf _ 18118 * @since 2.0.0 18119 * @category Object 18120 * @param {Object} object The object to iterate over. 18121 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18122 * @returns {Object} Returns `object`. 18123 * @see _.forOwn 18124 * @example 18125 * 18126 * function Foo() { 18127 * this.a = 1; 18128 * this.b = 2; 18129 * } 18130 * 18131 * Foo.prototype.c = 3; 18132 * 18133 * _.forOwnRight(new Foo, function(value, key) { 18134 * console.log(key); 18135 * }); 18136 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. 18137 */ 18138 function forOwnRight(object, iteratee) { 18139 return object && baseForOwnRight(object, getIteratee(iteratee, 3)); 18140 } 18141 18142 /** 18143 * Creates an array of function property names from own enumerable properties 18144 * of `object`. 18145 * 18146 * @static 18147 * @since 0.1.0 18148 * @memberOf _ 18149 * @category Object 18150 * @param {Object} object The object to inspect. 18151 * @returns {Array} Returns the function names. 18152 * @see _.functionsIn 18153 * @example 18154 * 18155 * function Foo() { 18156 * this.a = _.constant('a'); 18157 * this.b = _.constant('b'); 18158 * } 18159 * 18160 * Foo.prototype.c = _.constant('c'); 18161 * 18162 * _.functions(new Foo); 18163 * // => ['a', 'b'] 18164 */ 18165 function functions(object) { 18166 return object == null ? [] : baseFunctions(object, keys(object)); 18167 } 18168 18169 /** 18170 * Creates an array of function property names from own and inherited 18171 * enumerable properties of `object`. 18172 * 18173 * @static 18174 * @memberOf _ 18175 * @since 4.0.0 18176 * @category Object 18177 * @param {Object} object The object to inspect. 18178 * @returns {Array} Returns the function names. 18179 * @see _.functions 18180 * @example 18181 * 18182 * function Foo() { 18183 * this.a = _.constant('a'); 18184 * this.b = _.constant('b'); 18185 * } 18186 * 18187 * Foo.prototype.c = _.constant('c'); 18188 * 18189 * _.functionsIn(new Foo); 18190 * // => ['a', 'b', 'c'] 18191 */ 18192 function functionsIn(object) { 18193 return object == null ? [] : baseFunctions(object, keysIn(object)); 18194 } 18195 18196 /** 18197 * Gets the value at `path` of `object`. If the resolved value is 18198 * `undefined`, the `defaultValue` is returned in its place. 18199 * 18200 * @static 18201 * @memberOf _ 18202 * @since 3.7.0 18203 * @category Object 18204 * @param {Object} object The object to query. 18205 * @param {Array|string} path The path of the property to get. 18206 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 18207 * @returns {*} Returns the resolved value. 18208 * @example 18209 * 18210 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 18211 * 18212 * _.get(object, 'a[0].b.c'); 18213 * // => 3 18214 * 18215 * _.get(object, ['a', '0', 'b', 'c']); 18216 * // => 3 18217 * 18218 * _.get(object, 'a.b.c', 'default'); 18219 * // => 'default' 18220 */ 18221 function get(object, path, defaultValue) { 18222 var result = object == null ? undefined : baseGet(object, path); 18223 return result === undefined ? defaultValue : result; 18224 } 18225 18226 /** 18227 * Checks if `path` is a direct property of `object`. 18228 * 18229 * @static 18230 * @since 0.1.0 18231 * @memberOf _ 18232 * @category Object 18233 * @param {Object} object The object to query. 18234 * @param {Array|string} path The path to check. 18235 * @returns {boolean} Returns `true` if `path` exists, else `false`. 18236 * @example 18237 * 18238 * var object = { 'a': { 'b': 2 } }; 18239 * var other = _.create({ 'a': _.create({ 'b': 2 }) }); 18240 * 18241 * _.has(object, 'a'); 18242 * // => true 18243 * 18244 * _.has(object, 'a.b'); 18245 * // => true 18246 * 18247 * _.has(object, ['a', 'b']); 18248 * // => true 18249 * 18250 * _.has(other, 'a'); 18251 * // => false 18252 */ 18253 function has(object, path) { 18254 return object != null && hasPath(object, path, baseHas); 18255 } 18256 18257 /** 18258 * Checks if `path` is a direct or inherited property of `object`. 18259 * 18260 * @static 18261 * @memberOf _ 18262 * @since 4.0.0 18263 * @category Object 18264 * @param {Object} object The object to query. 18265 * @param {Array|string} path The path to check. 18266 * @returns {boolean} Returns `true` if `path` exists, else `false`. 18267 * @example 18268 * 18269 * var object = _.create({ 'a': _.create({ 'b': 2 }) }); 18270 * 18271 * _.hasIn(object, 'a'); 18272 * // => true 18273 * 18274 * _.hasIn(object, 'a.b'); 18275 * // => true 18276 * 18277 * _.hasIn(object, ['a', 'b']); 18278 * // => true 18279 * 18280 * _.hasIn(object, 'b'); 18281 * // => false 18282 */ 18283 function hasIn(object, path) { 18284 return object != null && hasPath(object, path, baseHasIn); 18285 } 18286 18287 /** 18288 * Creates an object composed of the inverted keys and values of `object`. 18289 * If `object` contains duplicate values, subsequent values overwrite 18290 * property assignments of previous values. 18291 * 18292 * @static 18293 * @memberOf _ 18294 * @since 0.7.0 18295 * @category Object 18296 * @param {Object} object The object to invert. 18297 * @returns {Object} Returns the new inverted object. 18298 * @example 18299 * 18300 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 18301 * 18302 * _.invert(object); 18303 * // => { '1': 'c', '2': 'b' } 18304 */ 18305 var invert = createInverter(function(result, value, key) { 18306 if (value != null && 18307 typeof value.toString != 'function') { 18308 value = nativeObjectToString.call(value); 18309 } 18310 18311 result[value] = key; 18312 }, constant(identity)); 18313 18314 /** 18315 * This method is like `_.invert` except that the inverted object is generated 18316 * from the results of running each element of `object` thru `iteratee`. The 18317 * corresponding inverted value of each inverted key is an array of keys 18318 * responsible for generating the inverted value. The iteratee is invoked 18319 * with one argument: (value). 18320 * 18321 * @static 18322 * @memberOf _ 18323 * @since 4.1.0 18324 * @category Object 18325 * @param {Object} object The object to invert. 18326 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18327 * @returns {Object} Returns the new inverted object. 18328 * @example 18329 * 18330 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 18331 * 18332 * _.invertBy(object); 18333 * // => { '1': ['a', 'c'], '2': ['b'] } 18334 * 18335 * _.invertBy(object, function(value) { 18336 * return 'group' + value; 18337 * }); 18338 * // => { 'group1': ['a', 'c'], 'group2': ['b'] } 18339 */ 18340 var invertBy = createInverter(function(result, value, key) { 18341 if (value != null && 18342 typeof value.toString != 'function') { 18343 value = nativeObjectToString.call(value); 18344 } 18345 18346 if (hasOwnProperty.call(result, value)) { 18347 result[value].push(key); 18348 } else { 18349 result[value] = [key]; 18350 } 18351 }, getIteratee); 18352 18353 /** 18354 * Invokes the method at `path` of `object`. 18355 * 18356 * @static 18357 * @memberOf _ 18358 * @since 4.0.0 18359 * @category Object 18360 * @param {Object} object The object to query. 18361 * @param {Array|string} path The path of the method to invoke. 18362 * @param {...*} [args] The arguments to invoke the method with. 18363 * @returns {*} Returns the result of the invoked method. 18364 * @example 18365 * 18366 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 18367 * 18368 * _.invoke(object, 'a[0].b.c.slice', 1, 3); 18369 * // => [2, 3] 18370 */ 18371 var invoke = baseRest(baseInvoke); 18372 18373 /** 18374 * Creates an array of the own enumerable property names of `object`. 18375 * 18376 * **Note:** Non-object values are coerced to objects. See the 18377 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 18378 * for more details. 18379 * 18380 * @static 18381 * @since 0.1.0 18382 * @memberOf _ 18383 * @category Object 18384 * @param {Object} object The object to query. 18385 * @returns {Array} Returns the array of property names. 18386 * @example 18387 * 18388 * function Foo() { 18389 * this.a = 1; 18390 * this.b = 2; 18391 * } 18392 * 18393 * Foo.prototype.c = 3; 18394 * 18395 * _.keys(new Foo); 18396 * // => ['a', 'b'] (iteration order is not guaranteed) 18397 * 18398 * _.keys('hi'); 18399 * // => ['0', '1'] 18400 */ 18401 function keys(object) { 18402 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); 18403 } 18404 18405 /** 18406 * Creates an array of the own and inherited enumerable property names of `object`. 18407 * 18408 * **Note:** Non-object values are coerced to objects. 18409 * 18410 * @static 18411 * @memberOf _ 18412 * @since 3.0.0 18413 * @category Object 18414 * @param {Object} object The object to query. 18415 * @returns {Array} Returns the array of property names. 18416 * @example 18417 * 18418 * function Foo() { 18419 * this.a = 1; 18420 * this.b = 2; 18421 * } 18422 * 18423 * Foo.prototype.c = 3; 18424 * 18425 * _.keysIn(new Foo); 18426 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 18427 */ 18428 function keysIn(object) { 18429 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); 18430 } 18431 18432 /** 18433 * The opposite of `_.mapValues`; this method creates an object with the 18434 * same values as `object` and keys generated by running each own enumerable 18435 * string keyed property of `object` thru `iteratee`. The iteratee is invoked 18436 * with three arguments: (value, key, object). 18437 * 18438 * @static 18439 * @memberOf _ 18440 * @since 3.8.0 18441 * @category Object 18442 * @param {Object} object The object to iterate over. 18443 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18444 * @returns {Object} Returns the new mapped object. 18445 * @see _.mapValues 18446 * @example 18447 * 18448 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 18449 * return key + value; 18450 * }); 18451 * // => { 'a1': 1, 'b2': 2 } 18452 */ 18453 function mapKeys(object, iteratee) { 18454 var result = {}; 18455 iteratee = getIteratee(iteratee, 3); 18456 18457 baseForOwn(object, function(value, key, object) { 18458 baseAssignValue(result, iteratee(value, key, object), value); 18459 }); 18460 return result; 18461 } 18462 18463 /** 18464 * Creates an object with the same keys as `object` and values generated 18465 * by running each own enumerable string keyed property of `object` thru 18466 * `iteratee`. The iteratee is invoked with three arguments: 18467 * (value, key, object). 18468 * 18469 * @static 18470 * @memberOf _ 18471 * @since 2.4.0 18472 * @category Object 18473 * @param {Object} object The object to iterate over. 18474 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18475 * @returns {Object} Returns the new mapped object. 18476 * @see _.mapKeys 18477 * @example 18478 * 18479 * var users = { 18480 * 'fred': { 'user': 'fred', 'age': 40 }, 18481 * 'pebbles': { 'user': 'pebbles', 'age': 1 } 18482 * }; 18483 * 18484 * _.mapValues(users, function(o) { return o.age; }); 18485 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 18486 * 18487 * // The `_.property` iteratee shorthand. 18488 * _.mapValues(users, 'age'); 18489 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 18490 */ 18491 function mapValues(object, iteratee) { 18492 var result = {}; 18493 iteratee = getIteratee(iteratee, 3); 18494 18495 baseForOwn(object, function(value, key, object) { 18496 baseAssignValue(result, key, iteratee(value, key, object)); 18497 }); 18498 return result; 18499 } 18500 18501 /** 18502 * This method is like `_.assign` except that it recursively merges own and 18503 * inherited enumerable string keyed properties of source objects into the 18504 * destination object. Source properties that resolve to `undefined` are 18505 * skipped if a destination value exists. Array and plain object properties 18506 * are merged recursively. Other objects and value types are overridden by 18507 * assignment. Source objects are applied from left to right. Subsequent 18508 * sources overwrite property assignments of previous sources. 18509 * 18510 * **Note:** This method mutates `object`. 18511 * 18512 * @static 18513 * @memberOf _ 18514 * @since 0.5.0 18515 * @category Object 18516 * @param {Object} object The destination object. 18517 * @param {...Object} [sources] The source objects. 18518 * @returns {Object} Returns `object`. 18519 * @example 18520 * 18521 * var object = { 18522 * 'a': [{ 'b': 2 }, { 'd': 4 }] 18523 * }; 18524 * 18525 * var other = { 18526 * 'a': [{ 'c': 3 }, { 'e': 5 }] 18527 * }; 18528 * 18529 * _.merge(object, other); 18530 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } 18531 */ 18532 var merge = createAssigner(function(object, source, srcIndex) { 18533 baseMerge(object, source, srcIndex); 18534 }); 18535 18536 /** 18537 * This method is like `_.merge` except that it accepts `customizer` which 18538 * is invoked to produce the merged values of the destination and source 18539 * properties. If `customizer` returns `undefined`, merging is handled by the 18540 * method instead. The `customizer` is invoked with six arguments: 18541 * (objValue, srcValue, key, object, source, stack). 18542 * 18543 * **Note:** This method mutates `object`. 18544 * 18545 * @static 18546 * @memberOf _ 18547 * @since 4.0.0 18548 * @category Object 18549 * @param {Object} object The destination object. 18550 * @param {...Object} sources The source objects. 18551 * @param {Function} customizer The function to customize assigned values. 18552 * @returns {Object} Returns `object`. 18553 * @example 18554 * 18555 * function customizer(objValue, srcValue) { 18556 * if (_.isArray(objValue)) { 18557 * return objValue.concat(srcValue); 18558 * } 18559 * } 18560 * 18561 * var object = { 'a': [1], 'b': [2] }; 18562 * var other = { 'a': [3], 'b': [4] }; 18563 * 18564 * _.mergeWith(object, other, customizer); 18565 * // => { 'a': [1, 3], 'b': [2, 4] } 18566 */ 18567 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { 18568 baseMerge(object, source, srcIndex, customizer); 18569 }); 18570 18571 /** 18572 * The opposite of `_.pick`; this method creates an object composed of the 18573 * own and inherited enumerable property paths of `object` that are not omitted. 18574 * 18575 * **Note:** This method is considerably slower than `_.pick`. 18576 * 18577 * @static 18578 * @since 0.1.0 18579 * @memberOf _ 18580 * @category Object 18581 * @param {Object} object The source object. 18582 * @param {...(string|string[])} [paths] The property paths to omit. 18583 * @returns {Object} Returns the new object. 18584 * @example 18585 * 18586 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 18587 * 18588 * _.omit(object, ['a', 'c']); 18589 * // => { 'b': '2' } 18590 */ 18591 var omit = flatRest(function(object, paths) { 18592 var result = {}; 18593 if (object == null) { 18594 return result; 18595 } 18596 var isDeep = false; 18597 paths = arrayMap(paths, function(path) { 18598 path = castPath(path, object); 18599 isDeep || (isDeep = path.length > 1); 18600 return path; 18601 }); 18602 copyObject(object, getAllKeysIn(object), result); 18603 if (isDeep) { 18604 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); 18605 } 18606 var length = paths.length; 18607 while (length--) { 18608 baseUnset(result, paths[length]); 18609 } 18610 return result; 18611 }); 18612 18613 /** 18614 * The opposite of `_.pickBy`; this method creates an object composed of 18615 * the own and inherited enumerable string keyed properties of `object` that 18616 * `predicate` doesn't return truthy for. The predicate is invoked with two 18617 * arguments: (value, key). 18618 * 18619 * @static 18620 * @memberOf _ 18621 * @since 4.0.0 18622 * @category Object 18623 * @param {Object} object The source object. 18624 * @param {Function} [predicate=_.identity] The function invoked per property. 18625 * @returns {Object} Returns the new object. 18626 * @example 18627 * 18628 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 18629 * 18630 * _.omitBy(object, _.isNumber); 18631 * // => { 'b': '2' } 18632 */ 18633 function omitBy(object, predicate) { 18634 return pickBy(object, negate(getIteratee(predicate))); 18635 } 18636 18637 /** 18638 * Creates an object composed of the picked `object` properties. 18639 * 18640 * @static 18641 * @since 0.1.0 18642 * @memberOf _ 18643 * @category Object 18644 * @param {Object} object The source object. 18645 * @param {...(string|string[])} [paths] The property paths to pick. 18646 * @returns {Object} Returns the new object. 18647 * @example 18648 * 18649 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 18650 * 18651 * _.pick(object, ['a', 'c']); 18652 * // => { 'a': 1, 'c': 3 } 18653 */ 18654 var pick = flatRest(function(object, paths) { 18655 return object == null ? {} : basePick(object, paths); 18656 }); 18657 18658 /** 18659 * Creates an object composed of the `object` properties `predicate` returns 18660 * truthy for. The predicate is invoked with two arguments: (value, key). 18661 * 18662 * @static 18663 * @memberOf _ 18664 * @since 4.0.0 18665 * @category Object 18666 * @param {Object} object The source object. 18667 * @param {Function} [predicate=_.identity] The function invoked per property. 18668 * @returns {Object} Returns the new object. 18669 * @example 18670 * 18671 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 18672 * 18673 * _.pickBy(object, _.isNumber); 18674 * // => { 'a': 1, 'c': 3 } 18675 */ 18676 function pickBy(object, predicate) { 18677 if (object == null) { 18678 return {}; 18679 } 18680 var props = arrayMap(getAllKeysIn(object), function(prop) { 18681 return [prop]; 18682 }); 18683 predicate = getIteratee(predicate); 18684 return basePickBy(object, props, function(value, path) { 18685 return predicate(value, path[0]); 18686 }); 18687 } 18688 18689 /** 18690 * This method is like `_.get` except that if the resolved value is a 18691 * function it's invoked with the `this` binding of its parent object and 18692 * its result is returned. 18693 * 18694 * @static 18695 * @since 0.1.0 18696 * @memberOf _ 18697 * @category Object 18698 * @param {Object} object The object to query. 18699 * @param {Array|string} path The path of the property to resolve. 18700 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 18701 * @returns {*} Returns the resolved value. 18702 * @example 18703 * 18704 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 18705 * 18706 * _.result(object, 'a[0].b.c1'); 18707 * // => 3 18708 * 18709 * _.result(object, 'a[0].b.c2'); 18710 * // => 4 18711 * 18712 * _.result(object, 'a[0].b.c3', 'default'); 18713 * // => 'default' 18714 * 18715 * _.result(object, 'a[0].b.c3', _.constant('default')); 18716 * // => 'default' 18717 */ 18718 function result(object, path, defaultValue) { 18719 path = castPath(path, object); 18720 18721 var index = -1, 18722 length = path.length; 18723 18724 // Ensure the loop is entered when path is empty. 18725 if (!length) { 18726 length = 1; 18727 object = undefined; 18728 } 18729 while (++index < length) { 18730 var value = object == null ? undefined : object[toKey(path[index])]; 18731 if (value === undefined) { 18732 index = length; 18733 value = defaultValue; 18734 } 18735 object = isFunction(value) ? value.call(object) : value; 18736 } 18737 return object; 18738 } 18739 18740 /** 18741 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, 18742 * it's created. Arrays are created for missing index properties while objects 18743 * are created for all other missing properties. Use `_.setWith` to customize 18744 * `path` creation. 18745 * 18746 * **Note:** This method mutates `object`. 18747 * 18748 * @static 18749 * @memberOf _ 18750 * @since 3.7.0 18751 * @category Object 18752 * @param {Object} object The object to modify. 18753 * @param {Array|string} path The path of the property to set. 18754 * @param {*} value The value to set. 18755 * @returns {Object} Returns `object`. 18756 * @example 18757 * 18758 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 18759 * 18760 * _.set(object, 'a[0].b.c', 4); 18761 * console.log(object.a[0].b.c); 18762 * // => 4 18763 * 18764 * _.set(object, ['x', '0', 'y', 'z'], 5); 18765 * console.log(object.x[0].y.z); 18766 * // => 5 18767 */ 18768 function set(object, path, value) { 18769 return object == null ? object : baseSet(object, path, value); 18770 } 18771 18772 /** 18773 * This method is like `_.set` except that it accepts `customizer` which is 18774 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 18775 * path creation is handled by the method instead. The `customizer` is invoked 18776 * with three arguments: (nsValue, key, nsObject). 18777 * 18778 * **Note:** This method mutates `object`. 18779 * 18780 * @static 18781 * @memberOf _ 18782 * @since 4.0.0 18783 * @category Object 18784 * @param {Object} object The object to modify. 18785 * @param {Array|string} path The path of the property to set. 18786 * @param {*} value The value to set. 18787 * @param {Function} [customizer] The function to customize assigned values. 18788 * @returns {Object} Returns `object`. 18789 * @example 18790 * 18791 * var object = {}; 18792 * 18793 * _.setWith(object, '[0][1]', 'a', Object); 18794 * // => { '0': { '1': 'a' } } 18795 */ 18796 function setWith(object, path, value, customizer) { 18797 customizer = typeof customizer == 'function' ? customizer : undefined; 18798 return object == null ? object : baseSet(object, path, value, customizer); 18799 } 18800 18801 /** 18802 * Creates an array of own enumerable string keyed-value pairs for `object` 18803 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its 18804 * entries are returned. 18805 * 18806 * @static 18807 * @memberOf _ 18808 * @since 4.0.0 18809 * @alias entries 18810 * @category Object 18811 * @param {Object} object The object to query. 18812 * @returns {Array} Returns the key-value pairs. 18813 * @example 18814 * 18815 * function Foo() { 18816 * this.a = 1; 18817 * this.b = 2; 18818 * } 18819 * 18820 * Foo.prototype.c = 3; 18821 * 18822 * _.toPairs(new Foo); 18823 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) 18824 */ 18825 var toPairs = createToPairs(keys); 18826 18827 /** 18828 * Creates an array of own and inherited enumerable string keyed-value pairs 18829 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map 18830 * or set, its entries are returned. 18831 * 18832 * @static 18833 * @memberOf _ 18834 * @since 4.0.0 18835 * @alias entriesIn 18836 * @category Object 18837 * @param {Object} object The object to query. 18838 * @returns {Array} Returns the key-value pairs. 18839 * @example 18840 * 18841 * function Foo() { 18842 * this.a = 1; 18843 * this.b = 2; 18844 * } 18845 * 18846 * Foo.prototype.c = 3; 18847 * 18848 * _.toPairsIn(new Foo); 18849 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) 18850 */ 18851 var toPairsIn = createToPairs(keysIn); 18852 18853 /** 18854 * An alternative to `_.reduce`; this method transforms `object` to a new 18855 * `accumulator` object which is the result of running each of its own 18856 * enumerable string keyed properties thru `iteratee`, with each invocation 18857 * potentially mutating the `accumulator` object. If `accumulator` is not 18858 * provided, a new object with the same `[[Prototype]]` will be used. The 18859 * iteratee is invoked with four arguments: (accumulator, value, key, object). 18860 * Iteratee functions may exit iteration early by explicitly returning `false`. 18861 * 18862 * @static 18863 * @memberOf _ 18864 * @since 1.3.0 18865 * @category Object 18866 * @param {Object} object The object to iterate over. 18867 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18868 * @param {*} [accumulator] The custom accumulator value. 18869 * @returns {*} Returns the accumulated value. 18870 * @example 18871 * 18872 * _.transform([2, 3, 4], function(result, n) { 18873 * result.push(n *= n); 18874 * return n % 2 == 0; 18875 * }, []); 18876 * // => [4, 9] 18877 * 18878 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 18879 * (result[value] || (result[value] = [])).push(key); 18880 * }, {}); 18881 * // => { '1': ['a', 'c'], '2': ['b'] } 18882 */ 18883 function transform(object, iteratee, accumulator) { 18884 var isArr = isArray(object), 18885 isArrLike = isArr || isBuffer(object) || isTypedArray(object); 18886 18887 iteratee = getIteratee(iteratee, 4); 18888 if (accumulator == null) { 18889 var Ctor = object && object.constructor; 18890 if (isArrLike) { 18891 accumulator = isArr ? new Ctor : []; 18892 } 18893 else if (isObject(object)) { 18894 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; 18895 } 18896 else { 18897 accumulator = {}; 18898 } 18899 } 18900 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { 18901 return iteratee(accumulator, value, index, object); 18902 }); 18903 return accumulator; 18904 } 18905 18906 /** 18907 * Removes the property at `path` of `object`. 18908 * 18909 * **Note:** This method mutates `object`. 18910 * 18911 * @static 18912 * @memberOf _ 18913 * @since 4.0.0 18914 * @category Object 18915 * @param {Object} object The object to modify. 18916 * @param {Array|string} path The path of the property to unset. 18917 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 18918 * @example 18919 * 18920 * var object = { 'a': [{ 'b': { 'c': 7 } }] }; 18921 * _.unset(object, 'a[0].b.c'); 18922 * // => true 18923 * 18924 * console.log(object); 18925 * // => { 'a': [{ 'b': {} }] }; 18926 * 18927 * _.unset(object, ['a', '0', 'b', 'c']); 18928 * // => true 18929 * 18930 * console.log(object); 18931 * // => { 'a': [{ 'b': {} }] }; 18932 */ 18933 function unset(object, path) { 18934 return object == null ? true : baseUnset(object, path); 18935 } 18936 18937 /** 18938 * This method is like `_.set` except that accepts `updater` to produce the 18939 * value to set. Use `_.updateWith` to customize `path` creation. The `updater` 18940 * is invoked with one argument: (value). 18941 * 18942 * **Note:** This method mutates `object`. 18943 * 18944 * @static 18945 * @memberOf _ 18946 * @since 4.6.0 18947 * @category Object 18948 * @param {Object} object The object to modify. 18949 * @param {Array|string} path The path of the property to set. 18950 * @param {Function} updater The function to produce the updated value. 18951 * @returns {Object} Returns `object`. 18952 * @example 18953 * 18954 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 18955 * 18956 * _.update(object, 'a[0].b.c', function(n) { return n * n; }); 18957 * console.log(object.a[0].b.c); 18958 * // => 9 18959 * 18960 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 18961 * console.log(object.x[0].y.z); 18962 * // => 0 18963 */ 18964 function update(object, path, updater) { 18965 return object == null ? object : baseUpdate(object, path, castFunction(updater)); 18966 } 18967 18968 /** 18969 * This method is like `_.update` except that it accepts `customizer` which is 18970 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 18971 * path creation is handled by the method instead. The `customizer` is invoked 18972 * with three arguments: (nsValue, key, nsObject). 18973 * 18974 * **Note:** This method mutates `object`. 18975 * 18976 * @static 18977 * @memberOf _ 18978 * @since 4.6.0 18979 * @category Object 18980 * @param {Object} object The object to modify. 18981 * @param {Array|string} path The path of the property to set. 18982 * @param {Function} updater The function to produce the updated value. 18983 * @param {Function} [customizer] The function to customize assigned values. 18984 * @returns {Object} Returns `object`. 18985 * @example 18986 * 18987 * var object = {}; 18988 * 18989 * _.updateWith(object, '[0][1]', _.constant('a'), Object); 18990 * // => { '0': { '1': 'a' } } 18991 */ 18992 function updateWith(object, path, updater, customizer) { 18993 customizer = typeof customizer == 'function' ? customizer : undefined; 18994 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); 18995 } 18996 18997 /** 18998 * Creates an array of the own enumerable string keyed property values of `object`. 18999 * 19000 * **Note:** Non-object values are coerced to objects. 19001 * 19002 * @static 19003 * @since 0.1.0 19004 * @memberOf _ 19005 * @category Object 19006 * @param {Object} object The object to query. 19007 * @returns {Array} Returns the array of property values. 19008 * @example 19009 * 19010 * function Foo() { 19011 * this.a = 1; 19012 * this.b = 2; 19013 * } 19014 * 19015 * Foo.prototype.c = 3; 19016 * 19017 * _.values(new Foo); 19018 * // => [1, 2] (iteration order is not guaranteed) 19019 * 19020 * _.values('hi'); 19021 * // => ['h', 'i'] 19022 */ 19023 function values(object) { 19024 return object == null ? [] : baseValues(object, keys(object)); 19025 } 19026 19027 /** 19028 * Creates an array of the own and inherited enumerable string keyed property 19029 * values of `object`. 19030 * 19031 * **Note:** Non-object values are coerced to objects. 19032 * 19033 * @static 19034 * @memberOf _ 19035 * @since 3.0.0 19036 * @category Object 19037 * @param {Object} object The object to query. 19038 * @returns {Array} Returns the array of property values. 19039 * @example 19040 * 19041 * function Foo() { 19042 * this.a = 1; 19043 * this.b = 2; 19044 * } 19045 * 19046 * Foo.prototype.c = 3; 19047 * 19048 * _.valuesIn(new Foo); 19049 * // => [1, 2, 3] (iteration order is not guaranteed) 19050 */ 19051 function valuesIn(object) { 19052 return object == null ? [] : baseValues(object, keysIn(object)); 19053 } 19054 19055 /*------------------------------------------------------------------------*/ 19056 19057 /** 19058 * Clamps `number` within the inclusive `lower` and `upper` bounds. 19059 * 19060 * @static 19061 * @memberOf _ 19062 * @since 4.0.0 19063 * @category Number 19064 * @param {number} number The number to clamp. 19065 * @param {number} [lower] The lower bound. 19066 * @param {number} upper The upper bound. 19067 * @returns {number} Returns the clamped number. 19068 * @example 19069 * 19070 * _.clamp(-10, -5, 5); 19071 * // => -5 19072 * 19073 * _.clamp(10, -5, 5); 19074 * // => 5 19075 */ 19076 function clamp(number, lower, upper) { 19077 if (upper === undefined) { 19078 upper = lower; 19079 lower = undefined; 19080 } 19081 if (upper !== undefined) { 19082 upper = toNumber(upper); 19083 upper = upper === upper ? upper : 0; 19084 } 19085 if (lower !== undefined) { 19086 lower = toNumber(lower); 19087 lower = lower === lower ? lower : 0; 19088 } 19089 return baseClamp(toNumber(number), lower, upper); 19090 } 19091 19092 /** 19093 * Checks if `n` is between `start` and up to, but not including, `end`. If 19094 * `end` is not specified, it's set to `start` with `start` then set to `0`. 19095 * If `start` is greater than `end` the params are swapped to support 19096 * negative ranges. 19097 * 19098 * @static 19099 * @memberOf _ 19100 * @since 3.3.0 19101 * @category Number 19102 * @param {number} number The number to check. 19103 * @param {number} [start=0] The start of the range. 19104 * @param {number} end The end of the range. 19105 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 19106 * @see _.range, _.rangeRight 19107 * @example 19108 * 19109 * _.inRange(3, 2, 4); 19110 * // => true 19111 * 19112 * _.inRange(4, 8); 19113 * // => true 19114 * 19115 * _.inRange(4, 2); 19116 * // => false 19117 * 19118 * _.inRange(2, 2); 19119 * // => false 19120 * 19121 * _.inRange(1.2, 2); 19122 * // => true 19123 * 19124 * _.inRange(5.2, 4); 19125 * // => false 19126 * 19127 * _.inRange(-3, -2, -6); 19128 * // => true 19129 */ 19130 function inRange(number, start, end) { 19131 start = toFinite(start); 19132 if (end === undefined) { 19133 end = start; 19134 start = 0; 19135 } else { 19136 end = toFinite(end); 19137 } 19138 number = toNumber(number); 19139 return baseInRange(number, start, end); 19140 } 19141 19142 /** 19143 * Produces a random number between the inclusive `lower` and `upper` bounds. 19144 * If only one argument is provided a number between `0` and the given number 19145 * is returned. If `floating` is `true`, or either `lower` or `upper` are 19146 * floats, a floating-point number is returned instead of an integer. 19147 * 19148 * **Note:** JavaScript follows the IEEE-754 standard for resolving 19149 * floating-point values which can produce unexpected results. 19150 * 19151 * @static 19152 * @memberOf _ 19153 * @since 0.7.0 19154 * @category Number 19155 * @param {number} [lower=0] The lower bound. 19156 * @param {number} [upper=1] The upper bound. 19157 * @param {boolean} [floating] Specify returning a floating-point number. 19158 * @returns {number} Returns the random number. 19159 * @example 19160 * 19161 * _.random(0, 5); 19162 * // => an integer between 0 and 5 19163 * 19164 * _.random(5); 19165 * // => also an integer between 0 and 5 19166 * 19167 * _.random(5, true); 19168 * // => a floating-point number between 0 and 5 19169 * 19170 * _.random(1.2, 5.2); 19171 * // => a floating-point number between 1.2 and 5.2 19172 */ 19173 function random(lower, upper, floating) { 19174 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { 19175 upper = floating = undefined; 19176 } 19177 if (floating === undefined) { 19178 if (typeof upper == 'boolean') { 19179 floating = upper; 19180 upper = undefined; 19181 } 19182 else if (typeof lower == 'boolean') { 19183 floating = lower; 19184 lower = undefined; 19185 } 19186 } 19187 if (lower === undefined && upper === undefined) { 19188 lower = 0; 19189 upper = 1; 19190 } 19191 else { 19192 lower = toFinite(lower); 19193 if (upper === undefined) { 19194 upper = lower; 19195 lower = 0; 19196 } else { 19197 upper = toFinite(upper); 19198 } 19199 } 19200 if (lower > upper) { 19201 var temp = lower; 19202 lower = upper; 19203 upper = temp; 19204 } 19205 if (floating || lower % 1 || upper % 1) { 19206 var rand = nativeRandom(); 19207 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); 19208 } 19209 return baseRandom(lower, upper); 19210 } 19211 19212 /*------------------------------------------------------------------------*/ 19213 19214 /** 19215 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 19216 * 19217 * @static 19218 * @memberOf _ 19219 * @since 3.0.0 19220 * @category String 19221 * @param {string} [string=''] The string to convert. 19222 * @returns {string} Returns the camel cased string. 19223 * @example 19224 * 19225 * _.camelCase('Foo Bar'); 19226 * // => 'fooBar' 19227 * 19228 * _.camelCase('--foo-bar--'); 19229 * // => 'fooBar' 19230 * 19231 * _.camelCase('__FOO_BAR__'); 19232 * // => 'fooBar' 19233 */ 19234 var camelCase = createCompounder(function(result, word, index) { 19235 word = word.toLowerCase(); 19236 return result + (index ? capitalize(word) : word); 19237 }); 19238 19239 /** 19240 * Converts the first character of `string` to upper case and the remaining 19241 * to lower case. 19242 * 19243 * @static 19244 * @memberOf _ 19245 * @since 3.0.0 19246 * @category String 19247 * @param {string} [string=''] The string to capitalize. 19248 * @returns {string} Returns the capitalized string. 19249 * @example 19250 * 19251 * _.capitalize('FRED'); 19252 * // => 'Fred' 19253 */ 19254 function capitalize(string) { 19255 return upperFirst(toString(string).toLowerCase()); 19256 } 19257 19258 /** 19259 * Deburrs `string` by converting 19260 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 19261 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 19262 * letters to basic Latin letters and removing 19263 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 19264 * 19265 * @static 19266 * @memberOf _ 19267 * @since 3.0.0 19268 * @category String 19269 * @param {string} [string=''] The string to deburr. 19270 * @returns {string} Returns the deburred string. 19271 * @example 19272 * 19273 * _.deburr('déjà vu'); 19274 * // => 'deja vu' 19275 */ 19276 function deburr(string) { 19277 string = toString(string); 19278 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); 19279 } 19280 19281 /** 19282 * Checks if `string` ends with the given target string. 19283 * 19284 * @static 19285 * @memberOf _ 19286 * @since 3.0.0 19287 * @category String 19288 * @param {string} [string=''] The string to inspect. 19289 * @param {string} [target] The string to search for. 19290 * @param {number} [position=string.length] The position to search up to. 19291 * @returns {boolean} Returns `true` if `string` ends with `target`, 19292 * else `false`. 19293 * @example 19294 * 19295 * _.endsWith('abc', 'c'); 19296 * // => true 19297 * 19298 * _.endsWith('abc', 'b'); 19299 * // => false 19300 * 19301 * _.endsWith('abc', 'b', 2); 19302 * // => true 19303 */ 19304 function endsWith(string, target, position) { 19305 string = toString(string); 19306 target = baseToString(target); 19307 19308 var length = string.length; 19309 position = position === undefined 19310 ? length 19311 : baseClamp(toInteger(position), 0, length); 19312 19313 var end = position; 19314 position -= target.length; 19315 return position >= 0 && string.slice(position, end) == target; 19316 } 19317 19318 /** 19319 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their 19320 * corresponding HTML entities. 19321 * 19322 * **Note:** No other characters are escaped. To escape additional 19323 * characters use a third-party library like [_he_](https://mths.be/he). 19324 * 19325 * Though the ">" character is escaped for symmetry, characters like 19326 * ">" and "/" don't need escaping in HTML and have no special meaning 19327 * unless they're part of a tag or unquoted attribute value. See 19328 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) 19329 * (under "semi-related fun fact") for more details. 19330 * 19331 * When working with HTML you should always 19332 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce 19333 * XSS vectors. 19334 * 19335 * @static 19336 * @since 0.1.0 19337 * @memberOf _ 19338 * @category String 19339 * @param {string} [string=''] The string to escape. 19340 * @returns {string} Returns the escaped string. 19341 * @example 19342 * 19343 * _.escape('fred, barney, & pebbles'); 19344 * // => 'fred, barney, & pebbles' 19345 */ 19346 function escape(string) { 19347 string = toString(string); 19348 return (string && reHasUnescapedHtml.test(string)) 19349 ? string.replace(reUnescapedHtml, escapeHtmlChar) 19350 : string; 19351 } 19352 19353 /** 19354 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", 19355 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. 19356 * 19357 * @static 19358 * @memberOf _ 19359 * @since 3.0.0 19360 * @category String 19361 * @param {string} [string=''] The string to escape. 19362 * @returns {string} Returns the escaped string. 19363 * @example 19364 * 19365 * _.escapeRegExp('[lodash](https://lodash.com/)'); 19366 * // => '\[lodash\]\(https://lodash\.com/\)' 19367 */ 19368 function escapeRegExp(string) { 19369 string = toString(string); 19370 return (string && reHasRegExpChar.test(string)) 19371 ? string.replace(reRegExpChar, '\\$&') 19372 : string; 19373 } 19374 19375 /** 19376 * Converts `string` to 19377 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 19378 * 19379 * @static 19380 * @memberOf _ 19381 * @since 3.0.0 19382 * @category String 19383 * @param {string} [string=''] The string to convert. 19384 * @returns {string} Returns the kebab cased string. 19385 * @example 19386 * 19387 * _.kebabCase('Foo Bar'); 19388 * // => 'foo-bar' 19389 * 19390 * _.kebabCase('fooBar'); 19391 * // => 'foo-bar' 19392 * 19393 * _.kebabCase('__FOO_BAR__'); 19394 * // => 'foo-bar' 19395 */ 19396 var kebabCase = createCompounder(function(result, word, index) { 19397 return result + (index ? '-' : '') + word.toLowerCase(); 19398 }); 19399 19400 /** 19401 * Converts `string`, as space separated words, to lower case. 19402 * 19403 * @static 19404 * @memberOf _ 19405 * @since 4.0.0 19406 * @category String 19407 * @param {string} [string=''] The string to convert. 19408 * @returns {string} Returns the lower cased string. 19409 * @example 19410 * 19411 * _.lowerCase('--Foo-Bar--'); 19412 * // => 'foo bar' 19413 * 19414 * _.lowerCase('fooBar'); 19415 * // => 'foo bar' 19416 * 19417 * _.lowerCase('__FOO_BAR__'); 19418 * // => 'foo bar' 19419 */ 19420 var lowerCase = createCompounder(function(result, word, index) { 19421 return result + (index ? ' ' : '') + word.toLowerCase(); 19422 }); 19423 19424 /** 19425 * Converts the first character of `string` to lower case. 19426 * 19427 * @static 19428 * @memberOf _ 19429 * @since 4.0.0 19430 * @category String 19431 * @param {string} [string=''] The string to convert. 19432 * @returns {string} Returns the converted string. 19433 * @example 19434 * 19435 * _.lowerFirst('Fred'); 19436 * // => 'fred' 19437 * 19438 * _.lowerFirst('FRED'); 19439 * // => 'fRED' 19440 */ 19441 var lowerFirst = createCaseFirst('toLowerCase'); 19442 19443 /** 19444 * Pads `string` on the left and right sides if it's shorter than `length`. 19445 * Padding characters are truncated if they can't be evenly divided by `length`. 19446 * 19447 * @static 19448 * @memberOf _ 19449 * @since 3.0.0 19450 * @category String 19451 * @param {string} [string=''] The string to pad. 19452 * @param {number} [length=0] The padding length. 19453 * @param {string} [chars=' '] The string used as padding. 19454 * @returns {string} Returns the padded string. 19455 * @example 19456 * 19457 * _.pad('abc', 8); 19458 * // => ' abc ' 19459 * 19460 * _.pad('abc', 8, '_-'); 19461 * // => '_-abc_-_' 19462 * 19463 * _.pad('abc', 3); 19464 * // => 'abc' 19465 */ 19466 function pad(string, length, chars) { 19467 string = toString(string); 19468 length = toInteger(length); 19469 19470 var strLength = length ? stringSize(string) : 0; 19471 if (!length || strLength >= length) { 19472 return string; 19473 } 19474 var mid = (length - strLength) / 2; 19475 return ( 19476 createPadding(nativeFloor(mid), chars) + 19477 string + 19478 createPadding(nativeCeil(mid), chars) 19479 ); 19480 } 19481 19482 /** 19483 * Pads `string` on the right side if it's shorter than `length`. Padding 19484 * characters are truncated if they exceed `length`. 19485 * 19486 * @static 19487 * @memberOf _ 19488 * @since 4.0.0 19489 * @category String 19490 * @param {string} [string=''] The string to pad. 19491 * @param {number} [length=0] The padding length. 19492 * @param {string} [chars=' '] The string used as padding. 19493 * @returns {string} Returns the padded string. 19494 * @example 19495 * 19496 * _.padEnd('abc', 6); 19497 * // => 'abc ' 19498 * 19499 * _.padEnd('abc', 6, '_-'); 19500 * // => 'abc_-_' 19501 * 19502 * _.padEnd('abc', 3); 19503 * // => 'abc' 19504 */ 19505 function padEnd(string, length, chars) { 19506 string = toString(string); 19507 length = toInteger(length); 19508 19509 var strLength = length ? stringSize(string) : 0; 19510 return (length && strLength < length) 19511 ? (string + createPadding(length - strLength, chars)) 19512 : string; 19513 } 19514 19515 /** 19516 * Pads `string` on the left side if it's shorter than `length`. Padding 19517 * characters are truncated if they exceed `length`. 19518 * 19519 * @static 19520 * @memberOf _ 19521 * @since 4.0.0 19522 * @category String 19523 * @param {string} [string=''] The string to pad. 19524 * @param {number} [length=0] The padding length. 19525 * @param {string} [chars=' '] The string used as padding. 19526 * @returns {string} Returns the padded string. 19527 * @example 19528 * 19529 * _.padStart('abc', 6); 19530 * // => ' abc' 19531 * 19532 * _.padStart('abc', 6, '_-'); 19533 * // => '_-_abc' 19534 * 19535 * _.padStart('abc', 3); 19536 * // => 'abc' 19537 */ 19538 function padStart(string, length, chars) { 19539 string = toString(string); 19540 length = toInteger(length); 19541 19542 var strLength = length ? stringSize(string) : 0; 19543 return (length && strLength < length) 19544 ? (createPadding(length - strLength, chars) + string) 19545 : string; 19546 } 19547 19548 /** 19549 * Converts `string` to an integer of the specified radix. If `radix` is 19550 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a 19551 * hexadecimal, in which case a `radix` of `16` is used. 19552 * 19553 * **Note:** This method aligns with the 19554 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. 19555 * 19556 * @static 19557 * @memberOf _ 19558 * @since 1.1.0 19559 * @category String 19560 * @param {string} string The string to convert. 19561 * @param {number} [radix=10] The radix to interpret `value` by. 19562 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 19563 * @returns {number} Returns the converted integer. 19564 * @example 19565 * 19566 * _.parseInt('08'); 19567 * // => 8 19568 * 19569 * _.map(['6', '08', '10'], _.parseInt); 19570 * // => [6, 8, 10] 19571 */ 19572 function parseInt(string, radix, guard) { 19573 if (guard || radix == null) { 19574 radix = 0; 19575 } else if (radix) { 19576 radix = +radix; 19577 } 19578 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); 19579 } 19580 19581 /** 19582 * Repeats the given string `n` times. 19583 * 19584 * @static 19585 * @memberOf _ 19586 * @since 3.0.0 19587 * @category String 19588 * @param {string} [string=''] The string to repeat. 19589 * @param {number} [n=1] The number of times to repeat the string. 19590 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 19591 * @returns {string} Returns the repeated string. 19592 * @example 19593 * 19594 * _.repeat('*', 3); 19595 * // => '***' 19596 * 19597 * _.repeat('abc', 2); 19598 * // => 'abcabc' 19599 * 19600 * _.repeat('abc', 0); 19601 * // => '' 19602 */ 19603 function repeat(string, n, guard) { 19604 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { 19605 n = 1; 19606 } else { 19607 n = toInteger(n); 19608 } 19609 return baseRepeat(toString(string), n); 19610 } 19611 19612 /** 19613 * Replaces matches for `pattern` in `string` with `replacement`. 19614 * 19615 * **Note:** This method is based on 19616 * [`String#replace`](https://mdn.io/String/replace). 19617 * 19618 * @static 19619 * @memberOf _ 19620 * @since 4.0.0 19621 * @category String 19622 * @param {string} [string=''] The string to modify. 19623 * @param {RegExp|string} pattern The pattern to replace. 19624 * @param {Function|string} replacement The match replacement. 19625 * @returns {string} Returns the modified string. 19626 * @example 19627 * 19628 * _.replace('Hi Fred', 'Fred', 'Barney'); 19629 * // => 'Hi Barney' 19630 */ 19631 function replace() { 19632 var args = arguments, 19633 string = toString(args[0]); 19634 19635 return args.length < 3 ? string : string.replace(args[1], args[2]); 19636 } 19637 19638 /** 19639 * Converts `string` to 19640 * [snake case](https://en.wikipedia.org/wiki/Snake_case). 19641 * 19642 * @static 19643 * @memberOf _ 19644 * @since 3.0.0 19645 * @category String 19646 * @param {string} [string=''] The string to convert. 19647 * @returns {string} Returns the snake cased string. 19648 * @example 19649 * 19650 * _.snakeCase('Foo Bar'); 19651 * // => 'foo_bar' 19652 * 19653 * _.snakeCase('fooBar'); 19654 * // => 'foo_bar' 19655 * 19656 * _.snakeCase('--FOO-BAR--'); 19657 * // => 'foo_bar' 19658 */ 19659 var snakeCase = createCompounder(function(result, word, index) { 19660 return result + (index ? '_' : '') + word.toLowerCase(); 19661 }); 19662 19663 /** 19664 * Splits `string` by `separator`. 19665 * 19666 * **Note:** This method is based on 19667 * [`String#split`](https://mdn.io/String/split). 19668 * 19669 * @static 19670 * @memberOf _ 19671 * @since 4.0.0 19672 * @category String 19673 * @param {string} [string=''] The string to split. 19674 * @param {RegExp|string} separator The separator pattern to split by. 19675 * @param {number} [limit] The length to truncate results to. 19676 * @returns {Array} Returns the string segments. 19677 * @example 19678 * 19679 * _.split('a-b-c', '-', 2); 19680 * // => ['a', 'b'] 19681 */ 19682 function split(string, separator, limit) { 19683 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { 19684 separator = limit = undefined; 19685 } 19686 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; 19687 if (!limit) { 19688 return []; 19689 } 19690 string = toString(string); 19691 if (string && ( 19692 typeof separator == 'string' || 19693 (separator != null && !isRegExp(separator)) 19694 )) { 19695 separator = baseToString(separator); 19696 if (!separator && hasUnicode(string)) { 19697 return castSlice(stringToArray(string), 0, limit); 19698 } 19699 } 19700 return string.split(separator, limit); 19701 } 19702 19703 /** 19704 * Converts `string` to 19705 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). 19706 * 19707 * @static 19708 * @memberOf _ 19709 * @since 3.1.0 19710 * @category String 19711 * @param {string} [string=''] The string to convert. 19712 * @returns {string} Returns the start cased string. 19713 * @example 19714 * 19715 * _.startCase('--foo-bar--'); 19716 * // => 'Foo Bar' 19717 * 19718 * _.startCase('fooBar'); 19719 * // => 'Foo Bar' 19720 * 19721 * _.startCase('__FOO_BAR__'); 19722 * // => 'FOO BAR' 19723 */ 19724 var startCase = createCompounder(function(result, word, index) { 19725 return result + (index ? ' ' : '') + upperFirst(word); 19726 }); 19727 19728 /** 19729 * Checks if `string` starts with the given target string. 19730 * 19731 * @static 19732 * @memberOf _ 19733 * @since 3.0.0 19734 * @category String 19735 * @param {string} [string=''] The string to inspect. 19736 * @param {string} [target] The string to search for. 19737 * @param {number} [position=0] The position to search from. 19738 * @returns {boolean} Returns `true` if `string` starts with `target`, 19739 * else `false`. 19740 * @example 19741 * 19742 * _.startsWith('abc', 'a'); 19743 * // => true 19744 * 19745 * _.startsWith('abc', 'b'); 19746 * // => false 19747 * 19748 * _.startsWith('abc', 'b', 1); 19749 * // => true 19750 */ 19751 function startsWith(string, target, position) { 19752 string = toString(string); 19753 position = position == null 19754 ? 0 19755 : baseClamp(toInteger(position), 0, string.length); 19756 19757 target = baseToString(target); 19758 return string.slice(position, position + target.length) == target; 19759 } 19760 19761 /** 19762 * Creates a compiled template function that can interpolate data properties 19763 * in "interpolate" delimiters, HTML-escape interpolated data properties in 19764 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data 19765 * properties may be accessed as free variables in the template. If a setting 19766 * object is given, it takes precedence over `_.templateSettings` values. 19767 * 19768 * **Note:** In the development build `_.template` utilizes 19769 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) 19770 * for easier debugging. 19771 * 19772 * For more information on precompiling templates see 19773 * [lodash's custom builds documentation](https://lodash.com/custom-builds). 19774 * 19775 * For more information on Chrome extension sandboxes see 19776 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). 19777 * 19778 * @static 19779 * @since 0.1.0 19780 * @memberOf _ 19781 * @category String 19782 * @param {string} [string=''] The template string. 19783 * @param {Object} [options={}] The options object. 19784 * @param {RegExp} [options.escape=_.templateSettings.escape] 19785 * The HTML "escape" delimiter. 19786 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] 19787 * The "evaluate" delimiter. 19788 * @param {Object} [options.imports=_.templateSettings.imports] 19789 * An object to import into the template as free variables. 19790 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] 19791 * The "interpolate" delimiter. 19792 * @param {string} [options.sourceURL='lodash.templateSources[n]'] 19793 * The sourceURL of the compiled template. 19794 * @param {string} [options.variable='obj'] 19795 * The data object variable name. 19796 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 19797 * @returns {Function} Returns the compiled template function. 19798 * @example 19799 * 19800 * // Use the "interpolate" delimiter to create a compiled template. 19801 * var compiled = _.template('hello <%= user %>!'); 19802 * compiled({ 'user': 'fred' }); 19803 * // => 'hello fred!' 19804 * 19805 * // Use the HTML "escape" delimiter to escape data property values. 19806 * var compiled = _.template('<b><%- value %></b>'); 19807 * compiled({ 'value': '<script>' }); 19808 * // => '<b><script></b>' 19809 * 19810 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. 19811 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); 19812 * compiled({ 'users': ['fred', 'barney'] }); 19813 * // => '<li>fred</li><li>barney</li>' 19814 * 19815 * // Use the internal `print` function in "evaluate" delimiters. 19816 * var compiled = _.template('<% print("hello " + user); %>!'); 19817 * compiled({ 'user': 'barney' }); 19818 * // => 'hello barney!' 19819 * 19820 * // Use the ES template literal delimiter as an "interpolate" delimiter. 19821 * // Disable support by replacing the "interpolate" delimiter. 19822 * var compiled = _.template('hello ${ user }!'); 19823 * compiled({ 'user': 'pebbles' }); 19824 * // => 'hello pebbles!' 19825 * 19826 * // Use backslashes to treat delimiters as plain text. 19827 * var compiled = _.template('<%= "\\<%- value %\\>" %>'); 19828 * compiled({ 'value': 'ignored' }); 19829 * // => '<%- value %>' 19830 * 19831 * // Use the `imports` option to import `jQuery` as `jq`. 19832 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; 19833 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); 19834 * compiled({ 'users': ['fred', 'barney'] }); 19835 * // => '<li>fred</li><li>barney</li>' 19836 * 19837 * // Use the `sourceURL` option to specify a custom sourceURL for the template. 19838 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); 19839 * compiled(data); 19840 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. 19841 * 19842 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. 19843 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); 19844 * compiled.source; 19845 * // => function(data) { 19846 * // var __t, __p = ''; 19847 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; 19848 * // return __p; 19849 * // } 19850 * 19851 * // Use custom template delimiters. 19852 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; 19853 * var compiled = _.template('hello {{ user }}!'); 19854 * compiled({ 'user': 'mustache' }); 19855 * // => 'hello mustache!' 19856 * 19857 * // Use the `source` property to inline compiled templates for meaningful 19858 * // line numbers in error messages and stack traces. 19859 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ 19860 * var JST = {\ 19861 * "main": ' + _.template(mainText).source + '\ 19862 * };\ 19863 * '); 19864 */ 19865 function template(string, options, guard) { 19866 // Based on John Resig's `tmpl` implementation 19867 // (http://ejohn.org/blog/javascript-micro-templating/) 19868 // and Laura Doktorova's doT.js (https://github.com/olado/doT). 19869 var settings = lodash.templateSettings; 19870 19871 if (guard && isIterateeCall(string, options, guard)) { 19872 options = undefined; 19873 } 19874 string = toString(string); 19875 options = assignInWith({}, options, settings, customDefaultsAssignIn); 19876 19877 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), 19878 importsKeys = keys(imports), 19879 importsValues = baseValues(imports, importsKeys); 19880 19881 var isEscaping, 19882 isEvaluating, 19883 index = 0, 19884 interpolate = options.interpolate || reNoMatch, 19885 source = "__p += '"; 19886 19887 // Compile the regexp to match each delimiter. 19888 var reDelimiters = RegExp( 19889 (options.escape || reNoMatch).source + '|' + 19890 interpolate.source + '|' + 19891 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + 19892 (options.evaluate || reNoMatch).source + '|$' 19893 , 'g'); 19894 19895 // Use a sourceURL for easier debugging. 19896 // The sourceURL gets injected into the source that's eval-ed, so be careful 19897 // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in 19898 // and escape the comment, thus injecting code that gets evaled. 19899 var sourceURL = '//# sourceURL=' + 19900 (hasOwnProperty.call(options, 'sourceURL') 19901 ? (options.sourceURL + '').replace(/\s/g, ' ') 19902 : ('lodash.templateSources[' + (++templateCounter) + ']') 19903 ) + '\n'; 19904 19905 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { 19906 interpolateValue || (interpolateValue = esTemplateValue); 19907 19908 // Escape characters that can't be included in string literals. 19909 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); 19910 19911 // Replace delimiters with snippets. 19912 if (escapeValue) { 19913 isEscaping = true; 19914 source += "' +\n__e(" + escapeValue + ") +\n'"; 19915 } 19916 if (evaluateValue) { 19917 isEvaluating = true; 19918 source += "';\n" + evaluateValue + ";\n__p += '"; 19919 } 19920 if (interpolateValue) { 19921 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; 19922 } 19923 index = offset + match.length; 19924 19925 // The JS engine embedded in Adobe products needs `match` returned in 19926 // order to produce the correct `offset` value. 19927 return match; 19928 }); 19929 19930 source += "';\n"; 19931 19932 // If `variable` is not specified wrap a with-statement around the generated 19933 // code to add the data object to the top of the scope chain. 19934 var variable = hasOwnProperty.call(options, 'variable') && options.variable; 19935 if (!variable) { 19936 source = 'with (obj) {\n' + source + '\n}\n'; 19937 } 19938 // Throw an error if a forbidden character was found in `variable`, to prevent 19939 // potential command injection attacks. 19940 else if (reForbiddenIdentifierChars.test(variable)) { 19941 throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT); 19942 } 19943 19944 // Cleanup code by stripping empty strings. 19945 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) 19946 .replace(reEmptyStringMiddle, '$1') 19947 .replace(reEmptyStringTrailing, '$1;'); 19948 19949 // Frame code as the function body. 19950 source = 'function(' + (variable || 'obj') + ') {\n' + 19951 (variable 19952 ? '' 19953 : 'obj || (obj = {});\n' 19954 ) + 19955 "var __t, __p = ''" + 19956 (isEscaping 19957 ? ', __e = _.escape' 19958 : '' 19959 ) + 19960 (isEvaluating 19961 ? ', __j = Array.prototype.join;\n' + 19962 "function print() { __p += __j.call(arguments, '') }\n" 19963 : ';\n' 19964 ) + 19965 source + 19966 'return __p\n}'; 19967 19968 var result = attempt(function() { 19969 return Function(importsKeys, sourceURL + 'return ' + source) 19970 .apply(undefined, importsValues); 19971 }); 19972 19973 // Provide the compiled function's source by its `toString` method or 19974 // the `source` property as a convenience for inlining compiled templates. 19975 result.source = source; 19976 if (isError(result)) { 19977 throw result; 19978 } 19979 return result; 19980 } 19981 19982 /** 19983 * Converts `string`, as a whole, to lower case just like 19984 * [String#toLowerCase](https://mdn.io/toLowerCase). 19985 * 19986 * @static 19987 * @memberOf _ 19988 * @since 4.0.0 19989 * @category String 19990 * @param {string} [string=''] The string to convert. 19991 * @returns {string} Returns the lower cased string. 19992 * @example 19993 * 19994 * _.toLower('--Foo-Bar--'); 19995 * // => '--foo-bar--' 19996 * 19997 * _.toLower('fooBar'); 19998 * // => 'foobar' 19999 * 20000 * _.toLower('__FOO_BAR__'); 20001 * // => '__foo_bar__' 20002 */ 20003 function toLower(value) { 20004 return toString(value).toLowerCase(); 20005 } 20006 20007 /** 20008 * Converts `string`, as a whole, to upper case just like 20009 * [String#toUpperCase](https://mdn.io/toUpperCase). 20010 * 20011 * @static 20012 * @memberOf _ 20013 * @since 4.0.0 20014 * @category String 20015 * @param {string} [string=''] The string to convert. 20016 * @returns {string} Returns the upper cased string. 20017 * @example 20018 * 20019 * _.toUpper('--foo-bar--'); 20020 * // => '--FOO-BAR--' 20021 * 20022 * _.toUpper('fooBar'); 20023 * // => 'FOOBAR' 20024 * 20025 * _.toUpper('__foo_bar__'); 20026 * // => '__FOO_BAR__' 20027 */ 20028 function toUpper(value) { 20029 return toString(value).toUpperCase(); 20030 } 20031 20032 /** 20033 * Removes leading and trailing whitespace or specified characters from `string`. 20034 * 20035 * @static 20036 * @memberOf _ 20037 * @since 3.0.0 20038 * @category String 20039 * @param {string} [string=''] The string to trim. 20040 * @param {string} [chars=whitespace] The characters to trim. 20041 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20042 * @returns {string} Returns the trimmed string. 20043 * @example 20044 * 20045 * _.trim(' abc '); 20046 * // => 'abc' 20047 * 20048 * _.trim('-_-abc-_-', '_-'); 20049 * // => 'abc' 20050 * 20051 * _.map([' foo ', ' bar '], _.trim); 20052 * // => ['foo', 'bar'] 20053 */ 20054 function trim(string, chars, guard) { 20055 string = toString(string); 20056 if (string && (guard || chars === undefined)) { 20057 return baseTrim(string); 20058 } 20059 if (!string || !(chars = baseToString(chars))) { 20060 return string; 20061 } 20062 var strSymbols = stringToArray(string), 20063 chrSymbols = stringToArray(chars), 20064 start = charsStartIndex(strSymbols, chrSymbols), 20065 end = charsEndIndex(strSymbols, chrSymbols) + 1; 20066 20067 return castSlice(strSymbols, start, end).join(''); 20068 } 20069 20070 /** 20071 * Removes trailing whitespace or specified characters from `string`. 20072 * 20073 * @static 20074 * @memberOf _ 20075 * @since 4.0.0 20076 * @category String 20077 * @param {string} [string=''] The string to trim. 20078 * @param {string} [chars=whitespace] The characters to trim. 20079 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20080 * @returns {string} Returns the trimmed string. 20081 * @example 20082 * 20083 * _.trimEnd(' abc '); 20084 * // => ' abc' 20085 * 20086 * _.trimEnd('-_-abc-_-', '_-'); 20087 * // => '-_-abc' 20088 */ 20089 function trimEnd(string, chars, guard) { 20090 string = toString(string); 20091 if (string && (guard || chars === undefined)) { 20092 return string.slice(0, trimmedEndIndex(string) + 1); 20093 } 20094 if (!string || !(chars = baseToString(chars))) { 20095 return string; 20096 } 20097 var strSymbols = stringToArray(string), 20098 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; 20099 20100 return castSlice(strSymbols, 0, end).join(''); 20101 } 20102 20103 /** 20104 * Removes leading whitespace or specified characters from `string`. 20105 * 20106 * @static 20107 * @memberOf _ 20108 * @since 4.0.0 20109 * @category String 20110 * @param {string} [string=''] The string to trim. 20111 * @param {string} [chars=whitespace] The characters to trim. 20112 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20113 * @returns {string} Returns the trimmed string. 20114 * @example 20115 * 20116 * _.trimStart(' abc '); 20117 * // => 'abc ' 20118 * 20119 * _.trimStart('-_-abc-_-', '_-'); 20120 * // => 'abc-_-' 20121 */ 20122 function trimStart(string, chars, guard) { 20123 string = toString(string); 20124 if (string && (guard || chars === undefined)) { 20125 return string.replace(reTrimStart, ''); 20126 } 20127 if (!string || !(chars = baseToString(chars))) { 20128 return string; 20129 } 20130 var strSymbols = stringToArray(string), 20131 start = charsStartIndex(strSymbols, stringToArray(chars)); 20132 20133 return castSlice(strSymbols, start).join(''); 20134 } 20135 20136 /** 20137 * Truncates `string` if it's longer than the given maximum string length. 20138 * The last characters of the truncated string are replaced with the omission 20139 * string which defaults to "...". 20140 * 20141 * @static 20142 * @memberOf _ 20143 * @since 4.0.0 20144 * @category String 20145 * @param {string} [string=''] The string to truncate. 20146 * @param {Object} [options={}] The options object. 20147 * @param {number} [options.length=30] The maximum string length. 20148 * @param {string} [options.omission='...'] The string to indicate text is omitted. 20149 * @param {RegExp|string} [options.separator] The separator pattern to truncate to. 20150 * @returns {string} Returns the truncated string. 20151 * @example 20152 * 20153 * _.truncate('hi-diddly-ho there, neighborino'); 20154 * // => 'hi-diddly-ho there, neighbo...' 20155 * 20156 * _.truncate('hi-diddly-ho there, neighborino', { 20157 * 'length': 24, 20158 * 'separator': ' ' 20159 * }); 20160 * // => 'hi-diddly-ho there,...' 20161 * 20162 * _.truncate('hi-diddly-ho there, neighborino', { 20163 * 'length': 24, 20164 * 'separator': /,? +/ 20165 * }); 20166 * // => 'hi-diddly-ho there...' 20167 * 20168 * _.truncate('hi-diddly-ho there, neighborino', { 20169 * 'omission': ' [...]' 20170 * }); 20171 * // => 'hi-diddly-ho there, neig [...]' 20172 */ 20173 function truncate(string, options) { 20174 var length = DEFAULT_TRUNC_LENGTH, 20175 omission = DEFAULT_TRUNC_OMISSION; 20176 20177 if (isObject(options)) { 20178 var separator = 'separator' in options ? options.separator : separator; 20179 length = 'length' in options ? toInteger(options.length) : length; 20180 omission = 'omission' in options ? baseToString(options.omission) : omission; 20181 } 20182 string = toString(string); 20183 20184 var strLength = string.length; 20185 if (hasUnicode(string)) { 20186 var strSymbols = stringToArray(string); 20187 strLength = strSymbols.length; 20188 } 20189 if (length >= strLength) { 20190 return string; 20191 } 20192 var end = length - stringSize(omission); 20193 if (end < 1) { 20194 return omission; 20195 } 20196 var result = strSymbols 20197 ? castSlice(strSymbols, 0, end).join('') 20198 : string.slice(0, end); 20199 20200 if (separator === undefined) { 20201 return result + omission; 20202 } 20203 if (strSymbols) { 20204 end += (result.length - end); 20205 } 20206 if (isRegExp(separator)) { 20207 if (string.slice(end).search(separator)) { 20208 var match, 20209 substring = result; 20210 20211 if (!separator.global) { 20212 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); 20213 } 20214 separator.lastIndex = 0; 20215 while ((match = separator.exec(substring))) { 20216 var newEnd = match.index; 20217 } 20218 result = result.slice(0, newEnd === undefined ? end : newEnd); 20219 } 20220 } else if (string.indexOf(baseToString(separator), end) != end) { 20221 var index = result.lastIndexOf(separator); 20222 if (index > -1) { 20223 result = result.slice(0, index); 20224 } 20225 } 20226 return result + omission; 20227 } 20228 20229 /** 20230 * The inverse of `_.escape`; this method converts the HTML entities 20231 * `&`, `<`, `>`, `"`, and `'` in `string` to 20232 * their corresponding characters. 20233 * 20234 * **Note:** No other HTML entities are unescaped. To unescape additional 20235 * HTML entities use a third-party library like [_he_](https://mths.be/he). 20236 * 20237 * @static 20238 * @memberOf _ 20239 * @since 0.6.0 20240 * @category String 20241 * @param {string} [string=''] The string to unescape. 20242 * @returns {string} Returns the unescaped string. 20243 * @example 20244 * 20245 * _.unescape('fred, barney, & pebbles'); 20246 * // => 'fred, barney, & pebbles' 20247 */ 20248 function unescape(string) { 20249 string = toString(string); 20250 return (string && reHasEscapedHtml.test(string)) 20251 ? string.replace(reEscapedHtml, unescapeHtmlChar) 20252 : string; 20253 } 20254 20255 /** 20256 * Converts `string`, as space separated words, to upper case. 20257 * 20258 * @static 20259 * @memberOf _ 20260 * @since 4.0.0 20261 * @category String 20262 * @param {string} [string=''] The string to convert. 20263 * @returns {string} Returns the upper cased string. 20264 * @example 20265 * 20266 * _.upperCase('--foo-bar'); 20267 * // => 'FOO BAR' 20268 * 20269 * _.upperCase('fooBar'); 20270 * // => 'FOO BAR' 20271 * 20272 * _.upperCase('__foo_bar__'); 20273 * // => 'FOO BAR' 20274 */ 20275 var upperCase = createCompounder(function(result, word, index) { 20276 return result + (index ? ' ' : '') + word.toUpperCase(); 20277 }); 20278 20279 /** 20280 * Converts the first character of `string` to upper case. 20281 * 20282 * @static 20283 * @memberOf _ 20284 * @since 4.0.0 20285 * @category String 20286 * @param {string} [string=''] The string to convert. 20287 * @returns {string} Returns the converted string. 20288 * @example 20289 * 20290 * _.upperFirst('fred'); 20291 * // => 'Fred' 20292 * 20293 * _.upperFirst('FRED'); 20294 * // => 'FRED' 20295 */ 20296 var upperFirst = createCaseFirst('toUpperCase'); 20297 20298 /** 20299 * Splits `string` into an array of its words. 20300 * 20301 * @static 20302 * @memberOf _ 20303 * @since 3.0.0 20304 * @category String 20305 * @param {string} [string=''] The string to inspect. 20306 * @param {RegExp|string} [pattern] The pattern to match words. 20307 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20308 * @returns {Array} Returns the words of `string`. 20309 * @example 20310 * 20311 * _.words('fred, barney, & pebbles'); 20312 * // => ['fred', 'barney', 'pebbles'] 20313 * 20314 * _.words('fred, barney, & pebbles', /[^, ]+/g); 20315 * // => ['fred', 'barney', '&', 'pebbles'] 20316 */ 20317 function words(string, pattern, guard) { 20318 string = toString(string); 20319 pattern = guard ? undefined : pattern; 20320 20321 if (pattern === undefined) { 20322 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 20323 } 20324 return string.match(pattern) || []; 20325 } 20326 20327 /*------------------------------------------------------------------------*/ 20328 20329 /** 20330 * Attempts to invoke `func`, returning either the result or the caught error 20331 * object. Any additional arguments are provided to `func` when it's invoked. 20332 * 20333 * @static 20334 * @memberOf _ 20335 * @since 3.0.0 20336 * @category Util 20337 * @param {Function} func The function to attempt. 20338 * @param {...*} [args] The arguments to invoke `func` with. 20339 * @returns {*} Returns the `func` result or error object. 20340 * @example 20341 * 20342 * // Avoid throwing errors for invalid selectors. 20343 * var elements = _.attempt(function(selector) { 20344 * return document.querySelectorAll(selector); 20345 * }, '>_>'); 20346 * 20347 * if (_.isError(elements)) { 20348 * elements = []; 20349 * } 20350 */ 20351 var attempt = baseRest(function(func, args) { 20352 try { 20353 return apply(func, undefined, args); 20354 } catch (e) { 20355 return isError(e) ? e : new Error(e); 20356 } 20357 }); 20358 20359 /** 20360 * Binds methods of an object to the object itself, overwriting the existing 20361 * method. 20362 * 20363 * **Note:** This method doesn't set the "length" property of bound functions. 20364 * 20365 * @static 20366 * @since 0.1.0 20367 * @memberOf _ 20368 * @category Util 20369 * @param {Object} object The object to bind and assign the bound methods to. 20370 * @param {...(string|string[])} methodNames The object method names to bind. 20371 * @returns {Object} Returns `object`. 20372 * @example 20373 * 20374 * var view = { 20375 * 'label': 'docs', 20376 * 'click': function() { 20377 * console.log('clicked ' + this.label); 20378 * } 20379 * }; 20380 * 20381 * _.bindAll(view, ['click']); 20382 * jQuery(element).on('click', view.click); 20383 * // => Logs 'clicked docs' when clicked. 20384 */ 20385 var bindAll = flatRest(function(object, methodNames) { 20386 arrayEach(methodNames, function(key) { 20387 key = toKey(key); 20388 baseAssignValue(object, key, bind(object[key], object)); 20389 }); 20390 return object; 20391 }); 20392 20393 /** 20394 * Creates a function that iterates over `pairs` and invokes the corresponding 20395 * function of the first predicate to return truthy. The predicate-function 20396 * pairs are invoked with the `this` binding and arguments of the created 20397 * function. 20398 * 20399 * @static 20400 * @memberOf _ 20401 * @since 4.0.0 20402 * @category Util 20403 * @param {Array} pairs The predicate-function pairs. 20404 * @returns {Function} Returns the new composite function. 20405 * @example 20406 * 20407 * var func = _.cond([ 20408 * [_.matches({ 'a': 1 }), _.constant('matches A')], 20409 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 20410 * [_.stubTrue, _.constant('no match')] 20411 * ]); 20412 * 20413 * func({ 'a': 1, 'b': 2 }); 20414 * // => 'matches A' 20415 * 20416 * func({ 'a': 0, 'b': 1 }); 20417 * // => 'matches B' 20418 * 20419 * func({ 'a': '1', 'b': '2' }); 20420 * // => 'no match' 20421 */ 20422 function cond(pairs) { 20423 var length = pairs == null ? 0 : pairs.length, 20424 toIteratee = getIteratee(); 20425 20426 pairs = !length ? [] : arrayMap(pairs, function(pair) { 20427 if (typeof pair[1] != 'function') { 20428 throw new TypeError(FUNC_ERROR_TEXT); 20429 } 20430 return [toIteratee(pair[0]), pair[1]]; 20431 }); 20432 20433 return baseRest(function(args) { 20434 var index = -1; 20435 while (++index < length) { 20436 var pair = pairs[index]; 20437 if (apply(pair[0], this, args)) { 20438 return apply(pair[1], this, args); 20439 } 20440 } 20441 }); 20442 } 20443 20444 /** 20445 * Creates a function that invokes the predicate properties of `source` with 20446 * the corresponding property values of a given object, returning `true` if 20447 * all predicates return truthy, else `false`. 20448 * 20449 * **Note:** The created function is equivalent to `_.conformsTo` with 20450 * `source` partially applied. 20451 * 20452 * @static 20453 * @memberOf _ 20454 * @since 4.0.0 20455 * @category Util 20456 * @param {Object} source The object of property predicates to conform to. 20457 * @returns {Function} Returns the new spec function. 20458 * @example 20459 * 20460 * var objects = [ 20461 * { 'a': 2, 'b': 1 }, 20462 * { 'a': 1, 'b': 2 } 20463 * ]; 20464 * 20465 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); 20466 * // => [{ 'a': 1, 'b': 2 }] 20467 */ 20468 function conforms(source) { 20469 return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); 20470 } 20471 20472 /** 20473 * Creates a function that returns `value`. 20474 * 20475 * @static 20476 * @memberOf _ 20477 * @since 2.4.0 20478 * @category Util 20479 * @param {*} value The value to return from the new function. 20480 * @returns {Function} Returns the new constant function. 20481 * @example 20482 * 20483 * var objects = _.times(2, _.constant({ 'a': 1 })); 20484 * 20485 * console.log(objects); 20486 * // => [{ 'a': 1 }, { 'a': 1 }] 20487 * 20488 * console.log(objects[0] === objects[1]); 20489 * // => true 20490 */ 20491 function constant(value) { 20492 return function() { 20493 return value; 20494 }; 20495 } 20496 20497 /** 20498 * Checks `value` to determine whether a default value should be returned in 20499 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, 20500 * or `undefined`. 20501 * 20502 * @static 20503 * @memberOf _ 20504 * @since 4.14.0 20505 * @category Util 20506 * @param {*} value The value to check. 20507 * @param {*} defaultValue The default value. 20508 * @returns {*} Returns the resolved value. 20509 * @example 20510 * 20511 * _.defaultTo(1, 10); 20512 * // => 1 20513 * 20514 * _.defaultTo(undefined, 10); 20515 * // => 10 20516 */ 20517 function defaultTo(value, defaultValue) { 20518 return (value == null || value !== value) ? defaultValue : value; 20519 } 20520 20521 /** 20522 * Creates a function that returns the result of invoking the given functions 20523 * with the `this` binding of the created function, where each successive 20524 * invocation is supplied the return value of the previous. 20525 * 20526 * @static 20527 * @memberOf _ 20528 * @since 3.0.0 20529 * @category Util 20530 * @param {...(Function|Function[])} [funcs] The functions to invoke. 20531 * @returns {Function} Returns the new composite function. 20532 * @see _.flowRight 20533 * @example 20534 * 20535 * function square(n) { 20536 * return n * n; 20537 * } 20538 * 20539 * var addSquare = _.flow([_.add, square]); 20540 * addSquare(1, 2); 20541 * // => 9 20542 */ 20543 var flow = createFlow(); 20544 20545 /** 20546 * This method is like `_.flow` except that it creates a function that 20547 * invokes the given functions from right to left. 20548 * 20549 * @static 20550 * @since 3.0.0 20551 * @memberOf _ 20552 * @category Util 20553 * @param {...(Function|Function[])} [funcs] The functions to invoke. 20554 * @returns {Function} Returns the new composite function. 20555 * @see _.flow 20556 * @example 20557 * 20558 * function square(n) { 20559 * return n * n; 20560 * } 20561 * 20562 * var addSquare = _.flowRight([square, _.add]); 20563 * addSquare(1, 2); 20564 * // => 9 20565 */ 20566 var flowRight = createFlow(true); 20567 20568 /** 20569 * This method returns the first argument it receives. 20570 * 20571 * @static 20572 * @since 0.1.0 20573 * @memberOf _ 20574 * @category Util 20575 * @param {*} value Any value. 20576 * @returns {*} Returns `value`. 20577 * @example 20578 * 20579 * var object = { 'a': 1 }; 20580 * 20581 * console.log(_.identity(object) === object); 20582 * // => true 20583 */ 20584 function identity(value) { 20585 return value; 20586 } 20587 20588 /** 20589 * Creates a function that invokes `func` with the arguments of the created 20590 * function. If `func` is a property name, the created function returns the 20591 * property value for a given element. If `func` is an array or object, the 20592 * created function returns `true` for elements that contain the equivalent 20593 * source properties, otherwise it returns `false`. 20594 * 20595 * @static 20596 * @since 4.0.0 20597 * @memberOf _ 20598 * @category Util 20599 * @param {*} [func=_.identity] The value to convert to a callback. 20600 * @returns {Function} Returns the callback. 20601 * @example 20602 * 20603 * var users = [ 20604 * { 'user': 'barney', 'age': 36, 'active': true }, 20605 * { 'user': 'fred', 'age': 40, 'active': false } 20606 * ]; 20607 * 20608 * // The `_.matches` iteratee shorthand. 20609 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 20610 * // => [{ 'user': 'barney', 'age': 36, 'active': true }] 20611 * 20612 * // The `_.matchesProperty` iteratee shorthand. 20613 * _.filter(users, _.iteratee(['user', 'fred'])); 20614 * // => [{ 'user': 'fred', 'age': 40 }] 20615 * 20616 * // The `_.property` iteratee shorthand. 20617 * _.map(users, _.iteratee('user')); 20618 * // => ['barney', 'fred'] 20619 * 20620 * // Create custom iteratee shorthands. 20621 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 20622 * return !_.isRegExp(func) ? iteratee(func) : function(string) { 20623 * return func.test(string); 20624 * }; 20625 * }); 20626 * 20627 * _.filter(['abc', 'def'], /ef/); 20628 * // => ['def'] 20629 */ 20630 function iteratee(func) { 20631 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); 20632 } 20633 20634 /** 20635 * Creates a function that performs a partial deep comparison between a given 20636 * object and `source`, returning `true` if the given object has equivalent 20637 * property values, else `false`. 20638 * 20639 * **Note:** The created function is equivalent to `_.isMatch` with `source` 20640 * partially applied. 20641 * 20642 * Partial comparisons will match empty array and empty object `source` 20643 * values against any array or object value, respectively. See `_.isEqual` 20644 * for a list of supported value comparisons. 20645 * 20646 * **Note:** Multiple values can be checked by combining several matchers 20647 * using `_.overSome` 20648 * 20649 * @static 20650 * @memberOf _ 20651 * @since 3.0.0 20652 * @category Util 20653 * @param {Object} source The object of property values to match. 20654 * @returns {Function} Returns the new spec function. 20655 * @example 20656 * 20657 * var objects = [ 20658 * { 'a': 1, 'b': 2, 'c': 3 }, 20659 * { 'a': 4, 'b': 5, 'c': 6 } 20660 * ]; 20661 * 20662 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); 20663 * // => [{ 'a': 4, 'b': 5, 'c': 6 }] 20664 * 20665 * // Checking for several possible values 20666 * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); 20667 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 20668 */ 20669 function matches(source) { 20670 return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); 20671 } 20672 20673 /** 20674 * Creates a function that performs a partial deep comparison between the 20675 * value at `path` of a given object to `srcValue`, returning `true` if the 20676 * object value is equivalent, else `false`. 20677 * 20678 * **Note:** Partial comparisons will match empty array and empty object 20679 * `srcValue` values against any array or object value, respectively. See 20680 * `_.isEqual` for a list of supported value comparisons. 20681 * 20682 * **Note:** Multiple values can be checked by combining several matchers 20683 * using `_.overSome` 20684 * 20685 * @static 20686 * @memberOf _ 20687 * @since 3.2.0 20688 * @category Util 20689 * @param {Array|string} path The path of the property to get. 20690 * @param {*} srcValue The value to match. 20691 * @returns {Function} Returns the new spec function. 20692 * @example 20693 * 20694 * var objects = [ 20695 * { 'a': 1, 'b': 2, 'c': 3 }, 20696 * { 'a': 4, 'b': 5, 'c': 6 } 20697 * ]; 20698 * 20699 * _.find(objects, _.matchesProperty('a', 4)); 20700 * // => { 'a': 4, 'b': 5, 'c': 6 } 20701 * 20702 * // Checking for several possible values 20703 * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); 20704 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 20705 */ 20706 function matchesProperty(path, srcValue) { 20707 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); 20708 } 20709 20710 /** 20711 * Creates a function that invokes the method at `path` of a given object. 20712 * Any additional arguments are provided to the invoked method. 20713 * 20714 * @static 20715 * @memberOf _ 20716 * @since 3.7.0 20717 * @category Util 20718 * @param {Array|string} path The path of the method to invoke. 20719 * @param {...*} [args] The arguments to invoke the method with. 20720 * @returns {Function} Returns the new invoker function. 20721 * @example 20722 * 20723 * var objects = [ 20724 * { 'a': { 'b': _.constant(2) } }, 20725 * { 'a': { 'b': _.constant(1) } } 20726 * ]; 20727 * 20728 * _.map(objects, _.method('a.b')); 20729 * // => [2, 1] 20730 * 20731 * _.map(objects, _.method(['a', 'b'])); 20732 * // => [2, 1] 20733 */ 20734 var method = baseRest(function(path, args) { 20735 return function(object) { 20736 return baseInvoke(object, path, args); 20737 }; 20738 }); 20739 20740 /** 20741 * The opposite of `_.method`; this method creates a function that invokes 20742 * the method at a given path of `object`. Any additional arguments are 20743 * provided to the invoked method. 20744 * 20745 * @static 20746 * @memberOf _ 20747 * @since 3.7.0 20748 * @category Util 20749 * @param {Object} object The object to query. 20750 * @param {...*} [args] The arguments to invoke the method with. 20751 * @returns {Function} Returns the new invoker function. 20752 * @example 20753 * 20754 * var array = _.times(3, _.constant), 20755 * object = { 'a': array, 'b': array, 'c': array }; 20756 * 20757 * _.map(['a[2]', 'c[0]'], _.methodOf(object)); 20758 * // => [2, 0] 20759 * 20760 * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); 20761 * // => [2, 0] 20762 */ 20763 var methodOf = baseRest(function(object, args) { 20764 return function(path) { 20765 return baseInvoke(object, path, args); 20766 }; 20767 }); 20768 20769 /** 20770 * Adds all own enumerable string keyed function properties of a source 20771 * object to the destination object. If `object` is a function, then methods 20772 * are added to its prototype as well. 20773 * 20774 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to 20775 * avoid conflicts caused by modifying the original. 20776 * 20777 * @static 20778 * @since 0.1.0 20779 * @memberOf _ 20780 * @category Util 20781 * @param {Function|Object} [object=lodash] The destination object. 20782 * @param {Object} source The object of functions to add. 20783 * @param {Object} [options={}] The options object. 20784 * @param {boolean} [options.chain=true] Specify whether mixins are chainable. 20785 * @returns {Function|Object} Returns `object`. 20786 * @example 20787 * 20788 * function vowels(string) { 20789 * return _.filter(string, function(v) { 20790 * return /[aeiou]/i.test(v); 20791 * }); 20792 * } 20793 * 20794 * _.mixin({ 'vowels': vowels }); 20795 * _.vowels('fred'); 20796 * // => ['e'] 20797 * 20798 * _('fred').vowels().value(); 20799 * // => ['e'] 20800 * 20801 * _.mixin({ 'vowels': vowels }, { 'chain': false }); 20802 * _('fred').vowels(); 20803 * // => ['e'] 20804 */ 20805 function mixin(object, source, options) { 20806 var props = keys(source), 20807 methodNames = baseFunctions(source, props); 20808 20809 if (options == null && 20810 !(isObject(source) && (methodNames.length || !props.length))) { 20811 options = source; 20812 source = object; 20813 object = this; 20814 methodNames = baseFunctions(source, keys(source)); 20815 } 20816 var chain = !(isObject(options) && 'chain' in options) || !!options.chain, 20817 isFunc = isFunction(object); 20818 20819 arrayEach(methodNames, function(methodName) { 20820 var func = source[methodName]; 20821 object[methodName] = func; 20822 if (isFunc) { 20823 object.prototype[methodName] = function() { 20824 var chainAll = this.__chain__; 20825 if (chain || chainAll) { 20826 var result = object(this.__wrapped__), 20827 actions = result.__actions__ = copyArray(this.__actions__); 20828 20829 actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); 20830 result.__chain__ = chainAll; 20831 return result; 20832 } 20833 return func.apply(object, arrayPush([this.value()], arguments)); 20834 }; 20835 } 20836 }); 20837 20838 return object; 20839 } 20840 20841 /** 20842 * Reverts the `_` variable to its previous value and returns a reference to 20843 * the `lodash` function. 20844 * 20845 * @static 20846 * @since 0.1.0 20847 * @memberOf _ 20848 * @category Util 20849 * @returns {Function} Returns the `lodash` function. 20850 * @example 20851 * 20852 * var lodash = _.noConflict(); 20853 */ 20854 function noConflict() { 20855 if (root._ === this) { 20856 root._ = oldDash; 20857 } 20858 return this; 20859 } 20860 20861 /** 20862 * This method returns `undefined`. 20863 * 20864 * @static 20865 * @memberOf _ 20866 * @since 2.3.0 20867 * @category Util 20868 * @example 20869 * 20870 * _.times(2, _.noop); 20871 * // => [undefined, undefined] 20872 */ 20873 function noop() { 20874 // No operation performed. 20875 } 20876 20877 /** 20878 * Creates a function that gets the argument at index `n`. If `n` is negative, 20879 * the nth argument from the end is returned. 20880 * 20881 * @static 20882 * @memberOf _ 20883 * @since 4.0.0 20884 * @category Util 20885 * @param {number} [n=0] The index of the argument to return. 20886 * @returns {Function} Returns the new pass-thru function. 20887 * @example 20888 * 20889 * var func = _.nthArg(1); 20890 * func('a', 'b', 'c', 'd'); 20891 * // => 'b' 20892 * 20893 * var func = _.nthArg(-2); 20894 * func('a', 'b', 'c', 'd'); 20895 * // => 'c' 20896 */ 20897 function nthArg(n) { 20898 n = toInteger(n); 20899 return baseRest(function(args) { 20900 return baseNth(args, n); 20901 }); 20902 } 20903 20904 /** 20905 * Creates a function that invokes `iteratees` with the arguments it receives 20906 * and returns their results. 20907 * 20908 * @static 20909 * @memberOf _ 20910 * @since 4.0.0 20911 * @category Util 20912 * @param {...(Function|Function[])} [iteratees=[_.identity]] 20913 * The iteratees to invoke. 20914 * @returns {Function} Returns the new function. 20915 * @example 20916 * 20917 * var func = _.over([Math.max, Math.min]); 20918 * 20919 * func(1, 2, 3, 4); 20920 * // => [4, 1] 20921 */ 20922 var over = createOver(arrayMap); 20923 20924 /** 20925 * Creates a function that checks if **all** of the `predicates` return 20926 * truthy when invoked with the arguments it receives. 20927 * 20928 * Following shorthands are possible for providing predicates. 20929 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 20930 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 20931 * 20932 * @static 20933 * @memberOf _ 20934 * @since 4.0.0 20935 * @category Util 20936 * @param {...(Function|Function[])} [predicates=[_.identity]] 20937 * The predicates to check. 20938 * @returns {Function} Returns the new function. 20939 * @example 20940 * 20941 * var func = _.overEvery([Boolean, isFinite]); 20942 * 20943 * func('1'); 20944 * // => true 20945 * 20946 * func(null); 20947 * // => false 20948 * 20949 * func(NaN); 20950 * // => false 20951 */ 20952 var overEvery = createOver(arrayEvery); 20953 20954 /** 20955 * Creates a function that checks if **any** of the `predicates` return 20956 * truthy when invoked with the arguments it receives. 20957 * 20958 * Following shorthands are possible for providing predicates. 20959 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 20960 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 20961 * 20962 * @static 20963 * @memberOf _ 20964 * @since 4.0.0 20965 * @category Util 20966 * @param {...(Function|Function[])} [predicates=[_.identity]] 20967 * The predicates to check. 20968 * @returns {Function} Returns the new function. 20969 * @example 20970 * 20971 * var func = _.overSome([Boolean, isFinite]); 20972 * 20973 * func('1'); 20974 * // => true 20975 * 20976 * func(null); 20977 * // => true 20978 * 20979 * func(NaN); 20980 * // => false 20981 * 20982 * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) 20983 * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) 20984 */ 20985 var overSome = createOver(arraySome); 20986 20987 /** 20988 * Creates a function that returns the value at `path` of a given object. 20989 * 20990 * @static 20991 * @memberOf _ 20992 * @since 2.4.0 20993 * @category Util 20994 * @param {Array|string} path The path of the property to get. 20995 * @returns {Function} Returns the new accessor function. 20996 * @example 20997 * 20998 * var objects = [ 20999 * { 'a': { 'b': 2 } }, 21000 * { 'a': { 'b': 1 } } 21001 * ]; 21002 * 21003 * _.map(objects, _.property('a.b')); 21004 * // => [2, 1] 21005 * 21006 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); 21007 * // => [1, 2] 21008 */ 21009 function property(path) { 21010 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); 21011 } 21012 21013 /** 21014 * The opposite of `_.property`; this method creates a function that returns 21015 * the value at a given path of `object`. 21016 * 21017 * @static 21018 * @memberOf _ 21019 * @since 3.0.0 21020 * @category Util 21021 * @param {Object} object The object to query. 21022 * @returns {Function} Returns the new accessor function. 21023 * @example 21024 * 21025 * var array = [0, 1, 2], 21026 * object = { 'a': array, 'b': array, 'c': array }; 21027 * 21028 * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); 21029 * // => [2, 0] 21030 * 21031 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); 21032 * // => [2, 0] 21033 */ 21034 function propertyOf(object) { 21035 return function(path) { 21036 return object == null ? undefined : baseGet(object, path); 21037 }; 21038 } 21039 21040 /** 21041 * Creates an array of numbers (positive and/or negative) progressing from 21042 * `start` up to, but not including, `end`. A step of `-1` is used if a negative 21043 * `start` is specified without an `end` or `step`. If `end` is not specified, 21044 * it's set to `start` with `start` then set to `0`. 21045 * 21046 * **Note:** JavaScript follows the IEEE-754 standard for resolving 21047 * floating-point values which can produce unexpected results. 21048 * 21049 * @static 21050 * @since 0.1.0 21051 * @memberOf _ 21052 * @category Util 21053 * @param {number} [start=0] The start of the range. 21054 * @param {number} end The end of the range. 21055 * @param {number} [step=1] The value to increment or decrement by. 21056 * @returns {Array} Returns the range of numbers. 21057 * @see _.inRange, _.rangeRight 21058 * @example 21059 * 21060 * _.range(4); 21061 * // => [0, 1, 2, 3] 21062 * 21063 * _.range(-4); 21064 * // => [0, -1, -2, -3] 21065 * 21066 * _.range(1, 5); 21067 * // => [1, 2, 3, 4] 21068 * 21069 * _.range(0, 20, 5); 21070 * // => [0, 5, 10, 15] 21071 * 21072 * _.range(0, -4, -1); 21073 * // => [0, -1, -2, -3] 21074 * 21075 * _.range(1, 4, 0); 21076 * // => [1, 1, 1] 21077 * 21078 * _.range(0); 21079 * // => [] 21080 */ 21081 var range = createRange(); 21082 21083 /** 21084 * This method is like `_.range` except that it populates values in 21085 * descending order. 21086 * 21087 * @static 21088 * @memberOf _ 21089 * @since 4.0.0 21090 * @category Util 21091 * @param {number} [start=0] The start of the range. 21092 * @param {number} end The end of the range. 21093 * @param {number} [step=1] The value to increment or decrement by. 21094 * @returns {Array} Returns the range of numbers. 21095 * @see _.inRange, _.range 21096 * @example 21097 * 21098 * _.rangeRight(4); 21099 * // => [3, 2, 1, 0] 21100 * 21101 * _.rangeRight(-4); 21102 * // => [-3, -2, -1, 0] 21103 * 21104 * _.rangeRight(1, 5); 21105 * // => [4, 3, 2, 1] 21106 * 21107 * _.rangeRight(0, 20, 5); 21108 * // => [15, 10, 5, 0] 21109 * 21110 * _.rangeRight(0, -4, -1); 21111 * // => [-3, -2, -1, 0] 21112 * 21113 * _.rangeRight(1, 4, 0); 21114 * // => [1, 1, 1] 21115 * 21116 * _.rangeRight(0); 21117 * // => [] 21118 */ 21119 var rangeRight = createRange(true); 21120 21121 /** 21122 * This method returns a new empty array. 21123 * 21124 * @static 21125 * @memberOf _ 21126 * @since 4.13.0 21127 * @category Util 21128 * @returns {Array} Returns the new empty array. 21129 * @example 21130 * 21131 * var arrays = _.times(2, _.stubArray); 21132 * 21133 * console.log(arrays); 21134 * // => [[], []] 21135 * 21136 * console.log(arrays[0] === arrays[1]); 21137 * // => false 21138 */ 21139 function stubArray() { 21140 return []; 21141 } 21142 21143 /** 21144 * This method returns `false`. 21145 * 21146 * @static 21147 * @memberOf _ 21148 * @since 4.13.0 21149 * @category Util 21150 * @returns {boolean} Returns `false`. 21151 * @example 21152 * 21153 * _.times(2, _.stubFalse); 21154 * // => [false, false] 21155 */ 21156 function stubFalse() { 21157 return false; 21158 } 21159 21160 /** 21161 * This method returns a new empty object. 21162 * 21163 * @static 21164 * @memberOf _ 21165 * @since 4.13.0 21166 * @category Util 21167 * @returns {Object} Returns the new empty object. 21168 * @example 21169 * 21170 * var objects = _.times(2, _.stubObject); 21171 * 21172 * console.log(objects); 21173 * // => [{}, {}] 21174 * 21175 * console.log(objects[0] === objects[1]); 21176 * // => false 21177 */ 21178 function stubObject() { 21179 return {}; 21180 } 21181 21182 /** 21183 * This method returns an empty string. 21184 * 21185 * @static 21186 * @memberOf _ 21187 * @since 4.13.0 21188 * @category Util 21189 * @returns {string} Returns the empty string. 21190 * @example 21191 * 21192 * _.times(2, _.stubString); 21193 * // => ['', ''] 21194 */ 21195 function stubString() { 21196 return ''; 21197 } 21198 21199 /** 21200 * This method returns `true`. 21201 * 21202 * @static 21203 * @memberOf _ 21204 * @since 4.13.0 21205 * @category Util 21206 * @returns {boolean} Returns `true`. 21207 * @example 21208 * 21209 * _.times(2, _.stubTrue); 21210 * // => [true, true] 21211 */ 21212 function stubTrue() { 21213 return true; 21214 } 21215 21216 /** 21217 * Invokes the iteratee `n` times, returning an array of the results of 21218 * each invocation. The iteratee is invoked with one argument; (index). 21219 * 21220 * @static 21221 * @since 0.1.0 21222 * @memberOf _ 21223 * @category Util 21224 * @param {number} n The number of times to invoke `iteratee`. 21225 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 21226 * @returns {Array} Returns the array of results. 21227 * @example 21228 * 21229 * _.times(3, String); 21230 * // => ['0', '1', '2'] 21231 * 21232 * _.times(4, _.constant(0)); 21233 * // => [0, 0, 0, 0] 21234 */ 21235 function times(n, iteratee) { 21236 n = toInteger(n); 21237 if (n < 1 || n > MAX_SAFE_INTEGER) { 21238 return []; 21239 } 21240 var index = MAX_ARRAY_LENGTH, 21241 length = nativeMin(n, MAX_ARRAY_LENGTH); 21242 21243 iteratee = getIteratee(iteratee); 21244 n -= MAX_ARRAY_LENGTH; 21245 21246 var result = baseTimes(length, iteratee); 21247 while (++index < n) { 21248 iteratee(index); 21249 } 21250 return result; 21251 } 21252 21253 /** 21254 * Converts `value` to a property path array. 21255 * 21256 * @static 21257 * @memberOf _ 21258 * @since 4.0.0 21259 * @category Util 21260 * @param {*} value The value to convert. 21261 * @returns {Array} Returns the new property path array. 21262 * @example 21263 * 21264 * _.toPath('a.b.c'); 21265 * // => ['a', 'b', 'c'] 21266 * 21267 * _.toPath('a[0].b.c'); 21268 * // => ['a', '0', 'b', 'c'] 21269 */ 21270 function toPath(value) { 21271 if (isArray(value)) { 21272 return arrayMap(value, toKey); 21273 } 21274 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); 21275 } 21276 21277 /** 21278 * Generates a unique ID. If `prefix` is given, the ID is appended to it. 21279 * 21280 * @static 21281 * @since 0.1.0 21282 * @memberOf _ 21283 * @category Util 21284 * @param {string} [prefix=''] The value to prefix the ID with. 21285 * @returns {string} Returns the unique ID. 21286 * @example 21287 * 21288 * _.uniqueId('contact_'); 21289 * // => 'contact_104' 21290 * 21291 * _.uniqueId(); 21292 * // => '105' 21293 */ 21294 function uniqueId(prefix) { 21295 var id = ++idCounter; 21296 return toString(prefix) + id; 21297 } 21298 21299 /*------------------------------------------------------------------------*/ 21300 21301 /** 21302 * Adds two numbers. 21303 * 21304 * @static 21305 * @memberOf _ 21306 * @since 3.4.0 21307 * @category Math 21308 * @param {number} augend The first number in an addition. 21309 * @param {number} addend The second number in an addition. 21310 * @returns {number} Returns the total. 21311 * @example 21312 * 21313 * _.add(6, 4); 21314 * // => 10 21315 */ 21316 var add = createMathOperation(function(augend, addend) { 21317 return augend + addend; 21318 }, 0); 21319 21320 /** 21321 * Computes `number` rounded up to `precision`. 21322 * 21323 * @static 21324 * @memberOf _ 21325 * @since 3.10.0 21326 * @category Math 21327 * @param {number} number The number to round up. 21328 * @param {number} [precision=0] The precision to round up to. 21329 * @returns {number} Returns the rounded up number. 21330 * @example 21331 * 21332 * _.ceil(4.006); 21333 * // => 5 21334 * 21335 * _.ceil(6.004, 2); 21336 * // => 6.01 21337 * 21338 * _.ceil(6040, -2); 21339 * // => 6100 21340 */ 21341 var ceil = createRound('ceil'); 21342 21343 /** 21344 * Divide two numbers. 21345 * 21346 * @static 21347 * @memberOf _ 21348 * @since 4.7.0 21349 * @category Math 21350 * @param {number} dividend The first number in a division. 21351 * @param {number} divisor The second number in a division. 21352 * @returns {number} Returns the quotient. 21353 * @example 21354 * 21355 * _.divide(6, 4); 21356 * // => 1.5 21357 */ 21358 var divide = createMathOperation(function(dividend, divisor) { 21359 return dividend / divisor; 21360 }, 1); 21361 21362 /** 21363 * Computes `number` rounded down to `precision`. 21364 * 21365 * @static 21366 * @memberOf _ 21367 * @since 3.10.0 21368 * @category Math 21369 * @param {number} number The number to round down. 21370 * @param {number} [precision=0] The precision to round down to. 21371 * @returns {number} Returns the rounded down number. 21372 * @example 21373 * 21374 * _.floor(4.006); 21375 * // => 4 21376 * 21377 * _.floor(0.046, 2); 21378 * // => 0.04 21379 * 21380 * _.floor(4060, -2); 21381 * // => 4000 21382 */ 21383 var floor = createRound('floor'); 21384 21385 /** 21386 * Computes the maximum value of `array`. If `array` is empty or falsey, 21387 * `undefined` is returned. 21388 * 21389 * @static 21390 * @since 0.1.0 21391 * @memberOf _ 21392 * @category Math 21393 * @param {Array} array The array to iterate over. 21394 * @returns {*} Returns the maximum value. 21395 * @example 21396 * 21397 * _.max([4, 2, 8, 6]); 21398 * // => 8 21399 * 21400 * _.max([]); 21401 * // => undefined 21402 */ 21403 function max(array) { 21404 return (array && array.length) 21405 ? baseExtremum(array, identity, baseGt) 21406 : undefined; 21407 } 21408 21409 /** 21410 * This method is like `_.max` except that it accepts `iteratee` which is 21411 * invoked for each element in `array` to generate the criterion by which 21412 * the value is ranked. The iteratee is invoked with one argument: (value). 21413 * 21414 * @static 21415 * @memberOf _ 21416 * @since 4.0.0 21417 * @category Math 21418 * @param {Array} array The array to iterate over. 21419 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 21420 * @returns {*} Returns the maximum value. 21421 * @example 21422 * 21423 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 21424 * 21425 * _.maxBy(objects, function(o) { return o.n; }); 21426 * // => { 'n': 2 } 21427 * 21428 * // The `_.property` iteratee shorthand. 21429 * _.maxBy(objects, 'n'); 21430 * // => { 'n': 2 } 21431 */ 21432 function maxBy(array, iteratee) { 21433 return (array && array.length) 21434 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) 21435 : undefined; 21436 } 21437 21438 /** 21439 * Computes the mean of the values in `array`. 21440 * 21441 * @static 21442 * @memberOf _ 21443 * @since 4.0.0 21444 * @category Math 21445 * @param {Array} array The array to iterate over. 21446 * @returns {number} Returns the mean. 21447 * @example 21448 * 21449 * _.mean([4, 2, 8, 6]); 21450 * // => 5 21451 */ 21452 function mean(array) { 21453 return baseMean(array, identity); 21454 } 21455 21456 /** 21457 * This method is like `_.mean` except that it accepts `iteratee` which is 21458 * invoked for each element in `array` to generate the value to be averaged. 21459 * The iteratee is invoked with one argument: (value). 21460 * 21461 * @static 21462 * @memberOf _ 21463 * @since 4.7.0 21464 * @category Math 21465 * @param {Array} array The array to iterate over. 21466 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 21467 * @returns {number} Returns the mean. 21468 * @example 21469 * 21470 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 21471 * 21472 * _.meanBy(objects, function(o) { return o.n; }); 21473 * // => 5 21474 * 21475 * // The `_.property` iteratee shorthand. 21476 * _.meanBy(objects, 'n'); 21477 * // => 5 21478 */ 21479 function meanBy(array, iteratee) { 21480 return baseMean(array, getIteratee(iteratee, 2)); 21481 } 21482 21483 /** 21484 * Computes the minimum value of `array`. If `array` is empty or falsey, 21485 * `undefined` is returned. 21486 * 21487 * @static 21488 * @since 0.1.0 21489 * @memberOf _ 21490 * @category Math 21491 * @param {Array} array The array to iterate over. 21492 * @returns {*} Returns the minimum value. 21493 * @example 21494 * 21495 * _.min([4, 2, 8, 6]); 21496 * // => 2 21497 * 21498 * _.min([]); 21499 * // => undefined 21500 */ 21501 function min(array) { 21502 return (array && array.length) 21503 ? baseExtremum(array, identity, baseLt) 21504 : undefined; 21505 } 21506 21507 /** 21508 * This method is like `_.min` except that it accepts `iteratee` which is 21509 * invoked for each element in `array` to generate the criterion by which 21510 * the value is ranked. The iteratee is invoked with one argument: (value). 21511 * 21512 * @static 21513 * @memberOf _ 21514 * @since 4.0.0 21515 * @category Math 21516 * @param {Array} array The array to iterate over. 21517 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 21518 * @returns {*} Returns the minimum value. 21519 * @example 21520 * 21521 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 21522 * 21523 * _.minBy(objects, function(o) { return o.n; }); 21524 * // => { 'n': 1 } 21525 * 21526 * // The `_.property` iteratee shorthand. 21527 * _.minBy(objects, 'n'); 21528 * // => { 'n': 1 } 21529 */ 21530 function minBy(array, iteratee) { 21531 return (array && array.length) 21532 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) 21533 : undefined; 21534 } 21535 21536 /** 21537 * Multiply two numbers. 21538 * 21539 * @static 21540 * @memberOf _ 21541 * @since 4.7.0 21542 * @category Math 21543 * @param {number} multiplier The first number in a multiplication. 21544 * @param {number} multiplicand The second number in a multiplication. 21545 * @returns {number} Returns the product. 21546 * @example 21547 * 21548 * _.multiply(6, 4); 21549 * // => 24 21550 */ 21551 var multiply = createMathOperation(function(multiplier, multiplicand) { 21552 return multiplier * multiplicand; 21553 }, 1); 21554 21555 /** 21556 * Computes `number` rounded to `precision`. 21557 * 21558 * @static 21559 * @memberOf _ 21560 * @since 3.10.0 21561 * @category Math 21562 * @param {number} number The number to round. 21563 * @param {number} [precision=0] The precision to round to. 21564 * @returns {number} Returns the rounded number. 21565 * @example 21566 * 21567 * _.round(4.006); 21568 * // => 4 21569 * 21570 * _.round(4.006, 2); 21571 * // => 4.01 21572 * 21573 * _.round(4060, -2); 21574 * // => 4100 21575 */ 21576 var round = createRound('round'); 21577 21578 /** 21579 * Subtract two numbers. 21580 * 21581 * @static 21582 * @memberOf _ 21583 * @since 4.0.0 21584 * @category Math 21585 * @param {number} minuend The first number in a subtraction. 21586 * @param {number} subtrahend The second number in a subtraction. 21587 * @returns {number} Returns the difference. 21588 * @example 21589 * 21590 * _.subtract(6, 4); 21591 * // => 2 21592 */ 21593 var subtract = createMathOperation(function(minuend, subtrahend) { 21594 return minuend - subtrahend; 21595 }, 0); 21596 21597 /** 21598 * Computes the sum of the values in `array`. 21599 * 21600 * @static 21601 * @memberOf _ 21602 * @since 3.4.0 21603 * @category Math 21604 * @param {Array} array The array to iterate over. 21605 * @returns {number} Returns the sum. 21606 * @example 21607 * 21608 * _.sum([4, 2, 8, 6]); 21609 * // => 20 21610 */ 21611 function sum(array) { 21612 return (array && array.length) 21613 ? baseSum(array, identity) 21614 : 0; 21615 } 21616 21617 /** 21618 * This method is like `_.sum` except that it accepts `iteratee` which is 21619 * invoked for each element in `array` to generate the value to be summed. 21620 * The iteratee is invoked with one argument: (value). 21621 * 21622 * @static 21623 * @memberOf _ 21624 * @since 4.0.0 21625 * @category Math 21626 * @param {Array} array The array to iterate over. 21627 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 21628 * @returns {number} Returns the sum. 21629 * @example 21630 * 21631 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 21632 * 21633 * _.sumBy(objects, function(o) { return o.n; }); 21634 * // => 20 21635 * 21636 * // The `_.property` iteratee shorthand. 21637 * _.sumBy(objects, 'n'); 21638 * // => 20 21639 */ 21640 function sumBy(array, iteratee) { 21641 return (array && array.length) 21642 ? baseSum(array, getIteratee(iteratee, 2)) 21643 : 0; 21644 } 21645 21646 /*------------------------------------------------------------------------*/ 21647 21648 // Add methods that return wrapped values in chain sequences. 21649 lodash.after = after; 21650 lodash.ary = ary; 21651 lodash.assign = assign; 21652 lodash.assignIn = assignIn; 21653 lodash.assignInWith = assignInWith; 21654 lodash.assignWith = assignWith; 21655 lodash.at = at; 21656 lodash.before = before; 21657 lodash.bind = bind; 21658 lodash.bindAll = bindAll; 21659 lodash.bindKey = bindKey; 21660 lodash.castArray = castArray; 21661 lodash.chain = chain; 21662 lodash.chunk = chunk; 21663 lodash.compact = compact; 21664 lodash.concat = concat; 21665 lodash.cond = cond; 21666 lodash.conforms = conforms; 21667 lodash.constant = constant; 21668 lodash.countBy = countBy; 21669 lodash.create = create; 21670 lodash.curry = curry; 21671 lodash.curryRight = curryRight; 21672 lodash.debounce = debounce; 21673 lodash.defaults = defaults; 21674 lodash.defaultsDeep = defaultsDeep; 21675 lodash.defer = defer; 21676 lodash.delay = delay; 21677 lodash.difference = difference; 21678 lodash.differenceBy = differenceBy; 21679 lodash.differenceWith = differenceWith; 21680 lodash.drop = drop; 21681 lodash.dropRight = dropRight; 21682 lodash.dropRightWhile = dropRightWhile; 21683 lodash.dropWhile = dropWhile; 21684 lodash.fill = fill; 21685 lodash.filter = filter; 21686 lodash.flatMap = flatMap; 21687 lodash.flatMapDeep = flatMapDeep; 21688 lodash.flatMapDepth = flatMapDepth; 21689 lodash.flatten = flatten; 21690 lodash.flattenDeep = flattenDeep; 21691 lodash.flattenDepth = flattenDepth; 21692 lodash.flip = flip; 21693 lodash.flow = flow; 21694 lodash.flowRight = flowRight; 21695 lodash.fromPairs = fromPairs; 21696 lodash.functions = functions; 21697 lodash.functionsIn = functionsIn; 21698 lodash.groupBy = groupBy; 21699 lodash.initial = initial; 21700 lodash.intersection = intersection; 21701 lodash.intersectionBy = intersectionBy; 21702 lodash.intersectionWith = intersectionWith; 21703 lodash.invert = invert; 21704 lodash.invertBy = invertBy; 21705 lodash.invokeMap = invokeMap; 21706 lodash.iteratee = iteratee; 21707 lodash.keyBy = keyBy; 21708 lodash.keys = keys; 21709 lodash.keysIn = keysIn; 21710 lodash.map = map; 21711 lodash.mapKeys = mapKeys; 21712 lodash.mapValues = mapValues; 21713 lodash.matches = matches; 21714 lodash.matchesProperty = matchesProperty; 21715 lodash.memoize = memoize; 21716 lodash.merge = merge; 21717 lodash.mergeWith = mergeWith; 21718 lodash.method = method; 21719 lodash.methodOf = methodOf; 21720 lodash.mixin = mixin; 21721 lodash.negate = negate; 21722 lodash.nthArg = nthArg; 21723 lodash.omit = omit; 21724 lodash.omitBy = omitBy; 21725 lodash.once = once; 21726 lodash.orderBy = orderBy; 21727 lodash.over = over; 21728 lodash.overArgs = overArgs; 21729 lodash.overEvery = overEvery; 21730 lodash.overSome = overSome; 21731 lodash.partial = partial; 21732 lodash.partialRight = partialRight; 21733 lodash.partition = partition; 21734 lodash.pick = pick; 21735 lodash.pickBy = pickBy; 21736 lodash.property = property; 21737 lodash.propertyOf = propertyOf; 21738 lodash.pull = pull; 21739 lodash.pullAll = pullAll; 21740 lodash.pullAllBy = pullAllBy; 21741 lodash.pullAllWith = pullAllWith; 21742 lodash.pullAt = pullAt; 21743 lodash.range = range; 21744 lodash.rangeRight = rangeRight; 21745 lodash.rearg = rearg; 21746 lodash.reject = reject; 21747 lodash.remove = remove; 21748 lodash.rest = rest; 21749 lodash.reverse = reverse; 21750 lodash.sampleSize = sampleSize; 21751 lodash.set = set; 21752 lodash.setWith = setWith; 21753 lodash.shuffle = shuffle; 21754 lodash.slice = slice; 21755 lodash.sortBy = sortBy; 21756 lodash.sortedUniq = sortedUniq; 21757 lodash.sortedUniqBy = sortedUniqBy; 21758 lodash.split = split; 21759 lodash.spread = spread; 21760 lodash.tail = tail; 21761 lodash.take = take; 21762 lodash.takeRight = takeRight; 21763 lodash.takeRightWhile = takeRightWhile; 21764 lodash.takeWhile = takeWhile; 21765 lodash.tap = tap; 21766 lodash.throttle = throttle; 21767 lodash.thru = thru; 21768 lodash.toArray = toArray; 21769 lodash.toPairs = toPairs; 21770 lodash.toPairsIn = toPairsIn; 21771 lodash.toPath = toPath; 21772 lodash.toPlainObject = toPlainObject; 21773 lodash.transform = transform; 21774 lodash.unary = unary; 21775 lodash.union = union; 21776 lodash.unionBy = unionBy; 21777 lodash.unionWith = unionWith; 21778 lodash.uniq = uniq; 21779 lodash.uniqBy = uniqBy; 21780 lodash.uniqWith = uniqWith; 21781 lodash.unset = unset; 21782 lodash.unzip = unzip; 21783 lodash.unzipWith = unzipWith; 21784 lodash.update = update; 21785 lodash.updateWith = updateWith; 21786 lodash.values = values; 21787 lodash.valuesIn = valuesIn; 21788 lodash.without = without; 21789 lodash.words = words; 21790 lodash.wrap = wrap; 21791 lodash.xor = xor; 21792 lodash.xorBy = xorBy; 21793 lodash.xorWith = xorWith; 21794 lodash.zip = zip; 21795 lodash.zipObject = zipObject; 21796 lodash.zipObjectDeep = zipObjectDeep; 21797 lodash.zipWith = zipWith; 21798 21799 // Add aliases. 21800 lodash.entries = toPairs; 21801 lodash.entriesIn = toPairsIn; 21802 lodash.extend = assignIn; 21803 lodash.extendWith = assignInWith; 21804 21805 // Add methods to `lodash.prototype`. 21806 mixin(lodash, lodash); 21807 21808 /*------------------------------------------------------------------------*/ 21809 21810 // Add methods that return unwrapped values in chain sequences. 21811 lodash.add = add; 21812 lodash.attempt = attempt; 21813 lodash.camelCase = camelCase; 21814 lodash.capitalize = capitalize; 21815 lodash.ceil = ceil; 21816 lodash.clamp = clamp; 21817 lodash.clone = clone; 21818 lodash.cloneDeep = cloneDeep; 21819 lodash.cloneDeepWith = cloneDeepWith; 21820 lodash.cloneWith = cloneWith; 21821 lodash.conformsTo = conformsTo; 21822 lodash.deburr = deburr; 21823 lodash.defaultTo = defaultTo; 21824 lodash.divide = divide; 21825 lodash.endsWith = endsWith; 21826 lodash.eq = eq; 21827 lodash.escape = escape; 21828 lodash.escapeRegExp = escapeRegExp; 21829 lodash.every = every; 21830 lodash.find = find; 21831 lodash.findIndex = findIndex; 21832 lodash.findKey = findKey; 21833 lodash.findLast = findLast; 21834 lodash.findLastIndex = findLastIndex; 21835 lodash.findLastKey = findLastKey; 21836 lodash.floor = floor; 21837 lodash.forEach = forEach; 21838 lodash.forEachRight = forEachRight; 21839 lodash.forIn = forIn; 21840 lodash.forInRight = forInRight; 21841 lodash.forOwn = forOwn; 21842 lodash.forOwnRight = forOwnRight; 21843 lodash.get = get; 21844 lodash.gt = gt; 21845 lodash.gte = gte; 21846 lodash.has = has; 21847 lodash.hasIn = hasIn; 21848 lodash.head = head; 21849 lodash.identity = identity; 21850 lodash.includes = includes; 21851 lodash.indexOf = indexOf; 21852 lodash.inRange = inRange; 21853 lodash.invoke = invoke; 21854 lodash.isArguments = isArguments; 21855 lodash.isArray = isArray; 21856 lodash.isArrayBuffer = isArrayBuffer; 21857 lodash.isArrayLike = isArrayLike; 21858 lodash.isArrayLikeObject = isArrayLikeObject; 21859 lodash.isBoolean = isBoolean; 21860 lodash.isBuffer = isBuffer; 21861 lodash.isDate = isDate; 21862 lodash.isElement = isElement; 21863 lodash.isEmpty = isEmpty; 21864 lodash.isEqual = isEqual; 21865 lodash.isEqualWith = isEqualWith; 21866 lodash.isError = isError; 21867 lodash.isFinite = isFinite; 21868 lodash.isFunction = isFunction; 21869 lodash.isInteger = isInteger; 21870 lodash.isLength = isLength; 21871 lodash.isMap = isMap; 21872 lodash.isMatch = isMatch; 21873 lodash.isMatchWith = isMatchWith; 21874 lodash.isNaN = isNaN; 21875 lodash.isNative = isNative; 21876 lodash.isNil = isNil; 21877 lodash.isNull = isNull; 21878 lodash.isNumber = isNumber; 21879 lodash.isObject = isObject; 21880 lodash.isObjectLike = isObjectLike; 21881 lodash.isPlainObject = isPlainObject; 21882 lodash.isRegExp = isRegExp; 21883 lodash.isSafeInteger = isSafeInteger; 21884 lodash.isSet = isSet; 21885 lodash.isString = isString; 21886 lodash.isSymbol = isSymbol; 21887 lodash.isTypedArray = isTypedArray; 21888 lodash.isUndefined = isUndefined; 21889 lodash.isWeakMap = isWeakMap; 21890 lodash.isWeakSet = isWeakSet; 21891 lodash.join = join; 21892 lodash.kebabCase = kebabCase; 21893 lodash.last = last; 21894 lodash.lastIndexOf = lastIndexOf; 21895 lodash.lowerCase = lowerCase; 21896 lodash.lowerFirst = lowerFirst; 21897 lodash.lt = lt; 21898 lodash.lte = lte; 21899 lodash.max = max; 21900 lodash.maxBy = maxBy; 21901 lodash.mean = mean; 21902 lodash.meanBy = meanBy; 21903 lodash.min = min; 21904 lodash.minBy = minBy; 21905 lodash.stubArray = stubArray; 21906 lodash.stubFalse = stubFalse; 21907 lodash.stubObject = stubObject; 21908 lodash.stubString = stubString; 21909 lodash.stubTrue = stubTrue; 21910 lodash.multiply = multiply; 21911 lodash.nth = nth; 21912 lodash.noConflict = noConflict; 21913 lodash.noop = noop; 21914 lodash.now = now; 21915 lodash.pad = pad; 21916 lodash.padEnd = padEnd; 21917 lodash.padStart = padStart; 21918 lodash.parseInt = parseInt; 21919 lodash.random = random; 21920 lodash.reduce = reduce; 21921 lodash.reduceRight = reduceRight; 21922 lodash.repeat = repeat; 21923 lodash.replace = replace; 21924 lodash.result = result; 21925 lodash.round = round; 21926 lodash.runInContext = runInContext; 21927 lodash.sample = sample; 21928 lodash.size = size; 21929 lodash.snakeCase = snakeCase; 21930 lodash.some = some; 21931 lodash.sortedIndex = sortedIndex; 21932 lodash.sortedIndexBy = sortedIndexBy; 21933 lodash.sortedIndexOf = sortedIndexOf; 21934 lodash.sortedLastIndex = sortedLastIndex; 21935 lodash.sortedLastIndexBy = sortedLastIndexBy; 21936 lodash.sortedLastIndexOf = sortedLastIndexOf; 21937 lodash.startCase = startCase; 21938 lodash.startsWith = startsWith; 21939 lodash.subtract = subtract; 21940 lodash.sum = sum; 21941 lodash.sumBy = sumBy; 21942 lodash.template = template; 21943 lodash.times = times; 21944 lodash.toFinite = toFinite; 21945 lodash.toInteger = toInteger; 21946 lodash.toLength = toLength; 21947 lodash.toLower = toLower; 21948 lodash.toNumber = toNumber; 21949 lodash.toSafeInteger = toSafeInteger; 21950 lodash.toString = toString; 21951 lodash.toUpper = toUpper; 21952 lodash.trim = trim; 21953 lodash.trimEnd = trimEnd; 21954 lodash.trimStart = trimStart; 21955 lodash.truncate = truncate; 21956 lodash.unescape = unescape; 21957 lodash.uniqueId = uniqueId; 21958 lodash.upperCase = upperCase; 21959 lodash.upperFirst = upperFirst; 21960 21961 // Add aliases. 21962 lodash.each = forEach; 21963 lodash.eachRight = forEachRight; 21964 lodash.first = head; 21965 21966 mixin(lodash, (function() { 21967 var source = {}; 21968 baseForOwn(lodash, function(func, methodName) { 21969 if (!hasOwnProperty.call(lodash.prototype, methodName)) { 21970 source[methodName] = func; 21971 } 21972 }); 21973 return source; 21974 }()), { 'chain': false }); 21975 21976 /*------------------------------------------------------------------------*/ 21977 21978 /** 21979 * The semantic version number. 21980 * 21981 * @static 21982 * @memberOf _ 21983 * @type {string} 21984 */ 21985 lodash.VERSION = VERSION; 21986 21987 // Assign default placeholders. 21988 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { 21989 lodash[methodName].placeholder = lodash; 21990 }); 21991 21992 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. 21993 arrayEach(['drop', 'take'], function(methodName, index) { 21994 LazyWrapper.prototype[methodName] = function(n) { 21995 n = n === undefined ? 1 : nativeMax(toInteger(n), 0); 21996 21997 var result = (this.__filtered__ && !index) 21998 ? new LazyWrapper(this) 21999 : this.clone(); 22000 22001 if (result.__filtered__) { 22002 result.__takeCount__ = nativeMin(n, result.__takeCount__); 22003 } else { 22004 result.__views__.push({ 22005 'size': nativeMin(n, MAX_ARRAY_LENGTH), 22006 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') 22007 }); 22008 } 22009 return result; 22010 }; 22011 22012 LazyWrapper.prototype[methodName + 'Right'] = function(n) { 22013 return this.reverse()[methodName](n).reverse(); 22014 }; 22015 }); 22016 22017 // Add `LazyWrapper` methods that accept an `iteratee` value. 22018 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { 22019 var type = index + 1, 22020 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; 22021 22022 LazyWrapper.prototype[methodName] = function(iteratee) { 22023 var result = this.clone(); 22024 result.__iteratees__.push({ 22025 'iteratee': getIteratee(iteratee, 3), 22026 'type': type 22027 }); 22028 result.__filtered__ = result.__filtered__ || isFilter; 22029 return result; 22030 }; 22031 }); 22032 22033 // Add `LazyWrapper` methods for `_.head` and `_.last`. 22034 arrayEach(['head', 'last'], function(methodName, index) { 22035 var takeName = 'take' + (index ? 'Right' : ''); 22036 22037 LazyWrapper.prototype[methodName] = function() { 22038 return this[takeName](1).value()[0]; 22039 }; 22040 }); 22041 22042 // Add `LazyWrapper` methods for `_.initial` and `_.tail`. 22043 arrayEach(['initial', 'tail'], function(methodName, index) { 22044 var dropName = 'drop' + (index ? '' : 'Right'); 22045 22046 LazyWrapper.prototype[methodName] = function() { 22047 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); 22048 }; 22049 }); 22050 22051 LazyWrapper.prototype.compact = function() { 22052 return this.filter(identity); 22053 }; 22054 22055 LazyWrapper.prototype.find = function(predicate) { 22056 return this.filter(predicate).head(); 22057 }; 22058 22059 LazyWrapper.prototype.findLast = function(predicate) { 22060 return this.reverse().find(predicate); 22061 }; 22062 22063 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { 22064 if (typeof path == 'function') { 22065 return new LazyWrapper(this); 22066 } 22067 return this.map(function(value) { 22068 return baseInvoke(value, path, args); 22069 }); 22070 }); 22071 22072 LazyWrapper.prototype.reject = function(predicate) { 22073 return this.filter(negate(getIteratee(predicate))); 22074 }; 22075 22076 LazyWrapper.prototype.slice = function(start, end) { 22077 start = toInteger(start); 22078 22079 var result = this; 22080 if (result.__filtered__ && (start > 0 || end < 0)) { 22081 return new LazyWrapper(result); 22082 } 22083 if (start < 0) { 22084 result = result.takeRight(-start); 22085 } else if (start) { 22086 result = result.drop(start); 22087 } 22088 if (end !== undefined) { 22089 end = toInteger(end); 22090 result = end < 0 ? result.dropRight(-end) : result.take(end - start); 22091 } 22092 return result; 22093 }; 22094 22095 LazyWrapper.prototype.takeRightWhile = function(predicate) { 22096 return this.reverse().takeWhile(predicate).reverse(); 22097 }; 22098 22099 LazyWrapper.prototype.toArray = function() { 22100 return this.take(MAX_ARRAY_LENGTH); 22101 }; 22102 22103 // Add `LazyWrapper` methods to `lodash.prototype`. 22104 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 22105 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), 22106 isTaker = /^(?:head|last)$/.test(methodName), 22107 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], 22108 retUnwrapped = isTaker || /^find/.test(methodName); 22109 22110 if (!lodashFunc) { 22111 return; 22112 } 22113 lodash.prototype[methodName] = function() { 22114 var value = this.__wrapped__, 22115 args = isTaker ? [1] : arguments, 22116 isLazy = value instanceof LazyWrapper, 22117 iteratee = args[0], 22118 useLazy = isLazy || isArray(value); 22119 22120 var interceptor = function(value) { 22121 var result = lodashFunc.apply(lodash, arrayPush([value], args)); 22122 return (isTaker && chainAll) ? result[0] : result; 22123 }; 22124 22125 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { 22126 // Avoid lazy use if the iteratee has a "length" value other than `1`. 22127 isLazy = useLazy = false; 22128 } 22129 var chainAll = this.__chain__, 22130 isHybrid = !!this.__actions__.length, 22131 isUnwrapped = retUnwrapped && !chainAll, 22132 onlyLazy = isLazy && !isHybrid; 22133 22134 if (!retUnwrapped && useLazy) { 22135 value = onlyLazy ? value : new LazyWrapper(this); 22136 var result = func.apply(value, args); 22137 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); 22138 return new LodashWrapper(result, chainAll); 22139 } 22140 if (isUnwrapped && onlyLazy) { 22141 return func.apply(this, args); 22142 } 22143 result = this.thru(interceptor); 22144 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; 22145 }; 22146 }); 22147 22148 // Add `Array` methods to `lodash.prototype`. 22149 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { 22150 var func = arrayProto[methodName], 22151 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', 22152 retUnwrapped = /^(?:pop|shift)$/.test(methodName); 22153 22154 lodash.prototype[methodName] = function() { 22155 var args = arguments; 22156 if (retUnwrapped && !this.__chain__) { 22157 var value = this.value(); 22158 return func.apply(isArray(value) ? value : [], args); 22159 } 22160 return this[chainName](function(value) { 22161 return func.apply(isArray(value) ? value : [], args); 22162 }); 22163 }; 22164 }); 22165 22166 // Map minified method names to their real names. 22167 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 22168 var lodashFunc = lodash[methodName]; 22169 if (lodashFunc) { 22170 var key = lodashFunc.name + ''; 22171 if (!hasOwnProperty.call(realNames, key)) { 22172 realNames[key] = []; 22173 } 22174 realNames[key].push({ 'name': methodName, 'func': lodashFunc }); 22175 } 22176 }); 22177 22178 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ 22179 'name': 'wrapper', 22180 'func': undefined 22181 }]; 22182 22183 // Add methods to `LazyWrapper`. 22184 LazyWrapper.prototype.clone = lazyClone; 22185 LazyWrapper.prototype.reverse = lazyReverse; 22186 LazyWrapper.prototype.value = lazyValue; 22187 22188 // Add chain sequence methods to the `lodash` wrapper. 22189 lodash.prototype.at = wrapperAt; 22190 lodash.prototype.chain = wrapperChain; 22191 lodash.prototype.commit = wrapperCommit; 22192 lodash.prototype.next = wrapperNext; 22193 lodash.prototype.plant = wrapperPlant; 22194 lodash.prototype.reverse = wrapperReverse; 22195 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; 22196 22197 // Add lazy aliases. 22198 lodash.prototype.first = lodash.prototype.head; 22199 22200 if (symIterator) { 22201 lodash.prototype[symIterator] = wrapperToIterator; 22202 } 22203 return lodash; 22204 }); 22205 22206 /*--------------------------------------------------------------------------*/ 22207 22208 // Export lodash. 22209 var _ = runInContext(); 22210 22211 // Some AMD build optimizers, like r.js, check for condition patterns like: 22212 if (true) { 22213 // Expose Lodash on the global object to prevent errors when Lodash is 22214 // loaded by a script tag in the presence of an AMD loader. 22215 // See http://requirejs.org/docs/errors.html#mismatch for more details. 22216 // Use `_.noConflict` to remove Lodash from the global object. 22217 root._ = _; 22218 22219 // Define as an anonymous module so, through path mapping, it can be 22220 // referenced as the "underscore" module. 22221 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 22222 return _; 22223 }).call(exports, __webpack_require__, exports, module), 22224 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 22225 } 22226 // Check for `exports` after `define` in case a build optimizer adds it. 22227 else {} 22228}.call(this)); 22229 22230/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module))) 22231 22232/***/ }), 22233 22234/***/ "./node_modules/moment/locale sync recursive en": 22235/*!********************************************!*\ 22236 !*** ./node_modules/moment/locale sync en ***! 22237 \********************************************/ 22238/*! no static exports found */ 22239/***/ (function(module, exports, __webpack_require__) { 22240 22241var map = { 22242 "./en-au": "./node_modules/moment/locale/en-au.js", 22243 "./en-au.js": "./node_modules/moment/locale/en-au.js", 22244 "./en-ca": "./node_modules/moment/locale/en-ca.js", 22245 "./en-ca.js": "./node_modules/moment/locale/en-ca.js", 22246 "./en-gb": "./node_modules/moment/locale/en-gb.js", 22247 "./en-gb.js": "./node_modules/moment/locale/en-gb.js", 22248 "./en-ie": "./node_modules/moment/locale/en-ie.js", 22249 "./en-ie.js": "./node_modules/moment/locale/en-ie.js", 22250 "./en-il": "./node_modules/moment/locale/en-il.js", 22251 "./en-il.js": "./node_modules/moment/locale/en-il.js", 22252 "./en-nz": "./node_modules/moment/locale/en-nz.js", 22253 "./en-nz.js": "./node_modules/moment/locale/en-nz.js" 22254}; 22255 22256 22257function webpackContext(req) { 22258 var id = webpackContextResolve(req); 22259 return __webpack_require__(id); 22260} 22261function webpackContextResolve(req) { 22262 if(!__webpack_require__.o(map, req)) { 22263 var e = new Error("Cannot find module '" + req + "'"); 22264 e.code = 'MODULE_NOT_FOUND'; 22265 throw e; 22266 } 22267 return map[req]; 22268} 22269webpackContext.keys = function webpackContextKeys() { 22270 return Object.keys(map); 22271}; 22272webpackContext.resolve = webpackContextResolve; 22273module.exports = webpackContext; 22274webpackContext.id = "./node_modules/moment/locale sync recursive en"; 22275 22276/***/ }), 22277
vendor: 2,485 bytes, lines 22278-22352
22278/***/ "./node_modules/moment/locale/en-au.js": 22279/*!*********************************************!*\ 22280 !*** ./node_modules/moment/locale/en-au.js ***! 22281 \*********************************************/ 22282/*! no static exports found */ 22283/***/ (function(module, exports, __webpack_require__) { 22284 22285//! moment.js locale configuration 22286 22287;(function (global, factory) { 22288 true ? factory(__webpack_require__(/*! ../moment */ "./node_modules/moment/moment.js")) : 22289 undefined 22290}(this, (function (moment) { 'use strict'; 22291 22292 22293 var enAu = moment.defineLocale('en-au', { 22294 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), 22295 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), 22296 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), 22297 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), 22298 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), 22299 longDateFormat : { 22300 LT : 'h:mm A', 22301 LTS : 'h:mm:ss A', 22302 L : 'DD/MM/YYYY', 22303 LL : 'D MMMM YYYY', 22304 LLL : 'D MMMM YYYY h:mm A', 22305 LLLL : 'dddd, D MMMM YYYY h:mm A' 22306 }, 22307 calendar : { 22308 sameDay : '[Today at] LT', 22309 nextDay : '[Tomorrow at] LT', 22310 nextWeek : 'dddd [at] LT', 22311 lastDay : '[Yesterday at] LT', 22312 lastWeek : '[Last] dddd [at] LT', 22313 sameElse : 'L' 22314 }, 22315 relativeTime : { 22316 future : 'in %s', 22317 past : '%s ago', 22318 s : 'a few seconds', 22319 ss : '%d seconds', 22320 m : 'a minute', 22321 mm : '%d minutes', 22322 h : 'an hour', 22323 hh : '%d hours', 22324 d : 'a day', 22325 dd : '%d days', 22326 M : 'a month', 22327 MM : '%d months', 22328 y : 'a year', 22329 yy : '%d years' 22330 }, 22331 dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/, 22332 ordinal : function (number) { 22333 var b = number % 10, 22334 output = (~~(number % 100 / 10) === 1) ? 'th' : 22335 (b === 1) ? 'st' : 22336 (b === 2) ? 'nd' : 22337 (b === 3) ? 'rd' : 'th'; 22338 return number + output; 22339 }, 22340 week : { 22341 dow : 1, // Monday is the first day of the week. 22342 doy : 4 // The week that contains Jan 4th is the first week of the year. 22343 } 22344 }); 22345 22346 return enAu; 22347 22348}))); 22349 22350 22351/***/ }), 22352
vendor: 2,313 bytes, lines 22353-22423
22353/***/ "./node_modules/moment/locale/en-ca.js": 22354/*!*********************************************!*\ 22355 !*** ./node_modules/moment/locale/en-ca.js ***! 22356 \*********************************************/ 22357/*! no static exports found */ 22358/***/ (function(module, exports, __webpack_require__) { 22359 22360//! moment.js locale configuration 22361 22362;(function (global, factory) { 22363 true ? factory(__webpack_require__(/*! ../moment */ "./node_modules/moment/moment.js")) : 22364 undefined 22365}(this, (function (moment) { 'use strict'; 22366 22367 22368 var enCa = moment.defineLocale('en-ca', { 22369 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), 22370 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), 22371 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), 22372 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), 22373 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), 22374 longDateFormat : { 22375 LT : 'h:mm A', 22376 LTS : 'h:mm:ss A', 22377 L : 'YYYY-MM-DD', 22378 LL : 'MMMM D, YYYY', 22379 LLL : 'MMMM D, YYYY h:mm A', 22380 LLLL : 'dddd, MMMM D, YYYY h:mm A' 22381 }, 22382 calendar : { 22383 sameDay : '[Today at] LT', 22384 nextDay : '[Tomorrow at] LT', 22385 nextWeek : 'dddd [at] LT', 22386 lastDay : '[Yesterday at] LT', 22387 lastWeek : '[Last] dddd [at] LT', 22388 sameElse : 'L' 22389 }, 22390 relativeTime : { 22391 future : 'in %s', 22392 past : '%s ago', 22393 s : 'a few seconds', 22394 ss : '%d seconds', 22395 m : 'a minute', 22396 mm : '%d minutes', 22397 h : 'an hour', 22398 hh : '%d hours', 22399 d : 'a day', 22400 dd : '%d days', 22401 M : 'a month', 22402 MM : '%d months', 22403 y : 'a year', 22404 yy : '%d years' 22405 }, 22406 dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/, 22407 ordinal : function (number) { 22408 var b = number % 10, 22409 output = (~~(number % 100 / 10) === 1) ? 'th' : 22410 (b === 1) ? 'st' : 22411 (b === 2) ? 'nd' : 22412 (b === 3) ? 'rd' : 'th'; 22413 return number + output; 22414 } 22415 }); 22416 22417 return enCa; 22418 22419}))); 22420 22421 22422/***/ }), 22423
vendor: 2,481 bytes, lines 22424-22498
22424/***/ "./node_modules/moment/locale/en-gb.js": 22425/*!*********************************************!*\ 22426 !*** ./node_modules/moment/locale/en-gb.js ***! 22427 \*********************************************/ 22428/*! no static exports found */ 22429/***/ (function(module, exports, __webpack_require__) { 22430 22431//! moment.js locale configuration 22432 22433;(function (global, factory) { 22434 true ? factory(__webpack_require__(/*! ../moment */ "./node_modules/moment/moment.js")) : 22435 undefined 22436}(this, (function (moment) { 'use strict'; 22437 22438 22439 var enGb = moment.defineLocale('en-gb', { 22440 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), 22441 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), 22442 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), 22443 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), 22444 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), 22445 longDateFormat : { 22446 LT : 'HH:mm', 22447 LTS : 'HH:mm:ss', 22448 L : 'DD/MM/YYYY', 22449 LL : 'D MMMM YYYY', 22450 LLL : 'D MMMM YYYY HH:mm', 22451 LLLL : 'dddd, D MMMM YYYY HH:mm' 22452 }, 22453 calendar : { 22454 sameDay : '[Today at] LT', 22455 nextDay : '[Tomorrow at] LT', 22456 nextWeek : 'dddd [at] LT', 22457 lastDay : '[Yesterday at] LT', 22458 lastWeek : '[Last] dddd [at] LT', 22459 sameElse : 'L' 22460 }, 22461 relativeTime : { 22462 future : 'in %s', 22463 past : '%s ago', 22464 s : 'a few seconds', 22465 ss : '%d seconds', 22466 m : 'a minute', 22467 mm : '%d minutes', 22468 h : 'an hour', 22469 hh : '%d hours', 22470 d : 'a day', 22471 dd : '%d days', 22472 M : 'a month', 22473 MM : '%d months', 22474 y : 'a year', 22475 yy : '%d years' 22476 }, 22477 dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/, 22478 ordinal : function (number) { 22479 var b = number % 10, 22480 output = (~~(number % 100 / 10) === 1) ? 'th' : 22481 (b === 1) ? 'st' : 22482 (b === 2) ? 'nd' : 22483 (b === 3) ? 'rd' : 'th'; 22484 return number + output; 22485 }, 22486 week : { 22487 dow : 1, // Monday is the first day of the week. 22488 doy : 4 // The week that contains Jan 4th is the first week of the year. 22489 } 22490 }); 22491 22492 return enGb; 22493 22494}))); 22495 22496 22497/***/ }), 22498
vendor: 2,480 bytes, lines 22499-22573
22499/***/ "./node_modules/moment/locale/en-ie.js": 22500/*!*********************************************!*\ 22501 !*** ./node_modules/moment/locale/en-ie.js ***! 22502 \*********************************************/ 22503/*! no static exports found */ 22504/***/ (function(module, exports, __webpack_require__) { 22505 22506//! moment.js locale configuration 22507 22508;(function (global, factory) { 22509 true ? factory(__webpack_require__(/*! ../moment */ "./node_modules/moment/moment.js")) : 22510 undefined 22511}(this, (function (moment) { 'use strict'; 22512 22513 22514 var enIe = moment.defineLocale('en-ie', { 22515 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), 22516 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), 22517 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), 22518 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), 22519 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), 22520 longDateFormat : { 22521 LT : 'HH:mm', 22522 LTS : 'HH:mm:ss', 22523 L : 'DD-MM-YYYY', 22524 LL : 'D MMMM YYYY', 22525 LLL : 'D MMMM YYYY HH:mm', 22526 LLLL : 'dddd D MMMM YYYY HH:mm' 22527 }, 22528 calendar : { 22529 sameDay : '[Today at] LT', 22530 nextDay : '[Tomorrow at] LT', 22531 nextWeek : 'dddd [at] LT', 22532 lastDay : '[Yesterday at] LT', 22533 lastWeek : '[Last] dddd [at] LT', 22534 sameElse : 'L' 22535 }, 22536 relativeTime : { 22537 future : 'in %s', 22538 past : '%s ago', 22539 s : 'a few seconds', 22540 ss : '%d seconds', 22541 m : 'a minute', 22542 mm : '%d minutes', 22543 h : 'an hour', 22544 hh : '%d hours', 22545 d : 'a day', 22546 dd : '%d days', 22547 M : 'a month', 22548 MM : '%d months', 22549 y : 'a year', 22550 yy : '%d years' 22551 }, 22552 dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/, 22553 ordinal : function (number) { 22554 var b = number % 10, 22555 output = (~~(number % 100 / 10) === 1) ? 'th' : 22556 (b === 1) ? 'st' : 22557 (b === 2) ? 'nd' : 22558 (b === 3) ? 'rd' : 'th'; 22559 return number + output; 22560 }, 22561 week : { 22562 dow : 1, // Monday is the first day of the week. 22563 doy : 4 // The week that contains Jan 4th is the first week of the year. 22564 } 22565 }); 22566 22567 return enIe; 22568 22569}))); 22570 22571 22572/***/ }), 22573
vendor: 2,275 bytes, lines 22574-22643
22574/***/ "./node_modules/moment/locale/en-il.js": 22575/*!*********************************************!*\ 22576 !*** ./node_modules/moment/locale/en-il.js ***! 22577 \*********************************************/ 22578/*! no static exports found */ 22579/***/ (function(module, exports, __webpack_require__) { 22580 22581//! moment.js locale configuration 22582 22583;(function (global, factory) { 22584 true ? factory(__webpack_require__(/*! ../moment */ "./node_modules/moment/moment.js")) : 22585 undefined 22586}(this, (function (moment) { 'use strict'; 22587 22588 22589 var enIl = moment.defineLocale('en-il', { 22590 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), 22591 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), 22592 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), 22593 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), 22594 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), 22595 longDateFormat : { 22596 LT : 'HH:mm', 22597 LTS : 'HH:mm:ss', 22598 L : 'DD/MM/YYYY', 22599 LL : 'D MMMM YYYY', 22600 LLL : 'D MMMM YYYY HH:mm', 22601 LLLL : 'dddd, D MMMM YYYY HH:mm' 22602 }, 22603 calendar : { 22604 sameDay : '[Today at] LT', 22605 nextDay : '[Tomorrow at] LT', 22606 nextWeek : 'dddd [at] LT', 22607 lastDay : '[Yesterday at] LT', 22608 lastWeek : '[Last] dddd [at] LT', 22609 sameElse : 'L' 22610 }, 22611 relativeTime : { 22612 future : 'in %s', 22613 past : '%s ago', 22614 s : 'a few seconds', 22615 m : 'a minute', 22616 mm : '%d minutes', 22617 h : 'an hour', 22618 hh : '%d hours', 22619 d : 'a day', 22620 dd : '%d days', 22621 M : 'a month', 22622 MM : '%d months', 22623 y : 'a year', 22624 yy : '%d years' 22625 }, 22626 dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/, 22627 ordinal : function (number) { 22628 var b = number % 10, 22629 output = (~~(number % 100 / 10) === 1) ? 'th' : 22630 (b === 1) ? 'st' : 22631 (b === 2) ? 'nd' : 22632 (b === 3) ? 'rd' : 'th'; 22633 return number + output; 22634 } 22635 }); 22636 22637 return enIl; 22638 22639}))); 22640 22641 22642/***/ }), 22643
vendor: 2,485 bytes, lines 22644-22718
22644/***/ "./node_modules/moment/locale/en-nz.js": 22645/*!*********************************************!*\ 22646 !*** ./node_modules/moment/locale/en-nz.js ***! 22647 \*********************************************/ 22648/*! no static exports found */ 22649/***/ (function(module, exports, __webpack_require__) { 22650 22651//! moment.js locale configuration 22652 22653;(function (global, factory) { 22654 true ? factory(__webpack_require__(/*! ../moment */ "./node_modules/moment/moment.js")) : 22655 undefined 22656}(this, (function (moment) { 'use strict'; 22657 22658 22659 var enNz = moment.defineLocale('en-nz', { 22660 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), 22661 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), 22662 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), 22663 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), 22664 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), 22665 longDateFormat : { 22666 LT : 'h:mm A', 22667 LTS : 'h:mm:ss A', 22668 L : 'DD/MM/YYYY', 22669 LL : 'D MMMM YYYY', 22670 LLL : 'D MMMM YYYY h:mm A', 22671 LLLL : 'dddd, D MMMM YYYY h:mm A' 22672 }, 22673 calendar : { 22674 sameDay : '[Today at] LT', 22675 nextDay : '[Tomorrow at] LT', 22676 nextWeek : 'dddd [at] LT', 22677 lastDay : '[Yesterday at] LT', 22678 lastWeek : '[Last] dddd [at] LT', 22679 sameElse : 'L' 22680 }, 22681 relativeTime : { 22682 future : 'in %s', 22683 past : '%s ago', 22684 s : 'a few seconds', 22685 ss : '%d seconds', 22686 m : 'a minute', 22687 mm : '%d minutes', 22688 h : 'an hour', 22689 hh : '%d hours', 22690 d : 'a day', 22691 dd : '%d days', 22692 M : 'a month', 22693 MM : '%d months', 22694 y : 'a year', 22695 yy : '%d years' 22696 }, 22697 dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/, 22698 ordinal : function (number) { 22699 var b = number % 10, 22700 output = (~~(number % 100 / 10) === 1) ? 'th' : 22701 (b === 1) ? 'st' : 22702 (b === 2) ? 'nd' : 22703 (b === 3) ? 'rd' : 'th'; 22704 return number + output; 22705 }, 22706 week : { 22707 dow : 1, // Monday is the first day of the week. 22708 doy : 4 // The week that contains Jan 4th is the first week of the year. 22709 } 22710 }); 22711 22712 return enNz; 22713 22714}))); 22715 22716 22717/***/ }), 22718
vendor: 147,256 bytes, lines 22719-27235
22719/***/ "./node_modules/moment/moment.js": 22720/*!***************************************!*\ 22721 !*** ./node_modules/moment/moment.js ***! 22722 \***************************************/ 22723/*! no static exports found */ 22724/***/ (function(module, exports, __webpack_require__) { 22725 22726/* WEBPACK VAR INJECTION */(function(module) {var require;//! moment.js 22727 22728;(function (global, factory) { 22729 true ? module.exports = factory() : 22730 undefined 22731}(this, (function () { 'use strict'; 22732 22733 var hookCallback; 22734 22735 function hooks () { 22736 return hookCallback.apply(null, arguments); 22737 } 22738 22739 // This is done to register the method called with moment() 22740 // without creating circular dependencies. 22741 function setHookCallback (callback) { 22742 hookCallback = callback; 22743 } 22744 22745 function isArray(input) { 22746 return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]'; 22747 } 22748 22749 function isObject(input) { 22750 // IE8 will treat undefined and null as object if it wasn't for 22751 // input != null 22752 return input != null && Object.prototype.toString.call(input) === '[object Object]'; 22753 } 22754 22755 function isObjectEmpty(obj) { 22756 if (Object.getOwnPropertyNames) { 22757 return (Object.getOwnPropertyNames(obj).length === 0); 22758 } else { 22759 var k; 22760 for (k in obj) { 22761 if (obj.hasOwnProperty(k)) { 22762 return false; 22763 } 22764 } 22765 return true; 22766 } 22767 } 22768 22769 function isUndefined(input) { 22770 return input === void 0; 22771 } 22772 22773 function isNumber(input) { 22774 return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]'; 22775 } 22776 22777 function isDate(input) { 22778 return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]'; 22779 } 22780 22781 function map(arr, fn) { 22782 var res = [], i; 22783 for (i = 0; i < arr.length; ++i) { 22784 res.push(fn(arr[i], i)); 22785 } 22786 return res; 22787 } 22788 22789 function hasOwnProp(a, b) { 22790 return Object.prototype.hasOwnProperty.call(a, b); 22791 } 22792 22793 function extend(a, b) { 22794 for (var i in b) { 22795 if (hasOwnProp(b, i)) { 22796 a[i] = b[i]; 22797 } 22798 } 22799 22800 if (hasOwnProp(b, 'toString')) { 22801 a.toString = b.toString; 22802 } 22803 22804 if (hasOwnProp(b, 'valueOf')) { 22805 a.valueOf = b.valueOf; 22806 } 22807 22808 return a; 22809 } 22810 22811 function createUTC (input, format, locale, strict) { 22812 return createLocalOrUTC(input, format, locale, strict, true).utc(); 22813 } 22814 22815 function defaultParsingFlags() { 22816 // We need to deep clone this object. 22817 return { 22818 empty : false, 22819 unusedTokens : [], 22820 unusedInput : [], 22821 overflow : -2, 22822 charsLeftOver : 0, 22823 nullInput : false, 22824 invalidMonth : null, 22825 invalidFormat : false, 22826 userInvalidated : false, 22827 iso : false, 22828 parsedDateParts : [], 22829 meridiem : null, 22830 rfc2822 : false, 22831 weekdayMismatch : false 22832 }; 22833 } 22834 22835 function getParsingFlags(m) { 22836 if (m._pf == null) { 22837 m._pf = defaultParsingFlags(); 22838 } 22839 return m._pf; 22840 } 22841 22842 var some; 22843 if (Array.prototype.some) { 22844 some = Array.prototype.some; 22845 } else { 22846 some = function (fun) { 22847 var t = Object(this); 22848 var len = t.length >>> 0; 22849 22850 for (var i = 0; i < len; i++) { 22851 if (i in t && fun.call(this, t[i], i, t)) { 22852 return true; 22853 } 22854 } 22855 22856 return false; 22857 }; 22858 } 22859 22860 function isValid(m) { 22861 if (m._isValid == null) { 22862 var flags = getParsingFlags(m); 22863 var parsedParts = some.call(flags.parsedDateParts, function (i) { 22864 return i != null; 22865 }); 22866 var isNowValid = !isNaN(m._d.getTime()) && 22867 flags.overflow < 0 && 22868 !flags.empty && 22869 !flags.invalidMonth && 22870 !flags.invalidWeekday && 22871 !flags.weekdayMismatch && 22872 !flags.nullInput && 22873 !flags.invalidFormat && 22874 !flags.userInvalidated && 22875 (!flags.meridiem || (flags.meridiem && parsedParts)); 22876 22877 if (m._strict) { 22878 isNowValid = isNowValid && 22879 flags.charsLeftOver === 0 && 22880 flags.unusedTokens.length === 0 && 22881 flags.bigHour === undefined; 22882 } 22883 22884 if (Object.isFrozen == null || !Object.isFrozen(m)) { 22885 m._isValid = isNowValid; 22886 } 22887 else { 22888 return isNowValid; 22889 } 22890 } 22891 return m._isValid; 22892 } 22893 22894 function createInvalid (flags) { 22895 var m = createUTC(NaN); 22896 if (flags != null) { 22897 extend(getParsingFlags(m), flags); 22898 } 22899 else { 22900 getParsingFlags(m).userInvalidated = true; 22901 } 22902 22903 return m; 22904 } 22905 22906 // Plugins that add properties should also add the key here (null value), 22907 // so we can properly clone ourselves. 22908 var momentProperties = hooks.momentProperties = []; 22909 22910 function copyConfig(to, from) { 22911 var i, prop, val; 22912 22913 if (!isUndefined(from._isAMomentObject)) { 22914 to._isAMomentObject = from._isAMomentObject; 22915 } 22916 if (!isUndefined(from._i)) { 22917 to._i = from._i; 22918 } 22919 if (!isUndefined(from._f)) { 22920 to._f = from._f; 22921 } 22922 if (!isUndefined(from._l)) { 22923 to._l = from._l; 22924 } 22925 if (!isUndefined(from._strict)) { 22926 to._strict = from._strict; 22927 } 22928 if (!isUndefined(from._tzm)) { 22929 to._tzm = from._tzm; 22930 } 22931 if (!isUndefined(from._isUTC)) { 22932 to._isUTC = from._isUTC; 22933 } 22934 if (!isUndefined(from._offset)) { 22935 to._offset = from._offset; 22936 } 22937 if (!isUndefined(from._pf)) { 22938 to._pf = getParsingFlags(from); 22939 } 22940 if (!isUndefined(from._locale)) { 22941 to._locale = from._locale; 22942 } 22943 22944 if (momentProperties.length > 0) { 22945 for (i = 0; i < momentProperties.length; i++) { 22946 prop = momentProperties[i]; 22947 val = from[prop]; 22948 if (!isUndefined(val)) { 22949 to[prop] = val; 22950 } 22951 } 22952 } 22953 22954 return to; 22955 } 22956 22957 var updateInProgress = false; 22958 22959 // Moment prototype object 22960 function Moment(config) { 22961 copyConfig(this, config); 22962 this._d = new Date(config._d != null ? config._d.getTime() : NaN); 22963 if (!this.isValid()) { 22964 this._d = new Date(NaN); 22965 } 22966 // Prevent infinite loop in case updateOffset creates new moment 22967 // objects. 22968 if (updateInProgress === false) { 22969 updateInProgress = true; 22970 hooks.updateOffset(this); 22971 updateInProgress = false; 22972 } 22973 } 22974 22975 function isMoment (obj) { 22976 return obj instanceof Moment || (obj != null && obj._isAMomentObject != null); 22977 } 22978 22979 function absFloor (number) { 22980 if (number < 0) { 22981 // -0 -> 0 22982 return Math.ceil(number) || 0; 22983 } else { 22984 return Math.floor(number); 22985 } 22986 } 22987 22988 function toInt(argumentForCoercion) { 22989 var coercedNumber = +argumentForCoercion, 22990 value = 0; 22991 22992 if (coercedNumber !== 0 && isFinite(coercedNumber)) { 22993 value = absFloor(coercedNumber); 22994 } 22995 22996 return value; 22997 } 22998 22999 // compare two arrays, return the number of differences 23000 function compareArrays(array1, array2, dontConvert) { 23001 var len = Math.min(array1.length, array2.length), 23002 lengthDiff = Math.abs(array1.length - array2.length), 23003 diffs = 0, 23004 i; 23005 for (i = 0; i < len; i++) { 23006 if ((dontConvert && array1[i] !== array2[i]) || 23007 (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) { 23008 diffs++; 23009 } 23010 } 23011 return diffs + lengthDiff; 23012 } 23013 23014 function warn(msg) { 23015 if (hooks.suppressDeprecationWarnings === false && 23016 (typeof console !== 'undefined') && console.warn) { 23017 console.warn('Deprecation warning: ' + msg); 23018 } 23019 } 23020 23021 function deprecate(msg, fn) { 23022 var firstTime = true; 23023 23024 return extend(function () { 23025 if (hooks.deprecationHandler != null) { 23026 hooks.deprecationHandler(null, msg); 23027 } 23028 if (firstTime) { 23029 var args = []; 23030 var arg; 23031 for (var i = 0; i < arguments.length; i++) { 23032 arg = ''; 23033 if (typeof arguments[i] === 'object') { 23034 arg += '\n[' + i + '] '; 23035 for (var key in arguments[0]) { 23036 arg += key + ': ' + arguments[0][key] + ', '; 23037 } 23038 arg = arg.slice(0, -2); // Remove trailing comma and space 23039 } else { 23040 arg = arguments[i]; 23041 } 23042 args.push(arg); 23043 } 23044 warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack); 23045 firstTime = false; 23046 } 23047 return fn.apply(this, arguments); 23048 }, fn); 23049 } 23050 23051 var deprecations = {}; 23052 23053 function deprecateSimple(name, msg) { 23054 if (hooks.deprecationHandler != null) { 23055 hooks.deprecationHandler(name, msg); 23056 } 23057 if (!deprecations[name]) { 23058 warn(msg); 23059 deprecations[name] = true; 23060 } 23061 } 23062 23063 hooks.suppressDeprecationWarnings = false; 23064 hooks.deprecationHandler = null; 23065 23066 function isFunction(input) { 23067 return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]'; 23068 } 23069 23070 function set (config) { 23071 var prop, i; 23072 for (i in config) { 23073 prop = config[i]; 23074 if (isFunction(prop)) { 23075 this[i] = prop; 23076 } else { 23077 this['_' + i] = prop; 23078 } 23079 } 23080 this._config = config; 23081 // Lenient ordinal parsing accepts just a number in addition to 23082 // number + (possibly) stuff coming from _dayOfMonthOrdinalParse. 23083 // TODO: Remove "ordinalParse" fallback in next major release. 23084 this._dayOfMonthOrdinalParseLenient = new RegExp( 23085 (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + 23086 '|' + (/\d{1,2}/).source); 23087 } 23088 23089 function mergeConfigs(parentConfig, childConfig) { 23090 var res = extend({}, parentConfig), prop; 23091 for (prop in childConfig) { 23092 if (hasOwnProp(childConfig, prop)) { 23093 if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) { 23094 res[prop] = {}; 23095 extend(res[prop], parentConfig[prop]); 23096 extend(res[prop], childConfig[prop]); 23097 } else if (childConfig[prop] != null) { 23098 res[prop] = childConfig[prop]; 23099 } else { 23100 delete res[prop]; 23101 } 23102 } 23103 } 23104 for (prop in parentConfig) { 23105 if (hasOwnProp(parentConfig, prop) && 23106 !hasOwnProp(childConfig, prop) && 23107 isObject(parentConfig[prop])) { 23108 // make sure changes to properties don't modify parent config 23109 res[prop] = extend({}, res[prop]); 23110 } 23111 } 23112 return res; 23113 } 23114 23115 function Locale(config) { 23116 if (config != null) { 23117 this.set(config); 23118 } 23119 } 23120 23121 var keys; 23122 23123 if (Object.keys) { 23124 keys = Object.keys; 23125 } else { 23126 keys = function (obj) { 23127 var i, res = []; 23128 for (i in obj) { 23129 if (hasOwnProp(obj, i)) { 23130 res.push(i); 23131 } 23132 } 23133 return res; 23134 }; 23135 } 23136 23137 var defaultCalendar = { 23138 sameDay : '[Today at] LT', 23139 nextDay : '[Tomorrow at] LT', 23140 nextWeek : 'dddd [at] LT', 23141 lastDay : '[Yesterday at] LT', 23142 lastWeek : '[Last] dddd [at] LT', 23143 sameElse : 'L' 23144 }; 23145 23146 function calendar (key, mom, now) { 23147 var output = this._calendar[key] || this._calendar['sameElse']; 23148 return isFunction(output) ? output.call(mom, now) : output; 23149 } 23150 23151 var defaultLongDateFormat = { 23152 LTS : 'h:mm:ss A', 23153 LT : 'h:mm A', 23154 L : 'MM/DD/YYYY', 23155 LL : 'MMMM D, YYYY', 23156 LLL : 'MMMM D, YYYY h:mm A', 23157 LLLL : 'dddd, MMMM D, YYYY h:mm A' 23158 }; 23159 23160 function longDateFormat (key) { 23161 var format = this._longDateFormat[key], 23162 formatUpper = this._longDateFormat[key.toUpperCase()]; 23163 23164 if (format || !formatUpper) { 23165 return format; 23166 } 23167 23168 this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) { 23169 return val.slice(1); 23170 }); 23171 23172 return this._longDateFormat[key]; 23173 } 23174 23175 var defaultInvalidDate = 'Invalid date'; 23176 23177 function invalidDate () { 23178 return this._invalidDate; 23179 } 23180 23181 var defaultOrdinal = '%d'; 23182 var defaultDayOfMonthOrdinalParse = /\d{1,2}/; 23183 23184 function ordinal (number) { 23185 return this._ordinal.replace('%d', number); 23186 } 23187 23188 var defaultRelativeTime = { 23189 future : 'in %s', 23190 past : '%s ago', 23191 s : 'a few seconds', 23192 ss : '%d seconds', 23193 m : 'a minute', 23194 mm : '%d minutes', 23195 h : 'an hour', 23196 hh : '%d hours', 23197 d : 'a day', 23198 dd : '%d days', 23199 M : 'a month', 23200 MM : '%d months', 23201 y : 'a year', 23202 yy : '%d years' 23203 }; 23204 23205 function relativeTime (number, withoutSuffix, string, isFuture) { 23206 var output = this._relativeTime[string]; 23207 return (isFunction(output)) ? 23208 output(number, withoutSuffix, string, isFuture) : 23209 output.replace(/%d/i, number); 23210 } 23211 23212 function pastFuture (diff, output) { 23213 var format = this._relativeTime[diff > 0 ? 'future' : 'past']; 23214 return isFunction(format) ? format(output) : format.replace(/%s/i, output); 23215 } 23216 23217 var aliases = {}; 23218 23219 function addUnitAlias (unit, shorthand) { 23220 var lowerCase = unit.toLowerCase(); 23221 aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit; 23222 } 23223 23224 function normalizeUnits(units) { 23225 return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined; 23226 } 23227 23228 function normalizeObjectUnits(inputObject) { 23229 var normalizedInput = {}, 23230 normalizedProp, 23231 prop; 23232 23233 for (prop in inputObject) { 23234 if (hasOwnProp(inputObject, prop)) { 23235 normalizedProp = normalizeUnits(prop); 23236 if (normalizedProp) { 23237 normalizedInput[normalizedProp] = inputObject[prop]; 23238 } 23239 } 23240 } 23241 23242 return normalizedInput; 23243 } 23244 23245 var priorities = {}; 23246 23247 function addUnitPriority(unit, priority) { 23248 priorities[unit] = priority; 23249 } 23250 23251 function getPrioritizedUnits(unitsObj) { 23252 var units = []; 23253 for (var u in unitsObj) { 23254 units.push({unit: u, priority: priorities[u]}); 23255 } 23256 units.sort(function (a, b) { 23257 return a.priority - b.priority; 23258 }); 23259 return units; 23260 } 23261 23262 function zeroFill(number, targetLength, forceSign) { 23263 var absNumber = '' + Math.abs(number), 23264 zerosToFill = targetLength - absNumber.length, 23265 sign = number >= 0; 23266 return (sign ? (forceSign ? '+' : '') : '-') + 23267 Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber; 23268 } 23269 23270 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; 23271 23272 var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g; 23273 23274 var formatFunctions = {}; 23275 23276 var formatTokenFunctions = {}; 23277 23278 // token: 'M' 23279 // padded: ['MM', 2] 23280 // ordinal: 'Mo' 23281 // callback: function () { this.month() + 1 } 23282 function addFormatToken (token, padded, ordinal, callback) { 23283 var func = callback; 23284 if (typeof callback === 'string') { 23285 func = function () { 23286 return this[callback](); 23287 }; 23288 } 23289 if (token) { 23290 formatTokenFunctions[token] = func; 23291 } 23292 if (padded) { 23293 formatTokenFunctions[padded[0]] = function () { 23294 return zeroFill(func.apply(this, arguments), padded[1], padded[2]); 23295 }; 23296 } 23297 if (ordinal) { 23298 formatTokenFunctions[ordinal] = function () { 23299 return this.localeData().ordinal(func.apply(this, arguments), token); 23300 }; 23301 } 23302 } 23303 23304 function removeFormattingTokens(input) { 23305 if (input.match(/\[[\s\S]/)) { 23306 return input.replace(/^\[|\]$/g, ''); 23307 } 23308 return input.replace(/\\/g, ''); 23309 } 23310 23311 function makeFormatFunction(format) { 23312 var array = format.match(formattingTokens), i, length; 23313 23314 for (i = 0, length = array.length; i < length; i++) { 23315 if (formatTokenFunctions[array[i]]) { 23316 array[i] = formatTokenFunctions[array[i]]; 23317 } else { 23318 array[i] = removeFormattingTokens(array[i]); 23319 } 23320 } 23321 23322 return function (mom) { 23323 var output = '', i; 23324 for (i = 0; i < length; i++) { 23325 output += isFunction(array[i]) ? array[i].call(mom, format) : array[i]; 23326 } 23327 return output; 23328 }; 23329 } 23330 23331 // format date using native date object 23332 function formatMoment(m, format) { 23333 if (!m.isValid()) { 23334 return m.localeData().invalidDate(); 23335 } 23336 23337 format = expandFormat(format, m.localeData()); 23338 formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format); 23339 23340 return formatFunctions[format](m); 23341 } 23342 23343 function expandFormat(format, locale) { 23344 var i = 5; 23345 23346 function replaceLongDateFormatTokens(input) { 23347 return locale.longDateFormat(input) || input; 23348 } 23349 23350 localFormattingTokens.lastIndex = 0; 23351 while (i >= 0 && localFormattingTokens.test(format)) { 23352 format = format.replace(localFormattingTokens, replaceLongDateFormatTokens); 23353 localFormattingTokens.lastIndex = 0; 23354 i -= 1; 23355 } 23356 23357 return format; 23358 } 23359 23360 var match1 = /\d/; // 0 - 9 23361 var match2 = /\d\d/; // 00 - 99 23362 var match3 = /\d{3}/; // 000 - 999 23363 var match4 = /\d{4}/; // 0000 - 9999 23364 var match6 = /[+-]?\d{6}/; // -999999 - 999999 23365 var match1to2 = /\d\d?/; // 0 - 99 23366 var match3to4 = /\d\d\d\d?/; // 999 - 9999 23367 var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999 23368 var match1to3 = /\d{1,3}/; // 0 - 999 23369 var match1to4 = /\d{1,4}/; // 0 - 9999 23370 var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999 23371 23372 var matchUnsigned = /\d+/; // 0 - inf 23373 var matchSigned = /[+-]?\d+/; // -inf - inf 23374 23375 var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z 23376 var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z 23377 23378 var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123 23379 23380 // any word (or two) characters or numbers including two/three word month in arabic. 23381 // includes scottish gaelic two word and hyphenated months 23382 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; 23383 23384 var regexes = {}; 23385 23386 function addRegexToken (token, regex, strictRegex) { 23387 regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) { 23388 return (isStrict && strictRegex) ? strictRegex : regex; 23389 }; 23390 } 23391 23392 function getParseRegexForToken (token, config) { 23393 if (!hasOwnProp(regexes, token)) { 23394 return new RegExp(unescapeFormat(token)); 23395 } 23396 23397 return regexes[token](config._strict, config._locale); 23398 } 23399 23400 // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript 23401 function unescapeFormat(s) { 23402 return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) { 23403 return p1 || p2 || p3 || p4; 23404 })); 23405 } 23406 23407 function regexEscape(s) { 23408 return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); 23409 } 23410 23411 var tokens = {}; 23412 23413 function addParseToken (token, callback) { 23414 var i, func = callback; 23415 if (typeof token === 'string') { 23416 token = [token]; 23417 } 23418 if (isNumber(callback)) { 23419 func = function (input, array) { 23420 array[callback] = toInt(input); 23421 }; 23422 } 23423 for (i = 0; i < token.length; i++) { 23424 tokens[token[i]] = func; 23425 } 23426 } 23427 23428 function addWeekParseToken (token, callback) { 23429 addParseToken(token, function (input, array, config, token) { 23430 config._w = config._w || {}; 23431 callback(input, config._w, config, token); 23432 }); 23433 } 23434 23435 function addTimeToArrayFromToken(token, input, config) { 23436 if (input != null && hasOwnProp(tokens, token)) { 23437 tokens[token](input, config._a, config, token); 23438 } 23439 } 23440 23441 var YEAR = 0; 23442 var MONTH = 1; 23443 var DATE = 2; 23444 var HOUR = 3; 23445 var MINUTE = 4; 23446 var SECOND = 5; 23447 var MILLISECOND = 6; 23448 var WEEK = 7; 23449 var WEEKDAY = 8; 23450 23451 // FORMATTING 23452 23453 addFormatToken('Y', 0, 0, function () { 23454 var y = this.year(); 23455 return y <= 9999 ? '' + y : '+' + y; 23456 }); 23457 23458 addFormatToken(0, ['YY', 2], 0, function () { 23459 return this.year() % 100; 23460 }); 23461 23462 addFormatToken(0, ['YYYY', 4], 0, 'year'); 23463 addFormatToken(0, ['YYYYY', 5], 0, 'year'); 23464 addFormatToken(0, ['YYYYYY', 6, true], 0, 'year'); 23465 23466 // ALIASES 23467 23468 addUnitAlias('year', 'y'); 23469 23470 // PRIORITIES 23471 23472 addUnitPriority('year', 1); 23473 23474 // PARSING 23475 23476 addRegexToken('Y', matchSigned); 23477 addRegexToken('YY', match1to2, match2); 23478 addRegexToken('YYYY', match1to4, match4); 23479 addRegexToken('YYYYY', match1to6, match6); 23480 addRegexToken('YYYYYY', match1to6, match6); 23481 23482 addParseToken(['YYYYY', 'YYYYYY'], YEAR); 23483 addParseToken('YYYY', function (input, array) { 23484 array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input); 23485 }); 23486 addParseToken('YY', function (input, array) { 23487 array[YEAR] = hooks.parseTwoDigitYear(input); 23488 }); 23489 addParseToken('Y', function (input, array) { 23490 array[YEAR] = parseInt(input, 10); 23491 }); 23492 23493 // HELPERS 23494 23495 function daysInYear(year) { 23496 return isLeapYear(year) ? 366 : 365; 23497 } 23498 23499 function isLeapYear(year) { 23500 return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; 23501 } 23502 23503 // HOOKS 23504 23505 hooks.parseTwoDigitYear = function (input) { 23506 return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); 23507 }; 23508 23509 // MOMENTS 23510 23511 var getSetYear = makeGetSet('FullYear', true); 23512 23513 function getIsLeapYear () { 23514 return isLeapYear(this.year()); 23515 } 23516 23517 function makeGetSet (unit, keepTime) { 23518 return function (value) { 23519 if (value != null) { 23520 set$1(this, unit, value); 23521 hooks.updateOffset(this, keepTime); 23522 return this; 23523 } else { 23524 return get(this, unit); 23525 } 23526 }; 23527 } 23528 23529 function get (mom, unit) { 23530 return mom.isValid() ? 23531 mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN; 23532 } 23533 23534 function set$1 (mom, unit, value) { 23535 if (mom.isValid() && !isNaN(value)) { 23536 if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) { 23537 mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month())); 23538 } 23539 else { 23540 mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value); 23541 } 23542 } 23543 } 23544 23545 // MOMENTS 23546 23547 function stringGet (units) { 23548 units = normalizeUnits(units); 23549 if (isFunction(this[units])) { 23550 return this[units](); 23551 } 23552 return this; 23553 } 23554 23555 23556 function stringSet (units, value) { 23557 if (typeof units === 'object') { 23558 units = normalizeObjectUnits(units); 23559 var prioritized = getPrioritizedUnits(units); 23560 for (var i = 0; i < prioritized.length; i++) { 23561 this[prioritized[i].unit](units[prioritized[i].unit]); 23562 } 23563 } else { 23564 units = normalizeUnits(units); 23565 if (isFunction(this[units])) { 23566 return this[units](value); 23567 } 23568 } 23569 return this; 23570 } 23571 23572 function mod(n, x) { 23573 return ((n % x) + x) % x; 23574 } 23575 23576 var indexOf; 23577 23578 if (Array.prototype.indexOf) { 23579 indexOf = Array.prototype.indexOf; 23580 } else { 23581 indexOf = function (o) { 23582 // I know 23583 var i; 23584 for (i = 0; i < this.length; ++i) { 23585 if (this[i] === o) { 23586 return i; 23587 } 23588 } 23589 return -1; 23590 }; 23591 } 23592 23593 function daysInMonth(year, month) { 23594 if (isNaN(year) || isNaN(month)) { 23595 return NaN; 23596 } 23597 var modMonth = mod(month, 12); 23598 year += (month - modMonth) / 12; 23599 return modMonth === 1 ? (isLeapYear(year) ? 29 : 28) : (31 - modMonth % 7 % 2); 23600 } 23601 23602 // FORMATTING 23603 23604 addFormatToken('M', ['MM', 2], 'Mo', function () { 23605 return this.month() + 1; 23606 }); 23607 23608 addFormatToken('MMM', 0, 0, function (format) { 23609 return this.localeData().monthsShort(this, format); 23610 }); 23611 23612 addFormatToken('MMMM', 0, 0, function (format) { 23613 return this.localeData().months(this, format); 23614 }); 23615 23616 // ALIASES 23617 23618 addUnitAlias('month', 'M'); 23619 23620 // PRIORITY 23621 23622 addUnitPriority('month', 8); 23623 23624 // PARSING 23625 23626 addRegexToken('M', match1to2); 23627 addRegexToken('MM', match1to2, match2); 23628 addRegexToken('MMM', function (isStrict, locale) { 23629 return locale.monthsShortRegex(isStrict); 23630 }); 23631 addRegexToken('MMMM', function (isStrict, locale) { 23632 return locale.monthsRegex(isStrict); 23633 }); 23634 23635 addParseToken(['M', 'MM'], function (input, array) { 23636 array[MONTH] = toInt(input) - 1; 23637 }); 23638 23639 addParseToken(['MMM', 'MMMM'], function (input, array, config, token) { 23640 var month = config._locale.monthsParse(input, token, config._strict); 23641 // if we didn't find a month name, mark the date as invalid. 23642 if (month != null) { 23643 array[MONTH] = month; 23644 } else { 23645 getParsingFlags(config).invalidMonth = input; 23646 } 23647 }); 23648 23649 // LOCALES 23650 23651 var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/; 23652 var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'); 23653 function localeMonths (m, format) { 23654 if (!m) { 23655 return isArray(this._months) ? this._months : 23656 this._months['standalone']; 23657 } 23658 return isArray(this._months) ? this._months[m.month()] : 23659 this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()]; 23660 } 23661 23662 var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'); 23663 function localeMonthsShort (m, format) { 23664 if (!m) { 23665 return isArray(this._monthsShort) ? this._monthsShort : 23666 this._monthsShort['standalone']; 23667 } 23668 return isArray(this._monthsShort) ? this._monthsShort[m.month()] : 23669 this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()]; 23670 } 23671 23672 function handleStrictParse(monthName, format, strict) { 23673 var i, ii, mom, llc = monthName.toLocaleLowerCase(); 23674 if (!this._monthsParse) { 23675 // this is not used 23676 this._monthsParse = []; 23677 this._longMonthsParse = []; 23678 this._shortMonthsParse = []; 23679 for (i = 0; i < 12; ++i) { 23680 mom = createUTC([2000, i]); 23681 this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase(); 23682 this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase(); 23683 } 23684 } 23685 23686 if (strict) { 23687 if (format === 'MMM') { 23688 ii = indexOf.call(this._shortMonthsParse, llc); 23689 return ii !== -1 ? ii : null; 23690 } else { 23691 ii = indexOf.call(this._longMonthsParse, llc); 23692 return ii !== -1 ? ii : null; 23693 } 23694 } else { 23695 if (format === 'MMM') { 23696 ii = indexOf.call(this._shortMonthsParse, llc); 23697 if (ii !== -1) { 23698 return ii; 23699 } 23700 ii = indexOf.call(this._longMonthsParse, llc); 23701 return ii !== -1 ? ii : null; 23702 } else { 23703 ii = indexOf.call(this._longMonthsParse, llc); 23704 if (ii !== -1) { 23705 return ii; 23706 } 23707 ii = indexOf.call(this._shortMonthsParse, llc); 23708 return ii !== -1 ? ii : null; 23709 } 23710 } 23711 } 23712 23713 function localeMonthsParse (monthName, format, strict) { 23714 var i, mom, regex; 23715 23716 if (this._monthsParseExact) { 23717 return handleStrictParse.call(this, monthName, format, strict); 23718 } 23719 23720 if (!this._monthsParse) { 23721 this._monthsParse = []; 23722 this._longMonthsParse = []; 23723 this._shortMonthsParse = []; 23724 } 23725 23726 // TODO: add sorting 23727 // Sorting makes sure if one month (or abbr) is a prefix of another 23728 // see sorting in computeMonthsParse 23729 for (i = 0; i < 12; i++) { 23730 // make the regex if we don't have it already 23731 mom = createUTC([2000, i]); 23732 if (strict && !this._longMonthsParse[i]) { 23733 this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i'); 23734 this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i'); 23735 } 23736 if (!strict && !this._monthsParse[i]) { 23737 regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); 23738 this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); 23739 } 23740 // test the regex 23741 if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) { 23742 return i; 23743 } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) { 23744 return i; 23745 } else if (!strict && this._monthsParse[i].test(monthName)) { 23746 return i; 23747 } 23748 } 23749 } 23750 23751 // MOMENTS 23752 23753 function setMonth (mom, value) { 23754 var dayOfMonth; 23755 23756 if (!mom.isValid()) { 23757 // No op 23758 return mom; 23759 } 23760 23761 if (typeof value === 'string') { 23762 if (/^\d+$/.test(value)) { 23763 value = toInt(value); 23764 } else { 23765 value = mom.localeData().monthsParse(value); 23766 // TODO: Another silent failure? 23767 if (!isNumber(value)) { 23768 return mom; 23769 } 23770 } 23771 } 23772 23773 dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value)); 23774 mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth); 23775 return mom; 23776 } 23777 23778 function getSetMonth (value) { 23779 if (value != null) { 23780 setMonth(this, value); 23781 hooks.updateOffset(this, true); 23782 return this; 23783 } else { 23784 return get(this, 'Month'); 23785 } 23786 } 23787 23788 function getDaysInMonth () { 23789 return daysInMonth(this.year(), this.month()); 23790 } 23791 23792 var defaultMonthsShortRegex = matchWord; 23793 function monthsShortRegex (isStrict) { 23794 if (this._monthsParseExact) { 23795 if (!hasOwnProp(this, '_monthsRegex')) { 23796 computeMonthsParse.call(this); 23797 } 23798 if (isStrict) { 23799 return this._monthsShortStrictRegex; 23800 } else { 23801 return this._monthsShortRegex; 23802 } 23803 } else { 23804 if (!hasOwnProp(this, '_monthsShortRegex')) { 23805 this._monthsShortRegex = defaultMonthsShortRegex; 23806 } 23807 return this._monthsShortStrictRegex && isStrict ? 23808 this._monthsShortStrictRegex : this._monthsShortRegex; 23809 } 23810 } 23811 23812 var defaultMonthsRegex = matchWord; 23813 function monthsRegex (isStrict) { 23814 if (this._monthsParseExact) { 23815 if (!hasOwnProp(this, '_monthsRegex')) { 23816 computeMonthsParse.call(this); 23817 } 23818 if (isStrict) { 23819 return this._monthsStrictRegex; 23820 } else { 23821 return this._monthsRegex; 23822 } 23823 } else { 23824 if (!hasOwnProp(this, '_monthsRegex')) { 23825 this._monthsRegex = defaultMonthsRegex; 23826 } 23827 return this._monthsStrictRegex && isStrict ? 23828 this._monthsStrictRegex : this._monthsRegex; 23829 } 23830 } 23831 23832 function computeMonthsParse () { 23833 function cmpLenRev(a, b) { 23834 return b.length - a.length; 23835 } 23836 23837 var shortPieces = [], longPieces = [], mixedPieces = [], 23838 i, mom; 23839 for (i = 0; i < 12; i++) { 23840 // make the regex if we don't have it already 23841 mom = createUTC([2000, i]); 23842 shortPieces.push(this.monthsShort(mom, '')); 23843 longPieces.push(this.months(mom, '')); 23844 mixedPieces.push(this.months(mom, '')); 23845 mixedPieces.push(this.monthsShort(mom, '')); 23846 } 23847 // Sorting makes sure if one month (or abbr) is a prefix of another it 23848 // will match the longer piece. 23849 shortPieces.sort(cmpLenRev); 23850 longPieces.sort(cmpLenRev); 23851 mixedPieces.sort(cmpLenRev); 23852 for (i = 0; i < 12; i++) { 23853 shortPieces[i] = regexEscape(shortPieces[i]); 23854 longPieces[i] = regexEscape(longPieces[i]); 23855 } 23856 for (i = 0; i < 24; i++) { 23857 mixedPieces[i] = regexEscape(mixedPieces[i]); 23858 } 23859 23860 this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); 23861 this._monthsShortRegex = this._monthsRegex; 23862 this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i'); 23863 this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i'); 23864 } 23865 23866 function createDate (y, m, d, h, M, s, ms) { 23867 // can't just apply() to create a date: 23868 // https://stackoverflow.com/q/181348 23869 var date = new Date(y, m, d, h, M, s, ms); 23870 23871 // the date constructor remaps years 0-99 to 1900-1999 23872 if (y < 100 && y >= 0 && isFinite(date.getFullYear())) { 23873 date.setFullYear(y); 23874 } 23875 return date; 23876 } 23877 23878 function createUTCDate (y) { 23879 var date = new Date(Date.UTC.apply(null, arguments)); 23880 23881 // the Date.UTC function remaps years 0-99 to 1900-1999 23882 if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) { 23883 date.setUTCFullYear(y); 23884 } 23885 return date; 23886 } 23887 23888 // start-of-first-week - start-of-year 23889 function firstWeekOffset(year, dow, doy) { 23890 var // first-week day -- which january is always in the first week (4 for iso, 1 for other) 23891 fwd = 7 + dow - doy, 23892 // first-week day local weekday -- which local weekday is fwd 23893 fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7; 23894 23895 return -fwdlw + fwd - 1; 23896 } 23897 23898 // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday 23899 function dayOfYearFromWeeks(year, week, weekday, dow, doy) { 23900 var localWeekday = (7 + weekday - dow) % 7, 23901 weekOffset = firstWeekOffset(year, dow, doy), 23902 dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset, 23903 resYear, resDayOfYear; 23904 23905 if (dayOfYear <= 0) { 23906 resYear = year - 1; 23907 resDayOfYear = daysInYear(resYear) + dayOfYear; 23908 } else if (dayOfYear > daysInYear(year)) { 23909 resYear = year + 1; 23910 resDayOfYear = dayOfYear - daysInYear(year); 23911 } else { 23912 resYear = year; 23913 resDayOfYear = dayOfYear; 23914 } 23915 23916 return { 23917 year: resYear, 23918 dayOfYear: resDayOfYear 23919 }; 23920 } 23921 23922 function weekOfYear(mom, dow, doy) { 23923 var weekOffset = firstWeekOffset(mom.year(), dow, doy), 23924 week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1, 23925 resWeek, resYear; 23926 23927 if (week < 1) { 23928 resYear = mom.year() - 1; 23929 resWeek = week + weeksInYear(resYear, dow, doy); 23930 } else if (week > weeksInYear(mom.year(), dow, doy)) { 23931 resWeek = week - weeksInYear(mom.year(), dow, doy); 23932 resYear = mom.year() + 1; 23933 } else { 23934 resYear = mom.year(); 23935 resWeek = week; 23936 } 23937 23938 return { 23939 week: resWeek, 23940 year: resYear 23941 }; 23942 } 23943 23944 function weeksInYear(year, dow, doy) { 23945 var weekOffset = firstWeekOffset(year, dow, doy), 23946 weekOffsetNext = firstWeekOffset(year + 1, dow, doy); 23947 return (daysInYear(year) - weekOffset + weekOffsetNext) / 7; 23948 } 23949 23950 // FORMATTING 23951 23952 addFormatToken('w', ['ww', 2], 'wo', 'week'); 23953 addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek'); 23954 23955 // ALIASES 23956 23957 addUnitAlias('week', 'w'); 23958 addUnitAlias('isoWeek', 'W'); 23959 23960 // PRIORITIES 23961 23962 addUnitPriority('week', 5); 23963 addUnitPriority('isoWeek', 5); 23964 23965 // PARSING 23966 23967 addRegexToken('w', match1to2); 23968 addRegexToken('ww', match1to2, match2); 23969 addRegexToken('W', match1to2); 23970 addRegexToken('WW', match1to2, match2); 23971 23972 addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) { 23973 week[token.substr(0, 1)] = toInt(input); 23974 }); 23975 23976 // HELPERS 23977 23978 // LOCALES 23979 23980 function localeWeek (mom) { 23981 return weekOfYear(mom, this._week.dow, this._week.doy).week; 23982 } 23983 23984 var defaultLocaleWeek = { 23985 dow : 0, // Sunday is the first day of the week. 23986 doy : 6 // The week that contains Jan 1st is the first week of the year. 23987 }; 23988 23989 function localeFirstDayOfWeek () { 23990 return this._week.dow; 23991 } 23992 23993 function localeFirstDayOfYear () { 23994 return this._week.doy; 23995 } 23996 23997 // MOMENTS 23998 23999 function getSetWeek (input) { 24000 var week = this.localeData().week(this); 24001 return input == null ? week : this.add((input - week) * 7, 'd'); 24002 } 24003 24004 function getSetISOWeek (input) { 24005 var week = weekOfYear(this, 1, 4).week; 24006 return input == null ? week : this.add((input - week) * 7, 'd'); 24007 } 24008 24009 // FORMATTING 24010 24011 addFormatToken('d', 0, 'do', 'day'); 24012 24013 addFormatToken('dd', 0, 0, function (format) { 24014 return this.localeData().weekdaysMin(this, format); 24015 }); 24016 24017 addFormatToken('ddd', 0, 0, function (format) { 24018 return this.localeData().weekdaysShort(this, format); 24019 }); 24020 24021 addFormatToken('dddd', 0, 0, function (format) { 24022 return this.localeData().weekdays(this, format); 24023 }); 24024 24025 addFormatToken('e', 0, 0, 'weekday'); 24026 addFormatToken('E', 0, 0, 'isoWeekday'); 24027 24028 // ALIASES 24029 24030 addUnitAlias('day', 'd'); 24031 addUnitAlias('weekday', 'e'); 24032 addUnitAlias('isoWeekday', 'E'); 24033 24034 // PRIORITY 24035 addUnitPriority('day', 11); 24036 addUnitPriority('weekday', 11); 24037 addUnitPriority('isoWeekday', 11); 24038 24039 // PARSING 24040 24041 addRegexToken('d', match1to2); 24042 addRegexToken('e', match1to2); 24043 addRegexToken('E', match1to2); 24044 addRegexToken('dd', function (isStrict, locale) { 24045 return locale.weekdaysMinRegex(isStrict); 24046 }); 24047 addRegexToken('ddd', function (isStrict, locale) { 24048 return locale.weekdaysShortRegex(isStrict); 24049 }); 24050 addRegexToken('dddd', function (isStrict, locale) { 24051 return locale.weekdaysRegex(isStrict); 24052 }); 24053 24054 addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) { 24055 var weekday = config._locale.weekdaysParse(input, token, config._strict); 24056 // if we didn't get a weekday name, mark the date as invalid 24057 if (weekday != null) { 24058 week.d = weekday; 24059 } else { 24060 getParsingFlags(config).invalidWeekday = input; 24061 } 24062 }); 24063 24064 addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) { 24065 week[token] = toInt(input); 24066 }); 24067 24068 // HELPERS 24069 24070 function parseWeekday(input, locale) { 24071 if (typeof input !== 'string') { 24072 return input; 24073 } 24074 24075 if (!isNaN(input)) { 24076 return parseInt(input, 10); 24077 } 24078 24079 input = locale.weekdaysParse(input); 24080 if (typeof input === 'number') { 24081 return input; 24082 } 24083 24084 return null; 24085 } 24086 24087 function parseIsoWeekday(input, locale) { 24088 if (typeof input === 'string') { 24089 return locale.weekdaysParse(input) % 7 || 7; 24090 } 24091 return isNaN(input) ? null : input; 24092 } 24093 24094 // LOCALES 24095 24096 var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'); 24097 function localeWeekdays (m, format) { 24098 if (!m) { 24099 return isArray(this._weekdays) ? this._weekdays : 24100 this._weekdays['standalone']; 24101 } 24102 return isArray(this._weekdays) ? this._weekdays[m.day()] : 24103 this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()]; 24104 } 24105 24106 var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'); 24107 function localeWeekdaysShort (m) { 24108 return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort; 24109 } 24110 24111 var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'); 24112 function localeWeekdaysMin (m) { 24113 return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin; 24114 } 24115 24116 function handleStrictParse$1(weekdayName, format, strict) { 24117 var i, ii, mom, llc = weekdayName.toLocaleLowerCase(); 24118 if (!this._weekdaysParse) { 24119 this._weekdaysParse = []; 24120 this._shortWeekdaysParse = []; 24121 this._minWeekdaysParse = []; 24122 24123 for (i = 0; i < 7; ++i) { 24124 mom = createUTC([2000, 1]).day(i); 24125 this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase(); 24126 this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase(); 24127 this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase(); 24128 } 24129 } 24130 24131 if (strict) { 24132 if (format === 'dddd') { 24133 ii = indexOf.call(this._weekdaysParse, llc); 24134 return ii !== -1 ? ii : null; 24135 } else if (format === 'ddd') { 24136 ii = indexOf.call(this._shortWeekdaysParse, llc); 24137 return ii !== -1 ? ii : null; 24138 } else { 24139 ii = indexOf.call(this._minWeekdaysParse, llc); 24140 return ii !== -1 ? ii : null; 24141 } 24142 } else { 24143 if (format === 'dddd') { 24144 ii = indexOf.call(this._weekdaysParse, llc); 24145 if (ii !== -1) { 24146 return ii; 24147 } 24148 ii = indexOf.call(this._shortWeekdaysParse, llc); 24149 if (ii !== -1) { 24150 return ii; 24151 } 24152 ii = indexOf.call(this._minWeekdaysParse, llc); 24153 return ii !== -1 ? ii : null; 24154 } else if (format === 'ddd') { 24155 ii = indexOf.call(this._shortWeekdaysParse, llc); 24156 if (ii !== -1) { 24157 return ii; 24158 } 24159 ii = indexOf.call(this._weekdaysParse, llc); 24160 if (ii !== -1) { 24161 return ii; 24162 } 24163 ii = indexOf.call(this._minWeekdaysParse, llc); 24164 return ii !== -1 ? ii : null; 24165 } else { 24166 ii = indexOf.call(this._minWeekdaysParse, llc); 24167 if (ii !== -1) { 24168 return ii; 24169 } 24170 ii = indexOf.call(this._weekdaysParse, llc); 24171 if (ii !== -1) { 24172 return ii; 24173 } 24174 ii = indexOf.call(this._shortWeekdaysParse, llc); 24175 return ii !== -1 ? ii : null; 24176 } 24177 } 24178 } 24179 24180 function localeWeekdaysParse (weekdayName, format, strict) { 24181 var i, mom, regex; 24182 24183 if (this._weekdaysParseExact) { 24184 return handleStrictParse$1.call(this, weekdayName, format, strict); 24185 } 24186 24187 if (!this._weekdaysParse) { 24188 this._weekdaysParse = []; 24189 this._minWeekdaysParse = []; 24190 this._shortWeekdaysParse = []; 24191 this._fullWeekdaysParse = []; 24192 } 24193 24194 for (i = 0; i < 7; i++) { 24195 // make the regex if we don't have it already 24196 24197 mom = createUTC([2000, 1]).day(i); 24198 if (strict && !this._fullWeekdaysParse[i]) { 24199 this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i'); 24200 this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i'); 24201 this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i'); 24202 } 24203 if (!this._weekdaysParse[i]) { 24204 regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, ''); 24205 this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); 24206 } 24207 // test the regex 24208 if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) { 24209 return i; 24210 } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) { 24211 return i; 24212 } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) { 24213 return i; 24214 } else if (!strict && this._weekdaysParse[i].test(weekdayName)) { 24215 return i; 24216 } 24217 } 24218 } 24219 24220 // MOMENTS 24221 24222 function getSetDayOfWeek (input) { 24223 if (!this.isValid()) { 24224 return input != null ? this : NaN; 24225 } 24226 var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); 24227 if (input != null) { 24228 input = parseWeekday(input, this.localeData()); 24229 return this.add(input - day, 'd'); 24230 } else { 24231 return day; 24232 } 24233 } 24234 24235 function getSetLocaleDayOfWeek (input) { 24236 if (!this.isValid()) { 24237 return input != null ? this : NaN; 24238 } 24239 var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7; 24240 return input == null ? weekday : this.add(input - weekday, 'd'); 24241 } 24242 24243 function getSetISODayOfWeek (input) { 24244 if (!this.isValid()) { 24245 return input != null ? this : NaN; 24246 } 24247 24248 // behaves the same as moment#day except 24249 // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) 24250 // as a setter, sunday should belong to the previous week. 24251 24252 if (input != null) { 24253 var weekday = parseIsoWeekday(input, this.localeData()); 24254 return this.day(this.day() % 7 ? weekday : weekday - 7); 24255 } else { 24256 return this.day() || 7; 24257 } 24258 } 24259 24260 var defaultWeekdaysRegex = matchWord; 24261 function weekdaysRegex (isStrict) { 24262 if (this._weekdaysParseExact) { 24263 if (!hasOwnProp(this, '_weekdaysRegex')) { 24264 computeWeekdaysParse.call(this); 24265 } 24266 if (isStrict) { 24267 return this._weekdaysStrictRegex; 24268 } else { 24269 return this._weekdaysRegex; 24270 } 24271 } else { 24272 if (!hasOwnProp(this, '_weekdaysRegex')) { 24273 this._weekdaysRegex = defaultWeekdaysRegex; 24274 } 24275 return this._weekdaysStrictRegex && isStrict ? 24276 this._weekdaysStrictRegex : this._weekdaysRegex; 24277 } 24278 } 24279 24280 var defaultWeekdaysShortRegex = matchWord; 24281 function weekdaysShortRegex (isStrict) { 24282 if (this._weekdaysParseExact) { 24283 if (!hasOwnProp(this, '_weekdaysRegex')) { 24284 computeWeekdaysParse.call(this); 24285 } 24286 if (isStrict) { 24287 return this._weekdaysShortStrictRegex; 24288 } else { 24289 return this._weekdaysShortRegex; 24290 } 24291 } else { 24292 if (!hasOwnProp(this, '_weekdaysShortRegex')) { 24293 this._weekdaysShortRegex = defaultWeekdaysShortRegex; 24294 } 24295 return this._weekdaysShortStrictRegex && isStrict ? 24296 this._weekdaysShortStrictRegex : this._weekdaysShortRegex; 24297 } 24298 } 24299 24300 var defaultWeekdaysMinRegex = matchWord; 24301 function weekdaysMinRegex (isStrict) { 24302 if (this._weekdaysParseExact) { 24303 if (!hasOwnProp(this, '_weekdaysRegex')) { 24304 computeWeekdaysParse.call(this); 24305 } 24306 if (isStrict) { 24307 return this._weekdaysMinStrictRegex; 24308 } else { 24309 return this._weekdaysMinRegex; 24310 } 24311 } else { 24312 if (!hasOwnProp(this, '_weekdaysMinRegex')) { 24313 this._weekdaysMinRegex = defaultWeekdaysMinRegex; 24314 } 24315 return this._weekdaysMinStrictRegex && isStrict ? 24316 this._weekdaysMinStrictRegex : this._weekdaysMinRegex; 24317 } 24318 } 24319 24320 24321 function computeWeekdaysParse () { 24322 function cmpLenRev(a, b) { 24323 return b.length - a.length; 24324 } 24325 24326 var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [], 24327 i, mom, minp, shortp, longp; 24328 for (i = 0; i < 7; i++) { 24329 // make the regex if we don't have it already 24330 mom = createUTC([2000, 1]).day(i); 24331 minp = this.weekdaysMin(mom, ''); 24332 shortp = this.weekdaysShort(mom, ''); 24333 longp = this.weekdays(mom, ''); 24334 minPieces.push(minp); 24335 shortPieces.push(shortp); 24336 longPieces.push(longp); 24337 mixedPieces.push(minp); 24338 mixedPieces.push(shortp); 24339 mixedPieces.push(longp); 24340 } 24341 // Sorting makes sure if one weekday (or abbr) is a prefix of another it 24342 // will match the longer piece. 24343 minPieces.sort(cmpLenRev); 24344 shortPieces.sort(cmpLenRev); 24345 longPieces.sort(cmpLenRev); 24346 mixedPieces.sort(cmpLenRev); 24347 for (i = 0; i < 7; i++) { 24348 shortPieces[i] = regexEscape(shortPieces[i]); 24349 longPieces[i] = regexEscape(longPieces[i]); 24350 mixedPieces[i] = regexEscape(mixedPieces[i]); 24351 } 24352 24353 this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); 24354 this._weekdaysShortRegex = this._weekdaysRegex; 24355 this._weekdaysMinRegex = this._weekdaysRegex; 24356 24357 this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i'); 24358 this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i'); 24359 this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i'); 24360 } 24361 24362 // FORMATTING 24363 24364 function hFormat() { 24365 return this.hours() % 12 || 12; 24366 } 24367 24368 function kFormat() { 24369 return this.hours() || 24; 24370 } 24371 24372 addFormatToken('H', ['HH', 2], 0, 'hour'); 24373 addFormatToken('h', ['hh', 2], 0, hFormat); 24374 addFormatToken('k', ['kk', 2], 0, kFormat); 24375 24376 addFormatToken('hmm', 0, 0, function () { 24377 return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2); 24378 }); 24379 24380 addFormatToken('hmmss', 0, 0, function () { 24381 return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) + 24382 zeroFill(this.seconds(), 2); 24383 }); 24384 24385 addFormatToken('Hmm', 0, 0, function () { 24386 return '' + this.hours() + zeroFill(this.minutes(), 2); 24387 }); 24388 24389 addFormatToken('Hmmss', 0, 0, function () { 24390 return '' + this.hours() + zeroFill(this.minutes(), 2) + 24391 zeroFill(this.seconds(), 2); 24392 }); 24393 24394 function meridiem (token, lowercase) { 24395 addFormatToken(token, 0, 0, function () { 24396 return this.localeData().meridiem(this.hours(), this.minutes(), lowercase); 24397 }); 24398 } 24399 24400 meridiem('a', true); 24401 meridiem('A', false); 24402 24403 // ALIASES 24404 24405 addUnitAlias('hour', 'h'); 24406 24407 // PRIORITY 24408 addUnitPriority('hour', 13); 24409 24410 // PARSING 24411 24412 function matchMeridiem (isStrict, locale) { 24413 return locale._meridiemParse; 24414 } 24415 24416 addRegexToken('a', matchMeridiem); 24417 addRegexToken('A', matchMeridiem); 24418 addRegexToken('H', match1to2); 24419 addRegexToken('h', match1to2); 24420 addRegexToken('k', match1to2); 24421 addRegexToken('HH', match1to2, match2); 24422 addRegexToken('hh', match1to2, match2); 24423 addRegexToken('kk', match1to2, match2); 24424 24425 addRegexToken('hmm', match3to4); 24426 addRegexToken('hmmss', match5to6); 24427 addRegexToken('Hmm', match3to4); 24428 addRegexToken('Hmmss', match5to6); 24429 24430 addParseToken(['H', 'HH'], HOUR); 24431 addParseToken(['k', 'kk'], function (input, array, config) { 24432 var kInput = toInt(input); 24433 array[HOUR] = kInput === 24 ? 0 : kInput; 24434 }); 24435 addParseToken(['a', 'A'], function (input, array, config) { 24436 config._isPm = config._locale.isPM(input); 24437 config._meridiem = input; 24438 }); 24439 addParseToken(['h', 'hh'], function (input, array, config) { 24440 array[HOUR] = toInt(input); 24441 getParsingFlags(config).bigHour = true; 24442 }); 24443 addParseToken('hmm', function (input, array, config) { 24444 var pos = input.length - 2; 24445 array[HOUR] = toInt(input.substr(0, pos)); 24446 array[MINUTE] = toInt(input.substr(pos)); 24447 getParsingFlags(config).bigHour = true; 24448 }); 24449 addParseToken('hmmss', function (input, array, config) { 24450 var pos1 = input.length - 4; 24451 var pos2 = input.length - 2; 24452 array[HOUR] = toInt(input.substr(0, pos1)); 24453 array[MINUTE] = toInt(input.substr(pos1, 2)); 24454 array[SECOND] = toInt(input.substr(pos2)); 24455 getParsingFlags(config).bigHour = true; 24456 }); 24457 addParseToken('Hmm', function (input, array, config) { 24458 var pos = input.length - 2; 24459 array[HOUR] = toInt(input.substr(0, pos)); 24460 array[MINUTE] = toInt(input.substr(pos)); 24461 }); 24462 addParseToken('Hmmss', function (input, array, config) { 24463 var pos1 = input.length - 4; 24464 var pos2 = input.length - 2; 24465 array[HOUR] = toInt(input.substr(0, pos1)); 24466 array[MINUTE] = toInt(input.substr(pos1, 2)); 24467 array[SECOND] = toInt(input.substr(pos2)); 24468 }); 24469 24470 // LOCALES 24471 24472 function localeIsPM (input) { 24473 // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays 24474 // Using charAt should be more compatible. 24475 return ((input + '').toLowerCase().charAt(0) === 'p'); 24476 } 24477 24478 var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i; 24479 function localeMeridiem (hours, minutes, isLower) { 24480 if (hours > 11) { 24481 return isLower ? 'pm' : 'PM'; 24482 } else { 24483 return isLower ? 'am' : 'AM'; 24484 } 24485 } 24486 24487 24488 // MOMENTS 24489 24490 // Setting the hour should keep the time, because the user explicitly 24491 // specified which hour they want. So trying to maintain the same hour (in 24492 // a new timezone) makes sense. Adding/subtracting hours does not follow 24493 // this rule. 24494 var getSetHour = makeGetSet('Hours', true); 24495 24496 var baseConfig = { 24497 calendar: defaultCalendar, 24498 longDateFormat: defaultLongDateFormat, 24499 invalidDate: defaultInvalidDate, 24500 ordinal: defaultOrdinal, 24501 dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse, 24502 relativeTime: defaultRelativeTime, 24503 24504 months: defaultLocaleMonths, 24505 monthsShort: defaultLocaleMonthsShort, 24506 24507 week: defaultLocaleWeek, 24508 24509 weekdays: defaultLocaleWeekdays, 24510 weekdaysMin: defaultLocaleWeekdaysMin, 24511 weekdaysShort: defaultLocaleWeekdaysShort, 24512 24513 meridiemParse: defaultLocaleMeridiemParse 24514 }; 24515 24516 // internal storage for locale config files 24517 var locales = {}; 24518 var localeFamilies = {}; 24519 var globalLocale; 24520 24521 function normalizeLocale(key) { 24522 return key ? key.toLowerCase().replace('_', '-') : key; 24523 } 24524 24525 // pick the locale from the array 24526 // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each 24527 // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root 24528 function chooseLocale(names) { 24529 var i = 0, j, next, locale, split; 24530 24531 while (i < names.length) { 24532 split = normalizeLocale(names[i]).split('-'); 24533 j = split.length; 24534 next = normalizeLocale(names[i + 1]); 24535 next = next ? next.split('-') : null; 24536 while (j > 0) { 24537 locale = loadLocale(split.slice(0, j).join('-')); 24538 if (locale) { 24539 return locale; 24540 } 24541 if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { 24542 //the next array item is better than a shallower substring of this one 24543 break; 24544 } 24545 j--; 24546 } 24547 i++; 24548 } 24549 return globalLocale; 24550 } 24551 24552 function loadLocale(name) { 24553 var oldLocale = null; 24554 // TODO: Find a better way to register and load all the locales in Node 24555 if (!locales[name] && (typeof module !== 'undefined') && 24556 module && module.exports) { 24557 try { 24558 oldLocale = globalLocale._abbr; 24559 var aliasedRequire = require; 24560 __webpack_require__("./node_modules/moment/locale sync recursive en")("./" + name); 24561 getSetGlobalLocale(oldLocale); 24562 } catch (e) {} 24563 } 24564 return locales[name]; 24565 } 24566 24567 // This function will load locale and then set the global locale. If 24568 // no arguments are passed in, it will simply return the current global 24569 // locale key. 24570 function getSetGlobalLocale (key, values) { 24571 var data; 24572 if (key) { 24573 if (isUndefined(values)) { 24574 data = getLocale(key); 24575 } 24576 else { 24577 data = defineLocale(key, values); 24578 } 24579 24580 if (data) { 24581 // moment.duration._locale = moment._locale = data; 24582 globalLocale = data; 24583 } 24584 else { 24585 if ((typeof console !== 'undefined') && console.warn) { 24586 //warn user if arguments are passed but the locale could not be set 24587 console.warn('Locale ' + key + ' not found. Did you forget to load it?'); 24588 } 24589 } 24590 } 24591 24592 return globalLocale._abbr; 24593 } 24594 24595 function defineLocale (name, config) { 24596 if (config !== null) { 24597 var locale, parentConfig = baseConfig; 24598 config.abbr = name; 24599 if (locales[name] != null) { 24600 deprecateSimple('defineLocaleOverride', 24601 'use moment.updateLocale(localeName, config) to change ' + 24602 'an existing locale. moment.defineLocale(localeName, ' + 24603 'config) should only be used for creating a new locale ' + 24604 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'); 24605 parentConfig = locales[name]._config; 24606 } else if (config.parentLocale != null) { 24607 if (locales[config.parentLocale] != null) { 24608 parentConfig = locales[config.parentLocale]._config; 24609 } else { 24610 locale = loadLocale(config.parentLocale); 24611 if (locale != null) { 24612 parentConfig = locale._config; 24613 } else { 24614 if (!localeFamilies[config.parentLocale]) { 24615 localeFamilies[config.parentLocale] = []; 24616 } 24617 localeFamilies[config.parentLocale].push({ 24618 name: name, 24619 config: config 24620 }); 24621 return null; 24622 } 24623 } 24624 } 24625 locales[name] = new Locale(mergeConfigs(parentConfig, config)); 24626 24627 if (localeFamilies[name]) { 24628 localeFamilies[name].forEach(function (x) { 24629 defineLocale(x.name, x.config); 24630 }); 24631 } 24632 24633 // backwards compat for now: also set the locale 24634 // make sure we set the locale AFTER all child locales have been 24635 // created, so we won't end up with the child locale set. 24636 getSetGlobalLocale(name); 24637 24638 24639 return locales[name]; 24640 } else { 24641 // useful for testing 24642 delete locales[name]; 24643 return null; 24644 } 24645 } 24646 24647 function updateLocale(name, config) { 24648 if (config != null) { 24649 var locale, tmpLocale, parentConfig = baseConfig; 24650 // MERGE 24651 tmpLocale = loadLocale(name); 24652 if (tmpLocale != null) { 24653 parentConfig = tmpLocale._config; 24654 } 24655 config = mergeConfigs(parentConfig, config); 24656 locale = new Locale(config); 24657 locale.parentLocale = locales[name]; 24658 locales[name] = locale; 24659 24660 // backwards compat for now: also set the locale 24661 getSetGlobalLocale(name); 24662 } else { 24663 // pass null for config to unupdate, useful for tests 24664 if (locales[name] != null) { 24665 if (locales[name].parentLocale != null) { 24666 locales[name] = locales[name].parentLocale; 24667 } else if (locales[name] != null) { 24668 delete locales[name]; 24669 } 24670 } 24671 } 24672 return locales[name]; 24673 } 24674 24675 // returns locale data 24676 function getLocale (key) { 24677 var locale; 24678 24679 if (key && key._locale && key._locale._abbr) { 24680 key = key._locale._abbr; 24681 } 24682 24683 if (!key) { 24684 return globalLocale; 24685 } 24686 24687 if (!isArray(key)) { 24688 //short-circuit everything else 24689 locale = loadLocale(key); 24690 if (locale) { 24691 return locale; 24692 } 24693 key = [key]; 24694 } 24695 24696 return chooseLocale(key); 24697 } 24698 24699 function listLocales() { 24700 return keys(locales); 24701 } 24702 24703 function checkOverflow (m) { 24704 var overflow; 24705 var a = m._a; 24706 24707 if (a && getParsingFlags(m).overflow === -2) { 24708 overflow = 24709 a[MONTH] < 0 || a[MONTH] > 11 ? MONTH : 24710 a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE : 24711 a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR : 24712 a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE : 24713 a[SECOND] < 0 || a[SECOND] > 59 ? SECOND : 24714 a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND : 24715 -1; 24716 24717 if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) { 24718 overflow = DATE; 24719 } 24720 if (getParsingFlags(m)._overflowWeeks && overflow === -1) { 24721 overflow = WEEK; 24722 } 24723 if (getParsingFlags(m)._overflowWeekday && overflow === -1) { 24724 overflow = WEEKDAY; 24725 } 24726 24727 getParsingFlags(m).overflow = overflow; 24728 } 24729 24730 return m; 24731 } 24732 24733 // Pick the first defined of two or three arguments. 24734 function defaults(a, b, c) { 24735 if (a != null) { 24736 return a; 24737 } 24738 if (b != null) { 24739 return b; 24740 } 24741 return c; 24742 } 24743 24744 function currentDateArray(config) { 24745 // hooks is actually the exported moment object 24746 var nowValue = new Date(hooks.now()); 24747 if (config._useUTC) { 24748 return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()]; 24749 } 24750 return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()]; 24751 } 24752 24753 // convert an array to a date. 24754 // the array should mirror the parameters below 24755 // note: all values past the year are optional and will default to the lowest possible value. 24756 // [year, month, day , hour, minute, second, millisecond] 24757 function configFromArray (config) { 24758 var i, date, input = [], currentDate, expectedWeekday, yearToUse; 24759 24760 if (config._d) { 24761 return; 24762 } 24763 24764 currentDate = currentDateArray(config); 24765 24766 //compute day of the year from weeks and weekdays 24767 if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { 24768 dayOfYearFromWeekInfo(config); 24769 } 24770 24771 //if the day of the year is set, figure out what it is 24772 if (config._dayOfYear != null) { 24773 yearToUse = defaults(config._a[YEAR], currentDate[YEAR]); 24774 24775 if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) { 24776 getParsingFlags(config)._overflowDayOfYear = true; 24777 } 24778 24779 date = createUTCDate(yearToUse, 0, config._dayOfYear); 24780 config._a[MONTH] = date.getUTCMonth(); 24781 config._a[DATE] = date.getUTCDate(); 24782 } 24783 24784 // Default to current date. 24785 // * if no year, month, day of month are given, default to today 24786 // * if day of month is given, default month and year 24787 // * if month is given, default only year 24788 // * if year is given, don't default anything 24789 for (i = 0; i < 3 && config._a[i] == null; ++i) { 24790 config._a[i] = input[i] = currentDate[i]; 24791 } 24792 24793 // Zero out whatever was not defaulted, including time 24794 for (; i < 7; i++) { 24795 config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; 24796 } 24797 24798 // Check for 24:00:00.000 24799 if (config._a[HOUR] === 24 && 24800 config._a[MINUTE] === 0 && 24801 config._a[SECOND] === 0 && 24802 config._a[MILLISECOND] === 0) { 24803 config._nextDay = true; 24804 config._a[HOUR] = 0; 24805 } 24806 24807 config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input); 24808 expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay(); 24809 24810 // Apply timezone offset from input. The actual utcOffset can be changed 24811 // with parseZone. 24812 if (config._tzm != null) { 24813 config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm); 24814 } 24815 24816 if (config._nextDay) { 24817 config._a[HOUR] = 24; 24818 } 24819 24820 // check for mismatching day of week 24821 if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) { 24822 getParsingFlags(config).weekdayMismatch = true; 24823 } 24824 } 24825 24826 function dayOfYearFromWeekInfo(config) { 24827 var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow; 24828 24829 w = config._w; 24830 if (w.GG != null || w.W != null || w.E != null) { 24831 dow = 1; 24832 doy = 4; 24833 24834 // TODO: We need to take the current isoWeekYear, but that depends on 24835 // how we interpret now (local, utc, fixed offset). So create 24836 // a now version of current config (take local/utc/offset flags, and 24837 // create now). 24838 weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year); 24839 week = defaults(w.W, 1); 24840 weekday = defaults(w.E, 1); 24841 if (weekday < 1 || weekday > 7) { 24842 weekdayOverflow = true; 24843 } 24844 } else { 24845 dow = config._locale._week.dow; 24846 doy = config._locale._week.doy; 24847 24848 var curWeek = weekOfYear(createLocal(), dow, doy); 24849 24850 weekYear = defaults(w.gg, config._a[YEAR], curWeek.year); 24851 24852 // Default to current week. 24853 week = defaults(w.w, curWeek.week); 24854 24855 if (w.d != null) { 24856 // weekday -- low day numbers are considered next week 24857 weekday = w.d; 24858 if (weekday < 0 || weekday > 6) { 24859 weekdayOverflow = true; 24860 } 24861 } else if (w.e != null) { 24862 // local weekday -- counting starts from begining of week 24863 weekday = w.e + dow; 24864 if (w.e < 0 || w.e > 6) { 24865 weekdayOverflow = true; 24866 } 24867 } else { 24868 // default to begining of week 24869 weekday = dow; 24870 } 24871 } 24872 if (week < 1 || week > weeksInYear(weekYear, dow, doy)) { 24873 getParsingFlags(config)._overflowWeeks = true; 24874 } else if (weekdayOverflow != null) { 24875 getParsingFlags(config)._overflowWeekday = true; 24876 } else { 24877 temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy); 24878 config._a[YEAR] = temp.year; 24879 config._dayOfYear = temp.dayOfYear; 24880 } 24881 } 24882 24883 // iso 8601 regex 24884 // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00) 24885 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)?)?$/; 24886 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)?)?$/; 24887 24888 var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/; 24889 24890 var isoDates = [ 24891 ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], 24892 ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], 24893 ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], 24894 ['GGGG-[W]WW', /\d{4}-W\d\d/, false], 24895 ['YYYY-DDD', /\d{4}-\d{3}/], 24896 ['YYYY-MM', /\d{4}-\d\d/, false], 24897 ['YYYYYYMMDD', /[+-]\d{10}/], 24898 ['YYYYMMDD', /\d{8}/], 24899 // YYYYMM is NOT allowed by the standard 24900 ['GGGG[W]WWE', /\d{4}W\d{3}/], 24901 ['GGGG[W]WW', /\d{4}W\d{2}/, false], 24902 ['YYYYDDD', /\d{7}/] 24903 ]; 24904 24905 // iso time formats and regexes 24906 var isoTimes = [ 24907 ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], 24908 ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], 24909 ['HH:mm:ss', /\d\d:\d\d:\d\d/], 24910 ['HH:mm', /\d\d:\d\d/], 24911 ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], 24912 ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], 24913 ['HHmmss', /\d\d\d\d\d\d/], 24914 ['HHmm', /\d\d\d\d/], 24915 ['HH', /\d\d/] 24916 ]; 24917 24918 var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i; 24919 24920 // date from iso format 24921 function configFromISO(config) { 24922 var i, l, 24923 string = config._i, 24924 match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string), 24925 allowTime, dateFormat, timeFormat, tzFormat; 24926 24927 if (match) { 24928 getParsingFlags(config).iso = true; 24929 24930 for (i = 0, l = isoDates.length; i < l; i++) { 24931 if (isoDates[i][1].exec(match[1])) { 24932 dateFormat = isoDates[i][0]; 24933 allowTime = isoDates[i][2] !== false; 24934 break; 24935 } 24936 } 24937 if (dateFormat == null) { 24938 config._isValid = false; 24939 return; 24940 } 24941 if (match[3]) { 24942 for (i = 0, l = isoTimes.length; i < l; i++) { 24943 if (isoTimes[i][1].exec(match[3])) { 24944 // match[2] should be 'T' or space 24945 timeFormat = (match[2] || ' ') + isoTimes[i][0]; 24946 break; 24947 } 24948 } 24949 if (timeFormat == null) { 24950 config._isValid = false; 24951 return; 24952 } 24953 } 24954 if (!allowTime && timeFormat != null) { 24955 config._isValid = false; 24956 return; 24957 } 24958 if (match[4]) { 24959 if (tzRegex.exec(match[4])) { 24960 tzFormat = 'Z'; 24961 } else { 24962 config._isValid = false; 24963 return; 24964 } 24965 } 24966 config._f = dateFormat + (timeFormat || '') + (tzFormat || ''); 24967 configFromStringAndFormat(config); 24968 } else { 24969 config._isValid = false; 24970 } 24971 } 24972 24973 // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3 24974 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}))$/; 24975 24976 function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) { 24977 var result = [ 24978 untruncateYear(yearStr), 24979 defaultLocaleMonthsShort.indexOf(monthStr), 24980 parseInt(dayStr, 10), 24981 parseInt(hourStr, 10), 24982 parseInt(minuteStr, 10) 24983 ]; 24984 24985 if (secondStr) { 24986 result.push(parseInt(secondStr, 10)); 24987 } 24988 24989 return result; 24990 } 24991 24992 function untruncateYear(yearStr) { 24993 var year = parseInt(yearStr, 10); 24994 if (year <= 49) { 24995 return 2000 + year; 24996 } else if (year <= 999) { 24997 return 1900 + year; 24998 } 24999 return year; 25000 } 25001 25002 function preprocessRFC2822(s) { 25003 // Remove comments and folding whitespace and replace multiple-spaces with a single space 25004 return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, ''); 25005 } 25006 25007 function checkWeekday(weekdayStr, parsedInput, config) { 25008 if (weekdayStr) { 25009 // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check. 25010 var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr), 25011 weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay(); 25012 if (weekdayProvided !== weekdayActual) { 25013 getParsingFlags(config).weekdayMismatch = true; 25014 config._isValid = false; 25015 return false; 25016 } 25017 } 25018 return true; 25019 } 25020 25021 var obsOffsets = { 25022 UT: 0, 25023 GMT: 0, 25024 EDT: -4 * 60, 25025 EST: -5 * 60, 25026 CDT: -5 * 60, 25027 CST: -6 * 60, 25028 MDT: -6 * 60, 25029 MST: -7 * 60, 25030 PDT: -7 * 60, 25031 PST: -8 * 60 25032 }; 25033 25034 function calculateOffset(obsOffset, militaryOffset, numOffset) { 25035 if (obsOffset) { 25036 return obsOffsets[obsOffset]; 25037 } else if (militaryOffset) { 25038 // the only allowed military tz is Z 25039 return 0; 25040 } else { 25041 var hm = parseInt(numOffset, 10); 25042 var m = hm % 100, h = (hm - m) / 100; 25043 return h * 60 + m; 25044 } 25045 } 25046 25047 // date and time from ref 2822 format 25048 function configFromRFC2822(config) { 25049 var match = rfc2822.exec(preprocessRFC2822(config._i)); 25050 if (match) { 25051 var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]); 25052 if (!checkWeekday(match[1], parsedArray, config)) { 25053 return; 25054 } 25055 25056 config._a = parsedArray; 25057 config._tzm = calculateOffset(match[8], match[9], match[10]); 25058 25059 config._d = createUTCDate.apply(null, config._a); 25060 config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm); 25061 25062 getParsingFlags(config).rfc2822 = true; 25063 } else { 25064 config._isValid = false; 25065 } 25066 } 25067 25068 // date from iso format or fallback 25069 function configFromString(config) { 25070 var matched = aspNetJsonRegex.exec(config._i); 25071 25072 if (matched !== null) { 25073 config._d = new Date(+matched[1]); 25074 return; 25075 } 25076 25077 configFromISO(config); 25078 if (config._isValid === false) { 25079 delete config._isValid; 25080 } else { 25081 return; 25082 } 25083 25084 configFromRFC2822(config); 25085 if (config._isValid === false) { 25086 delete config._isValid; 25087 } else { 25088 return; 25089 } 25090 25091 // Final attempt, use Input Fallback 25092 hooks.createFromInputFallback(config); 25093 } 25094 25095 hooks.createFromInputFallback = deprecate( 25096 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' + 25097 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' + 25098 'discouraged and will be removed in an upcoming major release. Please refer to ' + 25099 'http://momentjs.com/guides/#/warnings/js-date/ for more info.', 25100 function (config) { 25101 config._d = new Date(config._i + (config._useUTC ? ' UTC' : '')); 25102 } 25103 ); 25104 25105 // constant that refers to the ISO standard 25106 hooks.ISO_8601 = function () {}; 25107 25108 // constant that refers to the RFC 2822 form 25109 hooks.RFC_2822 = function () {}; 25110 25111 // date from string and format string 25112 function configFromStringAndFormat(config) { 25113 // TODO: Move this to another part of the creation flow to prevent circular deps 25114 if (config._f === hooks.ISO_8601) { 25115 configFromISO(config); 25116 return; 25117 } 25118 if (config._f === hooks.RFC_2822) { 25119 configFromRFC2822(config); 25120 return; 25121 } 25122 config._a = []; 25123 getParsingFlags(config).empty = true; 25124 25125 // This array is used to make a Date, either with `new Date` or `Date.UTC` 25126 var string = '' + config._i, 25127 i, parsedInput, tokens, token, skipped, 25128 stringLength = string.length, 25129 totalParsedInputLength = 0; 25130 25131 tokens = expandFormat(config._f, config._locale).match(formattingTokens) || []; 25132 25133 for (i = 0; i < tokens.length; i++) { 25134 token = tokens[i]; 25135 parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0]; 25136 // console.log('token', token, 'parsedInput', parsedInput, 25137 // 'regex', getParseRegexForToken(token, config)); 25138 if (parsedInput) { 25139 skipped = string.substr(0, string.indexOf(parsedInput)); 25140 if (skipped.length > 0) { 25141 getParsingFlags(config).unusedInput.push(skipped); 25142 } 25143 string = string.slice(string.indexOf(parsedInput) + parsedInput.length); 25144 totalParsedInputLength += parsedInput.length; 25145 } 25146 // don't parse if it's not a known token 25147 if (formatTokenFunctions[token]) { 25148 if (parsedInput) { 25149 getParsingFlags(config).empty = false; 25150 } 25151 else { 25152 getParsingFlags(config).unusedTokens.push(token); 25153 } 25154 addTimeToArrayFromToken(token, parsedInput, config); 25155 } 25156 else if (config._strict && !parsedInput) { 25157 getParsingFlags(config).unusedTokens.push(token); 25158 } 25159 } 25160 25161 // add remaining unparsed input length to the string 25162 getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength; 25163 if (string.length > 0) { 25164 getParsingFlags(config).unusedInput.push(string); 25165 } 25166 25167 // clear _12h flag if hour is <= 12 25168 if (config._a[HOUR] <= 12 && 25169 getParsingFlags(config).bigHour === true && 25170 config._a[HOUR] > 0) { 25171 getParsingFlags(config).bigHour = undefined; 25172 } 25173 25174 getParsingFlags(config).parsedDateParts = config._a.slice(0); 25175 getParsingFlags(config).meridiem = config._meridiem; 25176 // handle meridiem 25177 config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem); 25178 25179 configFromArray(config); 25180 checkOverflow(config); 25181 } 25182 25183 25184 function meridiemFixWrap (locale, hour, meridiem) { 25185 var isPm; 25186 25187 if (meridiem == null) { 25188 // nothing to do 25189 return hour; 25190 } 25191 if (locale.meridiemHour != null) { 25192 return locale.meridiemHour(hour, meridiem); 25193 } else if (locale.isPM != null) { 25194 // Fallback 25195 isPm = locale.isPM(meridiem); 25196 if (isPm && hour < 12) { 25197 hour += 12; 25198 } 25199 if (!isPm && hour === 12) { 25200 hour = 0; 25201 } 25202 return hour; 25203 } else { 25204 // this is not supposed to happen 25205 return hour; 25206 } 25207 } 25208 25209 // date from string and array of format strings 25210 function configFromStringAndArray(config) { 25211 var tempConfig, 25212 bestMoment, 25213 25214 scoreToBeat, 25215 i, 25216 currentScore; 25217 25218 if (config._f.length === 0) { 25219 getParsingFlags(config).invalidFormat = true; 25220 config._d = new Date(NaN); 25221 return; 25222 } 25223 25224 for (i = 0; i < config._f.length; i++) { 25225 currentScore = 0; 25226 tempConfig = copyConfig({}, config); 25227 if (config._useUTC != null) { 25228 tempConfig._useUTC = config._useUTC; 25229 } 25230 tempConfig._f = config._f[i]; 25231 configFromStringAndFormat(tempConfig); 25232 25233 if (!isValid(tempConfig)) { 25234 continue; 25235 } 25236 25237 // if there is any input that was not parsed add a penalty for that format 25238 currentScore += getParsingFlags(tempConfig).charsLeftOver; 25239 25240 //or tokens 25241 currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10; 25242 25243 getParsingFlags(tempConfig).score = currentScore; 25244 25245 if (scoreToBeat == null || currentScore < scoreToBeat) { 25246 scoreToBeat = currentScore; 25247 bestMoment = tempConfig; 25248 } 25249 } 25250 25251 extend(config, bestMoment || tempConfig); 25252 } 25253 25254 function configFromObject(config) { 25255 if (config._d) { 25256 return; 25257 } 25258 25259 var i = normalizeObjectUnits(config._i); 25260 config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) { 25261 return obj && parseInt(obj, 10); 25262 }); 25263 25264 configFromArray(config); 25265 } 25266 25267 function createFromConfig (config) { 25268 var res = new Moment(checkOverflow(prepareConfig(config))); 25269 if (res._nextDay) { 25270 // Adding is smart enough around DST 25271 res.add(1, 'd'); 25272 res._nextDay = undefined; 25273 } 25274 25275 return res; 25276 } 25277 25278 function prepareConfig (config) { 25279 var input = config._i, 25280 format = config._f; 25281 25282 config._locale = config._locale || getLocale(config._l); 25283 25284 if (input === null || (format === undefined && input === '')) { 25285 return createInvalid({nullInput: true}); 25286 } 25287 25288 if (typeof input === 'string') { 25289 config._i = input = config._locale.preparse(input); 25290 } 25291 25292 if (isMoment(input)) { 25293 return new Moment(checkOverflow(input)); 25294 } else if (isDate(input)) { 25295 config._d = input; 25296 } else if (isArray(format)) { 25297 configFromStringAndArray(config); 25298 } else if (format) { 25299 configFromStringAndFormat(config); 25300 } else { 25301 configFromInput(config); 25302 } 25303 25304 if (!isValid(config)) { 25305 config._d = null; 25306 } 25307 25308 return config; 25309 } 25310 25311 function configFromInput(config) { 25312 var input = config._i; 25313 if (isUndefined(input)) { 25314 config._d = new Date(hooks.now()); 25315 } else if (isDate(input)) { 25316 config._d = new Date(input.valueOf()); 25317 } else if (typeof input === 'string') { 25318 configFromString(config); 25319 } else if (isArray(input)) { 25320 config._a = map(input.slice(0), function (obj) { 25321 return parseInt(obj, 10); 25322 }); 25323 configFromArray(config); 25324 } else if (isObject(input)) { 25325 configFromObject(config); 25326 } else if (isNumber(input)) { 25327 // from milliseconds 25328 config._d = new Date(input); 25329 } else { 25330 hooks.createFromInputFallback(config); 25331 } 25332 } 25333 25334 function createLocalOrUTC (input, format, locale, strict, isUTC) { 25335 var c = {}; 25336 25337 if (locale === true || locale === false) { 25338 strict = locale; 25339 locale = undefined; 25340 } 25341 25342 if ((isObject(input) && isObjectEmpty(input)) || 25343 (isArray(input) && input.length === 0)) { 25344 input = undefined; 25345 } 25346 // object construction must be done this way. 25347 // https://github.com/moment/moment/issues/1423 25348 c._isAMomentObject = true; 25349 c._useUTC = c._isUTC = isUTC; 25350 c._l = locale; 25351 c._i = input; 25352 c._f = format; 25353 c._strict = strict; 25354 25355 return createFromConfig(c); 25356 } 25357 25358 function createLocal (input, format, locale, strict) { 25359 return createLocalOrUTC(input, format, locale, strict, false); 25360 } 25361 25362 var prototypeMin = deprecate( 25363 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/', 25364 function () { 25365 var other = createLocal.apply(null, arguments); 25366 if (this.isValid() && other.isValid()) { 25367 return other < this ? this : other; 25368 } else { 25369 return createInvalid(); 25370 } 25371 } 25372 ); 25373 25374 var prototypeMax = deprecate( 25375 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', 25376 function () { 25377 var other = createLocal.apply(null, arguments); 25378 if (this.isValid() && other.isValid()) { 25379 return other > this ? this : other; 25380 } else { 25381 return createInvalid(); 25382 } 25383 } 25384 ); 25385 25386 // Pick a moment m from moments so that m[fn](other) is true for all 25387 // other. This relies on the function fn to be transitive. 25388 // 25389 // moments should either be an array of moment objects or an array, whose 25390 // first element is an array of moment objects. 25391 function pickBy(fn, moments) { 25392 var res, i; 25393 if (moments.length === 1 && isArray(moments[0])) { 25394 moments = moments[0]; 25395 } 25396 if (!moments.length) { 25397 return createLocal(); 25398 } 25399 res = moments[0]; 25400 for (i = 1; i < moments.length; ++i) { 25401 if (!moments[i].isValid() || moments[i][fn](res)) { 25402 res = moments[i]; 25403 } 25404 } 25405 return res; 25406 } 25407 25408 // TODO: Use [].sort instead? 25409 function min () { 25410 var args = [].slice.call(arguments, 0); 25411 25412 return pickBy('isBefore', args); 25413 } 25414 25415 function max () { 25416 var args = [].slice.call(arguments, 0); 25417 25418 return pickBy('isAfter', args); 25419 } 25420 25421 var now = function () { 25422 return Date.now ? Date.now() : +(new Date()); 25423 }; 25424 25425 var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond']; 25426 25427 function isDurationValid(m) { 25428 for (var key in m) { 25429 if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) { 25430 return false; 25431 } 25432 } 25433 25434 var unitHasDecimal = false; 25435 for (var i = 0; i < ordering.length; ++i) { 25436 if (m[ordering[i]]) { 25437 if (unitHasDecimal) { 25438 return false; // only allow non-integers for smallest unit 25439 } 25440 if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) { 25441 unitHasDecimal = true; 25442 } 25443 } 25444 } 25445 25446 return true; 25447 } 25448 25449 function isValid$1() { 25450 return this._isValid; 25451 } 25452 25453 function createInvalid$1() { 25454 return createDuration(NaN); 25455 } 25456 25457 function Duration (duration) { 25458 var normalizedInput = normalizeObjectUnits(duration), 25459 years = normalizedInput.year || 0, 25460 quarters = normalizedInput.quarter || 0, 25461 months = normalizedInput.month || 0, 25462 weeks = normalizedInput.week || 0, 25463 days = normalizedInput.day || 0, 25464 hours = normalizedInput.hour || 0, 25465 minutes = normalizedInput.minute || 0, 25466 seconds = normalizedInput.second || 0, 25467 milliseconds = normalizedInput.millisecond || 0; 25468 25469 this._isValid = isDurationValid(normalizedInput); 25470 25471 // representation for dateAddRemove 25472 this._milliseconds = +milliseconds + 25473 seconds * 1e3 + // 1000 25474 minutes * 6e4 + // 1000 * 60 25475 hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978 25476 // Because of dateAddRemove treats 24 hours as different from a 25477 // day when working around DST, we need to store them separately 25478 this._days = +days + 25479 weeks * 7; 25480 // It is impossible to translate months into days without knowing 25481 // which months you are are talking about, so we have to store 25482 // it separately. 25483 this._months = +months + 25484 quarters * 3 + 25485 years * 12; 25486 25487 this._data = {}; 25488 25489 this._locale = getLocale(); 25490 25491 this._bubble(); 25492 } 25493 25494 function isDuration (obj) { 25495 return obj instanceof Duration; 25496 } 25497 25498 function absRound (number) { 25499 if (number < 0) { 25500 return Math.round(-1 * number) * -1; 25501 } else { 25502 return Math.round(number); 25503 } 25504 } 25505 25506 // FORMATTING 25507 25508 function offset (token, separator) { 25509 addFormatToken(token, 0, 0, function () { 25510 var offset = this.utcOffset(); 25511 var sign = '+'; 25512 if (offset < 0) { 25513 offset = -offset; 25514 sign = '-'; 25515 } 25516 return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2); 25517 }); 25518 } 25519 25520 offset('Z', ':'); 25521 offset('ZZ', ''); 25522 25523 // PARSING 25524 25525 addRegexToken('Z', matchShortOffset); 25526 addRegexToken('ZZ', matchShortOffset); 25527 addParseToken(['Z', 'ZZ'], function (input, array, config) { 25528 config._useUTC = true; 25529 config._tzm = offsetFromString(matchShortOffset, input); 25530 }); 25531 25532 // HELPERS 25533 25534 // timezone chunker 25535 // '+10:00' > ['10', '00'] 25536 // '-1530' > ['-15', '30'] 25537 var chunkOffset = /([\+\-]|\d\d)/gi; 25538 25539 function offsetFromString(matcher, string) { 25540 var matches = (string || '').match(matcher); 25541 25542 if (matches === null) { 25543 return null; 25544 } 25545 25546 var chunk = matches[matches.length - 1] || []; 25547 var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0]; 25548 var minutes = +(parts[1] * 60) + toInt(parts[2]); 25549 25550 return minutes === 0 ? 25551 0 : 25552 parts[0] === '+' ? minutes : -minutes; 25553 } 25554 25555 // Return a moment from input, that is local/utc/zone equivalent to model. 25556 function cloneWithOffset(input, model) { 25557 var res, diff; 25558 if (model._isUTC) { 25559 res = model.clone(); 25560 diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf(); 25561 // Use low-level api, because this fn is low-level api. 25562 res._d.setTime(res._d.valueOf() + diff); 25563 hooks.updateOffset(res, false); 25564 return res; 25565 } else { 25566 return createLocal(input).local(); 25567 } 25568 } 25569 25570 function getDateOffset (m) { 25571 // On Firefox.24 Date#getTimezoneOffset returns a floating point. 25572 // https://github.com/moment/moment/pull/1871 25573 return -Math.round(m._d.getTimezoneOffset() / 15) * 15; 25574 } 25575 25576 // HOOKS 25577 25578 // This function will be called whenever a moment is mutated. 25579 // It is intended to keep the offset in sync with the timezone. 25580 hooks.updateOffset = function () {}; 25581 25582 // MOMENTS 25583 25584 // keepLocalTime = true means only change the timezone, without 25585 // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]--> 25586 // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset 25587 // +0200, so we adjust the time as needed, to be valid. 25588 // 25589 // Keeping the time actually adds/subtracts (one hour) 25590 // from the actual represented time. That is why we call updateOffset 25591 // a second time. In case it wants us to change the offset again 25592 // _changeInProgress == true case, then we have to adjust, because 25593 // there is no such time in the given timezone. 25594 function getSetOffset (input, keepLocalTime, keepMinutes) { 25595 var offset = this._offset || 0, 25596 localAdjust; 25597 if (!this.isValid()) { 25598 return input != null ? this : NaN; 25599 } 25600 if (input != null) { 25601 if (typeof input === 'string') { 25602 input = offsetFromString(matchShortOffset, input); 25603 if (input === null) { 25604 return this; 25605 } 25606 } else if (Math.abs(input) < 16 && !keepMinutes) { 25607 input = input * 60; 25608 } 25609 if (!this._isUTC && keepLocalTime) { 25610 localAdjust = getDateOffset(this); 25611 } 25612 this._offset = input; 25613 this._isUTC = true; 25614 if (localAdjust != null) { 25615 this.add(localAdjust, 'm'); 25616 } 25617 if (offset !== input) { 25618 if (!keepLocalTime || this._changeInProgress) { 25619 addSubtract(this, createDuration(input - offset, 'm'), 1, false); 25620 } else if (!this._changeInProgress) { 25621 this._changeInProgress = true; 25622 hooks.updateOffset(this, true); 25623 this._changeInProgress = null; 25624 } 25625 } 25626 return this; 25627 } else { 25628 return this._isUTC ? offset : getDateOffset(this); 25629 } 25630 } 25631 25632 function getSetZone (input, keepLocalTime) { 25633 if (input != null) { 25634 if (typeof input !== 'string') { 25635 input = -input; 25636 } 25637 25638 this.utcOffset(input, keepLocalTime); 25639 25640 return this; 25641 } else { 25642 return -this.utcOffset(); 25643 } 25644 } 25645 25646 function setOffsetToUTC (keepLocalTime) { 25647 return this.utcOffset(0, keepLocalTime); 25648 } 25649 25650 function setOffsetToLocal (keepLocalTime) { 25651 if (this._isUTC) { 25652 this.utcOffset(0, keepLocalTime); 25653 this._isUTC = false; 25654 25655 if (keepLocalTime) { 25656 this.subtract(getDateOffset(this), 'm'); 25657 } 25658 } 25659 return this; 25660 } 25661 25662 function setOffsetToParsedOffset () { 25663 if (this._tzm != null) { 25664 this.utcOffset(this._tzm, false, true); 25665 } else if (typeof this._i === 'string') { 25666 var tZone = offsetFromString(matchOffset, this._i); 25667 if (tZone != null) { 25668 this.utcOffset(tZone); 25669 } 25670 else { 25671 this.utcOffset(0, true); 25672 } 25673 } 25674 return this; 25675 } 25676 25677 function hasAlignedHourOffset (input) { 25678 if (!this.isValid()) { 25679 return false; 25680 } 25681 input = input ? createLocal(input).utcOffset() : 0; 25682 25683 return (this.utcOffset() - input) % 60 === 0; 25684 } 25685 25686 function isDaylightSavingTime () { 25687 return ( 25688 this.utcOffset() > this.clone().month(0).utcOffset() || 25689 this.utcOffset() > this.clone().month(5).utcOffset() 25690 ); 25691 } 25692 25693 function isDaylightSavingTimeShifted () { 25694 if (!isUndefined(this._isDSTShifted)) { 25695 return this._isDSTShifted; 25696 } 25697 25698 var c = {}; 25699 25700 copyConfig(c, this); 25701 c = prepareConfig(c); 25702 25703 if (c._a) { 25704 var other = c._isUTC ? createUTC(c._a) : createLocal(c._a); 25705 this._isDSTShifted = this.isValid() && 25706 compareArrays(c._a, other.toArray()) > 0; 25707 } else { 25708 this._isDSTShifted = false; 25709 } 25710 25711 return this._isDSTShifted; 25712 } 25713 25714 function isLocal () { 25715 return this.isValid() ? !this._isUTC : false; 25716 } 25717 25718 function isUtcOffset () { 25719 return this.isValid() ? this._isUTC : false; 25720 } 25721 25722 function isUtc () { 25723 return this.isValid() ? this._isUTC && this._offset === 0 : false; 25724 } 25725 25726 // ASP.NET json date format regex 25727 var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/; 25728 25729 // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html 25730 // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere 25731 // and further modified to allow for strings containing both week and day 25732 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)?)?$/; 25733 25734 function createDuration (input, key) { 25735 var duration = input, 25736 // matching against regexp is expensive, do it on demand 25737 match = null, 25738 sign, 25739 ret, 25740 diffRes; 25741 25742 if (isDuration(input)) { 25743 duration = { 25744 ms : input._milliseconds, 25745 d : input._days, 25746 M : input._months 25747 }; 25748 } else if (isNumber(input)) { 25749 duration = {}; 25750 if (key) { 25751 duration[key] = input; 25752 } else { 25753 duration.milliseconds = input; 25754 } 25755 } else if (!!(match = aspNetRegex.exec(input))) { 25756 sign = (match[1] === '-') ? -1 : 1; 25757 duration = { 25758 y : 0, 25759 d : toInt(match[DATE]) * sign, 25760 h : toInt(match[HOUR]) * sign, 25761 m : toInt(match[MINUTE]) * sign, 25762 s : toInt(match[SECOND]) * sign, 25763 ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match 25764 }; 25765 } else if (!!(match = isoRegex.exec(input))) { 25766 sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1; 25767 duration = { 25768 y : parseIso(match[2], sign), 25769 M : parseIso(match[3], sign), 25770 w : parseIso(match[4], sign), 25771 d : parseIso(match[5], sign), 25772 h : parseIso(match[6], sign), 25773 m : parseIso(match[7], sign), 25774 s : parseIso(match[8], sign) 25775 }; 25776 } else if (duration == null) {// checks for null or undefined 25777 duration = {}; 25778 } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) { 25779 diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to)); 25780 25781 duration = {}; 25782 duration.ms = diffRes.milliseconds; 25783 duration.M = diffRes.months; 25784 } 25785 25786 ret = new Duration(duration); 25787 25788 if (isDuration(input) && hasOwnProp(input, '_locale')) { 25789 ret._locale = input._locale; 25790 } 25791 25792 return ret; 25793 } 25794 25795 createDuration.fn = Duration.prototype; 25796 createDuration.invalid = createInvalid$1; 25797 25798 function parseIso (inp, sign) { 25799 // We'd normally use ~~inp for this, but unfortunately it also 25800 // converts floats to ints. 25801 // inp may be undefined, so careful calling replace on it. 25802 var res = inp && parseFloat(inp.replace(',', '.')); 25803 // apply sign while we're at it 25804 return (isNaN(res) ? 0 : res) * sign; 25805 } 25806 25807 function positiveMomentsDifference(base, other) { 25808 var res = {milliseconds: 0, months: 0}; 25809 25810 res.months = other.month() - base.month() + 25811 (other.year() - base.year()) * 12; 25812 if (base.clone().add(res.months, 'M').isAfter(other)) { 25813 --res.months; 25814 } 25815 25816 res.milliseconds = +other - +(base.clone().add(res.months, 'M')); 25817 25818 return res; 25819 } 25820 25821 function momentsDifference(base, other) { 25822 var res; 25823 if (!(base.isValid() && other.isValid())) { 25824 return {milliseconds: 0, months: 0}; 25825 } 25826 25827 other = cloneWithOffset(other, base); 25828 if (base.isBefore(other)) { 25829 res = positiveMomentsDifference(base, other); 25830 } else { 25831 res = positiveMomentsDifference(other, base); 25832 res.milliseconds = -res.milliseconds; 25833 res.months = -res.months; 25834 } 25835 25836 return res; 25837 } 25838 25839 // TODO: remove 'name' arg after deprecation is removed 25840 function createAdder(direction, name) { 25841 return function (val, period) { 25842 var dur, tmp; 25843 //invert the arguments, but complain about it 25844 if (period !== null && !isNaN(+period)) { 25845 deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' + 25846 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'); 25847 tmp = val; val = period; period = tmp; 25848 } 25849 25850 val = typeof val === 'string' ? +val : val; 25851 dur = createDuration(val, period); 25852 addSubtract(this, dur, direction); 25853 return this; 25854 }; 25855 } 25856 25857 function addSubtract (mom, duration, isAdding, updateOffset) { 25858 var milliseconds = duration._milliseconds, 25859 days = absRound(duration._days), 25860 months = absRound(duration._months); 25861 25862 if (!mom.isValid()) { 25863 // No op 25864 return; 25865 } 25866 25867 updateOffset = updateOffset == null ? true : updateOffset; 25868 25869 if (months) { 25870 setMonth(mom, get(mom, 'Month') + months * isAdding); 25871 } 25872 if (days) { 25873 set$1(mom, 'Date', get(mom, 'Date') + days * isAdding); 25874 } 25875 if (milliseconds) { 25876 mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding); 25877 } 25878 if (updateOffset) { 25879 hooks.updateOffset(mom, days || months); 25880 } 25881 } 25882 25883 var add = createAdder(1, 'add'); 25884 var subtract = createAdder(-1, 'subtract'); 25885 25886 function getCalendarFormat(myMoment, now) { 25887 var diff = myMoment.diff(now, 'days', true); 25888 return diff < -6 ? 'sameElse' : 25889 diff < -1 ? 'lastWeek' : 25890 diff < 0 ? 'lastDay' : 25891 diff < 1 ? 'sameDay' : 25892 diff < 2 ? 'nextDay' : 25893 diff < 7 ? 'nextWeek' : 'sameElse'; 25894 } 25895 25896 function calendar$1 (time, formats) { 25897 // We want to compare the start of today, vs this. 25898 // Getting start-of-today depends on whether we're local/utc/offset or not. 25899 var now = time || createLocal(), 25900 sod = cloneWithOffset(now, this).startOf('day'), 25901 format = hooks.calendarFormat(this, sod) || 'sameElse'; 25902 25903 var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]); 25904 25905 return this.format(output || this.localeData().calendar(format, this, createLocal(now))); 25906 } 25907 25908 function clone () { 25909 return new Moment(this); 25910 } 25911 25912 function isAfter (input, units) { 25913 var localInput = isMoment(input) ? input : createLocal(input); 25914 if (!(this.isValid() && localInput.isValid())) { 25915 return false; 25916 } 25917 units = normalizeUnits(!isUndefined(units) ? units : 'millisecond'); 25918 if (units === 'millisecond') { 25919 return this.valueOf() > localInput.valueOf(); 25920 } else { 25921 return localInput.valueOf() < this.clone().startOf(units).valueOf(); 25922 } 25923 } 25924 25925 function isBefore (input, units) { 25926 var localInput = isMoment(input) ? input : createLocal(input); 25927 if (!(this.isValid() && localInput.isValid())) { 25928 return false; 25929 } 25930 units = normalizeUnits(!isUndefined(units) ? units : 'millisecond'); 25931 if (units === 'millisecond') { 25932 return this.valueOf() < localInput.valueOf(); 25933 } else { 25934 return this.clone().endOf(units).valueOf() < localInput.valueOf(); 25935 } 25936 } 25937 25938 function isBetween (from, to, units, inclusivity) { 25939 inclusivity = inclusivity || '()'; 25940 return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) && 25941 (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units)); 25942 } 25943 25944 function isSame (input, units) { 25945 var localInput = isMoment(input) ? input : createLocal(input), 25946 inputMs; 25947 if (!(this.isValid() && localInput.isValid())) { 25948 return false; 25949 } 25950 units = normalizeUnits(units || 'millisecond'); 25951 if (units === 'millisecond') { 25952 return this.valueOf() === localInput.valueOf(); 25953 } else { 25954 inputMs = localInput.valueOf(); 25955 return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf(); 25956 } 25957 } 25958 25959 function isSameOrAfter (input, units) { 25960 return this.isSame(input, units) || this.isAfter(input,units); 25961 } 25962 25963 function isSameOrBefore (input, units) { 25964 return this.isSame(input, units) || this.isBefore(input,units); 25965 } 25966 25967 function diff (input, units, asFloat) { 25968 var that, 25969 zoneDelta, 25970 output; 25971 25972 if (!this.isValid()) { 25973 return NaN; 25974 } 25975 25976 that = cloneWithOffset(input, this); 25977 25978 if (!that.isValid()) { 25979 return NaN; 25980 } 25981 25982 zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4; 25983 25984 units = normalizeUnits(units); 25985 25986 switch (units) { 25987 case 'year': output = monthDiff(this, that) / 12; break; 25988 case 'month': output = monthDiff(this, that); break; 25989 case 'quarter': output = monthDiff(this, that) / 3; break; 25990 case 'second': output = (this - that) / 1e3; break; // 1000 25991 case 'minute': output = (this - that) / 6e4; break; // 1000 * 60 25992 case 'hour': output = (this - that) / 36e5; break; // 1000 * 60 * 60 25993 case 'day': output = (this - that - zoneDelta) / 864e5; break; // 1000 * 60 * 60 * 24, negate dst 25994 case 'week': output = (this - that - zoneDelta) / 6048e5; break; // 1000 * 60 * 60 * 24 * 7, negate dst 25995 default: output = this - that; 25996 } 25997 25998 return asFloat ? output : absFloor(output); 25999 } 26000 26001 function monthDiff (a, b) { 26002 // difference in months 26003 var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()), 26004 // b is in (anchor - 1 month, anchor + 1 month) 26005 anchor = a.clone().add(wholeMonthDiff, 'months'), 26006 anchor2, adjust; 26007 26008 if (b - anchor < 0) { 26009 anchor2 = a.clone().add(wholeMonthDiff - 1, 'months'); 26010 // linear across the month 26011 adjust = (b - anchor) / (anchor - anchor2); 26012 } else { 26013 anchor2 = a.clone().add(wholeMonthDiff + 1, 'months'); 26014 // linear across the month 26015 adjust = (b - anchor) / (anchor2 - anchor); 26016 } 26017 26018 //check for negative zero, return zero if negative zero 26019 return -(wholeMonthDiff + adjust) || 0; 26020 } 26021 26022 hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ'; 26023 hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]'; 26024 26025 function toString () { 26026 return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'); 26027 } 26028 26029 function toISOString(keepOffset) { 26030 if (!this.isValid()) { 26031 return null; 26032 } 26033 var utc = keepOffset !== true; 26034 var m = utc ? this.clone().utc() : this; 26035 if (m.year() < 0 || m.year() > 9999) { 26036 return formatMoment(m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'); 26037 } 26038 if (isFunction(Date.prototype.toISOString)) { 26039 // native implementation is ~50x faster, use it when we can 26040 if (utc) { 26041 return this.toDate().toISOString(); 26042 } else { 26043 return new Date(this.valueOf() + this.utcOffset() * 60 * 1000).toISOString().replace('Z', formatMoment(m, 'Z')); 26044 } 26045 } 26046 return formatMoment(m, utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'); 26047 } 26048 26049 /** 26050 * Return a human readable representation of a moment that can 26051 * also be evaluated to get a new moment which is the same 26052 * 26053 * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects 26054 */ 26055 function inspect () { 26056 if (!this.isValid()) { 26057 return 'moment.invalid(/* ' + this._i + ' */)'; 26058 } 26059 var func = 'moment'; 26060 var zone = ''; 26061 if (!this.isLocal()) { 26062 func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone'; 26063 zone = 'Z'; 26064 } 26065 var prefix = '[' + func + '("]'; 26066 var year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY'; 26067 var datetime = '-MM-DD[T]HH:mm:ss.SSS'; 26068 var suffix = zone + '[")]'; 26069 26070 return this.format(prefix + year + datetime + suffix); 26071 } 26072 26073 function format (inputString) { 26074 if (!inputString) { 26075 inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat; 26076 } 26077 var output = formatMoment(this, inputString); 26078 return this.localeData().postformat(output); 26079 } 26080 26081 function from (time, withoutSuffix) { 26082 if (this.isValid() && 26083 ((isMoment(time) && time.isValid()) || 26084 createLocal(time).isValid())) { 26085 return createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix); 26086 } else { 26087 return this.localeData().invalidDate(); 26088 } 26089 } 26090 26091 function fromNow (withoutSuffix) { 26092 return this.from(createLocal(), withoutSuffix); 26093 } 26094 26095 function to (time, withoutSuffix) { 26096 if (this.isValid() && 26097 ((isMoment(time) && time.isValid()) || 26098 createLocal(time).isValid())) { 26099 return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix); 26100 } else { 26101 return this.localeData().invalidDate(); 26102 } 26103 } 26104 26105 function toNow (withoutSuffix) { 26106 return this.to(createLocal(), withoutSuffix); 26107 } 26108 26109 // If passed a locale key, it will set the locale for this 26110 // instance. Otherwise, it will return the locale configuration 26111 // variables for this instance. 26112 function locale (key) { 26113 var newLocaleData; 26114 26115 if (key === undefined) { 26116 return this._locale._abbr; 26117 } else { 26118 newLocaleData = getLocale(key); 26119 if (newLocaleData != null) { 26120 this._locale = newLocaleData; 26121 } 26122 return this; 26123 } 26124 } 26125 26126 var lang = deprecate( 26127 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', 26128 function (key) { 26129 if (key === undefined) { 26130 return this.localeData(); 26131 } else { 26132 return this.locale(key); 26133 } 26134 } 26135 ); 26136 26137 function localeData () { 26138 return this._locale; 26139 } 26140 26141 function startOf (units) { 26142 units = normalizeUnits(units); 26143 // the following switch intentionally omits break keywords 26144 // to utilize falling through the cases. 26145 switch (units) { 26146 case 'year': 26147 this.month(0); 26148 /* falls through */ 26149 case 'quarter': 26150 case 'month': 26151 this.date(1); 26152 /* falls through */ 26153 case 'week': 26154 case 'isoWeek': 26155 case 'day': 26156 case 'date': 26157 this.hours(0); 26158 /* falls through */ 26159 case 'hour': 26160 this.minutes(0); 26161 /* falls through */ 26162 case 'minute': 26163 this.seconds(0); 26164 /* falls through */ 26165 case 'second': 26166 this.milliseconds(0); 26167 } 26168 26169 // weeks are a special case 26170 if (units === 'week') { 26171 this.weekday(0); 26172 } 26173 if (units === 'isoWeek') { 26174 this.isoWeekday(1); 26175 } 26176 26177 // quarters are also special 26178 if (units === 'quarter') { 26179 this.month(Math.floor(this.month() / 3) * 3); 26180 } 26181 26182 return this; 26183 } 26184 26185 function endOf (units) { 26186 units = normalizeUnits(units); 26187 if (units === undefined || units === 'millisecond') { 26188 return this; 26189 } 26190 26191 // 'date' is an alias for 'day', so it should be considered as such. 26192 if (units === 'date') { 26193 units = 'day'; 26194 } 26195 26196 return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms'); 26197 } 26198 26199 function valueOf () { 26200 return this._d.valueOf() - ((this._offset || 0) * 60000); 26201 } 26202 26203 function unix () { 26204 return Math.floor(this.valueOf() / 1000); 26205 } 26206 26207 function toDate () { 26208 return new Date(this.valueOf()); 26209 } 26210 26211 function toArray () { 26212 var m = this; 26213 return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()]; 26214 } 26215 26216 function toObject () { 26217 var m = this; 26218 return { 26219 years: m.year(), 26220 months: m.month(), 26221 date: m.date(), 26222 hours: m.hours(), 26223 minutes: m.minutes(), 26224 seconds: m.seconds(), 26225 milliseconds: m.milliseconds() 26226 }; 26227 } 26228 26229 function toJSON () { 26230 // new Date(NaN).toJSON() === null 26231 return this.isValid() ? this.toISOString() : null; 26232 } 26233 26234 function isValid$2 () { 26235 return isValid(this); 26236 } 26237 26238 function parsingFlags () { 26239 return extend({}, getParsingFlags(this)); 26240 } 26241 26242 function invalidAt () { 26243 return getParsingFlags(this).overflow; 26244 } 26245 26246 function creationData() { 26247 return { 26248 input: this._i, 26249 format: this._f, 26250 locale: this._locale, 26251 isUTC: this._isUTC, 26252 strict: this._strict 26253 }; 26254 } 26255 26256 // FORMATTING 26257 26258 addFormatToken(0, ['gg', 2], 0, function () { 26259 return this.weekYear() % 100; 26260 }); 26261 26262 addFormatToken(0, ['GG', 2], 0, function () { 26263 return this.isoWeekYear() % 100; 26264 }); 26265 26266 function addWeekYearFormatToken (token, getter) { 26267 addFormatToken(0, [token, token.length], 0, getter); 26268 } 26269 26270 addWeekYearFormatToken('gggg', 'weekYear'); 26271 addWeekYearFormatToken('ggggg', 'weekYear'); 26272 addWeekYearFormatToken('GGGG', 'isoWeekYear'); 26273 addWeekYearFormatToken('GGGGG', 'isoWeekYear'); 26274 26275 // ALIASES 26276 26277 addUnitAlias('weekYear', 'gg'); 26278 addUnitAlias('isoWeekYear', 'GG'); 26279 26280 // PRIORITY 26281 26282 addUnitPriority('weekYear', 1); 26283 addUnitPriority('isoWeekYear', 1); 26284 26285 26286 // PARSING 26287 26288 addRegexToken('G', matchSigned); 26289 addRegexToken('g', matchSigned); 26290 addRegexToken('GG', match1to2, match2); 26291 addRegexToken('gg', match1to2, match2); 26292 addRegexToken('GGGG', match1to4, match4); 26293 addRegexToken('gggg', match1to4, match4); 26294 addRegexToken('GGGGG', match1to6, match6); 26295 addRegexToken('ggggg', match1to6, match6); 26296 26297 addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) { 26298 week[token.substr(0, 2)] = toInt(input); 26299 }); 26300 26301 addWeekParseToken(['gg', 'GG'], function (input, week, config, token) { 26302 week[token] = hooks.parseTwoDigitYear(input); 26303 }); 26304 26305 // MOMENTS 26306 26307 function getSetWeekYear (input) { 26308 return getSetWeekYearHelper.call(this, 26309 input, 26310 this.week(), 26311 this.weekday(), 26312 this.localeData()._week.dow, 26313 this.localeData()._week.doy); 26314 } 26315 26316 function getSetISOWeekYear (input) { 26317 return getSetWeekYearHelper.call(this, 26318 input, this.isoWeek(), this.isoWeekday(), 1, 4); 26319 } 26320 26321 function getISOWeeksInYear () { 26322 return weeksInYear(this.year(), 1, 4); 26323 } 26324 26325 function getWeeksInYear () { 26326 var weekInfo = this.localeData()._week; 26327 return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy); 26328 } 26329 26330 function getSetWeekYearHelper(input, week, weekday, dow, doy) { 26331 var weeksTarget; 26332 if (input == null) { 26333 return weekOfYear(this, dow, doy).year; 26334 } else { 26335 weeksTarget = weeksInYear(input, dow, doy); 26336 if (week > weeksTarget) { 26337 week = weeksTarget; 26338 } 26339 return setWeekAll.call(this, input, week, weekday, dow, doy); 26340 } 26341 } 26342 26343 function setWeekAll(weekYear, week, weekday, dow, doy) { 26344 var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy), 26345 date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear); 26346 26347 this.year(date.getUTCFullYear()); 26348 this.month(date.getUTCMonth()); 26349 this.date(date.getUTCDate()); 26350 return this; 26351 } 26352 26353 // FORMATTING 26354 26355 addFormatToken('Q', 0, 'Qo', 'quarter'); 26356 26357 // ALIASES 26358 26359 addUnitAlias('quarter', 'Q'); 26360 26361 // PRIORITY 26362 26363 addUnitPriority('quarter', 7); 26364 26365 // PARSING 26366 26367 addRegexToken('Q', match1); 26368 addParseToken('Q', function (input, array) { 26369 array[MONTH] = (toInt(input) - 1) * 3; 26370 }); 26371 26372 // MOMENTS 26373 26374 function getSetQuarter (input) { 26375 return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3); 26376 } 26377 26378 // FORMATTING 26379 26380 addFormatToken('D', ['DD', 2], 'Do', 'date'); 26381 26382 // ALIASES 26383 26384 addUnitAlias('date', 'D'); 26385 26386 // PRIORITY 26387 addUnitPriority('date', 9); 26388 26389 // PARSING 26390 26391 addRegexToken('D', match1to2); 26392 addRegexToken('DD', match1to2, match2); 26393 addRegexToken('Do', function (isStrict, locale) { 26394 // TODO: Remove "ordinalParse" fallback in next major release. 26395 return isStrict ? 26396 (locale._dayOfMonthOrdinalParse || locale._ordinalParse) : 26397 locale._dayOfMonthOrdinalParseLenient; 26398 }); 26399 26400 addParseToken(['D', 'DD'], DATE); 26401 addParseToken('Do', function (input, array) { 26402 array[DATE] = toInt(input.match(match1to2)[0]); 26403 }); 26404 26405 // MOMENTS 26406 26407 var getSetDayOfMonth = makeGetSet('Date', true); 26408 26409 // FORMATTING 26410 26411 addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear'); 26412 26413 // ALIASES 26414 26415 addUnitAlias('dayOfYear', 'DDD'); 26416 26417 // PRIORITY 26418 addUnitPriority('dayOfYear', 4); 26419 26420 // PARSING 26421 26422 addRegexToken('DDD', match1to3); 26423 addRegexToken('DDDD', match3); 26424 addParseToken(['DDD', 'DDDD'], function (input, array, config) { 26425 config._dayOfYear = toInt(input); 26426 }); 26427 26428 // HELPERS 26429 26430 // MOMENTS 26431 26432 function getSetDayOfYear (input) { 26433 var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1; 26434 return input == null ? dayOfYear : this.add((input - dayOfYear), 'd'); 26435 } 26436 26437 // FORMATTING 26438 26439 addFormatToken('m', ['mm', 2], 0, 'minute'); 26440 26441 // ALIASES 26442 26443 addUnitAlias('minute', 'm'); 26444 26445 // PRIORITY 26446 26447 addUnitPriority('minute', 14); 26448 26449 // PARSING 26450 26451 addRegexToken('m', match1to2); 26452 addRegexToken('mm', match1to2, match2); 26453 addParseToken(['m', 'mm'], MINUTE); 26454 26455 // MOMENTS 26456 26457 var getSetMinute = makeGetSet('Minutes', false); 26458 26459 // FORMATTING 26460 26461 addFormatToken('s', ['ss', 2], 0, 'second'); 26462 26463 // ALIASES 26464 26465 addUnitAlias('second', 's'); 26466 26467 // PRIORITY 26468 26469 addUnitPriority('second', 15); 26470 26471 // PARSING 26472 26473 addRegexToken('s', match1to2); 26474 addRegexToken('ss', match1to2, match2); 26475 addParseToken(['s', 'ss'], SECOND); 26476 26477 // MOMENTS 26478 26479 var getSetSecond = makeGetSet('Seconds', false); 26480 26481 // FORMATTING 26482 26483 addFormatToken('S', 0, 0, function () { 26484 return ~~(this.millisecond() / 100); 26485 }); 26486 26487 addFormatToken(0, ['SS', 2], 0, function () { 26488 return ~~(this.millisecond() / 10); 26489 }); 26490 26491 addFormatToken(0, ['SSS', 3], 0, 'millisecond'); 26492 addFormatToken(0, ['SSSS', 4], 0, function () { 26493 return this.millisecond() * 10; 26494 }); 26495 addFormatToken(0, ['SSSSS', 5], 0, function () { 26496 return this.millisecond() * 100; 26497 }); 26498 addFormatToken(0, ['SSSSSS', 6], 0, function () { 26499 return this.millisecond() * 1000; 26500 }); 26501 addFormatToken(0, ['SSSSSSS', 7], 0, function () { 26502 return this.millisecond() * 10000; 26503 }); 26504 addFormatToken(0, ['SSSSSSSS', 8], 0, function () { 26505 return this.millisecond() * 100000; 26506 }); 26507 addFormatToken(0, ['SSSSSSSSS', 9], 0, function () { 26508 return this.millisecond() * 1000000; 26509 }); 26510 26511 26512 // ALIASES 26513 26514 addUnitAlias('millisecond', 'ms'); 26515 26516 // PRIORITY 26517 26518 addUnitPriority('millisecond', 16); 26519 26520 // PARSING 26521 26522 addRegexToken('S', match1to3, match1); 26523 addRegexToken('SS', match1to3, match2); 26524 addRegexToken('SSS', match1to3, match3); 26525 26526 var token; 26527 for (token = 'SSSS'; token.length <= 9; token += 'S') { 26528 addRegexToken(token, matchUnsigned); 26529 } 26530 26531 function parseMs(input, array) { 26532 array[MILLISECOND] = toInt(('0.' + input) * 1000); 26533 } 26534 26535 for (token = 'S'; token.length <= 9; token += 'S') { 26536 addParseToken(token, parseMs); 26537 } 26538 // MOMENTS 26539 26540 var getSetMillisecond = makeGetSet('Milliseconds', false); 26541 26542 // FORMATTING 26543 26544 addFormatToken('z', 0, 0, 'zoneAbbr'); 26545 addFormatToken('zz', 0, 0, 'zoneName'); 26546 26547 // MOMENTS 26548 26549 function getZoneAbbr () { 26550 return this._isUTC ? 'UTC' : ''; 26551 } 26552 26553 function getZoneName () { 26554 return this._isUTC ? 'Coordinated Universal Time' : ''; 26555 } 26556 26557 var proto = Moment.prototype; 26558 26559 proto.add = add; 26560 proto.calendar = calendar$1; 26561 proto.clone = clone; 26562 proto.diff = diff; 26563 proto.endOf = endOf; 26564 proto.format = format; 26565 proto.from = from; 26566 proto.fromNow = fromNow; 26567 proto.to = to; 26568 proto.toNow = toNow; 26569 proto.get = stringGet; 26570 proto.invalidAt = invalidAt; 26571 proto.isAfter = isAfter; 26572 proto.isBefore = isBefore; 26573 proto.isBetween = isBetween; 26574 proto.isSame = isSame; 26575 proto.isSameOrAfter = isSameOrAfter; 26576 proto.isSameOrBefore = isSameOrBefore; 26577 proto.isValid = isValid$2; 26578 proto.lang = lang; 26579 proto.locale = locale; 26580 proto.localeData = localeData; 26581 proto.max = prototypeMax; 26582 proto.min = prototypeMin; 26583 proto.parsingFlags = parsingFlags; 26584 proto.set = stringSet; 26585 proto.startOf = startOf; 26586 proto.subtract = subtract; 26587 proto.toArray = toArray; 26588 proto.toObject = toObject; 26589 proto.toDate = toDate; 26590 proto.toISOString = toISOString; 26591 proto.inspect = inspect; 26592 proto.toJSON = toJSON; 26593 proto.toString = toString; 26594 proto.unix = unix; 26595 proto.valueOf = valueOf; 26596 proto.creationData = creationData; 26597 proto.year = getSetYear; 26598 proto.isLeapYear = getIsLeapYear; 26599 proto.weekYear = getSetWeekYear; 26600 proto.isoWeekYear = getSetISOWeekYear; 26601 proto.quarter = proto.quarters = getSetQuarter; 26602 proto.month = getSetMonth; 26603 proto.daysInMonth = getDaysInMonth; 26604 proto.week = proto.weeks = getSetWeek; 26605 proto.isoWeek = proto.isoWeeks = getSetISOWeek; 26606 proto.weeksInYear = getWeeksInYear; 26607 proto.isoWeeksInYear = getISOWeeksInYear; 26608 proto.date = getSetDayOfMonth; 26609 proto.day = proto.days = getSetDayOfWeek; 26610 proto.weekday = getSetLocaleDayOfWeek; 26611 proto.isoWeekday = getSetISODayOfWeek; 26612 proto.dayOfYear = getSetDayOfYear; 26613 proto.hour = proto.hours = getSetHour; 26614 proto.minute = proto.minutes = getSetMinute; 26615 proto.second = proto.seconds = getSetSecond; 26616 proto.millisecond = proto.milliseconds = getSetMillisecond; 26617 proto.utcOffset = getSetOffset; 26618 proto.utc = setOffsetToUTC; 26619 proto.local = setOffsetToLocal; 26620 proto.parseZone = setOffsetToParsedOffset; 26621 proto.hasAlignedHourOffset = hasAlignedHourOffset; 26622 proto.isDST = isDaylightSavingTime; 26623 proto.isLocal = isLocal; 26624 proto.isUtcOffset = isUtcOffset; 26625 proto.isUtc = isUtc; 26626 proto.isUTC = isUtc; 26627 proto.zoneAbbr = getZoneAbbr; 26628 proto.zoneName = getZoneName; 26629 proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth); 26630 proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth); 26631 proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear); 26632 proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone); 26633 proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted); 26634 26635 function createUnix (input) { 26636 return createLocal(input * 1000); 26637 } 26638 26639 function createInZone () { 26640 return createLocal.apply(null, arguments).parseZone(); 26641 } 26642 26643 function preParsePostFormat (string) { 26644 return string; 26645 } 26646 26647 var proto$1 = Locale.prototype; 26648 26649 proto$1.calendar = calendar; 26650 proto$1.longDateFormat = longDateFormat; 26651 proto$1.invalidDate = invalidDate; 26652 proto$1.ordinal = ordinal; 26653 proto$1.preparse = preParsePostFormat; 26654 proto$1.postformat = preParsePostFormat; 26655 proto$1.relativeTime = relativeTime; 26656 proto$1.pastFuture = pastFuture; 26657 proto$1.set = set; 26658 26659 proto$1.months = localeMonths; 26660 proto$1.monthsShort = localeMonthsShort; 26661 proto$1.monthsParse = localeMonthsParse; 26662 proto$1.monthsRegex = monthsRegex; 26663 proto$1.monthsShortRegex = monthsShortRegex; 26664 proto$1.week = localeWeek; 26665 proto$1.firstDayOfYear = localeFirstDayOfYear; 26666 proto$1.firstDayOfWeek = localeFirstDayOfWeek; 26667 26668 proto$1.weekdays = localeWeekdays; 26669 proto$1.weekdaysMin = localeWeekdaysMin; 26670 proto$1.weekdaysShort = localeWeekdaysShort; 26671 proto$1.weekdaysParse = localeWeekdaysParse; 26672 26673 proto$1.weekdaysRegex = weekdaysRegex; 26674 proto$1.weekdaysShortRegex = weekdaysShortRegex; 26675 proto$1.weekdaysMinRegex = weekdaysMinRegex; 26676 26677 proto$1.isPM = localeIsPM; 26678 proto$1.meridiem = localeMeridiem; 26679 26680 function get$1 (format, index, field, setter) { 26681 var locale = getLocale(); 26682 var utc = createUTC().set(setter, index); 26683 return locale[field](utc, format); 26684 } 26685 26686 function listMonthsImpl (format, index, field) { 26687 if (isNumber(format)) { 26688 index = format; 26689 format = undefined; 26690 } 26691 26692 format = format || ''; 26693 26694 if (index != null) { 26695 return get$1(format, index, field, 'month'); 26696 } 26697 26698 var i; 26699 var out = []; 26700 for (i = 0; i < 12; i++) { 26701 out[i] = get$1(format, i, field, 'month'); 26702 } 26703 return out; 26704 } 26705 26706 // () 26707 // (5) 26708 // (fmt, 5) 26709 // (fmt) 26710 // (true) 26711 // (true, 5) 26712 // (true, fmt, 5) 26713 // (true, fmt) 26714 function listWeekdaysImpl (localeSorted, format, index, field) { 26715 if (typeof localeSorted === 'boolean') { 26716 if (isNumber(format)) { 26717 index = format; 26718 format = undefined; 26719 } 26720 26721 format = format || ''; 26722 } else { 26723 format = localeSorted; 26724 index = format; 26725 localeSorted = false; 26726 26727 if (isNumber(format)) { 26728 index = format; 26729 format = undefined; 26730 } 26731 26732 format = format || ''; 26733 } 26734 26735 var locale = getLocale(), 26736 shift = localeSorted ? locale._week.dow : 0; 26737 26738 if (index != null) { 26739 return get$1(format, (index + shift) % 7, field, 'day'); 26740 } 26741 26742 var i; 26743 var out = []; 26744 for (i = 0; i < 7; i++) { 26745 out[i] = get$1(format, (i + shift) % 7, field, 'day'); 26746 } 26747 return out; 26748 } 26749 26750 function listMonths (format, index) { 26751 return listMonthsImpl(format, index, 'months'); 26752 } 26753 26754 function listMonthsShort (format, index) { 26755 return listMonthsImpl(format, index, 'monthsShort'); 26756 } 26757 26758 function listWeekdays (localeSorted, format, index) { 26759 return listWeekdaysImpl(localeSorted, format, index, 'weekdays'); 26760 } 26761 26762 function listWeekdaysShort (localeSorted, format, index) { 26763 return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort'); 26764 } 26765 26766 function listWeekdaysMin (localeSorted, format, index) { 26767 return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin'); 26768 } 26769 26770 getSetGlobalLocale('en', { 26771 dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/, 26772 ordinal : function (number) { 26773 var b = number % 10, 26774 output = (toInt(number % 100 / 10) === 1) ? 'th' : 26775 (b === 1) ? 'st' : 26776 (b === 2) ? 'nd' : 26777 (b === 3) ? 'rd' : 'th'; 26778 return number + output; 26779 } 26780 }); 26781 26782 // Side effect imports 26783 26784 hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale); 26785 hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale); 26786 26787 var mathAbs = Math.abs; 26788 26789 function abs () { 26790 var data = this._data; 26791 26792 this._milliseconds = mathAbs(this._milliseconds); 26793 this._days = mathAbs(this._days); 26794 this._months = mathAbs(this._months); 26795 26796 data.milliseconds = mathAbs(data.milliseconds); 26797 data.seconds = mathAbs(data.seconds); 26798 data.minutes = mathAbs(data.minutes); 26799 data.hours = mathAbs(data.hours); 26800 data.months = mathAbs(data.months); 26801 data.years = mathAbs(data.years); 26802 26803 return this; 26804 } 26805 26806 function addSubtract$1 (duration, input, value, direction) { 26807 var other = createDuration(input, value); 26808 26809 duration._milliseconds += direction * other._milliseconds; 26810 duration._days += direction * other._days; 26811 duration._months += direction * other._months; 26812 26813 return duration._bubble(); 26814 } 26815 26816 // supports only 2.0-style add(1, 's') or add(duration) 26817 function add$1 (input, value) { 26818 return addSubtract$1(this, input, value, 1); 26819 } 26820 26821 // supports only 2.0-style subtract(1, 's') or subtract(duration) 26822 function subtract$1 (input, value) { 26823 return addSubtract$1(this, input, value, -1); 26824 } 26825 26826 function absCeil (number) { 26827 if (number < 0) { 26828 return Math.floor(number); 26829 } else { 26830 return Math.ceil(number); 26831 } 26832 } 26833 26834 function bubble () { 26835 var milliseconds = this._milliseconds; 26836 var days = this._days; 26837 var months = this._months; 26838 var data = this._data; 26839 var seconds, minutes, hours, years, monthsFromDays; 26840 26841 // if we have a mix of positive and negative values, bubble down first 26842 // check: https://github.com/moment/moment/issues/2166 26843 if (!((milliseconds >= 0 && days >= 0 && months >= 0) || 26844 (milliseconds <= 0 && days <= 0 && months <= 0))) { 26845 milliseconds += absCeil(monthsToDays(months) + days) * 864e5; 26846 days = 0; 26847 months = 0; 26848 } 26849 26850 // The following code bubbles up values, see the tests for 26851 // examples of what that means. 26852 data.milliseconds = milliseconds % 1000; 26853 26854 seconds = absFloor(milliseconds / 1000); 26855 data.seconds = seconds % 60; 26856 26857 minutes = absFloor(seconds / 60); 26858 data.minutes = minutes % 60; 26859 26860 hours = absFloor(minutes / 60); 26861 data.hours = hours % 24; 26862 26863 days += absFloor(hours / 24); 26864 26865 // convert days to months 26866 monthsFromDays = absFloor(daysToMonths(days)); 26867 months += monthsFromDays; 26868 days -= absCeil(monthsToDays(monthsFromDays)); 26869 26870 // 12 months -> 1 year 26871 years = absFloor(months / 12); 26872 months %= 12; 26873 26874 data.days = days; 26875 data.months = months; 26876 data.years = years; 26877 26878 return this; 26879 } 26880 26881 function daysToMonths (days) { 26882 // 400 years have 146097 days (taking into account leap year rules) 26883 // 400 years have 12 months === 4800 26884 return days * 4800 / 146097; 26885 } 26886 26887 function monthsToDays (months) { 26888 // the reverse of daysToMonths 26889 return months * 146097 / 4800; 26890 } 26891 26892 function as (units) { 26893 if (!this.isValid()) { 26894 return NaN; 26895 } 26896 var days; 26897 var months; 26898 var milliseconds = this._milliseconds; 26899 26900 units = normalizeUnits(units); 26901 26902 if (units === 'month' || units === 'year') { 26903 days = this._days + milliseconds / 864e5; 26904 months = this._months + daysToMonths(days); 26905 return units === 'month' ? months : months / 12; 26906 } else { 26907 // handle milliseconds separately because of floating point math errors (issue #1867) 26908 days = this._days + Math.round(monthsToDays(this._months)); 26909 switch (units) { 26910 case 'week' : return days / 7 + milliseconds / 6048e5; 26911 case 'day' : return days + milliseconds / 864e5; 26912 case 'hour' : return days * 24 + milliseconds / 36e5; 26913 case 'minute' : return days * 1440 + milliseconds / 6e4; 26914 case 'second' : return days * 86400 + milliseconds / 1000; 26915 // Math.floor prevents floating point math errors here 26916 case 'millisecond': return Math.floor(days * 864e5) + milliseconds; 26917 default: throw new Error('Unknown unit ' + units); 26918 } 26919 } 26920 } 26921 26922 // TODO: Use this.as('ms')? 26923 function valueOf$1 () { 26924 if (!this.isValid()) { 26925 return NaN; 26926 } 26927 return ( 26928 this._milliseconds + 26929 this._days * 864e5 + 26930 (this._months % 12) * 2592e6 + 26931 toInt(this._months / 12) * 31536e6 26932 ); 26933 } 26934 26935 function makeAs (alias) { 26936 return function () { 26937 return this.as(alias); 26938 }; 26939 } 26940 26941 var asMilliseconds = makeAs('ms'); 26942 var asSeconds = makeAs('s'); 26943 var asMinutes = makeAs('m'); 26944 var asHours = makeAs('h'); 26945 var asDays = makeAs('d'); 26946 var asWeeks = makeAs('w'); 26947 var asMonths = makeAs('M'); 26948 var asYears = makeAs('y'); 26949 26950 function clone$1 () { 26951 return createDuration(this); 26952 } 26953 26954 function get$2 (units) { 26955 units = normalizeUnits(units); 26956 return this.isValid() ? this[units + 's']() : NaN; 26957 } 26958 26959 function makeGetter(name) { 26960 return function () { 26961 return this.isValid() ? this._data[name] : NaN; 26962 }; 26963 } 26964 26965 var milliseconds = makeGetter('milliseconds'); 26966 var seconds = makeGetter('seconds'); 26967 var minutes = makeGetter('minutes'); 26968 var hours = makeGetter('hours'); 26969 var days = makeGetter('days'); 26970 var months = makeGetter('months'); 26971 var years = makeGetter('years'); 26972 26973 function weeks () { 26974 return absFloor(this.days() / 7); 26975 } 26976 26977 var round = Math.round; 26978 var thresholds = { 26979 ss: 44, // a few seconds to seconds 26980 s : 45, // seconds to minute 26981 m : 45, // minutes to hour 26982 h : 22, // hours to day 26983 d : 26, // days to month 26984 M : 11 // months to year 26985 }; 26986 26987 // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize 26988 function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) { 26989 return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture); 26990 } 26991 26992 function relativeTime$1 (posNegDuration, withoutSuffix, locale) { 26993 var duration = createDuration(posNegDuration).abs(); 26994 var seconds = round(duration.as('s')); 26995 var minutes = round(duration.as('m')); 26996 var hours = round(duration.as('h')); 26997 var days = round(duration.as('d')); 26998 var months = round(duration.as('M')); 26999 var years = round(duration.as('y')); 27000 27001 var a = seconds <= thresholds.ss && ['s', seconds] || 27002 seconds < thresholds.s && ['ss', seconds] || 27003 minutes <= 1 && ['m'] || 27004 minutes < thresholds.m && ['mm', minutes] || 27005 hours <= 1 && ['h'] || 27006 hours < thresholds.h && ['hh', hours] || 27007 days <= 1 && ['d'] || 27008 days < thresholds.d && ['dd', days] || 27009 months <= 1 && ['M'] || 27010 months < thresholds.M && ['MM', months] || 27011 years <= 1 && ['y'] || ['yy', years]; 27012 27013 a[2] = withoutSuffix; 27014 a[3] = +posNegDuration > 0; 27015 a[4] = locale; 27016 return substituteTimeAgo.apply(null, a); 27017 } 27018 27019 // This function allows you to set the rounding function for relative time strings 27020 function getSetRelativeTimeRounding (roundingFunction) { 27021 if (roundingFunction === undefined) { 27022 return round; 27023 } 27024 if (typeof(roundingFunction) === 'function') { 27025 round = roundingFunction; 27026 return true; 27027 } 27028 return false; 27029 } 27030 27031 // This function allows you to set a threshold for relative time strings 27032 function getSetRelativeTimeThreshold (threshold, limit) { 27033 if (thresholds[threshold] === undefined) { 27034 return false; 27035 } 27036 if (limit === undefined) { 27037 return thresholds[threshold]; 27038 } 27039 thresholds[threshold] = limit; 27040 if (threshold === 's') { 27041 thresholds.ss = limit - 1; 27042 } 27043 return true; 27044 } 27045 27046 function humanize (withSuffix) { 27047 if (!this.isValid()) { 27048 return this.localeData().invalidDate(); 27049 } 27050 27051 var locale = this.localeData(); 27052 var output = relativeTime$1(this, !withSuffix, locale); 27053 27054 if (withSuffix) { 27055 output = locale.pastFuture(+this, output); 27056 } 27057 27058 return locale.postformat(output); 27059 } 27060 27061 var abs$1 = Math.abs; 27062 27063 function sign(x) { 27064 return ((x > 0) - (x < 0)) || +x; 27065 } 27066 27067 function toISOString$1() { 27068 // for ISO strings we do not use the normal bubbling rules: 27069 // * milliseconds bubble up until they become hours 27070 // * days do not bubble at all 27071 // * months bubble up until they become years 27072 // This is because there is no context-free conversion between hours and days 27073 // (think of clock changes) 27074 // and also not between days and months (28-31 days per month) 27075 if (!this.isValid()) { 27076 return this.localeData().invalidDate(); 27077 } 27078 27079 var seconds = abs$1(this._milliseconds) / 1000; 27080 var days = abs$1(this._days); 27081 var months = abs$1(this._months); 27082 var minutes, hours, years; 27083 27084 // 3600 seconds -> 60 minutes -> 1 hour 27085 minutes = absFloor(seconds / 60); 27086 hours = absFloor(minutes / 60); 27087 seconds %= 60; 27088 minutes %= 60; 27089 27090 // 12 months -> 1 year 27091 years = absFloor(months / 12); 27092 months %= 12; 27093 27094 27095 // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js 27096 var Y = years; 27097 var M = months; 27098 var D = days; 27099 var h = hours; 27100 var m = minutes; 27101 var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : ''; 27102 var total = this.asSeconds(); 27103 27104 if (!total) { 27105 // this is the same as C#'s (Noda) and python (isodate)... 27106 // but not other JS (goog.date) 27107 return 'P0D'; 27108 } 27109 27110 var totalSign = total < 0 ? '-' : ''; 27111 var ymSign = sign(this._months) !== sign(total) ? '-' : ''; 27112 var daysSign = sign(this._days) !== sign(total) ? '-' : ''; 27113 var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : ''; 27114 27115 return totalSign + 'P' + 27116 (Y ? ymSign + Y + 'Y' : '') + 27117 (M ? ymSign + M + 'M' : '') + 27118 (D ? daysSign + D + 'D' : '') + 27119 ((h || m || s) ? 'T' : '') + 27120 (h ? hmsSign + h + 'H' : '') + 27121 (m ? hmsSign + m + 'M' : '') + 27122 (s ? hmsSign + s + 'S' : ''); 27123 } 27124 27125 var proto$2 = Duration.prototype; 27126 27127 proto$2.isValid = isValid$1; 27128 proto$2.abs = abs; 27129 proto$2.add = add$1; 27130 proto$2.subtract = subtract$1; 27131 proto$2.as = as; 27132 proto$2.asMilliseconds = asMilliseconds; 27133 proto$2.asSeconds = asSeconds; 27134 proto$2.asMinutes = asMinutes; 27135 proto$2.asHours = asHours; 27136 proto$2.asDays = asDays; 27137 proto$2.asWeeks = asWeeks; 27138 proto$2.asMonths = asMonths; 27139 proto$2.asYears = asYears; 27140 proto$2.valueOf = valueOf$1; 27141 proto$2._bubble = bubble; 27142 proto$2.clone = clone$1; 27143 proto$2.get = get$2; 27144 proto$2.milliseconds = milliseconds; 27145 proto$2.seconds = seconds; 27146 proto$2.minutes = minutes; 27147 proto$2.hours = hours; 27148 proto$2.days = days; 27149 proto$2.weeks = weeks; 27150 proto$2.months = months; 27151 proto$2.years = years; 27152 proto$2.humanize = humanize; 27153 proto$2.toISOString = toISOString$1; 27154 proto$2.toString = toISOString$1; 27155 proto$2.toJSON = toISOString$1; 27156 proto$2.locale = locale; 27157 proto$2.localeData = localeData; 27158 27159 proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1); 27160 proto$2.lang = lang; 27161 27162 // Side effect imports 27163 27164 // FORMATTING 27165 27166 addFormatToken('X', 0, 0, 'unix'); 27167 addFormatToken('x', 0, 0, 'valueOf'); 27168 27169 // PARSING 27170 27171 addRegexToken('x', matchSigned); 27172 addRegexToken('X', matchTimestamp); 27173 addParseToken('X', function (input, array, config) { 27174 config._d = new Date(parseFloat(input, 10) * 1000); 27175 }); 27176 addParseToken('x', function (input, array, config) { 27177 config._d = new Date(toInt(input)); 27178 }); 27179 27180 // Side effect imports 27181 27182 27183 hooks.version = '2.22.2'; 27184 27185 setHookCallback(createLocal); 27186 27187 hooks.fn = proto; 27188 hooks.min = min; 27189 hooks.max = max; 27190 hooks.now = now; 27191 hooks.utc = createUTC; 27192 hooks.unix = createUnix; 27193 hooks.months = listMonths; 27194 hooks.isDate = isDate; 27195 hooks.locale = getSetGlobalLocale; 27196 hooks.invalid = createInvalid; 27197 hooks.duration = createDuration; 27198 hooks.isMoment = isMoment; 27199 hooks.weekdays = listWeekdays; 27200 hooks.parseZone = createInZone; 27201 hooks.localeData = getLocale; 27202 hooks.isDuration = isDuration; 27203 hooks.monthsShort = listMonthsShort; 27204 hooks.weekdaysMin = listWeekdaysMin; 27205 hooks.defineLocale = defineLocale; 27206 hooks.updateLocale = updateLocale; 27207 hooks.locales = listLocales; 27208 hooks.weekdaysShort = listWeekdaysShort; 27209 hooks.normalizeUnits = normalizeUnits; 27210 hooks.relativeTimeRounding = getSetRelativeTimeRounding; 27211 hooks.relativeTimeThreshold = getSetRelativeTimeThreshold; 27212 hooks.calendarFormat = getCalendarFormat; 27213 hooks.prototype = proto; 27214 27215 // currently HTML5 input type only supports 24-hour formats 27216 hooks.HTML5_FMT = { 27217 DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" /> 27218 DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" /> 27219 DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" /> 27220 DATE: 'YYYY-MM-DD', // <input type="date" /> 27221 TIME: 'HH:mm', // <input type="time" /> 27222 TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" /> 27223 TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" /> 27224 WEEK: 'YYYY-[W]WW', // <input type="week" /> 27225 MONTH: 'YYYY-MM' // <input type="month" /> 27226 }; 27227 27228 return hooks; 27229 27230}))); 27231 27232/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module))) 27233 27234/***/ }), 27235
vendor: 34,125 bytes, lines 27236-28259
27236/***/ "./node_modules/numeral/numeral.js": 27237/*!*****************************************!*\ 27238 !*** ./node_modules/numeral/numeral.js ***! 27239 \*****************************************/ 27240/*! no static exports found */ 27241/***/ (function(module, exports, __webpack_require__) { 27242 27243var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @preserve 27244 * numeral.js 27245 * version : 2.0.6 27246 * author : Adam Draper 27247 * license : MIT 27248 * http://adamwdraper.github.com/Numeral-js/ 27249 */ 27250 27251(function (global, factory) { 27252 if (true) { 27253 !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory), 27254 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? 27255 (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : 27256 __WEBPACK_AMD_DEFINE_FACTORY__), 27257 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 27258 } else {} 27259}(this, function () { 27260 /************************************ 27261 Variables 27262 ************************************/ 27263 27264 var numeral, 27265 _, 27266 VERSION = '2.0.6', 27267 formats = {}, 27268 locales = {}, 27269 defaults = { 27270 currentLocale: 'en', 27271 zeroFormat: null, 27272 nullFormat: null, 27273 defaultFormat: '0,0', 27274 scalePercentBy100: true 27275 }, 27276 options = { 27277 currentLocale: defaults.currentLocale, 27278 zeroFormat: defaults.zeroFormat, 27279 nullFormat: defaults.nullFormat, 27280 defaultFormat: defaults.defaultFormat, 27281 scalePercentBy100: defaults.scalePercentBy100 27282 }; 27283 27284 27285 /************************************ 27286 Constructors 27287 ************************************/ 27288 27289 // Numeral prototype object 27290 function Numeral(input, number) { 27291 this._input = input; 27292 27293 this._value = number; 27294 } 27295 27296 numeral = function(input) { 27297 var value, 27298 kind, 27299 unformatFunction, 27300 regexp; 27301 27302 if (numeral.isNumeral(input)) { 27303 value = input.value(); 27304 } else if (input === 0 || typeof input === 'undefined') { 27305 value = 0; 27306 } else if (input === null || _.isNaN(input)) { 27307 value = null; 27308 } else if (typeof input === 'string') { 27309 if (options.zeroFormat && input === options.zeroFormat) { 27310 value = 0; 27311 } else if (options.nullFormat && input === options.nullFormat || !input.replace(/[^0-9]+/g, '').length) { 27312 value = null; 27313 } else { 27314 for (kind in formats) { 27315 regexp = typeof formats[kind].regexps.unformat === 'function' ? formats[kind].regexps.unformat() : formats[kind].regexps.unformat; 27316 27317 if (regexp && input.match(regexp)) { 27318 unformatFunction = formats[kind].unformat; 27319 27320 break; 27321 } 27322 } 27323 27324 unformatFunction = unformatFunction || numeral._.stringToNumber; 27325 27326 value = unformatFunction(input); 27327 } 27328 } else { 27329 value = Number(input)|| null; 27330 } 27331 27332 return new Numeral(input, value); 27333 }; 27334 27335 // version number 27336 numeral.version = VERSION; 27337 27338 // compare numeral object 27339 numeral.isNumeral = function(obj) { 27340 return obj instanceof Numeral; 27341 }; 27342 27343 // helper functions 27344 numeral._ = _ = { 27345 // formats numbers separators, decimals places, signs, abbreviations 27346 numberToFormat: function(value, format, roundingFunction) { 27347 var locale = locales[numeral.options.currentLocale], 27348 negP = false, 27349 optDec = false, 27350 leadingCount = 0, 27351 abbr = '', 27352 trillion = 1000000000000, 27353 billion = 1000000000, 27354 million = 1000000, 27355 thousand = 1000, 27356 decimal = '', 27357 neg = false, 27358 abbrForce, // force abbreviation 27359 abs, 27360 min, 27361 max, 27362 power, 27363 int, 27364 precision, 27365 signed, 27366 thousands, 27367 output; 27368 27369 // make sure we never format a null value 27370 value = value || 0; 27371 27372 abs = Math.abs(value); 27373 27374 // see if we should use parentheses for negative number or if we should prefix with a sign 27375 // if both are present we default to parentheses 27376 if (numeral._.includes(format, '(')) { 27377 negP = true; 27378 format = format.replace(/[\(|\)]/g, ''); 27379 } else if (numeral._.includes(format, '+') || numeral._.includes(format, '-')) { 27380 signed = numeral._.includes(format, '+') ? format.indexOf('+') : value < 0 ? format.indexOf('-') : -1; 27381 format = format.replace(/[\+|\-]/g, ''); 27382 } 27383 27384 // see if abbreviation is wanted 27385 if (numeral._.includes(format, 'a')) { 27386 abbrForce = format.match(/a(k|m|b|t)?/); 27387 27388 abbrForce = abbrForce ? abbrForce[1] : false; 27389 27390 // check for space before abbreviation 27391 if (numeral._.includes(format, ' a')) { 27392 abbr = ' '; 27393 } 27394 27395 format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); 27396 27397 if (abs >= trillion && !abbrForce || abbrForce === 't') { 27398 // trillion 27399 abbr += locale.abbreviations.trillion; 27400 value = value / trillion; 27401 } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { 27402 // billion 27403 abbr += locale.abbreviations.billion; 27404 value = value / billion; 27405 } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { 27406 // million 27407 abbr += locale.abbreviations.million; 27408 value = value / million; 27409 } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { 27410 // thousand 27411 abbr += locale.abbreviations.thousand; 27412 value = value / thousand; 27413 } 27414 } 27415 27416 // check for optional decimals 27417 if (numeral._.includes(format, '[.]')) { 27418 optDec = true; 27419 format = format.replace('[.]', '.'); 27420 } 27421 27422 // break number and format 27423 int = value.toString().split('.')[0]; 27424 precision = format.split('.')[1]; 27425 thousands = format.indexOf(','); 27426 leadingCount = (format.split('.')[0].split(',')[0].match(/0/g) || []).length; 27427 27428 if (precision) { 27429 if (numeral._.includes(precision, '[')) { 27430 precision = precision.replace(']', ''); 27431 precision = precision.split('['); 27432 decimal = numeral._.toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); 27433 } else { 27434 decimal = numeral._.toFixed(value, precision.length, roundingFunction); 27435 } 27436 27437 int = decimal.split('.')[0]; 27438 27439 if (numeral._.includes(decimal, '.')) { 27440 decimal = locale.delimiters.decimal + decimal.split('.')[1]; 27441 } else { 27442 decimal = ''; 27443 } 27444 27445 if (optDec && Number(decimal.slice(1)) === 0) { 27446 decimal = ''; 27447 } 27448 } else { 27449 int = numeral._.toFixed(value, 0, roundingFunction); 27450 } 27451 27452 // check abbreviation again after rounding 27453 if (abbr && !abbrForce && Number(int) >= 1000 && abbr !== locale.abbreviations.trillion) { 27454 int = String(Number(int) / 1000); 27455 27456 switch (abbr) { 27457 case locale.abbreviations.thousand: 27458 abbr = locale.abbreviations.million; 27459 break; 27460 case locale.abbreviations.million: 27461 abbr = locale.abbreviations.billion; 27462 break; 27463 case locale.abbreviations.billion: 27464 abbr = locale.abbreviations.trillion; 27465 break; 27466 } 27467 } 27468 27469 27470 // format number 27471 if (numeral._.includes(int, '-')) { 27472 int = int.slice(1); 27473 neg = true; 27474 } 27475 27476 if (int.length < leadingCount) { 27477 for (var i = leadingCount - int.length; i > 0; i--) { 27478 int = '0' + int; 27479 } 27480 } 27481 27482 if (thousands > -1) { 27483 int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locale.delimiters.thousands); 27484 } 27485 27486 if (format.indexOf('.') === 0) { 27487 int = ''; 27488 } 27489 27490 output = int + decimal + (abbr ? abbr : ''); 27491 27492 if (negP) { 27493 output = (negP && neg ? '(' : '') + output + (negP && neg ? ')' : ''); 27494 } else { 27495 if (signed >= 0) { 27496 output = signed === 0 ? (neg ? '-' : '+') + output : output + (neg ? '-' : '+'); 27497 } else if (neg) { 27498 output = '-' + output; 27499 } 27500 } 27501 27502 return output; 27503 }, 27504 // unformats numbers separators, decimals places, signs, abbreviations 27505 stringToNumber: function(string) { 27506 var locale = locales[options.currentLocale], 27507 stringOriginal = string, 27508 abbreviations = { 27509 thousand: 3, 27510 million: 6, 27511 billion: 9, 27512 trillion: 12 27513 }, 27514 abbreviation, 27515 value, 27516 i, 27517 regexp; 27518 27519 if (options.zeroFormat && string === options.zeroFormat) { 27520 value = 0; 27521 } else if (options.nullFormat && string === options.nullFormat || !string.replace(/[^0-9]+/g, '').length) { 27522 value = null; 27523 } else { 27524 value = 1; 27525 27526 if (locale.delimiters.decimal !== '.') { 27527 string = string.replace(/\./g, '').replace(locale.delimiters.decimal, '.'); 27528 } 27529 27530 for (abbreviation in abbreviations) { 27531 regexp = new RegExp('[^a-zA-Z]' + locale.abbreviations[abbreviation] + '(?:\\)|(\\' + locale.currency.symbol + ')?(?:\\))?)?$'); 27532 27533 if (stringOriginal.match(regexp)) { 27534 value *= Math.pow(10, abbreviations[abbreviation]); 27535 break; 27536 } 27537 } 27538 27539 // check for negative number 27540 value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; 27541 27542 // remove non numbers 27543 string = string.replace(/[^0-9\.]+/g, ''); 27544 27545 value *= Number(string); 27546 } 27547 27548 return value; 27549 }, 27550 isNaN: function(value) { 27551 return typeof value === 'number' && isNaN(value); 27552 }, 27553 includes: function(string, search) { 27554 return string.indexOf(search) !== -1; 27555 }, 27556 insert: function(string, subString, start) { 27557 return string.slice(0, start) + subString + string.slice(start); 27558 }, 27559 reduce: function(array, callback /*, initialValue*/) { 27560 if (this === null) { 27561 throw new TypeError('Array.prototype.reduce called on null or undefined'); 27562 } 27563 27564 if (typeof callback !== 'function') { 27565 throw new TypeError(callback + ' is not a function'); 27566 } 27567 27568 var t = Object(array), 27569 len = t.length >>> 0, 27570 k = 0, 27571 value; 27572 27573 if (arguments.length === 3) { 27574 value = arguments[2]; 27575 } else { 27576 while (k < len && !(k in t)) { 27577 k++; 27578 } 27579 27580 if (k >= len) { 27581 throw new TypeError('Reduce of empty array with no initial value'); 27582 } 27583 27584 value = t[k++]; 27585 } 27586 for (; k < len; k++) { 27587 if (k in t) { 27588 value = callback(value, t[k], k, t); 27589 } 27590 } 27591 return value; 27592 }, 27593 /** 27594 * Computes the multiplier necessary to make x >= 1, 27595 * effectively eliminating miscalculations caused by 27596 * finite precision. 27597 */ 27598 multiplier: function (x) { 27599 var parts = x.toString().split('.'); 27600 27601 return parts.length < 2 ? 1 : Math.pow(10, parts[1].length); 27602 }, 27603 /** 27604 * Given a variable number of arguments, returns the maximum 27605 * multiplier that must be used to normalize an operation involving 27606 * all of them. 27607 */ 27608 correctionFactor: function () { 27609 var args = Array.prototype.slice.call(arguments); 27610 27611 return args.reduce(function(accum, next) { 27612 var mn = _.multiplier(next); 27613 return accum > mn ? accum : mn; 27614 }, 1); 27615 }, 27616 /** 27617 * Implementation of toFixed() that treats floats more like decimals 27618 * 27619 * Fixes binary rounding issues (eg. (0.615).toFixed(2) === '0.61') that present 27620 * problems for accounting- and finance-related software. 27621 */ 27622 toFixed: function(value, maxDecimals, roundingFunction, optionals) { 27623 var splitValue = value.toString().split('.'), 27624 minDecimals = maxDecimals - (optionals || 0), 27625 boundedPrecision, 27626 optionalsRegExp, 27627 power, 27628 output; 27629 27630 // Use the smallest precision value possible to avoid errors from floating point representation 27631 if (splitValue.length === 2) { 27632 boundedPrecision = Math.min(Math.max(splitValue[1].length, minDecimals), maxDecimals); 27633 } else { 27634 boundedPrecision = minDecimals; 27635 } 27636 27637 power = Math.pow(10, boundedPrecision); 27638 27639 // Multiply up by precision, round accurately, then divide and use native toFixed(): 27640 output = (roundingFunction(value + 'e+' + boundedPrecision) / power).toFixed(boundedPrecision); 27641 27642 if (optionals > maxDecimals - boundedPrecision) { 27643 optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); 27644 output = output.replace(optionalsRegExp, ''); 27645 } 27646 27647 return output; 27648 } 27649 }; 27650 27651 // avaliable options 27652 numeral.options = options; 27653 27654 // avaliable formats 27655 numeral.formats = formats; 27656 27657 // avaliable formats 27658 numeral.locales = locales; 27659 27660 // This function sets the current locale. If 27661 // no arguments are passed in, it will simply return the current global 27662 // locale key. 27663 numeral.locale = function(key) { 27664 if (key) { 27665 options.currentLocale = key.toLowerCase(); 27666 } 27667 27668 return options.currentLocale; 27669 }; 27670 27671 // This function provides access to the loaded locale data. If 27672 // no arguments are passed in, it will simply return the current 27673 // global locale object. 27674 numeral.localeData = function(key) { 27675 if (!key) { 27676 return locales[options.currentLocale]; 27677 } 27678 27679 key = key.toLowerCase(); 27680 27681 if (!locales[key]) { 27682 throw new Error('Unknown locale : ' + key); 27683 } 27684 27685 return locales[key]; 27686 }; 27687 27688 numeral.reset = function() { 27689 for (var property in defaults) { 27690 options[property] = defaults[property]; 27691 } 27692 }; 27693 27694 numeral.zeroFormat = function(format) { 27695 options.zeroFormat = typeof(format) === 'string' ? format : null; 27696 }; 27697 27698 numeral.nullFormat = function (format) { 27699 options.nullFormat = typeof(format) === 'string' ? format : null; 27700 }; 27701 27702 numeral.defaultFormat = function(format) { 27703 options.defaultFormat = typeof(format) === 'string' ? format : '0.0'; 27704 }; 27705 27706 numeral.register = function(type, name, format) { 27707 name = name.toLowerCase(); 27708 27709 if (this[type + 's'][name]) { 27710 throw new TypeError(name + ' ' + type + ' already registered.'); 27711 } 27712 27713 this[type + 's'][name] = format; 27714 27715 return format; 27716 }; 27717 27718 27719 numeral.validate = function(val, culture) { 27720 var _decimalSep, 27721 _thousandSep, 27722 _currSymbol, 27723 _valArray, 27724 _abbrObj, 27725 _thousandRegEx, 27726 localeData, 27727 temp; 27728 27729 //coerce val to string 27730 if (typeof val !== 'string') { 27731 val += ''; 27732 27733 if (console.warn) { 27734 console.warn('Numeral.js: Value is not string. It has been co-erced to: ', val); 27735 } 27736 } 27737 27738 //trim whitespaces from either sides 27739 val = val.trim(); 27740 27741 //if val is just digits return true 27742 if (!!val.match(/^\d+$/)) { 27743 return true; 27744 } 27745 27746 //if val is empty return false 27747 if (val === '') { 27748 return false; 27749 } 27750 27751 //get the decimal and thousands separator from numeral.localeData 27752 try { 27753 //check if the culture is understood by numeral. if not, default it to current locale 27754 localeData = numeral.localeData(culture); 27755 } catch (e) { 27756 localeData = numeral.localeData(numeral.locale()); 27757 } 27758 27759 //setup the delimiters and currency symbol based on culture/locale 27760 _currSymbol = localeData.currency.symbol; 27761 _abbrObj = localeData.abbreviations; 27762 _decimalSep = localeData.delimiters.decimal; 27763 if (localeData.delimiters.thousands === '.') { 27764 _thousandSep = '\\.'; 27765 } else { 27766 _thousandSep = localeData.delimiters.thousands; 27767 } 27768 27769 // validating currency symbol 27770 temp = val.match(/^[^\d]+/); 27771 if (temp !== null) { 27772 val = val.substr(1); 27773 if (temp[0] !== _currSymbol) { 27774 return false; 27775 } 27776 } 27777 27778 //validating abbreviation symbol 27779 temp = val.match(/[^\d]+$/); 27780 if (temp !== null) { 27781 val = val.slice(0, -1); 27782 if (temp[0] !== _abbrObj.thousand && temp[0] !== _abbrObj.million && temp[0] !== _abbrObj.billion && temp[0] !== _abbrObj.trillion) { 27783 return false; 27784 } 27785 } 27786 27787 _thousandRegEx = new RegExp(_thousandSep + '{2}'); 27788 27789 if (!val.match(/[^\d.,]/g)) { 27790 _valArray = val.split(_decimalSep); 27791 if (_valArray.length > 2) { 27792 return false; 27793 } else { 27794 if (_valArray.length < 2) { 27795 return ( !! _valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx)); 27796 } else { 27797 if (_valArray[0].length === 1) { 27798 return ( !! _valArray[0].match(/^\d+$/) && !_valArray[0].match(_thousandRegEx) && !! _valArray[1].match(/^\d+$/)); 27799 } else { 27800 return ( !! _valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx) && !! _valArray[1].match(/^\d+$/)); 27801 } 27802 } 27803 } 27804 } 27805 27806 return false; 27807 }; 27808 27809 27810 /************************************ 27811 Numeral Prototype 27812 ************************************/ 27813 27814 numeral.fn = Numeral.prototype = { 27815 clone: function() { 27816 return numeral(this); 27817 }, 27818 format: function(inputString, roundingFunction) { 27819 var value = this._value, 27820 format = inputString || options.defaultFormat, 27821 kind, 27822 output, 27823 formatFunction; 27824 27825 // make sure we have a roundingFunction 27826 roundingFunction = roundingFunction || Math.round; 27827 27828 // format based on value 27829 if (value === 0 && options.zeroFormat !== null) { 27830 output = options.zeroFormat; 27831 } else if (value === null && options.nullFormat !== null) { 27832 output = options.nullFormat; 27833 } else { 27834 for (kind in formats) { 27835 if (format.match(formats[kind].regexps.format)) { 27836 formatFunction = formats[kind].format; 27837 27838 break; 27839 } 27840 } 27841 27842 formatFunction = formatFunction || numeral._.numberToFormat; 27843 27844 output = formatFunction(value, format, roundingFunction); 27845 } 27846 27847 return output; 27848 }, 27849 value: function() { 27850 return this._value; 27851 }, 27852 input: function() { 27853 return this._input; 27854 }, 27855 set: function(value) { 27856 this._value = Number(value); 27857 27858 return this; 27859 }, 27860 add: function(value) { 27861 var corrFactor = _.correctionFactor.call(null, this._value, value); 27862 27863 function cback(accum, curr, currI, O) { 27864 return accum + Math.round(corrFactor * curr); 27865 } 27866 27867 this._value = _.reduce([this._value, value], cback, 0) / corrFactor; 27868 27869 return this; 27870 }, 27871 subtract: function(value) { 27872 var corrFactor = _.correctionFactor.call(null, this._value, value); 27873 27874 function cback(accum, curr, currI, O) { 27875 return accum - Math.round(corrFactor * curr); 27876 } 27877 27878 this._value = _.reduce([value], cback, Math.round(this._value * corrFactor)) / corrFactor; 27879 27880 return this; 27881 }, 27882 multiply: function(value) { 27883 function cback(accum, curr, currI, O) { 27884 var corrFactor = _.correctionFactor(accum, curr); 27885 return Math.round(accum * corrFactor) * Math.round(curr * corrFactor) / Math.round(corrFactor * corrFactor); 27886 } 27887 27888 this._value = _.reduce([this._value, value], cback, 1); 27889 27890 return this; 27891 }, 27892 divide: function(value) { 27893 function cback(accum, curr, currI, O) { 27894 var corrFactor = _.correctionFactor(accum, curr); 27895 return Math.round(accum * corrFactor) / Math.round(curr * corrFactor); 27896 } 27897 27898 this._value = _.reduce([this._value, value], cback); 27899 27900 return this; 27901 }, 27902 difference: function(value) { 27903 return Math.abs(numeral(this._value).subtract(value).value()); 27904 } 27905 }; 27906 27907 /************************************ 27908 Default Locale && Format 27909 ************************************/ 27910 27911 numeral.register('locale', 'en', { 27912 delimiters: { 27913 thousands: ',', 27914 decimal: '.' 27915 }, 27916 abbreviations: { 27917 thousand: 'k', 27918 million: 'm', 27919 billion: 'b', 27920 trillion: 't' 27921 }, 27922 ordinal: function(number) { 27923 var b = number % 10; 27924 return (~~(number % 100 / 10) === 1) ? 'th' : 27925 (b === 1) ? 'st' : 27926 (b === 2) ? 'nd' : 27927 (b === 3) ? 'rd' : 'th'; 27928 }, 27929 currency: { 27930 symbol: '$' 27931 } 27932 }); 27933 27934 27935 27936(function() { 27937 numeral.register('format', 'bps', { 27938 regexps: { 27939 format: /(BPS)/, 27940 unformat: /(BPS)/ 27941 }, 27942 format: function(value, format, roundingFunction) { 27943 var space = numeral._.includes(format, ' BPS') ? ' ' : '', 27944 output; 27945 27946 value = value * 10000; 27947 27948 // check for space before BPS 27949 format = format.replace(/\s?BPS/, ''); 27950 27951 output = numeral._.numberToFormat(value, format, roundingFunction); 27952 27953 if (numeral._.includes(output, ')')) { 27954 output = output.split(''); 27955 27956 output.splice(-1, 0, space + 'BPS'); 27957 27958 output = output.join(''); 27959 } else { 27960 output = output + space + 'BPS'; 27961 } 27962 27963 return output; 27964 }, 27965 unformat: function(string) { 27966 return +(numeral._.stringToNumber(string) * 0.0001).toFixed(15); 27967 } 27968 }); 27969})(); 27970 27971 27972(function() { 27973 var decimal = { 27974 base: 1000, 27975 suffixes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] 27976 }, 27977 binary = { 27978 base: 1024, 27979 suffixes: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] 27980 }; 27981 27982 var allSuffixes = decimal.suffixes.concat(binary.suffixes.filter(function (item) { 27983 return decimal.suffixes.indexOf(item) < 0; 27984 })); 27985 var unformatRegex = allSuffixes.join('|'); 27986 // Allow support for BPS (http://www.investopedia.com/terms/b/basispoint.asp) 27987 unformatRegex = '(' + unformatRegex.replace('B', 'B(?!PS)') + ')'; 27988 27989 numeral.register('format', 'bytes', { 27990 regexps: { 27991 format: /([0\s]i?b)/, 27992 unformat: new RegExp(unformatRegex) 27993 }, 27994 format: function(value, format, roundingFunction) { 27995 var output, 27996 bytes = numeral._.includes(format, 'ib') ? binary : decimal, 27997 suffix = numeral._.includes(format, ' b') || numeral._.includes(format, ' ib') ? ' ' : '', 27998 power, 27999 min, 28000 max; 28001 28002 // check for space before 28003 format = format.replace(/\s?i?b/, ''); 28004 28005 for (power = 0; power <= bytes.suffixes.length; power++) { 28006 min = Math.pow(bytes.base, power); 28007 max = Math.pow(bytes.base, power + 1); 28008 28009 if (value === null || value === 0 || value >= min && value < max) { 28010 suffix += bytes.suffixes[power]; 28011 28012 if (min > 0) { 28013 value = value / min; 28014 } 28015 28016 break; 28017 } 28018 } 28019 28020 output = numeral._.numberToFormat(value, format, roundingFunction); 28021 28022 return output + suffix; 28023 }, 28024 unformat: function(string) { 28025 var value = numeral._.stringToNumber(string), 28026 power, 28027 bytesMultiplier; 28028 28029 if (value) { 28030 for (power = decimal.suffixes.length - 1; power >= 0; power--) { 28031 if (numeral._.includes(string, decimal.suffixes[power])) { 28032 bytesMultiplier = Math.pow(decimal.base, power); 28033 28034 break; 28035 } 28036 28037 if (numeral._.includes(string, binary.suffixes[power])) { 28038 bytesMultiplier = Math.pow(binary.base, power); 28039 28040 break; 28041 } 28042 } 28043 28044 value *= (bytesMultiplier || 1); 28045 } 28046 28047 return value; 28048 } 28049 }); 28050})(); 28051 28052 28053(function() { 28054 numeral.register('format', 'currency', { 28055 regexps: { 28056 format: /(\$)/ 28057 }, 28058 format: function(value, format, roundingFunction) { 28059 var locale = numeral.locales[numeral.options.currentLocale], 28060 symbols = { 28061 before: format.match(/^([\+|\-|\(|\s|\$]*)/)[0], 28062 after: format.match(/([\+|\-|\)|\s|\$]*)$/)[0] 28063 }, 28064 output, 28065 symbol, 28066 i; 28067 28068 // strip format of spaces and $ 28069 format = format.replace(/\s?\$\s?/, ''); 28070 28071 // format the number 28072 output = numeral._.numberToFormat(value, format, roundingFunction); 28073 28074 // update the before and after based on value 28075 if (value >= 0) { 28076 symbols.before = symbols.before.replace(/[\-\(]/, ''); 28077 symbols.after = symbols.after.replace(/[\-\)]/, ''); 28078 } else if (value < 0 && (!numeral._.includes(symbols.before, '-') && !numeral._.includes(symbols.before, '('))) { 28079 symbols.before = '-' + symbols.before; 28080 } 28081 28082 // loop through each before symbol 28083 for (i = 0; i < symbols.before.length; i++) { 28084 symbol = symbols.before[i]; 28085 28086 switch (symbol) { 28087 case '$': 28088 output = numeral._.insert(output, locale.currency.symbol, i); 28089 break; 28090 case ' ': 28091 output = numeral._.insert(output, ' ', i + locale.currency.symbol.length - 1); 28092 break; 28093 } 28094 } 28095 28096 // loop through each after symbol 28097 for (i = symbols.after.length - 1; i >= 0; i--) { 28098 symbol = symbols.after[i]; 28099 28100 switch (symbol) { 28101 case '$': 28102 output = i === symbols.after.length - 1 ? output + locale.currency.symbol : numeral._.insert(output, locale.currency.symbol, -(symbols.after.length - (1 + i))); 28103 break; 28104 case ' ': 28105 output = i === symbols.after.length - 1 ? output + ' ' : numeral._.insert(output, ' ', -(symbols.after.length - (1 + i) + locale.currency.symbol.length - 1)); 28106 break; 28107 } 28108 } 28109 28110 28111 return output; 28112 } 28113 }); 28114})(); 28115 28116 28117(function() { 28118 numeral.register('format', 'exponential', { 28119 regexps: { 28120 format: /(e\+|e-)/, 28121 unformat: /(e\+|e-)/ 28122 }, 28123 format: function(value, format, roundingFunction) { 28124 var output, 28125 exponential = typeof value === 'number' && !numeral._.isNaN(value) ? value.toExponential() : '0e+0', 28126 parts = exponential.split('e'); 28127 28128 format = format.replace(/e[\+|\-]{1}0/, ''); 28129 28130 output = numeral._.numberToFormat(Number(parts[0]), format, roundingFunction); 28131 28132 return output + 'e' + parts[1]; 28133 }, 28134 unformat: function(string) { 28135 var parts = numeral._.includes(string, 'e+') ? string.split('e+') : string.split('e-'), 28136 value = Number(parts[0]), 28137 power = Number(parts[1]); 28138 28139 power = numeral._.includes(string, 'e-') ? power *= -1 : power; 28140 28141 function cback(accum, curr, currI, O) { 28142 var corrFactor = numeral._.correctionFactor(accum, curr), 28143 num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); 28144 return num; 28145 } 28146 28147 return numeral._.reduce([value, Math.pow(10, power)], cback, 1); 28148 } 28149 }); 28150})(); 28151 28152 28153(function() { 28154 numeral.register('format', 'ordinal', { 28155 regexps: { 28156 format: /(o)/ 28157 }, 28158 format: function(value, format, roundingFunction) { 28159 var locale = numeral.locales[numeral.options.currentLocale], 28160 output, 28161 ordinal = numeral._.includes(format, ' o') ? ' ' : ''; 28162 28163 // check for space before 28164 format = format.replace(/\s?o/, ''); 28165 28166 ordinal += locale.ordinal(value); 28167 28168 output = numeral._.numberToFormat(value, format, roundingFunction); 28169 28170 return output + ordinal; 28171 } 28172 }); 28173})(); 28174 28175 28176(function() { 28177 numeral.register('format', 'percentage', { 28178 regexps: { 28179 format: /(%)/, 28180 unformat: /(%)/ 28181 }, 28182 format: function(value, format, roundingFunction) { 28183 var space = numeral._.includes(format, ' %') ? ' ' : '', 28184 output; 28185 28186 if (numeral.options.scalePercentBy100) { 28187 value = value * 100; 28188 } 28189 28190 // check for space before % 28191 format = format.replace(/\s?\%/, ''); 28192 28193 output = numeral._.numberToFormat(value, format, roundingFunction); 28194 28195 if (numeral._.includes(output, ')')) { 28196 output = output.split(''); 28197 28198 output.splice(-1, 0, space + '%'); 28199 28200 output = output.join(''); 28201 } else { 28202 output = output + space + '%'; 28203 } 28204 28205 return output; 28206 }, 28207 unformat: function(string) { 28208 var number = numeral._.stringToNumber(string); 28209 if (numeral.options.scalePercentBy100) { 28210 return number * 0.01; 28211 } 28212 return number; 28213 } 28214 }); 28215})(); 28216 28217 28218(function() { 28219 numeral.register('format', 'time', { 28220 regexps: { 28221 format: /(:)/, 28222 unformat: /(:)/ 28223 }, 28224 format: function(value, format, roundingFunction) { 28225 var hours = Math.floor(value / 60 / 60), 28226 minutes = Math.floor((value - (hours * 60 * 60)) / 60), 28227 seconds = Math.round(value - (hours * 60 * 60) - (minutes * 60)); 28228 28229 return hours + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds); 28230 }, 28231 unformat: function(string) { 28232 var timeArray = string.split(':'), 28233 seconds = 0; 28234 28235 // turn hours and minutes into seconds and add them all up 28236 if (timeArray.length === 3) { 28237 // hours 28238 seconds = seconds + (Number(timeArray[0]) * 60 * 60); 28239 // minutes 28240 seconds = seconds + (Number(timeArray[1]) * 60); 28241 // seconds 28242 seconds = seconds + Number(timeArray[2]); 28243 } else if (timeArray.length === 2) { 28244 // minutes 28245 seconds = seconds + (Number(timeArray[0]) * 60); 28246 // seconds 28247 seconds = seconds + Number(timeArray[1]); 28248 } 28249 return Number(seconds); 28250 } 28251 }); 28252})(); 28253 28254return numeral; 28255})); 28256 28257 28258/***/ }), 28259
vendor: 2,409 bytes, lines 28260-28361
28260/***/ "./node_modules/object-assign/index.js": 28261/*!*********************************************!*\ 28262 !*** ./node_modules/object-assign/index.js ***! 28263 \*********************************************/ 28264/*! no static exports found */ 28265/***/ (function(module, exports, __webpack_require__) { 28266 28267"use strict"; 28268/* 28269object-assign 28270(c) Sindre Sorhus 28271@license MIT 28272*/ 28273 28274 28275/* eslint-disable no-unused-vars */ 28276var getOwnPropertySymbols = Object.getOwnPropertySymbols; 28277var hasOwnProperty = Object.prototype.hasOwnProperty; 28278var propIsEnumerable = Object.prototype.propertyIsEnumerable; 28279 28280function toObject(val) { 28281 if (val === null || val === undefined) { 28282 throw new TypeError('Object.assign cannot be called with null or undefined'); 28283 } 28284 28285 return Object(val); 28286} 28287 28288function shouldUseNative() { 28289 try { 28290 if (!Object.assign) { 28291 return false; 28292 } 28293 28294 // Detect buggy property enumeration order in older V8 versions. 28295 28296 // https://bugs.chromium.org/p/v8/issues/detail?id=4118 28297 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers 28298 test1[5] = 'de'; 28299 if (Object.getOwnPropertyNames(test1)[0] === '5') { 28300 return false; 28301 } 28302 28303 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 28304 var test2 = {}; 28305 for (var i = 0; i < 10; i++) { 28306 test2['_' + String.fromCharCode(i)] = i; 28307 } 28308 var order2 = Object.getOwnPropertyNames(test2).map(function (n) { 28309 return test2[n]; 28310 }); 28311 if (order2.join('') !== '0123456789') { 28312 return false; 28313 } 28314 28315 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 28316 var test3 = {}; 28317 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { 28318 test3[letter] = letter; 28319 }); 28320 if (Object.keys(Object.assign({}, test3)).join('') !== 28321 'abcdefghijklmnopqrst') { 28322 return false; 28323 } 28324 28325 return true; 28326 } catch (err) { 28327 // We don't expect any of the above to throw, but better to be safe. 28328 return false; 28329 } 28330} 28331 28332module.exports = shouldUseNative() ? Object.assign : function (target, source) { 28333 var from; 28334 var to = toObject(target); 28335 var symbols; 28336 28337 for (var s = 1; s < arguments.length; s++) { 28338 from = Object(arguments[s]); 28339 28340 for (var key in from) { 28341 if (hasOwnProperty.call(from, key)) { 28342 to[key] = from[key]; 28343 } 28344 } 28345 28346 if (getOwnPropertySymbols) { 28347 symbols = getOwnPropertySymbols(from); 28348 for (var i = 0; i < symbols.length; i++) { 28349 if (propIsEnumerable.call(from, symbols[i])) { 28350 to[symbols[i]] = from[symbols[i]]; 28351 } 28352 } 28353 } 28354 } 28355 28356 return to; 28357}; 28358 28359 28360/***/ }), 28361
vendor: 5,681 bytes, lines 28362-28556
28362/***/ "./node_modules/process/browser.js": 28363/*!*****************************************!*\ 28364 !*** ./node_modules/process/browser.js ***! 28365 \*****************************************/ 28366/*! no static exports found */ 28367/***/ (function(module, exports) { 28368 28369// shim for using process in browser 28370var process = module.exports = {}; 28371 28372// cached from whatever global is present so that test runners that stub it 28373// don't break things. But we need to wrap it in a try catch in case it is 28374// wrapped in strict mode code which doesn't define any globals. It's inside a 28375// function because try/catches deoptimize in certain engines. 28376 28377var cachedSetTimeout; 28378var cachedClearTimeout; 28379 28380function defaultSetTimout() { 28381 throw new Error('setTimeout has not been defined'); 28382} 28383function defaultClearTimeout () { 28384 throw new Error('clearTimeout has not been defined'); 28385} 28386(function () { 28387 try { 28388 if (typeof setTimeout === 'function') { 28389 cachedSetTimeout = setTimeout; 28390 } else { 28391 cachedSetTimeout = defaultSetTimout; 28392 } 28393 } catch (e) { 28394 cachedSetTimeout = defaultSetTimout; 28395 } 28396 try { 28397 if (typeof clearTimeout === 'function') { 28398 cachedClearTimeout = clearTimeout; 28399 } else { 28400 cachedClearTimeout = defaultClearTimeout; 28401 } 28402 } catch (e) { 28403 cachedClearTimeout = defaultClearTimeout; 28404 } 28405} ()) 28406function runTimeout(fun) { 28407 if (cachedSetTimeout === setTimeout) { 28408 //normal enviroments in sane situations 28409 return setTimeout(fun, 0); 28410 } 28411 // if setTimeout wasn't available but was latter defined 28412 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { 28413 cachedSetTimeout = setTimeout; 28414 return setTimeout(fun, 0); 28415 } 28416 try { 28417 // when when somebody has screwed with setTimeout but no I.E. maddness 28418 return cachedSetTimeout(fun, 0); 28419 } catch(e){ 28420 try { 28421 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 28422 return cachedSetTimeout.call(null, fun, 0); 28423 } catch(e){ 28424 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error 28425 return cachedSetTimeout.call(this, fun, 0); 28426 } 28427 } 28428 28429 28430} 28431function runClearTimeout(marker) { 28432 if (cachedClearTimeout === clearTimeout) { 28433 //normal enviroments in sane situations 28434 return clearTimeout(marker); 28435 } 28436 // if clearTimeout wasn't available but was latter defined 28437 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { 28438 cachedClearTimeout = clearTimeout; 28439 return clearTimeout(marker); 28440 } 28441 try { 28442 // when when somebody has screwed with setTimeout but no I.E. maddness 28443 return cachedClearTimeout(marker); 28444 } catch (e){ 28445 try { 28446 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 28447 return cachedClearTimeout.call(null, marker); 28448 } catch (e){ 28449 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. 28450 // Some versions of I.E. have different rules for clearTimeout vs setTimeout 28451 return cachedClearTimeout.call(this, marker); 28452 } 28453 } 28454 28455 28456 28457} 28458var queue = []; 28459var draining = false; 28460var currentQueue; 28461var queueIndex = -1; 28462 28463function cleanUpNextTick() { 28464 if (!draining || !currentQueue) { 28465 return; 28466 } 28467 draining = false; 28468 if (currentQueue.length) { 28469 queue = currentQueue.concat(queue); 28470 } else { 28471 queueIndex = -1; 28472 } 28473 if (queue.length) { 28474 drainQueue(); 28475 } 28476} 28477 28478function drainQueue() { 28479 if (draining) { 28480 return; 28481 } 28482 var timeout = runTimeout(cleanUpNextTick); 28483 draining = true; 28484 28485 var len = queue.length; 28486 while(len) { 28487 currentQueue = queue; 28488 queue = []; 28489 while (++queueIndex < len) { 28490 if (currentQueue) { 28491 currentQueue[queueIndex].run(); 28492 } 28493 } 28494 queueIndex = -1; 28495 len = queue.length; 28496 } 28497 currentQueue = null; 28498 draining = false; 28499 runClearTimeout(timeout); 28500} 28501 28502process.nextTick = function (fun) { 28503 var args = new Array(arguments.length - 1); 28504 if (arguments.length > 1) { 28505 for (var i = 1; i < arguments.length; i++) { 28506 args[i - 1] = arguments[i]; 28507 } 28508 } 28509 queue.push(new Item(fun, args)); 28510 if (queue.length === 1 && !draining) { 28511 runTimeout(drainQueue); 28512 } 28513}; 28514 28515// v8 likes predictible objects 28516function Item(fun, array) { 28517 this.fun = fun; 28518 this.array = array; 28519} 28520Item.prototype.run = function () { 28521 this.fun.apply(null, this.array); 28522}; 28523process.title = 'browser'; 28524process.browser = true; 28525process.env = {}; 28526process.argv = []; 28527process.version = ''; // empty string to avoid regexp issues 28528process.versions = {}; 28529 28530function noop() {} 28531 28532process.on = noop; 28533process.addListener = noop; 28534process.once = noop; 28535process.off = noop; 28536process.removeListener = noop; 28537process.removeAllListeners = noop; 28538process.emit = noop; 28539process.prependListener = noop; 28540process.prependOnceListener = noop; 28541 28542process.listeners = function (name) { return [] } 28543 28544process.binding = function (name) { 28545 throw new Error('process.binding is not supported'); 28546}; 28547 28548process.cwd = function () { return '/' }; 28549process.chdir = function (dir) { 28550 throw new Error('process.chdir is not supported'); 28551}; 28552process.umask = function() { return 0; }; 28553 28554 28555/***/ }), 28556
vendor: 3,866 bytes, lines 28557-28659
28557/***/ "./node_modules/prop-types/checkPropTypes.js": 28558/*!***************************************************!*\ 28559 !*** ./node_modules/prop-types/checkPropTypes.js ***! 28560 \***************************************************/ 28561/*! no static exports found */ 28562/***/ (function(module, exports, __webpack_require__) { 28563 28564"use strict"; 28565/** 28566 * Copyright (c) 2013-present, Facebook, Inc. 28567 * 28568 * This source code is licensed under the MIT license found in the 28569 * LICENSE file in the root directory of this source tree. 28570 */ 28571 28572 28573 28574var printWarning = function() {}; 28575 28576if (true) { 28577 var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "./node_modules/prop-types/lib/ReactPropTypesSecret.js"); 28578 var loggedTypeFailures = {}; 28579 28580 printWarning = function(text) { 28581 var message = 'Warning: ' + text; 28582 if (typeof console !== 'undefined') { 28583 console.error(message); 28584 } 28585 try { 28586 // --- Welcome to debugging React --- 28587 // This error was thrown as a convenience so that you can use this stack 28588 // to find the callsite that caused this warning to fire. 28589 throw new Error(message); 28590 } catch (x) {} 28591 }; 28592} 28593 28594/** 28595 * Assert that the values match with the type specs. 28596 * Error messages are memorized and will only be shown once. 28597 * 28598 * @param {object} typeSpecs Map of name to a ReactPropType 28599 * @param {object} values Runtime values that need to be type-checked 28600 * @param {string} location e.g. "prop", "context", "child context" 28601 * @param {string} componentName Name of the component for error messages. 28602 * @param {?Function} getStack Returns the component stack. 28603 * @private 28604 */ 28605function checkPropTypes(typeSpecs, values, location, componentName, getStack) { 28606 if (true) { 28607 for (var typeSpecName in typeSpecs) { 28608 if (typeSpecs.hasOwnProperty(typeSpecName)) { 28609 var error; 28610 // Prop type validation may throw. In case they do, we don't want to 28611 // fail the render phase where it didn't fail before. So we log it. 28612 // After these have been cleaned up, we'll let them throw. 28613 try { 28614 // This is intentionally an invariant that gets caught. It's the same 28615 // behavior as without this statement except with a better message. 28616 if (typeof typeSpecs[typeSpecName] !== 'function') { 28617 var err = Error( 28618 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 28619 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' 28620 ); 28621 err.name = 'Invariant Violation'; 28622 throw err; 28623 } 28624 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); 28625 } catch (ex) { 28626 error = ex; 28627 } 28628 if (error && !(error instanceof Error)) { 28629 printWarning( 28630 (componentName || 'React class') + ': type specification of ' + 28631 location + ' `' + typeSpecName + '` is invalid; the type checker ' + 28632 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + 28633 'You may have forgotten to pass an argument to the type checker ' + 28634 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 28635 'shape all require an argument).' 28636 ) 28637 28638 } 28639 if (error instanceof Error && !(error.message in loggedTypeFailures)) { 28640 // Only monitor this failure once because there tends to be a lot of the 28641 // same error. 28642 loggedTypeFailures[error.message] = true; 28643 28644 var stack = getStack ? getStack() : ''; 28645 28646 printWarning( 28647 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') 28648 ); 28649 } 28650 } 28651 } 28652 } 28653} 28654 28655module.exports = checkPropTypes; 28656 28657 28658/***/ }), 28659
vendor: 20,635 bytes, lines 28660-29226
28660/***/ "./node_modules/prop-types/factoryWithTypeCheckers.js": 28661/*!************************************************************!*\ 28662 !*** ./node_modules/prop-types/factoryWithTypeCheckers.js ***! 28663 \************************************************************/ 28664/*! no static exports found */ 28665/***/ (function(module, exports, __webpack_require__) { 28666 28667"use strict"; 28668/** 28669 * Copyright (c) 2013-present, Facebook, Inc. 28670 * 28671 * This source code is licensed under the MIT license found in the 28672 * LICENSE file in the root directory of this source tree. 28673 */ 28674 28675 28676 28677var assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js"); 28678 28679var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "./node_modules/prop-types/lib/ReactPropTypesSecret.js"); 28680var checkPropTypes = __webpack_require__(/*! ./checkPropTypes */ "./node_modules/prop-types/checkPropTypes.js"); 28681 28682var printWarning = function() {}; 28683 28684if (true) { 28685 printWarning = function(text) { 28686 var message = 'Warning: ' + text; 28687 if (typeof console !== 'undefined') { 28688 console.error(message); 28689 } 28690 try { 28691 // --- Welcome to debugging React --- 28692 // This error was thrown as a convenience so that you can use this stack 28693 // to find the callsite that caused this warning to fire. 28694 throw new Error(message); 28695 } catch (x) {} 28696 }; 28697} 28698 28699function emptyFunctionThatReturnsNull() { 28700 return null; 28701} 28702 28703module.exports = function(isValidElement, throwOnDirectAccess) { 28704 /* global Symbol */ 28705 var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 28706 var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. 28707 28708 /** 28709 * Returns the iterator method function contained on the iterable object. 28710 * 28711 * Be sure to invoke the function with the iterable as context: 28712 * 28713 * var iteratorFn = getIteratorFn(myIterable); 28714 * if (iteratorFn) { 28715 * var iterator = iteratorFn.call(myIterable); 28716 * ... 28717 * } 28718 * 28719 * @param {?object} maybeIterable 28720 * @return {?function} 28721 */ 28722 function getIteratorFn(maybeIterable) { 28723 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); 28724 if (typeof iteratorFn === 'function') { 28725 return iteratorFn; 28726 } 28727 } 28728 28729 /** 28730 * Collection of methods that allow declaration and validation of props that are 28731 * supplied to React components. Example usage: 28732 * 28733 * var Props = require('ReactPropTypes'); 28734 * var MyArticle = React.createClass({ 28735 * propTypes: { 28736 * // An optional string prop named "description". 28737 * description: Props.string, 28738 * 28739 * // A required enum prop named "category". 28740 * category: Props.oneOf(['News','Photos']).isRequired, 28741 * 28742 * // A prop named "dialog" that requires an instance of Dialog. 28743 * dialog: Props.instanceOf(Dialog).isRequired 28744 * }, 28745 * render: function() { ... } 28746 * }); 28747 * 28748 * A more formal specification of how these methods are used: 28749 * 28750 * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) 28751 * decl := ReactPropTypes.{type}(.isRequired)? 28752 * 28753 * Each and every declaration produces a function with the same signature. This 28754 * allows the creation of custom validation functions. For example: 28755 * 28756 * var MyLink = React.createClass({ 28757 * propTypes: { 28758 * // An optional string or URI prop named "href". 28759 * href: function(props, propName, componentName) { 28760 * var propValue = props[propName]; 28761 * if (propValue != null && typeof propValue !== 'string' && 28762 * !(propValue instanceof URI)) { 28763 * return new Error( 28764 * 'Expected a string or an URI for ' + propName + ' in ' + 28765 * componentName 28766 * ); 28767 * } 28768 * } 28769 * }, 28770 * render: function() {...} 28771 * }); 28772 * 28773 * @internal 28774 */ 28775 28776 var ANONYMOUS = '<<anonymous>>'; 28777 28778 // Important! 28779 // Keep this list in sync with production version in `./factoryWithThrowingShims.js`. 28780 var ReactPropTypes = { 28781 array: createPrimitiveTypeChecker('array'), 28782 bool: createPrimitiveTypeChecker('boolean'), 28783 func: createPrimitiveTypeChecker('function'), 28784 number: createPrimitiveTypeChecker('number'), 28785 object: createPrimitiveTypeChecker('object'), 28786 string: createPrimitiveTypeChecker('string'), 28787 symbol: createPrimitiveTypeChecker('symbol'), 28788 28789 any: createAnyTypeChecker(), 28790 arrayOf: createArrayOfTypeChecker, 28791 element: createElementTypeChecker(), 28792 instanceOf: createInstanceTypeChecker, 28793 node: createNodeChecker(), 28794 objectOf: createObjectOfTypeChecker, 28795 oneOf: createEnumTypeChecker, 28796 oneOfType: createUnionTypeChecker, 28797 shape: createShapeTypeChecker, 28798 exact: createStrictShapeTypeChecker, 28799 }; 28800 28801 /** 28802 * inlined Object.is polyfill to avoid requiring consumers ship their own 28803 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is 28804 */ 28805 /*eslint-disable no-self-compare*/ 28806 function is(x, y) { 28807 // SameValue algorithm 28808 if (x === y) { 28809 // Steps 1-5, 7-10 28810 // Steps 6.b-6.e: +0 != -0 28811 return x !== 0 || 1 / x === 1 / y; 28812 } else { 28813 // Step 6.a: NaN == NaN 28814 return x !== x && y !== y; 28815 } 28816 } 28817 /*eslint-enable no-self-compare*/ 28818 28819 /** 28820 * We use an Error-like object for backward compatibility as people may call 28821 * PropTypes directly and inspect their output. However, we don't use real 28822 * Errors anymore. We don't inspect their stack anyway, and creating them 28823 * is prohibitively expensive if they are created too often, such as what 28824 * happens in oneOfType() for any type before the one that matched. 28825 */ 28826 function PropTypeError(message) { 28827 this.message = message; 28828 this.stack = ''; 28829 } 28830 // Make `instanceof Error` still work for returned errors. 28831 PropTypeError.prototype = Error.prototype; 28832 28833 function createChainableTypeChecker(validate) { 28834 if (true) { 28835 var manualPropTypeCallCache = {}; 28836 var manualPropTypeWarningCount = 0; 28837 } 28838 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { 28839 componentName = componentName || ANONYMOUS; 28840 propFullName = propFullName || propName; 28841 28842 if (secret !== ReactPropTypesSecret) { 28843 if (throwOnDirectAccess) { 28844 // New behavior only for users of `prop-types` package 28845 var err = new Error( 28846 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 28847 'Use `PropTypes.checkPropTypes()` to call them. ' + 28848 'Read more at http://fb.me/use-check-prop-types' 28849 ); 28850 err.name = 'Invariant Violation'; 28851 throw err; 28852 } else if ( true && typeof console !== 'undefined') { 28853 // Old behavior for people using React.PropTypes 28854 var cacheKey = componentName + ':' + propName; 28855 if ( 28856 !manualPropTypeCallCache[cacheKey] && 28857 // Avoid spamming the console because they are often not actionable except for lib authors 28858 manualPropTypeWarningCount < 3 28859 ) { 28860 printWarning( 28861 'You are manually calling a React.PropTypes validation ' + 28862 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + 28863 'and will throw in the standalone `prop-types` package. ' + 28864 'You may be seeing this warning due to a third-party PropTypes ' + 28865 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.' 28866 ); 28867 manualPropTypeCallCache[cacheKey] = true; 28868 manualPropTypeWarningCount++; 28869 } 28870 } 28871 } 28872 if (props[propName] == null) { 28873 if (isRequired) { 28874 if (props[propName] === null) { 28875 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); 28876 } 28877 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); 28878 } 28879 return null; 28880 } else { 28881 return validate(props, propName, componentName, location, propFullName); 28882 } 28883 } 28884 28885 var chainedCheckType = checkType.bind(null, false); 28886 chainedCheckType.isRequired = checkType.bind(null, true); 28887 28888 return chainedCheckType; 28889 } 28890 28891 function createPrimitiveTypeChecker(expectedType) { 28892 function validate(props, propName, componentName, location, propFullName, secret) { 28893 var propValue = props[propName]; 28894 var propType = getPropType(propValue); 28895 if (propType !== expectedType) { 28896 // `propValue` being instance of, say, date/regexp, pass the 'object' 28897 // check, but we can offer a more precise error message here rather than 28898 // 'of type `object`'. 28899 var preciseType = getPreciseType(propValue); 28900 28901 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); 28902 } 28903 return null; 28904 } 28905 return createChainableTypeChecker(validate); 28906 } 28907 28908 function createAnyTypeChecker() { 28909 return createChainableTypeChecker(emptyFunctionThatReturnsNull); 28910 } 28911 28912 function createArrayOfTypeChecker(typeChecker) { 28913 function validate(props, propName, componentName, location, propFullName) { 28914 if (typeof typeChecker !== 'function') { 28915 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); 28916 } 28917 var propValue = props[propName]; 28918 if (!Array.isArray(propValue)) { 28919 var propType = getPropType(propValue); 28920 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); 28921 } 28922 for (var i = 0; i < propValue.length; i++) { 28923 var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); 28924 if (error instanceof Error) { 28925 return error; 28926 } 28927 } 28928 return null; 28929 } 28930 return createChainableTypeChecker(validate); 28931 } 28932 28933 function createElementTypeChecker() { 28934 function validate(props, propName, componentName, location, propFullName) { 28935 var propValue = props[propName]; 28936 if (!isValidElement(propValue)) { 28937 var propType = getPropType(propValue); 28938 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); 28939 } 28940 return null; 28941 } 28942 return createChainableTypeChecker(validate); 28943 } 28944 28945 function createInstanceTypeChecker(expectedClass) { 28946 function validate(props, propName, componentName, location, propFullName) { 28947 if (!(props[propName] instanceof expectedClass)) { 28948 var expectedClassName = expectedClass.name || ANONYMOUS; 28949 var actualClassName = getClassName(props[propName]); 28950 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); 28951 } 28952 return null; 28953 } 28954 return createChainableTypeChecker(validate); 28955 } 28956 28957 function createEnumTypeChecker(expectedValues) { 28958 if (!Array.isArray(expectedValues)) { 28959 true ? printWarning('Invalid argument supplied to oneOf, expected an instance of array.') : undefined; 28960 return emptyFunctionThatReturnsNull; 28961 } 28962 28963 function validate(props, propName, componentName, location, propFullName) { 28964 var propValue = props[propName]; 28965 for (var i = 0; i < expectedValues.length; i++) { 28966 if (is(propValue, expectedValues[i])) { 28967 return null; 28968 } 28969 } 28970 28971 var valuesString = JSON.stringify(expectedValues); 28972 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); 28973 } 28974 return createChainableTypeChecker(validate); 28975 } 28976 28977 function createObjectOfTypeChecker(typeChecker) { 28978 function validate(props, propName, componentName, location, propFullName) { 28979 if (typeof typeChecker !== 'function') { 28980 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); 28981 } 28982 var propValue = props[propName]; 28983 var propType = getPropType(propValue); 28984 if (propType !== 'object') { 28985 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); 28986 } 28987 for (var key in propValue) { 28988 if (propValue.hasOwnProperty(key)) { 28989 var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); 28990 if (error instanceof Error) { 28991 return error; 28992 } 28993 } 28994 } 28995 return null; 28996 } 28997 return createChainableTypeChecker(validate); 28998 } 28999 29000 function createUnionTypeChecker(arrayOfTypeCheckers) { 29001 if (!Array.isArray(arrayOfTypeCheckers)) { 29002 true ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : undefined; 29003 return emptyFunctionThatReturnsNull; 29004 } 29005 29006 for (var i = 0; i < arrayOfTypeCheckers.length; i++) { 29007 var checker = arrayOfTypeCheckers[i]; 29008 if (typeof checker !== 'function') { 29009 printWarning( 29010 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + 29011 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.' 29012 ); 29013 return emptyFunctionThatReturnsNull; 29014 } 29015 } 29016 29017 function validate(props, propName, componentName, location, propFullName) { 29018 for (var i = 0; i < arrayOfTypeCheckers.length; i++) { 29019 var checker = arrayOfTypeCheckers[i]; 29020 if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) { 29021 return null; 29022 } 29023 } 29024 29025 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); 29026 } 29027 return createChainableTypeChecker(validate); 29028 } 29029 29030 function createNodeChecker() { 29031 function validate(props, propName, componentName, location, propFullName) { 29032 if (!isNode(props[propName])) { 29033 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); 29034 } 29035 return null; 29036 } 29037 return createChainableTypeChecker(validate); 29038 } 29039 29040 function createShapeTypeChecker(shapeTypes) { 29041 function validate(props, propName, componentName, location, propFullName) { 29042 var propValue = props[propName]; 29043 var propType = getPropType(propValue); 29044 if (propType !== 'object') { 29045 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); 29046 } 29047 for (var key in shapeTypes) { 29048 var checker = shapeTypes[key]; 29049 if (!checker) { 29050 continue; 29051 } 29052 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); 29053 if (error) { 29054 return error; 29055 } 29056 } 29057 return null; 29058 } 29059 return createChainableTypeChecker(validate); 29060 } 29061 29062 function createStrictShapeTypeChecker(shapeTypes) { 29063 function validate(props, propName, componentName, location, propFullName) { 29064 var propValue = props[propName]; 29065 var propType = getPropType(propValue); 29066 if (propType !== 'object') { 29067 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); 29068 } 29069 // We need to check all keys in case some are required but missing from 29070 // props. 29071 var allKeys = assign({}, props[propName], shapeTypes); 29072 for (var key in allKeys) { 29073 var checker = shapeTypes[key]; 29074 if (!checker) { 29075 return new PropTypeError( 29076 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + 29077 '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + 29078 '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') 29079 ); 29080 } 29081 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); 29082 if (error) { 29083 return error; 29084 } 29085 } 29086 return null; 29087 } 29088 29089 return createChainableTypeChecker(validate); 29090 } 29091 29092 function isNode(propValue) { 29093 switch (typeof propValue) { 29094 case 'number': 29095 case 'string': 29096 case 'undefined': 29097 return true; 29098 case 'boolean': 29099 return !propValue; 29100 case 'object': 29101 if (Array.isArray(propValue)) { 29102 return propValue.every(isNode); 29103 } 29104 if (propValue === null || isValidElement(propValue)) { 29105 return true; 29106 } 29107 29108 var iteratorFn = getIteratorFn(propValue); 29109 if (iteratorFn) { 29110 var iterator = iteratorFn.call(propValue); 29111 var step; 29112 if (iteratorFn !== propValue.entries) { 29113 while (!(step = iterator.next()).done) { 29114 if (!isNode(step.value)) { 29115 return false; 29116 } 29117 } 29118 } else { 29119 // Iterator will provide entry [k,v] tuples rather than values. 29120 while (!(step = iterator.next()).done) { 29121 var entry = step.value; 29122 if (entry) { 29123 if (!isNode(entry[1])) { 29124 return false; 29125 } 29126 } 29127 } 29128 } 29129 } else { 29130 return false; 29131 } 29132 29133 return true; 29134 default: 29135 return false; 29136 } 29137 } 29138 29139 function isSymbol(propType, propValue) { 29140 // Native Symbol. 29141 if (propType === 'symbol') { 29142 return true; 29143 } 29144 29145 // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' 29146 if (propValue['@@toStringTag'] === 'Symbol') { 29147 return true; 29148 } 29149 29150 // Fallback for non-spec compliant Symbols which are polyfilled. 29151 if (typeof Symbol === 'function' && propValue instanceof Symbol) { 29152 return true; 29153 } 29154 29155 return false; 29156 } 29157 29158 // Equivalent of `typeof` but with special handling for array and regexp. 29159 function getPropType(propValue) { 29160 var propType = typeof propValue; 29161 if (Array.isArray(propValue)) { 29162 return 'array'; 29163 } 29164 if (propValue instanceof RegExp) { 29165 // Old webkits (at least until Android 4.0) return 'function' rather than 29166 // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ 29167 // passes PropTypes.object. 29168 return 'object'; 29169 } 29170 if (isSymbol(propType, propValue)) { 29171 return 'symbol'; 29172 } 29173 return propType; 29174 } 29175 29176 // This handles more types than `getPropType`. Only used for error messages. 29177 // See `createPrimitiveTypeChecker`. 29178 function getPreciseType(propValue) { 29179 if (typeof propValue === 'undefined' || propValue === null) { 29180 return '' + propValue; 29181 } 29182 var propType = getPropType(propValue); 29183 if (propType === 'object') { 29184 if (propValue instanceof Date) { 29185 return 'date'; 29186 } else if (propValue instanceof RegExp) { 29187 return 'regexp'; 29188 } 29189 } 29190 return propType; 29191 } 29192 29193 // Returns a string that is postfixed to a warning about an invalid type. 29194 // For example, "undefined" or "of type array" 29195 function getPostfixForTypeWarning(value) { 29196 var type = getPreciseType(value); 29197 switch (type) { 29198 case 'array': 29199 case 'object': 29200 return 'an ' + type; 29201 case 'boolean': 29202 case 'date': 29203 case 'regexp': 29204 return 'a ' + type; 29205 default: 29206 return type; 29207 } 29208 } 29209 29210 // Returns class name of the object, if any. 29211 function getClassName(propValue) { 29212 if (!propValue.constructor || !propValue.constructor.name) { 29213 return ANONYMOUS; 29214 } 29215 return propValue.constructor.name; 29216 } 29217 29218 ReactPropTypes.checkPropTypes = checkPropTypes; 29219 ReactPropTypes.PropTypes = ReactPropTypes; 29220 29221 return ReactPropTypes; 29222}; 29223 29224 29225/***/ }), 29226
vendor: 1,102 bytes, lines 29227-29261
29227/***/ "./node_modules/prop-types/index.js": 29228/*!******************************************!*\ 29229 !*** ./node_modules/prop-types/index.js ***! 29230 \******************************************/ 29231/*! no static exports found */ 29232/***/ (function(module, exports, __webpack_require__) { 29233 29234/** 29235 * Copyright (c) 2013-present, Facebook, Inc. 29236 * 29237 * This source code is licensed under the MIT license found in the 29238 * LICENSE file in the root directory of this source tree. 29239 */ 29240 29241if (true) { 29242 var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && 29243 Symbol.for && 29244 Symbol.for('react.element')) || 29245 0xeac7; 29246 29247 var isValidElement = function(object) { 29248 return typeof object === 'object' && 29249 object !== null && 29250 object.$$typeof === REACT_ELEMENT_TYPE; 29251 }; 29252 29253 // By explicitly using `prop-types` you are opting into new development behavior. 29254 // http://fb.me/prop-types-in-prod 29255 var throwOnDirectAccess = true; 29256 module.exports = __webpack_require__(/*! ./factoryWithTypeCheckers */ "./node_modules/prop-types/factoryWithTypeCheckers.js")(isValidElement, throwOnDirectAccess); 29257} else {} 29258 29259 29260/***/ }), 29261
vendor: 679 bytes, lines 29262-29285
29262/***/ "./node_modules/prop-types/lib/ReactPropTypesSecret.js": 29263/*!*************************************************************!*\ 29264 !*** ./node_modules/prop-types/lib/ReactPropTypesSecret.js ***! 29265 \*************************************************************/ 29266/*! no static exports found */ 29267/***/ (function(module, exports, __webpack_require__) { 29268 29269"use strict"; 29270/** 29271 * Copyright (c) 2013-present, Facebook, Inc. 29272 * 29273 * This source code is licensed under the MIT license found in the 29274 * LICENSE file in the root directory of this source tree. 29275 */ 29276 29277 29278 29279var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; 29280 29281module.exports = ReactPropTypesSecret; 29282 29283 29284/***/ }), 29285
vendor: 626,622 bytes, lines 29286-46727
29286/***/ "./node_modules/react-dom/cjs/react-dom.development.js": 29287/*!*************************************************************!*\ 29288 !*** ./node_modules/react-dom/cjs/react-dom.development.js ***! 29289 \*************************************************************/ 29290/*! no static exports found */ 29291/***/ (function(module, exports, __webpack_require__) { 29292 29293"use strict"; 29294/** @license React v16.4.1 29295 * react-dom.development.js 29296 * 29297 * Copyright (c) 2013-present, Facebook, Inc. 29298 * 29299 * This source code is licensed under the MIT license found in the 29300 * LICENSE file in the root directory of this source tree. 29301 */ 29302 29303 29304 29305 29306 29307if (true) { 29308 (function() { 29309'use strict'; 29310 29311var invariant = __webpack_require__(/*! fbjs/lib/invariant */ "./node_modules/fbjs/lib/invariant.js"); 29312var React = __webpack_require__(/*! react */ "./node_modules/react/index.js"); 29313var warning = __webpack_require__(/*! fbjs/lib/warning */ "./node_modules/fbjs/lib/warning.js"); 29314var ExecutionEnvironment = __webpack_require__(/*! fbjs/lib/ExecutionEnvironment */ "./node_modules/fbjs/lib/ExecutionEnvironment.js"); 29315var _assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js"); 29316var emptyFunction = __webpack_require__(/*! fbjs/lib/emptyFunction */ "./node_modules/fbjs/lib/emptyFunction.js"); 29317var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "./node_modules/prop-types/checkPropTypes.js"); 29318var getActiveElement = __webpack_require__(/*! fbjs/lib/getActiveElement */ "./node_modules/fbjs/lib/getActiveElement.js"); 29319var shallowEqual = __webpack_require__(/*! fbjs/lib/shallowEqual */ "./node_modules/fbjs/lib/shallowEqual.js"); 29320var containsNode = __webpack_require__(/*! fbjs/lib/containsNode */ "./node_modules/fbjs/lib/containsNode.js"); 29321var emptyObject = __webpack_require__(/*! fbjs/lib/emptyObject */ "./node_modules/fbjs/lib/emptyObject.js"); 29322var hyphenateStyleName = __webpack_require__(/*! fbjs/lib/hyphenateStyleName */ "./node_modules/fbjs/lib/hyphenateStyleName.js"); 29323var camelizeStyleName = __webpack_require__(/*! fbjs/lib/camelizeStyleName */ "./node_modules/fbjs/lib/camelizeStyleName.js"); 29324 29325// Relying on the `invariant()` implementation lets us 29326// have preserve the format and params in the www builds. 29327 29328!React ? invariant(false, 'ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM.') : void 0; 29329 29330var invokeGuardedCallback = function (name, func, context, a, b, c, d, e, f) { 29331 this._hasCaughtError = false; 29332 this._caughtError = null; 29333 var funcArgs = Array.prototype.slice.call(arguments, 3); 29334 try { 29335 func.apply(context, funcArgs); 29336 } catch (error) { 29337 this._caughtError = error; 29338 this._hasCaughtError = true; 29339 } 29340}; 29341 29342{ 29343 // In DEV mode, we swap out invokeGuardedCallback for a special version 29344 // that plays more nicely with the browser's DevTools. The idea is to preserve 29345 // "Pause on exceptions" behavior. Because React wraps all user-provided 29346 // functions in invokeGuardedCallback, and the production version of 29347 // invokeGuardedCallback uses a try-catch, all user exceptions are treated 29348 // like caught exceptions, and the DevTools won't pause unless the developer 29349 // takes the extra step of enabling pause on caught exceptions. This is 29350 // untintuitive, though, because even though React has caught the error, from 29351 // the developer's perspective, the error is uncaught. 29352 // 29353 // To preserve the expected "Pause on exceptions" behavior, we don't use a 29354 // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake 29355 // DOM node, and call the user-provided callback from inside an event handler 29356 // for that fake event. If the callback throws, the error is "captured" using 29357 // a global event handler. But because the error happens in a different 29358 // event loop context, it does not interrupt the normal program flow. 29359 // Effectively, this gives us try-catch behavior without actually using 29360 // try-catch. Neat! 29361 29362 // Check that the browser supports the APIs we need to implement our special 29363 // DEV version of invokeGuardedCallback 29364 if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { 29365 var fakeNode = document.createElement('react'); 29366 29367 var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) { 29368 // If document doesn't exist we know for sure we will crash in this method 29369 // when we call document.createEvent(). However this can cause confusing 29370 // errors: https://github.com/facebookincubator/create-react-app/issues/3482 29371 // So we preemptively throw with a better message instead. 29372 !(typeof document !== 'undefined') ? invariant(false, 'The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous.') : void 0; 29373 var evt = document.createEvent('Event'); 29374 29375 // Keeps track of whether the user-provided callback threw an error. We 29376 // set this to true at the beginning, then set it to false right after 29377 // calling the function. If the function errors, `didError` will never be 29378 // set to false. This strategy works even if the browser is flaky and 29379 // fails to call our global error handler, because it doesn't rely on 29380 // the error event at all. 29381 var didError = true; 29382 29383 // Create an event handler for our fake event. We will synchronously 29384 // dispatch our fake event using `dispatchEvent`. Inside the handler, we 29385 // call the user-provided callback. 29386 var funcArgs = Array.prototype.slice.call(arguments, 3); 29387 function callCallback() { 29388 // We immediately remove the callback from event listeners so that 29389 // nested `invokeGuardedCallback` calls do not clash. Otherwise, a 29390 // nested call would trigger the fake event handlers of any call higher 29391 // in the stack. 29392 fakeNode.removeEventListener(evtType, callCallback, false); 29393 func.apply(context, funcArgs); 29394 didError = false; 29395 } 29396 29397 // Create a global error event handler. We use this to capture the value 29398 // that was thrown. It's possible that this error handler will fire more 29399 // than once; for example, if non-React code also calls `dispatchEvent` 29400 // and a handler for that event throws. We should be resilient to most of 29401 // those cases. Even if our error event handler fires more than once, the 29402 // last error event is always used. If the callback actually does error, 29403 // we know that the last error event is the correct one, because it's not 29404 // possible for anything else to have happened in between our callback 29405 // erroring and the code that follows the `dispatchEvent` call below. If 29406 // the callback doesn't error, but the error event was fired, we know to 29407 // ignore it because `didError` will be false, as described above. 29408 var error = void 0; 29409 // Use this to track whether the error event is ever called. 29410 var didSetError = false; 29411 var isCrossOriginError = false; 29412 29413 function onError(event) { 29414 error = event.error; 29415 didSetError = true; 29416 if (error === null && event.colno === 0 && event.lineno === 0) { 29417 isCrossOriginError = true; 29418 } 29419 } 29420 29421 // Create a fake event type. 29422 var evtType = 'react-' + (name ? name : 'invokeguardedcallback'); 29423 29424 // Attach our event handlers 29425 window.addEventListener('error', onError); 29426 fakeNode.addEventListener(evtType, callCallback, false); 29427 29428 // Synchronously dispatch our fake event. If the user-provided function 29429 // errors, it will trigger our global error handler. 29430 evt.initEvent(evtType, false, false); 29431 fakeNode.dispatchEvent(evt); 29432 29433 if (didError) { 29434 if (!didSetError) { 29435 // The callback errored, but the error event never fired. 29436 error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.'); 29437 } else if (isCrossOriginError) { 29438 error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.'); 29439 } 29440 this._hasCaughtError = true; 29441 this._caughtError = error; 29442 } else { 29443 this._hasCaughtError = false; 29444 this._caughtError = null; 29445 } 29446 29447 // Remove our event listeners 29448 window.removeEventListener('error', onError); 29449 }; 29450 29451 invokeGuardedCallback = invokeGuardedCallbackDev; 29452 } 29453} 29454 29455var invokeGuardedCallback$1 = invokeGuardedCallback; 29456 29457var ReactErrorUtils = { 29458 // Used by Fiber to simulate a try-catch. 29459 _caughtError: null, 29460 _hasCaughtError: false, 29461 29462 // Used by event system to capture/rethrow the first error. 29463 _rethrowError: null, 29464 _hasRethrowError: false, 29465 29466 /** 29467 * Call a function while guarding against errors that happens within it. 29468 * Returns an error if it throws, otherwise null. 29469 * 29470 * In production, this is implemented using a try-catch. The reason we don't 29471 * use a try-catch directly is so that we can swap out a different 29472 * implementation in DEV mode. 29473 * 29474 * @param {String} name of the guard to use for logging or debugging 29475 * @param {Function} func The function to invoke 29476 * @param {*} context The context to use when calling the function 29477 * @param {...*} args Arguments for function 29478 */ 29479 invokeGuardedCallback: function (name, func, context, a, b, c, d, e, f) { 29480 invokeGuardedCallback$1.apply(ReactErrorUtils, arguments); 29481 }, 29482 29483 /** 29484 * Same as invokeGuardedCallback, but instead of returning an error, it stores 29485 * it in a global so it can be rethrown by `rethrowCaughtError` later. 29486 * TODO: See if _caughtError and _rethrowError can be unified. 29487 * 29488 * @param {String} name of the guard to use for logging or debugging 29489 * @param {Function} func The function to invoke 29490 * @param {*} context The context to use when calling the function 29491 * @param {...*} args Arguments for function 29492 */ 29493 invokeGuardedCallbackAndCatchFirstError: function (name, func, context, a, b, c, d, e, f) { 29494 ReactErrorUtils.invokeGuardedCallback.apply(this, arguments); 29495 if (ReactErrorUtils.hasCaughtError()) { 29496 var error = ReactErrorUtils.clearCaughtError(); 29497 if (!ReactErrorUtils._hasRethrowError) { 29498 ReactErrorUtils._hasRethrowError = true; 29499 ReactErrorUtils._rethrowError = error; 29500 } 29501 } 29502 }, 29503 29504 /** 29505 * During execution of guarded functions we will capture the first error which 29506 * we will rethrow to be handled by the top level error handler. 29507 */ 29508 rethrowCaughtError: function () { 29509 return rethrowCaughtError.apply(ReactErrorUtils, arguments); 29510 }, 29511 29512 hasCaughtError: function () { 29513 return ReactErrorUtils._hasCaughtError; 29514 }, 29515 29516 clearCaughtError: function () { 29517 if (ReactErrorUtils._hasCaughtError) { 29518 var error = ReactErrorUtils._caughtError; 29519 ReactErrorUtils._caughtError = null; 29520 ReactErrorUtils._hasCaughtError = false; 29521 return error; 29522 } else { 29523 invariant(false, 'clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.'); 29524 } 29525 } 29526}; 29527 29528var rethrowCaughtError = function () { 29529 if (ReactErrorUtils._hasRethrowError) { 29530 var error = ReactErrorUtils._rethrowError; 29531 ReactErrorUtils._rethrowError = null; 29532 ReactErrorUtils._hasRethrowError = false; 29533 throw error; 29534 } 29535}; 29536 29537/** 29538 * Injectable ordering of event plugins. 29539 */ 29540var eventPluginOrder = null; 29541 29542/** 29543 * Injectable mapping from names to event plugin modules. 29544 */ 29545var namesToPlugins = {}; 29546 29547/** 29548 * Recomputes the plugin list using the injected plugins and plugin ordering. 29549 * 29550 * @private 29551 */ 29552function recomputePluginOrdering() { 29553 if (!eventPluginOrder) { 29554 // Wait until an `eventPluginOrder` is injected. 29555 return; 29556 } 29557 for (var pluginName in namesToPlugins) { 29558 var pluginModule = namesToPlugins[pluginName]; 29559 var pluginIndex = eventPluginOrder.indexOf(pluginName); 29560 !(pluginIndex > -1) ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.', pluginName) : void 0; 29561 if (plugins[pluginIndex]) { 29562 continue; 29563 } 29564 !pluginModule.extractEvents ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.', pluginName) : void 0; 29565 plugins[pluginIndex] = pluginModule; 29566 var publishedEvents = pluginModule.eventTypes; 29567 for (var eventName in publishedEvents) { 29568 !publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName) ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : void 0; 29569 } 29570 } 29571} 29572 29573/** 29574 * Publishes an event so that it can be dispatched by the supplied plugin. 29575 * 29576 * @param {object} dispatchConfig Dispatch configuration for the event. 29577 * @param {object} PluginModule Plugin publishing the event. 29578 * @return {boolean} True if the event was successfully published. 29579 * @private 29580 */ 29581function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { 29582 !!eventNameDispatchConfigs.hasOwnProperty(eventName) ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.', eventName) : void 0; 29583 eventNameDispatchConfigs[eventName] = dispatchConfig; 29584 29585 var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; 29586 if (phasedRegistrationNames) { 29587 for (var phaseName in phasedRegistrationNames) { 29588 if (phasedRegistrationNames.hasOwnProperty(phaseName)) { 29589 var phasedRegistrationName = phasedRegistrationNames[phaseName]; 29590 publishRegistrationName(phasedRegistrationName, pluginModule, eventName); 29591 } 29592 } 29593 return true; 29594 } else if (dispatchConfig.registrationName) { 29595 publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName); 29596 return true; 29597 } 29598 return false; 29599} 29600 29601/** 29602 * Publishes a registration name that is used to identify dispatched events. 29603 * 29604 * @param {string} registrationName Registration name to add. 29605 * @param {object} PluginModule Plugin publishing the event. 29606 * @private 29607 */ 29608function publishRegistrationName(registrationName, pluginModule, eventName) { 29609 !!registrationNameModules[registrationName] ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.', registrationName) : void 0; 29610 registrationNameModules[registrationName] = pluginModule; 29611 registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies; 29612 29613 { 29614 var lowerCasedName = registrationName.toLowerCase(); 29615 possibleRegistrationNames[lowerCasedName] = registrationName; 29616 29617 if (registrationName === 'onDoubleClick') { 29618 possibleRegistrationNames.ondblclick = registrationName; 29619 } 29620 } 29621} 29622 29623/** 29624 * Registers plugins so that they can extract and dispatch events. 29625 * 29626 * @see {EventPluginHub} 29627 */ 29628 29629/** 29630 * Ordered list of injected plugins. 29631 */ 29632var plugins = []; 29633 29634/** 29635 * Mapping from event name to dispatch config 29636 */ 29637var eventNameDispatchConfigs = {}; 29638 29639/** 29640 * Mapping from registration name to plugin module 29641 */ 29642var registrationNameModules = {}; 29643 29644/** 29645 * Mapping from registration name to event name 29646 */ 29647var registrationNameDependencies = {}; 29648 29649/** 29650 * Mapping from lowercase registration names to the properly cased version, 29651 * used to warn in the case of missing event handlers. Available 29652 * only in true. 29653 * @type {Object} 29654 */ 29655var possibleRegistrationNames = {}; 29656// Trust the developer to only use possibleRegistrationNames in true 29657 29658/** 29659 * Injects an ordering of plugins (by plugin name). This allows the ordering 29660 * to be decoupled from injection of the actual plugins so that ordering is 29661 * always deterministic regardless of packaging, on-the-fly injection, etc. 29662 * 29663 * @param {array} InjectedEventPluginOrder 29664 * @internal 29665 * @see {EventPluginHub.injection.injectEventPluginOrder} 29666 */ 29667function injectEventPluginOrder(injectedEventPluginOrder) { 29668 !!eventPluginOrder ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.') : void 0; 29669 // Clone the ordering so it cannot be dynamically mutated. 29670 eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); 29671 recomputePluginOrdering(); 29672} 29673 29674/** 29675 * Injects plugins to be used by `EventPluginHub`. The plugin names must be 29676 * in the ordering injected by `injectEventPluginOrder`. 29677 * 29678 * Plugins can be injected as part of page initialization or on-the-fly. 29679 * 29680 * @param {object} injectedNamesToPlugins Map from names to plugin modules. 29681 * @internal 29682 * @see {EventPluginHub.injection.injectEventPluginsByName} 29683 */ 29684function injectEventPluginsByName(injectedNamesToPlugins) { 29685 var isOrderingDirty = false; 29686 for (var pluginName in injectedNamesToPlugins) { 29687 if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { 29688 continue; 29689 } 29690 var pluginModule = injectedNamesToPlugins[pluginName]; 29691 if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) { 29692 !!namesToPlugins[pluginName] ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.', pluginName) : void 0; 29693 namesToPlugins[pluginName] = pluginModule; 29694 isOrderingDirty = true; 29695 } 29696 } 29697 if (isOrderingDirty) { 29698 recomputePluginOrdering(); 29699 } 29700} 29701 29702var EventPluginRegistry = Object.freeze({ 29703 plugins: plugins, 29704 eventNameDispatchConfigs: eventNameDispatchConfigs, 29705 registrationNameModules: registrationNameModules, 29706 registrationNameDependencies: registrationNameDependencies, 29707 possibleRegistrationNames: possibleRegistrationNames, 29708 injectEventPluginOrder: injectEventPluginOrder, 29709 injectEventPluginsByName: injectEventPluginsByName 29710}); 29711 29712var getFiberCurrentPropsFromNode = null; 29713var getInstanceFromNode = null; 29714var getNodeFromInstance = null; 29715 29716var injection$1 = { 29717 injectComponentTree: function (Injected) { 29718 getFiberCurrentPropsFromNode = Injected.getFiberCurrentPropsFromNode; 29719 getInstanceFromNode = Injected.getInstanceFromNode; 29720 getNodeFromInstance = Injected.getNodeFromInstance; 29721 29722 { 29723 !(getNodeFromInstance && getInstanceFromNode) ? warning(false, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0; 29724 } 29725 } 29726}; 29727 29728var validateEventDispatches = void 0; 29729{ 29730 validateEventDispatches = function (event) { 29731 var dispatchListeners = event._dispatchListeners; 29732 var dispatchInstances = event._dispatchInstances; 29733 29734 var listenersIsArr = Array.isArray(dispatchListeners); 29735 var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0; 29736 29737 var instancesIsArr = Array.isArray(dispatchInstances); 29738 var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0; 29739 29740 !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warning(false, 'EventPluginUtils: Invalid `event`.') : void 0; 29741 }; 29742} 29743 29744/** 29745 * Dispatch the event to the listener. 29746 * @param {SyntheticEvent} event SyntheticEvent to handle 29747 * @param {boolean} simulated If the event is simulated (changes exn behavior) 29748 * @param {function} listener Application-level callback 29749 * @param {*} inst Internal component instance 29750 */ 29751function executeDispatch(event, simulated, listener, inst) { 29752 var type = event.type || 'unknown-event'; 29753 event.currentTarget = getNodeFromInstance(inst); 29754 ReactErrorUtils.invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); 29755 event.currentTarget = null; 29756} 29757 29758/** 29759 * Standard/simple iteration through an event's collected dispatches. 29760 */ 29761function executeDispatchesInOrder(event, simulated) { 29762 var dispatchListeners = event._dispatchListeners; 29763 var dispatchInstances = event._dispatchInstances; 29764 { 29765 validateEventDispatches(event); 29766 } 29767 if (Array.isArray(dispatchListeners)) { 29768 for (var i = 0; i < dispatchListeners.length; i++) { 29769 if (event.isPropagationStopped()) { 29770 break; 29771 } 29772 // Listeners and Instances are two parallel arrays that are always in sync. 29773 executeDispatch(event, simulated, dispatchListeners[i], dispatchInstances[i]); 29774 } 29775 } else if (dispatchListeners) { 29776 executeDispatch(event, simulated, dispatchListeners, dispatchInstances); 29777 } 29778 event._dispatchListeners = null; 29779 event._dispatchInstances = null; 29780} 29781 29782/** 29783 * @see executeDispatchesInOrderStopAtTrueImpl 29784 */ 29785 29786 29787/** 29788 * Execution of a "direct" dispatch - there must be at most one dispatch 29789 * accumulated on the event or it is considered an error. It doesn't really make 29790 * sense for an event with multiple dispatches (bubbled) to keep track of the 29791 * return values at each dispatch execution, but it does tend to make sense when 29792 * dealing with "direct" dispatches. 29793 * 29794 * @return {*} The return value of executing the single dispatch. 29795 */ 29796 29797 29798/** 29799 * @param {SyntheticEvent} event 29800 * @return {boolean} True iff number of dispatches accumulated is greater than 0. 29801 */ 29802 29803/** 29804 * Accumulates items that must not be null or undefined into the first one. This 29805 * is used to conserve memory by avoiding array allocations, and thus sacrifices 29806 * API cleanness. Since `current` can be null before being passed in and not 29807 * null after this function, make sure to assign it back to `current`: 29808 * 29809 * `a = accumulateInto(a, b);` 29810 * 29811 * This API should be sparingly used. Try `accumulate` for something cleaner. 29812 * 29813 * @return {*|array<*>} An accumulation of items. 29814 */ 29815 29816function accumulateInto(current, next) { 29817 !(next != null) ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : void 0; 29818 29819 if (current == null) { 29820 return next; 29821 } 29822 29823 // Both are not empty. Warning: Never call x.concat(y) when you are not 29824 // certain that x is an Array (x could be a string with concat method). 29825 if (Array.isArray(current)) { 29826 if (Array.isArray(next)) { 29827 current.push.apply(current, next); 29828 return current; 29829 } 29830 current.push(next); 29831 return current; 29832 } 29833 29834 if (Array.isArray(next)) { 29835 // A bit too dangerous to mutate `next`. 29836 return [current].concat(next); 29837 } 29838 29839 return [current, next]; 29840} 29841 29842/** 29843 * @param {array} arr an "accumulation" of items which is either an Array or 29844 * a single item. Useful when paired with the `accumulate` module. This is a 29845 * simple utility that allows us to reason about a collection of items, but 29846 * handling the case when there is exactly one item (and we do not need to 29847 * allocate an array). 29848 * @param {function} cb Callback invoked with each element or a collection. 29849 * @param {?} [scope] Scope used as `this` in a callback. 29850 */ 29851function forEachAccumulated(arr, cb, scope) { 29852 if (Array.isArray(arr)) { 29853 arr.forEach(cb, scope); 29854 } else if (arr) { 29855 cb.call(scope, arr); 29856 } 29857} 29858 29859/** 29860 * Internal queue of events that have accumulated their dispatches and are 29861 * waiting to have their dispatches executed. 29862 */ 29863var eventQueue = null; 29864 29865/** 29866 * Dispatches an event and releases it back into the pool, unless persistent. 29867 * 29868 * @param {?object} event Synthetic event to be dispatched. 29869 * @param {boolean} simulated If the event is simulated (changes exn behavior) 29870 * @private 29871 */ 29872var executeDispatchesAndRelease = function (event, simulated) { 29873 if (event) { 29874 executeDispatchesInOrder(event, simulated); 29875 29876 if (!event.isPersistent()) { 29877 event.constructor.release(event); 29878 } 29879 } 29880}; 29881var executeDispatchesAndReleaseSimulated = function (e) { 29882 return executeDispatchesAndRelease(e, true); 29883}; 29884var executeDispatchesAndReleaseTopLevel = function (e) { 29885 return executeDispatchesAndRelease(e, false); 29886}; 29887 29888function isInteractive(tag) { 29889 return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; 29890} 29891 29892function shouldPreventMouseEvent(name, type, props) { 29893 switch (name) { 29894 case 'onClick': 29895 case 'onClickCapture': 29896 case 'onDoubleClick': 29897 case 'onDoubleClickCapture': 29898 case 'onMouseDown': 29899 case 'onMouseDownCapture': 29900 case 'onMouseMove': 29901 case 'onMouseMoveCapture': 29902 case 'onMouseUp': 29903 case 'onMouseUpCapture': 29904 return !!(props.disabled && isInteractive(type)); 29905 default: 29906 return false; 29907 } 29908} 29909 29910/** 29911 * This is a unified interface for event plugins to be installed and configured. 29912 * 29913 * Event plugins can implement the following properties: 29914 * 29915 * `extractEvents` {function(string, DOMEventTarget, string, object): *} 29916 * Required. When a top-level event is fired, this method is expected to 29917 * extract synthetic events that will in turn be queued and dispatched. 29918 * 29919 * `eventTypes` {object} 29920 * Optional, plugins that fire events must publish a mapping of registration 29921 * names that are used to register listeners. Values of this mapping must 29922 * be objects that contain `registrationName` or `phasedRegistrationNames`. 29923 * 29924 * `executeDispatch` {function(object, function, string)} 29925 * Optional, allows plugins to override how an event gets dispatched. By 29926 * default, the listener is simply invoked. 29927 * 29928 * Each plugin that is injected into `EventsPluginHub` is immediately operable. 29929 * 29930 * @public 29931 */ 29932 29933/** 29934 * Methods for injecting dependencies. 29935 */ 29936var injection = { 29937 /** 29938 * @param {array} InjectedEventPluginOrder 29939 * @public 29940 */ 29941 injectEventPluginOrder: injectEventPluginOrder, 29942 29943 /** 29944 * @param {object} injectedNamesToPlugins Map from names to plugin modules. 29945 */ 29946 injectEventPluginsByName: injectEventPluginsByName 29947}; 29948 29949/** 29950 * @param {object} inst The instance, which is the source of events. 29951 * @param {string} registrationName Name of listener (e.g. `onClick`). 29952 * @return {?function} The stored callback. 29953 */ 29954function getListener(inst, registrationName) { 29955 var listener = void 0; 29956 29957 // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not 29958 // live here; needs to be moved to a better place soon 29959 var stateNode = inst.stateNode; 29960 if (!stateNode) { 29961 // Work in progress (ex: onload events in incremental mode). 29962 return null; 29963 } 29964 var props = getFiberCurrentPropsFromNode(stateNode); 29965 if (!props) { 29966 // Work in progress. 29967 return null; 29968 } 29969 listener = props[registrationName]; 29970 if (shouldPreventMouseEvent(registrationName, inst.type, props)) { 29971 return null; 29972 } 29973 !(!listener || typeof listener === 'function') ? invariant(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener) : void 0; 29974 return listener; 29975} 29976 29977/** 29978 * Allows registered plugins an opportunity to extract events from top-level 29979 * native browser events. 29980 * 29981 * @return {*} An accumulation of synthetic events. 29982 * @internal 29983 */ 29984function extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget) { 29985 var events = null; 29986 for (var i = 0; i < plugins.length; i++) { 29987 // Not every plugin in the ordering may be loaded at runtime. 29988 var possiblePlugin = plugins[i]; 29989 if (possiblePlugin) { 29990 var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget); 29991 if (extractedEvents) { 29992 events = accumulateInto(events, extractedEvents); 29993 } 29994 } 29995 } 29996 return events; 29997} 29998 29999function runEventsInBatch(events, simulated) { 30000 if (events !== null) { 30001 eventQueue = accumulateInto(eventQueue, events); 30002 } 30003 30004 // Set `eventQueue` to null before processing it so that we can tell if more 30005 // events get enqueued while processing. 30006 var processingEventQueue = eventQueue; 30007 eventQueue = null; 30008 30009 if (!processingEventQueue) { 30010 return; 30011 } 30012 30013 if (simulated) { 30014 forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseSimulated); 30015 } else { 30016 forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); 30017 } 30018 !!eventQueue ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.') : void 0; 30019 // This would be a good time to rethrow if any of the event handlers threw. 30020 ReactErrorUtils.rethrowCaughtError(); 30021} 30022 30023function runExtractedEventsInBatch(topLevelType, targetInst, nativeEvent, nativeEventTarget) { 30024 var events = extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget); 30025 runEventsInBatch(events, false); 30026} 30027 30028var EventPluginHub = Object.freeze({ 30029 injection: injection, 30030 getListener: getListener, 30031 runEventsInBatch: runEventsInBatch, 30032 runExtractedEventsInBatch: runExtractedEventsInBatch 30033}); 30034 30035var IndeterminateComponent = 0; // Before we know whether it is functional or class 30036var FunctionalComponent = 1; 30037var ClassComponent = 2; 30038var HostRoot = 3; // Root of a host tree. Could be nested inside another node. 30039var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. 30040var HostComponent = 5; 30041var HostText = 6; 30042 30043 30044 30045var Fragment = 10; 30046var Mode = 11; 30047var ContextConsumer = 12; 30048var ContextProvider = 13; 30049var ForwardRef = 14; 30050var Profiler = 15; 30051var TimeoutComponent = 16; 30052 30053var randomKey = Math.random().toString(36).slice(2); 30054var internalInstanceKey = '__reactInternalInstance$' + randomKey; 30055var internalEventHandlersKey = '__reactEventHandlers$' + randomKey; 30056 30057function precacheFiberNode(hostInst, node) { 30058 node[internalInstanceKey] = hostInst; 30059} 30060 30061/** 30062 * Given a DOM node, return the closest ReactDOMComponent or 30063 * ReactDOMTextComponent instance ancestor. 30064 */ 30065function getClosestInstanceFromNode(node) { 30066 if (node[internalInstanceKey]) { 30067 return node[internalInstanceKey]; 30068 } 30069 30070 while (!node[internalInstanceKey]) { 30071 if (node.parentNode) { 30072 node = node.parentNode; 30073 } else { 30074 // Top of the tree. This node must not be part of a React tree (or is 30075 // unmounted, potentially). 30076 return null; 30077 } 30078 } 30079 30080 var inst = node[internalInstanceKey]; 30081 if (inst.tag === HostComponent || inst.tag === HostText) { 30082 // In Fiber, this will always be the deepest root. 30083 return inst; 30084 } 30085 30086 return null; 30087} 30088 30089/** 30090 * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent 30091 * instance, or null if the node was not rendered by this React. 30092 */ 30093function getInstanceFromNode$1(node) { 30094 var inst = node[internalInstanceKey]; 30095 if (inst) { 30096 if (inst.tag === HostComponent || inst.tag === HostText) { 30097 return inst; 30098 } else { 30099 return null; 30100 } 30101 } 30102 return null; 30103} 30104 30105/** 30106 * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding 30107 * DOM node. 30108 */ 30109function getNodeFromInstance$1(inst) { 30110 if (inst.tag === HostComponent || inst.tag === HostText) { 30111 // In Fiber this, is just the state node right now. We assume it will be 30112 // a host component or host text. 30113 return inst.stateNode; 30114 } 30115 30116 // Without this first invariant, passing a non-DOM-component triggers the next 30117 // invariant for a missing parent, which is super confusing. 30118 invariant(false, 'getNodeFromInstance: Invalid argument.'); 30119} 30120 30121function getFiberCurrentPropsFromNode$1(node) { 30122 return node[internalEventHandlersKey] || null; 30123} 30124 30125function updateFiberProps(node, props) { 30126 node[internalEventHandlersKey] = props; 30127} 30128 30129var ReactDOMComponentTree = Object.freeze({ 30130 precacheFiberNode: precacheFiberNode, 30131 getClosestInstanceFromNode: getClosestInstanceFromNode, 30132 getInstanceFromNode: getInstanceFromNode$1, 30133 getNodeFromInstance: getNodeFromInstance$1, 30134 getFiberCurrentPropsFromNode: getFiberCurrentPropsFromNode$1, 30135 updateFiberProps: updateFiberProps 30136}); 30137 30138function getParent(inst) { 30139 do { 30140 inst = inst.return; 30141 // TODO: If this is a HostRoot we might want to bail out. 30142 // That is depending on if we want nested subtrees (layers) to bubble 30143 // events to their parent. We could also go through parentNode on the 30144 // host node but that wouldn't work for React Native and doesn't let us 30145 // do the portal feature. 30146 } while (inst && inst.tag !== HostComponent); 30147 if (inst) { 30148 return inst; 30149 } 30150 return null; 30151} 30152 30153/** 30154 * Return the lowest common ancestor of A and B, or null if they are in 30155 * different trees. 30156 */ 30157function getLowestCommonAncestor(instA, instB) { 30158 var depthA = 0; 30159 for (var tempA = instA; tempA; tempA = getParent(tempA)) { 30160 depthA++; 30161 } 30162 var depthB = 0; 30163 for (var tempB = instB; tempB; tempB = getParent(tempB)) { 30164 depthB++; 30165 } 30166 30167 // If A is deeper, crawl up. 30168 while (depthA - depthB > 0) { 30169 instA = getParent(instA); 30170 depthA--; 30171 } 30172 30173 // If B is deeper, crawl up. 30174 while (depthB - depthA > 0) { 30175 instB = getParent(instB); 30176 depthB--; 30177 } 30178 30179 // Walk in lockstep until we find a match. 30180 var depth = depthA; 30181 while (depth--) { 30182 if (instA === instB || instA === instB.alternate) { 30183 return instA; 30184 } 30185 instA = getParent(instA); 30186 instB = getParent(instB); 30187 } 30188 return null; 30189} 30190 30191/** 30192 * Return if A is an ancestor of B. 30193 */ 30194 30195 30196/** 30197 * Return the parent instance of the passed-in instance. 30198 */ 30199function getParentInstance(inst) { 30200 return getParent(inst); 30201} 30202 30203/** 30204 * Simulates the traversal of a two-phase, capture/bubble event dispatch. 30205 */ 30206function traverseTwoPhase(inst, fn, arg) { 30207 var path = []; 30208 while (inst) { 30209 path.push(inst); 30210 inst = getParent(inst); 30211 } 30212 var i = void 0; 30213 for (i = path.length; i-- > 0;) { 30214 fn(path[i], 'captured', arg); 30215 } 30216 for (i = 0; i < path.length; i++) { 30217 fn(path[i], 'bubbled', arg); 30218 } 30219} 30220 30221/** 30222 * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that 30223 * should would receive a `mouseEnter` or `mouseLeave` event. 30224 * 30225 * Does not invoke the callback on the nearest common ancestor because nothing 30226 * "entered" or "left" that element. 30227 */ 30228function traverseEnterLeave(from, to, fn, argFrom, argTo) { 30229 var common = from && to ? getLowestCommonAncestor(from, to) : null; 30230 var pathFrom = []; 30231 while (true) { 30232 if (!from) { 30233 break; 30234 } 30235 if (from === common) { 30236 break; 30237 } 30238 var alternate = from.alternate; 30239 if (alternate !== null && alternate === common) { 30240 break; 30241 } 30242 pathFrom.push(from); 30243 from = getParent(from); 30244 } 30245 var pathTo = []; 30246 while (true) { 30247 if (!to) { 30248 break; 30249 } 30250 if (to === common) { 30251 break; 30252 } 30253 var _alternate = to.alternate; 30254 if (_alternate !== null && _alternate === common) { 30255 break; 30256 } 30257 pathTo.push(to); 30258 to = getParent(to); 30259 } 30260 for (var i = 0; i < pathFrom.length; i++) { 30261 fn(pathFrom[i], 'bubbled', argFrom); 30262 } 30263 for (var _i = pathTo.length; _i-- > 0;) { 30264 fn(pathTo[_i], 'captured', argTo); 30265 } 30266} 30267 30268/** 30269 * Some event types have a notion of different registration names for different 30270 * "phases" of propagation. This finds listeners by a given phase. 30271 */ 30272function listenerAtPhase(inst, event, propagationPhase) { 30273 var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase]; 30274 return getListener(inst, registrationName); 30275} 30276 30277/** 30278 * A small set of propagation patterns, each of which will accept a small amount 30279 * of information, and generate a set of "dispatch ready event objects" - which 30280 * are sets of events that have already been annotated with a set of dispatched 30281 * listener functions/ids. The API is designed this way to discourage these 30282 * propagation strategies from actually executing the dispatches, since we 30283 * always want to collect the entire set of dispatches before executing even a 30284 * single one. 30285 */ 30286 30287/** 30288 * Tags a `SyntheticEvent` with dispatched listeners. Creating this function 30289 * here, allows us to not have to bind or create functions for each event. 30290 * Mutating the event's members allows us to not have to create a wrapping 30291 * "dispatch" object that pairs the event with the listener. 30292 */ 30293function accumulateDirectionalDispatches(inst, phase, event) { 30294 { 30295 !inst ? warning(false, 'Dispatching inst must not be null') : void 0; 30296 } 30297 var listener = listenerAtPhase(inst, event, phase); 30298 if (listener) { 30299 event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); 30300 event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); 30301 } 30302} 30303 30304/** 30305 * Collect dispatches (must be entirely collected before dispatching - see unit 30306 * tests). Lazily allocate the array to conserve memory. We must loop through 30307 * each event and perform the traversal for each one. We cannot perform a 30308 * single traversal for the entire collection of events because each event may 30309 * have a different target. 30310 */ 30311function accumulateTwoPhaseDispatchesSingle(event) { 30312 if (event && event.dispatchConfig.phasedRegistrationNames) { 30313 traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); 30314 } 30315} 30316 30317/** 30318 * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID. 30319 */ 30320function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { 30321 if (event && event.dispatchConfig.phasedRegistrationNames) { 30322 var targetInst = event._targetInst; 30323 var parentInst = targetInst ? getParentInstance(targetInst) : null; 30324 traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); 30325 } 30326} 30327 30328/** 30329 * Accumulates without regard to direction, does not look for phased 30330 * registration names. Same as `accumulateDirectDispatchesSingle` but without 30331 * requiring that the `dispatchMarker` be the same as the dispatched ID. 30332 */ 30333function accumulateDispatches(inst, ignoredDirection, event) { 30334 if (inst && event && event.dispatchConfig.registrationName) { 30335 var registrationName = event.dispatchConfig.registrationName; 30336 var listener = getListener(inst, registrationName); 30337 if (listener) { 30338 event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); 30339 event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); 30340 } 30341 } 30342} 30343 30344/** 30345 * Accumulates dispatches on an `SyntheticEvent`, but only for the 30346 * `dispatchMarker`. 30347 * @param {SyntheticEvent} event 30348 */ 30349function accumulateDirectDispatchesSingle(event) { 30350 if (event && event.dispatchConfig.registrationName) { 30351 accumulateDispatches(event._targetInst, null, event); 30352 } 30353} 30354 30355function accumulateTwoPhaseDispatches(events) { 30356 forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); 30357} 30358 30359function accumulateTwoPhaseDispatchesSkipTarget(events) { 30360 forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget); 30361} 30362 30363function accumulateEnterLeaveDispatches(leave, enter, from, to) { 30364 traverseEnterLeave(from, to, accumulateDispatches, leave, enter); 30365} 30366 30367function accumulateDirectDispatches(events) { 30368 forEachAccumulated(events, accumulateDirectDispatchesSingle); 30369} 30370 30371var EventPropagators = Object.freeze({ 30372 accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches, 30373 accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget, 30374 accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches, 30375 accumulateDirectDispatches: accumulateDirectDispatches 30376}); 30377 30378// Do not uses the below two methods directly! 30379// Instead use constants exported from DOMTopLevelEventTypes in ReactDOM. 30380// (It is the only module that is allowed to access these methods.) 30381 30382function unsafeCastStringToDOMTopLevelType(topLevelType) { 30383 return topLevelType; 30384} 30385 30386function unsafeCastDOMTopLevelTypeToString(topLevelType) { 30387 return topLevelType; 30388} 30389 30390/** 30391 * Generate a mapping of standard vendor prefixes using the defined style property and event name. 30392 * 30393 * @param {string} styleProp 30394 * @param {string} eventName 30395 * @returns {object} 30396 */ 30397function makePrefixMap(styleProp, eventName) { 30398 var prefixes = {}; 30399 30400 prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); 30401 prefixes['Webkit' + styleProp] = 'webkit' + eventName; 30402 prefixes['Moz' + styleProp] = 'moz' + eventName; 30403 prefixes['ms' + styleProp] = 'MS' + eventName; 30404 prefixes['O' + styleProp] = 'o' + eventName.toLowerCase(); 30405 30406 return prefixes; 30407} 30408 30409/** 30410 * A list of event names to a configurable list of vendor prefixes. 30411 */ 30412var vendorPrefixes = { 30413 animationend: makePrefixMap('Animation', 'AnimationEnd'), 30414 animationiteration: makePrefixMap('Animation', 'AnimationIteration'), 30415 animationstart: makePrefixMap('Animation', 'AnimationStart'), 30416 transitionend: makePrefixMap('Transition', 'TransitionEnd') 30417}; 30418 30419/** 30420 * Event names that have already been detected and prefixed (if applicable). 30421 */ 30422var prefixedEventNames = {}; 30423 30424/** 30425 * Element to check for prefixes on. 30426 */ 30427var style = {}; 30428 30429/** 30430 * Bootstrap if a DOM exists. 30431 */ 30432if (ExecutionEnvironment.canUseDOM) { 30433 style = document.createElement('div').style; 30434 30435 // On some platforms, in particular some releases of Android 4.x, 30436 // the un-prefixed "animation" and "transition" properties are defined on the 30437 // style object but the events that fire will still be prefixed, so we need 30438 // to check if the un-prefixed events are usable, and if not remove them from the map. 30439 if (!('AnimationEvent' in window)) { 30440 delete vendorPrefixes.animationend.animation; 30441 delete vendorPrefixes.animationiteration.animation; 30442 delete vendorPrefixes.animationstart.animation; 30443 } 30444 30445 // Same as above 30446 if (!('TransitionEvent' in window)) { 30447 delete vendorPrefixes.transitionend.transition; 30448 } 30449} 30450 30451/** 30452 * Attempts to determine the correct vendor prefixed event name. 30453 * 30454 * @param {string} eventName 30455 * @returns {string} 30456 */ 30457function getVendorPrefixedEventName(eventName) { 30458 if (prefixedEventNames[eventName]) { 30459 return prefixedEventNames[eventName]; 30460 } else if (!vendorPrefixes[eventName]) { 30461 return eventName; 30462 } 30463 30464 var prefixMap = vendorPrefixes[eventName]; 30465 30466 for (var styleProp in prefixMap) { 30467 if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { 30468 return prefixedEventNames[eventName] = prefixMap[styleProp]; 30469 } 30470 } 30471 30472 return eventName; 30473} 30474 30475/** 30476 * To identify top level events in ReactDOM, we use constants defined by this 30477 * module. This is the only module that uses the unsafe* methods to express 30478 * that the constants actually correspond to the browser event names. This lets 30479 * us save some bundle size by avoiding a top level type -> event name map. 30480 * The rest of ReactDOM code should import top level types from this file. 30481 */ 30482var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort'); 30483var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend')); 30484var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration')); 30485var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart')); 30486var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur'); 30487var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay'); 30488var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough'); 30489var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel'); 30490var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change'); 30491var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click'); 30492var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close'); 30493var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend'); 30494var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart'); 30495var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate'); 30496var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu'); 30497var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy'); 30498var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut'); 30499var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick'); 30500var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag'); 30501var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend'); 30502var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter'); 30503var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit'); 30504var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave'); 30505var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover'); 30506var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart'); 30507var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop'); 30508var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange'); 30509var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied'); 30510var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted'); 30511var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended'); 30512var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error'); 30513var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus'); 30514var TOP_GOT_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('gotpointercapture'); 30515var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input'); 30516var TOP_INVALID = unsafeCastStringToDOMTopLevelType('invalid'); 30517var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown'); 30518var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress'); 30519var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup'); 30520var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load'); 30521var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart'); 30522var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata'); 30523var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata'); 30524var TOP_LOST_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('lostpointercapture'); 30525var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown'); 30526var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove'); 30527var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout'); 30528var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover'); 30529var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup'); 30530var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste'); 30531var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause'); 30532var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play'); 30533var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing'); 30534var TOP_POINTER_CANCEL = unsafeCastStringToDOMTopLevelType('pointercancel'); 30535var TOP_POINTER_DOWN = unsafeCastStringToDOMTopLevelType('pointerdown'); 30536 30537 30538var TOP_POINTER_MOVE = unsafeCastStringToDOMTopLevelType('pointermove'); 30539var TOP_POINTER_OUT = unsafeCastStringToDOMTopLevelType('pointerout'); 30540var TOP_POINTER_OVER = unsafeCastStringToDOMTopLevelType('pointerover'); 30541var TOP_POINTER_UP = unsafeCastStringToDOMTopLevelType('pointerup'); 30542var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress'); 30543var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange'); 30544var TOP_RESET = unsafeCastStringToDOMTopLevelType('reset'); 30545var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll'); 30546var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked'); 30547var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking'); 30548var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange'); 30549var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled'); 30550var TOP_SUBMIT = unsafeCastStringToDOMTopLevelType('submit'); 30551var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend'); 30552var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput'); 30553var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate'); 30554var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle'); 30555var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel'); 30556var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend'); 30557var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove'); 30558var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart'); 30559var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend')); 30560var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange'); 30561var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting'); 30562var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel'); 30563 30564// List of events that need to be individually attached to media elements. 30565// Note that events in this list will *not* be listened to at the top level 30566// unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`. 30567var mediaEventTypes = [TOP_ABORT, TOP_CAN_PLAY, TOP_CAN_PLAY_THROUGH, TOP_DURATION_CHANGE, TOP_EMPTIED, TOP_ENCRYPTED, TOP_ENDED, TOP_ERROR, TOP_LOADED_DATA, TOP_LOADED_METADATA, TOP_LOAD_START, TOP_PAUSE, TOP_PLAY, TOP_PLAYING, TOP_PROGRESS, TOP_RATE_CHANGE, TOP_SEEKED, TOP_SEEKING, TOP_STALLED, TOP_SUSPEND, TOP_TIME_UPDATE, TOP_VOLUME_CHANGE, TOP_WAITING]; 30568 30569function getRawEventName(topLevelType) { 30570 return unsafeCastDOMTopLevelTypeToString(topLevelType); 30571} 30572 30573var contentKey = null; 30574 30575/** 30576 * Gets the key used to access text content on a DOM node. 30577 * 30578 * @return {?string} Key used to access text content. 30579 * @internal 30580 */ 30581function getTextContentAccessor() { 30582 if (!contentKey && ExecutionEnvironment.canUseDOM) { 30583 // Prefer textContent to innerText because many browsers support both but 30584 // SVG <text> elements don't support innerText even when <div> does. 30585 contentKey = 'textContent' in document.documentElement ? 'textContent' : 'innerText'; 30586 } 30587 return contentKey; 30588} 30589 30590/** 30591 * This helper object stores information about text content of a target node, 30592 * allowing comparison of content before and after a given event. 30593 * 30594 * Identify the node where selection currently begins, then observe 30595 * both its text content and its current position in the DOM. Since the 30596 * browser may natively replace the target node during composition, we can 30597 * use its position to find its replacement. 30598 * 30599 * 30600 */ 30601var compositionState = { 30602 _root: null, 30603 _startText: null, 30604 _fallbackText: null 30605}; 30606 30607function initialize(nativeEventTarget) { 30608 compositionState._root = nativeEventTarget; 30609 compositionState._startText = getText(); 30610 return true; 30611} 30612 30613function reset() { 30614 compositionState._root = null; 30615 compositionState._startText = null; 30616 compositionState._fallbackText = null; 30617} 30618 30619function getData() { 30620 if (compositionState._fallbackText) { 30621 return compositionState._fallbackText; 30622 } 30623 30624 var start = void 0; 30625 var startValue = compositionState._startText; 30626 var startLength = startValue.length; 30627 var end = void 0; 30628 var endValue = getText(); 30629 var endLength = endValue.length; 30630 30631 for (start = 0; start < startLength; start++) { 30632 if (startValue[start] !== endValue[start]) { 30633 break; 30634 } 30635 } 30636 30637 var minEnd = startLength - start; 30638 for (end = 1; end <= minEnd; end++) { 30639 if (startValue[startLength - end] !== endValue[endLength - end]) { 30640 break; 30641 } 30642 } 30643 30644 var sliceTail = end > 1 ? 1 - end : undefined; 30645 compositionState._fallbackText = endValue.slice(start, sliceTail); 30646 return compositionState._fallbackText; 30647} 30648 30649function getText() { 30650 if ('value' in compositionState._root) { 30651 return compositionState._root.value; 30652 } 30653 return compositionState._root[getTextContentAccessor()]; 30654} 30655 30656/* eslint valid-typeof: 0 */ 30657 30658var didWarnForAddedNewProperty = false; 30659var EVENT_POOL_SIZE = 10; 30660 30661var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances']; 30662 30663/** 30664 * @interface Event 30665 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 30666 */ 30667var EventInterface = { 30668 type: null, 30669 target: null, 30670 // currentTarget is set when dispatching; no use in copying it here 30671 currentTarget: emptyFunction.thatReturnsNull, 30672 eventPhase: null, 30673 bubbles: null, 30674 cancelable: null, 30675 timeStamp: function (event) { 30676 return event.timeStamp || Date.now(); 30677 }, 30678 defaultPrevented: null, 30679 isTrusted: null 30680}; 30681 30682/** 30683 * Synthetic events are dispatched by event plugins, typically in response to a 30684 * top-level event delegation handler. 30685 * 30686 * These systems should generally use pooling to reduce the frequency of garbage 30687 * collection. The system should check `isPersistent` to determine whether the 30688 * event should be released into the pool after being dispatched. Users that 30689 * need a persisted event should invoke `persist`. 30690 * 30691 * Synthetic events (and subclasses) implement the DOM Level 3 Events API by 30692 * normalizing browser quirks. Subclasses do not necessarily have to implement a 30693 * DOM interface; custom application-specific events can also subclass this. 30694 * 30695 * @param {object} dispatchConfig Configuration used to dispatch this event. 30696 * @param {*} targetInst Marker identifying the event target. 30697 * @param {object} nativeEvent Native browser event. 30698 * @param {DOMEventTarget} nativeEventTarget Target node. 30699 */ 30700function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) { 30701 { 30702 // these have a getter/setter for warnings 30703 delete this.nativeEvent; 30704 delete this.preventDefault; 30705 delete this.stopPropagation; 30706 } 30707 30708 this.dispatchConfig = dispatchConfig; 30709 this._targetInst = targetInst; 30710 this.nativeEvent = nativeEvent; 30711 30712 var Interface = this.constructor.Interface; 30713 for (var propName in Interface) { 30714 if (!Interface.hasOwnProperty(propName)) { 30715 continue; 30716 } 30717 { 30718 delete this[propName]; // this has a getter/setter for warnings 30719 } 30720 var normalize = Interface[propName]; 30721 if (normalize) { 30722 this[propName] = normalize(nativeEvent); 30723 } else { 30724 if (propName === 'target') { 30725 this.target = nativeEventTarget; 30726 } else { 30727 this[propName] = nativeEvent[propName]; 30728 } 30729 } 30730 } 30731 30732 var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false; 30733 if (defaultPrevented) { 30734 this.isDefaultPrevented = emptyFunction.thatReturnsTrue; 30735 } else { 30736 this.isDefaultPrevented = emptyFunction.thatReturnsFalse; 30737 } 30738 this.isPropagationStopped = emptyFunction.thatReturnsFalse; 30739 return this; 30740} 30741 30742_assign(SyntheticEvent.prototype, { 30743 preventDefault: function () { 30744 this.defaultPrevented = true; 30745 var event = this.nativeEvent; 30746 if (!event) { 30747 return; 30748 } 30749 30750 if (event.preventDefault) { 30751 event.preventDefault(); 30752 } else if (typeof event.returnValue !== 'unknown') { 30753 event.returnValue = false; 30754 } 30755 this.isDefaultPrevented = emptyFunction.thatReturnsTrue; 30756 }, 30757 30758 stopPropagation: function () { 30759 var event = this.nativeEvent; 30760 if (!event) { 30761 return; 30762 } 30763 30764 if (event.stopPropagation) { 30765 event.stopPropagation(); 30766 } else if (typeof event.cancelBubble !== 'unknown') { 30767 // The ChangeEventPlugin registers a "propertychange" event for 30768 // IE. This event does not support bubbling or cancelling, and 30769 // any references to cancelBubble throw "Member not found". A 30770 // typeof check of "unknown" circumvents this issue (and is also 30771 // IE specific). 30772 event.cancelBubble = true; 30773 } 30774 30775 this.isPropagationStopped = emptyFunction.thatReturnsTrue; 30776 }, 30777 30778 /** 30779 * We release all dispatched `SyntheticEvent`s after each event loop, adding 30780 * them back into the pool. This allows a way to hold onto a reference that 30781 * won't be added back into the pool. 30782 */ 30783 persist: function () { 30784 this.isPersistent = emptyFunction.thatReturnsTrue; 30785 }, 30786 30787 /** 30788 * Checks if this event should be released back into the pool. 30789 * 30790 * @return {boolean} True if this should not be released, false otherwise. 30791 */ 30792 isPersistent: emptyFunction.thatReturnsFalse, 30793 30794 /** 30795 * `PooledClass` looks for `destructor` on each instance it releases. 30796 */ 30797 destructor: function () { 30798 var Interface = this.constructor.Interface; 30799 for (var propName in Interface) { 30800 { 30801 Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName])); 30802 } 30803 } 30804 for (var i = 0; i < shouldBeReleasedProperties.length; i++) { 30805 this[shouldBeReleasedProperties[i]] = null; 30806 } 30807 { 30808 Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null)); 30809 Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction)); 30810 Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction)); 30811 } 30812 } 30813}); 30814 30815SyntheticEvent.Interface = EventInterface; 30816 30817/** 30818 * Helper to reduce boilerplate when creating subclasses. 30819 */ 30820SyntheticEvent.extend = function (Interface) { 30821 var Super = this; 30822 30823 var E = function () {}; 30824 E.prototype = Super.prototype; 30825 var prototype = new E(); 30826 30827 function Class() { 30828 return Super.apply(this, arguments); 30829 } 30830 _assign(prototype, Class.prototype); 30831 Class.prototype = prototype; 30832 Class.prototype.constructor = Class; 30833 30834 Class.Interface = _assign({}, Super.Interface, Interface); 30835 Class.extend = Super.extend; 30836 addEventPoolingTo(Class); 30837 30838 return Class; 30839}; 30840 30841/** Proxying after everything set on SyntheticEvent 30842 * to resolve Proxy issue on some WebKit browsers 30843 * in which some Event properties are set to undefined (GH#10010) 30844 */ 30845{ 30846 var isProxySupported = typeof Proxy === 'function' && 30847 // https://github.com/facebook/react/issues/12011 30848 !Object.isSealed(new Proxy({}, {})); 30849 30850 if (isProxySupported) { 30851 /*eslint-disable no-func-assign */ 30852 SyntheticEvent = new Proxy(SyntheticEvent, { 30853 construct: function (target, args) { 30854 return this.apply(target, Object.create(target.prototype), args); 30855 }, 30856 apply: function (constructor, that, args) { 30857 return new Proxy(constructor.apply(that, args), { 30858 set: function (target, prop, value) { 30859 if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) { 30860 !(didWarnForAddedNewProperty || target.isPersistent()) ? warning(false, "This synthetic event is reused for performance reasons. If you're " + "seeing this, you're adding a new property in the synthetic event object. " + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.') : void 0; 30861 didWarnForAddedNewProperty = true; 30862 } 30863 target[prop] = value; 30864 return true; 30865 } 30866 }); 30867 } 30868 }); 30869 /*eslint-enable no-func-assign */ 30870 } 30871} 30872 30873addEventPoolingTo(SyntheticEvent); 30874 30875/** 30876 * Helper to nullify syntheticEvent instance properties when destructing 30877 * 30878 * @param {String} propName 30879 * @param {?object} getVal 30880 * @return {object} defineProperty object 30881 */ 30882function getPooledWarningPropertyDefinition(propName, getVal) { 30883 var isFunction = typeof getVal === 'function'; 30884 return { 30885 configurable: true, 30886 set: set, 30887 get: get 30888 }; 30889 30890 function set(val) { 30891 var action = isFunction ? 'setting the method' : 'setting the property'; 30892 warn(action, 'This is effectively a no-op'); 30893 return val; 30894 } 30895 30896 function get() { 30897 var action = isFunction ? 'accessing the method' : 'accessing the property'; 30898 var result = isFunction ? 'This is a no-op function' : 'This is set to null'; 30899 warn(action, result); 30900 return getVal; 30901 } 30902 30903 function warn(action, result) { 30904 var warningCondition = false; 30905 !warningCondition ? warning(false, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result) : void 0; 30906 } 30907} 30908 30909function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { 30910 var EventConstructor = this; 30911 if (EventConstructor.eventPool.length) { 30912 var instance = EventConstructor.eventPool.pop(); 30913 EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); 30914 return instance; 30915 } 30916 return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst); 30917} 30918 30919function releasePooledEvent(event) { 30920 var EventConstructor = this; 30921 !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0; 30922 event.destructor(); 30923 if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) { 30924 EventConstructor.eventPool.push(event); 30925 } 30926} 30927 30928function addEventPoolingTo(EventConstructor) { 30929 EventConstructor.eventPool = []; 30930 EventConstructor.getPooled = getPooledEvent; 30931 EventConstructor.release = releasePooledEvent; 30932} 30933 30934var SyntheticEvent$1 = SyntheticEvent; 30935 30936/** 30937 * @interface Event 30938 * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents 30939 */ 30940var SyntheticCompositionEvent = SyntheticEvent$1.extend({ 30941 data: null 30942}); 30943 30944/** 30945 * @interface Event 30946 * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105 30947 * /#events-inputevents 30948 */ 30949var SyntheticInputEvent = SyntheticEvent$1.extend({ 30950 data: null 30951}); 30952 30953var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space 30954var START_KEYCODE = 229; 30955 30956var canUseCompositionEvent = ExecutionEnvironment.canUseDOM && 'CompositionEvent' in window; 30957 30958var documentMode = null; 30959if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) { 30960 documentMode = document.documentMode; 30961} 30962 30963// Webkit offers a very useful `textInput` event that can be used to 30964// directly represent `beforeInput`. The IE `textinput` event is not as 30965// useful, so we don't use it. 30966var canUseTextInputEvent = ExecutionEnvironment.canUseDOM && 'TextEvent' in window && !documentMode; 30967 30968// In IE9+, we have access to composition events, but the data supplied 30969// by the native compositionend event may be incorrect. Japanese ideographic 30970// spaces, for instance (\u3000) are not recorded correctly. 30971var useFallbackCompositionData = ExecutionEnvironment.canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11); 30972 30973var SPACEBAR_CODE = 32; 30974var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); 30975 30976// Events and their corresponding property names. 30977var eventTypes = { 30978 beforeInput: { 30979 phasedRegistrationNames: { 30980 bubbled: 'onBeforeInput', 30981 captured: 'onBeforeInputCapture' 30982 }, 30983 dependencies: [TOP_COMPOSITION_END, TOP_KEY_PRESS, TOP_TEXT_INPUT, TOP_PASTE] 30984 }, 30985 compositionEnd: { 30986 phasedRegistrationNames: { 30987 bubbled: 'onCompositionEnd', 30988 captured: 'onCompositionEndCapture' 30989 }, 30990 dependencies: [TOP_BLUR, TOP_COMPOSITION_END, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN] 30991 }, 30992 compositionStart: { 30993 phasedRegistrationNames: { 30994 bubbled: 'onCompositionStart', 30995 captured: 'onCompositionStartCapture' 30996 }, 30997 dependencies: [TOP_BLUR, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN] 30998 }, 30999 compositionUpdate: { 31000 phasedRegistrationNames: { 31001 bubbled: 'onCompositionUpdate', 31002 captured: 'onCompositionUpdateCapture' 31003 }, 31004 dependencies: [TOP_BLUR, TOP_COMPOSITION_UPDATE, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN] 31005 } 31006}; 31007 31008// Track whether we've ever handled a keypress on the space key. 31009var hasSpaceKeypress = false; 31010 31011/** 31012 * Return whether a native keypress event is assumed to be a command. 31013 * This is required because Firefox fires `keypress` events for key commands 31014 * (cut, copy, select-all, etc.) even though no character is inserted. 31015 */ 31016function isKeypressCommand(nativeEvent) { 31017 return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && 31018 // ctrlKey && altKey is equivalent to AltGr, and is not a command. 31019 !(nativeEvent.ctrlKey && nativeEvent.altKey); 31020} 31021 31022/** 31023 * Translate native top level events into event types. 31024 * 31025 * @param {string} topLevelType 31026 * @return {object} 31027 */ 31028function getCompositionEventType(topLevelType) { 31029 switch (topLevelType) { 31030 case TOP_COMPOSITION_START: 31031 return eventTypes.compositionStart; 31032 case TOP_COMPOSITION_END: 31033 return eventTypes.compositionEnd; 31034 case TOP_COMPOSITION_UPDATE: 31035 return eventTypes.compositionUpdate; 31036 } 31037} 31038 31039/** 31040 * Does our fallback best-guess model think this event signifies that 31041 * composition has begun? 31042 * 31043 * @param {string} topLevelType 31044 * @param {object} nativeEvent 31045 * @return {boolean} 31046 */ 31047function isFallbackCompositionStart(topLevelType, nativeEvent) { 31048 return topLevelType === TOP_KEY_DOWN && nativeEvent.keyCode === START_KEYCODE; 31049} 31050 31051/** 31052 * Does our fallback mode think that this event is the end of composition? 31053 * 31054 * @param {string} topLevelType 31055 * @param {object} nativeEvent 31056 * @return {boolean} 31057 */ 31058function isFallbackCompositionEnd(topLevelType, nativeEvent) { 31059 switch (topLevelType) { 31060 case TOP_KEY_UP: 31061 // Command keys insert or clear IME input. 31062 return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; 31063 case TOP_KEY_DOWN: 31064 // Expect IME keyCode on each keydown. If we get any other 31065 // code we must have exited earlier. 31066 return nativeEvent.keyCode !== START_KEYCODE; 31067 case TOP_KEY_PRESS: 31068 case TOP_MOUSE_DOWN: 31069 case TOP_BLUR: 31070 // Events are not possible without cancelling IME. 31071 return true; 31072 default: 31073 return false; 31074 } 31075} 31076 31077/** 31078 * Google Input Tools provides composition data via a CustomEvent, 31079 * with the `data` property populated in the `detail` object. If this 31080 * is available on the event object, use it. If not, this is a plain 31081 * composition event and we have nothing special to extract. 31082 * 31083 * @param {object} nativeEvent 31084 * @return {?string} 31085 */ 31086function getDataFromCustomEvent(nativeEvent) { 31087 var detail = nativeEvent.detail; 31088 if (typeof detail === 'object' && 'data' in detail) { 31089 return detail.data; 31090 } 31091 return null; 31092} 31093 31094// Track the current IME composition status, if any. 31095var isComposing = false; 31096 31097/** 31098 * @return {?object} A SyntheticCompositionEvent. 31099 */ 31100function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { 31101 var eventType = void 0; 31102 var fallbackData = void 0; 31103 31104 if (canUseCompositionEvent) { 31105 eventType = getCompositionEventType(topLevelType); 31106 } else if (!isComposing) { 31107 if (isFallbackCompositionStart(topLevelType, nativeEvent)) { 31108 eventType = eventTypes.compositionStart; 31109 } 31110 } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) { 31111 eventType = eventTypes.compositionEnd; 31112 } 31113 31114 if (!eventType) { 31115 return null; 31116 } 31117 31118 if (useFallbackCompositionData) { 31119 // The current composition is stored statically and must not be 31120 // overwritten while composition continues. 31121 if (!isComposing && eventType === eventTypes.compositionStart) { 31122 isComposing = initialize(nativeEventTarget); 31123 } else if (eventType === eventTypes.compositionEnd) { 31124 if (isComposing) { 31125 fallbackData = getData(); 31126 } 31127 } 31128 } 31129 31130 var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget); 31131 31132 if (fallbackData) { 31133 // Inject data generated from fallback path into the synthetic event. 31134 // This matches the property of native CompositionEventInterface. 31135 event.data = fallbackData; 31136 } else { 31137 var customData = getDataFromCustomEvent(nativeEvent); 31138 if (customData !== null) { 31139 event.data = customData; 31140 } 31141 } 31142 31143 accumulateTwoPhaseDispatches(event); 31144 return event; 31145} 31146 31147/** 31148 * @param {TopLevelType} topLevelType Number from `TopLevelType`. 31149 * @param {object} nativeEvent Native browser event. 31150 * @return {?string} The string corresponding to this `beforeInput` event. 31151 */ 31152function getNativeBeforeInputChars(topLevelType, nativeEvent) { 31153 switch (topLevelType) { 31154 case TOP_COMPOSITION_END: 31155 return getDataFromCustomEvent(nativeEvent); 31156 case TOP_KEY_PRESS: 31157 /** 31158 * If native `textInput` events are available, our goal is to make 31159 * use of them. However, there is a special case: the spacebar key. 31160 * In Webkit, preventing default on a spacebar `textInput` event 31161 * cancels character insertion, but it *also* causes the browser 31162 * to fall back to its default spacebar behavior of scrolling the 31163 * page. 31164 * 31165 * Tracking at: 31166 * https://code.google.com/p/chromium/issues/detail?id=355103 31167 * 31168 * To avoid this issue, use the keypress event as if no `textInput` 31169 * event is available. 31170 */ 31171 var which = nativeEvent.which; 31172 if (which !== SPACEBAR_CODE) { 31173 return null; 31174 } 31175 31176 hasSpaceKeypress = true; 31177 return SPACEBAR_CHAR; 31178 31179 case TOP_TEXT_INPUT: 31180 // Record the characters to be added to the DOM. 31181 var chars = nativeEvent.data; 31182 31183 // If it's a spacebar character, assume that we have already handled 31184 // it at the keypress level and bail immediately. Android Chrome 31185 // doesn't give us keycodes, so we need to blacklist it. 31186 if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { 31187 return null; 31188 } 31189 31190 return chars; 31191 31192 default: 31193 // For other native event types, do nothing. 31194 return null; 31195 } 31196} 31197 31198/** 31199 * For browsers that do not provide the `textInput` event, extract the 31200 * appropriate string to use for SyntheticInputEvent. 31201 * 31202 * @param {number} topLevelType Number from `TopLevelEventTypes`. 31203 * @param {object} nativeEvent Native browser event. 31204 * @return {?string} The fallback string for this `beforeInput` event. 31205 */ 31206function getFallbackBeforeInputChars(topLevelType, nativeEvent) { 31207 // If we are currently composing (IME) and using a fallback to do so, 31208 // try to extract the composed characters from the fallback object. 31209 // If composition event is available, we extract a string only at 31210 // compositionevent, otherwise extract it at fallback events. 31211 if (isComposing) { 31212 if (topLevelType === TOP_COMPOSITION_END || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) { 31213 var chars = getData(); 31214 reset(); 31215 isComposing = false; 31216 return chars; 31217 } 31218 return null; 31219 } 31220 31221 switch (topLevelType) { 31222 case TOP_PASTE: 31223 // If a paste event occurs after a keypress, throw out the input 31224 // chars. Paste events should not lead to BeforeInput events. 31225 return null; 31226 case TOP_KEY_PRESS: 31227 /** 31228 * As of v27, Firefox may fire keypress events even when no character 31229 * will be inserted. A few possibilities: 31230 * 31231 * - `which` is `0`. Arrow keys, Esc key, etc. 31232 * 31233 * - `which` is the pressed key code, but no char is available. 31234 * Ex: 'AltGr + d` in Polish. There is no modified character for 31235 * this key combination and no character is inserted into the 31236 * document, but FF fires the keypress for char code `100` anyway. 31237 * No `input` event will occur. 31238 * 31239 * - `which` is the pressed key code, but a command combination is 31240 * being used. Ex: `Cmd+C`. No character is inserted, and no 31241 * `input` event will occur. 31242 */ 31243 if (!isKeypressCommand(nativeEvent)) { 31244 // IE fires the `keypress` event when a user types an emoji via 31245 // Touch keyboard of Windows. In such a case, the `char` property 31246 // holds an emoji character like `\uD83D\uDE0A`. Because its length 31247 // is 2, the property `which` does not represent an emoji correctly. 31248 // In such a case, we directly return the `char` property instead of 31249 // using `which`. 31250 if (nativeEvent.char && nativeEvent.char.length > 1) { 31251 return nativeEvent.char; 31252 } else if (nativeEvent.which) { 31253 return String.fromCharCode(nativeEvent.which); 31254 } 31255 } 31256 return null; 31257 case TOP_COMPOSITION_END: 31258 return useFallbackCompositionData ? null : nativeEvent.data; 31259 default: 31260 return null; 31261 } 31262} 31263 31264/** 31265 * Extract a SyntheticInputEvent for `beforeInput`, based on either native 31266 * `textInput` or fallback behavior. 31267 * 31268 * @return {?object} A SyntheticInputEvent. 31269 */ 31270function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { 31271 var chars = void 0; 31272 31273 if (canUseTextInputEvent) { 31274 chars = getNativeBeforeInputChars(topLevelType, nativeEvent); 31275 } else { 31276 chars = getFallbackBeforeInputChars(topLevelType, nativeEvent); 31277 } 31278 31279 // If no characters are being inserted, no BeforeInput event should 31280 // be fired. 31281 if (!chars) { 31282 return null; 31283 } 31284 31285 var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget); 31286 31287 event.data = chars; 31288 accumulateTwoPhaseDispatches(event); 31289 return event; 31290} 31291 31292/** 31293 * Create an `onBeforeInput` event to match 31294 * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents. 31295 * 31296 * This event plugin is based on the native `textInput` event 31297 * available in Chrome, Safari, Opera, and IE. This event fires after 31298 * `onKeyPress` and `onCompositionEnd`, but before `onInput`. 31299 * 31300 * `beforeInput` is spec'd but not implemented in any browsers, and 31301 * the `input` event does not provide any useful information about what has 31302 * actually been added, contrary to the spec. Thus, `textInput` is the best 31303 * available event to identify the characters that have actually been inserted 31304 * into the target node. 31305 * 31306 * This plugin is also responsible for emitting `composition` events, thus 31307 * allowing us to share composition fallback code for both `beforeInput` and 31308 * `composition` event types. 31309 */ 31310var BeforeInputEventPlugin = { 31311 eventTypes: eventTypes, 31312 31313 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { 31314 var composition = extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget); 31315 31316 var beforeInput = extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget); 31317 31318 if (composition === null) { 31319 return beforeInput; 31320 } 31321 31322 if (beforeInput === null) { 31323 return composition; 31324 } 31325 31326 return [composition, beforeInput]; 31327 } 31328}; 31329 31330// Use to restore controlled state after a change event has fired. 31331 31332var fiberHostComponent = null; 31333 31334var ReactControlledComponentInjection = { 31335 injectFiberControlledHostComponent: function (hostComponentImpl) { 31336 // The fiber implementation doesn't use dynamic dispatch so we need to 31337 // inject the implementation. 31338 fiberHostComponent = hostComponentImpl; 31339 } 31340}; 31341 31342var restoreTarget = null; 31343var restoreQueue = null; 31344 31345function restoreStateOfTarget(target) { 31346 // We perform this translation at the end of the event loop so that we 31347 // always receive the correct fiber here 31348 var internalInstance = getInstanceFromNode(target); 31349 if (!internalInstance) { 31350 // Unmounted 31351 return; 31352 } 31353 !(fiberHostComponent && typeof fiberHostComponent.restoreControlledState === 'function') ? invariant(false, 'Fiber needs to be injected to handle a fiber target for controlled events. This error is likely caused by a bug in React. Please file an issue.') : void 0; 31354 var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); 31355 fiberHostComponent.restoreControlledState(internalInstance.stateNode, internalInstance.type, props); 31356} 31357 31358var injection$2 = ReactControlledComponentInjection; 31359 31360function enqueueStateRestore(target) { 31361 if (restoreTarget) { 31362 if (restoreQueue) { 31363 restoreQueue.push(target); 31364 } else { 31365 restoreQueue = [target]; 31366 } 31367 } else { 31368 restoreTarget = target; 31369 } 31370} 31371 31372function needsStateRestore() { 31373 return restoreTarget !== null || restoreQueue !== null; 31374} 31375 31376function restoreStateIfNeeded() { 31377 if (!restoreTarget) { 31378 return; 31379 } 31380 var target = restoreTarget; 31381 var queuedTargets = restoreQueue; 31382 restoreTarget = null; 31383 restoreQueue = null; 31384 31385 restoreStateOfTarget(target); 31386 if (queuedTargets) { 31387 for (var i = 0; i < queuedTargets.length; i++) { 31388 restoreStateOfTarget(queuedTargets[i]); 31389 } 31390 } 31391} 31392 31393var ReactControlledComponent = Object.freeze({ 31394 injection: injection$2, 31395 enqueueStateRestore: enqueueStateRestore, 31396 needsStateRestore: needsStateRestore, 31397 restoreStateIfNeeded: restoreStateIfNeeded 31398}); 31399 31400// Used as a way to call batchedUpdates when we don't have a reference to 31401// the renderer. Such as when we're dispatching events or if third party 31402// libraries need to call batchedUpdates. Eventually, this API will go away when 31403// everything is batched by default. We'll then have a similar API to opt-out of 31404// scheduled work and instead do synchronous work. 31405 31406// Defaults 31407var _batchedUpdates = function (fn, bookkeeping) { 31408 return fn(bookkeeping); 31409}; 31410var _interactiveUpdates = function (fn, a, b) { 31411 return fn(a, b); 31412}; 31413var _flushInteractiveUpdates = function () {}; 31414 31415var isBatching = false; 31416function batchedUpdates(fn, bookkeeping) { 31417 if (isBatching) { 31418 // If we are currently inside another batch, we need to wait until it 31419 // fully completes before restoring state. 31420 return fn(bookkeeping); 31421 } 31422 isBatching = true; 31423 try { 31424 return _batchedUpdates(fn, bookkeeping); 31425 } finally { 31426 // Here we wait until all updates have propagated, which is important 31427 // when using controlled components within layers: 31428 // https://github.com/facebook/react/issues/1698 31429 // Then we restore state of any controlled component. 31430 isBatching = false; 31431 var controlledComponentsHavePendingUpdates = needsStateRestore(); 31432 if (controlledComponentsHavePendingUpdates) { 31433 // If a controlled event was fired, we may need to restore the state of 31434 // the DOM node back to the controlled value. This is necessary when React 31435 // bails out of the update without touching the DOM. 31436 _flushInteractiveUpdates(); 31437 restoreStateIfNeeded(); 31438 } 31439 } 31440} 31441 31442function interactiveUpdates(fn, a, b) { 31443 return _interactiveUpdates(fn, a, b); 31444} 31445 31446 31447 31448var injection$3 = { 31449 injectRenderer: function (renderer) { 31450 _batchedUpdates = renderer.batchedUpdates; 31451 _interactiveUpdates = renderer.interactiveUpdates; 31452 _flushInteractiveUpdates = renderer.flushInteractiveUpdates; 31453 } 31454}; 31455 31456/** 31457 * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary 31458 */ 31459var supportedInputTypes = { 31460 color: true, 31461 date: true, 31462 datetime: true, 31463 'datetime-local': true, 31464 email: true, 31465 month: true, 31466 number: true, 31467 password: true, 31468 range: true, 31469 search: true, 31470 tel: true, 31471 text: true, 31472 time: true, 31473 url: true, 31474 week: true 31475}; 31476 31477function isTextInputElement(elem) { 31478 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); 31479 31480 if (nodeName === 'input') { 31481 return !!supportedInputTypes[elem.type]; 31482 } 31483 31484 if (nodeName === 'textarea') { 31485 return true; 31486 } 31487 31488 return false; 31489} 31490 31491/** 31492 * HTML nodeType values that represent the type of the node 31493 */ 31494 31495var ELEMENT_NODE = 1; 31496var TEXT_NODE = 3; 31497var COMMENT_NODE = 8; 31498var DOCUMENT_NODE = 9; 31499var DOCUMENT_FRAGMENT_NODE = 11; 31500 31501/** 31502 * Gets the target node from a native browser event by accounting for 31503 * inconsistencies in browser DOM APIs. 31504 * 31505 * @param {object} nativeEvent Native browser event. 31506 * @return {DOMEventTarget} Target node. 31507 */ 31508function getEventTarget(nativeEvent) { 31509 // Fallback to nativeEvent.srcElement for IE9 31510 // https://github.com/facebook/react/issues/12506 31511 var target = nativeEvent.target || nativeEvent.srcElement || window; 31512 31513 // Normalize SVG <use> element events #4963 31514 if (target.correspondingUseElement) { 31515 target = target.correspondingUseElement; 31516 } 31517 31518 // Safari may fire events on text nodes (Node.TEXT_NODE is 3). 31519 // @see http://www.quirksmode.org/js/events_properties.html 31520 return target.nodeType === TEXT_NODE ? target.parentNode : target; 31521} 31522 31523/** 31524 * Checks if an event is supported in the current execution environment. 31525 * 31526 * NOTE: This will not work correctly for non-generic events such as `change`, 31527 * `reset`, `load`, `error`, and `select`. 31528 * 31529 * Borrows from Modernizr. 31530 * 31531 * @param {string} eventNameSuffix Event name, e.g. "click". 31532 * @param {?boolean} capture Check if the capture phase is supported. 31533 * @return {boolean} True if the event is supported. 31534 * @internal 31535 * @license Modernizr 3.0.0pre (Custom Build) | MIT 31536 */ 31537function isEventSupported(eventNameSuffix, capture) { 31538 if (!ExecutionEnvironment.canUseDOM || capture && !('addEventListener' in document)) { 31539 return false; 31540 } 31541 31542 var eventName = 'on' + eventNameSuffix; 31543 var isSupported = eventName in document; 31544 31545 if (!isSupported) { 31546 var element = document.createElement('div'); 31547 element.setAttribute(eventName, 'return;'); 31548 isSupported = typeof element[eventName] === 'function'; 31549 } 31550 31551 return isSupported; 31552} 31553 31554function isCheckable(elem) { 31555 var type = elem.type; 31556 var nodeName = elem.nodeName; 31557 return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); 31558} 31559 31560function getTracker(node) { 31561 return node._valueTracker; 31562} 31563 31564function detachTracker(node) { 31565 node._valueTracker = null; 31566} 31567 31568function getValueFromNode(node) { 31569 var value = ''; 31570 if (!node) { 31571 return value; 31572 } 31573 31574 if (isCheckable(node)) { 31575 value = node.checked ? 'true' : 'false'; 31576 } else { 31577 value = node.value; 31578 } 31579 31580 return value; 31581} 31582 31583function trackValueOnNode(node) { 31584 var valueField = isCheckable(node) ? 'checked' : 'value'; 31585 var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); 31586 31587 var currentValue = '' + node[valueField]; 31588 31589 // if someone has already defined a value or Safari, then bail 31590 // and don't track value will cause over reporting of changes, 31591 // but it's better then a hard failure 31592 // (needed for certain tests that spyOn input values and Safari) 31593 if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { 31594 return; 31595 } 31596 var get = descriptor.get, 31597 set = descriptor.set; 31598 31599 Object.defineProperty(node, valueField, { 31600 configurable: true, 31601 get: function () { 31602 return get.call(this); 31603 }, 31604 set: function (value) { 31605 currentValue = '' + value; 31606 set.call(this, value); 31607 } 31608 }); 31609 // We could've passed this the first time 31610 // but it triggers a bug in IE11 and Edge 14/15. 31611 // Calling defineProperty() again should be equivalent. 31612 // https://github.com/facebook/react/issues/11768 31613 Object.defineProperty(node, valueField, { 31614 enumerable: descriptor.enumerable 31615 }); 31616 31617 var tracker = { 31618 getValue: function () { 31619 return currentValue; 31620 }, 31621 setValue: function (value) { 31622 currentValue = '' + value; 31623 }, 31624 stopTracking: function () { 31625 detachTracker(node); 31626 delete node[valueField]; 31627 } 31628 }; 31629 return tracker; 31630} 31631 31632function track(node) { 31633 if (getTracker(node)) { 31634 return; 31635 } 31636 31637 // TODO: Once it's just Fiber we can move this to node._wrapperState 31638 node._valueTracker = trackValueOnNode(node); 31639} 31640 31641function updateValueIfChanged(node) { 31642 if (!node) { 31643 return false; 31644 } 31645 31646 var tracker = getTracker(node); 31647 // if there is no tracker at this point it's unlikely 31648 // that trying again will succeed 31649 if (!tracker) { 31650 return true; 31651 } 31652 31653 var lastValue = tracker.getValue(); 31654 var nextValue = getValueFromNode(node); 31655 if (nextValue !== lastValue) { 31656 tracker.setValue(nextValue); 31657 return true; 31658 } 31659 return false; 31660} 31661 31662var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; 31663 31664var ReactCurrentOwner = ReactInternals.ReactCurrentOwner; 31665var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame; 31666 31667var describeComponentFrame = function (name, source, ownerName) { 31668 return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : ''); 31669}; 31670 31671// The Symbol used to tag the ReactElement-like types. If there is no native Symbol 31672// nor polyfill, then a plain number is used for performance. 31673var hasSymbol = typeof Symbol === 'function' && Symbol.for; 31674 31675var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; 31676var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; 31677var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; 31678var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; 31679var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; 31680var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; 31681var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; 31682var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; 31683var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; 31684var REACT_TIMEOUT_TYPE = hasSymbol ? Symbol.for('react.timeout') : 0xead1; 31685 31686var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 31687var FAUX_ITERATOR_SYMBOL = '@@iterator'; 31688 31689function getIteratorFn(maybeIterable) { 31690 if (maybeIterable === null || typeof maybeIterable === 'undefined') { 31691 return null; 31692 } 31693 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 31694 if (typeof maybeIterator === 'function') { 31695 return maybeIterator; 31696 } 31697 return null; 31698} 31699 31700function getComponentName(fiber) { 31701 var type = fiber.type; 31702 31703 if (typeof type === 'function') { 31704 return type.displayName || type.name; 31705 } 31706 if (typeof type === 'string') { 31707 return type; 31708 } 31709 switch (type) { 31710 case REACT_ASYNC_MODE_TYPE: 31711 return 'AsyncMode'; 31712 case REACT_CONTEXT_TYPE: 31713 return 'Context.Consumer'; 31714 case REACT_FRAGMENT_TYPE: 31715 return 'ReactFragment'; 31716 case REACT_PORTAL_TYPE: 31717 return 'ReactPortal'; 31718 case REACT_PROFILER_TYPE: 31719 return 'Profiler(' + fiber.pendingProps.id + ')'; 31720 case REACT_PROVIDER_TYPE: 31721 return 'Context.Provider'; 31722 case REACT_STRICT_MODE_TYPE: 31723 return 'StrictMode'; 31724 case REACT_TIMEOUT_TYPE: 31725 return 'Timeout'; 31726 } 31727 if (typeof type === 'object' && type !== null) { 31728 switch (type.$$typeof) { 31729 case REACT_FORWARD_REF_TYPE: 31730 var functionName = type.render.displayName || type.render.name || ''; 31731 return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef'; 31732 } 31733 } 31734 return null; 31735} 31736 31737function describeFiber(fiber) { 31738 switch (fiber.tag) { 31739 case IndeterminateComponent: 31740 case FunctionalComponent: 31741 case ClassComponent: 31742 case HostComponent: 31743 var owner = fiber._debugOwner; 31744 var source = fiber._debugSource; 31745 var name = getComponentName(fiber); 31746 var ownerName = null; 31747 if (owner) { 31748 ownerName = getComponentName(owner); 31749 } 31750 return describeComponentFrame(name, source, ownerName); 31751 default: 31752 return ''; 31753 } 31754} 31755 31756// This function can only be called with a work-in-progress fiber and 31757// only during begin or complete phase. Do not call it under any other 31758// circumstances. 31759function getStackAddendumByWorkInProgressFiber(workInProgress) { 31760 var info = ''; 31761 var node = workInProgress; 31762 do { 31763 info += describeFiber(node); 31764 // Otherwise this return pointer might point to the wrong tree: 31765 node = node.return; 31766 } while (node); 31767 return info; 31768} 31769 31770function getCurrentFiberOwnerName$1() { 31771 { 31772 var fiber = ReactDebugCurrentFiber.current; 31773 if (fiber === null) { 31774 return null; 31775 } 31776 var owner = fiber._debugOwner; 31777 if (owner !== null && typeof owner !== 'undefined') { 31778 return getComponentName(owner); 31779 } 31780 } 31781 return null; 31782} 31783 31784function getCurrentFiberStackAddendum$1() { 31785 { 31786 var fiber = ReactDebugCurrentFiber.current; 31787 if (fiber === null) { 31788 return null; 31789 } 31790 // Safe because if current fiber exists, we are reconciling, 31791 // and it is guaranteed to be the work-in-progress version. 31792 return getStackAddendumByWorkInProgressFiber(fiber); 31793 } 31794 return null; 31795} 31796 31797function resetCurrentFiber() { 31798 ReactDebugCurrentFrame.getCurrentStack = null; 31799 ReactDebugCurrentFiber.current = null; 31800 ReactDebugCurrentFiber.phase = null; 31801} 31802 31803function setCurrentFiber(fiber) { 31804 ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackAddendum$1; 31805 ReactDebugCurrentFiber.current = fiber; 31806 ReactDebugCurrentFiber.phase = null; 31807} 31808 31809function setCurrentPhase(phase) { 31810 ReactDebugCurrentFiber.phase = phase; 31811} 31812 31813var ReactDebugCurrentFiber = { 31814 current: null, 31815 phase: null, 31816 resetCurrentFiber: resetCurrentFiber, 31817 setCurrentFiber: setCurrentFiber, 31818 setCurrentPhase: setCurrentPhase, 31819 getCurrentFiberOwnerName: getCurrentFiberOwnerName$1, 31820 getCurrentFiberStackAddendum: getCurrentFiberStackAddendum$1 31821}; 31822 31823// A reserved attribute. 31824// It is handled by React separately and shouldn't be written to the DOM. 31825var RESERVED = 0; 31826 31827// A simple string attribute. 31828// Attributes that aren't in the whitelist are presumed to have this type. 31829var STRING = 1; 31830 31831// A string attribute that accepts booleans in React. In HTML, these are called 31832// "enumerated" attributes with "true" and "false" as possible values. 31833// When true, it should be set to a "true" string. 31834// When false, it should be set to a "false" string. 31835var BOOLEANISH_STRING = 2; 31836 31837// A real boolean attribute. 31838// When true, it should be present (set either to an empty string or its name). 31839// When false, it should be omitted. 31840var BOOLEAN = 3; 31841 31842// An attribute that can be used as a flag as well as with a value. 31843// When true, it should be present (set either to an empty string or its name). 31844// When false, it should be omitted. 31845// For any other value, should be present with that value. 31846var OVERLOADED_BOOLEAN = 4; 31847 31848// An attribute that must be numeric or parse as a numeric. 31849// When falsy, it should be removed. 31850var NUMERIC = 5; 31851 31852// An attribute that must be positive numeric or parse as a positive numeric. 31853// When falsy, it should be removed. 31854var POSITIVE_NUMERIC = 6; 31855 31856/* eslint-disable max-len */ 31857var ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD'; 31858/* eslint-enable max-len */ 31859var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040'; 31860 31861 31862var ROOT_ATTRIBUTE_NAME = 'data-reactroot'; 31863var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$'); 31864 31865var illegalAttributeNameCache = {}; 31866var validatedAttributeNameCache = {}; 31867 31868function isAttributeNameSafe(attributeName) { 31869 if (validatedAttributeNameCache.hasOwnProperty(attributeName)) { 31870 return true; 31871 } 31872 if (illegalAttributeNameCache.hasOwnProperty(attributeName)) { 31873 return false; 31874 } 31875 if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { 31876 validatedAttributeNameCache[attributeName] = true; 31877 return true; 31878 } 31879 illegalAttributeNameCache[attributeName] = true; 31880 { 31881 warning(false, 'Invalid attribute name: `%s`', attributeName); 31882 } 31883 return false; 31884} 31885 31886function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) { 31887 if (propertyInfo !== null) { 31888 return propertyInfo.type === RESERVED; 31889 } 31890 if (isCustomComponentTag) { 31891 return false; 31892 } 31893 if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) { 31894 return true; 31895 } 31896 return false; 31897} 31898 31899function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) { 31900 if (propertyInfo !== null && propertyInfo.type === RESERVED) { 31901 return false; 31902 } 31903 switch (typeof value) { 31904 case 'function': 31905 // $FlowIssue symbol is perfectly valid here 31906 case 'symbol': 31907 // eslint-disable-line 31908 return true; 31909 case 'boolean': 31910 { 31911 if (isCustomComponentTag) { 31912 return false; 31913 } 31914 if (propertyInfo !== null) { 31915 return !propertyInfo.acceptsBooleans; 31916 } else { 31917 var prefix = name.toLowerCase().slice(0, 5); 31918 return prefix !== 'data-' && prefix !== 'aria-'; 31919 } 31920 } 31921 default: 31922 return false; 31923 } 31924} 31925 31926function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) { 31927 if (value === null || typeof value === 'undefined') { 31928 return true; 31929 } 31930 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) { 31931 return true; 31932 } 31933 if (isCustomComponentTag) { 31934 return false; 31935 } 31936 if (propertyInfo !== null) { 31937 switch (propertyInfo.type) { 31938 case BOOLEAN: 31939 return !value; 31940 case OVERLOADED_BOOLEAN: 31941 return value === false; 31942 case NUMERIC: 31943 return isNaN(value); 31944 case POSITIVE_NUMERIC: 31945 return isNaN(value) || value < 1; 31946 } 31947 } 31948 return false; 31949} 31950 31951function getPropertyInfo(name) { 31952 return properties.hasOwnProperty(name) ? properties[name] : null; 31953} 31954 31955function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace) { 31956 this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN; 31957 this.attributeName = attributeName; 31958 this.attributeNamespace = attributeNamespace; 31959 this.mustUseProperty = mustUseProperty; 31960 this.propertyName = name; 31961 this.type = type; 31962} 31963 31964// When adding attributes to this list, be sure to also add them to 31965// the `possibleStandardNames` module to ensure casing and incorrect 31966// name warnings. 31967var properties = {}; 31968 31969// These props are reserved by React. They shouldn't be written to the DOM. 31970['children', 'dangerouslySetInnerHTML', 31971// TODO: This prevents the assignment of defaultValue to regular 31972// elements (not just inputs). Now that ReactDOMInput assigns to the 31973// defaultValue property -- do we need this? 31974'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'].forEach(function (name) { 31975 properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty 31976 name, // attributeName 31977 null); 31978} // attributeNamespace 31979); 31980 31981// A few React string attributes have a different name. 31982// This is a mapping from React prop names to the attribute names. 31983[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) { 31984 var name = _ref[0], 31985 attributeName = _ref[1]; 31986 31987 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 31988 attributeName, // attributeName 31989 null); 31990} // attributeNamespace 31991); 31992 31993// These are "enumerated" HTML attributes that accept "true" and "false". 31994// In React, we let users pass `true` and `false` even though technically 31995// these aren't boolean attributes (they are coerced to strings). 31996['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) { 31997 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty 31998 name.toLowerCase(), // attributeName 31999 null); 32000} // attributeNamespace 32001); 32002 32003// These are "enumerated" SVG attributes that accept "true" and "false". 32004// In React, we let users pass `true` and `false` even though technically 32005// these aren't boolean attributes (they are coerced to strings). 32006// Since these are SVG attributes, their attribute names are case-sensitive. 32007['autoReverse', 'externalResourcesRequired', 'preserveAlpha'].forEach(function (name) { 32008 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty 32009 name, // attributeName 32010 null); 32011} // attributeNamespace 32012); 32013 32014// These are HTML boolean attributes. 32015['allowFullScreen', 'async', 32016// Note: there is a special case that prevents it from being written to the DOM 32017// on the client side because the browsers are inconsistent. Instead we call focus(). 32018'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', 32019// Microdata 32020'itemScope'].forEach(function (name) { 32021 properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty 32022 name.toLowerCase(), // attributeName 32023 null); 32024} // attributeNamespace 32025); 32026 32027// These are the few React props that we set as DOM properties 32028// rather than attributes. These are all booleans. 32029['checked', 32030// Note: `option.selected` is not updated if `select.multiple` is 32031// disabled with `removeAttribute`. We have special logic for handling this. 32032'multiple', 'muted', 'selected'].forEach(function (name) { 32033 properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty 32034 name.toLowerCase(), // attributeName 32035 null); 32036} // attributeNamespace 32037); 32038 32039// These are HTML attributes that are "overloaded booleans": they behave like 32040// booleans, but can also accept a string value. 32041['capture', 'download'].forEach(function (name) { 32042 properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty 32043 name.toLowerCase(), // attributeName 32044 null); 32045} // attributeNamespace 32046); 32047 32048// These are HTML attributes that must be positive numbers. 32049['cols', 'rows', 'size', 'span'].forEach(function (name) { 32050 properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty 32051 name.toLowerCase(), // attributeName 32052 null); 32053} // attributeNamespace 32054); 32055 32056// These are HTML attributes that must be numbers. 32057['rowSpan', 'start'].forEach(function (name) { 32058 properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty 32059 name.toLowerCase(), // attributeName 32060 null); 32061} // attributeNamespace 32062); 32063 32064var CAMELIZE = /[\-\:]([a-z])/g; 32065var capitalize = function (token) { 32066 return token[1].toUpperCase(); 32067}; 32068 32069// This is a list of all SVG attributes that need special casing, namespacing, 32070// or boolean value assignment. Regular attributes that just accept strings 32071// and have the same names are omitted, just like in the HTML whitelist. 32072// Some of these attributes can be hard to find. This list was created by 32073// scrapping the MDN documentation. 32074['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height'].forEach(function (attributeName) { 32075 var name = attributeName.replace(CAMELIZE, capitalize); 32076 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 32077 attributeName, null); 32078} // attributeNamespace 32079); 32080 32081// String SVG attributes with the xlink namespace. 32082['xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) { 32083 var name = attributeName.replace(CAMELIZE, capitalize); 32084 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 32085 attributeName, 'http://www.w3.org/1999/xlink'); 32086}); 32087 32088// String SVG attributes with the xml namespace. 32089['xml:base', 'xml:lang', 'xml:space'].forEach(function (attributeName) { 32090 var name = attributeName.replace(CAMELIZE, capitalize); 32091 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 32092 attributeName, 'http://www.w3.org/XML/1998/namespace'); 32093}); 32094 32095// Special case: this attribute exists both in HTML and SVG. 32096// Its "tabindex" attribute name is case-sensitive in SVG so we can't just use 32097// its React `tabIndex` name, like we do for attributes that exist only in HTML. 32098properties.tabIndex = new PropertyInfoRecord('tabIndex', STRING, false, // mustUseProperty 32099'tabindex', // attributeName 32100null); 32101 32102/** 32103 * Get the value for a property on a node. Only used in DEV for SSR validation. 32104 * The "expected" argument is used as a hint of what the expected value is. 32105 * Some properties have multiple equivalent values. 32106 */ 32107function getValueForProperty(node, name, expected, propertyInfo) { 32108 { 32109 if (propertyInfo.mustUseProperty) { 32110 var propertyName = propertyInfo.propertyName; 32111 32112 return node[propertyName]; 32113 } else { 32114 var attributeName = propertyInfo.attributeName; 32115 32116 var stringValue = null; 32117 32118 if (propertyInfo.type === OVERLOADED_BOOLEAN) { 32119 if (node.hasAttribute(attributeName)) { 32120 var value = node.getAttribute(attributeName); 32121 if (value === '') { 32122 return true; 32123 } 32124 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 32125 return value; 32126 } 32127 if (value === '' + expected) { 32128 return expected; 32129 } 32130 return value; 32131 } 32132 } else if (node.hasAttribute(attributeName)) { 32133 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 32134 // We had an attribute but shouldn't have had one, so read it 32135 // for the error message. 32136 return node.getAttribute(attributeName); 32137 } 32138 if (propertyInfo.type === BOOLEAN) { 32139 // If this was a boolean, it doesn't matter what the value is 32140 // the fact that we have it is the same as the expected. 32141 return expected; 32142 } 32143 // Even if this property uses a namespace we use getAttribute 32144 // because we assume its namespaced name is the same as our config. 32145 // To use getAttributeNS we need the local name which we don't have 32146 // in our config atm. 32147 stringValue = node.getAttribute(attributeName); 32148 } 32149 32150 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 32151 return stringValue === null ? expected : stringValue; 32152 } else if (stringValue === '' + expected) { 32153 return expected; 32154 } else { 32155 return stringValue; 32156 } 32157 } 32158 } 32159} 32160 32161/** 32162 * Get the value for a attribute on a node. Only used in DEV for SSR validation. 32163 * The third argument is used as a hint of what the expected value is. Some 32164 * attributes have multiple equivalent values. 32165 */ 32166function getValueForAttribute(node, name, expected) { 32167 { 32168 if (!isAttributeNameSafe(name)) { 32169 return; 32170 } 32171 if (!node.hasAttribute(name)) { 32172 return expected === undefined ? undefined : null; 32173 } 32174 var value = node.getAttribute(name); 32175 if (value === '' + expected) { 32176 return expected; 32177 } 32178 return value; 32179 } 32180} 32181 32182/** 32183 * Sets the value for a property on a node. 32184 * 32185 * @param {DOMElement} node 32186 * @param {string} name 32187 * @param {*} value 32188 */ 32189function setValueForProperty(node, name, value, isCustomComponentTag) { 32190 var propertyInfo = getPropertyInfo(name); 32191 if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) { 32192 return; 32193 } 32194 if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) { 32195 value = null; 32196 } 32197 // If the prop isn't in the special list, treat it as a simple attribute. 32198 if (isCustomComponentTag || propertyInfo === null) { 32199 if (isAttributeNameSafe(name)) { 32200 var _attributeName = name; 32201 if (value === null) { 32202 node.removeAttribute(_attributeName); 32203 } else { 32204 node.setAttribute(_attributeName, '' + value); 32205 } 32206 } 32207 return; 32208 } 32209 var mustUseProperty = propertyInfo.mustUseProperty; 32210 32211 if (mustUseProperty) { 32212 var propertyName = propertyInfo.propertyName; 32213 32214 if (value === null) { 32215 var type = propertyInfo.type; 32216 32217 node[propertyName] = type === BOOLEAN ? false : ''; 32218 } else { 32219 // Contrary to `setAttribute`, object properties are properly 32220 // `toString`ed by IE8/9. 32221 node[propertyName] = value; 32222 } 32223 return; 32224 } 32225 // The rest are treated as attributes with special cases. 32226 var attributeName = propertyInfo.attributeName, 32227 attributeNamespace = propertyInfo.attributeNamespace; 32228 32229 if (value === null) { 32230 node.removeAttribute(attributeName); 32231 } else { 32232 var _type = propertyInfo.type; 32233 32234 var attributeValue = void 0; 32235 if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) { 32236 attributeValue = ''; 32237 } else { 32238 // `setAttribute` with objects becomes only `[object]` in IE8/9, 32239 // ('' + value) makes it output the correct toString()-value. 32240 attributeValue = '' + value; 32241 } 32242 if (attributeNamespace) { 32243 node.setAttributeNS(attributeNamespace, attributeName, attributeValue); 32244 } else { 32245 node.setAttribute(attributeName, attributeValue); 32246 } 32247 } 32248} 32249 32250var ReactControlledValuePropTypes = { 32251 checkPropTypes: null 32252}; 32253 32254{ 32255 var hasReadOnlyValue = { 32256 button: true, 32257 checkbox: true, 32258 image: true, 32259 hidden: true, 32260 radio: true, 32261 reset: true, 32262 submit: true 32263 }; 32264 32265 var propTypes = { 32266 value: function (props, propName, componentName) { 32267 if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled) { 32268 return null; 32269 } 32270 return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); 32271 }, 32272 checked: function (props, propName, componentName) { 32273 if (!props[propName] || props.onChange || props.readOnly || props.disabled) { 32274 return null; 32275 } 32276 return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); 32277 } 32278 }; 32279 32280 /** 32281 * Provide a linked `value` attribute for controlled forms. You should not use 32282 * this outside of the ReactDOM controlled form components. 32283 */ 32284 ReactControlledValuePropTypes.checkPropTypes = function (tagName, props, getStack) { 32285 checkPropTypes(propTypes, props, 'prop', tagName, getStack); 32286 }; 32287} 32288 32289// TODO: direct imports like some-package/src/* are bad. Fix me. 32290var getCurrentFiberOwnerName = ReactDebugCurrentFiber.getCurrentFiberOwnerName; 32291var getCurrentFiberStackAddendum = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 32292 32293var didWarnValueDefaultValue = false; 32294var didWarnCheckedDefaultChecked = false; 32295var didWarnControlledToUncontrolled = false; 32296var didWarnUncontrolledToControlled = false; 32297 32298function isControlled(props) { 32299 var usesChecked = props.type === 'checkbox' || props.type === 'radio'; 32300 return usesChecked ? props.checked != null : props.value != null; 32301} 32302 32303/** 32304 * Implements an <input> host component that allows setting these optional 32305 * props: `checked`, `value`, `defaultChecked`, and `defaultValue`. 32306 * 32307 * If `checked` or `value` are not supplied (or null/undefined), user actions 32308 * that affect the checked state or value will trigger updates to the element. 32309 * 32310 * If they are supplied (and not null/undefined), the rendered element will not 32311 * trigger updates to the element. Instead, the props must change in order for 32312 * the rendered element to be updated. 32313 * 32314 * The rendered element will be initialized as unchecked (or `defaultChecked`) 32315 * with an empty value (or `defaultValue`). 32316 * 32317 * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html 32318 */ 32319 32320function getHostProps(element, props) { 32321 var node = element; 32322 var checked = props.checked; 32323 32324 var hostProps = _assign({}, props, { 32325 defaultChecked: undefined, 32326 defaultValue: undefined, 32327 value: undefined, 32328 checked: checked != null ? checked : node._wrapperState.initialChecked 32329 }); 32330 32331 return hostProps; 32332} 32333 32334function initWrapperState(element, props) { 32335 { 32336 ReactControlledValuePropTypes.checkPropTypes('input', props, getCurrentFiberStackAddendum); 32337 32338 if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { 32339 warning(false, '%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerName() || 'A component', props.type); 32340 didWarnCheckedDefaultChecked = true; 32341 } 32342 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { 32343 warning(false, '%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerName() || 'A component', props.type); 32344 didWarnValueDefaultValue = true; 32345 } 32346 } 32347 32348 var node = element; 32349 var defaultValue = props.defaultValue == null ? '' : props.defaultValue; 32350 32351 node._wrapperState = { 32352 initialChecked: props.checked != null ? props.checked : props.defaultChecked, 32353 initialValue: getSafeValue(props.value != null ? props.value : defaultValue), 32354 controlled: isControlled(props) 32355 }; 32356} 32357 32358function updateChecked(element, props) { 32359 var node = element; 32360 var checked = props.checked; 32361 if (checked != null) { 32362 setValueForProperty(node, 'checked', checked, false); 32363 } 32364} 32365 32366function updateWrapper(element, props) { 32367 var node = element; 32368 { 32369 var _controlled = isControlled(props); 32370 32371 if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) { 32372 warning(false, 'A component is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components%s', props.type, getCurrentFiberStackAddendum()); 32373 didWarnUncontrolledToControlled = true; 32374 } 32375 if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) { 32376 warning(false, 'A component is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components%s', props.type, getCurrentFiberStackAddendum()); 32377 didWarnControlledToUncontrolled = true; 32378 } 32379 } 32380 32381 updateChecked(element, props); 32382 32383 var value = getSafeValue(props.value); 32384 32385 if (value != null) { 32386 if (props.type === 'number') { 32387 if (value === 0 && node.value === '' || 32388 // eslint-disable-next-line 32389 node.value != value) { 32390 node.value = '' + value; 32391 } 32392 } else if (node.value !== '' + value) { 32393 node.value = '' + value; 32394 } 32395 } 32396 32397 if (props.hasOwnProperty('value')) { 32398 setDefaultValue(node, props.type, value); 32399 } else if (props.hasOwnProperty('defaultValue')) { 32400 setDefaultValue(node, props.type, getSafeValue(props.defaultValue)); 32401 } 32402 32403 if (props.checked == null && props.defaultChecked != null) { 32404 node.defaultChecked = !!props.defaultChecked; 32405 } 32406} 32407 32408function postMountWrapper(element, props, isHydrating) { 32409 var node = element; 32410 32411 if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) { 32412 var _initialValue = '' + node._wrapperState.initialValue; 32413 var currentValue = node.value; 32414 32415 // Do not assign value if it is already set. This prevents user text input 32416 // from being lost during SSR hydration. 32417 if (!isHydrating) { 32418 // Do not re-assign the value property if there is no change. This 32419 // potentially avoids a DOM write and prevents Firefox (~60.0.1) from 32420 // prematurely marking required inputs as invalid 32421 if (_initialValue !== currentValue) { 32422 node.value = _initialValue; 32423 } 32424 } 32425 32426 // value must be assigned before defaultValue. This fixes an issue where the 32427 // visually displayed value of date inputs disappears on mobile Safari and Chrome: 32428 // https://github.com/facebook/react/issues/7233 32429 node.defaultValue = _initialValue; 32430 } 32431 32432 // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug 32433 // this is needed to work around a chrome bug where setting defaultChecked 32434 // will sometimes influence the value of checked (even after detachment). 32435 // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 32436 // We need to temporarily unset name to avoid disrupting radio button groups. 32437 var name = node.name; 32438 if (name !== '') { 32439 node.name = ''; 32440 } 32441 node.defaultChecked = !node.defaultChecked; 32442 node.defaultChecked = !node.defaultChecked; 32443 if (name !== '') { 32444 node.name = name; 32445 } 32446} 32447 32448function restoreControlledState(element, props) { 32449 var node = element; 32450 updateWrapper(node, props); 32451 updateNamedCousins(node, props); 32452} 32453 32454function updateNamedCousins(rootNode, props) { 32455 var name = props.name; 32456 if (props.type === 'radio' && name != null) { 32457 var queryRoot = rootNode; 32458 32459 while (queryRoot.parentNode) { 32460 queryRoot = queryRoot.parentNode; 32461 } 32462 32463 // If `rootNode.form` was non-null, then we could try `form.elements`, 32464 // but that sometimes behaves strangely in IE8. We could also try using 32465 // `form.getElementsByName`, but that will only return direct children 32466 // and won't include inputs that use the HTML5 `form=` attribute. Since 32467 // the input might not even be in a form. It might not even be in the 32468 // document. Let's just use the local `querySelectorAll` to ensure we don't 32469 // miss anything. 32470 var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); 32471 32472 for (var i = 0; i < group.length; i++) { 32473 var otherNode = group[i]; 32474 if (otherNode === rootNode || otherNode.form !== rootNode.form) { 32475 continue; 32476 } 32477 // This will throw if radio buttons rendered by different copies of React 32478 // and the same name are rendered into the same form (same as #1939). 32479 // That's probably okay; we don't support it just as we don't support 32480 // mixing React radio buttons with non-React ones. 32481 var otherProps = getFiberCurrentPropsFromNode$1(otherNode); 32482 !otherProps ? invariant(false, 'ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.') : void 0; 32483 32484 // We need update the tracked value on the named cousin since the value 32485 // was changed but the input saw no event or value set 32486 updateValueIfChanged(otherNode); 32487 32488 // If this is a controlled radio button group, forcing the input that 32489 // was previously checked to update will cause it to be come re-checked 32490 // as appropriate. 32491 updateWrapper(otherNode, otherProps); 32492 } 32493 } 32494} 32495 32496// In Chrome, assigning defaultValue to certain input types triggers input validation. 32497// For number inputs, the display value loses trailing decimal points. For email inputs, 32498// Chrome raises "The specified value <x> is not a valid email address". 32499// 32500// Here we check to see if the defaultValue has actually changed, avoiding these problems 32501// when the user is inputting text 32502// 32503// https://github.com/facebook/react/issues/7253 32504function setDefaultValue(node, type, value) { 32505 if ( 32506 // Focused number inputs synchronize on blur. See ChangeEventPlugin.js 32507 type !== 'number' || node.ownerDocument.activeElement !== node) { 32508 if (value == null) { 32509 node.defaultValue = '' + node._wrapperState.initialValue; 32510 } else if (node.defaultValue !== '' + value) { 32511 node.defaultValue = '' + value; 32512 } 32513 } 32514} 32515 32516function getSafeValue(value) { 32517 switch (typeof value) { 32518 case 'boolean': 32519 case 'number': 32520 case 'object': 32521 case 'string': 32522 case 'undefined': 32523 return value; 32524 default: 32525 // function, symbol are assigned as empty strings 32526 return ''; 32527 } 32528} 32529 32530var eventTypes$1 = { 32531 change: { 32532 phasedRegistrationNames: { 32533 bubbled: 'onChange', 32534 captured: 'onChangeCapture' 32535 }, 32536 dependencies: [TOP_BLUR, TOP_CHANGE, TOP_CLICK, TOP_FOCUS, TOP_INPUT, TOP_KEY_DOWN, TOP_KEY_UP, TOP_SELECTION_CHANGE] 32537 } 32538}; 32539 32540function createAndAccumulateChangeEvent(inst, nativeEvent, target) { 32541 var event = SyntheticEvent$1.getPooled(eventTypes$1.change, inst, nativeEvent, target); 32542 event.type = 'change'; 32543 // Flag this event loop as needing state restore. 32544 enqueueStateRestore(target); 32545 accumulateTwoPhaseDispatches(event); 32546 return event; 32547} 32548/** 32549 * For IE shims 32550 */ 32551var activeElement = null; 32552var activeElementInst = null; 32553 32554/** 32555 * SECTION: handle `change` event 32556 */ 32557function shouldUseChangeEvent(elem) { 32558 var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); 32559 return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; 32560} 32561 32562function manualDispatchChangeEvent(nativeEvent) { 32563 var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent)); 32564 32565 // If change and propertychange bubbled, we'd just bind to it like all the 32566 // other events and have it go through ReactBrowserEventEmitter. Since it 32567 // doesn't, we manually listen for the events and so we have to enqueue and 32568 // process the abstract event manually. 32569 // 32570 // Batching is necessary here in order to ensure that all event handlers run 32571 // before the next rerender (including event handlers attached to ancestor 32572 // elements instead of directly on the input). Without this, controlled 32573 // components don't work properly in conjunction with event bubbling because 32574 // the component is rerendered and the value reverted before all the event 32575 // handlers can run. See https://github.com/facebook/react/issues/708. 32576 batchedUpdates(runEventInBatch, event); 32577} 32578 32579function runEventInBatch(event) { 32580 runEventsInBatch(event, false); 32581} 32582 32583function getInstIfValueChanged(targetInst) { 32584 var targetNode = getNodeFromInstance$1(targetInst); 32585 if (updateValueIfChanged(targetNode)) { 32586 return targetInst; 32587 } 32588} 32589 32590function getTargetInstForChangeEvent(topLevelType, targetInst) { 32591 if (topLevelType === TOP_CHANGE) { 32592 return targetInst; 32593 } 32594} 32595 32596/** 32597 * SECTION: handle `input` event 32598 */ 32599var isInputEventSupported = false; 32600if (ExecutionEnvironment.canUseDOM) { 32601 // IE9 claims to support the input event but fails to trigger it when 32602 // deleting text, so we ignore its input events. 32603 isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9); 32604} 32605 32606/** 32607 * (For IE <=9) Starts tracking propertychange events on the passed-in element 32608 * and override the value property so that we can distinguish user events from 32609 * value changes in JS. 32610 */ 32611function startWatchingForValueChange(target, targetInst) { 32612 activeElement = target; 32613 activeElementInst = targetInst; 32614 activeElement.attachEvent('onpropertychange', handlePropertyChange); 32615} 32616 32617/** 32618 * (For IE <=9) Removes the event listeners from the currently-tracked element, 32619 * if any exists. 32620 */ 32621function stopWatchingForValueChange() { 32622 if (!activeElement) { 32623 return; 32624 } 32625 activeElement.detachEvent('onpropertychange', handlePropertyChange); 32626 activeElement = null; 32627 activeElementInst = null; 32628} 32629 32630/** 32631 * (For IE <=9) Handles a propertychange event, sending a `change` event if 32632 * the value of the active element has changed. 32633 */ 32634function handlePropertyChange(nativeEvent) { 32635 if (nativeEvent.propertyName !== 'value') { 32636 return; 32637 } 32638 if (getInstIfValueChanged(activeElementInst)) { 32639 manualDispatchChangeEvent(nativeEvent); 32640 } 32641} 32642 32643function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) { 32644 if (topLevelType === TOP_FOCUS) { 32645 // In IE9, propertychange fires for most input events but is buggy and 32646 // doesn't fire when text is deleted, but conveniently, selectionchange 32647 // appears to fire in all of the remaining cases so we catch those and 32648 // forward the event if the value has changed 32649 // In either case, we don't want to call the event handler if the value 32650 // is changed from JS so we redefine a setter for `.value` that updates 32651 // our activeElementValue variable, allowing us to ignore those changes 32652 // 32653 // stopWatching() should be a noop here but we call it just in case we 32654 // missed a blur event somehow. 32655 stopWatchingForValueChange(); 32656 startWatchingForValueChange(target, targetInst); 32657 } else if (topLevelType === TOP_BLUR) { 32658 stopWatchingForValueChange(); 32659 } 32660} 32661 32662// For IE8 and IE9. 32663function getTargetInstForInputEventPolyfill(topLevelType, targetInst) { 32664 if (topLevelType === TOP_SELECTION_CHANGE || topLevelType === TOP_KEY_UP || topLevelType === TOP_KEY_DOWN) { 32665 // On the selectionchange event, the target is just document which isn't 32666 // helpful for us so just check activeElement instead. 32667 // 32668 // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire 32669 // propertychange on the first input event after setting `value` from a 32670 // script and fires only keydown, keypress, keyup. Catching keyup usually 32671 // gets it and catching keydown lets us fire an event for the first 32672 // keystroke if user does a key repeat (it'll be a little delayed: right 32673 // before the second keystroke). Other input methods (e.g., paste) seem to 32674 // fire selectionchange normally. 32675 return getInstIfValueChanged(activeElementInst); 32676 } 32677} 32678 32679/** 32680 * SECTION: handle `click` event 32681 */ 32682function shouldUseClickEvent(elem) { 32683 // Use the `click` event to detect changes to checkbox and radio inputs. 32684 // This approach works across all browsers, whereas `change` does not fire 32685 // until `blur` in IE8. 32686 var nodeName = elem.nodeName; 32687 return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); 32688} 32689 32690function getTargetInstForClickEvent(topLevelType, targetInst) { 32691 if (topLevelType === TOP_CLICK) { 32692 return getInstIfValueChanged(targetInst); 32693 } 32694} 32695 32696function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) { 32697 if (topLevelType === TOP_INPUT || topLevelType === TOP_CHANGE) { 32698 return getInstIfValueChanged(targetInst); 32699 } 32700} 32701 32702function handleControlledInputBlur(node) { 32703 var state = node._wrapperState; 32704 32705 if (!state || !state.controlled || node.type !== 'number') { 32706 return; 32707 } 32708 32709 // If controlled, assign the value attribute to the current value on blur 32710 setDefaultValue(node, 'number', node.value); 32711} 32712 32713/** 32714 * This plugin creates an `onChange` event that normalizes change events 32715 * across form elements. This event fires at a time when it's possible to 32716 * change the element's value without seeing a flicker. 32717 * 32718 * Supported elements are: 32719 * - input (see `isTextInputElement`) 32720 * - textarea 32721 * - select 32722 */ 32723var ChangeEventPlugin = { 32724 eventTypes: eventTypes$1, 32725 32726 _isInputEventSupported: isInputEventSupported, 32727 32728 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { 32729 var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window; 32730 32731 var getTargetInstFunc = void 0, 32732 handleEventFunc = void 0; 32733 if (shouldUseChangeEvent(targetNode)) { 32734 getTargetInstFunc = getTargetInstForChangeEvent; 32735 } else if (isTextInputElement(targetNode)) { 32736 if (isInputEventSupported) { 32737 getTargetInstFunc = getTargetInstForInputOrChangeEvent; 32738 } else { 32739 getTargetInstFunc = getTargetInstForInputEventPolyfill; 32740 handleEventFunc = handleEventsForInputEventPolyfill; 32741 } 32742 } else if (shouldUseClickEvent(targetNode)) { 32743 getTargetInstFunc = getTargetInstForClickEvent; 32744 } 32745 32746 if (getTargetInstFunc) { 32747 var inst = getTargetInstFunc(topLevelType, targetInst); 32748 if (inst) { 32749 var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget); 32750 return event; 32751 } 32752 } 32753 32754 if (handleEventFunc) { 32755 handleEventFunc(topLevelType, targetNode, targetInst); 32756 } 32757 32758 // When blurring, set the value attribute for number inputs 32759 if (topLevelType === TOP_BLUR) { 32760 handleControlledInputBlur(targetNode); 32761 } 32762 } 32763}; 32764 32765/** 32766 * Module that is injectable into `EventPluginHub`, that specifies a 32767 * deterministic ordering of `EventPlugin`s. A convenient way to reason about 32768 * plugins, without having to package every one of them. This is better than 32769 * having plugins be ordered in the same order that they are injected because 32770 * that ordering would be influenced by the packaging order. 32771 * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that 32772 * preventing default on events is convenient in `SimpleEventPlugin` handlers. 32773 */ 32774var DOMEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'TapEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin']; 32775 32776var SyntheticUIEvent = SyntheticEvent$1.extend({ 32777 view: null, 32778 detail: null 32779}); 32780 32781/** 32782 * Translation from modifier key to the associated property in the event. 32783 * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers 32784 */ 32785 32786var modifierKeyToProp = { 32787 Alt: 'altKey', 32788 Control: 'ctrlKey', 32789 Meta: 'metaKey', 32790 Shift: 'shiftKey' 32791}; 32792 32793// IE8 does not implement getModifierState so we simply map it to the only 32794// modifier keys exposed by the event itself, does not support Lock-keys. 32795// Currently, all major browsers except Chrome seems to support Lock-keys. 32796function modifierStateGetter(keyArg) { 32797 var syntheticEvent = this; 32798 var nativeEvent = syntheticEvent.nativeEvent; 32799 if (nativeEvent.getModifierState) { 32800 return nativeEvent.getModifierState(keyArg); 32801 } 32802 var keyProp = modifierKeyToProp[keyArg]; 32803 return keyProp ? !!nativeEvent[keyProp] : false; 32804} 32805 32806function getEventModifierState(nativeEvent) { 32807 return modifierStateGetter; 32808} 32809 32810/** 32811 * @interface MouseEvent 32812 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 32813 */ 32814var SyntheticMouseEvent = SyntheticUIEvent.extend({ 32815 screenX: null, 32816 screenY: null, 32817 clientX: null, 32818 clientY: null, 32819 pageX: null, 32820 pageY: null, 32821 ctrlKey: null, 32822 shiftKey: null, 32823 altKey: null, 32824 metaKey: null, 32825 getModifierState: getEventModifierState, 32826 button: null, 32827 buttons: null, 32828 relatedTarget: function (event) { 32829 return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement); 32830 } 32831}); 32832 32833/** 32834 * @interface PointerEvent 32835 * @see http://www.w3.org/TR/pointerevents/ 32836 */ 32837var SyntheticPointerEvent = SyntheticMouseEvent.extend({ 32838 pointerId: null, 32839 width: null, 32840 height: null, 32841 pressure: null, 32842 tiltX: null, 32843 tiltY: null, 32844 pointerType: null, 32845 isPrimary: null 32846}); 32847 32848var eventTypes$2 = { 32849 mouseEnter: { 32850 registrationName: 'onMouseEnter', 32851 dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER] 32852 }, 32853 mouseLeave: { 32854 registrationName: 'onMouseLeave', 32855 dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER] 32856 }, 32857 pointerEnter: { 32858 registrationName: 'onPointerEnter', 32859 dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER] 32860 }, 32861 pointerLeave: { 32862 registrationName: 'onPointerLeave', 32863 dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER] 32864 } 32865}; 32866 32867var EnterLeaveEventPlugin = { 32868 eventTypes: eventTypes$2, 32869 32870 /** 32871 * For almost every interaction we care about, there will be both a top-level 32872 * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that 32873 * we do not extract duplicate events. However, moving the mouse into the 32874 * browser from outside will not fire a `mouseout` event. In this case, we use 32875 * the `mouseover` top-level event. 32876 */ 32877 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { 32878 var isOverEvent = topLevelType === TOP_MOUSE_OVER || topLevelType === TOP_POINTER_OVER; 32879 var isOutEvent = topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_POINTER_OUT; 32880 32881 if (isOverEvent && (nativeEvent.relatedTarget || nativeEvent.fromElement)) { 32882 return null; 32883 } 32884 32885 if (!isOutEvent && !isOverEvent) { 32886 // Must not be a mouse or pointer in or out - ignoring. 32887 return null; 32888 } 32889 32890 var win = void 0; 32891 if (nativeEventTarget.window === nativeEventTarget) { 32892 // `nativeEventTarget` is probably a window object. 32893 win = nativeEventTarget; 32894 } else { 32895 // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8. 32896 var doc = nativeEventTarget.ownerDocument; 32897 if (doc) { 32898 win = doc.defaultView || doc.parentWindow; 32899 } else { 32900 win = window; 32901 } 32902 } 32903 32904 var from = void 0; 32905 var to = void 0; 32906 if (isOutEvent) { 32907 from = targetInst; 32908 var related = nativeEvent.relatedTarget || nativeEvent.toElement; 32909 to = related ? getClosestInstanceFromNode(related) : null; 32910 } else { 32911 // Moving to a node from outside the window. 32912 from = null; 32913 to = targetInst; 32914 } 32915 32916 if (from === to) { 32917 // Nothing pertains to our managed components. 32918 return null; 32919 } 32920 32921 var eventInterface = void 0, 32922 leaveEventType = void 0, 32923 enterEventType = void 0, 32924 eventTypePrefix = void 0; 32925 32926 if (topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_MOUSE_OVER) { 32927 eventInterface = SyntheticMouseEvent; 32928 leaveEventType = eventTypes$2.mouseLeave; 32929 enterEventType = eventTypes$2.mouseEnter; 32930 eventTypePrefix = 'mouse'; 32931 } else if (topLevelType === TOP_POINTER_OUT || topLevelType === TOP_POINTER_OVER) { 32932 eventInterface = SyntheticPointerEvent; 32933 leaveEventType = eventTypes$2.pointerLeave; 32934 enterEventType = eventTypes$2.pointerEnter; 32935 eventTypePrefix = 'pointer'; 32936 } 32937 32938 var fromNode = from == null ? win : getNodeFromInstance$1(from); 32939 var toNode = to == null ? win : getNodeFromInstance$1(to); 32940 32941 var leave = eventInterface.getPooled(leaveEventType, from, nativeEvent, nativeEventTarget); 32942 leave.type = eventTypePrefix + 'leave'; 32943 leave.target = fromNode; 32944 leave.relatedTarget = toNode; 32945 32946 var enter = eventInterface.getPooled(enterEventType, to, nativeEvent, nativeEventTarget); 32947 enter.type = eventTypePrefix + 'enter'; 32948 enter.target = toNode; 32949 enter.relatedTarget = fromNode; 32950 32951 accumulateEnterLeaveDispatches(leave, enter, from, to); 32952 32953 return [leave, enter]; 32954 } 32955}; 32956 32957/** 32958 * `ReactInstanceMap` maintains a mapping from a public facing stateful 32959 * instance (key) and the internal representation (value). This allows public 32960 * methods to accept the user facing instance as an argument and map them back 32961 * to internal methods. 32962 * 32963 * Note that this module is currently shared and assumed to be stateless. 32964 * If this becomes an actual Map, that will break. 32965 */ 32966 32967/** 32968 * This API should be called `delete` but we'd have to make sure to always 32969 * transform these to strings for IE support. When this transform is fully 32970 * supported we can rename it. 32971 */ 32972 32973 32974function get(key) { 32975 return key._reactInternalFiber; 32976} 32977 32978function has(key) { 32979 return key._reactInternalFiber !== undefined; 32980} 32981 32982function set(key, value) { 32983 key._reactInternalFiber = value; 32984} 32985 32986// Don't change these two values. They're used by React Dev Tools. 32987var NoEffect = /* */0; 32988var PerformedWork = /* */1; 32989 32990// You can change the rest (and add more). 32991var Placement = /* */2; 32992var Update = /* */4; 32993var PlacementAndUpdate = /* */6; 32994var Deletion = /* */8; 32995var ContentReset = /* */16; 32996var Callback = /* */32; 32997var DidCapture = /* */64; 32998var Ref = /* */128; 32999var Snapshot = /* */256; 33000 33001// Union of all host effects 33002var HostEffectMask = /* */511; 33003 33004var Incomplete = /* */512; 33005var ShouldCapture = /* */1024; 33006 33007var MOUNTING = 1; 33008var MOUNTED = 2; 33009var UNMOUNTED = 3; 33010 33011function isFiberMountedImpl(fiber) { 33012 var node = fiber; 33013 if (!fiber.alternate) { 33014 // If there is no alternate, this might be a new tree that isn't inserted 33015 // yet. If it is, then it will have a pending insertion effect on it. 33016 if ((node.effectTag & Placement) !== NoEffect) { 33017 return MOUNTING; 33018 } 33019 while (node.return) { 33020 node = node.return; 33021 if ((node.effectTag & Placement) !== NoEffect) { 33022 return MOUNTING; 33023 } 33024 } 33025 } else { 33026 while (node.return) { 33027 node = node.return; 33028 } 33029 } 33030 if (node.tag === HostRoot) { 33031 // TODO: Check if this was a nested HostRoot when used with 33032 // renderContainerIntoSubtree. 33033 return MOUNTED; 33034 } 33035 // If we didn't hit the root, that means that we're in an disconnected tree 33036 // that has been unmounted. 33037 return UNMOUNTED; 33038} 33039 33040function isFiberMounted(fiber) { 33041 return isFiberMountedImpl(fiber) === MOUNTED; 33042} 33043 33044function isMounted(component) { 33045 { 33046 var owner = ReactCurrentOwner.current; 33047 if (owner !== null && owner.tag === ClassComponent) { 33048 var ownerFiber = owner; 33049 var instance = ownerFiber.stateNode; 33050 !instance._warnedAboutRefsInRender ? warning(false, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber) || 'A component') : void 0; 33051 instance._warnedAboutRefsInRender = true; 33052 } 33053 } 33054 33055 var fiber = get(component); 33056 if (!fiber) { 33057 return false; 33058 } 33059 return isFiberMountedImpl(fiber) === MOUNTED; 33060} 33061 33062function assertIsMounted(fiber) { 33063 !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; 33064} 33065 33066function findCurrentFiberUsingSlowPath(fiber) { 33067 var alternate = fiber.alternate; 33068 if (!alternate) { 33069 // If there is no alternate, then we only need to check if it is mounted. 33070 var state = isFiberMountedImpl(fiber); 33071 !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; 33072 if (state === MOUNTING) { 33073 return null; 33074 } 33075 return fiber; 33076 } 33077 // If we have two possible branches, we'll walk backwards up to the root 33078 // to see what path the root points to. On the way we may hit one of the 33079 // special cases and we'll deal with them. 33080 var a = fiber; 33081 var b = alternate; 33082 while (true) { 33083 var parentA = a.return; 33084 var parentB = parentA ? parentA.alternate : null; 33085 if (!parentA || !parentB) { 33086 // We're at the root. 33087 break; 33088 } 33089 33090 // If both copies of the parent fiber point to the same child, we can 33091 // assume that the child is current. This happens when we bailout on low 33092 // priority: the bailed out fiber's child reuses the current child. 33093 if (parentA.child === parentB.child) { 33094 var child = parentA.child; 33095 while (child) { 33096 if (child === a) { 33097 // We've determined that A is the current branch. 33098 assertIsMounted(parentA); 33099 return fiber; 33100 } 33101 if (child === b) { 33102 // We've determined that B is the current branch. 33103 assertIsMounted(parentA); 33104 return alternate; 33105 } 33106 child = child.sibling; 33107 } 33108 // We should never have an alternate for any mounting node. So the only 33109 // way this could possibly happen is if this was unmounted, if at all. 33110 invariant(false, 'Unable to find node on an unmounted component.'); 33111 } 33112 33113 if (a.return !== b.return) { 33114 // The return pointer of A and the return pointer of B point to different 33115 // fibers. We assume that return pointers never criss-cross, so A must 33116 // belong to the child set of A.return, and B must belong to the child 33117 // set of B.return. 33118 a = parentA; 33119 b = parentB; 33120 } else { 33121 // The return pointers point to the same fiber. We'll have to use the 33122 // default, slow path: scan the child sets of each parent alternate to see 33123 // which child belongs to which set. 33124 // 33125 // Search parent A's child set 33126 var didFindChild = false; 33127 var _child = parentA.child; 33128 while (_child) { 33129 if (_child === a) { 33130 didFindChild = true; 33131 a = parentA; 33132 b = parentB; 33133 break; 33134 } 33135 if (_child === b) { 33136 didFindChild = true; 33137 b = parentA; 33138 a = parentB; 33139 break; 33140 } 33141 _child = _child.sibling; 33142 } 33143 if (!didFindChild) { 33144 // Search parent B's child set 33145 _child = parentB.child; 33146 while (_child) { 33147 if (_child === a) { 33148 didFindChild = true; 33149 a = parentB; 33150 b = parentA; 33151 break; 33152 } 33153 if (_child === b) { 33154 didFindChild = true; 33155 b = parentB; 33156 a = parentA; 33157 break; 33158 } 33159 _child = _child.sibling; 33160 } 33161 !didFindChild ? invariant(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0; 33162 } 33163 } 33164 33165 !(a.alternate === b) ? invariant(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0; 33166 } 33167 // If the root is not a host container, we're in a disconnected tree. I.e. 33168 // unmounted. 33169 !(a.tag === HostRoot) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; 33170 if (a.stateNode.current === a) { 33171 // We've determined that A is the current branch. 33172 return fiber; 33173 } 33174 // Otherwise B has to be current branch. 33175 return alternate; 33176} 33177 33178function findCurrentHostFiber(parent) { 33179 var currentParent = findCurrentFiberUsingSlowPath(parent); 33180 if (!currentParent) { 33181 return null; 33182 } 33183 33184 // Next we'll drill down this component to find the first HostComponent/Text. 33185 var node = currentParent; 33186 while (true) { 33187 if (node.tag === HostComponent || node.tag === HostText) { 33188 return node; 33189 } else if (node.child) { 33190 node.child.return = node; 33191 node = node.child; 33192 continue; 33193 } 33194 if (node === currentParent) { 33195 return null; 33196 } 33197 while (!node.sibling) { 33198 if (!node.return || node.return === currentParent) { 33199 return null; 33200 } 33201 node = node.return; 33202 } 33203 node.sibling.return = node.return; 33204 node = node.sibling; 33205 } 33206 // Flow needs the return null here, but ESLint complains about it. 33207 // eslint-disable-next-line no-unreachable 33208 return null; 33209} 33210 33211function findCurrentHostFiberWithNoPortals(parent) { 33212 var currentParent = findCurrentFiberUsingSlowPath(parent); 33213 if (!currentParent) { 33214 return null; 33215 } 33216 33217 // Next we'll drill down this component to find the first HostComponent/Text. 33218 var node = currentParent; 33219 while (true) { 33220 if (node.tag === HostComponent || node.tag === HostText) { 33221 return node; 33222 } else if (node.child && node.tag !== HostPortal) { 33223 node.child.return = node; 33224 node = node.child; 33225 continue; 33226 } 33227 if (node === currentParent) { 33228 return null; 33229 } 33230 while (!node.sibling) { 33231 if (!node.return || node.return === currentParent) { 33232 return null; 33233 } 33234 node = node.return; 33235 } 33236 node.sibling.return = node.return; 33237 node = node.sibling; 33238 } 33239 // Flow needs the return null here, but ESLint complains about it. 33240 // eslint-disable-next-line no-unreachable 33241 return null; 33242} 33243 33244function addEventBubbleListener(element, eventType, listener) { 33245 element.addEventListener(eventType, listener, false); 33246} 33247 33248function addEventCaptureListener(element, eventType, listener) { 33249 element.addEventListener(eventType, listener, true); 33250} 33251 33252/** 33253 * @interface Event 33254 * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface 33255 * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent 33256 */ 33257var SyntheticAnimationEvent = SyntheticEvent$1.extend({ 33258 animationName: null, 33259 elapsedTime: null, 33260 pseudoElement: null 33261}); 33262 33263/** 33264 * @interface Event 33265 * @see http://www.w3.org/TR/clipboard-apis/ 33266 */ 33267var SyntheticClipboardEvent = SyntheticEvent$1.extend({ 33268 clipboardData: function (event) { 33269 return 'clipboardData' in event ? event.clipboardData : window.clipboardData; 33270 } 33271}); 33272 33273/** 33274 * @interface FocusEvent 33275 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 33276 */ 33277var SyntheticFocusEvent = SyntheticUIEvent.extend({ 33278 relatedTarget: null 33279}); 33280 33281/** 33282 * `charCode` represents the actual "character code" and is safe to use with 33283 * `String.fromCharCode`. As such, only keys that correspond to printable 33284 * characters produce a valid `charCode`, the only exception to this is Enter. 33285 * The Tab-key is considered non-printable and does not have a `charCode`, 33286 * presumably because it does not produce a tab-character in browsers. 33287 * 33288 * @param {object} nativeEvent Native browser event. 33289 * @return {number} Normalized `charCode` property. 33290 */ 33291function getEventCharCode(nativeEvent) { 33292 var charCode = void 0; 33293 var keyCode = nativeEvent.keyCode; 33294 33295 if ('charCode' in nativeEvent) { 33296 charCode = nativeEvent.charCode; 33297 33298 // FF does not set `charCode` for the Enter-key, check against `keyCode`. 33299 if (charCode === 0 && keyCode === 13) { 33300 charCode = 13; 33301 } 33302 } else { 33303 // IE8 does not implement `charCode`, but `keyCode` has the correct value. 33304 charCode = keyCode; 33305 } 33306 33307 // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux) 33308 // report Enter as charCode 10 when ctrl is pressed. 33309 if (charCode === 10) { 33310 charCode = 13; 33311 } 33312 33313 // Some non-printable keys are reported in `charCode`/`keyCode`, discard them. 33314 // Must not discard the (non-)printable Enter-key. 33315 if (charCode >= 32 || charCode === 13) { 33316 return charCode; 33317 } 33318 33319 return 0; 33320} 33321 33322/** 33323 * Normalization of deprecated HTML5 `key` values 33324 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names 33325 */ 33326var normalizeKey = { 33327 Esc: 'Escape', 33328 Spacebar: ' ', 33329 Left: 'ArrowLeft', 33330 Up: 'ArrowUp', 33331 Right: 'ArrowRight', 33332 Down: 'ArrowDown', 33333 Del: 'Delete', 33334 Win: 'OS', 33335 Menu: 'ContextMenu', 33336 Apps: 'ContextMenu', 33337 Scroll: 'ScrollLock', 33338 MozPrintableKey: 'Unidentified' 33339}; 33340 33341/** 33342 * Translation from legacy `keyCode` to HTML5 `key` 33343 * Only special keys supported, all others depend on keyboard layout or browser 33344 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names 33345 */ 33346var translateToKey = { 33347 '8': 'Backspace', 33348 '9': 'Tab', 33349 '12': 'Clear', 33350 '13': 'Enter', 33351 '16': 'Shift', 33352 '17': 'Control', 33353 '18': 'Alt', 33354 '19': 'Pause', 33355 '20': 'CapsLock', 33356 '27': 'Escape', 33357 '32': ' ', 33358 '33': 'PageUp', 33359 '34': 'PageDown', 33360 '35': 'End', 33361 '36': 'Home', 33362 '37': 'ArrowLeft', 33363 '38': 'ArrowUp', 33364 '39': 'ArrowRight', 33365 '40': 'ArrowDown', 33366 '45': 'Insert', 33367 '46': 'Delete', 33368 '112': 'F1', 33369 '113': 'F2', 33370 '114': 'F3', 33371 '115': 'F4', 33372 '116': 'F5', 33373 '117': 'F6', 33374 '118': 'F7', 33375 '119': 'F8', 33376 '120': 'F9', 33377 '121': 'F10', 33378 '122': 'F11', 33379 '123': 'F12', 33380 '144': 'NumLock', 33381 '145': 'ScrollLock', 33382 '224': 'Meta' 33383}; 33384 33385/** 33386 * @param {object} nativeEvent Native browser event. 33387 * @return {string} Normalized `key` property. 33388 */ 33389function getEventKey(nativeEvent) { 33390 if (nativeEvent.key) { 33391 // Normalize inconsistent values reported by browsers due to 33392 // implementations of a working draft specification. 33393 33394 // FireFox implements `key` but returns `MozPrintableKey` for all 33395 // printable characters (normalized to `Unidentified`), ignore it. 33396 var key = normalizeKey[nativeEvent.key] || nativeEvent.key; 33397 if (key !== 'Unidentified') { 33398 return key; 33399 } 33400 } 33401 33402 // Browser does not implement `key`, polyfill as much of it as we can. 33403 if (nativeEvent.type === 'keypress') { 33404 var charCode = getEventCharCode(nativeEvent); 33405 33406 // The enter-key is technically both printable and non-printable and can 33407 // thus be captured by `keypress`, no other non-printable key should. 33408 return charCode === 13 ? 'Enter' : String.fromCharCode(charCode); 33409 } 33410 if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') { 33411 // While user keyboard layout determines the actual meaning of each 33412 // `keyCode` value, almost all function keys have a universal value. 33413 return translateToKey[nativeEvent.keyCode] || 'Unidentified'; 33414 } 33415 return ''; 33416} 33417 33418/** 33419 * @interface KeyboardEvent 33420 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 33421 */ 33422var SyntheticKeyboardEvent = SyntheticUIEvent.extend({ 33423 key: getEventKey, 33424 location: null, 33425 ctrlKey: null, 33426 shiftKey: null, 33427 altKey: null, 33428 metaKey: null, 33429 repeat: null, 33430 locale: null, 33431 getModifierState: getEventModifierState, 33432 // Legacy Interface 33433 charCode: function (event) { 33434 // `charCode` is the result of a KeyPress event and represents the value of 33435 // the actual printable character. 33436 33437 // KeyPress is deprecated, but its replacement is not yet final and not 33438 // implemented in any major browser. Only KeyPress has charCode. 33439 if (event.type === 'keypress') { 33440 return getEventCharCode(event); 33441 } 33442 return 0; 33443 }, 33444 keyCode: function (event) { 33445 // `keyCode` is the result of a KeyDown/Up event and represents the value of 33446 // physical keyboard key. 33447 33448 // The actual meaning of the value depends on the users' keyboard layout 33449 // which cannot be detected. Assuming that it is a US keyboard layout 33450 // provides a surprisingly accurate mapping for US and European users. 33451 // Due to this, it is left to the user to implement at this time. 33452 if (event.type === 'keydown' || event.type === 'keyup') { 33453 return event.keyCode; 33454 } 33455 return 0; 33456 }, 33457 which: function (event) { 33458 // `which` is an alias for either `keyCode` or `charCode` depending on the 33459 // type of the event. 33460 if (event.type === 'keypress') { 33461 return getEventCharCode(event); 33462 } 33463 if (event.type === 'keydown' || event.type === 'keyup') { 33464 return event.keyCode; 33465 } 33466 return 0; 33467 } 33468}); 33469 33470/** 33471 * @interface DragEvent 33472 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 33473 */ 33474var SyntheticDragEvent = SyntheticMouseEvent.extend({ 33475 dataTransfer: null 33476}); 33477 33478/** 33479 * @interface TouchEvent 33480 * @see http://www.w3.org/TR/touch-events/ 33481 */ 33482var SyntheticTouchEvent = SyntheticUIEvent.extend({ 33483 touches: null, 33484 targetTouches: null, 33485 changedTouches: null, 33486 altKey: null, 33487 metaKey: null, 33488 ctrlKey: null, 33489 shiftKey: null, 33490 getModifierState: getEventModifierState 33491}); 33492 33493/** 33494 * @interface Event 33495 * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events- 33496 * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent 33497 */ 33498var SyntheticTransitionEvent = SyntheticEvent$1.extend({ 33499 propertyName: null, 33500 elapsedTime: null, 33501 pseudoElement: null 33502}); 33503 33504/** 33505 * @interface WheelEvent 33506 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 33507 */ 33508var SyntheticWheelEvent = SyntheticMouseEvent.extend({ 33509 deltaX: function (event) { 33510 return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive). 33511 'wheelDeltaX' in event ? -event.wheelDeltaX : 0; 33512 }, 33513 deltaY: function (event) { 33514 return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive). 33515 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive). 33516 'wheelDelta' in event ? -event.wheelDelta : 0; 33517 }, 33518 33519 deltaZ: null, 33520 33521 // Browsers without "deltaMode" is reporting in raw wheel delta where one 33522 // notch on the scroll is always +/- 120, roughly equivalent to pixels. 33523 // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or 33524 // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size. 33525 deltaMode: null 33526}); 33527 33528/** 33529 * Turns 33530 * ['abort', ...] 33531 * into 33532 * eventTypes = { 33533 * 'abort': { 33534 * phasedRegistrationNames: { 33535 * bubbled: 'onAbort', 33536 * captured: 'onAbortCapture', 33537 * }, 33538 * dependencies: [TOP_ABORT], 33539 * }, 33540 * ... 33541 * }; 33542 * topLevelEventsToDispatchConfig = new Map([ 33543 * [TOP_ABORT, { sameConfig }], 33544 * ]); 33545 */ 33546 33547var interactiveEventTypeNames = [[TOP_BLUR, 'blur'], [TOP_CANCEL, 'cancel'], [TOP_CLICK, 'click'], [TOP_CLOSE, 'close'], [TOP_CONTEXT_MENU, 'contextMenu'], [TOP_COPY, 'copy'], [TOP_CUT, 'cut'], [TOP_DOUBLE_CLICK, 'doubleClick'], [TOP_DRAG_END, 'dragEnd'], [TOP_DRAG_START, 'dragStart'], [TOP_DROP, 'drop'], [TOP_FOCUS, 'focus'], [TOP_INPUT, 'input'], [TOP_INVALID, 'invalid'], [TOP_KEY_DOWN, 'keyDown'], [TOP_KEY_PRESS, 'keyPress'], [TOP_KEY_UP, 'keyUp'], [TOP_MOUSE_DOWN, 'mouseDown'], [TOP_MOUSE_UP, 'mouseUp'], [TOP_PASTE, 'paste'], [TOP_PAUSE, 'pause'], [TOP_PLAY, 'play'], [TOP_POINTER_CANCEL, 'pointerCancel'], [TOP_POINTER_DOWN, 'pointerDown'], [TOP_POINTER_UP, 'pointerUp'], [TOP_RATE_CHANGE, 'rateChange'], [TOP_RESET, 'reset'], [TOP_SEEKED, 'seeked'], [TOP_SUBMIT, 'submit'], [TOP_TOUCH_CANCEL, 'touchCancel'], [TOP_TOUCH_END, 'touchEnd'], [TOP_TOUCH_START, 'touchStart'], [TOP_VOLUME_CHANGE, 'volumeChange']]; 33548var nonInteractiveEventTypeNames = [[TOP_ABORT, 'abort'], [TOP_ANIMATION_END, 'animationEnd'], [TOP_ANIMATION_ITERATION, 'animationIteration'], [TOP_ANIMATION_START, 'animationStart'], [TOP_CAN_PLAY, 'canPlay'], [TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], [TOP_DRAG, 'drag'], [TOP_DRAG_ENTER, 'dragEnter'], [TOP_DRAG_EXIT, 'dragExit'], [TOP_DRAG_LEAVE, 'dragLeave'], [TOP_DRAG_OVER, 'dragOver'], [TOP_DURATION_CHANGE, 'durationChange'], [TOP_EMPTIED, 'emptied'], [TOP_ENCRYPTED, 'encrypted'], [TOP_ENDED, 'ended'], [TOP_ERROR, 'error'], [TOP_GOT_POINTER_CAPTURE, 'gotPointerCapture'], [TOP_LOAD, 'load'], [TOP_LOADED_DATA, 'loadedData'], [TOP_LOADED_METADATA, 'loadedMetadata'], [TOP_LOAD_START, 'loadStart'], [TOP_LOST_POINTER_CAPTURE, 'lostPointerCapture'], [TOP_MOUSE_MOVE, 'mouseMove'], [TOP_MOUSE_OUT, 'mouseOut'], [TOP_MOUSE_OVER, 'mouseOver'], [TOP_PLAYING, 'playing'], [TOP_POINTER_MOVE, 'pointerMove'], [TOP_POINTER_OUT, 'pointerOut'], [TOP_POINTER_OVER, 'pointerOver'], [TOP_PROGRESS, 'progress'], [TOP_SCROLL, 'scroll'], [TOP_SEEKING, 'seeking'], [TOP_STALLED, 'stalled'], [TOP_SUSPEND, 'suspend'], [TOP_TIME_UPDATE, 'timeUpdate'], [TOP_TOGGLE, 'toggle'], [TOP_TOUCH_MOVE, 'touchMove'], [TOP_TRANSITION_END, 'transitionEnd'], [TOP_WAITING, 'waiting'], [TOP_WHEEL, 'wheel']]; 33549 33550var eventTypes$4 = {}; 33551var topLevelEventsToDispatchConfig = {}; 33552 33553function addEventTypeNameToConfig(_ref, isInteractive) { 33554 var topEvent = _ref[0], 33555 event = _ref[1]; 33556 33557 var capitalizedEvent = event[0].toUpperCase() + event.slice(1); 33558 var onEvent = 'on' + capitalizedEvent; 33559 33560 var type = { 33561 phasedRegistrationNames: { 33562 bubbled: onEvent, 33563 captured: onEvent + 'Capture' 33564 }, 33565 dependencies: [topEvent], 33566 isInteractive: isInteractive 33567 }; 33568 eventTypes$4[event] = type; 33569 topLevelEventsToDispatchConfig[topEvent] = type; 33570} 33571 33572interactiveEventTypeNames.forEach(function (eventTuple) { 33573 addEventTypeNameToConfig(eventTuple, true); 33574}); 33575nonInteractiveEventTypeNames.forEach(function (eventTuple) { 33576 addEventTypeNameToConfig(eventTuple, false); 33577}); 33578 33579// Only used in DEV for exhaustiveness validation. 33580var knownHTMLTopLevelTypes = [TOP_ABORT, TOP_CANCEL, TOP_CAN_PLAY, TOP_CAN_PLAY_THROUGH, TOP_CLOSE, TOP_DURATION_CHANGE, TOP_EMPTIED, TOP_ENCRYPTED, TOP_ENDED, TOP_ERROR, TOP_INPUT, TOP_INVALID, TOP_LOAD, TOP_LOADED_DATA, TOP_LOADED_METADATA, TOP_LOAD_START, TOP_PAUSE, TOP_PLAY, TOP_PLAYING, TOP_PROGRESS, TOP_RATE_CHANGE, TOP_RESET, TOP_SEEKED, TOP_SEEKING, TOP_STALLED, TOP_SUBMIT, TOP_SUSPEND, TOP_TIME_UPDATE, TOP_TOGGLE, TOP_VOLUME_CHANGE, TOP_WAITING]; 33581 33582var SimpleEventPlugin = { 33583 eventTypes: eventTypes$4, 33584 33585 isInteractiveTopLevelEventType: function (topLevelType) { 33586 var config = topLevelEventsToDispatchConfig[topLevelType]; 33587 return config !== undefined && config.isInteractive === true; 33588 }, 33589 33590 33591 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { 33592 var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType]; 33593 if (!dispatchConfig) { 33594 return null; 33595 } 33596 var EventConstructor = void 0; 33597 switch (topLevelType) { 33598 case TOP_KEY_PRESS: 33599 // Firefox creates a keypress event for function keys too. This removes 33600 // the unwanted keypress events. Enter is however both printable and 33601 // non-printable. One would expect Tab to be as well (but it isn't). 33602 if (getEventCharCode(nativeEvent) === 0) { 33603 return null; 33604 } 33605 /* falls through */ 33606 case TOP_KEY_DOWN: 33607 case TOP_KEY_UP: 33608 EventConstructor = SyntheticKeyboardEvent; 33609 break; 33610 case TOP_BLUR: 33611 case TOP_FOCUS: 33612 EventConstructor = SyntheticFocusEvent; 33613 break; 33614 case TOP_CLICK: 33615 // Firefox creates a click event on right mouse clicks. This removes the 33616 // unwanted click events. 33617 if (nativeEvent.button === 2) { 33618 return null; 33619 } 33620 /* falls through */ 33621 case TOP_DOUBLE_CLICK: 33622 case TOP_MOUSE_DOWN: 33623 case TOP_MOUSE_MOVE: 33624 case TOP_MOUSE_UP: 33625 // TODO: Disabled elements should not respond to mouse events 33626 /* falls through */ 33627 case TOP_MOUSE_OUT: 33628 case TOP_MOUSE_OVER: 33629 case TOP_CONTEXT_MENU: 33630 EventConstructor = SyntheticMouseEvent; 33631 break; 33632 case TOP_DRAG: 33633 case TOP_DRAG_END: 33634 case TOP_DRAG_ENTER: 33635 case TOP_DRAG_EXIT: 33636 case TOP_DRAG_LEAVE: 33637 case TOP_DRAG_OVER: 33638 case TOP_DRAG_START: 33639 case TOP_DROP: 33640 EventConstructor = SyntheticDragEvent; 33641 break; 33642 case TOP_TOUCH_CANCEL: 33643 case TOP_TOUCH_END: 33644 case TOP_TOUCH_MOVE: 33645 case TOP_TOUCH_START: 33646 EventConstructor = SyntheticTouchEvent; 33647 break; 33648 case TOP_ANIMATION_END: 33649 case TOP_ANIMATION_ITERATION: 33650 case TOP_ANIMATION_START: 33651 EventConstructor = SyntheticAnimationEvent; 33652 break; 33653 case TOP_TRANSITION_END: 33654 EventConstructor = SyntheticTransitionEvent; 33655 break; 33656 case TOP_SCROLL: 33657 EventConstructor = SyntheticUIEvent; 33658 break; 33659 case TOP_WHEEL: 33660 EventConstructor = SyntheticWheelEvent; 33661 break; 33662 case TOP_COPY: 33663 case TOP_CUT: 33664 case TOP_PASTE: 33665 EventConstructor = SyntheticClipboardEvent; 33666 break; 33667 case TOP_GOT_POINTER_CAPTURE: 33668 case TOP_LOST_POINTER_CAPTURE: 33669 case TOP_POINTER_CANCEL: 33670 case TOP_POINTER_DOWN: 33671 case TOP_POINTER_MOVE: 33672 case TOP_POINTER_OUT: 33673 case TOP_POINTER_OVER: 33674 case TOP_POINTER_UP: 33675 EventConstructor = SyntheticPointerEvent; 33676 break; 33677 default: 33678 { 33679 if (knownHTMLTopLevelTypes.indexOf(topLevelType) === -1) { 33680 warning(false, 'SimpleEventPlugin: Unhandled event type, `%s`. This warning ' + 'is likely caused by a bug in React. Please file an issue.', topLevelType); 33681 } 33682 } 33683 // HTML Events 33684 // @see http://www.w3.org/TR/html5/index.html#events-0 33685 EventConstructor = SyntheticEvent$1; 33686 break; 33687 } 33688 var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget); 33689 accumulateTwoPhaseDispatches(event); 33690 return event; 33691 } 33692}; 33693 33694var isInteractiveTopLevelEventType = SimpleEventPlugin.isInteractiveTopLevelEventType; 33695 33696 33697var CALLBACK_BOOKKEEPING_POOL_SIZE = 10; 33698var callbackBookkeepingPool = []; 33699 33700/** 33701 * Find the deepest React component completely containing the root of the 33702 * passed-in instance (for use when entire React trees are nested within each 33703 * other). If React trees are not nested, returns null. 33704 */ 33705function findRootContainerNode(inst) { 33706 // TODO: It may be a good idea to cache this to prevent unnecessary DOM 33707 // traversal, but caching is difficult to do correctly without using a 33708 // mutation observer to listen for all DOM changes. 33709 while (inst.return) { 33710 inst = inst.return; 33711 } 33712 if (inst.tag !== HostRoot) { 33713 // This can happen if we're in a detached tree. 33714 return null; 33715 } 33716 return inst.stateNode.containerInfo; 33717} 33718 33719// Used to store ancestor hierarchy in top level callback 33720function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst) { 33721 if (callbackBookkeepingPool.length) { 33722 var instance = callbackBookkeepingPool.pop(); 33723 instance.topLevelType = topLevelType; 33724 instance.nativeEvent = nativeEvent; 33725 instance.targetInst = targetInst; 33726 return instance; 33727 } 33728 return { 33729 topLevelType: topLevelType, 33730 nativeEvent: nativeEvent, 33731 targetInst: targetInst, 33732 ancestors: [] 33733 }; 33734} 33735 33736function releaseTopLevelCallbackBookKeeping(instance) { 33737 instance.topLevelType = null; 33738 instance.nativeEvent = null; 33739 instance.targetInst = null; 33740 instance.ancestors.length = 0; 33741 if (callbackBookkeepingPool.length < CALLBACK_BOOKKEEPING_POOL_SIZE) { 33742 callbackBookkeepingPool.push(instance); 33743 } 33744} 33745 33746function handleTopLevel(bookKeeping) { 33747 var targetInst = bookKeeping.targetInst; 33748 33749 // Loop through the hierarchy, in case there's any nested components. 33750 // It's important that we build the array of ancestors before calling any 33751 // event handlers, because event handlers can modify the DOM, leading to 33752 // inconsistencies with ReactMount's node cache. See #1105. 33753 var ancestor = targetInst; 33754 do { 33755 if (!ancestor) { 33756 bookKeeping.ancestors.push(ancestor); 33757 break; 33758 } 33759 var root = findRootContainerNode(ancestor); 33760 if (!root) { 33761 break; 33762 } 33763 bookKeeping.ancestors.push(ancestor); 33764 ancestor = getClosestInstanceFromNode(root); 33765 } while (ancestor); 33766 33767 for (var i = 0; i < bookKeeping.ancestors.length; i++) { 33768 targetInst = bookKeeping.ancestors[i]; 33769 runExtractedEventsInBatch(bookKeeping.topLevelType, targetInst, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent)); 33770 } 33771} 33772 33773// TODO: can we stop exporting these? 33774var _enabled = true; 33775 33776function setEnabled(enabled) { 33777 _enabled = !!enabled; 33778} 33779 33780function isEnabled() { 33781 return _enabled; 33782} 33783 33784/** 33785 * Traps top-level events by using event bubbling. 33786 * 33787 * @param {number} topLevelType Number from `TopLevelEventTypes`. 33788 * @param {object} element Element on which to attach listener. 33789 * @return {?object} An object with a remove function which will forcefully 33790 * remove the listener. 33791 * @internal 33792 */ 33793function trapBubbledEvent(topLevelType, element) { 33794 if (!element) { 33795 return null; 33796 } 33797 var dispatch = isInteractiveTopLevelEventType(topLevelType) ? dispatchInteractiveEvent : dispatchEvent; 33798 33799 addEventBubbleListener(element, getRawEventName(topLevelType), 33800 // Check if interactive and wrap in interactiveUpdates 33801 dispatch.bind(null, topLevelType)); 33802} 33803 33804/** 33805 * Traps a top-level event by using event capturing. 33806 * 33807 * @param {number} topLevelType Number from `TopLevelEventTypes`. 33808 * @param {object} element Element on which to attach listener. 33809 * @return {?object} An object with a remove function which will forcefully 33810 * remove the listener. 33811 * @internal 33812 */ 33813function trapCapturedEvent(topLevelType, element) { 33814 if (!element) { 33815 return null; 33816 } 33817 var dispatch = isInteractiveTopLevelEventType(topLevelType) ? dispatchInteractiveEvent : dispatchEvent; 33818 33819 addEventCaptureListener(element, getRawEventName(topLevelType), 33820 // Check if interactive and wrap in interactiveUpdates 33821 dispatch.bind(null, topLevelType)); 33822} 33823 33824function dispatchInteractiveEvent(topLevelType, nativeEvent) { 33825 interactiveUpdates(dispatchEvent, topLevelType, nativeEvent); 33826} 33827 33828function dispatchEvent(topLevelType, nativeEvent) { 33829 if (!_enabled) { 33830 return; 33831 } 33832 33833 var nativeEventTarget = getEventTarget(nativeEvent); 33834 var targetInst = getClosestInstanceFromNode(nativeEventTarget); 33835 if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) { 33836 // If we get an event (ex: img onload) before committing that 33837 // component's mount, ignore it for now (that is, treat it as if it was an 33838 // event on a non-React tree). We might also consider queueing events and 33839 // dispatching them after the mount. 33840 targetInst = null; 33841 } 33842 33843 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst); 33844 33845 try { 33846 // Event queue being processed in the same cycle allows 33847 // `preventDefault`. 33848 batchedUpdates(handleTopLevel, bookKeeping); 33849 } finally { 33850 releaseTopLevelCallbackBookKeeping(bookKeeping); 33851 } 33852} 33853 33854var ReactDOMEventListener = Object.freeze({ 33855 get _enabled () { return _enabled; }, 33856 setEnabled: setEnabled, 33857 isEnabled: isEnabled, 33858 trapBubbledEvent: trapBubbledEvent, 33859 trapCapturedEvent: trapCapturedEvent, 33860 dispatchEvent: dispatchEvent 33861}); 33862 33863/** 33864 * Summary of `ReactBrowserEventEmitter` event handling: 33865 * 33866 * - Top-level delegation is used to trap most native browser events. This 33867 * may only occur in the main thread and is the responsibility of 33868 * ReactDOMEventListener, which is injected and can therefore support 33869 * pluggable event sources. This is the only work that occurs in the main 33870 * thread. 33871 * 33872 * - We normalize and de-duplicate events to account for browser quirks. This 33873 * may be done in the worker thread. 33874 * 33875 * - Forward these native events (with the associated top-level type used to 33876 * trap it) to `EventPluginHub`, which in turn will ask plugins if they want 33877 * to extract any synthetic events. 33878 * 33879 * - The `EventPluginHub` will then process each event by annotating them with 33880 * "dispatches", a sequence of listeners and IDs that care about that event. 33881 * 33882 * - The `EventPluginHub` then dispatches the events. 33883 * 33884 * Overview of React and the event system: 33885 * 33886 * +------------+ . 33887 * | DOM | . 33888 * +------------+ . 33889 * | . 33890 * v . 33891 * +------------+ . 33892 * | ReactEvent | . 33893 * | Listener | . 33894 * +------------+ . +-----------+ 33895 * | . +--------+|SimpleEvent| 33896 * | . | |Plugin | 33897 * +-----|------+ . v +-----------+ 33898 * | | | . +--------------+ +------------+ 33899 * | +-----------.--->|EventPluginHub| | Event | 33900 * | | . | | +-----------+ | Propagators| 33901 * | ReactEvent | . | | |TapEvent | |------------| 33902 * | Emitter | . | |<---+|Plugin | |other plugin| 33903 * | | . | | +-----------+ | utilities | 33904 * | +-----------.--->| | +------------+ 33905 * | | | . +--------------+ 33906 * +-----|------+ . ^ +-----------+ 33907 * | . | |Enter/Leave| 33908 * + . +-------+|Plugin | 33909 * +-------------+ . +-----------+ 33910 * | application | . 33911 * |-------------| . 33912 * | | . 33913 * | | . 33914 * +-------------+ . 33915 * . 33916 * React Core . General Purpose Event Plugin System 33917 */ 33918 33919var alreadyListeningTo = {}; 33920var reactTopListenersCounter = 0; 33921 33922/** 33923 * To ensure no conflicts with other potential React instances on the page 33924 */ 33925var topListenersIDKey = '_reactListenersID' + ('' + Math.random()).slice(2); 33926 33927function getListeningForDocument(mountAt) { 33928 // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty` 33929 // directly. 33930 if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) { 33931 mountAt[topListenersIDKey] = reactTopListenersCounter++; 33932 alreadyListeningTo[mountAt[topListenersIDKey]] = {}; 33933 } 33934 return alreadyListeningTo[mountAt[topListenersIDKey]]; 33935} 33936 33937/** 33938 * We listen for bubbled touch events on the document object. 33939 * 33940 * Firefox v8.01 (and possibly others) exhibited strange behavior when 33941 * mounting `onmousemove` events at some node that was not the document 33942 * element. The symptoms were that if your mouse is not moving over something 33943 * contained within that mount point (for example on the background) the 33944 * top-level listeners for `onmousemove` won't be called. However, if you 33945 * register the `mousemove` on the document object, then it will of course 33946 * catch all `mousemove`s. This along with iOS quirks, justifies restricting 33947 * top-level listeners to the document object only, at least for these 33948 * movement types of events and possibly all events. 33949 * 33950 * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html 33951 * 33952 * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but 33953 * they bubble to document. 33954 * 33955 * @param {string} registrationName Name of listener (e.g. `onClick`). 33956 * @param {object} mountAt Container where to mount the listener 33957 */ 33958function listenTo(registrationName, mountAt) { 33959 var isListening = getListeningForDocument(mountAt); 33960 var dependencies = registrationNameDependencies[registrationName]; 33961 33962 for (var i = 0; i < dependencies.length; i++) { 33963 var dependency = dependencies[i]; 33964 if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { 33965 switch (dependency) { 33966 case TOP_SCROLL: 33967 trapCapturedEvent(TOP_SCROLL, mountAt); 33968 break; 33969 case TOP_FOCUS: 33970 case TOP_BLUR: 33971 trapCapturedEvent(TOP_FOCUS, mountAt); 33972 trapCapturedEvent(TOP_BLUR, mountAt); 33973 // We set the flag for a single dependency later in this function, 33974 // but this ensures we mark both as attached rather than just one. 33975 isListening[TOP_BLUR] = true; 33976 isListening[TOP_FOCUS] = true; 33977 break; 33978 case TOP_CANCEL: 33979 case TOP_CLOSE: 33980 if (isEventSupported(getRawEventName(dependency), true)) { 33981 trapCapturedEvent(dependency, mountAt); 33982 } 33983 break; 33984 case TOP_INVALID: 33985 case TOP_SUBMIT: 33986 case TOP_RESET: 33987 // We listen to them on the target DOM elements. 33988 // Some of them bubble so we don't want them to fire twice. 33989 break; 33990 default: 33991 // By default, listen on the top level to all non-media events. 33992 // Media events don't bubble so adding the listener wouldn't do anything. 33993 var isMediaEvent = mediaEventTypes.indexOf(dependency) !== -1; 33994 if (!isMediaEvent) { 33995 trapBubbledEvent(dependency, mountAt); 33996 } 33997 break; 33998 } 33999 isListening[dependency] = true; 34000 } 34001 } 34002} 34003 34004function isListeningToAllDependencies(registrationName, mountAt) { 34005 var isListening = getListeningForDocument(mountAt); 34006 var dependencies = registrationNameDependencies[registrationName]; 34007 for (var i = 0; i < dependencies.length; i++) { 34008 var dependency = dependencies[i]; 34009 if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { 34010 return false; 34011 } 34012 } 34013 return true; 34014} 34015 34016/** 34017 * Given any node return the first leaf node without children. 34018 * 34019 * @param {DOMElement|DOMTextNode} node 34020 * @return {DOMElement|DOMTextNode} 34021 */ 34022function getLeafNode(node) { 34023 while (node && node.firstChild) { 34024 node = node.firstChild; 34025 } 34026 return node; 34027} 34028 34029/** 34030 * Get the next sibling within a container. This will walk up the 34031 * DOM if a node's siblings have been exhausted. 34032 * 34033 * @param {DOMElement|DOMTextNode} node 34034 * @return {?DOMElement|DOMTextNode} 34035 */ 34036function getSiblingNode(node) { 34037 while (node) { 34038 if (node.nextSibling) { 34039 return node.nextSibling; 34040 } 34041 node = node.parentNode; 34042 } 34043} 34044 34045/** 34046 * Get object describing the nodes which contain characters at offset. 34047 * 34048 * @param {DOMElement|DOMTextNode} root 34049 * @param {number} offset 34050 * @return {?object} 34051 */ 34052function getNodeForCharacterOffset(root, offset) { 34053 var node = getLeafNode(root); 34054 var nodeStart = 0; 34055 var nodeEnd = 0; 34056 34057 while (node) { 34058 if (node.nodeType === TEXT_NODE) { 34059 nodeEnd = nodeStart + node.textContent.length; 34060 34061 if (nodeStart <= offset && nodeEnd >= offset) { 34062 return { 34063 node: node, 34064 offset: offset - nodeStart 34065 }; 34066 } 34067 34068 nodeStart = nodeEnd; 34069 } 34070 34071 node = getLeafNode(getSiblingNode(node)); 34072 } 34073} 34074 34075/** 34076 * @param {DOMElement} outerNode 34077 * @return {?object} 34078 */ 34079function getOffsets(outerNode) { 34080 var selection = window.getSelection && window.getSelection(); 34081 34082 if (!selection || selection.rangeCount === 0) { 34083 return null; 34084 } 34085 34086 var anchorNode = selection.anchorNode, 34087 anchorOffset = selection.anchorOffset, 34088 focusNode = selection.focusNode, 34089 focusOffset = selection.focusOffset; 34090 34091 // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the 34092 // up/down buttons on an <input type="number">. Anonymous divs do not seem to 34093 // expose properties, triggering a "Permission denied error" if any of its 34094 // properties are accessed. The only seemingly possible way to avoid erroring 34095 // is to access a property that typically works for non-anonymous divs and 34096 // catch any error that may otherwise arise. See 34097 // https://bugzilla.mozilla.org/show_bug.cgi?id=208427 34098 34099 try { 34100 /* eslint-disable no-unused-expressions */ 34101 anchorNode.nodeType; 34102 focusNode.nodeType; 34103 /* eslint-enable no-unused-expressions */ 34104 } catch (e) { 34105 return null; 34106 } 34107 34108 return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset); 34109} 34110 34111/** 34112 * Returns {start, end} where `start` is the character/codepoint index of 34113 * (anchorNode, anchorOffset) within the textContent of `outerNode`, and 34114 * `end` is the index of (focusNode, focusOffset). 34115 * 34116 * Returns null if you pass in garbage input but we should probably just crash. 34117 * 34118 * Exported only for testing. 34119 */ 34120function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) { 34121 var length = 0; 34122 var start = -1; 34123 var end = -1; 34124 var indexWithinAnchor = 0; 34125 var indexWithinFocus = 0; 34126 var node = outerNode; 34127 var parentNode = null; 34128 34129 outer: while (true) { 34130 var next = null; 34131 34132 while (true) { 34133 if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) { 34134 start = length + anchorOffset; 34135 } 34136 if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) { 34137 end = length + focusOffset; 34138 } 34139 34140 if (node.nodeType === TEXT_NODE) { 34141 length += node.nodeValue.length; 34142 } 34143 34144 if ((next = node.firstChild) === null) { 34145 break; 34146 } 34147 // Moving from `node` to its first child `next`. 34148 parentNode = node; 34149 node = next; 34150 } 34151 34152 while (true) { 34153 if (node === outerNode) { 34154 // If `outerNode` has children, this is always the second time visiting 34155 // it. If it has no children, this is still the first loop, and the only 34156 // valid selection is anchorNode and focusNode both equal to this node 34157 // and both offsets 0, in which case we will have handled above. 34158 break outer; 34159 } 34160 if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) { 34161 start = length; 34162 } 34163 if (parentNode === focusNode && ++indexWithinFocus === focusOffset) { 34164 end = length; 34165 } 34166 if ((next = node.nextSibling) !== null) { 34167 break; 34168 } 34169 node = parentNode; 34170 parentNode = node.parentNode; 34171 } 34172 34173 // Moving from `node` to its next sibling `next`. 34174 node = next; 34175 } 34176 34177 if (start === -1 || end === -1) { 34178 // This should never happen. (Would happen if the anchor/focus nodes aren't 34179 // actually inside the passed-in node.) 34180 return null; 34181 } 34182 34183 return { 34184 start: start, 34185 end: end 34186 }; 34187} 34188 34189/** 34190 * In modern non-IE browsers, we can support both forward and backward 34191 * selections. 34192 * 34193 * Note: IE10+ supports the Selection object, but it does not support 34194 * the `extend` method, which means that even in modern IE, it's not possible 34195 * to programmatically create a backward selection. Thus, for all IE 34196 * versions, we use the old IE API to create our selections. 34197 * 34198 * @param {DOMElement|DOMTextNode} node 34199 * @param {object} offsets 34200 */ 34201function setOffsets(node, offsets) { 34202 if (!window.getSelection) { 34203 return; 34204 } 34205 34206 var selection = window.getSelection(); 34207 var length = node[getTextContentAccessor()].length; 34208 var start = Math.min(offsets.start, length); 34209 var end = offsets.end === undefined ? start : Math.min(offsets.end, length); 34210 34211 // IE 11 uses modern selection, but doesn't support the extend method. 34212 // Flip backward selections, so we can set with a single range. 34213 if (!selection.extend && start > end) { 34214 var temp = end; 34215 end = start; 34216 start = temp; 34217 } 34218 34219 var startMarker = getNodeForCharacterOffset(node, start); 34220 var endMarker = getNodeForCharacterOffset(node, end); 34221 34222 if (startMarker && endMarker) { 34223 if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) { 34224 return; 34225 } 34226 var range = document.createRange(); 34227 range.setStart(startMarker.node, startMarker.offset); 34228 selection.removeAllRanges(); 34229 34230 if (start > end) { 34231 selection.addRange(range); 34232 selection.extend(endMarker.node, endMarker.offset); 34233 } else { 34234 range.setEnd(endMarker.node, endMarker.offset); 34235 selection.addRange(range); 34236 } 34237 } 34238} 34239 34240function isInDocument(node) { 34241 return containsNode(document.documentElement, node); 34242} 34243 34244/** 34245 * @ReactInputSelection: React input selection module. Based on Selection.js, 34246 * but modified to be suitable for react and has a couple of bug fixes (doesn't 34247 * assume buttons have range selections allowed). 34248 * Input selection module for React. 34249 */ 34250 34251/** 34252 * @hasSelectionCapabilities: we get the element types that support selection 34253 * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart` 34254 * and `selectionEnd` rows. 34255 */ 34256function hasSelectionCapabilities(elem) { 34257 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); 34258 return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true'); 34259} 34260 34261function getSelectionInformation() { 34262 var focusedElem = getActiveElement(); 34263 return { 34264 focusedElem: focusedElem, 34265 selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection$1(focusedElem) : null 34266 }; 34267} 34268 34269/** 34270 * @restoreSelection: If any selection information was potentially lost, 34271 * restore it. This is useful when performing operations that could remove dom 34272 * nodes and place them back in, resulting in focus being lost. 34273 */ 34274function restoreSelection(priorSelectionInformation) { 34275 var curFocusedElem = getActiveElement(); 34276 var priorFocusedElem = priorSelectionInformation.focusedElem; 34277 var priorSelectionRange = priorSelectionInformation.selectionRange; 34278 if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) { 34279 if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) { 34280 setSelection(priorFocusedElem, priorSelectionRange); 34281 } 34282 34283 // Focusing a node can change the scroll position, which is undesirable 34284 var ancestors = []; 34285 var ancestor = priorFocusedElem; 34286 while (ancestor = ancestor.parentNode) { 34287 if (ancestor.nodeType === ELEMENT_NODE) { 34288 ancestors.push({ 34289 element: ancestor, 34290 left: ancestor.scrollLeft, 34291 top: ancestor.scrollTop 34292 }); 34293 } 34294 } 34295 34296 if (typeof priorFocusedElem.focus === 'function') { 34297 priorFocusedElem.focus(); 34298 } 34299 34300 for (var i = 0; i < ancestors.length; i++) { 34301 var info = ancestors[i]; 34302 info.element.scrollLeft = info.left; 34303 info.element.scrollTop = info.top; 34304 } 34305 } 34306} 34307 34308/** 34309 * @getSelection: Gets the selection bounds of a focused textarea, input or 34310 * contentEditable node. 34311 * -@input: Look up selection bounds of this input 34312 * -@return {start: selectionStart, end: selectionEnd} 34313 */ 34314function getSelection$1(input) { 34315 var selection = void 0; 34316 34317 if ('selectionStart' in input) { 34318 // Modern browser with input or textarea. 34319 selection = { 34320 start: input.selectionStart, 34321 end: input.selectionEnd 34322 }; 34323 } else { 34324 // Content editable or old IE textarea. 34325 selection = getOffsets(input); 34326 } 34327 34328 return selection || { start: 0, end: 0 }; 34329} 34330 34331/** 34332 * @setSelection: Sets the selection bounds of a textarea or input and focuses 34333 * the input. 34334 * -@input Set selection bounds of this input or textarea 34335 * -@offsets Object of same form that is returned from get* 34336 */ 34337function setSelection(input, offsets) { 34338 var start = offsets.start, 34339 end = offsets.end; 34340 34341 if (end === undefined) { 34342 end = start; 34343 } 34344 34345 if ('selectionStart' in input) { 34346 input.selectionStart = start; 34347 input.selectionEnd = Math.min(end, input.value.length); 34348 } else { 34349 setOffsets(input, offsets); 34350 } 34351} 34352 34353var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11; 34354 34355var eventTypes$3 = { 34356 select: { 34357 phasedRegistrationNames: { 34358 bubbled: 'onSelect', 34359 captured: 'onSelectCapture' 34360 }, 34361 dependencies: [TOP_BLUR, TOP_CONTEXT_MENU, TOP_FOCUS, TOP_KEY_DOWN, TOP_KEY_UP, TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_SELECTION_CHANGE] 34362 } 34363}; 34364 34365var activeElement$1 = null; 34366var activeElementInst$1 = null; 34367var lastSelection = null; 34368var mouseDown = false; 34369 34370/** 34371 * Get an object which is a unique representation of the current selection. 34372 * 34373 * The return value will not be consistent across nodes or browsers, but 34374 * two identical selections on the same node will return identical objects. 34375 * 34376 * @param {DOMElement} node 34377 * @return {object} 34378 */ 34379function getSelection(node) { 34380 if ('selectionStart' in node && hasSelectionCapabilities(node)) { 34381 return { 34382 start: node.selectionStart, 34383 end: node.selectionEnd 34384 }; 34385 } else if (window.getSelection) { 34386 var selection = window.getSelection(); 34387 return { 34388 anchorNode: selection.anchorNode, 34389 anchorOffset: selection.anchorOffset, 34390 focusNode: selection.focusNode, 34391 focusOffset: selection.focusOffset 34392 }; 34393 } 34394} 34395 34396/** 34397 * Poll selection to see whether it's changed. 34398 * 34399 * @param {object} nativeEvent 34400 * @return {?SyntheticEvent} 34401 */ 34402function constructSelectEvent(nativeEvent, nativeEventTarget) { 34403 // Ensure we have the right element, and that the user is not dragging a 34404 // selection (this matches native `select` event behavior). In HTML5, select 34405 // fires only on input and textarea thus if there's no focused element we 34406 // won't dispatch. 34407 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement()) { 34408 return null; 34409 } 34410 34411 // Only fire when selection has actually changed. 34412 var currentSelection = getSelection(activeElement$1); 34413 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { 34414 lastSelection = currentSelection; 34415 34416 var syntheticEvent = SyntheticEvent$1.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget); 34417 34418 syntheticEvent.type = 'select'; 34419 syntheticEvent.target = activeElement$1; 34420 34421 accumulateTwoPhaseDispatches(syntheticEvent); 34422 34423 return syntheticEvent; 34424 } 34425 34426 return null; 34427} 34428 34429/** 34430 * This plugin creates an `onSelect` event that normalizes select events 34431 * across form elements. 34432 * 34433 * Supported elements are: 34434 * - input (see `isTextInputElement`) 34435 * - textarea 34436 * - contentEditable 34437 * 34438 * This differs from native browser implementations in the following ways: 34439 * - Fires on contentEditable fields as well as inputs. 34440 * - Fires for collapsed selection. 34441 * - Fires after user input. 34442 */ 34443var SelectEventPlugin = { 34444 eventTypes: eventTypes$3, 34445 34446 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { 34447 var doc = nativeEventTarget.window === nativeEventTarget ? nativeEventTarget.document : nativeEventTarget.nodeType === DOCUMENT_NODE ? nativeEventTarget : nativeEventTarget.ownerDocument; 34448 // Track whether all listeners exists for this plugin. If none exist, we do 34449 // not extract events. See #3639. 34450 if (!doc || !isListeningToAllDependencies('onSelect', doc)) { 34451 return null; 34452 } 34453 34454 var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window; 34455 34456 switch (topLevelType) { 34457 // Track the input node that has focus. 34458 case TOP_FOCUS: 34459 if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') { 34460 activeElement$1 = targetNode; 34461 activeElementInst$1 = targetInst; 34462 lastSelection = null; 34463 } 34464 break; 34465 case TOP_BLUR: 34466 activeElement$1 = null; 34467 activeElementInst$1 = null; 34468 lastSelection = null; 34469 break; 34470 // Don't fire the event while the user is dragging. This matches the 34471 // semantics of the native select event. 34472 case TOP_MOUSE_DOWN: 34473 mouseDown = true; 34474 break; 34475 case TOP_CONTEXT_MENU: 34476 case TOP_MOUSE_UP: 34477 mouseDown = false; 34478 return constructSelectEvent(nativeEvent, nativeEventTarget); 34479 // Chrome and IE fire non-standard event when selection is changed (and 34480 // sometimes when it hasn't). IE's event fires out of order with respect 34481 // to key and input events on deletion, so we discard it. 34482 // 34483 // Firefox doesn't support selectionchange, so check selection status 34484 // after each key entry. The selection changes after keydown and before 34485 // keyup, but we check on keydown as well in the case of holding down a 34486 // key, when multiple keydown events are fired but only one keyup is. 34487 // This is also our approach for IE handling, for the reason above. 34488 case TOP_SELECTION_CHANGE: 34489 if (skipSelectionChangeEvent) { 34490 break; 34491 } 34492 // falls through 34493 case TOP_KEY_DOWN: 34494 case TOP_KEY_UP: 34495 return constructSelectEvent(nativeEvent, nativeEventTarget); 34496 } 34497 34498 return null; 34499 } 34500}; 34501 34502/** 34503 * Inject modules for resolving DOM hierarchy and plugin ordering. 34504 */ 34505injection.injectEventPluginOrder(DOMEventPluginOrder); 34506injection$1.injectComponentTree(ReactDOMComponentTree); 34507 34508/** 34509 * Some important event plugins included by default (without having to require 34510 * them). 34511 */ 34512injection.injectEventPluginsByName({ 34513 SimpleEventPlugin: SimpleEventPlugin, 34514 EnterLeaveEventPlugin: EnterLeaveEventPlugin, 34515 ChangeEventPlugin: ChangeEventPlugin, 34516 SelectEventPlugin: SelectEventPlugin, 34517 BeforeInputEventPlugin: BeforeInputEventPlugin 34518}); 34519 34520// We capture a local reference to any global, in case it gets polyfilled after 34521// this module is initially evaluated. 34522// We want to be using a consistent implementation. 34523 34524var localRequestAnimationFrame$1 = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined; 34525 34526/** 34527 * A scheduling library to allow scheduling work with more granular priority and 34528 * control than requestAnimationFrame and requestIdleCallback. 34529 * Current TODO items: 34530 * X- Pull out the scheduleWork polyfill built into React 34531 * X- Initial test coverage 34532 * X- Support for multiple callbacks 34533 * - Support for two priorities; serial and deferred 34534 * - Better test coverage 34535 * - Better docblock 34536 * - Polish documentation, API 34537 */ 34538 34539// This is a built-in polyfill for requestIdleCallback. It works by scheduling 34540// a requestAnimationFrame, storing the time for the start of the frame, then 34541// scheduling a postMessage which gets scheduled after paint. Within the 34542// postMessage handler do as much work as possible until time + frame rate. 34543// By separating the idle call into a separate event tick we ensure that 34544// layout, paint and other browser work is counted against the available time. 34545// The frame rate is dynamically adjusted. 34546 34547// We capture a local reference to any global, in case it gets polyfilled after 34548// this module is initially evaluated. 34549// We want to be using a consistent implementation. 34550var localDate = Date; 34551var localSetTimeout = setTimeout; 34552var localClearTimeout = clearTimeout; 34553 34554var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; 34555 34556var now$1 = void 0; 34557if (hasNativePerformanceNow) { 34558 var Performance = performance; 34559 now$1 = function () { 34560 return Performance.now(); 34561 }; 34562} else { 34563 now$1 = function () { 34564 return localDate.now(); 34565 }; 34566} 34567 34568var scheduleWork = void 0; 34569var cancelScheduledWork = void 0; 34570 34571if (!ExecutionEnvironment.canUseDOM) { 34572 var timeoutIds = new Map(); 34573 34574 scheduleWork = function (callback, options) { 34575 // keeping return type consistent 34576 var callbackConfig = { 34577 scheduledCallback: callback, 34578 timeoutTime: 0, 34579 next: null, 34580 prev: null 34581 }; 34582 var timeoutId = localSetTimeout(function () { 34583 callback({ 34584 timeRemaining: function () { 34585 return Infinity; 34586 }, 34587 34588 didTimeout: false 34589 }); 34590 }); 34591 timeoutIds.set(callback, timeoutId); 34592 return callbackConfig; 34593 }; 34594 cancelScheduledWork = function (callbackId) { 34595 var callback = callbackId.scheduledCallback; 34596 var timeoutId = timeoutIds.get(callback); 34597 timeoutIds.delete(callbackId); 34598 localClearTimeout(timeoutId); 34599 }; 34600} else { 34601 { 34602 if (typeof localRequestAnimationFrame$1 !== 'function') { 34603 warning(false, 'React depends on requestAnimationFrame. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); 34604 } 34605 } 34606 34607 var localRequestAnimationFrame = typeof localRequestAnimationFrame$1 === 'function' ? localRequestAnimationFrame$1 : function (callback) { 34608 invariant(false, 'React depends on requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills'); 34609 }; 34610 34611 var headOfPendingCallbacksLinkedList = null; 34612 var tailOfPendingCallbacksLinkedList = null; 34613 34614 // We track what the next soonest timeoutTime is, to be able to quickly tell 34615 // if none of the scheduled callbacks have timed out. 34616 var nextSoonestTimeoutTime = -1; 34617 34618 var isIdleScheduled = false; 34619 var isAnimationFrameScheduled = false; 34620 34621 var frameDeadline = 0; 34622 // We start out assuming that we run at 30fps but then the heuristic tracking 34623 // will adjust this value to a faster fps if we get more frequent animation 34624 // frames. 34625 var previousFrameTime = 33; 34626 var activeFrameTime = 33; 34627 34628 var frameDeadlineObject = { 34629 didTimeout: false, 34630 timeRemaining: function () { 34631 var remaining = frameDeadline - now$1(); 34632 return remaining > 0 ? remaining : 0; 34633 } 34634 }; 34635 34636 /** 34637 * Handles the case where a callback errors: 34638 * - don't catch the error, because this changes debugging behavior 34639 * - do start a new postMessage callback, to call any remaining callbacks, 34640 * - but only if there is an error, so there is not extra overhead. 34641 */ 34642 var callUnsafely = function (callbackConfig, arg) { 34643 var callback = callbackConfig.scheduledCallback; 34644 var finishedCalling = false; 34645 try { 34646 callback(arg); 34647 finishedCalling = true; 34648 } finally { 34649 // always remove it from linked list 34650 cancelScheduledWork(callbackConfig); 34651 34652 if (!finishedCalling) { 34653 // an error must have been thrown 34654 isIdleScheduled = true; 34655 window.postMessage(messageKey, '*'); 34656 } 34657 } 34658 }; 34659 34660 /** 34661 * Checks for timed out callbacks, runs them, and then checks again to see if 34662 * any more have timed out. 34663 * Keeps doing this until there are none which have currently timed out. 34664 */ 34665 var callTimedOutCallbacks = function () { 34666 if (headOfPendingCallbacksLinkedList === null) { 34667 return; 34668 } 34669 34670 var currentTime = now$1(); 34671 // TODO: this would be more efficient if deferred callbacks are stored in 34672 // min heap. 34673 // Or in a linked list with links for both timeoutTime order and insertion 34674 // order. 34675 // For now an easy compromise is the current approach: 34676 // Keep a pointer to the soonest timeoutTime, and check that first. 34677 // If it has not expired, we can skip traversing the whole list. 34678 // If it has expired, then we step through all the callbacks. 34679 if (nextSoonestTimeoutTime === -1 || nextSoonestTimeoutTime > currentTime) { 34680 // We know that none of them have timed out yet. 34681 return; 34682 } 34683 // NOTE: we intentionally wait to update the nextSoonestTimeoutTime until 34684 // after successfully calling any timed out callbacks. 34685 // If a timed out callback throws an error, we could get stuck in a state 34686 // where the nextSoonestTimeoutTime was set wrong. 34687 var updatedNextSoonestTimeoutTime = -1; // we will update nextSoonestTimeoutTime below 34688 var timedOutCallbacks = []; 34689 34690 // iterate once to find timed out callbacks and find nextSoonestTimeoutTime 34691 var currentCallbackConfig = headOfPendingCallbacksLinkedList; 34692 while (currentCallbackConfig !== null) { 34693 var _timeoutTime = currentCallbackConfig.timeoutTime; 34694 if (_timeoutTime !== -1 && _timeoutTime <= currentTime) { 34695 // it has timed out! 34696 timedOutCallbacks.push(currentCallbackConfig); 34697 } else { 34698 if (_timeoutTime !== -1 && (updatedNextSoonestTimeoutTime === -1 || _timeoutTime < updatedNextSoonestTimeoutTime)) { 34699 updatedNextSoonestTimeoutTime = _timeoutTime; 34700 } 34701 } 34702 currentCallbackConfig = currentCallbackConfig.next; 34703 } 34704 34705 if (timedOutCallbacks.length > 0) { 34706 frameDeadlineObject.didTimeout = true; 34707 for (var i = 0, len = timedOutCallbacks.length; i < len; i++) { 34708 callUnsafely(timedOutCallbacks[i], frameDeadlineObject); 34709 } 34710 } 34711 34712 // NOTE: we intentionally wait to update the nextSoonestTimeoutTime until 34713 // after successfully calling any timed out callbacks. 34714 nextSoonestTimeoutTime = updatedNextSoonestTimeoutTime; 34715 }; 34716 34717 // We use the postMessage trick to defer idle work until after the repaint. 34718 var messageKey = '__reactIdleCallback$' + Math.random().toString(36).slice(2); 34719 var idleTick = function (event) { 34720 if (event.source !== window || event.data !== messageKey) { 34721 return; 34722 } 34723 isIdleScheduled = false; 34724 34725 if (headOfPendingCallbacksLinkedList === null) { 34726 return; 34727 } 34728 34729 // First call anything which has timed out, until we have caught up. 34730 callTimedOutCallbacks(); 34731 34732 var currentTime = now$1(); 34733 // Next, as long as we have idle time, try calling more callbacks. 34734 while (frameDeadline - currentTime > 0 && headOfPendingCallbacksLinkedList !== null) { 34735 var latestCallbackConfig = headOfPendingCallbacksLinkedList; 34736 frameDeadlineObject.didTimeout = false; 34737 // callUnsafely will remove it from the head of the linked list 34738 callUnsafely(latestCallbackConfig, frameDeadlineObject); 34739 currentTime = now$1(); 34740 } 34741 if (headOfPendingCallbacksLinkedList !== null) { 34742 if (!isAnimationFrameScheduled) { 34743 // Schedule another animation callback so we retry later. 34744 isAnimationFrameScheduled = true; 34745 localRequestAnimationFrame(animationTick); 34746 } 34747 } 34748 }; 34749 // Assumes that we have addEventListener in this environment. Might need 34750 // something better for old IE. 34751 window.addEventListener('message', idleTick, false); 34752 34753 var animationTick = function (rafTime) { 34754 isAnimationFrameScheduled = false; 34755 var nextFrameTime = rafTime - frameDeadline + activeFrameTime; 34756 if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) { 34757 if (nextFrameTime < 8) { 34758 // Defensive coding. We don't support higher frame rates than 120hz. 34759 // If we get lower than that, it is probably a bug. 34760 nextFrameTime = 8; 34761 } 34762 // If one frame goes long, then the next one can be short to catch up. 34763 // If two frames are short in a row, then that's an indication that we 34764 // actually have a higher frame rate than what we're currently optimizing. 34765 // We adjust our heuristic dynamically accordingly. For example, if we're 34766 // running on 120hz display or 90hz VR display. 34767 // Take the max of the two in case one of them was an anomaly due to 34768 // missed frame deadlines. 34769 activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime; 34770 } else { 34771 previousFrameTime = nextFrameTime; 34772 } 34773 frameDeadline = rafTime + activeFrameTime; 34774 if (!isIdleScheduled) { 34775 isIdleScheduled = true; 34776 window.postMessage(messageKey, '*'); 34777 } 34778 }; 34779 34780 scheduleWork = function (callback, options) /* CallbackConfigType */{ 34781 var timeoutTime = -1; 34782 if (options != null && typeof options.timeout === 'number') { 34783 timeoutTime = now$1() + options.timeout; 34784 } 34785 if (nextSoonestTimeoutTime === -1 || timeoutTime !== -1 && timeoutTime < nextSoonestTimeoutTime) { 34786 nextSoonestTimeoutTime = timeoutTime; 34787 } 34788 34789 var scheduledCallbackConfig = { 34790 scheduledCallback: callback, 34791 timeoutTime: timeoutTime, 34792 prev: null, 34793 next: null 34794 }; 34795 if (headOfPendingCallbacksLinkedList === null) { 34796 // Make this callback the head and tail of our list 34797 headOfPendingCallbacksLinkedList = scheduledCallbackConfig; 34798 tailOfPendingCallbacksLinkedList = scheduledCallbackConfig; 34799 } else { 34800 // Add latest callback as the new tail of the list 34801 scheduledCallbackConfig.prev = tailOfPendingCallbacksLinkedList; 34802 // renaming for clarity 34803 var oldTailOfPendingCallbacksLinkedList = tailOfPendingCallbacksLinkedList; 34804 if (oldTailOfPendingCallbacksLinkedList !== null) { 34805 oldTailOfPendingCallbacksLinkedList.next = scheduledCallbackConfig; 34806 } 34807 tailOfPendingCallbacksLinkedList = scheduledCallbackConfig; 34808 } 34809 34810 if (!isAnimationFrameScheduled) { 34811 // If rAF didn't already schedule one, we need to schedule a frame. 34812 // TODO: If this rAF doesn't materialize because the browser throttles, we 34813 // might want to still have setTimeout trigger scheduleWork as a backup to ensure 34814 // that we keep performing work. 34815 isAnimationFrameScheduled = true; 34816 localRequestAnimationFrame(animationTick); 34817 } 34818 return scheduledCallbackConfig; 34819 }; 34820 34821 cancelScheduledWork = function (callbackConfig /* CallbackConfigType */ 34822 ) { 34823 if (callbackConfig.prev === null && headOfPendingCallbacksLinkedList !== callbackConfig) { 34824 // this callbackConfig has already been cancelled. 34825 // cancelScheduledWork should be idempotent, a no-op after first call. 34826 return; 34827 } 34828 34829 /** 34830 * There are four possible cases: 34831 * - Head/nodeToRemove/Tail -> null 34832 * In this case we set Head and Tail to null. 34833 * - Head -> ... middle nodes... -> Tail/nodeToRemove 34834 * In this case we point the middle.next to null and put middle as the new 34835 * Tail. 34836 * - Head/nodeToRemove -> ...middle nodes... -> Tail 34837 * In this case we point the middle.prev at null and move the Head to 34838 * middle. 34839 * - Head -> ... ?some nodes ... -> nodeToRemove -> ... ?some nodes ... -> Tail 34840 * In this case we point the Head.next to the Tail and the Tail.prev to 34841 * the Head. 34842 */ 34843 var next = callbackConfig.next; 34844 var prev = callbackConfig.prev; 34845 callbackConfig.next = null; 34846 callbackConfig.prev = null; 34847 if (next !== null) { 34848 // we have a next 34849 34850 if (prev !== null) { 34851 // we have a prev 34852 34853 // callbackConfig is somewhere in the middle of a list of 3 or more nodes. 34854 prev.next = next; 34855 next.prev = prev; 34856 return; 34857 } else { 34858 // there is a next but not a previous one; 34859 // callbackConfig is the head of a list of 2 or more other nodes. 34860 next.prev = null; 34861 headOfPendingCallbacksLinkedList = next; 34862 return; 34863 } 34864 } else { 34865 // there is no next callback config; this must the tail of the list 34866 34867 if (prev !== null) { 34868 // we have a prev 34869 34870 // callbackConfig is the tail of a list of 2 or more other nodes. 34871 prev.next = null; 34872 tailOfPendingCallbacksLinkedList = prev; 34873 return; 34874 } else { 34875 // there is no previous callback config; 34876 // callbackConfig is the only thing in the linked list, 34877 // so both head and tail point to it. 34878 headOfPendingCallbacksLinkedList = null; 34879 tailOfPendingCallbacksLinkedList = null; 34880 return; 34881 } 34882 } 34883 }; 34884} 34885 34886var didWarnSelectedSetOnOption = false; 34887 34888function flattenChildren(children) { 34889 var content = ''; 34890 34891 // Flatten children and warn if they aren't strings or numbers; 34892 // invalid types are ignored. 34893 // We can silently skip them because invalid DOM nesting warning 34894 // catches these cases in Fiber. 34895 React.Children.forEach(children, function (child) { 34896 if (child == null) { 34897 return; 34898 } 34899 if (typeof child === 'string' || typeof child === 'number') { 34900 content += child; 34901 } 34902 }); 34903 34904 return content; 34905} 34906 34907/** 34908 * Implements an <option> host component that warns when `selected` is set. 34909 */ 34910 34911function validateProps(element, props) { 34912 // TODO (yungsters): Remove support for `selected` in <option>. 34913 { 34914 if (props.selected != null && !didWarnSelectedSetOnOption) { 34915 warning(false, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.'); 34916 didWarnSelectedSetOnOption = true; 34917 } 34918 } 34919} 34920 34921function postMountWrapper$1(element, props) { 34922 // value="" should make a value attribute (#6219) 34923 if (props.value != null) { 34924 element.setAttribute('value', props.value); 34925 } 34926} 34927 34928function getHostProps$1(element, props) { 34929 var hostProps = _assign({ children: undefined }, props); 34930 var content = flattenChildren(props.children); 34931 34932 if (content) { 34933 hostProps.children = content; 34934 } 34935 34936 return hostProps; 34937} 34938 34939// TODO: direct imports like some-package/src/* are bad. Fix me. 34940var getCurrentFiberOwnerName$3 = ReactDebugCurrentFiber.getCurrentFiberOwnerName; 34941var getCurrentFiberStackAddendum$3 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 34942 34943 34944var didWarnValueDefaultValue$1 = void 0; 34945 34946{ 34947 didWarnValueDefaultValue$1 = false; 34948} 34949 34950function getDeclarationErrorAddendum() { 34951 var ownerName = getCurrentFiberOwnerName$3(); 34952 if (ownerName) { 34953 return '\n\nCheck the render method of `' + ownerName + '`.'; 34954 } 34955 return ''; 34956} 34957 34958var valuePropNames = ['value', 'defaultValue']; 34959 34960/** 34961 * Validation function for `value` and `defaultValue`. 34962 */ 34963function checkSelectPropTypes(props) { 34964 ReactControlledValuePropTypes.checkPropTypes('select', props, getCurrentFiberStackAddendum$3); 34965 34966 for (var i = 0; i < valuePropNames.length; i++) { 34967 var propName = valuePropNames[i]; 34968 if (props[propName] == null) { 34969 continue; 34970 } 34971 var isArray = Array.isArray(props[propName]); 34972 if (props.multiple && !isArray) { 34973 warning(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum()); 34974 } else if (!props.multiple && isArray) { 34975 warning(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum()); 34976 } 34977 } 34978} 34979 34980function updateOptions(node, multiple, propValue, setDefaultSelected) { 34981 var options = node.options; 34982 34983 if (multiple) { 34984 var selectedValues = propValue; 34985 var selectedValue = {}; 34986 for (var i = 0; i < selectedValues.length; i++) { 34987 // Prefix to avoid chaos with special keys. 34988 selectedValue['$' + selectedValues[i]] = true; 34989 } 34990 for (var _i = 0; _i < options.length; _i++) { 34991 var selected = selectedValue.hasOwnProperty('$' + options[_i].value); 34992 if (options[_i].selected !== selected) { 34993 options[_i].selected = selected; 34994 } 34995 if (selected && setDefaultSelected) { 34996 options[_i].defaultSelected = true; 34997 } 34998 } 34999 } else { 35000 // Do not set `select.value` as exact behavior isn't consistent across all 35001 // browsers for all cases. 35002 var _selectedValue = '' + propValue; 35003 var defaultSelected = null; 35004 for (var _i2 = 0; _i2 < options.length; _i2++) { 35005 if (options[_i2].value === _selectedValue) { 35006 options[_i2].selected = true; 35007 if (setDefaultSelected) { 35008 options[_i2].defaultSelected = true; 35009 } 35010 return; 35011 } 35012 if (defaultSelected === null && !options[_i2].disabled) { 35013 defaultSelected = options[_i2]; 35014 } 35015 } 35016 if (defaultSelected !== null) { 35017 defaultSelected.selected = true; 35018 } 35019 } 35020} 35021 35022/** 35023 * Implements a <select> host component that allows optionally setting the 35024 * props `value` and `defaultValue`. If `multiple` is false, the prop must be a 35025 * stringable. If `multiple` is true, the prop must be an array of stringables. 35026 * 35027 * If `value` is not supplied (or null/undefined), user actions that change the 35028 * selected option will trigger updates to the rendered options. 35029 * 35030 * If it is supplied (and not null/undefined), the rendered options will not 35031 * update in response to user actions. Instead, the `value` prop must change in 35032 * order for the rendered options to update. 35033 * 35034 * If `defaultValue` is provided, any options with the supplied values will be 35035 * selected. 35036 */ 35037 35038function getHostProps$2(element, props) { 35039 return _assign({}, props, { 35040 value: undefined 35041 }); 35042} 35043 35044function initWrapperState$1(element, props) { 35045 var node = element; 35046 { 35047 checkSelectPropTypes(props); 35048 } 35049 35050 var value = props.value; 35051 node._wrapperState = { 35052 initialValue: value != null ? value : props.defaultValue, 35053 wasMultiple: !!props.multiple 35054 }; 35055 35056 { 35057 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) { 35058 warning(false, 'Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components'); 35059 didWarnValueDefaultValue$1 = true; 35060 } 35061 } 35062} 35063 35064function postMountWrapper$2(element, props) { 35065 var node = element; 35066 node.multiple = !!props.multiple; 35067 var value = props.value; 35068 if (value != null) { 35069 updateOptions(node, !!props.multiple, value, false); 35070 } else if (props.defaultValue != null) { 35071 updateOptions(node, !!props.multiple, props.defaultValue, true); 35072 } 35073} 35074 35075function postUpdateWrapper(element, props) { 35076 var node = element; 35077 // After the initial mount, we control selected-ness manually so don't pass 35078 // this value down 35079 node._wrapperState.initialValue = undefined; 35080 35081 var wasMultiple = node._wrapperState.wasMultiple; 35082 node._wrapperState.wasMultiple = !!props.multiple; 35083 35084 var value = props.value; 35085 if (value != null) { 35086 updateOptions(node, !!props.multiple, value, false); 35087 } else if (wasMultiple !== !!props.multiple) { 35088 // For simplicity, reapply `defaultValue` if `multiple` is toggled. 35089 if (props.defaultValue != null) { 35090 updateOptions(node, !!props.multiple, props.defaultValue, true); 35091 } else { 35092 // Revert the select back to its default unselected state. 35093 updateOptions(node, !!props.multiple, props.multiple ? [] : '', false); 35094 } 35095 } 35096} 35097 35098function restoreControlledState$2(element, props) { 35099 var node = element; 35100 var value = props.value; 35101 35102 if (value != null) { 35103 updateOptions(node, !!props.multiple, value, false); 35104 } 35105} 35106 35107// TODO: direct imports like some-package/src/* are bad. Fix me. 35108var getCurrentFiberStackAddendum$4 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 35109 35110var didWarnValDefaultVal = false; 35111 35112/** 35113 * Implements a <textarea> host component that allows setting `value`, and 35114 * `defaultValue`. This differs from the traditional DOM API because value is 35115 * usually set as PCDATA children. 35116 * 35117 * If `value` is not supplied (or null/undefined), user actions that affect the 35118 * value will trigger updates to the element. 35119 * 35120 * If `value` is supplied (and not null/undefined), the rendered element will 35121 * not trigger updates to the element. Instead, the `value` prop must change in 35122 * order for the rendered element to be updated. 35123 * 35124 * The rendered element will be initialized with an empty value, the prop 35125 * `defaultValue` if specified, or the children content (deprecated). 35126 */ 35127 35128function getHostProps$3(element, props) { 35129 var node = element; 35130 !(props.dangerouslySetInnerHTML == null) ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : void 0; 35131 35132 // Always set children to the same thing. In IE9, the selection range will 35133 // get reset if `textContent` is mutated. We could add a check in setTextContent 35134 // to only set the value if/when the value differs from the node value (which would 35135 // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this 35136 // solution. The value can be a boolean or object so that's why it's forced 35137 // to be a string. 35138 var hostProps = _assign({}, props, { 35139 value: undefined, 35140 defaultValue: undefined, 35141 children: '' + node._wrapperState.initialValue 35142 }); 35143 35144 return hostProps; 35145} 35146 35147function initWrapperState$2(element, props) { 35148 var node = element; 35149 { 35150 ReactControlledValuePropTypes.checkPropTypes('textarea', props, getCurrentFiberStackAddendum$4); 35151 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) { 35152 warning(false, 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components'); 35153 didWarnValDefaultVal = true; 35154 } 35155 } 35156 35157 var initialValue = props.value; 35158 35159 // Only bother fetching default value if we're going to use it 35160 if (initialValue == null) { 35161 var defaultValue = props.defaultValue; 35162 // TODO (yungsters): Remove support for children content in <textarea>. 35163 var children = props.children; 35164 if (children != null) { 35165 { 35166 warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.'); 35167 } 35168 !(defaultValue == null) ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : void 0; 35169 if (Array.isArray(children)) { 35170 !(children.length <= 1) ? invariant(false, '<textarea> can only have at most one child.') : void 0; 35171 children = children[0]; 35172 } 35173 35174 defaultValue = '' + children; 35175 } 35176 if (defaultValue == null) { 35177 defaultValue = ''; 35178 } 35179 initialValue = defaultValue; 35180 } 35181 35182 node._wrapperState = { 35183 initialValue: '' + initialValue 35184 }; 35185} 35186 35187function updateWrapper$1(element, props) { 35188 var node = element; 35189 var value = props.value; 35190 if (value != null) { 35191 // Cast `value` to a string to ensure the value is set correctly. While 35192 // browsers typically do this as necessary, jsdom doesn't. 35193 var newValue = '' + value; 35194 35195 // To avoid side effects (such as losing text selection), only set value if changed 35196 if (newValue !== node.value) { 35197 node.value = newValue; 35198 } 35199 if (props.defaultValue == null) { 35200 node.defaultValue = newValue; 35201 } 35202 } 35203 if (props.defaultValue != null) { 35204 node.defaultValue = props.defaultValue; 35205 } 35206} 35207 35208function postMountWrapper$3(element, props) { 35209 var node = element; 35210 // This is in postMount because we need access to the DOM node, which is not 35211 // available until after the component has mounted. 35212 var textContent = node.textContent; 35213 35214 // Only set node.value if textContent is equal to the expected 35215 // initial value. In IE10/IE11 there is a bug where the placeholder attribute 35216 // will populate textContent as well. 35217 // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/ 35218 if (textContent === node._wrapperState.initialValue) { 35219 node.value = textContent; 35220 } 35221} 35222 35223function restoreControlledState$3(element, props) { 35224 // DOM component is still mounted; update 35225 updateWrapper$1(element, props); 35226} 35227 35228var HTML_NAMESPACE$1 = 'http://www.w3.org/1999/xhtml'; 35229var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; 35230var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; 35231 35232var Namespaces = { 35233 html: HTML_NAMESPACE$1, 35234 mathml: MATH_NAMESPACE, 35235 svg: SVG_NAMESPACE 35236}; 35237 35238// Assumes there is no parent namespace. 35239function getIntrinsicNamespace(type) { 35240 switch (type) { 35241 case 'svg': 35242 return SVG_NAMESPACE; 35243 case 'math': 35244 return MATH_NAMESPACE; 35245 default: 35246 return HTML_NAMESPACE$1; 35247 } 35248} 35249 35250function getChildNamespace(parentNamespace, type) { 35251 if (parentNamespace == null || parentNamespace === HTML_NAMESPACE$1) { 35252 // No (or default) parent namespace: potential entry point. 35253 return getIntrinsicNamespace(type); 35254 } 35255 if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') { 35256 // We're leaving SVG. 35257 return HTML_NAMESPACE$1; 35258 } 35259 // By default, pass namespace below. 35260 return parentNamespace; 35261} 35262 35263/* globals MSApp */ 35264 35265/** 35266 * Create a function which has 'unsafe' privileges (required by windows8 apps) 35267 */ 35268var createMicrosoftUnsafeLocalFunction = function (func) { 35269 if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) { 35270 return function (arg0, arg1, arg2, arg3) { 35271 MSApp.execUnsafeLocalFunction(function () { 35272 return func(arg0, arg1, arg2, arg3); 35273 }); 35274 }; 35275 } else { 35276 return func; 35277 } 35278}; 35279 35280// SVG temp container for IE lacking innerHTML 35281var reusableSVGContainer = void 0; 35282 35283/** 35284 * Set the innerHTML property of a node 35285 * 35286 * @param {DOMElement} node 35287 * @param {string} html 35288 * @internal 35289 */ 35290var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) { 35291 // IE does not have innerHTML for SVG nodes, so instead we inject the 35292 // new markup in a temp node and then move the child nodes across into 35293 // the target node 35294 35295 if (node.namespaceURI === Namespaces.svg && !('innerHTML' in node)) { 35296 reusableSVGContainer = reusableSVGContainer || document.createElement('div'); 35297 reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>'; 35298 var svgNode = reusableSVGContainer.firstChild; 35299 while (node.firstChild) { 35300 node.removeChild(node.firstChild); 35301 } 35302 while (svgNode.firstChild) { 35303 node.appendChild(svgNode.firstChild); 35304 } 35305 } else { 35306 node.innerHTML = html; 35307 } 35308}); 35309 35310/** 35311 * Set the textContent property of a node. For text updates, it's faster 35312 * to set the `nodeValue` of the Text node directly instead of using 35313 * `.textContent` which will remove the existing node and create a new one. 35314 * 35315 * @param {DOMElement} node 35316 * @param {string} text 35317 * @internal 35318 */ 35319var setTextContent = function (node, text) { 35320 if (text) { 35321 var firstChild = node.firstChild; 35322 35323 if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) { 35324 firstChild.nodeValue = text; 35325 return; 35326 } 35327 } 35328 node.textContent = text; 35329}; 35330 35331/** 35332 * CSS properties which accept numbers but are not in units of "px". 35333 */ 35334var isUnitlessNumber = { 35335 animationIterationCount: true, 35336 borderImageOutset: true, 35337 borderImageSlice: true, 35338 borderImageWidth: true, 35339 boxFlex: true, 35340 boxFlexGroup: true, 35341 boxOrdinalGroup: true, 35342 columnCount: true, 35343 columns: true, 35344 flex: true, 35345 flexGrow: true, 35346 flexPositive: true, 35347 flexShrink: true, 35348 flexNegative: true, 35349 flexOrder: true, 35350 gridRow: true, 35351 gridRowEnd: true, 35352 gridRowSpan: true, 35353 gridRowStart: true, 35354 gridColumn: true, 35355 gridColumnEnd: true, 35356 gridColumnSpan: true, 35357 gridColumnStart: true, 35358 fontWeight: true, 35359 lineClamp: true, 35360 lineHeight: true, 35361 opacity: true, 35362 order: true, 35363 orphans: true, 35364 tabSize: true, 35365 widows: true, 35366 zIndex: true, 35367 zoom: true, 35368 35369 // SVG-related properties 35370 fillOpacity: true, 35371 floodOpacity: true, 35372 stopOpacity: true, 35373 strokeDasharray: true, 35374 strokeDashoffset: true, 35375 strokeMiterlimit: true, 35376 strokeOpacity: true, 35377 strokeWidth: true 35378}; 35379 35380/** 35381 * @param {string} prefix vendor-specific prefix, eg: Webkit 35382 * @param {string} key style name, eg: transitionDuration 35383 * @return {string} style name prefixed with `prefix`, properly camelCased, eg: 35384 * WebkitTransitionDuration 35385 */ 35386function prefixKey(prefix, key) { 35387 return prefix + key.charAt(0).toUpperCase() + key.substring(1); 35388} 35389 35390/** 35391 * Support style names that may come passed in prefixed by adding permutations 35392 * of vendor prefixes. 35393 */ 35394var prefixes = ['Webkit', 'ms', 'Moz', 'O']; 35395 35396// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an 35397// infinite loop, because it iterates over the newly added props too. 35398Object.keys(isUnitlessNumber).forEach(function (prop) { 35399 prefixes.forEach(function (prefix) { 35400 isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; 35401 }); 35402}); 35403 35404/** 35405 * Convert a value into the proper css writable value. The style name `name` 35406 * should be logical (no hyphens), as specified 35407 * in `CSSProperty.isUnitlessNumber`. 35408 * 35409 * @param {string} name CSS property name such as `topMargin`. 35410 * @param {*} value CSS property value such as `10px`. 35411 * @return {string} Normalized style value with dimensions applied. 35412 */ 35413function dangerousStyleValue(name, value, isCustomProperty) { 35414 // Note that we've removed escapeTextForBrowser() calls here since the 35415 // whole string will be escaped when the attribute is injected into 35416 // the markup. If you provide unsafe user data here they can inject 35417 // arbitrary CSS which may be problematic (I couldn't repro this): 35418 // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet 35419 // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/ 35420 // This is not an XSS hole but instead a potential CSS injection issue 35421 // which has lead to a greater discussion about how we're going to 35422 // trust URLs moving forward. See #2115901 35423 35424 var isEmpty = value == null || typeof value === 'boolean' || value === ''; 35425 if (isEmpty) { 35426 return ''; 35427 } 35428 35429 if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) { 35430 return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers 35431 } 35432 35433 return ('' + value).trim(); 35434} 35435 35436var warnValidStyle = emptyFunction; 35437 35438{ 35439 // 'msTransform' is correct, but the other prefixes should be capitalized 35440 var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; 35441 35442 // style values shouldn't contain a semicolon 35443 var badStyleValueWithSemicolonPattern = /;\s*$/; 35444 35445 var warnedStyleNames = {}; 35446 var warnedStyleValues = {}; 35447 var warnedForNaNValue = false; 35448 var warnedForInfinityValue = false; 35449 35450 var warnHyphenatedStyleName = function (name, getStack) { 35451 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { 35452 return; 35453 } 35454 35455 warnedStyleNames[name] = true; 35456 warning(false, 'Unsupported style property %s. Did you mean %s?%s', name, camelizeStyleName(name), getStack()); 35457 }; 35458 35459 var warnBadVendoredStyleName = function (name, getStack) { 35460 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { 35461 return; 35462 } 35463 35464 warnedStyleNames[name] = true; 35465 warning(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?%s', name, name.charAt(0).toUpperCase() + name.slice(1), getStack()); 35466 }; 35467 35468 var warnStyleValueWithSemicolon = function (name, value, getStack) { 35469 if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { 35470 return; 35471 } 35472 35473 warnedStyleValues[value] = true; 35474 warning(false, "Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.%s', name, value.replace(badStyleValueWithSemicolonPattern, ''), getStack()); 35475 }; 35476 35477 var warnStyleValueIsNaN = function (name, value, getStack) { 35478 if (warnedForNaNValue) { 35479 return; 35480 } 35481 35482 warnedForNaNValue = true; 35483 warning(false, '`NaN` is an invalid value for the `%s` css style property.%s', name, getStack()); 35484 }; 35485 35486 var warnStyleValueIsInfinity = function (name, value, getStack) { 35487 if (warnedForInfinityValue) { 35488 return; 35489 } 35490 35491 warnedForInfinityValue = true; 35492 warning(false, '`Infinity` is an invalid value for the `%s` css style property.%s', name, getStack()); 35493 }; 35494 35495 warnValidStyle = function (name, value, getStack) { 35496 if (name.indexOf('-') > -1) { 35497 warnHyphenatedStyleName(name, getStack); 35498 } else if (badVendoredStyleNamePattern.test(name)) { 35499 warnBadVendoredStyleName(name, getStack); 35500 } else if (badStyleValueWithSemicolonPattern.test(value)) { 35501 warnStyleValueWithSemicolon(name, value, getStack); 35502 } 35503 35504 if (typeof value === 'number') { 35505 if (isNaN(value)) { 35506 warnStyleValueIsNaN(name, value, getStack); 35507 } else if (!isFinite(value)) { 35508 warnStyleValueIsInfinity(name, value, getStack); 35509 } 35510 } 35511 }; 35512} 35513 35514var warnValidStyle$1 = warnValidStyle; 35515 35516/** 35517 * Operations for dealing with CSS properties. 35518 */ 35519 35520/** 35521 * This creates a string that is expected to be equivalent to the style 35522 * attribute generated by server-side rendering. It by-passes warnings and 35523 * security checks so it's not safe to use this value for anything other than 35524 * comparison. It is only used in DEV for SSR validation. 35525 */ 35526function createDangerousStringForStyles(styles) { 35527 { 35528 var serialized = ''; 35529 var delimiter = ''; 35530 for (var styleName in styles) { 35531 if (!styles.hasOwnProperty(styleName)) { 35532 continue; 35533 } 35534 var styleValue = styles[styleName]; 35535 if (styleValue != null) { 35536 var isCustomProperty = styleName.indexOf('--') === 0; 35537 serialized += delimiter + hyphenateStyleName(styleName) + ':'; 35538 serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty); 35539 35540 delimiter = ';'; 35541 } 35542 } 35543 return serialized || null; 35544 } 35545} 35546 35547/** 35548 * Sets the value for multiple styles on a node. If a value is specified as 35549 * '' (empty string), the corresponding style property will be unset. 35550 * 35551 * @param {DOMElement} node 35552 * @param {object} styles 35553 */ 35554function setValueForStyles(node, styles, getStack) { 35555 var style = node.style; 35556 for (var styleName in styles) { 35557 if (!styles.hasOwnProperty(styleName)) { 35558 continue; 35559 } 35560 var isCustomProperty = styleName.indexOf('--') === 0; 35561 { 35562 if (!isCustomProperty) { 35563 warnValidStyle$1(styleName, styles[styleName], getStack); 35564 } 35565 } 35566 var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty); 35567 if (styleName === 'float') { 35568 styleName = 'cssFloat'; 35569 } 35570 if (isCustomProperty) { 35571 style.setProperty(styleName, styleValue); 35572 } else { 35573 style[styleName] = styleValue; 35574 } 35575 } 35576} 35577 35578// For HTML, certain tags should omit their close tag. We keep a whitelist for 35579// those special-case tags. 35580 35581var omittedCloseTags = { 35582 area: true, 35583 base: true, 35584 br: true, 35585 col: true, 35586 embed: true, 35587 hr: true, 35588 img: true, 35589 input: true, 35590 keygen: true, 35591 link: true, 35592 meta: true, 35593 param: true, 35594 source: true, 35595 track: true, 35596 wbr: true 35597 // NOTE: menuitem's close tag should be omitted, but that causes problems. 35598}; 35599 35600// For HTML, certain tags cannot have children. This has the same purpose as 35601// `omittedCloseTags` except that `menuitem` should still have its closing tag. 35602 35603var voidElementTags = _assign({ 35604 menuitem: true 35605}, omittedCloseTags); 35606 35607var HTML$1 = '__html'; 35608 35609function assertValidProps(tag, props, getStack) { 35610 if (!props) { 35611 return; 35612 } 35613 // Note the use of `==` which checks for null or undefined. 35614 if (voidElementTags[tag]) { 35615 !(props.children == null && props.dangerouslySetInnerHTML == null) ? invariant(false, '%s is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.%s', tag, getStack()) : void 0; 35616 } 35617 if (props.dangerouslySetInnerHTML != null) { 35618 !(props.children == null) ? invariant(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : void 0; 35619 !(typeof props.dangerouslySetInnerHTML === 'object' && HTML$1 in props.dangerouslySetInnerHTML) ? invariant(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.') : void 0; 35620 } 35621 { 35622 !(props.suppressContentEditableWarning || !props.contentEditable || props.children == null) ? warning(false, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.%s', getStack()) : void 0; 35623 } 35624 !(props.style == null || typeof props.style === 'object') ? invariant(false, 'The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + \'em\'}} when using JSX.%s', getStack()) : void 0; 35625} 35626 35627function isCustomComponent(tagName, props) { 35628 if (tagName.indexOf('-') === -1) { 35629 return typeof props.is === 'string'; 35630 } 35631 switch (tagName) { 35632 // These are reserved SVG and MathML elements. 35633 // We don't mind this whitelist too much because we expect it to never grow. 35634 // The alternative is to track the namespace in a few places which is convoluted. 35635 // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts 35636 case 'annotation-xml': 35637 case 'color-profile': 35638 case 'font-face': 35639 case 'font-face-src': 35640 case 'font-face-uri': 35641 case 'font-face-format': 35642 case 'font-face-name': 35643 case 'missing-glyph': 35644 return false; 35645 default: 35646 return true; 35647 } 35648} 35649 35650// When adding attributes to the HTML or SVG whitelist, be sure to 35651// also add them to this module to ensure casing and incorrect name 35652// warnings. 35653var possibleStandardNames = { 35654 // HTML 35655 accept: 'accept', 35656 acceptcharset: 'acceptCharset', 35657 'accept-charset': 'acceptCharset', 35658 accesskey: 'accessKey', 35659 action: 'action', 35660 allowfullscreen: 'allowFullScreen', 35661 alt: 'alt', 35662 as: 'as', 35663 async: 'async', 35664 autocapitalize: 'autoCapitalize', 35665 autocomplete: 'autoComplete', 35666 autocorrect: 'autoCorrect', 35667 autofocus: 'autoFocus', 35668 autoplay: 'autoPlay', 35669 autosave: 'autoSave', 35670 capture: 'capture', 35671 cellpadding: 'cellPadding', 35672 cellspacing: 'cellSpacing', 35673 challenge: 'challenge', 35674 charset: 'charSet', 35675 checked: 'checked', 35676 children: 'children', 35677 cite: 'cite', 35678 class: 'className', 35679 classid: 'classID', 35680 classname: 'className', 35681 cols: 'cols', 35682 colspan: 'colSpan', 35683 content: 'content', 35684 contenteditable: 'contentEditable', 35685 contextmenu: 'contextMenu', 35686 controls: 'controls', 35687 controlslist: 'controlsList', 35688 coords: 'coords', 35689 crossorigin: 'crossOrigin', 35690 dangerouslysetinnerhtml: 'dangerouslySetInnerHTML', 35691 data: 'data', 35692 datetime: 'dateTime', 35693 default: 'default', 35694 defaultchecked: 'defaultChecked', 35695 defaultvalue: 'defaultValue', 35696 defer: 'defer', 35697 dir: 'dir', 35698 disabled: 'disabled', 35699 download: 'download', 35700 draggable: 'draggable', 35701 enctype: 'encType', 35702 for: 'htmlFor', 35703 form: 'form', 35704 formmethod: 'formMethod', 35705 formaction: 'formAction', 35706 formenctype: 'formEncType', 35707 formnovalidate: 'formNoValidate', 35708 formtarget: 'formTarget', 35709 frameborder: 'frameBorder', 35710 headers: 'headers', 35711 height: 'height', 35712 hidden: 'hidden', 35713 high: 'high', 35714 href: 'href', 35715 hreflang: 'hrefLang', 35716 htmlfor: 'htmlFor', 35717 httpequiv: 'httpEquiv', 35718 'http-equiv': 'httpEquiv', 35719 icon: 'icon', 35720 id: 'id', 35721 innerhtml: 'innerHTML', 35722 inputmode: 'inputMode', 35723 integrity: 'integrity', 35724 is: 'is', 35725 itemid: 'itemID', 35726 itemprop: 'itemProp', 35727 itemref: 'itemRef', 35728 itemscope: 'itemScope', 35729 itemtype: 'itemType', 35730 keyparams: 'keyParams', 35731 keytype: 'keyType', 35732 kind: 'kind', 35733 label: 'label', 35734 lang: 'lang', 35735 list: 'list', 35736 loop: 'loop', 35737 low: 'low', 35738 manifest: 'manifest', 35739 marginwidth: 'marginWidth', 35740 marginheight: 'marginHeight', 35741 max: 'max', 35742 maxlength: 'maxLength', 35743 media: 'media', 35744 mediagroup: 'mediaGroup', 35745 method: 'method', 35746 min: 'min', 35747 minlength: 'minLength', 35748 multiple: 'multiple', 35749 muted: 'muted', 35750 name: 'name', 35751 nomodule: 'noModule', 35752 nonce: 'nonce', 35753 novalidate: 'noValidate', 35754 open: 'open', 35755 optimum: 'optimum', 35756 pattern: 'pattern', 35757 placeholder: 'placeholder', 35758 playsinline: 'playsInline', 35759 poster: 'poster', 35760 preload: 'preload', 35761 profile: 'profile', 35762 radiogroup: 'radioGroup', 35763 readonly: 'readOnly', 35764 referrerpolicy: 'referrerPolicy', 35765 rel: 'rel', 35766 required: 'required', 35767 reversed: 'reversed', 35768 role: 'role', 35769 rows: 'rows', 35770 rowspan: 'rowSpan', 35771 sandbox: 'sandbox', 35772 scope: 'scope', 35773 scoped: 'scoped', 35774 scrolling: 'scrolling', 35775 seamless: 'seamless', 35776 selected: 'selected', 35777 shape: 'shape', 35778 size: 'size', 35779 sizes: 'sizes', 35780 span: 'span', 35781 spellcheck: 'spellCheck', 35782 src: 'src', 35783 srcdoc: 'srcDoc', 35784 srclang: 'srcLang', 35785 srcset: 'srcSet', 35786 start: 'start', 35787 step: 'step', 35788 style: 'style', 35789 summary: 'summary', 35790 tabindex: 'tabIndex', 35791 target: 'target', 35792 title: 'title', 35793 type: 'type', 35794 usemap: 'useMap', 35795 value: 'value', 35796 width: 'width', 35797 wmode: 'wmode', 35798 wrap: 'wrap', 35799 35800 // SVG 35801 about: 'about', 35802 accentheight: 'accentHeight', 35803 'accent-height': 'accentHeight', 35804 accumulate: 'accumulate', 35805 additive: 'additive', 35806 alignmentbaseline: 'alignmentBaseline', 35807 'alignment-baseline': 'alignmentBaseline', 35808 allowreorder: 'allowReorder', 35809 alphabetic: 'alphabetic', 35810 amplitude: 'amplitude', 35811 arabicform: 'arabicForm', 35812 'arabic-form': 'arabicForm', 35813 ascent: 'ascent', 35814 attributename: 'attributeName', 35815 attributetype: 'attributeType', 35816 autoreverse: 'autoReverse', 35817 azimuth: 'azimuth', 35818 basefrequency: 'baseFrequency', 35819 baselineshift: 'baselineShift', 35820 'baseline-shift': 'baselineShift', 35821 baseprofile: 'baseProfile', 35822 bbox: 'bbox', 35823 begin: 'begin', 35824 bias: 'bias', 35825 by: 'by', 35826 calcmode: 'calcMode', 35827 capheight: 'capHeight', 35828 'cap-height': 'capHeight', 35829 clip: 'clip', 35830 clippath: 'clipPath', 35831 'clip-path': 'clipPath', 35832 clippathunits: 'clipPathUnits', 35833 cliprule: 'clipRule', 35834 'clip-rule': 'clipRule', 35835 color: 'color', 35836 colorinterpolation: 'colorInterpolation', 35837 'color-interpolation': 'colorInterpolation', 35838 colorinterpolationfilters: 'colorInterpolationFilters', 35839 'color-interpolation-filters': 'colorInterpolationFilters', 35840 colorprofile: 'colorProfile', 35841 'color-profile': 'colorProfile', 35842 colorrendering: 'colorRendering', 35843 'color-rendering': 'colorRendering', 35844 contentscripttype: 'contentScriptType', 35845 contentstyletype: 'contentStyleType', 35846 cursor: 'cursor', 35847 cx: 'cx', 35848 cy: 'cy', 35849 d: 'd', 35850 datatype: 'datatype', 35851 decelerate: 'decelerate', 35852 descent: 'descent', 35853 diffuseconstant: 'diffuseConstant', 35854 direction: 'direction', 35855 display: 'display', 35856 divisor: 'divisor', 35857 dominantbaseline: 'dominantBaseline', 35858 'dominant-baseline': 'dominantBaseline', 35859 dur: 'dur', 35860 dx: 'dx', 35861 dy: 'dy', 35862 edgemode: 'edgeMode', 35863 elevation: 'elevation', 35864 enablebackground: 'enableBackground', 35865 'enable-background': 'enableBackground', 35866 end: 'end', 35867 exponent: 'exponent', 35868 externalresourcesrequired: 'externalResourcesRequired', 35869 fill: 'fill', 35870 fillopacity: 'fillOpacity', 35871 'fill-opacity': 'fillOpacity', 35872 fillrule: 'fillRule', 35873 'fill-rule': 'fillRule', 35874 filter: 'filter', 35875 filterres: 'filterRes', 35876 filterunits: 'filterUnits', 35877 floodopacity: 'floodOpacity', 35878 'flood-opacity': 'floodOpacity', 35879 floodcolor: 'floodColor', 35880 'flood-color': 'floodColor', 35881 focusable: 'focusable', 35882 fontfamily: 'fontFamily', 35883 'font-family': 'fontFamily', 35884 fontsize: 'fontSize', 35885 'font-size': 'fontSize', 35886 fontsizeadjust: 'fontSizeAdjust', 35887 'font-size-adjust': 'fontSizeAdjust', 35888 fontstretch: 'fontStretch', 35889 'font-stretch': 'fontStretch', 35890 fontstyle: 'fontStyle', 35891 'font-style': 'fontStyle', 35892 fontvariant: 'fontVariant', 35893 'font-variant': 'fontVariant', 35894 fontweight: 'fontWeight', 35895 'font-weight': 'fontWeight', 35896 format: 'format', 35897 from: 'from', 35898 fx: 'fx', 35899 fy: 'fy', 35900 g1: 'g1', 35901 g2: 'g2', 35902 glyphname: 'glyphName', 35903 'glyph-name': 'glyphName', 35904 glyphorientationhorizontal: 'glyphOrientationHorizontal', 35905 'glyph-orientation-horizontal': 'glyphOrientationHorizontal', 35906 glyphorientationvertical: 'glyphOrientationVertical', 35907 'glyph-orientation-vertical': 'glyphOrientationVertical', 35908 glyphref: 'glyphRef', 35909 gradienttransform: 'gradientTransform', 35910 gradientunits: 'gradientUnits', 35911 hanging: 'hanging', 35912 horizadvx: 'horizAdvX', 35913 'horiz-adv-x': 'horizAdvX', 35914 horizoriginx: 'horizOriginX', 35915 'horiz-origin-x': 'horizOriginX', 35916 ideographic: 'ideographic', 35917 imagerendering: 'imageRendering', 35918 'image-rendering': 'imageRendering', 35919 in2: 'in2', 35920 in: 'in', 35921 inlist: 'inlist', 35922 intercept: 'intercept', 35923 k1: 'k1', 35924 k2: 'k2', 35925 k3: 'k3', 35926 k4: 'k4', 35927 k: 'k', 35928 kernelmatrix: 'kernelMatrix', 35929 kernelunitlength: 'kernelUnitLength', 35930 kerning: 'kerning', 35931 keypoints: 'keyPoints', 35932 keysplines: 'keySplines', 35933 keytimes: 'keyTimes', 35934 lengthadjust: 'lengthAdjust', 35935 letterspacing: 'letterSpacing', 35936 'letter-spacing': 'letterSpacing', 35937 lightingcolor: 'lightingColor', 35938 'lighting-color': 'lightingColor', 35939 limitingconeangle: 'limitingConeAngle', 35940 local: 'local', 35941 markerend: 'markerEnd', 35942 'marker-end': 'markerEnd', 35943 markerheight: 'markerHeight', 35944 markermid: 'markerMid', 35945 'marker-mid': 'markerMid', 35946 markerstart: 'markerStart', 35947 'marker-start': 'markerStart', 35948 markerunits: 'markerUnits', 35949 markerwidth: 'markerWidth', 35950 mask: 'mask', 35951 maskcontentunits: 'maskContentUnits', 35952 maskunits: 'maskUnits', 35953 mathematical: 'mathematical', 35954 mode: 'mode', 35955 numoctaves: 'numOctaves', 35956 offset: 'offset', 35957 opacity: 'opacity', 35958 operator: 'operator', 35959 order: 'order', 35960 orient: 'orient', 35961 orientation: 'orientation', 35962 origin: 'origin', 35963 overflow: 'overflow', 35964 overlineposition: 'overlinePosition', 35965 'overline-position': 'overlinePosition', 35966 overlinethickness: 'overlineThickness', 35967 'overline-thickness': 'overlineThickness', 35968 paintorder: 'paintOrder', 35969 'paint-order': 'paintOrder', 35970 panose1: 'panose1', 35971 'panose-1': 'panose1', 35972 pathlength: 'pathLength', 35973 patterncontentunits: 'patternContentUnits', 35974 patterntransform: 'patternTransform', 35975 patternunits: 'patternUnits', 35976 pointerevents: 'pointerEvents', 35977 'pointer-events': 'pointerEvents', 35978 points: 'points', 35979 pointsatx: 'pointsAtX', 35980 pointsaty: 'pointsAtY', 35981 pointsatz: 'pointsAtZ', 35982 prefix: 'prefix', 35983 preservealpha: 'preserveAlpha', 35984 preserveaspectratio: 'preserveAspectRatio', 35985 primitiveunits: 'primitiveUnits', 35986 property: 'property', 35987 r: 'r', 35988 radius: 'radius', 35989 refx: 'refX', 35990 refy: 'refY', 35991 renderingintent: 'renderingIntent', 35992 'rendering-intent': 'renderingIntent', 35993 repeatcount: 'repeatCount', 35994 repeatdur: 'repeatDur', 35995 requiredextensions: 'requiredExtensions', 35996 requiredfeatures: 'requiredFeatures', 35997 resource: 'resource', 35998 restart: 'restart', 35999 result: 'result', 36000 results: 'results', 36001 rotate: 'rotate', 36002 rx: 'rx', 36003 ry: 'ry', 36004 scale: 'scale', 36005 security: 'security', 36006 seed: 'seed', 36007 shaperendering: 'shapeRendering', 36008 'shape-rendering': 'shapeRendering', 36009 slope: 'slope', 36010 spacing: 'spacing', 36011 specularconstant: 'specularConstant', 36012 specularexponent: 'specularExponent', 36013 speed: 'speed', 36014 spreadmethod: 'spreadMethod', 36015 startoffset: 'startOffset', 36016 stddeviation: 'stdDeviation', 36017 stemh: 'stemh', 36018 stemv: 'stemv', 36019 stitchtiles: 'stitchTiles', 36020 stopcolor: 'stopColor', 36021 'stop-color': 'stopColor', 36022 stopopacity: 'stopOpacity', 36023 'stop-opacity': 'stopOpacity', 36024 strikethroughposition: 'strikethroughPosition', 36025 'strikethrough-position': 'strikethroughPosition', 36026 strikethroughthickness: 'strikethroughThickness', 36027 'strikethrough-thickness': 'strikethroughThickness', 36028 string: 'string', 36029 stroke: 'stroke', 36030 strokedasharray: 'strokeDasharray', 36031 'stroke-dasharray': 'strokeDasharray', 36032 strokedashoffset: 'strokeDashoffset', 36033 'stroke-dashoffset': 'strokeDashoffset', 36034 strokelinecap: 'strokeLinecap', 36035 'stroke-linecap': 'strokeLinecap', 36036 strokelinejoin: 'strokeLinejoin', 36037 'stroke-linejoin': 'strokeLinejoin', 36038 strokemiterlimit: 'strokeMiterlimit', 36039 'stroke-miterlimit': 'strokeMiterlimit', 36040 strokewidth: 'strokeWidth', 36041 'stroke-width': 'strokeWidth', 36042 strokeopacity: 'strokeOpacity', 36043 'stroke-opacity': 'strokeOpacity', 36044 suppresscontenteditablewarning: 'suppressContentEditableWarning', 36045 suppresshydrationwarning: 'suppressHydrationWarning', 36046 surfacescale: 'surfaceScale', 36047 systemlanguage: 'systemLanguage', 36048 tablevalues: 'tableValues', 36049 targetx: 'targetX', 36050 targety: 'targetY', 36051 textanchor: 'textAnchor', 36052 'text-anchor': 'textAnchor', 36053 textdecoration: 'textDecoration', 36054 'text-decoration': 'textDecoration', 36055 textlength: 'textLength', 36056 textrendering: 'textRendering', 36057 'text-rendering': 'textRendering', 36058 to: 'to', 36059 transform: 'transform', 36060 typeof: 'typeof', 36061 u1: 'u1', 36062 u2: 'u2', 36063 underlineposition: 'underlinePosition', 36064 'underline-position': 'underlinePosition', 36065 underlinethickness: 'underlineThickness', 36066 'underline-thickness': 'underlineThickness', 36067 unicode: 'unicode', 36068 unicodebidi: 'unicodeBidi', 36069 'unicode-bidi': 'unicodeBidi', 36070 unicoderange: 'unicodeRange', 36071 'unicode-range': 'unicodeRange', 36072 unitsperem: 'unitsPerEm', 36073 'units-per-em': 'unitsPerEm', 36074 unselectable: 'unselectable', 36075 valphabetic: 'vAlphabetic', 36076 'v-alphabetic': 'vAlphabetic', 36077 values: 'values', 36078 vectoreffect: 'vectorEffect', 36079 'vector-effect': 'vectorEffect', 36080 version: 'version', 36081 vertadvy: 'vertAdvY', 36082 'vert-adv-y': 'vertAdvY', 36083 vertoriginx: 'vertOriginX', 36084 'vert-origin-x': 'vertOriginX', 36085 vertoriginy: 'vertOriginY', 36086 'vert-origin-y': 'vertOriginY', 36087 vhanging: 'vHanging', 36088 'v-hanging': 'vHanging', 36089 videographic: 'vIdeographic', 36090 'v-ideographic': 'vIdeographic', 36091 viewbox: 'viewBox', 36092 viewtarget: 'viewTarget', 36093 visibility: 'visibility', 36094 vmathematical: 'vMathematical', 36095 'v-mathematical': 'vMathematical', 36096 vocab: 'vocab', 36097 widths: 'widths', 36098 wordspacing: 'wordSpacing', 36099 'word-spacing': 'wordSpacing', 36100 writingmode: 'writingMode', 36101 'writing-mode': 'writingMode', 36102 x1: 'x1', 36103 x2: 'x2', 36104 x: 'x', 36105 xchannelselector: 'xChannelSelector', 36106 xheight: 'xHeight', 36107 'x-height': 'xHeight', 36108 xlinkactuate: 'xlinkActuate', 36109 'xlink:actuate': 'xlinkActuate', 36110 xlinkarcrole: 'xlinkArcrole', 36111 'xlink:arcrole': 'xlinkArcrole', 36112 xlinkhref: 'xlinkHref', 36113 'xlink:href': 'xlinkHref', 36114 xlinkrole: 'xlinkRole', 36115 'xlink:role': 'xlinkRole', 36116 xlinkshow: 'xlinkShow', 36117 'xlink:show': 'xlinkShow', 36118 xlinktitle: 'xlinkTitle', 36119 'xlink:title': 'xlinkTitle', 36120 xlinktype: 'xlinkType', 36121 'xlink:type': 'xlinkType', 36122 xmlbase: 'xmlBase', 36123 'xml:base': 'xmlBase', 36124 xmllang: 'xmlLang', 36125 'xml:lang': 'xmlLang', 36126 xmlns: 'xmlns', 36127 'xml:space': 'xmlSpace', 36128 xmlnsxlink: 'xmlnsXlink', 36129 'xmlns:xlink': 'xmlnsXlink', 36130 xmlspace: 'xmlSpace', 36131 y1: 'y1', 36132 y2: 'y2', 36133 y: 'y', 36134 ychannelselector: 'yChannelSelector', 36135 z: 'z', 36136 zoomandpan: 'zoomAndPan' 36137}; 36138 36139var ariaProperties = { 36140 'aria-current': 0, // state 36141 'aria-details': 0, 36142 'aria-disabled': 0, // state 36143 'aria-hidden': 0, // state 36144 'aria-invalid': 0, // state 36145 'aria-keyshortcuts': 0, 36146 'aria-label': 0, 36147 'aria-roledescription': 0, 36148 // Widget Attributes 36149 'aria-autocomplete': 0, 36150 'aria-checked': 0, 36151 'aria-expanded': 0, 36152 'aria-haspopup': 0, 36153 'aria-level': 0, 36154 'aria-modal': 0, 36155 'aria-multiline': 0, 36156 'aria-multiselectable': 0, 36157 'aria-orientation': 0, 36158 'aria-placeholder': 0, 36159 'aria-pressed': 0, 36160 'aria-readonly': 0, 36161 'aria-required': 0, 36162 'aria-selected': 0, 36163 'aria-sort': 0, 36164 'aria-valuemax': 0, 36165 'aria-valuemin': 0, 36166 'aria-valuenow': 0, 36167 'aria-valuetext': 0, 36168 // Live Region Attributes 36169 'aria-atomic': 0, 36170 'aria-busy': 0, 36171 'aria-live': 0, 36172 'aria-relevant': 0, 36173 // Drag-and-Drop Attributes 36174 'aria-dropeffect': 0, 36175 'aria-grabbed': 0, 36176 // Relationship Attributes 36177 'aria-activedescendant': 0, 36178 'aria-colcount': 0, 36179 'aria-colindex': 0, 36180 'aria-colspan': 0, 36181 'aria-controls': 0, 36182 'aria-describedby': 0, 36183 'aria-errormessage': 0, 36184 'aria-flowto': 0, 36185 'aria-labelledby': 0, 36186 'aria-owns': 0, 36187 'aria-posinset': 0, 36188 'aria-rowcount': 0, 36189 'aria-rowindex': 0, 36190 'aria-rowspan': 0, 36191 'aria-setsize': 0 36192}; 36193 36194var warnedProperties = {}; 36195var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); 36196var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); 36197 36198var hasOwnProperty = Object.prototype.hasOwnProperty; 36199 36200function getStackAddendum() { 36201 var stack = ReactDebugCurrentFrame.getStackAddendum(); 36202 return stack != null ? stack : ''; 36203} 36204 36205function validateProperty(tagName, name) { 36206 if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) { 36207 return true; 36208 } 36209 36210 if (rARIACamel.test(name)) { 36211 var ariaName = 'aria-' + name.slice(4).toLowerCase(); 36212 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; 36213 36214 // If this is an aria-* attribute, but is not listed in the known DOM 36215 // DOM properties, then it is an invalid aria-* attribute. 36216 if (correctName == null) { 36217 warning(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.%s', name, getStackAddendum()); 36218 warnedProperties[name] = true; 36219 return true; 36220 } 36221 // aria-* attributes should be lowercase; suggest the lowercase version. 36222 if (name !== correctName) { 36223 warning(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?%s', name, correctName, getStackAddendum()); 36224 warnedProperties[name] = true; 36225 return true; 36226 } 36227 } 36228 36229 if (rARIA.test(name)) { 36230 var lowerCasedName = name.toLowerCase(); 36231 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; 36232 36233 // If this is an aria-* attribute, but is not listed in the known DOM 36234 // DOM properties, then it is an invalid aria-* attribute. 36235 if (standardName == null) { 36236 warnedProperties[name] = true; 36237 return false; 36238 } 36239 // aria-* attributes should be lowercase; suggest the lowercase version. 36240 if (name !== standardName) { 36241 warning(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum()); 36242 warnedProperties[name] = true; 36243 return true; 36244 } 36245 } 36246 36247 return true; 36248} 36249 36250function warnInvalidARIAProps(type, props) { 36251 var invalidProps = []; 36252 36253 for (var key in props) { 36254 var isValid = validateProperty(type, key); 36255 if (!isValid) { 36256 invalidProps.push(key); 36257 } 36258 } 36259 36260 var unknownPropString = invalidProps.map(function (prop) { 36261 return '`' + prop + '`'; 36262 }).join(', '); 36263 36264 if (invalidProps.length === 1) { 36265 warning(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, type, getStackAddendum()); 36266 } else if (invalidProps.length > 1) { 36267 warning(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, type, getStackAddendum()); 36268 } 36269} 36270 36271function validateProperties(type, props) { 36272 if (isCustomComponent(type, props)) { 36273 return; 36274 } 36275 warnInvalidARIAProps(type, props); 36276} 36277 36278var didWarnValueNull = false; 36279 36280function getStackAddendum$1() { 36281 var stack = ReactDebugCurrentFrame.getStackAddendum(); 36282 return stack != null ? stack : ''; 36283} 36284 36285function validateProperties$1(type, props) { 36286 if (type !== 'input' && type !== 'textarea' && type !== 'select') { 36287 return; 36288 } 36289 36290 if (props != null && props.value === null && !didWarnValueNull) { 36291 didWarnValueNull = true; 36292 if (type === 'select' && props.multiple) { 36293 warning(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty array when `multiple` is set to `true` ' + 'to clear the component or `undefined` for uncontrolled components.%s', type, getStackAddendum$1()); 36294 } else { 36295 warning(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.%s', type, getStackAddendum$1()); 36296 } 36297 } 36298} 36299 36300function getStackAddendum$2() { 36301 var stack = ReactDebugCurrentFrame.getStackAddendum(); 36302 return stack != null ? stack : ''; 36303} 36304 36305var validateProperty$1 = function () {}; 36306 36307{ 36308 var warnedProperties$1 = {}; 36309 var _hasOwnProperty = Object.prototype.hasOwnProperty; 36310 var EVENT_NAME_REGEX = /^on./; 36311 var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/; 36312 var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); 36313 var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); 36314 36315 validateProperty$1 = function (tagName, name, value, canUseEventSystem) { 36316 if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) { 36317 return true; 36318 } 36319 36320 var lowerCasedName = name.toLowerCase(); 36321 if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') { 36322 warning(false, 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.'); 36323 warnedProperties$1[name] = true; 36324 return true; 36325 } 36326 36327 // We can't rely on the event system being injected on the server. 36328 if (canUseEventSystem) { 36329 if (registrationNameModules.hasOwnProperty(name)) { 36330 return true; 36331 } 36332 var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null; 36333 if (registrationName != null) { 36334 warning(false, 'Invalid event handler property `%s`. Did you mean `%s`?%s', name, registrationName, getStackAddendum$2()); 36335 warnedProperties$1[name] = true; 36336 return true; 36337 } 36338 if (EVENT_NAME_REGEX.test(name)) { 36339 warning(false, 'Unknown event handler property `%s`. It will be ignored.%s', name, getStackAddendum$2()); 36340 warnedProperties$1[name] = true; 36341 return true; 36342 } 36343 } else if (EVENT_NAME_REGEX.test(name)) { 36344 // If no event plugins have been injected, we are in a server environment. 36345 // So we can't tell if the event name is correct for sure, but we can filter 36346 // out known bad ones like `onclick`. We can't suggest a specific replacement though. 36347 if (INVALID_EVENT_NAME_REGEX.test(name)) { 36348 warning(false, 'Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.%s', name, getStackAddendum$2()); 36349 } 36350 warnedProperties$1[name] = true; 36351 return true; 36352 } 36353 36354 // Let the ARIA attribute hook validate ARIA attributes 36355 if (rARIA$1.test(name) || rARIACamel$1.test(name)) { 36356 return true; 36357 } 36358 36359 if (lowerCasedName === 'innerhtml') { 36360 warning(false, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.'); 36361 warnedProperties$1[name] = true; 36362 return true; 36363 } 36364 36365 if (lowerCasedName === 'aria') { 36366 warning(false, 'The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.'); 36367 warnedProperties$1[name] = true; 36368 return true; 36369 } 36370 36371 if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') { 36372 warning(false, 'Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.%s', typeof value, getStackAddendum$2()); 36373 warnedProperties$1[name] = true; 36374 return true; 36375 } 36376 36377 if (typeof value === 'number' && isNaN(value)) { 36378 warning(false, 'Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.%s', name, getStackAddendum$2()); 36379 warnedProperties$1[name] = true; 36380 return true; 36381 } 36382 36383 var propertyInfo = getPropertyInfo(name); 36384 var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; 36385 36386 // Known attributes should match the casing specified in the property config. 36387 if (possibleStandardNames.hasOwnProperty(lowerCasedName)) { 36388 var standardName = possibleStandardNames[lowerCasedName]; 36389 if (standardName !== name) { 36390 warning(false, 'Invalid DOM property `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum$2()); 36391 warnedProperties$1[name] = true; 36392 return true; 36393 } 36394 } else if (!isReserved && name !== lowerCasedName) { 36395 // Unknown attributes should have lowercase casing since that's how they 36396 // will be cased anyway with server rendering. 36397 warning(false, 'React does not recognize the `%s` prop on a DOM element. If you ' + 'intentionally want it to appear in the DOM as a custom ' + 'attribute, spell it as lowercase `%s` instead. ' + 'If you accidentally passed it from a parent component, remove ' + 'it from the DOM element.%s', name, lowerCasedName, getStackAddendum$2()); 36398 warnedProperties$1[name] = true; 36399 return true; 36400 } 36401 36402 if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { 36403 if (value) { 36404 warning(false, 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.%s', value, name, name, value, name, getStackAddendum$2()); 36405 } else { 36406 warning(false, 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.%s', value, name, name, value, name, name, name, getStackAddendum$2()); 36407 } 36408 warnedProperties$1[name] = true; 36409 return true; 36410 } 36411 36412 // Now that we've validated casing, do not validate 36413 // data types for reserved props 36414 if (isReserved) { 36415 return true; 36416 } 36417 36418 // Warn when a known attribute is a bad type 36419 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { 36420 warnedProperties$1[name] = true; 36421 return false; 36422 } 36423 36424 return true; 36425 }; 36426} 36427 36428var warnUnknownProperties = function (type, props, canUseEventSystem) { 36429 var unknownProps = []; 36430 for (var key in props) { 36431 var isValid = validateProperty$1(type, key, props[key], canUseEventSystem); 36432 if (!isValid) { 36433 unknownProps.push(key); 36434 } 36435 } 36436 36437 var unknownPropString = unknownProps.map(function (prop) { 36438 return '`' + prop + '`'; 36439 }).join(', '); 36440 if (unknownProps.length === 1) { 36441 warning(false, 'Invalid value for prop %s on <%s> tag. Either remove it from the element, ' + 'or pass a string or number value to keep it in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior%s', unknownPropString, type, getStackAddendum$2()); 36442 } else if (unknownProps.length > 1) { 36443 warning(false, 'Invalid values for props %s on <%s> tag. Either remove them from the element, ' + 'or pass a string or number value to keep them in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior%s', unknownPropString, type, getStackAddendum$2()); 36444 } 36445}; 36446 36447function validateProperties$2(type, props, canUseEventSystem) { 36448 if (isCustomComponent(type, props)) { 36449 return; 36450 } 36451 warnUnknownProperties(type, props, canUseEventSystem); 36452} 36453 36454// TODO: direct imports like some-package/src/* are bad. Fix me. 36455var getCurrentFiberOwnerName$2 = ReactDebugCurrentFiber.getCurrentFiberOwnerName; 36456var getCurrentFiberStackAddendum$2 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 36457 36458var didWarnInvalidHydration = false; 36459var didWarnShadyDOM = false; 36460 36461var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML'; 36462var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning'; 36463var SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning'; 36464var AUTOFOCUS = 'autoFocus'; 36465var CHILDREN = 'children'; 36466var STYLE = 'style'; 36467var HTML = '__html'; 36468 36469var HTML_NAMESPACE = Namespaces.html; 36470 36471 36472var getStack = emptyFunction.thatReturns(''); 36473 36474var warnedUnknownTags = void 0; 36475var suppressHydrationWarning = void 0; 36476 36477var validatePropertiesInDevelopment = void 0; 36478var warnForTextDifference = void 0; 36479var warnForPropDifference = void 0; 36480var warnForExtraAttributes = void 0; 36481var warnForInvalidEventListener = void 0; 36482 36483var normalizeMarkupForTextOrAttribute = void 0; 36484var normalizeHTML = void 0; 36485 36486{ 36487 getStack = getCurrentFiberStackAddendum$2; 36488 36489 warnedUnknownTags = { 36490 // Chrome is the only major browser not shipping <time>. But as of July 36491 // 2017 it intends to ship it due to widespread usage. We intentionally 36492 // *don't* warn for <time> even if it's unrecognized by Chrome because 36493 // it soon will be, and many apps have been using it anyway. 36494 time: true, 36495 // There are working polyfills for <dialog>. Let people use it. 36496 dialog: true 36497 }; 36498 36499 validatePropertiesInDevelopment = function (type, props) { 36500 validateProperties(type, props); 36501 validateProperties$1(type, props); 36502 validateProperties$2(type, props, /* canUseEventSystem */true); 36503 }; 36504 36505 // HTML parsing normalizes CR and CRLF to LF. 36506 // It also can turn \u0000 into \uFFFD inside attributes. 36507 // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream 36508 // If we have a mismatch, it might be caused by that. 36509 // We will still patch up in this case but not fire the warning. 36510 var NORMALIZE_NEWLINES_REGEX = /\r\n?/g; 36511 var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g; 36512 36513 normalizeMarkupForTextOrAttribute = function (markup) { 36514 var markupString = typeof markup === 'string' ? markup : '' + markup; 36515 return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, ''); 36516 }; 36517 36518 warnForTextDifference = function (serverText, clientText) { 36519 if (didWarnInvalidHydration) { 36520 return; 36521 } 36522 var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText); 36523 var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText); 36524 if (normalizedServerText === normalizedClientText) { 36525 return; 36526 } 36527 didWarnInvalidHydration = true; 36528 warning(false, 'Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText); 36529 }; 36530 36531 warnForPropDifference = function (propName, serverValue, clientValue) { 36532 if (didWarnInvalidHydration) { 36533 return; 36534 } 36535 var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue); 36536 var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue); 36537 if (normalizedServerValue === normalizedClientValue) { 36538 return; 36539 } 36540 didWarnInvalidHydration = true; 36541 warning(false, 'Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue)); 36542 }; 36543 36544 warnForExtraAttributes = function (attributeNames) { 36545 if (didWarnInvalidHydration) { 36546 return; 36547 } 36548 didWarnInvalidHydration = true; 36549 var names = []; 36550 attributeNames.forEach(function (name) { 36551 names.push(name); 36552 }); 36553 warning(false, 'Extra attributes from the server: %s', names); 36554 }; 36555 36556 warnForInvalidEventListener = function (registrationName, listener) { 36557 if (listener === false) { 36558 warning(false, 'Expected `%s` listener to be a function, instead got `false`.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.%s', registrationName, registrationName, registrationName, getCurrentFiberStackAddendum$2()); 36559 } else { 36560 warning(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.%s', registrationName, typeof listener, getCurrentFiberStackAddendum$2()); 36561 } 36562 }; 36563 36564 // Parse the HTML and read it back to normalize the HTML string so that it 36565 // can be used for comparison. 36566 normalizeHTML = function (parent, html) { 36567 // We could have created a separate document here to avoid 36568 // re-initializing custom elements if they exist. But this breaks 36569 // how <noscript> is being handled. So we use the same document. 36570 // See the discussion in https://github.com/facebook/react/pull/11157. 36571 var testElement = parent.namespaceURI === HTML_NAMESPACE ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName); 36572 testElement.innerHTML = html; 36573 return testElement.innerHTML; 36574 }; 36575} 36576 36577function ensureListeningTo(rootContainerElement, registrationName) { 36578 var isDocumentOrFragment = rootContainerElement.nodeType === DOCUMENT_NODE || rootContainerElement.nodeType === DOCUMENT_FRAGMENT_NODE; 36579 var doc = isDocumentOrFragment ? rootContainerElement : rootContainerElement.ownerDocument; 36580 listenTo(registrationName, doc); 36581} 36582 36583function getOwnerDocumentFromRootContainer(rootContainerElement) { 36584 return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument; 36585} 36586 36587function trapClickOnNonInteractiveElement(node) { 36588 // Mobile Safari does not fire properly bubble click events on 36589 // non-interactive elements, which means delegated click listeners do not 36590 // fire. The workaround for this bug involves attaching an empty click 36591 // listener on the target node. 36592 // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html 36593 // Just set it using the onclick property so that we don't have to manage any 36594 // bookkeeping for it. Not sure if we need to clear it when the listener is 36595 // removed. 36596 // TODO: Only do this for the relevant Safaris maybe? 36597 node.onclick = emptyFunction; 36598} 36599 36600function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) { 36601 for (var propKey in nextProps) { 36602 if (!nextProps.hasOwnProperty(propKey)) { 36603 continue; 36604 } 36605 var nextProp = nextProps[propKey]; 36606 if (propKey === STYLE) { 36607 { 36608 if (nextProp) { 36609 // Freeze the next style object so that we can assume it won't be 36610 // mutated. We have already warned for this in the past. 36611 Object.freeze(nextProp); 36612 } 36613 } 36614 // Relies on `updateStylesByID` not mutating `styleUpdates`. 36615 setValueForStyles(domElement, nextProp, getStack); 36616 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 36617 var nextHtml = nextProp ? nextProp[HTML] : undefined; 36618 if (nextHtml != null) { 36619 setInnerHTML(domElement, nextHtml); 36620 } 36621 } else if (propKey === CHILDREN) { 36622 if (typeof nextProp === 'string') { 36623 // Avoid setting initial textContent when the text is empty. In IE11 setting 36624 // textContent on a <textarea> will cause the placeholder to not 36625 // show within the <textarea> until it has been focused and blurred again. 36626 // https://github.com/facebook/react/issues/6731#issuecomment-254874553 36627 var canSetTextContent = tag !== 'textarea' || nextProp !== ''; 36628 if (canSetTextContent) { 36629 setTextContent(domElement, nextProp); 36630 } 36631 } else if (typeof nextProp === 'number') { 36632 setTextContent(domElement, '' + nextProp); 36633 } 36634 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) { 36635 // Noop 36636 } else if (propKey === AUTOFOCUS) { 36637 // We polyfill it separately on the client during commit. 36638 // We blacklist it here rather than in the property list because we emit it in SSR. 36639 } else if (registrationNameModules.hasOwnProperty(propKey)) { 36640 if (nextProp != null) { 36641 if ( true && typeof nextProp !== 'function') { 36642 warnForInvalidEventListener(propKey, nextProp); 36643 } 36644 ensureListeningTo(rootContainerElement, propKey); 36645 } 36646 } else if (nextProp != null) { 36647 setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag); 36648 } 36649 } 36650} 36651 36652function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) { 36653 // TODO: Handle wasCustomComponentTag 36654 for (var i = 0; i < updatePayload.length; i += 2) { 36655 var propKey = updatePayload[i]; 36656 var propValue = updatePayload[i + 1]; 36657 if (propKey === STYLE) { 36658 setValueForStyles(domElement, propValue, getStack); 36659 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 36660 setInnerHTML(domElement, propValue); 36661 } else if (propKey === CHILDREN) { 36662 setTextContent(domElement, propValue); 36663 } else { 36664 setValueForProperty(domElement, propKey, propValue, isCustomComponentTag); 36665 } 36666 } 36667} 36668 36669function createElement$1(type, props, rootContainerElement, parentNamespace) { 36670 var isCustomComponentTag = void 0; 36671 36672 // We create tags in the namespace of their parent container, except HTML 36673 // tags get no namespace. 36674 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement); 36675 var domElement = void 0; 36676 var namespaceURI = parentNamespace; 36677 if (namespaceURI === HTML_NAMESPACE) { 36678 namespaceURI = getIntrinsicNamespace(type); 36679 } 36680 if (namespaceURI === HTML_NAMESPACE) { 36681 { 36682 isCustomComponentTag = isCustomComponent(type, props); 36683 // Should this check be gated by parent namespace? Not sure we want to 36684 // allow <SVG> or <mATH>. 36685 !(isCustomComponentTag || type === type.toLowerCase()) ? warning(false, '<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type) : void 0; 36686 } 36687 36688 if (type === 'script') { 36689 // Create the script via .innerHTML so its "parser-inserted" flag is 36690 // set to true and it does not execute 36691 var div = ownerDocument.createElement('div'); 36692 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line 36693 // This is guaranteed to yield a script element. 36694 var firstChild = div.firstChild; 36695 domElement = div.removeChild(firstChild); 36696 } else if (typeof props.is === 'string') { 36697 // $FlowIssue `createElement` should be updated for Web Components 36698 domElement = ownerDocument.createElement(type, { is: props.is }); 36699 } else { 36700 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug. 36701 // See discussion in https://github.com/facebook/react/pull/6896 36702 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240 36703 domElement = ownerDocument.createElement(type); 36704 } 36705 } else { 36706 domElement = ownerDocument.createElementNS(namespaceURI, type); 36707 } 36708 36709 { 36710 if (namespaceURI === HTML_NAMESPACE) { 36711 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) { 36712 warnedUnknownTags[type] = true; 36713 warning(false, 'The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type); 36714 } 36715 } 36716 } 36717 36718 return domElement; 36719} 36720 36721function createTextNode$1(text, rootContainerElement) { 36722 return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text); 36723} 36724 36725function setInitialProperties$1(domElement, tag, rawProps, rootContainerElement) { 36726 var isCustomComponentTag = isCustomComponent(tag, rawProps); 36727 { 36728 validatePropertiesInDevelopment(tag, rawProps); 36729 if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) { 36730 warning(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerName$2() || 'A component'); 36731 didWarnShadyDOM = true; 36732 } 36733 } 36734 36735 // TODO: Make sure that we check isMounted before firing any of these events. 36736 var props = void 0; 36737 switch (tag) { 36738 case 'iframe': 36739 case 'object': 36740 trapBubbledEvent(TOP_LOAD, domElement); 36741 props = rawProps; 36742 break; 36743 case 'video': 36744 case 'audio': 36745 // Create listener for each media event 36746 for (var i = 0; i < mediaEventTypes.length; i++) { 36747 trapBubbledEvent(mediaEventTypes[i], domElement); 36748 } 36749 props = rawProps; 36750 break; 36751 case 'source': 36752 trapBubbledEvent(TOP_ERROR, domElement); 36753 props = rawProps; 36754 break; 36755 case 'img': 36756 case 'image': 36757 case 'link': 36758 trapBubbledEvent(TOP_ERROR, domElement); 36759 trapBubbledEvent(TOP_LOAD, domElement); 36760 props = rawProps; 36761 break; 36762 case 'form': 36763 trapBubbledEvent(TOP_RESET, domElement); 36764 trapBubbledEvent(TOP_SUBMIT, domElement); 36765 props = rawProps; 36766 break; 36767 case 'details': 36768 trapBubbledEvent(TOP_TOGGLE, domElement); 36769 props = rawProps; 36770 break; 36771 case 'input': 36772 initWrapperState(domElement, rawProps); 36773 props = getHostProps(domElement, rawProps); 36774 trapBubbledEvent(TOP_INVALID, domElement); 36775 // For controlled components we always need to ensure we're listening 36776 // to onChange. Even if there is no listener. 36777 ensureListeningTo(rootContainerElement, 'onChange'); 36778 break; 36779 case 'option': 36780 validateProps(domElement, rawProps); 36781 props = getHostProps$1(domElement, rawProps); 36782 break; 36783 case 'select': 36784 initWrapperState$1(domElement, rawProps); 36785 props = getHostProps$2(domElement, rawProps); 36786 trapBubbledEvent(TOP_INVALID, domElement); 36787 // For controlled components we always need to ensure we're listening 36788 // to onChange. Even if there is no listener. 36789 ensureListeningTo(rootContainerElement, 'onChange'); 36790 break; 36791 case 'textarea': 36792 initWrapperState$2(domElement, rawProps); 36793 props = getHostProps$3(domElement, rawProps); 36794 trapBubbledEvent(TOP_INVALID, domElement); 36795 // For controlled components we always need to ensure we're listening 36796 // to onChange. Even if there is no listener. 36797 ensureListeningTo(rootContainerElement, 'onChange'); 36798 break; 36799 default: 36800 props = rawProps; 36801 } 36802 36803 assertValidProps(tag, props, getStack); 36804 36805 setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag); 36806 36807 switch (tag) { 36808 case 'input': 36809 // TODO: Make sure we check if this is still unmounted or do any clean 36810 // up necessary since we never stop tracking anymore. 36811 track(domElement); 36812 postMountWrapper(domElement, rawProps, false); 36813 break; 36814 case 'textarea': 36815 // TODO: Make sure we check if this is still unmounted or do any clean 36816 // up necessary since we never stop tracking anymore. 36817 track(domElement); 36818 postMountWrapper$3(domElement, rawProps); 36819 break; 36820 case 'option': 36821 postMountWrapper$1(domElement, rawProps); 36822 break; 36823 case 'select': 36824 postMountWrapper$2(domElement, rawProps); 36825 break; 36826 default: 36827 if (typeof props.onClick === 'function') { 36828 // TODO: This cast may not be sound for SVG, MathML or custom elements. 36829 trapClickOnNonInteractiveElement(domElement); 36830 } 36831 break; 36832 } 36833} 36834 36835// Calculate the diff between the two objects. 36836function diffProperties$1(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) { 36837 { 36838 validatePropertiesInDevelopment(tag, nextRawProps); 36839 } 36840 36841 var updatePayload = null; 36842 36843 var lastProps = void 0; 36844 var nextProps = void 0; 36845 switch (tag) { 36846 case 'input': 36847 lastProps = getHostProps(domElement, lastRawProps); 36848 nextProps = getHostProps(domElement, nextRawProps); 36849 updatePayload = []; 36850 break; 36851 case 'option': 36852 lastProps = getHostProps$1(domElement, lastRawProps); 36853 nextProps = getHostProps$1(domElement, nextRawProps); 36854 updatePayload = []; 36855 break; 36856 case 'select': 36857 lastProps = getHostProps$2(domElement, lastRawProps); 36858 nextProps = getHostProps$2(domElement, nextRawProps); 36859 updatePayload = []; 36860 break; 36861 case 'textarea': 36862 lastProps = getHostProps$3(domElement, lastRawProps); 36863 nextProps = getHostProps$3(domElement, nextRawProps); 36864 updatePayload = []; 36865 break; 36866 default: 36867 lastProps = lastRawProps; 36868 nextProps = nextRawProps; 36869 if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') { 36870 // TODO: This cast may not be sound for SVG, MathML or custom elements. 36871 trapClickOnNonInteractiveElement(domElement); 36872 } 36873 break; 36874 } 36875 36876 assertValidProps(tag, nextProps, getStack); 36877 36878 var propKey = void 0; 36879 var styleName = void 0; 36880 var styleUpdates = null; 36881 for (propKey in lastProps) { 36882 if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) { 36883 continue; 36884 } 36885 if (propKey === STYLE) { 36886 var lastStyle = lastProps[propKey]; 36887 for (styleName in lastStyle) { 36888 if (lastStyle.hasOwnProperty(styleName)) { 36889 if (!styleUpdates) { 36890 styleUpdates = {}; 36891 } 36892 styleUpdates[styleName] = ''; 36893 } 36894 } 36895 } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) { 36896 // Noop. This is handled by the clear text mechanism. 36897 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) { 36898 // Noop 36899 } else if (propKey === AUTOFOCUS) { 36900 // Noop. It doesn't work on updates anyway. 36901 } else if (registrationNameModules.hasOwnProperty(propKey)) { 36902 // This is a special case. If any listener updates we need to ensure 36903 // that the "current" fiber pointer gets updated so we need a commit 36904 // to update this element. 36905 if (!updatePayload) { 36906 updatePayload = []; 36907 } 36908 } else { 36909 // For all other deleted properties we add it to the queue. We use 36910 // the whitelist in the commit phase instead. 36911 (updatePayload = updatePayload || []).push(propKey, null); 36912 } 36913 } 36914 for (propKey in nextProps) { 36915 var nextProp = nextProps[propKey]; 36916 var lastProp = lastProps != null ? lastProps[propKey] : undefined; 36917 if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) { 36918 continue; 36919 } 36920 if (propKey === STYLE) { 36921 { 36922 if (nextProp) { 36923 // Freeze the next style object so that we can assume it won't be 36924 // mutated. We have already warned for this in the past. 36925 Object.freeze(nextProp); 36926 } 36927 } 36928 if (lastProp) { 36929 // Unset styles on `lastProp` but not on `nextProp`. 36930 for (styleName in lastProp) { 36931 if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) { 36932 if (!styleUpdates) { 36933 styleUpdates = {}; 36934 } 36935 styleUpdates[styleName] = ''; 36936 } 36937 } 36938 // Update styles that changed since `lastProp`. 36939 for (styleName in nextProp) { 36940 if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) { 36941 if (!styleUpdates) { 36942 styleUpdates = {}; 36943 } 36944 styleUpdates[styleName] = nextProp[styleName]; 36945 } 36946 } 36947 } else { 36948 // Relies on `updateStylesByID` not mutating `styleUpdates`. 36949 if (!styleUpdates) { 36950 if (!updatePayload) { 36951 updatePayload = []; 36952 } 36953 updatePayload.push(propKey, styleUpdates); 36954 } 36955 styleUpdates = nextProp; 36956 } 36957 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 36958 var nextHtml = nextProp ? nextProp[HTML] : undefined; 36959 var lastHtml = lastProp ? lastProp[HTML] : undefined; 36960 if (nextHtml != null) { 36961 if (lastHtml !== nextHtml) { 36962 (updatePayload = updatePayload || []).push(propKey, '' + nextHtml); 36963 } 36964 } else { 36965 // TODO: It might be too late to clear this if we have children 36966 // inserted already. 36967 } 36968 } else if (propKey === CHILDREN) { 36969 if (lastProp !== nextProp && (typeof nextProp === 'string' || typeof nextProp === 'number')) { 36970 (updatePayload = updatePayload || []).push(propKey, '' + nextProp); 36971 } 36972 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) { 36973 // Noop 36974 } else if (registrationNameModules.hasOwnProperty(propKey)) { 36975 if (nextProp != null) { 36976 // We eagerly listen to this even though we haven't committed yet. 36977 if ( true && typeof nextProp !== 'function') { 36978 warnForInvalidEventListener(propKey, nextProp); 36979 } 36980 ensureListeningTo(rootContainerElement, propKey); 36981 } 36982 if (!updatePayload && lastProp !== nextProp) { 36983 // This is a special case. If any listener updates we need to ensure 36984 // that the "current" props pointer gets updated so we need a commit 36985 // to update this element. 36986 updatePayload = []; 36987 } 36988 } else { 36989 // For any other property we always add it to the queue and then we 36990 // filter it out using the whitelist during the commit. 36991 (updatePayload = updatePayload || []).push(propKey, nextProp); 36992 } 36993 } 36994 if (styleUpdates) { 36995 (updatePayload = updatePayload || []).push(STYLE, styleUpdates); 36996 } 36997 return updatePayload; 36998} 36999 37000// Apply the diff. 37001function updateProperties$1(domElement, updatePayload, tag, lastRawProps, nextRawProps) { 37002 // Update checked *before* name. 37003 // In the middle of an update, it is possible to have multiple checked. 37004 // When a checked radio tries to change name, browser makes another radio's checked false. 37005 if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) { 37006 updateChecked(domElement, nextRawProps); 37007 } 37008 37009 var wasCustomComponentTag = isCustomComponent(tag, lastRawProps); 37010 var isCustomComponentTag = isCustomComponent(tag, nextRawProps); 37011 // Apply the diff. 37012 updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); 37013 37014 // TODO: Ensure that an update gets scheduled if any of the special props 37015 // changed. 37016 switch (tag) { 37017 case 'input': 37018 // Update the wrapper around inputs *after* updating props. This has to 37019 // happen after `updateDOMProperties`. Otherwise HTML5 input validations 37020 // raise warnings and prevent the new value from being assigned. 37021 updateWrapper(domElement, nextRawProps); 37022 break; 37023 case 'textarea': 37024 updateWrapper$1(domElement, nextRawProps); 37025 break; 37026 case 'select': 37027 // <select> value update needs to occur after <option> children 37028 // reconciliation 37029 postUpdateWrapper(domElement, nextRawProps); 37030 break; 37031 } 37032} 37033 37034function getPossibleStandardName(propName) { 37035 { 37036 var lowerCasedName = propName.toLowerCase(); 37037 if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) { 37038 return null; 37039 } 37040 return possibleStandardNames[lowerCasedName] || null; 37041 } 37042 return null; 37043} 37044 37045function diffHydratedProperties$1(domElement, tag, rawProps, parentNamespace, rootContainerElement) { 37046 var isCustomComponentTag = void 0; 37047 var extraAttributeNames = void 0; 37048 37049 { 37050 suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING$1] === true; 37051 isCustomComponentTag = isCustomComponent(tag, rawProps); 37052 validatePropertiesInDevelopment(tag, rawProps); 37053 if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) { 37054 warning(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerName$2() || 'A component'); 37055 didWarnShadyDOM = true; 37056 } 37057 } 37058 37059 // TODO: Make sure that we check isMounted before firing any of these events. 37060 switch (tag) { 37061 case 'iframe': 37062 case 'object': 37063 trapBubbledEvent(TOP_LOAD, domElement); 37064 break; 37065 case 'video': 37066 case 'audio': 37067 // Create listener for each media event 37068 for (var i = 0; i < mediaEventTypes.length; i++) { 37069 trapBubbledEvent(mediaEventTypes[i], domElement); 37070 } 37071 break; 37072 case 'source': 37073 trapBubbledEvent(TOP_ERROR, domElement); 37074 break; 37075 case 'img': 37076 case 'image': 37077 case 'link': 37078 trapBubbledEvent(TOP_ERROR, domElement); 37079 trapBubbledEvent(TOP_LOAD, domElement); 37080 break; 37081 case 'form': 37082 trapBubbledEvent(TOP_RESET, domElement); 37083 trapBubbledEvent(TOP_SUBMIT, domElement); 37084 break; 37085 case 'details': 37086 trapBubbledEvent(TOP_TOGGLE, domElement); 37087 break; 37088 case 'input': 37089 initWrapperState(domElement, rawProps); 37090 trapBubbledEvent(TOP_INVALID, domElement); 37091 // For controlled components we always need to ensure we're listening 37092 // to onChange. Even if there is no listener. 37093 ensureListeningTo(rootContainerElement, 'onChange'); 37094 break; 37095 case 'option': 37096 validateProps(domElement, rawProps); 37097 break; 37098 case 'select': 37099 initWrapperState$1(domElement, rawProps); 37100 trapBubbledEvent(TOP_INVALID, domElement); 37101 // For controlled components we always need to ensure we're listening 37102 // to onChange. Even if there is no listener. 37103 ensureListeningTo(rootContainerElement, 'onChange'); 37104 break; 37105 case 'textarea': 37106 initWrapperState$2(domElement, rawProps); 37107 trapBubbledEvent(TOP_INVALID, domElement); 37108 // For controlled components we always need to ensure we're listening 37109 // to onChange. Even if there is no listener. 37110 ensureListeningTo(rootContainerElement, 'onChange'); 37111 break; 37112 } 37113 37114 assertValidProps(tag, rawProps, getStack); 37115 37116 { 37117 extraAttributeNames = new Set(); 37118 var attributes = domElement.attributes; 37119 for (var _i = 0; _i < attributes.length; _i++) { 37120 var name = attributes[_i].name.toLowerCase(); 37121 switch (name) { 37122 // Built-in SSR attribute is whitelisted 37123 case 'data-reactroot': 37124 break; 37125 // Controlled attributes are not validated 37126 // TODO: Only ignore them on controlled tags. 37127 case 'value': 37128 break; 37129 case 'checked': 37130 break; 37131 case 'selected': 37132 break; 37133 default: 37134 // Intentionally use the original name. 37135 // See discussion in https://github.com/facebook/react/pull/10676. 37136 extraAttributeNames.add(attributes[_i].name); 37137 } 37138 } 37139 } 37140 37141 var updatePayload = null; 37142 for (var propKey in rawProps) { 37143 if (!rawProps.hasOwnProperty(propKey)) { 37144 continue; 37145 } 37146 var nextProp = rawProps[propKey]; 37147 if (propKey === CHILDREN) { 37148 // For text content children we compare against textContent. This 37149 // might match additional HTML that is hidden when we read it using 37150 // textContent. E.g. "foo" will match "f<span>oo</span>" but that still 37151 // satisfies our requirement. Our requirement is not to produce perfect 37152 // HTML and attributes. Ideally we should preserve structure but it's 37153 // ok not to if the visible content is still enough to indicate what 37154 // even listeners these nodes might be wired up to. 37155 // TODO: Warn if there is more than a single textNode as a child. 37156 // TODO: Should we use domElement.firstChild.nodeValue to compare? 37157 if (typeof nextProp === 'string') { 37158 if (domElement.textContent !== nextProp) { 37159 if ( true && !suppressHydrationWarning) { 37160 warnForTextDifference(domElement.textContent, nextProp); 37161 } 37162 updatePayload = [CHILDREN, nextProp]; 37163 } 37164 } else if (typeof nextProp === 'number') { 37165 if (domElement.textContent !== '' + nextProp) { 37166 if ( true && !suppressHydrationWarning) { 37167 warnForTextDifference(domElement.textContent, nextProp); 37168 } 37169 updatePayload = [CHILDREN, '' + nextProp]; 37170 } 37171 } 37172 } else if (registrationNameModules.hasOwnProperty(propKey)) { 37173 if (nextProp != null) { 37174 if ( true && typeof nextProp !== 'function') { 37175 warnForInvalidEventListener(propKey, nextProp); 37176 } 37177 ensureListeningTo(rootContainerElement, propKey); 37178 } 37179 } else if ( true && 37180 // Convince Flow we've calculated it (it's DEV-only in this method.) 37181 typeof isCustomComponentTag === 'boolean') { 37182 // Validate that the properties correspond to their expected values. 37183 var serverValue = void 0; 37184 var propertyInfo = getPropertyInfo(propKey); 37185 if (suppressHydrationWarning) { 37186 // Don't bother comparing. We're ignoring all these warnings. 37187 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1 || 37188 // Controlled attributes are not validated 37189 // TODO: Only ignore them on controlled tags. 37190 propKey === 'value' || propKey === 'checked' || propKey === 'selected') { 37191 // Noop 37192 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 37193 var rawHtml = nextProp ? nextProp[HTML] || '' : ''; 37194 var serverHTML = domElement.innerHTML; 37195 var expectedHTML = normalizeHTML(domElement, rawHtml); 37196 if (expectedHTML !== serverHTML) { 37197 warnForPropDifference(propKey, serverHTML, expectedHTML); 37198 } 37199 } else if (propKey === STYLE) { 37200 // $FlowFixMe - Should be inferred as not undefined. 37201 extraAttributeNames.delete(propKey); 37202 var expectedStyle = createDangerousStringForStyles(nextProp); 37203 serverValue = domElement.getAttribute('style'); 37204 if (expectedStyle !== serverValue) { 37205 warnForPropDifference(propKey, serverValue, expectedStyle); 37206 } 37207 } else if (isCustomComponentTag) { 37208 // $FlowFixMe - Should be inferred as not undefined. 37209 extraAttributeNames.delete(propKey.toLowerCase()); 37210 serverValue = getValueForAttribute(domElement, propKey, nextProp); 37211 37212 if (nextProp !== serverValue) { 37213 warnForPropDifference(propKey, serverValue, nextProp); 37214 } 37215 } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) { 37216 var isMismatchDueToBadCasing = false; 37217 if (propertyInfo !== null) { 37218 // $FlowFixMe - Should be inferred as not undefined. 37219 extraAttributeNames.delete(propertyInfo.attributeName); 37220 serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo); 37221 } else { 37222 var ownNamespace = parentNamespace; 37223 if (ownNamespace === HTML_NAMESPACE) { 37224 ownNamespace = getIntrinsicNamespace(tag); 37225 } 37226 if (ownNamespace === HTML_NAMESPACE) { 37227 // $FlowFixMe - Should be inferred as not undefined. 37228 extraAttributeNames.delete(propKey.toLowerCase()); 37229 } else { 37230 var standardName = getPossibleStandardName(propKey); 37231 if (standardName !== null && standardName !== propKey) { 37232 // If an SVG prop is supplied with bad casing, it will 37233 // be successfully parsed from HTML, but will produce a mismatch 37234 // (and would be incorrectly rendered on the client). 37235 // However, we already warn about bad casing elsewhere. 37236 // So we'll skip the misleading extra mismatch warning in this case. 37237 isMismatchDueToBadCasing = true; 37238 // $FlowFixMe - Should be inferred as not undefined. 37239 extraAttributeNames.delete(standardName); 37240 } 37241 // $FlowFixMe - Should be inferred as not undefined. 37242 extraAttributeNames.delete(propKey); 37243 } 37244 serverValue = getValueForAttribute(domElement, propKey, nextProp); 37245 } 37246 37247 if (nextProp !== serverValue && !isMismatchDueToBadCasing) { 37248 warnForPropDifference(propKey, serverValue, nextProp); 37249 } 37250 } 37251 } 37252 } 37253 37254 { 37255 // $FlowFixMe - Should be inferred as not undefined. 37256 if (extraAttributeNames.size > 0 && !suppressHydrationWarning) { 37257 // $FlowFixMe - Should be inferred as not undefined. 37258 warnForExtraAttributes(extraAttributeNames); 37259 } 37260 } 37261 37262 switch (tag) { 37263 case 'input': 37264 // TODO: Make sure we check if this is still unmounted or do any clean 37265 // up necessary since we never stop tracking anymore. 37266 track(domElement); 37267 postMountWrapper(domElement, rawProps, true); 37268 break; 37269 case 'textarea': 37270 // TODO: Make sure we check if this is still unmounted or do any clean 37271 // up necessary since we never stop tracking anymore. 37272 track(domElement); 37273 postMountWrapper$3(domElement, rawProps); 37274 break; 37275 case 'select': 37276 case 'option': 37277 // For input and textarea we current always set the value property at 37278 // post mount to force it to diverge from attributes. However, for 37279 // option and select we don't quite do the same thing and select 37280 // is not resilient to the DOM state changing so we don't do that here. 37281 // TODO: Consider not doing this for input and textarea. 37282 break; 37283 default: 37284 if (typeof rawProps.onClick === 'function') { 37285 // TODO: This cast may not be sound for SVG, MathML or custom elements. 37286 trapClickOnNonInteractiveElement(domElement); 37287 } 37288 break; 37289 } 37290 37291 return updatePayload; 37292} 37293 37294function diffHydratedText$1(textNode, text) { 37295 var isDifferent = textNode.nodeValue !== text; 37296 return isDifferent; 37297} 37298 37299function warnForUnmatchedText$1(textNode, text) { 37300 { 37301 warnForTextDifference(textNode.nodeValue, text); 37302 } 37303} 37304 37305function warnForDeletedHydratableElement$1(parentNode, child) { 37306 { 37307 if (didWarnInvalidHydration) { 37308 return; 37309 } 37310 didWarnInvalidHydration = true; 37311 warning(false, 'Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase()); 37312 } 37313} 37314 37315function warnForDeletedHydratableText$1(parentNode, child) { 37316 { 37317 if (didWarnInvalidHydration) { 37318 return; 37319 } 37320 didWarnInvalidHydration = true; 37321 warning(false, 'Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase()); 37322 } 37323} 37324 37325function warnForInsertedHydratedElement$1(parentNode, tag, props) { 37326 { 37327 if (didWarnInvalidHydration) { 37328 return; 37329 } 37330 didWarnInvalidHydration = true; 37331 warning(false, 'Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase()); 37332 } 37333} 37334 37335function warnForInsertedHydratedText$1(parentNode, text) { 37336 { 37337 if (text === '') { 37338 // We expect to insert empty text nodes since they're not represented in 37339 // the HTML. 37340 // TODO: Remove this special case if we can just avoid inserting empty 37341 // text nodes. 37342 return; 37343 } 37344 if (didWarnInvalidHydration) { 37345 return; 37346 } 37347 didWarnInvalidHydration = true; 37348 warning(false, 'Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase()); 37349 } 37350} 37351 37352function restoreControlledState$1(domElement, tag, props) { 37353 switch (tag) { 37354 case 'input': 37355 restoreControlledState(domElement, props); 37356 return; 37357 case 'textarea': 37358 restoreControlledState$3(domElement, props); 37359 return; 37360 case 'select': 37361 restoreControlledState$2(domElement, props); 37362 return; 37363 } 37364} 37365 37366var ReactDOMFiberComponent = Object.freeze({ 37367 createElement: createElement$1, 37368 createTextNode: createTextNode$1, 37369 setInitialProperties: setInitialProperties$1, 37370 diffProperties: diffProperties$1, 37371 updateProperties: updateProperties$1, 37372 diffHydratedProperties: diffHydratedProperties$1, 37373 diffHydratedText: diffHydratedText$1, 37374 warnForUnmatchedText: warnForUnmatchedText$1, 37375 warnForDeletedHydratableElement: warnForDeletedHydratableElement$1, 37376 warnForDeletedHydratableText: warnForDeletedHydratableText$1, 37377 warnForInsertedHydratedElement: warnForInsertedHydratedElement$1, 37378 warnForInsertedHydratedText: warnForInsertedHydratedText$1, 37379 restoreControlledState: restoreControlledState$1 37380}); 37381 37382// TODO: direct imports like some-package/src/* are bad. Fix me. 37383var getCurrentFiberStackAddendum$5 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 37384 37385var validateDOMNesting = emptyFunction; 37386 37387{ 37388 // This validation code was written based on the HTML5 parsing spec: 37389 // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope 37390 // 37391 // Note: this does not catch all invalid nesting, nor does it try to (as it's 37392 // not clear what practical benefit doing so provides); instead, we warn only 37393 // for cases where the parser will give a parse tree differing from what React 37394 // intended. For example, <b><div></div></b> is invalid but we don't warn 37395 // because it still parses correctly; we do warn for other cases like nested 37396 // <p> tags where the beginning of the second element implicitly closes the 37397 // first, causing a confusing mess. 37398 37399 // https://html.spec.whatwg.org/multipage/syntax.html#special 37400 var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp']; 37401 37402 // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope 37403 var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', 37404 37405 // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point 37406 // TODO: Distinguish by namespace here -- for <title>, including it here 37407 // errs on the side of fewer warnings 37408 'foreignObject', 'desc', 'title']; 37409 37410 // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope 37411 var buttonScopeTags = inScopeTags.concat(['button']); 37412 37413 // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags 37414 var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt']; 37415 37416 var emptyAncestorInfo = { 37417 current: null, 37418 37419 formTag: null, 37420 aTagInScope: null, 37421 buttonTagInScope: null, 37422 nobrTagInScope: null, 37423 pTagInButtonScope: null, 37424 37425 listItemTagAutoclosing: null, 37426 dlItemTagAutoclosing: null 37427 }; 37428 37429 var updatedAncestorInfo$1 = function (oldInfo, tag, instance) { 37430 var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo); 37431 var info = { tag: tag, instance: instance }; 37432 37433 if (inScopeTags.indexOf(tag) !== -1) { 37434 ancestorInfo.aTagInScope = null; 37435 ancestorInfo.buttonTagInScope = null; 37436 ancestorInfo.nobrTagInScope = null; 37437 } 37438 if (buttonScopeTags.indexOf(tag) !== -1) { 37439 ancestorInfo.pTagInButtonScope = null; 37440 } 37441 37442 // See rules for 'li', 'dd', 'dt' start tags in 37443 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody 37444 if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') { 37445 ancestorInfo.listItemTagAutoclosing = null; 37446 ancestorInfo.dlItemTagAutoclosing = null; 37447 } 37448 37449 ancestorInfo.current = info; 37450 37451 if (tag === 'form') { 37452 ancestorInfo.formTag = info; 37453 } 37454 if (tag === 'a') { 37455 ancestorInfo.aTagInScope = info; 37456 } 37457 if (tag === 'button') { 37458 ancestorInfo.buttonTagInScope = info; 37459 } 37460 if (tag === 'nobr') { 37461 ancestorInfo.nobrTagInScope = info; 37462 } 37463 if (tag === 'p') { 37464 ancestorInfo.pTagInButtonScope = info; 37465 } 37466 if (tag === 'li') { 37467 ancestorInfo.listItemTagAutoclosing = info; 37468 } 37469 if (tag === 'dd' || tag === 'dt') { 37470 ancestorInfo.dlItemTagAutoclosing = info; 37471 } 37472 37473 return ancestorInfo; 37474 }; 37475 37476 /** 37477 * Returns whether 37478 */ 37479 var isTagValidWithParent = function (tag, parentTag) { 37480 // First, let's check if we're in an unusual parsing mode... 37481 switch (parentTag) { 37482 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect 37483 case 'select': 37484 return tag === 'option' || tag === 'optgroup' || tag === '#text'; 37485 case 'optgroup': 37486 return tag === 'option' || tag === '#text'; 37487 // Strictly speaking, seeing an <option> doesn't mean we're in a <select> 37488 // but 37489 case 'option': 37490 return tag === '#text'; 37491 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd 37492 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption 37493 // No special behavior since these rules fall back to "in body" mode for 37494 // all except special table nodes which cause bad parsing behavior anyway. 37495 37496 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr 37497 case 'tr': 37498 return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template'; 37499 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody 37500 case 'tbody': 37501 case 'thead': 37502 case 'tfoot': 37503 return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template'; 37504 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup 37505 case 'colgroup': 37506 return tag === 'col' || tag === 'template'; 37507 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable 37508 case 'table': 37509 return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template'; 37510 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead 37511 case 'head': 37512 return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template'; 37513 // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element 37514 case 'html': 37515 return tag === 'head' || tag === 'body'; 37516 case '#document': 37517 return tag === 'html'; 37518 } 37519 37520 // Probably in the "in body" parsing mode, so we outlaw only tag combos 37521 // where the parsing rules cause implicit opens or closes to be added. 37522 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody 37523 switch (tag) { 37524 case 'h1': 37525 case 'h2': 37526 case 'h3': 37527 case 'h4': 37528 case 'h5': 37529 case 'h6': 37530 return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6'; 37531 37532 case 'rp': 37533 case 'rt': 37534 return impliedEndTags.indexOf(parentTag) === -1; 37535 37536 case 'body': 37537 case 'caption': 37538 case 'col': 37539 case 'colgroup': 37540 case 'frame': 37541 case 'head': 37542 case 'html': 37543 case 'tbody': 37544 case 'td': 37545 case 'tfoot': 37546 case 'th': 37547 case 'thead': 37548 case 'tr': 37549 // These tags are only valid with a few parents that have special child 37550 // parsing rules -- if we're down here, then none of those matched and 37551 // so we allow it only if we don't know what the parent is, as all other 37552 // cases are invalid. 37553 return parentTag == null; 37554 } 37555 37556 return true; 37557 }; 37558 37559 /** 37560 * Returns whether 37561 */ 37562 var findInvalidAncestorForTag = function (tag, ancestorInfo) { 37563 switch (tag) { 37564 case 'address': 37565 case 'article': 37566 case 'aside': 37567 case 'blockquote': 37568 case 'center': 37569 case 'details': 37570 case 'dialog': 37571 case 'dir': 37572 case 'div': 37573 case 'dl': 37574 case 'fieldset': 37575 case 'figcaption': 37576 case 'figure': 37577 case 'footer': 37578 case 'header': 37579 case 'hgroup': 37580 case 'main': 37581 case 'menu': 37582 case 'nav': 37583 case 'ol': 37584 case 'p': 37585 case 'section': 37586 case 'summary': 37587 case 'ul': 37588 case 'pre': 37589 case 'listing': 37590 case 'table': 37591 case 'hr': 37592 case 'xmp': 37593 case 'h1': 37594 case 'h2': 37595 case 'h3': 37596 case 'h4': 37597 case 'h5': 37598 case 'h6': 37599 return ancestorInfo.pTagInButtonScope; 37600 37601 case 'form': 37602 return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope; 37603 37604 case 'li': 37605 return ancestorInfo.listItemTagAutoclosing; 37606 37607 case 'dd': 37608 case 'dt': 37609 return ancestorInfo.dlItemTagAutoclosing; 37610 37611 case 'button': 37612 return ancestorInfo.buttonTagInScope; 37613 37614 case 'a': 37615 // Spec says something about storing a list of markers, but it sounds 37616 // equivalent to this check. 37617 return ancestorInfo.aTagInScope; 37618 37619 case 'nobr': 37620 return ancestorInfo.nobrTagInScope; 37621 } 37622 37623 return null; 37624 }; 37625 37626 var didWarn = {}; 37627 37628 validateDOMNesting = function (childTag, childText, ancestorInfo) { 37629 ancestorInfo = ancestorInfo || emptyAncestorInfo; 37630 var parentInfo = ancestorInfo.current; 37631 var parentTag = parentInfo && parentInfo.tag; 37632 37633 if (childText != null) { 37634 !(childTag == null) ? warning(false, 'validateDOMNesting: when childText is passed, childTag should be null') : void 0; 37635 childTag = '#text'; 37636 } 37637 37638 var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo; 37639 var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo); 37640 var invalidParentOrAncestor = invalidParent || invalidAncestor; 37641 if (!invalidParentOrAncestor) { 37642 return; 37643 } 37644 37645 var ancestorTag = invalidParentOrAncestor.tag; 37646 var addendum = getCurrentFiberStackAddendum$5(); 37647 37648 var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum; 37649 if (didWarn[warnKey]) { 37650 return; 37651 } 37652 didWarn[warnKey] = true; 37653 37654 var tagDisplayName = childTag; 37655 var whitespaceInfo = ''; 37656 if (childTag === '#text') { 37657 if (/\S/.test(childText)) { 37658 tagDisplayName = 'Text nodes'; 37659 } else { 37660 tagDisplayName = 'Whitespace text nodes'; 37661 whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.'; 37662 } 37663 } else { 37664 tagDisplayName = '<' + childTag + '>'; 37665 } 37666 37667 if (invalidParent) { 37668 var info = ''; 37669 if (ancestorTag === 'table' && childTag === 'tr') { 37670 info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.'; 37671 } 37672 warning(false, 'validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info, addendum); 37673 } else { 37674 warning(false, 'validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.%s', tagDisplayName, ancestorTag, addendum); 37675 } 37676 }; 37677 37678 // TODO: turn this into a named export 37679 validateDOMNesting.updatedAncestorInfo = updatedAncestorInfo$1; 37680} 37681 37682var validateDOMNesting$1 = validateDOMNesting; 37683 37684// Renderers that don't support persistence 37685// can re-export everything from this module. 37686 37687function shim() { 37688 invariant(false, 'The current renderer does not support persistence. This error is likely caused by a bug in React. Please file an issue.'); 37689} 37690 37691// Persistence (when unsupported) 37692var supportsPersistence = false; 37693var cloneInstance = shim; 37694var createContainerChildSet = shim; 37695var appendChildToContainerChildSet = shim; 37696var finalizeContainerChildren = shim; 37697var replaceContainerChildren = shim; 37698 37699// Unused 37700 37701var createElement = createElement$1; 37702var createTextNode = createTextNode$1; 37703var setInitialProperties = setInitialProperties$1; 37704var diffProperties = diffProperties$1; 37705var updateProperties = updateProperties$1; 37706var diffHydratedProperties = diffHydratedProperties$1; 37707var diffHydratedText = diffHydratedText$1; 37708var warnForUnmatchedText = warnForUnmatchedText$1; 37709var warnForDeletedHydratableElement = warnForDeletedHydratableElement$1; 37710var warnForDeletedHydratableText = warnForDeletedHydratableText$1; 37711var warnForInsertedHydratedElement = warnForInsertedHydratedElement$1; 37712var warnForInsertedHydratedText = warnForInsertedHydratedText$1; 37713var updatedAncestorInfo = validateDOMNesting$1.updatedAncestorInfo; 37714var precacheFiberNode$1 = precacheFiberNode; 37715var updateFiberProps$1 = updateFiberProps; 37716 37717 37718var SUPPRESS_HYDRATION_WARNING = void 0; 37719{ 37720 SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning'; 37721} 37722 37723var eventsEnabled = null; 37724var selectionInformation = null; 37725 37726function shouldAutoFocusHostComponent(type, props) { 37727 switch (type) { 37728 case 'button': 37729 case 'input': 37730 case 'select': 37731 case 'textarea': 37732 return !!props.autoFocus; 37733 } 37734 return false; 37735} 37736 37737function getRootHostContext(rootContainerInstance) { 37738 var type = void 0; 37739 var namespace = void 0; 37740 var nodeType = rootContainerInstance.nodeType; 37741 switch (nodeType) { 37742 case DOCUMENT_NODE: 37743 case DOCUMENT_FRAGMENT_NODE: 37744 { 37745 type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment'; 37746 var root = rootContainerInstance.documentElement; 37747 namespace = root ? root.namespaceURI : getChildNamespace(null, ''); 37748 break; 37749 } 37750 default: 37751 { 37752 var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance; 37753 var ownNamespace = container.namespaceURI || null; 37754 type = container.tagName; 37755 namespace = getChildNamespace(ownNamespace, type); 37756 break; 37757 } 37758 } 37759 { 37760 var validatedTag = type.toLowerCase(); 37761 var _ancestorInfo = updatedAncestorInfo(null, validatedTag, null); 37762 return { namespace: namespace, ancestorInfo: _ancestorInfo }; 37763 } 37764 return namespace; 37765} 37766 37767function getChildHostContext(parentHostContext, type, rootContainerInstance) { 37768 { 37769 var parentHostContextDev = parentHostContext; 37770 var _namespace = getChildNamespace(parentHostContextDev.namespace, type); 37771 var _ancestorInfo2 = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type, null); 37772 return { namespace: _namespace, ancestorInfo: _ancestorInfo2 }; 37773 } 37774 var parentNamespace = parentHostContext; 37775 return getChildNamespace(parentNamespace, type); 37776} 37777 37778function getPublicInstance(instance) { 37779 return instance; 37780} 37781 37782function prepareForCommit(containerInfo) { 37783 eventsEnabled = isEnabled(); 37784 selectionInformation = getSelectionInformation(); 37785 setEnabled(false); 37786} 37787 37788function resetAfterCommit(containerInfo) { 37789 restoreSelection(selectionInformation); 37790 selectionInformation = null; 37791 setEnabled(eventsEnabled); 37792 eventsEnabled = null; 37793} 37794 37795function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) { 37796 var parentNamespace = void 0; 37797 { 37798 // TODO: take namespace into account when validating. 37799 var hostContextDev = hostContext; 37800 validateDOMNesting$1(type, null, hostContextDev.ancestorInfo); 37801 if (typeof props.children === 'string' || typeof props.children === 'number') { 37802 var string = '' + props.children; 37803 var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type, null); 37804 validateDOMNesting$1(null, string, ownAncestorInfo); 37805 } 37806 parentNamespace = hostContextDev.namespace; 37807 } 37808 var domElement = createElement(type, props, rootContainerInstance, parentNamespace); 37809 precacheFiberNode$1(internalInstanceHandle, domElement); 37810 updateFiberProps$1(domElement, props); 37811 return domElement; 37812} 37813 37814function appendInitialChild(parentInstance, child) { 37815 parentInstance.appendChild(child); 37816} 37817 37818function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) { 37819 setInitialProperties(domElement, type, props, rootContainerInstance); 37820 return shouldAutoFocusHostComponent(type, props); 37821} 37822 37823function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) { 37824 { 37825 var hostContextDev = hostContext; 37826 if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) { 37827 var string = '' + newProps.children; 37828 var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type, null); 37829 validateDOMNesting$1(null, string, ownAncestorInfo); 37830 } 37831 } 37832 return diffProperties(domElement, type, oldProps, newProps, rootContainerInstance); 37833} 37834 37835function shouldSetTextContent(type, props) { 37836 return type === 'textarea' || typeof props.children === 'string' || typeof props.children === 'number' || typeof props.dangerouslySetInnerHTML === 'object' && props.dangerouslySetInnerHTML !== null && typeof props.dangerouslySetInnerHTML.__html === 'string'; 37837} 37838 37839function shouldDeprioritizeSubtree(type, props) { 37840 return !!props.hidden; 37841} 37842 37843function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) { 37844 { 37845 var hostContextDev = hostContext; 37846 validateDOMNesting$1(null, text, hostContextDev.ancestorInfo); 37847 } 37848 var textNode = createTextNode(text, rootContainerInstance); 37849 precacheFiberNode$1(internalInstanceHandle, textNode); 37850 return textNode; 37851} 37852 37853var now = now$1; 37854var isPrimaryRenderer = true; 37855var scheduleDeferredCallback = scheduleWork; 37856var cancelDeferredCallback = cancelScheduledWork; 37857 37858// ------------------- 37859// Mutation 37860// ------------------- 37861 37862var supportsMutation = true; 37863 37864function commitMount(domElement, type, newProps, internalInstanceHandle) { 37865 // Despite the naming that might imply otherwise, this method only 37866 // fires if there is an `Update` effect scheduled during mounting. 37867 // This happens if `finalizeInitialChildren` returns `true` (which it 37868 // does to implement the `autoFocus` attribute on the client). But 37869 // there are also other cases when this might happen (such as patching 37870 // up text content during hydration mismatch). So we'll check this again. 37871 if (shouldAutoFocusHostComponent(type, newProps)) { 37872 domElement.focus(); 37873 } 37874} 37875 37876function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) { 37877 // Update the props handle so that we know which props are the ones with 37878 // with current event handlers. 37879 updateFiberProps$1(domElement, newProps); 37880 // Apply the diff to the DOM node. 37881 updateProperties(domElement, updatePayload, type, oldProps, newProps); 37882} 37883 37884function resetTextContent(domElement) { 37885 setTextContent(domElement, ''); 37886} 37887 37888function commitTextUpdate(textInstance, oldText, newText) { 37889 textInstance.nodeValue = newText; 37890} 37891 37892function appendChild(parentInstance, child) { 37893 parentInstance.appendChild(child); 37894} 37895 37896function appendChildToContainer(container, child) { 37897 if (container.nodeType === COMMENT_NODE) { 37898 container.parentNode.insertBefore(child, container); 37899 } else { 37900 container.appendChild(child); 37901 } 37902} 37903 37904function insertBefore(parentInstance, child, beforeChild) { 37905 parentInstance.insertBefore(child, beforeChild); 37906} 37907 37908function insertInContainerBefore(container, child, beforeChild) { 37909 if (container.nodeType === COMMENT_NODE) { 37910 container.parentNode.insertBefore(child, beforeChild); 37911 } else { 37912 container.insertBefore(child, beforeChild); 37913 } 37914} 37915 37916function removeChild(parentInstance, child) { 37917 parentInstance.removeChild(child); 37918} 37919 37920function removeChildFromContainer(container, child) { 37921 if (container.nodeType === COMMENT_NODE) { 37922 container.parentNode.removeChild(child); 37923 } else { 37924 container.removeChild(child); 37925 } 37926} 37927 37928// ------------------- 37929// Hydration 37930// ------------------- 37931 37932var supportsHydration = true; 37933 37934function canHydrateInstance(instance, type, props) { 37935 if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) { 37936 return null; 37937 } 37938 // This has now been refined to an element node. 37939 return instance; 37940} 37941 37942function canHydrateTextInstance(instance, text) { 37943 if (text === '' || instance.nodeType !== TEXT_NODE) { 37944 // Empty strings are not parsed by HTML so there won't be a correct match here. 37945 return null; 37946 } 37947 // This has now been refined to a text node. 37948 return instance; 37949} 37950 37951function getNextHydratableSibling(instance) { 37952 var node = instance.nextSibling; 37953 // Skip non-hydratable nodes. 37954 while (node && node.nodeType !== ELEMENT_NODE && node.nodeType !== TEXT_NODE) { 37955 node = node.nextSibling; 37956 } 37957 return node; 37958} 37959 37960function getFirstHydratableChild(parentInstance) { 37961 var next = parentInstance.firstChild; 37962 // Skip non-hydratable nodes. 37963 while (next && next.nodeType !== ELEMENT_NODE && next.nodeType !== TEXT_NODE) { 37964 next = next.nextSibling; 37965 } 37966 return next; 37967} 37968 37969function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) { 37970 precacheFiberNode$1(internalInstanceHandle, instance); 37971 // TODO: Possibly defer this until the commit phase where all the events 37972 // get attached. 37973 updateFiberProps$1(instance, props); 37974 var parentNamespace = void 0; 37975 { 37976 var hostContextDev = hostContext; 37977 parentNamespace = hostContextDev.namespace; 37978 } 37979 return diffHydratedProperties(instance, type, props, parentNamespace, rootContainerInstance); 37980} 37981 37982function hydrateTextInstance(textInstance, text, internalInstanceHandle) { 37983 precacheFiberNode$1(internalInstanceHandle, textInstance); 37984 return diffHydratedText(textInstance, text); 37985} 37986 37987function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) { 37988 { 37989 warnForUnmatchedText(textInstance, text); 37990 } 37991} 37992 37993function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) { 37994 if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) { 37995 warnForUnmatchedText(textInstance, text); 37996 } 37997} 37998 37999function didNotHydrateContainerInstance(parentContainer, instance) { 38000 { 38001 if (instance.nodeType === 1) { 38002 warnForDeletedHydratableElement(parentContainer, instance); 38003 } else { 38004 warnForDeletedHydratableText(parentContainer, instance); 38005 } 38006 } 38007} 38008 38009function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) { 38010 if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) { 38011 if (instance.nodeType === 1) { 38012 warnForDeletedHydratableElement(parentInstance, instance); 38013 } else { 38014 warnForDeletedHydratableText(parentInstance, instance); 38015 } 38016 } 38017} 38018 38019function didNotFindHydratableContainerInstance(parentContainer, type, props) { 38020 { 38021 warnForInsertedHydratedElement(parentContainer, type, props); 38022 } 38023} 38024 38025function didNotFindHydratableContainerTextInstance(parentContainer, text) { 38026 { 38027 warnForInsertedHydratedText(parentContainer, text); 38028 } 38029} 38030 38031function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) { 38032 if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) { 38033 warnForInsertedHydratedElement(parentInstance, type, props); 38034 } 38035} 38036 38037function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) { 38038 if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) { 38039 warnForInsertedHydratedText(parentInstance, text); 38040 } 38041} 38042 38043// Exports ReactDOM.createRoot 38044var enableUserTimingAPI = true; 38045 38046// Experimental error-boundary API that can recover from errors within a single 38047// render phase 38048var enableGetDerivedStateFromCatch = false; 38049// Suspense 38050var enableSuspense = false; 38051// Helps identify side effects in begin-phase lifecycle hooks and setState reducers: 38052var debugRenderPhaseSideEffects = false; 38053 38054// In some cases, StrictMode should also double-render lifecycles. 38055// This can be confusing for tests though, 38056// And it can be bad for performance in production. 38057// This feature flag can be used to control the behavior: 38058var debugRenderPhaseSideEffectsForStrictMode = true; 38059 38060// To preserve the "Pause on caught exceptions" behavior of the debugger, we 38061// replay the begin phase of a failed component inside invokeGuardedCallback. 38062var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; 38063 38064// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6: 38065var warnAboutDeprecatedLifecycles = false; 38066 38067// Warn about legacy context API 38068var warnAboutLegacyContextAPI = false; 38069 38070// Gather advanced timing metrics for Profiler subtrees. 38071var enableProfilerTimer = true; 38072 38073// Only used in www builds. 38074 38075// Prefix measurements so that it's possible to filter them. 38076// Longer prefixes are hard to read in DevTools. 38077var reactEmoji = '\u269B'; 38078var warningEmoji = '\u26D4'; 38079var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; 38080 38081// Keep track of current fiber so that we know the path to unwind on pause. 38082// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them? 38083var currentFiber = null; 38084// If we're in the middle of user code, which fiber and method is it? 38085// Reusing `currentFiber` would be confusing for this because user code fiber 38086// can change during commit phase too, but we don't need to unwind it (since 38087// lifecycles in the commit phase don't resemble a tree). 38088var currentPhase = null; 38089var currentPhaseFiber = null; 38090// Did lifecycle hook schedule an update? This is often a performance problem, 38091// so we will keep track of it, and include it in the report. 38092// Track commits caused by cascading updates. 38093var isCommitting = false; 38094var hasScheduledUpdateInCurrentCommit = false; 38095var hasScheduledUpdateInCurrentPhase = false; 38096var commitCountInCurrentWorkLoop = 0; 38097var effectCountInCurrentCommit = 0; 38098var isWaitingForCallback = false; 38099// During commits, we only show a measurement once per method name 38100// to avoid stretch the commit phase with measurement overhead. 38101var labelsInCurrentCommit = new Set(); 38102 38103var formatMarkName = function (markName) { 38104 return reactEmoji + ' ' + markName; 38105}; 38106 38107var formatLabel = function (label, warning$$1) { 38108 var prefix = warning$$1 ? warningEmoji + ' ' : reactEmoji + ' '; 38109 var suffix = warning$$1 ? ' Warning: ' + warning$$1 : ''; 38110 return '' + prefix + label + suffix; 38111}; 38112 38113var beginMark = function (markName) { 38114 performance.mark(formatMarkName(markName)); 38115}; 38116 38117var clearMark = function (markName) { 38118 performance.clearMarks(formatMarkName(markName)); 38119}; 38120 38121var endMark = function (label, markName, warning$$1) { 38122 var formattedMarkName = formatMarkName(markName); 38123 var formattedLabel = formatLabel(label, warning$$1); 38124 try { 38125 performance.measure(formattedLabel, formattedMarkName); 38126 } catch (err) {} 38127 // If previous mark was missing for some reason, this will throw. 38128 // This could only happen if React crashed in an unexpected place earlier. 38129 // Don't pile on with more errors. 38130 38131 // Clear marks immediately to avoid growing buffer. 38132 performance.clearMarks(formattedMarkName); 38133 performance.clearMeasures(formattedLabel); 38134}; 38135 38136var getFiberMarkName = function (label, debugID) { 38137 return label + ' (#' + debugID + ')'; 38138}; 38139 38140var getFiberLabel = function (componentName, isMounted, phase) { 38141 if (phase === null) { 38142 // These are composite component total time measurements. 38143 return componentName + ' [' + (isMounted ? 'update' : 'mount') + ']'; 38144 } else { 38145 // Composite component methods. 38146 return componentName + '.' + phase; 38147 } 38148}; 38149 38150var beginFiberMark = function (fiber, phase) { 38151 var componentName = getComponentName(fiber) || 'Unknown'; 38152 var debugID = fiber._debugID; 38153 var isMounted = fiber.alternate !== null; 38154 var label = getFiberLabel(componentName, isMounted, phase); 38155 38156 if (isCommitting && labelsInCurrentCommit.has(label)) { 38157 // During the commit phase, we don't show duplicate labels because 38158 // there is a fixed overhead for every measurement, and we don't 38159 // want to stretch the commit phase beyond necessary. 38160 return false; 38161 } 38162 labelsInCurrentCommit.add(label); 38163 38164 var markName = getFiberMarkName(label, debugID); 38165 beginMark(markName); 38166 return true; 38167}; 38168 38169var clearFiberMark = function (fiber, phase) { 38170 var componentName = getComponentName(fiber) || 'Unknown'; 38171 var debugID = fiber._debugID; 38172 var isMounted = fiber.alternate !== null; 38173 var label = getFiberLabel(componentName, isMounted, phase); 38174 var markName = getFiberMarkName(label, debugID); 38175 clearMark(markName); 38176}; 38177 38178var endFiberMark = function (fiber, phase, warning$$1) { 38179 var componentName = getComponentName(fiber) || 'Unknown'; 38180 var debugID = fiber._debugID; 38181 var isMounted = fiber.alternate !== null; 38182 var label = getFiberLabel(componentName, isMounted, phase); 38183 var markName = getFiberMarkName(label, debugID); 38184 endMark(label, markName, warning$$1); 38185}; 38186 38187var shouldIgnoreFiber = function (fiber) { 38188 // Host components should be skipped in the timeline. 38189 // We could check typeof fiber.type, but does this work with RN? 38190 switch (fiber.tag) { 38191 case HostRoot: 38192 case HostComponent: 38193 case HostText: 38194 case HostPortal: 38195 case Fragment: 38196 case ContextProvider: 38197 case ContextConsumer: 38198 case Mode: 38199 return true; 38200 default: 38201 return false; 38202 } 38203}; 38204 38205var clearPendingPhaseMeasurement = function () { 38206 if (currentPhase !== null && currentPhaseFiber !== null) { 38207 clearFiberMark(currentPhaseFiber, currentPhase); 38208 } 38209 currentPhaseFiber = null; 38210 currentPhase = null; 38211 hasScheduledUpdateInCurrentPhase = false; 38212}; 38213 38214var pauseTimers = function () { 38215 // Stops all currently active measurements so that they can be resumed 38216 // if we continue in a later deferred loop from the same unit of work. 38217 var fiber = currentFiber; 38218 while (fiber) { 38219 if (fiber._debugIsCurrentlyTiming) { 38220 endFiberMark(fiber, null, null); 38221 } 38222 fiber = fiber.return; 38223 } 38224}; 38225 38226var resumeTimersRecursively = function (fiber) { 38227 if (fiber.return !== null) { 38228 resumeTimersRecursively(fiber.return); 38229 } 38230 if (fiber._debugIsCurrentlyTiming) { 38231 beginFiberMark(fiber, null); 38232 } 38233}; 38234 38235var resumeTimers = function () { 38236 // Resumes all measurements that were active during the last deferred loop. 38237 if (currentFiber !== null) { 38238 resumeTimersRecursively(currentFiber); 38239 } 38240}; 38241 38242function recordEffect() { 38243 if (enableUserTimingAPI) { 38244 effectCountInCurrentCommit++; 38245 } 38246} 38247 38248function recordScheduleUpdate() { 38249 if (enableUserTimingAPI) { 38250 if (isCommitting) { 38251 hasScheduledUpdateInCurrentCommit = true; 38252 } 38253 if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') { 38254 hasScheduledUpdateInCurrentPhase = true; 38255 } 38256 } 38257} 38258 38259function startRequestCallbackTimer() { 38260 if (enableUserTimingAPI) { 38261 if (supportsUserTiming && !isWaitingForCallback) { 38262 isWaitingForCallback = true; 38263 beginMark('(Waiting for async callback...)'); 38264 } 38265 } 38266} 38267 38268function stopRequestCallbackTimer(didExpire, expirationTime) { 38269 if (enableUserTimingAPI) { 38270 if (supportsUserTiming) { 38271 isWaitingForCallback = false; 38272 var warning$$1 = didExpire ? 'React was blocked by main thread' : null; 38273 endMark('(Waiting for async callback... will force flush in ' + expirationTime + ' ms)', '(Waiting for async callback...)', warning$$1); 38274 } 38275 } 38276} 38277 38278function startWorkTimer(fiber) { 38279 if (enableUserTimingAPI) { 38280 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 38281 return; 38282 } 38283 // If we pause, this is the fiber to unwind from. 38284 currentFiber = fiber; 38285 if (!beginFiberMark(fiber, null)) { 38286 return; 38287 } 38288 fiber._debugIsCurrentlyTiming = true; 38289 } 38290} 38291 38292function cancelWorkTimer(fiber) { 38293 if (enableUserTimingAPI) { 38294 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 38295 return; 38296 } 38297 // Remember we shouldn't complete measurement for this fiber. 38298 // Otherwise flamechart will be deep even for small updates. 38299 fiber._debugIsCurrentlyTiming = false; 38300 clearFiberMark(fiber, null); 38301 } 38302} 38303 38304function stopWorkTimer(fiber) { 38305 if (enableUserTimingAPI) { 38306 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 38307 return; 38308 } 38309 // If we pause, its parent is the fiber to unwind from. 38310 currentFiber = fiber.return; 38311 if (!fiber._debugIsCurrentlyTiming) { 38312 return; 38313 } 38314 fiber._debugIsCurrentlyTiming = false; 38315 endFiberMark(fiber, null, null); 38316 } 38317} 38318 38319function stopFailedWorkTimer(fiber) { 38320 if (enableUserTimingAPI) { 38321 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 38322 return; 38323 } 38324 // If we pause, its parent is the fiber to unwind from. 38325 currentFiber = fiber.return; 38326 if (!fiber._debugIsCurrentlyTiming) { 38327 return; 38328 } 38329 fiber._debugIsCurrentlyTiming = false; 38330 var warning$$1 = 'An error was thrown inside this error boundary'; 38331 endFiberMark(fiber, null, warning$$1); 38332 } 38333} 38334 38335function startPhaseTimer(fiber, phase) { 38336 if (enableUserTimingAPI) { 38337 if (!supportsUserTiming) { 38338 return; 38339 } 38340 clearPendingPhaseMeasurement(); 38341 if (!beginFiberMark(fiber, phase)) { 38342 return; 38343 } 38344 currentPhaseFiber = fiber; 38345 currentPhase = phase; 38346 } 38347} 38348 38349function stopPhaseTimer() { 38350 if (enableUserTimingAPI) { 38351 if (!supportsUserTiming) { 38352 return; 38353 } 38354 if (currentPhase !== null && currentPhaseFiber !== null) { 38355 var warning$$1 = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null; 38356 endFiberMark(currentPhaseFiber, currentPhase, warning$$1); 38357 } 38358 currentPhase = null; 38359 currentPhaseFiber = null; 38360 } 38361} 38362 38363function startWorkLoopTimer(nextUnitOfWork) { 38364 if (enableUserTimingAPI) { 38365 currentFiber = nextUnitOfWork; 38366 if (!supportsUserTiming) { 38367 return; 38368 } 38369 commitCountInCurrentWorkLoop = 0; 38370 // This is top level call. 38371 // Any other measurements are performed within. 38372 beginMark('(React Tree Reconciliation)'); 38373 // Resume any measurements that were in progress during the last loop. 38374 resumeTimers(); 38375 } 38376} 38377 38378function stopWorkLoopTimer(interruptedBy, didCompleteRoot) { 38379 if (enableUserTimingAPI) { 38380 if (!supportsUserTiming) { 38381 return; 38382 } 38383 var warning$$1 = null; 38384 if (interruptedBy !== null) { 38385 if (interruptedBy.tag === HostRoot) { 38386 warning$$1 = 'A top-level update interrupted the previous render'; 38387 } else { 38388 var componentName = getComponentName(interruptedBy) || 'Unknown'; 38389 warning$$1 = 'An update to ' + componentName + ' interrupted the previous render'; 38390 } 38391 } else if (commitCountInCurrentWorkLoop > 1) { 38392 warning$$1 = 'There were cascading updates'; 38393 } 38394 commitCountInCurrentWorkLoop = 0; 38395 var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)'; 38396 // Pause any measurements until the next loop. 38397 pauseTimers(); 38398 endMark(label, '(React Tree Reconciliation)', warning$$1); 38399 } 38400} 38401 38402function startCommitTimer() { 38403 if (enableUserTimingAPI) { 38404 if (!supportsUserTiming) { 38405 return; 38406 } 38407 isCommitting = true; 38408 hasScheduledUpdateInCurrentCommit = false; 38409 labelsInCurrentCommit.clear(); 38410 beginMark('(Committing Changes)'); 38411 } 38412} 38413 38414function stopCommitTimer() { 38415 if (enableUserTimingAPI) { 38416 if (!supportsUserTiming) { 38417 return; 38418 } 38419 38420 var warning$$1 = null; 38421 if (hasScheduledUpdateInCurrentCommit) { 38422 warning$$1 = 'Lifecycle hook scheduled a cascading update'; 38423 } else if (commitCountInCurrentWorkLoop > 0) { 38424 warning$$1 = 'Caused by a cascading update in earlier commit'; 38425 } 38426 hasScheduledUpdateInCurrentCommit = false; 38427 commitCountInCurrentWorkLoop++; 38428 isCommitting = false; 38429 labelsInCurrentCommit.clear(); 38430 38431 endMark('(Committing Changes)', '(Committing Changes)', warning$$1); 38432 } 38433} 38434 38435function startCommitSnapshotEffectsTimer() { 38436 if (enableUserTimingAPI) { 38437 if (!supportsUserTiming) { 38438 return; 38439 } 38440 effectCountInCurrentCommit = 0; 38441 beginMark('(Committing Snapshot Effects)'); 38442 } 38443} 38444 38445function stopCommitSnapshotEffectsTimer() { 38446 if (enableUserTimingAPI) { 38447 if (!supportsUserTiming) { 38448 return; 38449 } 38450 var count = effectCountInCurrentCommit; 38451 effectCountInCurrentCommit = 0; 38452 endMark('(Committing Snapshot Effects: ' + count + ' Total)', '(Committing Snapshot Effects)', null); 38453 } 38454} 38455 38456function startCommitHostEffectsTimer() { 38457 if (enableUserTimingAPI) { 38458 if (!supportsUserTiming) { 38459 return; 38460 } 38461 effectCountInCurrentCommit = 0; 38462 beginMark('(Committing Host Effects)'); 38463 } 38464} 38465 38466function stopCommitHostEffectsTimer() { 38467 if (enableUserTimingAPI) { 38468 if (!supportsUserTiming) { 38469 return; 38470 } 38471 var count = effectCountInCurrentCommit; 38472 effectCountInCurrentCommit = 0; 38473 endMark('(Committing Host Effects: ' + count + ' Total)', '(Committing Host Effects)', null); 38474 } 38475} 38476 38477function startCommitLifeCyclesTimer() { 38478 if (enableUserTimingAPI) { 38479 if (!supportsUserTiming) { 38480 return; 38481 } 38482 effectCountInCurrentCommit = 0; 38483 beginMark('(Calling Lifecycle Methods)'); 38484 } 38485} 38486 38487function stopCommitLifeCyclesTimer() { 38488 if (enableUserTimingAPI) { 38489 if (!supportsUserTiming) { 38490 return; 38491 } 38492 var count = effectCountInCurrentCommit; 38493 effectCountInCurrentCommit = 0; 38494 endMark('(Calling Lifecycle Methods: ' + count + ' Total)', '(Calling Lifecycle Methods)', null); 38495 } 38496} 38497 38498var valueStack = []; 38499 38500var fiberStack = void 0; 38501 38502{ 38503 fiberStack = []; 38504} 38505 38506var index = -1; 38507 38508function createCursor(defaultValue) { 38509 return { 38510 current: defaultValue 38511 }; 38512} 38513 38514function pop(cursor, fiber) { 38515 if (index < 0) { 38516 { 38517 warning(false, 'Unexpected pop.'); 38518 } 38519 return; 38520 } 38521 38522 { 38523 if (fiber !== fiberStack[index]) { 38524 warning(false, 'Unexpected Fiber popped.'); 38525 } 38526 } 38527 38528 cursor.current = valueStack[index]; 38529 38530 valueStack[index] = null; 38531 38532 { 38533 fiberStack[index] = null; 38534 } 38535 38536 index--; 38537} 38538 38539function push(cursor, value, fiber) { 38540 index++; 38541 38542 valueStack[index] = cursor.current; 38543 38544 { 38545 fiberStack[index] = fiber; 38546 } 38547 38548 cursor.current = value; 38549} 38550 38551function checkThatStackIsEmpty() { 38552 { 38553 if (index !== -1) { 38554 warning(false, 'Expected an empty stack. Something was not reset properly.'); 38555 } 38556 } 38557} 38558 38559function resetStackAfterFatalErrorInDev() { 38560 { 38561 index = -1; 38562 valueStack.length = 0; 38563 fiberStack.length = 0; 38564 } 38565} 38566 38567var warnedAboutMissingGetChildContext = void 0; 38568 38569{ 38570 warnedAboutMissingGetChildContext = {}; 38571} 38572 38573// A cursor to the current merged context object on the stack. 38574var contextStackCursor = createCursor(emptyObject); 38575// A cursor to a boolean indicating whether the context has changed. 38576var didPerformWorkStackCursor = createCursor(false); 38577// Keep track of the previous context object that was on the stack. 38578// We use this to get access to the parent context after we have already 38579// pushed the next context provider, and now need to merge their contexts. 38580var previousContext = emptyObject; 38581 38582function getUnmaskedContext(workInProgress) { 38583 var hasOwnContext = isContextProvider(workInProgress); 38584 if (hasOwnContext) { 38585 // If the fiber is a context provider itself, when we read its context 38586 // we have already pushed its own child context on the stack. A context 38587 // provider should not "see" its own child context. Therefore we read the 38588 // previous (parent) context instead for a context provider. 38589 return previousContext; 38590 } 38591 return contextStackCursor.current; 38592} 38593 38594function cacheContext(workInProgress, unmaskedContext, maskedContext) { 38595 var instance = workInProgress.stateNode; 38596 instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; 38597 instance.__reactInternalMemoizedMaskedChildContext = maskedContext; 38598} 38599 38600function getMaskedContext(workInProgress, unmaskedContext) { 38601 var type = workInProgress.type; 38602 var contextTypes = type.contextTypes; 38603 if (!contextTypes) { 38604 return emptyObject; 38605 } 38606 38607 // Avoid recreating masked context unless unmasked context has changed. 38608 // Failing to do this will result in unnecessary calls to componentWillReceiveProps. 38609 // This may trigger infinite loops if componentWillReceiveProps calls setState. 38610 var instance = workInProgress.stateNode; 38611 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { 38612 return instance.__reactInternalMemoizedMaskedChildContext; 38613 } 38614 38615 var context = {}; 38616 for (var key in contextTypes) { 38617 context[key] = unmaskedContext[key]; 38618 } 38619 38620 { 38621 var name = getComponentName(workInProgress) || 'Unknown'; 38622 checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum); 38623 } 38624 38625 // Cache unmasked context so we can avoid recreating masked context unless necessary. 38626 // Context is created before the class component is instantiated so check for instance. 38627 if (instance) { 38628 cacheContext(workInProgress, unmaskedContext, context); 38629 } 38630 38631 return context; 38632} 38633 38634function hasContextChanged() { 38635 return didPerformWorkStackCursor.current; 38636} 38637 38638function isContextConsumer(fiber) { 38639 return fiber.tag === ClassComponent && fiber.type.contextTypes != null; 38640} 38641 38642function isContextProvider(fiber) { 38643 return fiber.tag === ClassComponent && fiber.type.childContextTypes != null; 38644} 38645 38646function popContextProvider(fiber) { 38647 if (!isContextProvider(fiber)) { 38648 return; 38649 } 38650 38651 pop(didPerformWorkStackCursor, fiber); 38652 pop(contextStackCursor, fiber); 38653} 38654 38655function popTopLevelContextObject(fiber) { 38656 pop(didPerformWorkStackCursor, fiber); 38657 pop(contextStackCursor, fiber); 38658} 38659 38660function pushTopLevelContextObject(fiber, context, didChange) { 38661 !(contextStackCursor.current === emptyObject) ? invariant(false, 'Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.') : void 0; 38662 38663 push(contextStackCursor, context, fiber); 38664 push(didPerformWorkStackCursor, didChange, fiber); 38665} 38666 38667function processChildContext(fiber, parentContext) { 38668 var instance = fiber.stateNode; 38669 var childContextTypes = fiber.type.childContextTypes; 38670 38671 // TODO (bvaughn) Replace this behavior with an invariant() in the future. 38672 // It has only been added in Fiber to match the (unintentional) behavior in Stack. 38673 if (typeof instance.getChildContext !== 'function') { 38674 { 38675 var componentName = getComponentName(fiber) || 'Unknown'; 38676 38677 if (!warnedAboutMissingGetChildContext[componentName]) { 38678 warnedAboutMissingGetChildContext[componentName] = true; 38679 warning(false, '%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); 38680 } 38681 } 38682 return parentContext; 38683 } 38684 38685 var childContext = void 0; 38686 { 38687 ReactDebugCurrentFiber.setCurrentPhase('getChildContext'); 38688 } 38689 startPhaseTimer(fiber, 'getChildContext'); 38690 childContext = instance.getChildContext(); 38691 stopPhaseTimer(); 38692 { 38693 ReactDebugCurrentFiber.setCurrentPhase(null); 38694 } 38695 for (var contextKey in childContext) { 38696 !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(fiber) || 'Unknown', contextKey) : void 0; 38697 } 38698 { 38699 var name = getComponentName(fiber) || 'Unknown'; 38700 checkPropTypes(childContextTypes, childContext, 'child context', name, 38701 // In practice, there is one case in which we won't get a stack. It's when 38702 // somebody calls unstable_renderSubtreeIntoContainer() and we process 38703 // context from the parent component instance. The stack will be missing 38704 // because it's outside of the reconciliation, and so the pointer has not 38705 // been set. This is rare and doesn't matter. We'll also remove that API. 38706 ReactDebugCurrentFiber.getCurrentFiberStackAddendum); 38707 } 38708 38709 return _assign({}, parentContext, childContext); 38710} 38711 38712function pushContextProvider(workInProgress) { 38713 if (!isContextProvider(workInProgress)) { 38714 return false; 38715 } 38716 38717 var instance = workInProgress.stateNode; 38718 // We push the context as early as possible to ensure stack integrity. 38719 // If the instance does not exist yet, we will push null at first, 38720 // and replace it on the stack later when invalidating the context. 38721 var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyObject; 38722 38723 // Remember the parent context so we can merge with it later. 38724 // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. 38725 previousContext = contextStackCursor.current; 38726 push(contextStackCursor, memoizedMergedChildContext, workInProgress); 38727 push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); 38728 38729 return true; 38730} 38731 38732function invalidateContextProvider(workInProgress, didChange) { 38733 var instance = workInProgress.stateNode; 38734 !instance ? invariant(false, 'Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.') : void 0; 38735 38736 if (didChange) { 38737 // Merge parent and own context. 38738 // Skip this if we're not updating due to sCU. 38739 // This avoids unnecessarily recomputing memoized values. 38740 var mergedContext = processChildContext(workInProgress, previousContext); 38741 instance.__reactInternalMemoizedMergedChildContext = mergedContext; 38742 38743 // Replace the old (or empty) context with the new one. 38744 // It is important to unwind the context in the reverse order. 38745 pop(didPerformWorkStackCursor, workInProgress); 38746 pop(contextStackCursor, workInProgress); 38747 // Now push the new context and mark that it has changed. 38748 push(contextStackCursor, mergedContext, workInProgress); 38749 push(didPerformWorkStackCursor, didChange, workInProgress); 38750 } else { 38751 pop(didPerformWorkStackCursor, workInProgress); 38752 push(didPerformWorkStackCursor, didChange, workInProgress); 38753 } 38754} 38755 38756function findCurrentUnmaskedContext(fiber) { 38757 // Currently this is only used with renderSubtreeIntoContainer; not sure if it 38758 // makes sense elsewhere 38759 !(isFiberMounted(fiber) && fiber.tag === ClassComponent) ? invariant(false, 'Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.') : void 0; 38760 38761 var node = fiber; 38762 while (node.tag !== HostRoot) { 38763 if (isContextProvider(node)) { 38764 return node.stateNode.__reactInternalMemoizedMergedChildContext; 38765 } 38766 var parent = node.return; 38767 !parent ? invariant(false, 'Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.') : void 0; 38768 node = parent; 38769 } 38770 return node.stateNode.context; 38771} 38772 38773// Max 31 bit integer. The max integer size in V8 for 32-bit systems. 38774// Math.pow(2, 30) - 1 38775// 0b111111111111111111111111111111 38776var MAX_SIGNED_31_BIT_INT = 1073741823; 38777 38778// TODO: Use an opaque type once ESLint et al support the syntax 38779 38780 38781var NoWork = 0; 38782var Sync = 1; 38783var Never = MAX_SIGNED_31_BIT_INT; 38784 38785var UNIT_SIZE = 10; 38786var MAGIC_NUMBER_OFFSET = 2; 38787 38788// 1 unit of expiration time represents 10ms. 38789function msToExpirationTime(ms) { 38790 // Always add an offset so that we don't clash with the magic number for NoWork. 38791 return (ms / UNIT_SIZE | 0) + MAGIC_NUMBER_OFFSET; 38792} 38793 38794function expirationTimeToMs(expirationTime) { 38795 return (expirationTime - MAGIC_NUMBER_OFFSET) * UNIT_SIZE; 38796} 38797 38798function ceiling(num, precision) { 38799 return ((num / precision | 0) + 1) * precision; 38800} 38801 38802function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { 38803 return MAGIC_NUMBER_OFFSET + ceiling(currentTime - MAGIC_NUMBER_OFFSET + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE); 38804} 38805 38806var NoContext = 0; 38807var AsyncMode = 1; 38808var StrictMode = 2; 38809var ProfileMode = 4; 38810 38811var hasBadMapPolyfill = void 0; 38812 38813{ 38814 hasBadMapPolyfill = false; 38815 try { 38816 var nonExtensibleObject = Object.preventExtensions({}); 38817 var testMap = new Map([[nonExtensibleObject, null]]); 38818 var testSet = new Set([nonExtensibleObject]); 38819 // This is necessary for Rollup to not consider these unused. 38820 // https://github.com/rollup/rollup/issues/1771 38821 // TODO: we can remove these if Rollup fixes the bug. 38822 testMap.set(0, 0); 38823 testSet.add(0); 38824 } catch (e) { 38825 // TODO: Consider warning about bad polyfills 38826 hasBadMapPolyfill = true; 38827 } 38828} 38829 38830// A Fiber is work on a Component that needs to be done or was done. There can 38831// be more than one per component. 38832 38833 38834var debugCounter = void 0; 38835 38836{ 38837 debugCounter = 1; 38838} 38839 38840function FiberNode(tag, pendingProps, key, mode) { 38841 // Instance 38842 this.tag = tag; 38843 this.key = key; 38844 this.type = null; 38845 this.stateNode = null; 38846 38847 // Fiber 38848 this.return = null; 38849 this.child = null; 38850 this.sibling = null; 38851 this.index = 0; 38852 38853 this.ref = null; 38854 38855 this.pendingProps = pendingProps; 38856 this.memoizedProps = null; 38857 this.updateQueue = null; 38858 this.memoizedState = null; 38859 38860 this.mode = mode; 38861 38862 // Effects 38863 this.effectTag = NoEffect; 38864 this.nextEffect = null; 38865 38866 this.firstEffect = null; 38867 this.lastEffect = null; 38868 38869 this.expirationTime = NoWork; 38870 38871 this.alternate = null; 38872 38873 if (enableProfilerTimer) { 38874 this.actualDuration = 0; 38875 this.actualStartTime = 0; 38876 this.selfBaseTime = 0; 38877 this.treeBaseTime = 0; 38878 } 38879 38880 { 38881 this._debugID = debugCounter++; 38882 this._debugSource = null; 38883 this._debugOwner = null; 38884 this._debugIsCurrentlyTiming = false; 38885 if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') { 38886 Object.preventExtensions(this); 38887 } 38888 } 38889} 38890 38891// This is a constructor function, rather than a POJO constructor, still 38892// please ensure we do the following: 38893// 1) Nobody should add any instance methods on this. Instance methods can be 38894// more difficult to predict when they get optimized and they are almost 38895// never inlined properly in static compilers. 38896// 2) Nobody should rely on `instanceof Fiber` for type testing. We should 38897// always know when it is a fiber. 38898// 3) We might want to experiment with using numeric keys since they are easier 38899// to optimize in a non-JIT environment. 38900// 4) We can easily go from a constructor to a createFiber object literal if that 38901// is faster. 38902// 5) It should be easy to port this to a C struct and keep a C implementation 38903// compatible. 38904var createFiber = function (tag, pendingProps, key, mode) { 38905 // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors 38906 return new FiberNode(tag, pendingProps, key, mode); 38907}; 38908 38909function shouldConstruct(Component) { 38910 return !!(Component.prototype && Component.prototype.isReactComponent); 38911} 38912 38913// This is used to create an alternate fiber to do work on. 38914function createWorkInProgress(current, pendingProps, expirationTime) { 38915 var workInProgress = current.alternate; 38916 if (workInProgress === null) { 38917 // We use a double buffering pooling technique because we know that we'll 38918 // only ever need at most two versions of a tree. We pool the "other" unused 38919 // node that we're free to reuse. This is lazily created to avoid allocating 38920 // extra objects for things that are never updated. It also allow us to 38921 // reclaim the extra memory if needed. 38922 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode); 38923 workInProgress.type = current.type; 38924 workInProgress.stateNode = current.stateNode; 38925 38926 { 38927 // DEV-only fields 38928 workInProgress._debugID = current._debugID; 38929 workInProgress._debugSource = current._debugSource; 38930 workInProgress._debugOwner = current._debugOwner; 38931 } 38932 38933 workInProgress.alternate = current; 38934 current.alternate = workInProgress; 38935 } else { 38936 workInProgress.pendingProps = pendingProps; 38937 38938 // We already have an alternate. 38939 // Reset the effect tag. 38940 workInProgress.effectTag = NoEffect; 38941 38942 // The effect list is no longer valid. 38943 workInProgress.nextEffect = null; 38944 workInProgress.firstEffect = null; 38945 workInProgress.lastEffect = null; 38946 38947 if (enableProfilerTimer) { 38948 // We intentionally reset, rather than copy, actualDuration & actualStartTime. 38949 // This prevents time from endlessly accumulating in new commits. 38950 // This has the downside of resetting values for different priority renders, 38951 // But works for yielding (the common case) and should support resuming. 38952 workInProgress.actualDuration = 0; 38953 workInProgress.actualStartTime = 0; 38954 } 38955 } 38956 38957 workInProgress.expirationTime = expirationTime; 38958 38959 workInProgress.child = current.child; 38960 workInProgress.memoizedProps = current.memoizedProps; 38961 workInProgress.memoizedState = current.memoizedState; 38962 workInProgress.updateQueue = current.updateQueue; 38963 38964 // These will be overridden during the parent's reconciliation 38965 workInProgress.sibling = current.sibling; 38966 workInProgress.index = current.index; 38967 workInProgress.ref = current.ref; 38968 38969 if (enableProfilerTimer) { 38970 workInProgress.selfBaseTime = current.selfBaseTime; 38971 workInProgress.treeBaseTime = current.treeBaseTime; 38972 } 38973 38974 return workInProgress; 38975} 38976 38977function createHostRootFiber(isAsync) { 38978 var mode = isAsync ? AsyncMode | StrictMode : NoContext; 38979 return createFiber(HostRoot, null, null, mode); 38980} 38981 38982function createFiberFromElement(element, mode, expirationTime) { 38983 var owner = null; 38984 { 38985 owner = element._owner; 38986 } 38987 38988 var fiber = void 0; 38989 var type = element.type; 38990 var key = element.key; 38991 var pendingProps = element.props; 38992 38993 var fiberTag = void 0; 38994 if (typeof type === 'function') { 38995 fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent; 38996 } else if (typeof type === 'string') { 38997 fiberTag = HostComponent; 38998 } else { 38999 switch (type) { 39000 case REACT_FRAGMENT_TYPE: 39001 return createFiberFromFragment(pendingProps.children, mode, expirationTime, key); 39002 case REACT_ASYNC_MODE_TYPE: 39003 fiberTag = Mode; 39004 mode |= AsyncMode | StrictMode; 39005 break; 39006 case REACT_STRICT_MODE_TYPE: 39007 fiberTag = Mode; 39008 mode |= StrictMode; 39009 break; 39010 case REACT_PROFILER_TYPE: 39011 return createFiberFromProfiler(pendingProps, mode, expirationTime, key); 39012 case REACT_TIMEOUT_TYPE: 39013 fiberTag = TimeoutComponent; 39014 // Suspense does not require async, but its children should be strict 39015 // mode compatible. 39016 mode |= StrictMode; 39017 break; 39018 default: 39019 fiberTag = getFiberTagFromObjectType(type, owner); 39020 break; 39021 } 39022 } 39023 39024 fiber = createFiber(fiberTag, pendingProps, key, mode); 39025 fiber.type = type; 39026 fiber.expirationTime = expirationTime; 39027 39028 { 39029 fiber._debugSource = element._source; 39030 fiber._debugOwner = element._owner; 39031 } 39032 39033 return fiber; 39034} 39035 39036function getFiberTagFromObjectType(type, owner) { 39037 var $$typeof = typeof type === 'object' && type !== null ? type.$$typeof : null; 39038 39039 switch ($$typeof) { 39040 case REACT_PROVIDER_TYPE: 39041 return ContextProvider; 39042 case REACT_CONTEXT_TYPE: 39043 // This is a consumer 39044 return ContextConsumer; 39045 case REACT_FORWARD_REF_TYPE: 39046 return ForwardRef; 39047 default: 39048 { 39049 var info = ''; 39050 { 39051 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 39052 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and " + 'named imports.'; 39053 } 39054 var ownerName = owner ? getComponentName(owner) : null; 39055 if (ownerName) { 39056 info += '\n\nCheck the render method of `' + ownerName + '`.'; 39057 } 39058 } 39059 invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', type == null ? type : typeof type, info); 39060 } 39061 } 39062} 39063 39064function createFiberFromFragment(elements, mode, expirationTime, key) { 39065 var fiber = createFiber(Fragment, elements, key, mode); 39066 fiber.expirationTime = expirationTime; 39067 return fiber; 39068} 39069 39070function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { 39071 { 39072 if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') { 39073 invariant(false, 'Profiler must specify an "id" string and "onRender" function as props'); 39074 } 39075 } 39076 39077 var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); 39078 fiber.type = REACT_PROFILER_TYPE; 39079 fiber.expirationTime = expirationTime; 39080 39081 return fiber; 39082} 39083 39084function createFiberFromText(content, mode, expirationTime) { 39085 var fiber = createFiber(HostText, content, null, mode); 39086 fiber.expirationTime = expirationTime; 39087 return fiber; 39088} 39089 39090function createFiberFromHostInstanceForDeletion() { 39091 var fiber = createFiber(HostComponent, null, null, NoContext); 39092 fiber.type = 'DELETED'; 39093 return fiber; 39094} 39095 39096function createFiberFromPortal(portal, mode, expirationTime) { 39097 var pendingProps = portal.children !== null ? portal.children : []; 39098 var fiber = createFiber(HostPortal, pendingProps, portal.key, mode); 39099 fiber.expirationTime = expirationTime; 39100 fiber.stateNode = { 39101 containerInfo: portal.containerInfo, 39102 pendingChildren: null, // Used by persistent updates 39103 implementation: portal.implementation 39104 }; 39105 return fiber; 39106} 39107 39108// Used for stashing WIP properties to replay failed work in DEV. 39109function assignFiberPropertiesInDEV(target, source) { 39110 if (target === null) { 39111 // This Fiber's initial properties will always be overwritten. 39112 // We only use a Fiber to ensure the same hidden class so DEV isn't slow. 39113 target = createFiber(IndeterminateComponent, null, null, NoContext); 39114 } 39115 39116 // This is intentionally written as a list of all properties. 39117 // We tried to use Object.assign() instead but this is called in 39118 // the hottest path, and Object.assign() was too slow: 39119 // https://github.com/facebook/react/issues/12502 39120 // This code is DEV-only so size is not a concern. 39121 39122 target.tag = source.tag; 39123 target.key = source.key; 39124 target.type = source.type; 39125 target.stateNode = source.stateNode; 39126 target.return = source.return; 39127 target.child = source.child; 39128 target.sibling = source.sibling; 39129 target.index = source.index; 39130 target.ref = source.ref; 39131 target.pendingProps = source.pendingProps; 39132 target.memoizedProps = source.memoizedProps; 39133 target.updateQueue = source.updateQueue; 39134 target.memoizedState = source.memoizedState; 39135 target.mode = source.mode; 39136 target.effectTag = source.effectTag; 39137 target.nextEffect = source.nextEffect; 39138 target.firstEffect = source.firstEffect; 39139 target.lastEffect = source.lastEffect; 39140 target.expirationTime = source.expirationTime; 39141 target.alternate = source.alternate; 39142 if (enableProfilerTimer) { 39143 target.actualDuration = source.actualDuration; 39144 target.actualStartTime = source.actualStartTime; 39145 target.selfBaseTime = source.selfBaseTime; 39146 target.treeBaseTime = source.treeBaseTime; 39147 } 39148 target._debugID = source._debugID; 39149 target._debugSource = source._debugSource; 39150 target._debugOwner = source._debugOwner; 39151 target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming; 39152 return target; 39153} 39154 39155// TODO: This should be lifted into the renderer. 39156 39157 39158function createFiberRoot(containerInfo, isAsync, hydrate) { 39159 // Cyclic construction. This cheats the type system right now because 39160 // stateNode is any. 39161 var uninitializedFiber = createHostRootFiber(isAsync); 39162 var root = { 39163 current: uninitializedFiber, 39164 containerInfo: containerInfo, 39165 pendingChildren: null, 39166 39167 earliestPendingTime: NoWork, 39168 latestPendingTime: NoWork, 39169 earliestSuspendedTime: NoWork, 39170 latestSuspendedTime: NoWork, 39171 latestPingedTime: NoWork, 39172 39173 pendingCommitExpirationTime: NoWork, 39174 finishedWork: null, 39175 context: null, 39176 pendingContext: null, 39177 hydrate: hydrate, 39178 remainingExpirationTime: NoWork, 39179 firstBatch: null, 39180 nextScheduledRoot: null 39181 }; 39182 uninitializedFiber.stateNode = root; 39183 return root; 39184} 39185 39186var onCommitFiberRoot = null; 39187var onCommitFiberUnmount = null; 39188var hasLoggedError = false; 39189 39190function catchErrors(fn) { 39191 return function (arg) { 39192 try { 39193 return fn(arg); 39194 } catch (err) { 39195 if ( true && !hasLoggedError) { 39196 hasLoggedError = true; 39197 warning(false, 'React DevTools encountered an error: %s', err); 39198 } 39199 } 39200 }; 39201} 39202 39203function injectInternals(internals) { 39204 if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { 39205 // No DevTools 39206 return false; 39207 } 39208 var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; 39209 if (hook.isDisabled) { 39210 // This isn't a real property on the hook, but it can be set to opt out 39211 // of DevTools integration and associated warnings and logs. 39212 // https://github.com/facebook/react/issues/3877 39213 return true; 39214 } 39215 if (!hook.supportsFiber) { 39216 { 39217 warning(false, 'The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://fb.me/react-devtools'); 39218 } 39219 // DevTools exists, even though it doesn't support Fiber. 39220 return true; 39221 } 39222 try { 39223 var rendererID = hook.inject(internals); 39224 // We have successfully injected, so now it is safe to set up hooks. 39225 onCommitFiberRoot = catchErrors(function (root) { 39226 return hook.onCommitFiberRoot(rendererID, root); 39227 }); 39228 onCommitFiberUnmount = catchErrors(function (fiber) { 39229 return hook.onCommitFiberUnmount(rendererID, fiber); 39230 }); 39231 } catch (err) { 39232 // Catch all errors because it is unsafe to throw during initialization. 39233 { 39234 warning(false, 'React DevTools encountered an error: %s.', err); 39235 } 39236 } 39237 // DevTools exists 39238 return true; 39239} 39240 39241function onCommitRoot(root) { 39242 if (typeof onCommitFiberRoot === 'function') { 39243 onCommitFiberRoot(root); 39244 } 39245} 39246 39247function onCommitUnmount(fiber) { 39248 if (typeof onCommitFiberUnmount === 'function') { 39249 onCommitFiberUnmount(fiber); 39250 } 39251} 39252 39253/** 39254 * Forked from fbjs/warning: 39255 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js 39256 * 39257 * Only change is we use console.warn instead of console.error, 39258 * and do nothing when 'console' is not supported. 39259 * This really simplifies the code. 39260 * --- 39261 * Similar to invariant but only logs a warning if the condition is not met. 39262 * This can be used to log issues in development environments in critical 39263 * paths. Removing the logging code for production environments will keep the 39264 * same logic and follow the same code paths. 39265 */ 39266 39267var lowPriorityWarning = function () {}; 39268 39269{ 39270 var printWarning = function (format) { 39271 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 39272 args[_key - 1] = arguments[_key]; 39273 } 39274 39275 var argIndex = 0; 39276 var message = 'Warning: ' + format.replace(/%s/g, function () { 39277 return args[argIndex++]; 39278 }); 39279 if (typeof console !== 'undefined') { 39280 console.warn(message); 39281 } 39282 try { 39283 // --- Welcome to debugging React --- 39284 // This error was thrown as a convenience so that you can use this stack 39285 // to find the callsite that caused this warning to fire. 39286 throw new Error(message); 39287 } catch (x) {} 39288 }; 39289 39290 lowPriorityWarning = function (condition, format) { 39291 if (format === undefined) { 39292 throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); 39293 } 39294 if (!condition) { 39295 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { 39296 args[_key2 - 2] = arguments[_key2]; 39297 } 39298 39299 printWarning.apply(undefined, [format].concat(args)); 39300 } 39301 }; 39302} 39303 39304var lowPriorityWarning$1 = lowPriorityWarning; 39305 39306var ReactStrictModeWarnings = { 39307 discardPendingWarnings: function () {}, 39308 flushPendingDeprecationWarnings: function () {}, 39309 flushPendingUnsafeLifecycleWarnings: function () {}, 39310 recordDeprecationWarnings: function (fiber, instance) {}, 39311 recordUnsafeLifecycleWarnings: function (fiber, instance) {}, 39312 recordLegacyContextWarning: function (fiber, instance) {}, 39313 flushLegacyContextWarning: function () {} 39314}; 39315 39316{ 39317 var LIFECYCLE_SUGGESTIONS = { 39318 UNSAFE_componentWillMount: 'componentDidMount', 39319 UNSAFE_componentWillReceiveProps: 'static getDerivedStateFromProps', 39320 UNSAFE_componentWillUpdate: 'componentDidUpdate' 39321 }; 39322 39323 var pendingComponentWillMountWarnings = []; 39324 var pendingComponentWillReceivePropsWarnings = []; 39325 var pendingComponentWillUpdateWarnings = []; 39326 var pendingUnsafeLifecycleWarnings = new Map(); 39327 var pendingLegacyContextWarning = new Map(); 39328 39329 // Tracks components we have already warned about. 39330 var didWarnAboutDeprecatedLifecycles = new Set(); 39331 var didWarnAboutUnsafeLifecycles = new Set(); 39332 var didWarnAboutLegacyContext = new Set(); 39333 39334 var setToSortedString = function (set) { 39335 var array = []; 39336 set.forEach(function (value) { 39337 array.push(value); 39338 }); 39339 return array.sort().join(', '); 39340 }; 39341 39342 ReactStrictModeWarnings.discardPendingWarnings = function () { 39343 pendingComponentWillMountWarnings = []; 39344 pendingComponentWillReceivePropsWarnings = []; 39345 pendingComponentWillUpdateWarnings = []; 39346 pendingUnsafeLifecycleWarnings = new Map(); 39347 pendingLegacyContextWarning = new Map(); 39348 }; 39349 39350 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () { 39351 pendingUnsafeLifecycleWarnings.forEach(function (lifecycleWarningsMap, strictRoot) { 39352 var lifecyclesWarningMesages = []; 39353 39354 Object.keys(lifecycleWarningsMap).forEach(function (lifecycle) { 39355 var lifecycleWarnings = lifecycleWarningsMap[lifecycle]; 39356 if (lifecycleWarnings.length > 0) { 39357 var componentNames = new Set(); 39358 lifecycleWarnings.forEach(function (fiber) { 39359 componentNames.add(getComponentName(fiber) || 'Component'); 39360 didWarnAboutUnsafeLifecycles.add(fiber.type); 39361 }); 39362 39363 var formatted = lifecycle.replace('UNSAFE_', ''); 39364 var suggestion = LIFECYCLE_SUGGESTIONS[lifecycle]; 39365 var sortedComponentNames = setToSortedString(componentNames); 39366 39367 lifecyclesWarningMesages.push(formatted + ': Please update the following components to use ' + (suggestion + ' instead: ' + sortedComponentNames)); 39368 } 39369 }); 39370 39371 if (lifecyclesWarningMesages.length > 0) { 39372 var strictRootComponentStack = getStackAddendumByWorkInProgressFiber(strictRoot); 39373 39374 warning(false, 'Unsafe lifecycle methods were found within a strict-mode tree:%s' + '\n\n%s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-strict-mode-warnings', strictRootComponentStack, lifecyclesWarningMesages.join('\n\n')); 39375 } 39376 }); 39377 39378 pendingUnsafeLifecycleWarnings = new Map(); 39379 }; 39380 39381 var findStrictRoot = function (fiber) { 39382 var maybeStrictRoot = null; 39383 39384 var node = fiber; 39385 while (node !== null) { 39386 if (node.mode & StrictMode) { 39387 maybeStrictRoot = node; 39388 } 39389 node = node.return; 39390 } 39391 39392 return maybeStrictRoot; 39393 }; 39394 39395 ReactStrictModeWarnings.flushPendingDeprecationWarnings = function () { 39396 if (pendingComponentWillMountWarnings.length > 0) { 39397 var uniqueNames = new Set(); 39398 pendingComponentWillMountWarnings.forEach(function (fiber) { 39399 uniqueNames.add(getComponentName(fiber) || 'Component'); 39400 didWarnAboutDeprecatedLifecycles.add(fiber.type); 39401 }); 39402 39403 var sortedNames = setToSortedString(uniqueNames); 39404 39405 lowPriorityWarning$1(false, 'componentWillMount is deprecated and will be removed in the next major version. ' + 'Use componentDidMount instead. As a temporary workaround, ' + 'you can rename to UNSAFE_componentWillMount.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', sortedNames); 39406 39407 pendingComponentWillMountWarnings = []; 39408 } 39409 39410 if (pendingComponentWillReceivePropsWarnings.length > 0) { 39411 var _uniqueNames = new Set(); 39412 pendingComponentWillReceivePropsWarnings.forEach(function (fiber) { 39413 _uniqueNames.add(getComponentName(fiber) || 'Component'); 39414 didWarnAboutDeprecatedLifecycles.add(fiber.type); 39415 }); 39416 39417 var _sortedNames = setToSortedString(_uniqueNames); 39418 39419 lowPriorityWarning$1(false, 'componentWillReceiveProps is deprecated and will be removed in the next major version. ' + 'Use static getDerivedStateFromProps instead.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', _sortedNames); 39420 39421 pendingComponentWillReceivePropsWarnings = []; 39422 } 39423 39424 if (pendingComponentWillUpdateWarnings.length > 0) { 39425 var _uniqueNames2 = new Set(); 39426 pendingComponentWillUpdateWarnings.forEach(function (fiber) { 39427 _uniqueNames2.add(getComponentName(fiber) || 'Component'); 39428 didWarnAboutDeprecatedLifecycles.add(fiber.type); 39429 }); 39430 39431 var _sortedNames2 = setToSortedString(_uniqueNames2); 39432 39433 lowPriorityWarning$1(false, 'componentWillUpdate is deprecated and will be removed in the next major version. ' + 'Use componentDidUpdate instead. As a temporary workaround, ' + 'you can rename to UNSAFE_componentWillUpdate.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', _sortedNames2); 39434 39435 pendingComponentWillUpdateWarnings = []; 39436 } 39437 }; 39438 39439 ReactStrictModeWarnings.recordDeprecationWarnings = function (fiber, instance) { 39440 // Dedup strategy: Warn once per component. 39441 if (didWarnAboutDeprecatedLifecycles.has(fiber.type)) { 39442 return; 39443 } 39444 39445 // Don't warn about react-lifecycles-compat polyfilled components. 39446 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) { 39447 pendingComponentWillMountWarnings.push(fiber); 39448 } 39449 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { 39450 pendingComponentWillReceivePropsWarnings.push(fiber); 39451 } 39452 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { 39453 pendingComponentWillUpdateWarnings.push(fiber); 39454 } 39455 }; 39456 39457 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) { 39458 var strictRoot = findStrictRoot(fiber); 39459 if (strictRoot === null) { 39460 warning(false, 'Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.'); 39461 return; 39462 } 39463 39464 // Dedup strategy: Warn once per component. 39465 // This is difficult to track any other way since component names 39466 // are often vague and are likely to collide between 3rd party libraries. 39467 // An expand property is probably okay to use here since it's DEV-only, 39468 // and will only be set in the event of serious warnings. 39469 if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { 39470 return; 39471 } 39472 39473 var warningsForRoot = void 0; 39474 if (!pendingUnsafeLifecycleWarnings.has(strictRoot)) { 39475 warningsForRoot = { 39476 UNSAFE_componentWillMount: [], 39477 UNSAFE_componentWillReceiveProps: [], 39478 UNSAFE_componentWillUpdate: [] 39479 }; 39480 39481 pendingUnsafeLifecycleWarnings.set(strictRoot, warningsForRoot); 39482 } else { 39483 warningsForRoot = pendingUnsafeLifecycleWarnings.get(strictRoot); 39484 } 39485 39486 var unsafeLifecycles = []; 39487 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true || typeof instance.UNSAFE_componentWillMount === 'function') { 39488 unsafeLifecycles.push('UNSAFE_componentWillMount'); 39489 } 39490 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true || typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 39491 unsafeLifecycles.push('UNSAFE_componentWillReceiveProps'); 39492 } 39493 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true || typeof instance.UNSAFE_componentWillUpdate === 'function') { 39494 unsafeLifecycles.push('UNSAFE_componentWillUpdate'); 39495 } 39496 39497 if (unsafeLifecycles.length > 0) { 39498 unsafeLifecycles.forEach(function (lifecycle) { 39499 warningsForRoot[lifecycle].push(fiber); 39500 }); 39501 } 39502 }; 39503 39504 ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) { 39505 var strictRoot = findStrictRoot(fiber); 39506 if (strictRoot === null) { 39507 warning(false, 'Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.'); 39508 return; 39509 } 39510 39511 // Dedup strategy: Warn once per component. 39512 if (didWarnAboutLegacyContext.has(fiber.type)) { 39513 return; 39514 } 39515 39516 var warningsForRoot = pendingLegacyContextWarning.get(strictRoot); 39517 39518 if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') { 39519 if (warningsForRoot === undefined) { 39520 warningsForRoot = []; 39521 pendingLegacyContextWarning.set(strictRoot, warningsForRoot); 39522 } 39523 warningsForRoot.push(fiber); 39524 } 39525 }; 39526 39527 ReactStrictModeWarnings.flushLegacyContextWarning = function () { 39528 pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) { 39529 var uniqueNames = new Set(); 39530 fiberArray.forEach(function (fiber) { 39531 uniqueNames.add(getComponentName(fiber) || 'Component'); 39532 didWarnAboutLegacyContext.add(fiber.type); 39533 }); 39534 39535 var sortedNames = setToSortedString(uniqueNames); 39536 var strictRootComponentStack = getStackAddendumByWorkInProgressFiber(strictRoot); 39537 39538 warning(false, 'Legacy context API has been detected within a strict-mode tree: %s' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-strict-mode-warnings', strictRootComponentStack, sortedNames); 39539 }); 39540 }; 39541} 39542 39543// This lets us hook into Fiber to debug what it's doing. 39544// See https://github.com/facebook/react/pull/8033. 39545// This is not part of the public API, not even for React DevTools. 39546// You may only inject a debugTool if you work on React Fiber itself. 39547var ReactFiberInstrumentation = { 39548 debugTool: null 39549}; 39550 39551var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; 39552 39553// TODO: Offscreen updates 39554 39555function markPendingPriorityLevel(root, expirationTime) { 39556 if (enableSuspense) { 39557 // Update the latest and earliest pending times 39558 var earliestPendingTime = root.earliestPendingTime; 39559 if (earliestPendingTime === NoWork) { 39560 // No other pending updates. 39561 root.earliestPendingTime = root.latestPendingTime = expirationTime; 39562 } else { 39563 if (earliestPendingTime > expirationTime) { 39564 // This is the earliest pending update. 39565 root.earliestPendingTime = expirationTime; 39566 } else { 39567 var latestPendingTime = root.latestPendingTime; 39568 if (latestPendingTime < expirationTime) { 39569 // This is the latest pending update 39570 root.latestPendingTime = expirationTime; 39571 } 39572 } 39573 } 39574 } 39575} 39576 39577function markCommittedPriorityLevels(root, currentTime, earliestRemainingTime) { 39578 if (enableSuspense) { 39579 if (earliestRemainingTime === NoWork) { 39580 // Fast path. There's no remaining work. Clear everything. 39581 root.earliestPendingTime = NoWork; 39582 root.latestPendingTime = NoWork; 39583 root.earliestSuspendedTime = NoWork; 39584 root.latestSuspendedTime = NoWork; 39585 root.latestPingedTime = NoWork; 39586 return; 39587 } 39588 39589 // Let's see if the previous latest known pending level was just flushed. 39590 var latestPendingTime = root.latestPendingTime; 39591 if (latestPendingTime !== NoWork) { 39592 if (latestPendingTime < earliestRemainingTime) { 39593 // We've flushed all the known pending levels. 39594 root.earliestPendingTime = root.latestPendingTime = NoWork; 39595 } else { 39596 var earliestPendingTime = root.earliestPendingTime; 39597 if (earliestPendingTime < earliestRemainingTime) { 39598 // We've flushed the earliest known pending level. Set this to the 39599 // latest pending time. 39600 root.earliestPendingTime = root.latestPendingTime; 39601 } 39602 } 39603 } 39604 39605 // Now let's handle the earliest remaining level in the whole tree. We need to 39606 // decide whether to treat it as a pending level or as suspended. Check 39607 // it falls within the range of known suspended levels. 39608 39609 var earliestSuspendedTime = root.earliestSuspendedTime; 39610 if (earliestSuspendedTime === NoWork) { 39611 // There's no suspended work. Treat the earliest remaining level as a 39612 // pending level. 39613 markPendingPriorityLevel(root, earliestRemainingTime); 39614 return; 39615 } 39616 39617 var latestSuspendedTime = root.latestSuspendedTime; 39618 if (earliestRemainingTime > latestSuspendedTime) { 39619 // The earliest remaining level is later than all the suspended work. That 39620 // means we've flushed all the suspended work. 39621 root.earliestSuspendedTime = NoWork; 39622 root.latestSuspendedTime = NoWork; 39623 root.latestPingedTime = NoWork; 39624 39625 // There's no suspended work. Treat the earliest remaining level as a 39626 // pending level. 39627 markPendingPriorityLevel(root, earliestRemainingTime); 39628 return; 39629 } 39630 39631 if (earliestRemainingTime < earliestSuspendedTime) { 39632 // The earliest remaining time is earlier than all the suspended work. 39633 // Treat it as a pending update. 39634 markPendingPriorityLevel(root, earliestRemainingTime); 39635 return; 39636 } 39637 39638 // The earliest remaining time falls within the range of known suspended 39639 // levels. We should treat this as suspended work. 39640 } 39641} 39642 39643function markSuspendedPriorityLevel(root, suspendedTime) { 39644 if (enableSuspense) { 39645 // First, check the known pending levels and update them if needed. 39646 var earliestPendingTime = root.earliestPendingTime; 39647 var latestPendingTime = root.latestPendingTime; 39648 if (earliestPendingTime === suspendedTime) { 39649 if (latestPendingTime === suspendedTime) { 39650 // Both known pending levels were suspended. Clear them. 39651 root.earliestPendingTime = root.latestPendingTime = NoWork; 39652 } else { 39653 // The earliest pending level was suspended. Clear by setting it to the 39654 // latest pending level. 39655 root.earliestPendingTime = latestPendingTime; 39656 } 39657 } else if (latestPendingTime === suspendedTime) { 39658 // The latest pending level was suspended. Clear by setting it to the 39659 // latest pending level. 39660 root.latestPendingTime = earliestPendingTime; 39661 } 39662 39663 // Next, if we're working on the lowest known suspended level, clear the ping. 39664 // TODO: What if a promise suspends and pings before the root completes? 39665 var latestSuspendedTime = root.latestSuspendedTime; 39666 if (latestSuspendedTime === suspendedTime) { 39667 root.latestPingedTime = NoWork; 39668 } 39669 39670 // Finally, update the known suspended levels. 39671 var earliestSuspendedTime = root.earliestSuspendedTime; 39672 if (earliestSuspendedTime === NoWork) { 39673 // No other suspended levels. 39674 root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime; 39675 } else { 39676 if (earliestSuspendedTime > suspendedTime) { 39677 // This is the earliest suspended level. 39678 root.earliestSuspendedTime = suspendedTime; 39679 } else if (latestSuspendedTime < suspendedTime) { 39680 // This is the latest suspended level 39681 root.latestSuspendedTime = suspendedTime; 39682 } 39683 } 39684 } 39685} 39686 39687function markPingedPriorityLevel(root, pingedTime) { 39688 if (enableSuspense) { 39689 var latestSuspendedTime = root.latestSuspendedTime; 39690 if (latestSuspendedTime !== NoWork && latestSuspendedTime <= pingedTime) { 39691 var latestPingedTime = root.latestPingedTime; 39692 if (latestPingedTime === NoWork || latestPingedTime < pingedTime) { 39693 root.latestPingedTime = pingedTime; 39694 } 39695 } 39696 } 39697} 39698 39699function findNextPendingPriorityLevel(root) { 39700 if (enableSuspense) { 39701 var earliestSuspendedTime = root.earliestSuspendedTime; 39702 var earliestPendingTime = root.earliestPendingTime; 39703 if (earliestSuspendedTime === NoWork) { 39704 // Fast path. There's no suspended work. 39705 return earliestPendingTime; 39706 } 39707 39708 // First, check if there's known pending work. 39709 if (earliestPendingTime !== NoWork) { 39710 return earliestPendingTime; 39711 } 39712 39713 // Finally, if a suspended level was pinged, work on that. Otherwise there's 39714 // nothing to work on. 39715 return root.latestPingedTime; 39716 } else { 39717 return root.current.expirationTime; 39718 } 39719} 39720 39721// UpdateQueue is a linked list of prioritized updates. 39722// 39723// Like fibers, update queues come in pairs: a current queue, which represents 39724// the visible state of the screen, and a work-in-progress queue, which is 39725// can be mutated and processed asynchronously before it is committed â a form 39726// of double buffering. If a work-in-progress render is discarded before 39727// finishing, we create a new work-in-progress by cloning the current queue. 39728// 39729// Both queues share a persistent, singly-linked list structure. To schedule an 39730// update, we append it to the end of both queues. Each queue maintains a 39731// pointer to first update in the persistent list that hasn't been processed. 39732// The work-in-progress pointer always has a position equal to or greater than 39733// the current queue, since we always work on that one. The current queue's 39734// pointer is only updated during the commit phase, when we swap in the 39735// work-in-progress. 39736// 39737// For example: 39738// 39739// Current pointer: A - B - C - D - E - F 39740// Work-in-progress pointer: D - E - F 39741// ^ 39742// The work-in-progress queue has 39743// processed more updates than current. 39744// 39745// The reason we append to both queues is because otherwise we might drop 39746// updates without ever processing them. For example, if we only add updates to 39747// the work-in-progress queue, some updates could be lost whenever a work-in 39748// -progress render restarts by cloning from current. Similarly, if we only add 39749// updates to the current queue, the updates will be lost whenever an already 39750// in-progress queue commits and swaps with the current queue. However, by 39751// adding to both queues, we guarantee that the update will be part of the next 39752// work-in-progress. (And because the work-in-progress queue becomes the 39753// current queue once it commits, there's no danger of applying the same 39754// update twice.) 39755// 39756// Prioritization 39757// -------------- 39758// 39759// Updates are not sorted by priority, but by insertion; new updates are always 39760// appended to the end of the list. 39761// 39762// The priority is still important, though. When processing the update queue 39763// during the render phase, only the updates with sufficient priority are 39764// included in the result. If we skip an update because it has insufficient 39765// priority, it remains in the queue to be processed later, during a lower 39766// priority render. Crucially, all updates subsequent to a skipped update also 39767// remain in the queue *regardless of their priority*. That means high priority 39768// updates are sometimes processed twice, at two separate priorities. We also 39769// keep track of a base state, that represents the state before the first 39770// update in the queue is applied. 39771// 39772// For example: 39773// 39774// Given a base state of '', and the following queue of updates 39775// 39776// A1 - B2 - C1 - D2 39777// 39778// where the number indicates the priority, and the update is applied to the 39779// previous state by appending a letter, React will process these updates as 39780// two separate renders, one per distinct priority level: 39781// 39782// First render, at priority 1: 39783// Base state: '' 39784// Updates: [A1, C1] 39785// Result state: 'AC' 39786// 39787// Second render, at priority 2: 39788// Base state: 'A' <- The base state does not include C1, 39789// because B2 was skipped. 39790// Updates: [B2, C1, D2] <- C1 was rebased on top of B2 39791// Result state: 'ABCD' 39792// 39793// Because we process updates in insertion order, and rebase high priority 39794// updates when preceding updates are skipped, the final result is deterministic 39795// regardless of priority. Intermediate state may vary according to system 39796// resources, but the final state is always the same. 39797 39798var UpdateState = 0; 39799var ReplaceState = 1; 39800var ForceUpdate = 2; 39801var CaptureUpdate = 3; 39802 39803// Global state that is reset at the beginning of calling `processUpdateQueue`. 39804// It should only be read right after calling `processUpdateQueue`, via 39805// `checkHasForceUpdateAfterProcessing`. 39806var hasForceUpdate = false; 39807 39808var didWarnUpdateInsideUpdate = void 0; 39809var currentlyProcessingQueue = void 0; 39810var resetCurrentlyProcessingQueue = void 0; 39811{ 39812 didWarnUpdateInsideUpdate = false; 39813 currentlyProcessingQueue = null; 39814 resetCurrentlyProcessingQueue = function () { 39815 currentlyProcessingQueue = null; 39816 }; 39817} 39818 39819function createUpdateQueue(baseState) { 39820 var queue = { 39821 expirationTime: NoWork, 39822 baseState: baseState, 39823 firstUpdate: null, 39824 lastUpdate: null, 39825 firstCapturedUpdate: null, 39826 lastCapturedUpdate: null, 39827 firstEffect: null, 39828 lastEffect: null, 39829 firstCapturedEffect: null, 39830 lastCapturedEffect: null 39831 }; 39832 return queue; 39833} 39834 39835function cloneUpdateQueue(currentQueue) { 39836 var queue = { 39837 expirationTime: currentQueue.expirationTime, 39838 baseState: currentQueue.baseState, 39839 firstUpdate: currentQueue.firstUpdate, 39840 lastUpdate: currentQueue.lastUpdate, 39841 39842 // TODO: With resuming, if we bail out and resuse the child tree, we should 39843 // keep these effects. 39844 firstCapturedUpdate: null, 39845 lastCapturedUpdate: null, 39846 39847 firstEffect: null, 39848 lastEffect: null, 39849 39850 firstCapturedEffect: null, 39851 lastCapturedEffect: null 39852 }; 39853 return queue; 39854} 39855 39856function createUpdate(expirationTime) { 39857 return { 39858 expirationTime: expirationTime, 39859 39860 tag: UpdateState, 39861 payload: null, 39862 callback: null, 39863 39864 next: null, 39865 nextEffect: null 39866 }; 39867} 39868 39869function appendUpdateToQueue(queue, update, expirationTime) { 39870 // Append the update to the end of the list. 39871 if (queue.lastUpdate === null) { 39872 // Queue is empty 39873 queue.firstUpdate = queue.lastUpdate = update; 39874 } else { 39875 queue.lastUpdate.next = update; 39876 queue.lastUpdate = update; 39877 } 39878 if (queue.expirationTime === NoWork || queue.expirationTime > expirationTime) { 39879 // The incoming update has the earliest expiration of any update in the 39880 // queue. Update the queue's expiration time. 39881 queue.expirationTime = expirationTime; 39882 } 39883} 39884 39885function enqueueUpdate(fiber, update, expirationTime) { 39886 // Update queues are created lazily. 39887 var alternate = fiber.alternate; 39888 var queue1 = void 0; 39889 var queue2 = void 0; 39890 if (alternate === null) { 39891 // There's only one fiber. 39892 queue1 = fiber.updateQueue; 39893 queue2 = null; 39894 if (queue1 === null) { 39895 queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); 39896 } 39897 } else { 39898 // There are two owners. 39899 queue1 = fiber.updateQueue; 39900 queue2 = alternate.updateQueue; 39901 if (queue1 === null) { 39902 if (queue2 === null) { 39903 // Neither fiber has an update queue. Create new ones. 39904 queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); 39905 queue2 = alternate.updateQueue = createUpdateQueue(alternate.memoizedState); 39906 } else { 39907 // Only one fiber has an update queue. Clone to create a new one. 39908 queue1 = fiber.updateQueue = cloneUpdateQueue(queue2); 39909 } 39910 } else { 39911 if (queue2 === null) { 39912 // Only one fiber has an update queue. Clone to create a new one. 39913 queue2 = alternate.updateQueue = cloneUpdateQueue(queue1); 39914 } else { 39915 // Both owners have an update queue. 39916 } 39917 } 39918 } 39919 if (queue2 === null || queue1 === queue2) { 39920 // There's only a single queue. 39921 appendUpdateToQueue(queue1, update, expirationTime); 39922 } else { 39923 // There are two queues. We need to append the update to both queues, 39924 // while accounting for the persistent structure of the list â we don't 39925 // want the same update to be added multiple times. 39926 if (queue1.lastUpdate === null || queue2.lastUpdate === null) { 39927 // One of the queues is not empty. We must add the update to both queues. 39928 appendUpdateToQueue(queue1, update, expirationTime); 39929 appendUpdateToQueue(queue2, update, expirationTime); 39930 } else { 39931 // Both queues are non-empty. The last update is the same in both lists, 39932 // because of structural sharing. So, only append to one of the lists. 39933 appendUpdateToQueue(queue1, update, expirationTime); 39934 // But we still need to update the `lastUpdate` pointer of queue2. 39935 queue2.lastUpdate = update; 39936 } 39937 } 39938 39939 { 39940 if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) { 39941 warning(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.'); 39942 didWarnUpdateInsideUpdate = true; 39943 } 39944 } 39945} 39946 39947function enqueueCapturedUpdate(workInProgress, update, renderExpirationTime) { 39948 // Captured updates go into a separate list, and only on the work-in- 39949 // progress queue. 39950 var workInProgressQueue = workInProgress.updateQueue; 39951 if (workInProgressQueue === null) { 39952 workInProgressQueue = workInProgress.updateQueue = createUpdateQueue(workInProgress.memoizedState); 39953 } else { 39954 // TODO: I put this here rather than createWorkInProgress so that we don't 39955 // clone the queue unnecessarily. There's probably a better way to 39956 // structure this. 39957 workInProgressQueue = ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); 39958 } 39959 39960 // Append the update to the end of the list. 39961 if (workInProgressQueue.lastCapturedUpdate === null) { 39962 // This is the first render phase update 39963 workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update; 39964 } else { 39965 workInProgressQueue.lastCapturedUpdate.next = update; 39966 workInProgressQueue.lastCapturedUpdate = update; 39967 } 39968 if (workInProgressQueue.expirationTime === NoWork || workInProgressQueue.expirationTime > renderExpirationTime) { 39969 // The incoming update has the earliest expiration of any update in the 39970 // queue. Update the queue's expiration time. 39971 workInProgressQueue.expirationTime = renderExpirationTime; 39972 } 39973} 39974 39975function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { 39976 var current = workInProgress.alternate; 39977 if (current !== null) { 39978 // If the work-in-progress queue is equal to the current queue, 39979 // we need to clone it first. 39980 if (queue === current.updateQueue) { 39981 queue = workInProgress.updateQueue = cloneUpdateQueue(queue); 39982 } 39983 } 39984 return queue; 39985} 39986 39987function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) { 39988 switch (update.tag) { 39989 case ReplaceState: 39990 { 39991 var _payload = update.payload; 39992 if (typeof _payload === 'function') { 39993 // Updater function 39994 { 39995 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) { 39996 _payload.call(instance, prevState, nextProps); 39997 } 39998 } 39999 return _payload.call(instance, prevState, nextProps); 40000 } 40001 // State object 40002 return _payload; 40003 } 40004 case CaptureUpdate: 40005 { 40006 workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture; 40007 } 40008 // Intentional fallthrough 40009 case UpdateState: 40010 { 40011 var _payload2 = update.payload; 40012 var partialState = void 0; 40013 if (typeof _payload2 === 'function') { 40014 // Updater function 40015 { 40016 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) { 40017 _payload2.call(instance, prevState, nextProps); 40018 } 40019 } 40020 partialState = _payload2.call(instance, prevState, nextProps); 40021 } else { 40022 // Partial state object 40023 partialState = _payload2; 40024 } 40025 if (partialState === null || partialState === undefined) { 40026 // Null and undefined are treated as no-ops. 40027 return prevState; 40028 } 40029 // Merge the partial state and the previous state. 40030 return _assign({}, prevState, partialState); 40031 } 40032 case ForceUpdate: 40033 { 40034 hasForceUpdate = true; 40035 return prevState; 40036 } 40037 } 40038 return prevState; 40039} 40040 40041function processUpdateQueue(workInProgress, queue, props, instance, renderExpirationTime) { 40042 hasForceUpdate = false; 40043 40044 if (queue.expirationTime === NoWork || queue.expirationTime > renderExpirationTime) { 40045 // Insufficient priority. Bailout. 40046 return; 40047 } 40048 40049 queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); 40050 40051 { 40052 currentlyProcessingQueue = queue; 40053 } 40054 40055 // These values may change as we process the queue. 40056 var newBaseState = queue.baseState; 40057 var newFirstUpdate = null; 40058 var newExpirationTime = NoWork; 40059 40060 // Iterate through the list of updates to compute the result. 40061 var update = queue.firstUpdate; 40062 var resultState = newBaseState; 40063 while (update !== null) { 40064 var updateExpirationTime = update.expirationTime; 40065 if (updateExpirationTime > renderExpirationTime) { 40066 // This update does not have sufficient priority. Skip it. 40067 if (newFirstUpdate === null) { 40068 // This is the first skipped update. It will be the first update in 40069 // the new list. 40070 newFirstUpdate = update; 40071 // Since this is the first update that was skipped, the current result 40072 // is the new base state. 40073 newBaseState = resultState; 40074 } 40075 // Since this update will remain in the list, update the remaining 40076 // expiration time. 40077 if (newExpirationTime === NoWork || newExpirationTime > updateExpirationTime) { 40078 newExpirationTime = updateExpirationTime; 40079 } 40080 } else { 40081 // This update does have sufficient priority. Process it and compute 40082 // a new result. 40083 resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance); 40084 var _callback = update.callback; 40085 if (_callback !== null) { 40086 workInProgress.effectTag |= Callback; 40087 // Set this to null, in case it was mutated during an aborted render. 40088 update.nextEffect = null; 40089 if (queue.lastEffect === null) { 40090 queue.firstEffect = queue.lastEffect = update; 40091 } else { 40092 queue.lastEffect.nextEffect = update; 40093 queue.lastEffect = update; 40094 } 40095 } 40096 } 40097 // Continue to the next update. 40098 update = update.next; 40099 } 40100 40101 // Separately, iterate though the list of captured updates. 40102 var newFirstCapturedUpdate = null; 40103 update = queue.firstCapturedUpdate; 40104 while (update !== null) { 40105 var _updateExpirationTime = update.expirationTime; 40106 if (_updateExpirationTime > renderExpirationTime) { 40107 // This update does not have sufficient priority. Skip it. 40108 if (newFirstCapturedUpdate === null) { 40109 // This is the first skipped captured update. It will be the first 40110 // update in the new list. 40111 newFirstCapturedUpdate = update; 40112 // If this is the first update that was skipped, the current result is 40113 // the new base state. 40114 if (newFirstUpdate === null) { 40115 newBaseState = resultState; 40116 } 40117 } 40118 // Since this update will remain in the list, update the remaining 40119 // expiration time. 40120 if (newExpirationTime === NoWork || newExpirationTime > _updateExpirationTime) { 40121 newExpirationTime = _updateExpirationTime; 40122 } 40123 } else { 40124 // This update does have sufficient priority. Process it and compute 40125 // a new result. 40126 resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance); 40127 var _callback2 = update.callback; 40128 if (_callback2 !== null) { 40129 workInProgress.effectTag |= Callback; 40130 // Set this to null, in case it was mutated during an aborted render. 40131 update.nextEffect = null; 40132 if (queue.lastCapturedEffect === null) { 40133 queue.firstCapturedEffect = queue.lastCapturedEffect = update; 40134 } else { 40135 queue.lastCapturedEffect.nextEffect = update; 40136 queue.lastCapturedEffect = update; 40137 } 40138 } 40139 } 40140 update = update.next; 40141 } 40142 40143 if (newFirstUpdate === null) { 40144 queue.lastUpdate = null; 40145 } 40146 if (newFirstCapturedUpdate === null) { 40147 queue.lastCapturedUpdate = null; 40148 } else { 40149 workInProgress.effectTag |= Callback; 40150 } 40151 if (newFirstUpdate === null && newFirstCapturedUpdate === null) { 40152 // We processed every update, without skipping. That means the new base 40153 // state is the same as the result state. 40154 newBaseState = resultState; 40155 } 40156 40157 queue.baseState = newBaseState; 40158 queue.firstUpdate = newFirstUpdate; 40159 queue.firstCapturedUpdate = newFirstCapturedUpdate; 40160 queue.expirationTime = newExpirationTime; 40161 40162 workInProgress.memoizedState = resultState; 40163 40164 { 40165 currentlyProcessingQueue = null; 40166 } 40167} 40168 40169function callCallback(callback, context) { 40170 !(typeof callback === 'function') ? invariant(false, 'Invalid argument passed as callback. Expected a function. Instead received: %s', callback) : void 0; 40171 callback.call(context); 40172} 40173 40174function resetHasForceUpdateBeforeProcessing() { 40175 hasForceUpdate = false; 40176} 40177 40178function checkHasForceUpdateAfterProcessing() { 40179 return hasForceUpdate; 40180} 40181 40182function commitUpdateQueue(finishedWork, finishedQueue, instance, renderExpirationTime) { 40183 // If the finished render included captured updates, and there are still 40184 // lower priority updates left over, we need to keep the captured updates 40185 // in the queue so that they are rebased and not dropped once we process the 40186 // queue again at the lower priority. 40187 if (finishedQueue.firstCapturedUpdate !== null) { 40188 // Join the captured update list to the end of the normal list. 40189 if (finishedQueue.lastUpdate !== null) { 40190 finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate; 40191 finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate; 40192 } 40193 // Clear the list of captured updates. 40194 finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null; 40195 } 40196 40197 // Commit the effects 40198 var effect = finishedQueue.firstEffect; 40199 finishedQueue.firstEffect = finishedQueue.lastEffect = null; 40200 while (effect !== null) { 40201 var _callback3 = effect.callback; 40202 if (_callback3 !== null) { 40203 effect.callback = null; 40204 callCallback(_callback3, instance); 40205 } 40206 effect = effect.nextEffect; 40207 } 40208 40209 effect = finishedQueue.firstCapturedEffect; 40210 finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; 40211 while (effect !== null) { 40212 var _callback4 = effect.callback; 40213 if (_callback4 !== null) { 40214 effect.callback = null; 40215 callCallback(_callback4, instance); 40216 } 40217 effect = effect.nextEffect; 40218 } 40219} 40220 40221function createCapturedValue(value, source) { 40222 // If the value is an error, call this function immediately after it is thrown 40223 // so the stack is accurate. 40224 return { 40225 value: value, 40226 source: source, 40227 stack: getStackAddendumByWorkInProgressFiber(source) 40228 }; 40229} 40230 40231var providerCursor = createCursor(null); 40232var valueCursor = createCursor(null); 40233var changedBitsCursor = createCursor(0); 40234 40235var rendererSigil = void 0; 40236{ 40237 // Use this to detect multiple renderers using the same context 40238 rendererSigil = {}; 40239} 40240 40241function pushProvider(providerFiber) { 40242 var context = providerFiber.type._context; 40243 40244 if (isPrimaryRenderer) { 40245 push(changedBitsCursor, context._changedBits, providerFiber); 40246 push(valueCursor, context._currentValue, providerFiber); 40247 push(providerCursor, providerFiber, providerFiber); 40248 40249 context._currentValue = providerFiber.pendingProps.value; 40250 context._changedBits = providerFiber.stateNode; 40251 { 40252 !(context._currentRenderer === undefined || context._currentRenderer === null || context._currentRenderer === rendererSigil) ? warning(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0; 40253 context._currentRenderer = rendererSigil; 40254 } 40255 } else { 40256 push(changedBitsCursor, context._changedBits2, providerFiber); 40257 push(valueCursor, context._currentValue2, providerFiber); 40258 push(providerCursor, providerFiber, providerFiber); 40259 40260 context._currentValue2 = providerFiber.pendingProps.value; 40261 context._changedBits2 = providerFiber.stateNode; 40262 { 40263 !(context._currentRenderer2 === undefined || context._currentRenderer2 === null || context._currentRenderer2 === rendererSigil) ? warning(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0; 40264 context._currentRenderer2 = rendererSigil; 40265 } 40266 } 40267} 40268 40269function popProvider(providerFiber) { 40270 var changedBits = changedBitsCursor.current; 40271 var currentValue = valueCursor.current; 40272 40273 pop(providerCursor, providerFiber); 40274 pop(valueCursor, providerFiber); 40275 pop(changedBitsCursor, providerFiber); 40276 40277 var context = providerFiber.type._context; 40278 if (isPrimaryRenderer) { 40279 context._currentValue = currentValue; 40280 context._changedBits = changedBits; 40281 } else { 40282 context._currentValue2 = currentValue; 40283 context._changedBits2 = changedBits; 40284 } 40285} 40286 40287function getContextCurrentValue(context) { 40288 return isPrimaryRenderer ? context._currentValue : context._currentValue2; 40289} 40290 40291function getContextChangedBits(context) { 40292 return isPrimaryRenderer ? context._changedBits : context._changedBits2; 40293} 40294 40295var NO_CONTEXT = {}; 40296 40297var contextStackCursor$1 = createCursor(NO_CONTEXT); 40298var contextFiberStackCursor = createCursor(NO_CONTEXT); 40299var rootInstanceStackCursor = createCursor(NO_CONTEXT); 40300 40301function requiredContext(c) { 40302 !(c !== NO_CONTEXT) ? invariant(false, 'Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.') : void 0; 40303 return c; 40304} 40305 40306function getRootHostContainer() { 40307 var rootInstance = requiredContext(rootInstanceStackCursor.current); 40308 return rootInstance; 40309} 40310 40311function pushHostContainer(fiber, nextRootInstance) { 40312 // Push current root instance onto the stack; 40313 // This allows us to reset root when portals are popped. 40314 push(rootInstanceStackCursor, nextRootInstance, fiber); 40315 // Track the context and the Fiber that provided it. 40316 // This enables us to pop only Fibers that provide unique contexts. 40317 push(contextFiberStackCursor, fiber, fiber); 40318 40319 // Finally, we need to push the host context to the stack. 40320 // However, we can't just call getRootHostContext() and push it because 40321 // we'd have a different number of entries on the stack depending on 40322 // whether getRootHostContext() throws somewhere in renderer code or not. 40323 // So we push an empty value first. This lets us safely unwind on errors. 40324 push(contextStackCursor$1, NO_CONTEXT, fiber); 40325 var nextRootContext = getRootHostContext(nextRootInstance); 40326 // Now that we know this function doesn't throw, replace it. 40327 pop(contextStackCursor$1, fiber); 40328 push(contextStackCursor$1, nextRootContext, fiber); 40329} 40330 40331function popHostContainer(fiber) { 40332 pop(contextStackCursor$1, fiber); 40333 pop(contextFiberStackCursor, fiber); 40334 pop(rootInstanceStackCursor, fiber); 40335} 40336 40337function getHostContext() { 40338 var context = requiredContext(contextStackCursor$1.current); 40339 return context; 40340} 40341 40342function pushHostContext(fiber) { 40343 var rootInstance = requiredContext(rootInstanceStackCursor.current); 40344 var context = requiredContext(contextStackCursor$1.current); 40345 var nextContext = getChildHostContext(context, fiber.type, rootInstance); 40346 40347 // Don't push this Fiber's context unless it's unique. 40348 if (context === nextContext) { 40349 return; 40350 } 40351 40352 // Track the context and the Fiber that provided it. 40353 // This enables us to pop only Fibers that provide unique contexts. 40354 push(contextFiberStackCursor, fiber, fiber); 40355 push(contextStackCursor$1, nextContext, fiber); 40356} 40357 40358function popHostContext(fiber) { 40359 // Do not pop unless this Fiber provided the current context. 40360 // pushHostContext() only pushes Fibers that provide unique contexts. 40361 if (contextFiberStackCursor.current !== fiber) { 40362 return; 40363 } 40364 40365 pop(contextStackCursor$1, fiber); 40366 pop(contextFiberStackCursor, fiber); 40367} 40368 40369var commitTime = 0; 40370 40371function getCommitTime() { 40372 return commitTime; 40373} 40374 40375function recordCommitTime() { 40376 if (!enableProfilerTimer) { 40377 return; 40378 } 40379 commitTime = now(); 40380} 40381 40382/** 40383 * The "actual" render time is total time required to render the descendants of a Profiler component. 40384 * This time is stored as a stack, since Profilers can be nested. 40385 * This time is started during the "begin" phase and stopped during the "complete" phase. 40386 * It is paused (and accumulated) in the event of an interruption or an aborted render. 40387 */ 40388 40389var fiberStack$1 = void 0; 40390 40391{ 40392 fiberStack$1 = []; 40393} 40394 40395var timerPausedAt = 0; 40396var totalElapsedPauseTime = 0; 40397 40398function checkActualRenderTimeStackEmpty() { 40399 if (!enableProfilerTimer) { 40400 return; 40401 } 40402 { 40403 !(fiberStack$1.length === 0) ? warning(false, 'Expected an empty stack. Something was not reset properly.') : void 0; 40404 } 40405} 40406 40407function markActualRenderTimeStarted(fiber) { 40408 if (!enableProfilerTimer) { 40409 return; 40410 } 40411 { 40412 fiberStack$1.push(fiber); 40413 } 40414 40415 fiber.actualDuration = now() - fiber.actualDuration - totalElapsedPauseTime; 40416 fiber.actualStartTime = now(); 40417} 40418 40419function pauseActualRenderTimerIfRunning() { 40420 if (!enableProfilerTimer) { 40421 return; 40422 } 40423 if (timerPausedAt === 0) { 40424 timerPausedAt = now(); 40425 } 40426} 40427 40428function recordElapsedActualRenderTime(fiber) { 40429 if (!enableProfilerTimer) { 40430 return; 40431 } 40432 { 40433 !(fiber === fiberStack$1.pop()) ? warning(false, 'Unexpected Fiber (%s) popped.', getComponentName(fiber)) : void 0; 40434 } 40435 40436 fiber.actualDuration = now() - totalElapsedPauseTime - fiber.actualDuration; 40437} 40438 40439function resetActualRenderTimer() { 40440 if (!enableProfilerTimer) { 40441 return; 40442 } 40443 totalElapsedPauseTime = 0; 40444} 40445 40446function resumeActualRenderTimerIfPaused() { 40447 if (!enableProfilerTimer) { 40448 return; 40449 } 40450 if (timerPausedAt > 0) { 40451 totalElapsedPauseTime += now() - timerPausedAt; 40452 timerPausedAt = 0; 40453 } 40454} 40455 40456/** 40457 * The "base" render time is the duration of the âbeginâ phase of work for a particular fiber. 40458 * This time is measured and stored on each fiber. 40459 * The time for all sibling fibers are accumulated and stored on their parent during the "complete" phase. 40460 * If a fiber bails out (sCU false) then its "base" timer is cancelled and the fiber is not updated. 40461 */ 40462 40463var baseStartTime = -1; 40464 40465function recordElapsedBaseRenderTimeIfRunning(fiber) { 40466 if (!enableProfilerTimer) { 40467 return; 40468 } 40469 if (baseStartTime !== -1) { 40470 fiber.selfBaseTime = now() - baseStartTime; 40471 } 40472} 40473 40474function startBaseRenderTimer() { 40475 if (!enableProfilerTimer) { 40476 return; 40477 } 40478 { 40479 if (baseStartTime !== -1) { 40480 warning(false, 'Cannot start base timer that is already running. ' + 'This error is likely caused by a bug in React. ' + 'Please file an issue.'); 40481 } 40482 } 40483 baseStartTime = now(); 40484} 40485 40486function stopBaseRenderTimerIfRunning() { 40487 if (!enableProfilerTimer) { 40488 return; 40489 } 40490 baseStartTime = -1; 40491} 40492 40493var fakeInternalInstance = {}; 40494var isArray = Array.isArray; 40495 40496var didWarnAboutStateAssignmentForComponent = void 0; 40497var didWarnAboutUninitializedState = void 0; 40498var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = void 0; 40499var didWarnAboutLegacyLifecyclesAndDerivedState = void 0; 40500var didWarnAboutUndefinedDerivedState = void 0; 40501var warnOnUndefinedDerivedState = void 0; 40502var warnOnInvalidCallback$1 = void 0; 40503 40504{ 40505 didWarnAboutStateAssignmentForComponent = new Set(); 40506 didWarnAboutUninitializedState = new Set(); 40507 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set(); 40508 didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); 40509 didWarnAboutUndefinedDerivedState = new Set(); 40510 40511 var didWarnOnInvalidCallback = new Set(); 40512 40513 warnOnInvalidCallback$1 = function (callback, callerName) { 40514 if (callback === null || typeof callback === 'function') { 40515 return; 40516 } 40517 var key = callerName + '_' + callback; 40518 if (!didWarnOnInvalidCallback.has(key)) { 40519 didWarnOnInvalidCallback.add(key); 40520 warning(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); 40521 } 40522 }; 40523 40524 warnOnUndefinedDerivedState = function (workInProgress, partialState) { 40525 if (partialState === undefined) { 40526 var componentName = getComponentName(workInProgress) || 'Component'; 40527 if (!didWarnAboutUndefinedDerivedState.has(componentName)) { 40528 didWarnAboutUndefinedDerivedState.add(componentName); 40529 warning(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName); 40530 } 40531 } 40532 }; 40533 40534 // This is so gross but it's at least non-critical and can be removed if 40535 // it causes problems. This is meant to give a nicer error message for 40536 // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component, 40537 // ...)) which otherwise throws a "_processChildContext is not a function" 40538 // exception. 40539 Object.defineProperty(fakeInternalInstance, '_processChildContext', { 40540 enumerable: false, 40541 value: function () { 40542 invariant(false, '_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn\'t supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal).'); 40543 } 40544 }); 40545 Object.freeze(fakeInternalInstance); 40546} 40547 40548function applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, nextProps) { 40549 var prevState = workInProgress.memoizedState; 40550 40551 { 40552 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) { 40553 // Invoke the function an extra time to help detect side-effects. 40554 getDerivedStateFromProps(nextProps, prevState); 40555 } 40556 } 40557 40558 var partialState = getDerivedStateFromProps(nextProps, prevState); 40559 40560 { 40561 warnOnUndefinedDerivedState(workInProgress, partialState); 40562 } 40563 // Merge the partial state and the previous state. 40564 var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState); 40565 workInProgress.memoizedState = memoizedState; 40566 40567 // Once the update queue is empty, persist the derived state onto the 40568 // base state. 40569 var updateQueue = workInProgress.updateQueue; 40570 if (updateQueue !== null && updateQueue.expirationTime === NoWork) { 40571 updateQueue.baseState = memoizedState; 40572 } 40573} 40574 40575var classComponentUpdater = { 40576 isMounted: isMounted, 40577 enqueueSetState: function (inst, payload, callback) { 40578 var fiber = get(inst); 40579 var currentTime = recalculateCurrentTime(); 40580 var expirationTime = computeExpirationForFiber(currentTime, fiber); 40581 40582 var update = createUpdate(expirationTime); 40583 update.payload = payload; 40584 if (callback !== undefined && callback !== null) { 40585 { 40586 warnOnInvalidCallback$1(callback, 'setState'); 40587 } 40588 update.callback = callback; 40589 } 40590 40591 enqueueUpdate(fiber, update, expirationTime); 40592 scheduleWork$1(fiber, expirationTime); 40593 }, 40594 enqueueReplaceState: function (inst, payload, callback) { 40595 var fiber = get(inst); 40596 var currentTime = recalculateCurrentTime(); 40597 var expirationTime = computeExpirationForFiber(currentTime, fiber); 40598 40599 var update = createUpdate(expirationTime); 40600 update.tag = ReplaceState; 40601 update.payload = payload; 40602 40603 if (callback !== undefined && callback !== null) { 40604 { 40605 warnOnInvalidCallback$1(callback, 'replaceState'); 40606 } 40607 update.callback = callback; 40608 } 40609 40610 enqueueUpdate(fiber, update, expirationTime); 40611 scheduleWork$1(fiber, expirationTime); 40612 }, 40613 enqueueForceUpdate: function (inst, callback) { 40614 var fiber = get(inst); 40615 var currentTime = recalculateCurrentTime(); 40616 var expirationTime = computeExpirationForFiber(currentTime, fiber); 40617 40618 var update = createUpdate(expirationTime); 40619 update.tag = ForceUpdate; 40620 40621 if (callback !== undefined && callback !== null) { 40622 { 40623 warnOnInvalidCallback$1(callback, 'forceUpdate'); 40624 } 40625 update.callback = callback; 40626 } 40627 40628 enqueueUpdate(fiber, update, expirationTime); 40629 scheduleWork$1(fiber, expirationTime); 40630 } 40631}; 40632 40633function checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext) { 40634 var instance = workInProgress.stateNode; 40635 var ctor = workInProgress.type; 40636 if (typeof instance.shouldComponentUpdate === 'function') { 40637 startPhaseTimer(workInProgress, 'shouldComponentUpdate'); 40638 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext); 40639 stopPhaseTimer(); 40640 40641 { 40642 !(shouldUpdate !== undefined) ? warning(false, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Component') : void 0; 40643 } 40644 40645 return shouldUpdate; 40646 } 40647 40648 if (ctor.prototype && ctor.prototype.isPureReactComponent) { 40649 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState); 40650 } 40651 40652 return true; 40653} 40654 40655function checkClassInstance(workInProgress) { 40656 var instance = workInProgress.stateNode; 40657 var type = workInProgress.type; 40658 { 40659 var name = getComponentName(workInProgress) || 'Component'; 40660 var renderPresent = instance.render; 40661 40662 if (!renderPresent) { 40663 if (type.prototype && typeof type.prototype.render === 'function') { 40664 warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name); 40665 } else { 40666 warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name); 40667 } 40668 } 40669 40670 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state; 40671 !noGetInitialStateOnES6 ? warning(false, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name) : void 0; 40672 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved; 40673 !noGetDefaultPropsOnES6 ? warning(false, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name) : void 0; 40674 var noInstancePropTypes = !instance.propTypes; 40675 !noInstancePropTypes ? warning(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0; 40676 var noInstanceContextTypes = !instance.contextTypes; 40677 !noInstanceContextTypes ? warning(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0; 40678 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function'; 40679 !noComponentShouldUpdate ? warning(false, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name) : void 0; 40680 if (type.prototype && type.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') { 40681 warning(false, '%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(workInProgress) || 'A pure component'); 40682 } 40683 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function'; 40684 !noComponentDidUnmount ? warning(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0; 40685 var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function'; 40686 !noComponentDidReceiveProps ? warning(false, '%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name) : void 0; 40687 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function'; 40688 !noComponentWillRecieveProps ? warning(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0; 40689 var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function'; 40690 !noUnsafeComponentWillRecieveProps ? warning(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0; 40691 var hasMutatedProps = instance.props !== workInProgress.pendingProps; 40692 !(instance.props === undefined || !hasMutatedProps) ? warning(false, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name) : void 0; 40693 var noInstanceDefaultProps = !instance.defaultProps; 40694 !noInstanceDefaultProps ? warning(false, 'Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name) : void 0; 40695 40696 if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(type)) { 40697 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(type); 40698 warning(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(workInProgress)); 40699 } 40700 40701 var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function'; 40702 !noInstanceGetDerivedStateFromProps ? warning(false, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0; 40703 var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromCatch !== 'function'; 40704 !noInstanceGetDerivedStateFromCatch ? warning(false, '%s: getDerivedStateFromCatch() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0; 40705 var noStaticGetSnapshotBeforeUpdate = typeof type.getSnapshotBeforeUpdate !== 'function'; 40706 !noStaticGetSnapshotBeforeUpdate ? warning(false, '%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name) : void 0; 40707 var _state = instance.state; 40708 if (_state && (typeof _state !== 'object' || isArray(_state))) { 40709 warning(false, '%s.state: must be set to an object or null', name); 40710 } 40711 if (typeof instance.getChildContext === 'function') { 40712 !(typeof type.childContextTypes === 'object') ? warning(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0; 40713 } 40714 } 40715} 40716 40717function adoptClassInstance(workInProgress, instance) { 40718 instance.updater = classComponentUpdater; 40719 workInProgress.stateNode = instance; 40720 // The instance needs access to the fiber so that it can schedule updates 40721 set(instance, workInProgress); 40722 { 40723 instance._reactInternalInstance = fakeInternalInstance; 40724 } 40725} 40726 40727function constructClassInstance(workInProgress, props, renderExpirationTime) { 40728 var ctor = workInProgress.type; 40729 var unmaskedContext = getUnmaskedContext(workInProgress); 40730 var needsContext = isContextConsumer(workInProgress); 40731 var context = needsContext ? getMaskedContext(workInProgress, unmaskedContext) : emptyObject; 40732 40733 // Instantiate twice to help detect side-effects. 40734 { 40735 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) { 40736 new ctor(props, context); // eslint-disable-line no-new 40737 } 40738 } 40739 40740 var instance = new ctor(props, context); 40741 var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null; 40742 adoptClassInstance(workInProgress, instance); 40743 40744 { 40745 if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) { 40746 var componentName = getComponentName(workInProgress) || 'Component'; 40747 if (!didWarnAboutUninitializedState.has(componentName)) { 40748 didWarnAboutUninitializedState.add(componentName); 40749 warning(false, '%s: Did not properly initialize state during construction. ' + 'Expected state to be an object, but it was %s.', componentName, instance.state === null ? 'null' : 'undefined'); 40750 } 40751 } 40752 40753 // If new component APIs are defined, "unsafe" lifecycles won't be called. 40754 // Warn about these lifecycles if they are present. 40755 // Don't warn about react-lifecycles-compat polyfilled methods though. 40756 if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') { 40757 var foundWillMountName = null; 40758 var foundWillReceivePropsName = null; 40759 var foundWillUpdateName = null; 40760 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) { 40761 foundWillMountName = 'componentWillMount'; 40762 } else if (typeof instance.UNSAFE_componentWillMount === 'function') { 40763 foundWillMountName = 'UNSAFE_componentWillMount'; 40764 } 40765 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { 40766 foundWillReceivePropsName = 'componentWillReceiveProps'; 40767 } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 40768 foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps'; 40769 } 40770 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { 40771 foundWillUpdateName = 'componentWillUpdate'; 40772 } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') { 40773 foundWillUpdateName = 'UNSAFE_componentWillUpdate'; 40774 } 40775 if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) { 40776 var _componentName = getComponentName(workInProgress) || 'Component'; 40777 var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()'; 40778 if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { 40779 didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); 40780 warning(false, 'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', _componentName, newApiName, foundWillMountName !== null ? '\n ' + foundWillMountName : '', foundWillReceivePropsName !== null ? '\n ' + foundWillReceivePropsName : '', foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : ''); 40781 } 40782 } 40783 } 40784 } 40785 40786 // Cache unmasked context so we can avoid recreating masked context unless necessary. 40787 // ReactFiberContext usually updates this cache but can't for newly-created instances. 40788 if (needsContext) { 40789 cacheContext(workInProgress, unmaskedContext, context); 40790 } 40791 40792 return instance; 40793} 40794 40795function callComponentWillMount(workInProgress, instance) { 40796 startPhaseTimer(workInProgress, 'componentWillMount'); 40797 var oldState = instance.state; 40798 40799 if (typeof instance.componentWillMount === 'function') { 40800 instance.componentWillMount(); 40801 } 40802 if (typeof instance.UNSAFE_componentWillMount === 'function') { 40803 instance.UNSAFE_componentWillMount(); 40804 } 40805 40806 stopPhaseTimer(); 40807 40808 if (oldState !== instance.state) { 40809 { 40810 warning(false, '%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress) || 'Component'); 40811 } 40812 classComponentUpdater.enqueueReplaceState(instance, instance.state, null); 40813 } 40814} 40815 40816function callComponentWillReceiveProps(workInProgress, instance, newProps, newContext) { 40817 var oldState = instance.state; 40818 startPhaseTimer(workInProgress, 'componentWillReceiveProps'); 40819 if (typeof instance.componentWillReceiveProps === 'function') { 40820 instance.componentWillReceiveProps(newProps, newContext); 40821 } 40822 if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 40823 instance.UNSAFE_componentWillReceiveProps(newProps, newContext); 40824 } 40825 stopPhaseTimer(); 40826 40827 if (instance.state !== oldState) { 40828 { 40829 var componentName = getComponentName(workInProgress) || 'Component'; 40830 if (!didWarnAboutStateAssignmentForComponent.has(componentName)) { 40831 didWarnAboutStateAssignmentForComponent.add(componentName); 40832 warning(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName); 40833 } 40834 } 40835 classComponentUpdater.enqueueReplaceState(instance, instance.state, null); 40836 } 40837} 40838 40839// Invokes the mount life-cycles on a previously never rendered instance. 40840function mountClassInstance(workInProgress, renderExpirationTime) { 40841 var ctor = workInProgress.type; 40842 40843 { 40844 checkClassInstance(workInProgress); 40845 } 40846 40847 var instance = workInProgress.stateNode; 40848 var props = workInProgress.pendingProps; 40849 var unmaskedContext = getUnmaskedContext(workInProgress); 40850 40851 instance.props = props; 40852 instance.state = workInProgress.memoizedState; 40853 instance.refs = emptyObject; 40854 instance.context = getMaskedContext(workInProgress, unmaskedContext); 40855 40856 { 40857 if (workInProgress.mode & StrictMode) { 40858 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance); 40859 40860 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance); 40861 } 40862 40863 if (warnAboutDeprecatedLifecycles) { 40864 ReactStrictModeWarnings.recordDeprecationWarnings(workInProgress, instance); 40865 } 40866 } 40867 40868 var updateQueue = workInProgress.updateQueue; 40869 if (updateQueue !== null) { 40870 processUpdateQueue(workInProgress, updateQueue, props, instance, renderExpirationTime); 40871 instance.state = workInProgress.memoizedState; 40872 } 40873 40874 var getDerivedStateFromProps = workInProgress.type.getDerivedStateFromProps; 40875 if (typeof getDerivedStateFromProps === 'function') { 40876 applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, props); 40877 instance.state = workInProgress.memoizedState; 40878 } 40879 40880 // In order to support react-lifecycles-compat polyfilled components, 40881 // Unsafe lifecycles should not be invoked for components using the new APIs. 40882 if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { 40883 callComponentWillMount(workInProgress, instance); 40884 // If we had additional state updates during this life-cycle, let's 40885 // process them now. 40886 updateQueue = workInProgress.updateQueue; 40887 if (updateQueue !== null) { 40888 processUpdateQueue(workInProgress, updateQueue, props, instance, renderExpirationTime); 40889 instance.state = workInProgress.memoizedState; 40890 } 40891 } 40892 40893 if (typeof instance.componentDidMount === 'function') { 40894 workInProgress.effectTag |= Update; 40895 } 40896} 40897 40898function resumeMountClassInstance(workInProgress, renderExpirationTime) { 40899 var ctor = workInProgress.type; 40900 var instance = workInProgress.stateNode; 40901 40902 var oldProps = workInProgress.memoizedProps; 40903 var newProps = workInProgress.pendingProps; 40904 instance.props = oldProps; 40905 40906 var oldContext = instance.context; 40907 var newUnmaskedContext = getUnmaskedContext(workInProgress); 40908 var newContext = getMaskedContext(workInProgress, newUnmaskedContext); 40909 40910 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 40911 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; 40912 40913 // Note: During these life-cycles, instance.props/instance.state are what 40914 // ever the previously attempted to render - not the "current". However, 40915 // during componentDidUpdate we pass the "current" props. 40916 40917 // In order to support react-lifecycles-compat polyfilled components, 40918 // Unsafe lifecycles should not be invoked for components using the new APIs. 40919 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { 40920 if (oldProps !== newProps || oldContext !== newContext) { 40921 callComponentWillReceiveProps(workInProgress, instance, newProps, newContext); 40922 } 40923 } 40924 40925 resetHasForceUpdateBeforeProcessing(); 40926 40927 var oldState = workInProgress.memoizedState; 40928 var newState = instance.state = oldState; 40929 var updateQueue = workInProgress.updateQueue; 40930 if (updateQueue !== null) { 40931 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime); 40932 newState = workInProgress.memoizedState; 40933 } 40934 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { 40935 // If an update was already in progress, we should schedule an Update 40936 // effect even though we're bailing out, so that cWU/cDU are called. 40937 if (typeof instance.componentDidMount === 'function') { 40938 workInProgress.effectTag |= Update; 40939 } 40940 return false; 40941 } 40942 40943 if (typeof getDerivedStateFromProps === 'function') { 40944 applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, newProps); 40945 newState = workInProgress.memoizedState; 40946 } 40947 40948 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext); 40949 40950 if (shouldUpdate) { 40951 // In order to support react-lifecycles-compat polyfilled components, 40952 // Unsafe lifecycles should not be invoked for components using the new APIs. 40953 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { 40954 startPhaseTimer(workInProgress, 'componentWillMount'); 40955 if (typeof instance.componentWillMount === 'function') { 40956 instance.componentWillMount(); 40957 } 40958 if (typeof instance.UNSAFE_componentWillMount === 'function') { 40959 instance.UNSAFE_componentWillMount(); 40960 } 40961 stopPhaseTimer(); 40962 } 40963 if (typeof instance.componentDidMount === 'function') { 40964 workInProgress.effectTag |= Update; 40965 } 40966 } else { 40967 // If an update was already in progress, we should schedule an Update 40968 // effect even though we're bailing out, so that cWU/cDU are called. 40969 if (typeof instance.componentDidMount === 'function') { 40970 workInProgress.effectTag |= Update; 40971 } 40972 40973 // If shouldComponentUpdate returned false, we should still update the 40974 // memoized state to indicate that this work can be reused. 40975 workInProgress.memoizedProps = newProps; 40976 workInProgress.memoizedState = newState; 40977 } 40978 40979 // Update the existing instance's state, props, and context pointers even 40980 // if shouldComponentUpdate returns false. 40981 instance.props = newProps; 40982 instance.state = newState; 40983 instance.context = newContext; 40984 40985 return shouldUpdate; 40986} 40987 40988// Invokes the update life-cycles and returns false if it shouldn't rerender. 40989function updateClassInstance(current, workInProgress, renderExpirationTime) { 40990 var ctor = workInProgress.type; 40991 var instance = workInProgress.stateNode; 40992 40993 var oldProps = workInProgress.memoizedProps; 40994 var newProps = workInProgress.pendingProps; 40995 instance.props = oldProps; 40996 40997 var oldContext = instance.context; 40998 var newUnmaskedContext = getUnmaskedContext(workInProgress); 40999 var newContext = getMaskedContext(workInProgress, newUnmaskedContext); 41000 41001 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 41002 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; 41003 41004 // Note: During these life-cycles, instance.props/instance.state are what 41005 // ever the previously attempted to render - not the "current". However, 41006 // during componentDidUpdate we pass the "current" props. 41007 41008 // In order to support react-lifecycles-compat polyfilled components, 41009 // Unsafe lifecycles should not be invoked for components using the new APIs. 41010 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { 41011 if (oldProps !== newProps || oldContext !== newContext) { 41012 callComponentWillReceiveProps(workInProgress, instance, newProps, newContext); 41013 } 41014 } 41015 41016 resetHasForceUpdateBeforeProcessing(); 41017 41018 var oldState = workInProgress.memoizedState; 41019 var newState = instance.state = oldState; 41020 var updateQueue = workInProgress.updateQueue; 41021 if (updateQueue !== null) { 41022 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime); 41023 newState = workInProgress.memoizedState; 41024 } 41025 41026 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { 41027 // If an update was already in progress, we should schedule an Update 41028 // effect even though we're bailing out, so that cWU/cDU are called. 41029 if (typeof instance.componentDidUpdate === 'function') { 41030 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 41031 workInProgress.effectTag |= Update; 41032 } 41033 } 41034 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 41035 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 41036 workInProgress.effectTag |= Snapshot; 41037 } 41038 } 41039 return false; 41040 } 41041 41042 if (typeof getDerivedStateFromProps === 'function') { 41043 applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, newProps); 41044 newState = workInProgress.memoizedState; 41045 } 41046 41047 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext); 41048 41049 if (shouldUpdate) { 41050 // In order to support react-lifecycles-compat polyfilled components, 41051 // Unsafe lifecycles should not be invoked for components using the new APIs. 41052 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) { 41053 startPhaseTimer(workInProgress, 'componentWillUpdate'); 41054 if (typeof instance.componentWillUpdate === 'function') { 41055 instance.componentWillUpdate(newProps, newState, newContext); 41056 } 41057 if (typeof instance.UNSAFE_componentWillUpdate === 'function') { 41058 instance.UNSAFE_componentWillUpdate(newProps, newState, newContext); 41059 } 41060 stopPhaseTimer(); 41061 } 41062 if (typeof instance.componentDidUpdate === 'function') { 41063 workInProgress.effectTag |= Update; 41064 } 41065 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 41066 workInProgress.effectTag |= Snapshot; 41067 } 41068 } else { 41069 // If an update was already in progress, we should schedule an Update 41070 // effect even though we're bailing out, so that cWU/cDU are called. 41071 if (typeof instance.componentDidUpdate === 'function') { 41072 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 41073 workInProgress.effectTag |= Update; 41074 } 41075 } 41076 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 41077 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 41078 workInProgress.effectTag |= Snapshot; 41079 } 41080 } 41081 41082 // If shouldComponentUpdate returned false, we should still update the 41083 // memoized props/state to indicate that this work can be reused. 41084 workInProgress.memoizedProps = newProps; 41085 workInProgress.memoizedState = newState; 41086 } 41087 41088 // Update the existing instance's state, props, and context pointers even 41089 // if shouldComponentUpdate returns false. 41090 instance.props = newProps; 41091 instance.state = newState; 41092 instance.context = newContext; 41093 41094 return shouldUpdate; 41095} 41096 41097var getCurrentFiberStackAddendum$7 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 41098 41099 41100var didWarnAboutMaps = void 0; 41101var didWarnAboutStringRefInStrictMode = void 0; 41102var ownerHasKeyUseWarning = void 0; 41103var ownerHasFunctionTypeWarning = void 0; 41104var warnForMissingKey = function (child) {}; 41105 41106{ 41107 didWarnAboutMaps = false; 41108 didWarnAboutStringRefInStrictMode = {}; 41109 41110 /** 41111 * Warn if there's no key explicitly set on dynamic arrays of children or 41112 * object keys are not valid. This allows us to keep track of children between 41113 * updates. 41114 */ 41115 ownerHasKeyUseWarning = {}; 41116 ownerHasFunctionTypeWarning = {}; 41117 41118 warnForMissingKey = function (child) { 41119 if (child === null || typeof child !== 'object') { 41120 return; 41121 } 41122 if (!child._store || child._store.validated || child.key != null) { 41123 return; 41124 } 41125 !(typeof child._store === 'object') ? invariant(false, 'React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue.') : void 0; 41126 child._store.validated = true; 41127 41128 var currentComponentErrorInfo = 'Each child in an array or iterator should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + (getCurrentFiberStackAddendum$7() || ''); 41129 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 41130 return; 41131 } 41132 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; 41133 41134 warning(false, 'Each child in an array or iterator should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.%s', getCurrentFiberStackAddendum$7()); 41135 }; 41136} 41137 41138var isArray$1 = Array.isArray; 41139 41140function coerceRef(returnFiber, current, element) { 41141 var mixedRef = element.ref; 41142 if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') { 41143 { 41144 if (returnFiber.mode & StrictMode) { 41145 var componentName = getComponentName(returnFiber) || 'Component'; 41146 if (!didWarnAboutStringRefInStrictMode[componentName]) { 41147 warning(false, 'A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using createRef() instead.' + '\n%s' + '\n\nLearn more about using refs safely here:' + '\nhttps://fb.me/react-strict-mode-string-ref', mixedRef, getStackAddendumByWorkInProgressFiber(returnFiber)); 41148 didWarnAboutStringRefInStrictMode[componentName] = true; 41149 } 41150 } 41151 } 41152 41153 if (element._owner) { 41154 var owner = element._owner; 41155 var inst = void 0; 41156 if (owner) { 41157 var ownerFiber = owner; 41158 !(ownerFiber.tag === ClassComponent) ? invariant(false, 'Stateless function components cannot have refs.') : void 0; 41159 inst = ownerFiber.stateNode; 41160 } 41161 !inst ? invariant(false, 'Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.', mixedRef) : void 0; 41162 var stringRef = '' + mixedRef; 41163 // Check if previous string ref matches new string ref 41164 if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) { 41165 return current.ref; 41166 } 41167 var ref = function (value) { 41168 var refs = inst.refs === emptyObject ? inst.refs = {} : inst.refs; 41169 if (value === null) { 41170 delete refs[stringRef]; 41171 } else { 41172 refs[stringRef] = value; 41173 } 41174 }; 41175 ref._stringRef = stringRef; 41176 return ref; 41177 } else { 41178 !(typeof mixedRef === 'string') ? invariant(false, 'Expected ref to be a function or a string.') : void 0; 41179 !element._owner ? invariant(false, 'Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a functional component\n2. You may be adding a ref to a component that was not created inside a component\'s render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.', mixedRef) : void 0; 41180 } 41181 } 41182 return mixedRef; 41183} 41184 41185function throwOnInvalidObjectType(returnFiber, newChild) { 41186 if (returnFiber.type !== 'textarea') { 41187 var addendum = ''; 41188 { 41189 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + (getCurrentFiberStackAddendum$7() || ''); 41190 } 41191 invariant(false, 'Objects are not valid as a React child (found: %s).%s', Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild, addendum); 41192 } 41193} 41194 41195function warnOnFunctionType() { 41196 var currentComponentErrorInfo = 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + (getCurrentFiberStackAddendum$7() || ''); 41197 41198 if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { 41199 return; 41200 } 41201 ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; 41202 41203 warning(false, 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.%s', getCurrentFiberStackAddendum$7() || ''); 41204} 41205 41206// This wrapper function exists because I expect to clone the code in each path 41207// to be able to optimize each path individually by branching early. This needs 41208// a compiler or we can do it manually. Helpers that don't need this branching 41209// live outside of this function. 41210function ChildReconciler(shouldTrackSideEffects) { 41211 function deleteChild(returnFiber, childToDelete) { 41212 if (!shouldTrackSideEffects) { 41213 // Noop. 41214 return; 41215 } 41216 // Deletions are added in reversed order so we add it to the front. 41217 // At this point, the return fiber's effect list is empty except for 41218 // deletions, so we can just append the deletion to the list. The remaining 41219 // effects aren't added until the complete phase. Once we implement 41220 // resuming, this may not be true. 41221 var last = returnFiber.lastEffect; 41222 if (last !== null) { 41223 last.nextEffect = childToDelete; 41224 returnFiber.lastEffect = childToDelete; 41225 } else { 41226 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; 41227 } 41228 childToDelete.nextEffect = null; 41229 childToDelete.effectTag = Deletion; 41230 } 41231 41232 function deleteRemainingChildren(returnFiber, currentFirstChild) { 41233 if (!shouldTrackSideEffects) { 41234 // Noop. 41235 return null; 41236 } 41237 41238 // TODO: For the shouldClone case, this could be micro-optimized a bit by 41239 // assuming that after the first child we've already added everything. 41240 var childToDelete = currentFirstChild; 41241 while (childToDelete !== null) { 41242 deleteChild(returnFiber, childToDelete); 41243 childToDelete = childToDelete.sibling; 41244 } 41245 return null; 41246 } 41247 41248 function mapRemainingChildren(returnFiber, currentFirstChild) { 41249 // Add the remaining children to a temporary map so that we can find them by 41250 // keys quickly. Implicit (null) keys get added to this set with their index 41251 var existingChildren = new Map(); 41252 41253 var existingChild = currentFirstChild; 41254 while (existingChild !== null) { 41255 if (existingChild.key !== null) { 41256 existingChildren.set(existingChild.key, existingChild); 41257 } else { 41258 existingChildren.set(existingChild.index, existingChild); 41259 } 41260 existingChild = existingChild.sibling; 41261 } 41262 return existingChildren; 41263 } 41264 41265 function useFiber(fiber, pendingProps, expirationTime) { 41266 // We currently set sibling to null and index to 0 here because it is easy 41267 // to forget to do before returning it. E.g. for the single child case. 41268 var clone = createWorkInProgress(fiber, pendingProps, expirationTime); 41269 clone.index = 0; 41270 clone.sibling = null; 41271 return clone; 41272 } 41273 41274 function placeChild(newFiber, lastPlacedIndex, newIndex) { 41275 newFiber.index = newIndex; 41276 if (!shouldTrackSideEffects) { 41277 // Noop. 41278 return lastPlacedIndex; 41279 } 41280 var current = newFiber.alternate; 41281 if (current !== null) { 41282 var oldIndex = current.index; 41283 if (oldIndex < lastPlacedIndex) { 41284 // This is a move. 41285 newFiber.effectTag = Placement; 41286 return lastPlacedIndex; 41287 } else { 41288 // This item can stay in place. 41289 return oldIndex; 41290 } 41291 } else { 41292 // This is an insertion. 41293 newFiber.effectTag = Placement; 41294 return lastPlacedIndex; 41295 } 41296 } 41297 41298 function placeSingleChild(newFiber) { 41299 // This is simpler for the single child case. We only need to do a 41300 // placement for inserting new children. 41301 if (shouldTrackSideEffects && newFiber.alternate === null) { 41302 newFiber.effectTag = Placement; 41303 } 41304 return newFiber; 41305 } 41306 41307 function updateTextNode(returnFiber, current, textContent, expirationTime) { 41308 if (current === null || current.tag !== HostText) { 41309 // Insert 41310 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime); 41311 created.return = returnFiber; 41312 return created; 41313 } else { 41314 // Update 41315 var existing = useFiber(current, textContent, expirationTime); 41316 existing.return = returnFiber; 41317 return existing; 41318 } 41319 } 41320 41321 function updateElement(returnFiber, current, element, expirationTime) { 41322 if (current !== null && current.type === element.type) { 41323 // Move based on index 41324 var existing = useFiber(current, element.props, expirationTime); 41325 existing.ref = coerceRef(returnFiber, current, element); 41326 existing.return = returnFiber; 41327 { 41328 existing._debugSource = element._source; 41329 existing._debugOwner = element._owner; 41330 } 41331 return existing; 41332 } else { 41333 // Insert 41334 var created = createFiberFromElement(element, returnFiber.mode, expirationTime); 41335 created.ref = coerceRef(returnFiber, current, element); 41336 created.return = returnFiber; 41337 return created; 41338 } 41339 } 41340 41341 function updatePortal(returnFiber, current, portal, expirationTime) { 41342 if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) { 41343 // Insert 41344 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime); 41345 created.return = returnFiber; 41346 return created; 41347 } else { 41348 // Update 41349 var existing = useFiber(current, portal.children || [], expirationTime); 41350 existing.return = returnFiber; 41351 return existing; 41352 } 41353 } 41354 41355 function updateFragment(returnFiber, current, fragment, expirationTime, key) { 41356 if (current === null || current.tag !== Fragment) { 41357 // Insert 41358 var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key); 41359 created.return = returnFiber; 41360 return created; 41361 } else { 41362 // Update 41363 var existing = useFiber(current, fragment, expirationTime); 41364 existing.return = returnFiber; 41365 return existing; 41366 } 41367 } 41368 41369 function createChild(returnFiber, newChild, expirationTime) { 41370 if (typeof newChild === 'string' || typeof newChild === 'number') { 41371 // Text nodes don't have keys. If the previous node is implicitly keyed 41372 // we can continue to replace it without aborting even if it is not a text 41373 // node. 41374 var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime); 41375 created.return = returnFiber; 41376 return created; 41377 } 41378 41379 if (typeof newChild === 'object' && newChild !== null) { 41380 switch (newChild.$$typeof) { 41381 case REACT_ELEMENT_TYPE: 41382 { 41383 var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime); 41384 _created.ref = coerceRef(returnFiber, null, newChild); 41385 _created.return = returnFiber; 41386 return _created; 41387 } 41388 case REACT_PORTAL_TYPE: 41389 { 41390 var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime); 41391 _created2.return = returnFiber; 41392 return _created2; 41393 } 41394 } 41395 41396 if (isArray$1(newChild) || getIteratorFn(newChild)) { 41397 var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null); 41398 _created3.return = returnFiber; 41399 return _created3; 41400 } 41401 41402 throwOnInvalidObjectType(returnFiber, newChild); 41403 } 41404 41405 { 41406 if (typeof newChild === 'function') { 41407 warnOnFunctionType(); 41408 } 41409 } 41410 41411 return null; 41412 } 41413 41414 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { 41415 // Update the fiber if the keys match, otherwise return null. 41416 41417 var key = oldFiber !== null ? oldFiber.key : null; 41418 41419 if (typeof newChild === 'string' || typeof newChild === 'number') { 41420 // Text nodes don't have keys. If the previous node is implicitly keyed 41421 // we can continue to replace it without aborting even if it is not a text 41422 // node. 41423 if (key !== null) { 41424 return null; 41425 } 41426 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime); 41427 } 41428 41429 if (typeof newChild === 'object' && newChild !== null) { 41430 switch (newChild.$$typeof) { 41431 case REACT_ELEMENT_TYPE: 41432 { 41433 if (newChild.key === key) { 41434 if (newChild.type === REACT_FRAGMENT_TYPE) { 41435 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key); 41436 } 41437 return updateElement(returnFiber, oldFiber, newChild, expirationTime); 41438 } else { 41439 return null; 41440 } 41441 } 41442 case REACT_PORTAL_TYPE: 41443 { 41444 if (newChild.key === key) { 41445 return updatePortal(returnFiber, oldFiber, newChild, expirationTime); 41446 } else { 41447 return null; 41448 } 41449 } 41450 } 41451 41452 if (isArray$1(newChild) || getIteratorFn(newChild)) { 41453 if (key !== null) { 41454 return null; 41455 } 41456 41457 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null); 41458 } 41459 41460 throwOnInvalidObjectType(returnFiber, newChild); 41461 } 41462 41463 { 41464 if (typeof newChild === 'function') { 41465 warnOnFunctionType(); 41466 } 41467 } 41468 41469 return null; 41470 } 41471 41472 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) { 41473 if (typeof newChild === 'string' || typeof newChild === 'number') { 41474 // Text nodes don't have keys, so we neither have to check the old nor 41475 // new node for the key. If both are text nodes, they match. 41476 var matchedFiber = existingChildren.get(newIdx) || null; 41477 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime); 41478 } 41479 41480 if (typeof newChild === 'object' && newChild !== null) { 41481 switch (newChild.$$typeof) { 41482 case REACT_ELEMENT_TYPE: 41483 { 41484 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 41485 if (newChild.type === REACT_FRAGMENT_TYPE) { 41486 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key); 41487 } 41488 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime); 41489 } 41490 case REACT_PORTAL_TYPE: 41491 { 41492 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 41493 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime); 41494 } 41495 } 41496 41497 if (isArray$1(newChild) || getIteratorFn(newChild)) { 41498 var _matchedFiber3 = existingChildren.get(newIdx) || null; 41499 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null); 41500 } 41501 41502 throwOnInvalidObjectType(returnFiber, newChild); 41503 } 41504 41505 { 41506 if (typeof newChild === 'function') { 41507 warnOnFunctionType(); 41508 } 41509 } 41510 41511 return null; 41512 } 41513 41514 /** 41515 * Warns if there is a duplicate or missing key 41516 */ 41517 function warnOnInvalidKey(child, knownKeys) { 41518 { 41519 if (typeof child !== 'object' || child === null) { 41520 return knownKeys; 41521 } 41522 switch (child.$$typeof) { 41523 case REACT_ELEMENT_TYPE: 41524 case REACT_PORTAL_TYPE: 41525 warnForMissingKey(child); 41526 var key = child.key; 41527 if (typeof key !== 'string') { 41528 break; 41529 } 41530 if (knownKeys === null) { 41531 knownKeys = new Set(); 41532 knownKeys.add(key); 41533 break; 41534 } 41535 if (!knownKeys.has(key)) { 41536 knownKeys.add(key); 41537 break; 41538 } 41539 warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted â the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$7()); 41540 break; 41541 default: 41542 break; 41543 } 41544 } 41545 return knownKeys; 41546 } 41547 41548 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) { 41549 // This algorithm can't optimize by searching from boths ends since we 41550 // don't have backpointers on fibers. I'm trying to see how far we can get 41551 // with that model. If it ends up not being worth the tradeoffs, we can 41552 // add it later. 41553 41554 // Even with a two ended optimization, we'd want to optimize for the case 41555 // where there are few changes and brute force the comparison instead of 41556 // going for the Map. It'd like to explore hitting that path first in 41557 // forward-only mode and only go for the Map once we notice that we need 41558 // lots of look ahead. This doesn't handle reversal as well as two ended 41559 // search but that's unusual. Besides, for the two ended optimization to 41560 // work on Iterables, we'd need to copy the whole set. 41561 41562 // In this first iteration, we'll just live with hitting the bad case 41563 // (adding everything to a Map) in for every insert/move. 41564 41565 // If you change this code, also update reconcileChildrenIterator() which 41566 // uses the same algorithm. 41567 41568 { 41569 // First, validate keys. 41570 var knownKeys = null; 41571 for (var i = 0; i < newChildren.length; i++) { 41572 var child = newChildren[i]; 41573 knownKeys = warnOnInvalidKey(child, knownKeys); 41574 } 41575 } 41576 41577 var resultingFirstChild = null; 41578 var previousNewFiber = null; 41579 41580 var oldFiber = currentFirstChild; 41581 var lastPlacedIndex = 0; 41582 var newIdx = 0; 41583 var nextOldFiber = null; 41584 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) { 41585 if (oldFiber.index > newIdx) { 41586 nextOldFiber = oldFiber; 41587 oldFiber = null; 41588 } else { 41589 nextOldFiber = oldFiber.sibling; 41590 } 41591 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime); 41592 if (newFiber === null) { 41593 // TODO: This breaks on empty slots like null children. That's 41594 // unfortunate because it triggers the slow path all the time. We need 41595 // a better way to communicate whether this was a miss or null, 41596 // boolean, undefined, etc. 41597 if (oldFiber === null) { 41598 oldFiber = nextOldFiber; 41599 } 41600 break; 41601 } 41602 if (shouldTrackSideEffects) { 41603 if (oldFiber && newFiber.alternate === null) { 41604 // We matched the slot, but we didn't reuse the existing fiber, so we 41605 // need to delete the existing child. 41606 deleteChild(returnFiber, oldFiber); 41607 } 41608 } 41609 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); 41610 if (previousNewFiber === null) { 41611 // TODO: Move out of the loop. This only happens for the first run. 41612 resultingFirstChild = newFiber; 41613 } else { 41614 // TODO: Defer siblings if we're not at the right index for this slot. 41615 // I.e. if we had null values before, then we want to defer this 41616 // for each null value. However, we also don't want to call updateSlot 41617 // with the previous one. 41618 previousNewFiber.sibling = newFiber; 41619 } 41620 previousNewFiber = newFiber; 41621 oldFiber = nextOldFiber; 41622 } 41623 41624 if (newIdx === newChildren.length) { 41625 // We've reached the end of the new children. We can delete the rest. 41626 deleteRemainingChildren(returnFiber, oldFiber); 41627 return resultingFirstChild; 41628 } 41629 41630 if (oldFiber === null) { 41631 // If we don't have any more existing children we can choose a fast path 41632 // since the rest will all be insertions. 41633 for (; newIdx < newChildren.length; newIdx++) { 41634 var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime); 41635 if (!_newFiber) { 41636 continue; 41637 } 41638 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx); 41639 if (previousNewFiber === null) { 41640 // TODO: Move out of the loop. This only happens for the first run. 41641 resultingFirstChild = _newFiber; 41642 } else { 41643 previousNewFiber.sibling = _newFiber; 41644 } 41645 previousNewFiber = _newFiber; 41646 } 41647 return resultingFirstChild; 41648 } 41649 41650 // Add all children to a key map for quick lookups. 41651 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); 41652 41653 // Keep scanning and use the map to restore deleted items as moves. 41654 for (; newIdx < newChildren.length; newIdx++) { 41655 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime); 41656 if (_newFiber2) { 41657 if (shouldTrackSideEffects) { 41658 if (_newFiber2.alternate !== null) { 41659 // The new fiber is a work in progress, but if there exists a 41660 // current, that means that we reused the fiber. We need to delete 41661 // it from the child list so that we don't add it to the deletion 41662 // list. 41663 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key); 41664 } 41665 } 41666 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx); 41667 if (previousNewFiber === null) { 41668 resultingFirstChild = _newFiber2; 41669 } else { 41670 previousNewFiber.sibling = _newFiber2; 41671 } 41672 previousNewFiber = _newFiber2; 41673 } 41674 } 41675 41676 if (shouldTrackSideEffects) { 41677 // Any existing children that weren't consumed above were deleted. We need 41678 // to add them to the deletion list. 41679 existingChildren.forEach(function (child) { 41680 return deleteChild(returnFiber, child); 41681 }); 41682 } 41683 41684 return resultingFirstChild; 41685 } 41686 41687 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) { 41688 // This is the same implementation as reconcileChildrenArray(), 41689 // but using the iterator instead. 41690 41691 var iteratorFn = getIteratorFn(newChildrenIterable); 41692 !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0; 41693 41694 { 41695 // Warn about using Maps as children 41696 if (newChildrenIterable.entries === iteratorFn) { 41697 !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$7()) : void 0; 41698 didWarnAboutMaps = true; 41699 } 41700 41701 // First, validate keys. 41702 // We'll get a different iterator later for the main pass. 41703 var _newChildren = iteratorFn.call(newChildrenIterable); 41704 if (_newChildren) { 41705 var knownKeys = null; 41706 var _step = _newChildren.next(); 41707 for (; !_step.done; _step = _newChildren.next()) { 41708 var child = _step.value; 41709 knownKeys = warnOnInvalidKey(child, knownKeys); 41710 } 41711 } 41712 } 41713 41714 var newChildren = iteratorFn.call(newChildrenIterable); 41715 !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0; 41716 41717 var resultingFirstChild = null; 41718 var previousNewFiber = null; 41719 41720 var oldFiber = currentFirstChild; 41721 var lastPlacedIndex = 0; 41722 var newIdx = 0; 41723 var nextOldFiber = null; 41724 41725 var step = newChildren.next(); 41726 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) { 41727 if (oldFiber.index > newIdx) { 41728 nextOldFiber = oldFiber; 41729 oldFiber = null; 41730 } else { 41731 nextOldFiber = oldFiber.sibling; 41732 } 41733 var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime); 41734 if (newFiber === null) { 41735 // TODO: This breaks on empty slots like null children. That's 41736 // unfortunate because it triggers the slow path all the time. We need 41737 // a better way to communicate whether this was a miss or null, 41738 // boolean, undefined, etc. 41739 if (!oldFiber) { 41740 oldFiber = nextOldFiber; 41741 } 41742 break; 41743 } 41744 if (shouldTrackSideEffects) { 41745 if (oldFiber && newFiber.alternate === null) { 41746 // We matched the slot, but we didn't reuse the existing fiber, so we 41747 // need to delete the existing child. 41748 deleteChild(returnFiber, oldFiber); 41749 } 41750 } 41751 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); 41752 if (previousNewFiber === null) { 41753 // TODO: Move out of the loop. This only happens for the first run. 41754 resultingFirstChild = newFiber; 41755 } else { 41756 // TODO: Defer siblings if we're not at the right index for this slot. 41757 // I.e. if we had null values before, then we want to defer this 41758 // for each null value. However, we also don't want to call updateSlot 41759 // with the previous one. 41760 previousNewFiber.sibling = newFiber; 41761 } 41762 previousNewFiber = newFiber; 41763 oldFiber = nextOldFiber; 41764 } 41765 41766 if (step.done) { 41767 // We've reached the end of the new children. We can delete the rest. 41768 deleteRemainingChildren(returnFiber, oldFiber); 41769 return resultingFirstChild; 41770 } 41771 41772 if (oldFiber === null) { 41773 // If we don't have any more existing children we can choose a fast path 41774 // since the rest will all be insertions. 41775 for (; !step.done; newIdx++, step = newChildren.next()) { 41776 var _newFiber3 = createChild(returnFiber, step.value, expirationTime); 41777 if (_newFiber3 === null) { 41778 continue; 41779 } 41780 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx); 41781 if (previousNewFiber === null) { 41782 // TODO: Move out of the loop. This only happens for the first run. 41783 resultingFirstChild = _newFiber3; 41784 } else { 41785 previousNewFiber.sibling = _newFiber3; 41786 } 41787 previousNewFiber = _newFiber3; 41788 } 41789 return resultingFirstChild; 41790 } 41791 41792 // Add all children to a key map for quick lookups. 41793 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); 41794 41795 // Keep scanning and use the map to restore deleted items as moves. 41796 for (; !step.done; newIdx++, step = newChildren.next()) { 41797 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime); 41798 if (_newFiber4 !== null) { 41799 if (shouldTrackSideEffects) { 41800 if (_newFiber4.alternate !== null) { 41801 // The new fiber is a work in progress, but if there exists a 41802 // current, that means that we reused the fiber. We need to delete 41803 // it from the child list so that we don't add it to the deletion 41804 // list. 41805 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key); 41806 } 41807 } 41808 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx); 41809 if (previousNewFiber === null) { 41810 resultingFirstChild = _newFiber4; 41811 } else { 41812 previousNewFiber.sibling = _newFiber4; 41813 } 41814 previousNewFiber = _newFiber4; 41815 } 41816 } 41817 41818 if (shouldTrackSideEffects) { 41819 // Any existing children that weren't consumed above were deleted. We need 41820 // to add them to the deletion list. 41821 existingChildren.forEach(function (child) { 41822 return deleteChild(returnFiber, child); 41823 }); 41824 } 41825 41826 return resultingFirstChild; 41827 } 41828 41829 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) { 41830 // There's no need to check for keys on text nodes since we don't have a 41831 // way to define them. 41832 if (currentFirstChild !== null && currentFirstChild.tag === HostText) { 41833 // We already have an existing node so let's just update it and delete 41834 // the rest. 41835 deleteRemainingChildren(returnFiber, currentFirstChild.sibling); 41836 var existing = useFiber(currentFirstChild, textContent, expirationTime); 41837 existing.return = returnFiber; 41838 return existing; 41839 } 41840 // The existing first child is not a text node so we need to create one 41841 // and delete the existing ones. 41842 deleteRemainingChildren(returnFiber, currentFirstChild); 41843 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime); 41844 created.return = returnFiber; 41845 return created; 41846 } 41847 41848 function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) { 41849 var key = element.key; 41850 var child = currentFirstChild; 41851 while (child !== null) { 41852 // TODO: If key === null and child.key === null, then this only applies to 41853 // the first item in the list. 41854 if (child.key === key) { 41855 if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) { 41856 deleteRemainingChildren(returnFiber, child.sibling); 41857 var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime); 41858 existing.ref = coerceRef(returnFiber, child, element); 41859 existing.return = returnFiber; 41860 { 41861 existing._debugSource = element._source; 41862 existing._debugOwner = element._owner; 41863 } 41864 return existing; 41865 } else { 41866 deleteRemainingChildren(returnFiber, child); 41867 break; 41868 } 41869 } else { 41870 deleteChild(returnFiber, child); 41871 } 41872 child = child.sibling; 41873 } 41874 41875 if (element.type === REACT_FRAGMENT_TYPE) { 41876 var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key); 41877 created.return = returnFiber; 41878 return created; 41879 } else { 41880 var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime); 41881 _created4.ref = coerceRef(returnFiber, currentFirstChild, element); 41882 _created4.return = returnFiber; 41883 return _created4; 41884 } 41885 } 41886 41887 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) { 41888 var key = portal.key; 41889 var child = currentFirstChild; 41890 while (child !== null) { 41891 // TODO: If key === null and child.key === null, then this only applies to 41892 // the first item in the list. 41893 if (child.key === key) { 41894 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) { 41895 deleteRemainingChildren(returnFiber, child.sibling); 41896 var existing = useFiber(child, portal.children || [], expirationTime); 41897 existing.return = returnFiber; 41898 return existing; 41899 } else { 41900 deleteRemainingChildren(returnFiber, child); 41901 break; 41902 } 41903 } else { 41904 deleteChild(returnFiber, child); 41905 } 41906 child = child.sibling; 41907 } 41908 41909 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime); 41910 created.return = returnFiber; 41911 return created; 41912 } 41913 41914 // This API will tag the children with the side-effect of the reconciliation 41915 // itself. They will be added to the side-effect list as we pass through the 41916 // children and the parent. 41917 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) { 41918 // This function is not recursive. 41919 // If the top level item is an array, we treat it as a set of children, 41920 // not as a fragment. Nested arrays on the other hand will be treated as 41921 // fragment nodes. Recursion happens at the normal flow. 41922 41923 // Handle top level unkeyed fragments as if they were arrays. 41924 // This leads to an ambiguity between <>{[...]}</> and <>...</>. 41925 // We treat the ambiguous cases above the same. 41926 var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null; 41927 if (isUnkeyedTopLevelFragment) { 41928 newChild = newChild.props.children; 41929 } 41930 41931 // Handle object types 41932 var isObject = typeof newChild === 'object' && newChild !== null; 41933 41934 if (isObject) { 41935 switch (newChild.$$typeof) { 41936 case REACT_ELEMENT_TYPE: 41937 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime)); 41938 case REACT_PORTAL_TYPE: 41939 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime)); 41940 } 41941 } 41942 41943 if (typeof newChild === 'string' || typeof newChild === 'number') { 41944 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime)); 41945 } 41946 41947 if (isArray$1(newChild)) { 41948 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime); 41949 } 41950 41951 if (getIteratorFn(newChild)) { 41952 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime); 41953 } 41954 41955 if (isObject) { 41956 throwOnInvalidObjectType(returnFiber, newChild); 41957 } 41958 41959 { 41960 if (typeof newChild === 'function') { 41961 warnOnFunctionType(); 41962 } 41963 } 41964 if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) { 41965 // If the new child is undefined, and the return fiber is a composite 41966 // component, throw an error. If Fiber return types are disabled, 41967 // we already threw above. 41968 switch (returnFiber.tag) { 41969 case ClassComponent: 41970 { 41971 { 41972 var instance = returnFiber.stateNode; 41973 if (instance.render._isMockFunction) { 41974 // We allow auto-mocks to proceed as if they're returning null. 41975 break; 41976 } 41977 } 41978 } 41979 // Intentionally fall through to the next case, which handles both 41980 // functions and classes 41981 // eslint-disable-next-lined no-fallthrough 41982 case FunctionalComponent: 41983 { 41984 var Component = returnFiber.type; 41985 invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component'); 41986 } 41987 } 41988 } 41989 41990 // Remaining cases are all treated as empty. 41991 return deleteRemainingChildren(returnFiber, currentFirstChild); 41992 } 41993 41994 return reconcileChildFibers; 41995} 41996 41997var reconcileChildFibers = ChildReconciler(true); 41998var mountChildFibers = ChildReconciler(false); 41999 42000function cloneChildFibers(current, workInProgress) { 42001 !(current === null || workInProgress.child === current.child) ? invariant(false, 'Resuming work not yet implemented.') : void 0; 42002 42003 if (workInProgress.child === null) { 42004 return; 42005 } 42006 42007 var currentChild = workInProgress.child; 42008 var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime); 42009 workInProgress.child = newChild; 42010 42011 newChild.return = workInProgress; 42012 while (currentChild.sibling !== null) { 42013 currentChild = currentChild.sibling; 42014 newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime); 42015 newChild.return = workInProgress; 42016 } 42017 newChild.sibling = null; 42018} 42019 42020// The deepest Fiber on the stack involved in a hydration context. 42021// This may have been an insertion or a hydration. 42022var hydrationParentFiber = null; 42023var nextHydratableInstance = null; 42024var isHydrating = false; 42025 42026function enterHydrationState(fiber) { 42027 if (!supportsHydration) { 42028 return false; 42029 } 42030 42031 var parentInstance = fiber.stateNode.containerInfo; 42032 nextHydratableInstance = getFirstHydratableChild(parentInstance); 42033 hydrationParentFiber = fiber; 42034 isHydrating = true; 42035 return true; 42036} 42037 42038function deleteHydratableInstance(returnFiber, instance) { 42039 { 42040 switch (returnFiber.tag) { 42041 case HostRoot: 42042 didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance); 42043 break; 42044 case HostComponent: 42045 didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance); 42046 break; 42047 } 42048 } 42049 42050 var childToDelete = createFiberFromHostInstanceForDeletion(); 42051 childToDelete.stateNode = instance; 42052 childToDelete.return = returnFiber; 42053 childToDelete.effectTag = Deletion; 42054 42055 // This might seem like it belongs on progressedFirstDeletion. However, 42056 // these children are not part of the reconciliation list of children. 42057 // Even if we abort and rereconcile the children, that will try to hydrate 42058 // again and the nodes are still in the host tree so these will be 42059 // recreated. 42060 if (returnFiber.lastEffect !== null) { 42061 returnFiber.lastEffect.nextEffect = childToDelete; 42062 returnFiber.lastEffect = childToDelete; 42063 } else { 42064 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; 42065 } 42066} 42067 42068function insertNonHydratedInstance(returnFiber, fiber) { 42069 fiber.effectTag |= Placement; 42070 { 42071 switch (returnFiber.tag) { 42072 case HostRoot: 42073 { 42074 var parentContainer = returnFiber.stateNode.containerInfo; 42075 switch (fiber.tag) { 42076 case HostComponent: 42077 var type = fiber.type; 42078 var props = fiber.pendingProps; 42079 didNotFindHydratableContainerInstance(parentContainer, type, props); 42080 break; 42081 case HostText: 42082 var text = fiber.pendingProps; 42083 didNotFindHydratableContainerTextInstance(parentContainer, text); 42084 break; 42085 } 42086 break; 42087 } 42088 case HostComponent: 42089 { 42090 var parentType = returnFiber.type; 42091 var parentProps = returnFiber.memoizedProps; 42092 var parentInstance = returnFiber.stateNode; 42093 switch (fiber.tag) { 42094 case HostComponent: 42095 var _type = fiber.type; 42096 var _props = fiber.pendingProps; 42097 didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props); 42098 break; 42099 case HostText: 42100 var _text = fiber.pendingProps; 42101 didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text); 42102 break; 42103 } 42104 break; 42105 } 42106 default: 42107 return; 42108 } 42109 } 42110} 42111 42112function tryHydrate(fiber, nextInstance) { 42113 switch (fiber.tag) { 42114 case HostComponent: 42115 { 42116 var type = fiber.type; 42117 var props = fiber.pendingProps; 42118 var instance = canHydrateInstance(nextInstance, type, props); 42119 if (instance !== null) { 42120 fiber.stateNode = instance; 42121 return true; 42122 } 42123 return false; 42124 } 42125 case HostText: 42126 { 42127 var text = fiber.pendingProps; 42128 var textInstance = canHydrateTextInstance(nextInstance, text); 42129 if (textInstance !== null) { 42130 fiber.stateNode = textInstance; 42131 return true; 42132 } 42133 return false; 42134 } 42135 default: 42136 return false; 42137 } 42138} 42139 42140function tryToClaimNextHydratableInstance(fiber) { 42141 if (!isHydrating) { 42142 return; 42143 } 42144 var nextInstance = nextHydratableInstance; 42145 if (!nextInstance) { 42146 // Nothing to hydrate. Make it an insertion. 42147 insertNonHydratedInstance(hydrationParentFiber, fiber); 42148 isHydrating = false; 42149 hydrationParentFiber = fiber; 42150 return; 42151 } 42152 var firstAttemptedInstance = nextInstance; 42153 if (!tryHydrate(fiber, nextInstance)) { 42154 // If we can't hydrate this instance let's try the next one. 42155 // We use this as a heuristic. It's based on intuition and not data so it 42156 // might be flawed or unnecessary. 42157 nextInstance = getNextHydratableSibling(firstAttemptedInstance); 42158 if (!nextInstance || !tryHydrate(fiber, nextInstance)) { 42159 // Nothing to hydrate. Make it an insertion. 42160 insertNonHydratedInstance(hydrationParentFiber, fiber); 42161 isHydrating = false; 42162 hydrationParentFiber = fiber; 42163 return; 42164 } 42165 // We matched the next one, we'll now assume that the first one was 42166 // superfluous and we'll delete it. Since we can't eagerly delete it 42167 // we'll have to schedule a deletion. To do that, this node needs a dummy 42168 // fiber associated with it. 42169 deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance); 42170 } 42171 hydrationParentFiber = fiber; 42172 nextHydratableInstance = getFirstHydratableChild(nextInstance); 42173} 42174 42175function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) { 42176 if (!supportsHydration) { 42177 invariant(false, 'Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.'); 42178 } 42179 42180 var instance = fiber.stateNode; 42181 var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); 42182 // TODO: Type this specific to this type of component. 42183 fiber.updateQueue = updatePayload; 42184 // If the update payload indicates that there is a change or if there 42185 // is a new ref we mark this as an update. 42186 if (updatePayload !== null) { 42187 return true; 42188 } 42189 return false; 42190} 42191 42192function prepareToHydrateHostTextInstance(fiber) { 42193 if (!supportsHydration) { 42194 invariant(false, 'Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.'); 42195 } 42196 42197 var textInstance = fiber.stateNode; 42198 var textContent = fiber.memoizedProps; 42199 var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber); 42200 { 42201 if (shouldUpdate) { 42202 // We assume that prepareToHydrateHostTextInstance is called in a context where the 42203 // hydration parent is the parent host component of this host text. 42204 var returnFiber = hydrationParentFiber; 42205 if (returnFiber !== null) { 42206 switch (returnFiber.tag) { 42207 case HostRoot: 42208 { 42209 var parentContainer = returnFiber.stateNode.containerInfo; 42210 didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent); 42211 break; 42212 } 42213 case HostComponent: 42214 { 42215 var parentType = returnFiber.type; 42216 var parentProps = returnFiber.memoizedProps; 42217 var parentInstance = returnFiber.stateNode; 42218 didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent); 42219 break; 42220 } 42221 } 42222 } 42223 } 42224 } 42225 return shouldUpdate; 42226} 42227 42228function popToNextHostParent(fiber) { 42229 var parent = fiber.return; 42230 while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot) { 42231 parent = parent.return; 42232 } 42233 hydrationParentFiber = parent; 42234} 42235 42236function popHydrationState(fiber) { 42237 if (!supportsHydration) { 42238 return false; 42239 } 42240 if (fiber !== hydrationParentFiber) { 42241 // We're deeper than the current hydration context, inside an inserted 42242 // tree. 42243 return false; 42244 } 42245 if (!isHydrating) { 42246 // If we're not currently hydrating but we're in a hydration context, then 42247 // we were an insertion and now need to pop up reenter hydration of our 42248 // siblings. 42249 popToNextHostParent(fiber); 42250 isHydrating = true; 42251 return false; 42252 } 42253 42254 var type = fiber.type; 42255 42256 // If we have any remaining hydratable nodes, we need to delete them now. 42257 // We only do this deeper than head and body since they tend to have random 42258 // other nodes in them. We also ignore components with pure text content in 42259 // side of them. 42260 // TODO: Better heuristic. 42261 if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) { 42262 var nextInstance = nextHydratableInstance; 42263 while (nextInstance) { 42264 deleteHydratableInstance(fiber, nextInstance); 42265 nextInstance = getNextHydratableSibling(nextInstance); 42266 } 42267 } 42268 42269 popToNextHostParent(fiber); 42270 nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null; 42271 return true; 42272} 42273 42274function resetHydrationState() { 42275 if (!supportsHydration) { 42276 return; 42277 } 42278 42279 hydrationParentFiber = null; 42280 nextHydratableInstance = null; 42281 isHydrating = false; 42282} 42283 42284var getCurrentFiberStackAddendum$6 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum; 42285 42286 42287var didWarnAboutBadClass = void 0; 42288var didWarnAboutGetDerivedStateOnFunctionalComponent = void 0; 42289var didWarnAboutStatelessRefs = void 0; 42290 42291{ 42292 didWarnAboutBadClass = {}; 42293 didWarnAboutGetDerivedStateOnFunctionalComponent = {}; 42294 didWarnAboutStatelessRefs = {}; 42295} 42296 42297// TODO: Remove this and use reconcileChildrenAtExpirationTime directly. 42298function reconcileChildren(current, workInProgress, nextChildren) { 42299 reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, workInProgress.expirationTime); 42300} 42301 42302function reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, renderExpirationTime) { 42303 if (current === null) { 42304 // If this is a fresh new component that hasn't been rendered yet, we 42305 // won't update its child set by applying minimal side-effects. Instead, 42306 // we will add them all to the child before it gets rendered. That means 42307 // we can optimize this reconciliation pass by not tracking side-effects. 42308 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 42309 } else { 42310 // If the current child is the same as the work in progress, it means that 42311 // we haven't yet started any work on these children. Therefore, we use 42312 // the clone algorithm to create a copy of all the current children. 42313 42314 // If we had any progressed work already, that is invalid at this point so 42315 // let's throw it out. 42316 workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderExpirationTime); 42317 } 42318} 42319 42320function updateForwardRef(current, workInProgress) { 42321 var render = workInProgress.type.render; 42322 var nextProps = workInProgress.pendingProps; 42323 var ref = workInProgress.ref; 42324 if (hasContextChanged()) { 42325 // Normally we can bail out on props equality but if context has changed 42326 // we don't do the bailout and we have to reuse existing props instead. 42327 } else if (workInProgress.memoizedProps === nextProps) { 42328 var currentRef = current !== null ? current.ref : null; 42329 if (ref === currentRef) { 42330 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42331 } 42332 } 42333 42334 var nextChildren = void 0; 42335 { 42336 ReactCurrentOwner.current = workInProgress; 42337 ReactDebugCurrentFiber.setCurrentPhase('render'); 42338 nextChildren = render(nextProps, ref); 42339 ReactDebugCurrentFiber.setCurrentPhase(null); 42340 } 42341 42342 reconcileChildren(current, workInProgress, nextChildren); 42343 memoizeProps(workInProgress, nextProps); 42344 return workInProgress.child; 42345} 42346 42347function updateFragment(current, workInProgress) { 42348 var nextChildren = workInProgress.pendingProps; 42349 if (hasContextChanged()) { 42350 // Normally we can bail out on props equality but if context has changed 42351 // we don't do the bailout and we have to reuse existing props instead. 42352 } else if (workInProgress.memoizedProps === nextChildren) { 42353 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42354 } 42355 reconcileChildren(current, workInProgress, nextChildren); 42356 memoizeProps(workInProgress, nextChildren); 42357 return workInProgress.child; 42358} 42359 42360function updateMode(current, workInProgress) { 42361 var nextChildren = workInProgress.pendingProps.children; 42362 if (hasContextChanged()) { 42363 // Normally we can bail out on props equality but if context has changed 42364 // we don't do the bailout and we have to reuse existing props instead. 42365 } else if (nextChildren === null || workInProgress.memoizedProps === nextChildren) { 42366 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42367 } 42368 reconcileChildren(current, workInProgress, nextChildren); 42369 memoizeProps(workInProgress, nextChildren); 42370 return workInProgress.child; 42371} 42372 42373function updateProfiler(current, workInProgress) { 42374 var nextProps = workInProgress.pendingProps; 42375 if (enableProfilerTimer) { 42376 workInProgress.effectTag |= Update; 42377 } 42378 if (workInProgress.memoizedProps === nextProps) { 42379 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42380 } 42381 var nextChildren = nextProps.children; 42382 reconcileChildren(current, workInProgress, nextChildren); 42383 memoizeProps(workInProgress, nextProps); 42384 return workInProgress.child; 42385} 42386 42387function markRef(current, workInProgress) { 42388 var ref = workInProgress.ref; 42389 if (current === null && ref !== null || current !== null && current.ref !== ref) { 42390 // Schedule a Ref effect 42391 workInProgress.effectTag |= Ref; 42392 } 42393} 42394 42395function updateFunctionalComponent(current, workInProgress) { 42396 var fn = workInProgress.type; 42397 var nextProps = workInProgress.pendingProps; 42398 42399 if (hasContextChanged()) { 42400 // Normally we can bail out on props equality but if context has changed 42401 // we don't do the bailout and we have to reuse existing props instead. 42402 } else { 42403 if (workInProgress.memoizedProps === nextProps) { 42404 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42405 } 42406 // TODO: consider bringing fn.shouldComponentUpdate() back. 42407 // It used to be here. 42408 } 42409 42410 var unmaskedContext = getUnmaskedContext(workInProgress); 42411 var context = getMaskedContext(workInProgress, unmaskedContext); 42412 42413 var nextChildren = void 0; 42414 42415 { 42416 ReactCurrentOwner.current = workInProgress; 42417 ReactDebugCurrentFiber.setCurrentPhase('render'); 42418 nextChildren = fn(nextProps, context); 42419 ReactDebugCurrentFiber.setCurrentPhase(null); 42420 } 42421 // React DevTools reads this flag. 42422 workInProgress.effectTag |= PerformedWork; 42423 reconcileChildren(current, workInProgress, nextChildren); 42424 memoizeProps(workInProgress, nextProps); 42425 return workInProgress.child; 42426} 42427 42428function updateClassComponent(current, workInProgress, renderExpirationTime) { 42429 // Push context providers early to prevent context stack mismatches. 42430 // During mounting we don't know the child context yet as the instance doesn't exist. 42431 // We will invalidate the child context in finishClassComponent() right after rendering. 42432 var hasContext = pushContextProvider(workInProgress); 42433 var shouldUpdate = void 0; 42434 if (current === null) { 42435 if (workInProgress.stateNode === null) { 42436 // In the initial pass we might need to construct the instance. 42437 constructClassInstance(workInProgress, workInProgress.pendingProps, renderExpirationTime); 42438 mountClassInstance(workInProgress, renderExpirationTime); 42439 42440 shouldUpdate = true; 42441 } else { 42442 // In a resume, we'll already have an instance we can reuse. 42443 shouldUpdate = resumeMountClassInstance(workInProgress, renderExpirationTime); 42444 } 42445 } else { 42446 shouldUpdate = updateClassInstance(current, workInProgress, renderExpirationTime); 42447 } 42448 return finishClassComponent(current, workInProgress, shouldUpdate, hasContext, renderExpirationTime); 42449} 42450 42451function finishClassComponent(current, workInProgress, shouldUpdate, hasContext, renderExpirationTime) { 42452 // Refs should update even if shouldComponentUpdate returns false 42453 markRef(current, workInProgress); 42454 42455 var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect; 42456 42457 if (!shouldUpdate && !didCaptureError) { 42458 // Context providers should defer to sCU for rendering 42459 if (hasContext) { 42460 invalidateContextProvider(workInProgress, false); 42461 } 42462 42463 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42464 } 42465 42466 var ctor = workInProgress.type; 42467 var instance = workInProgress.stateNode; 42468 42469 // Rerender 42470 ReactCurrentOwner.current = workInProgress; 42471 var nextChildren = void 0; 42472 if (didCaptureError && (!enableGetDerivedStateFromCatch || typeof ctor.getDerivedStateFromCatch !== 'function')) { 42473 // If we captured an error, but getDerivedStateFrom catch is not defined, 42474 // unmount all the children. componentDidCatch will schedule an update to 42475 // re-render a fallback. This is temporary until we migrate everyone to 42476 // the new API. 42477 // TODO: Warn in a future release. 42478 nextChildren = null; 42479 42480 if (enableProfilerTimer) { 42481 stopBaseRenderTimerIfRunning(); 42482 } 42483 } else { 42484 { 42485 ReactDebugCurrentFiber.setCurrentPhase('render'); 42486 nextChildren = instance.render(); 42487 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) { 42488 instance.render(); 42489 } 42490 ReactDebugCurrentFiber.setCurrentPhase(null); 42491 } 42492 } 42493 42494 // React DevTools reads this flag. 42495 workInProgress.effectTag |= PerformedWork; 42496 if (didCaptureError) { 42497 // If we're recovering from an error, reconcile twice: first to delete 42498 // all the existing children. 42499 reconcileChildrenAtExpirationTime(current, workInProgress, null, renderExpirationTime); 42500 workInProgress.child = null; 42501 // Now we can continue reconciling like normal. This has the effect of 42502 // remounting all children regardless of whether their their 42503 // identity matches. 42504 } 42505 reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, renderExpirationTime); 42506 // Memoize props and state using the values we just used to render. 42507 // TODO: Restructure so we never read values from the instance. 42508 memoizeState(workInProgress, instance.state); 42509 memoizeProps(workInProgress, instance.props); 42510 42511 // The context might have changed so we need to recalculate it. 42512 if (hasContext) { 42513 invalidateContextProvider(workInProgress, true); 42514 } 42515 42516 return workInProgress.child; 42517} 42518 42519function pushHostRootContext(workInProgress) { 42520 var root = workInProgress.stateNode; 42521 if (root.pendingContext) { 42522 pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context); 42523 } else if (root.context) { 42524 // Should always be set 42525 pushTopLevelContextObject(workInProgress, root.context, false); 42526 } 42527 pushHostContainer(workInProgress, root.containerInfo); 42528} 42529 42530function updateHostRoot(current, workInProgress, renderExpirationTime) { 42531 pushHostRootContext(workInProgress); 42532 var updateQueue = workInProgress.updateQueue; 42533 if (updateQueue !== null) { 42534 var nextProps = workInProgress.pendingProps; 42535 var prevState = workInProgress.memoizedState; 42536 var prevChildren = prevState !== null ? prevState.element : null; 42537 processUpdateQueue(workInProgress, updateQueue, nextProps, null, renderExpirationTime); 42538 var nextState = workInProgress.memoizedState; 42539 // Caution: React DevTools currently depends on this property 42540 // being called "element". 42541 var nextChildren = nextState.element; 42542 42543 if (nextChildren === prevChildren) { 42544 // If the state is the same as before, that's a bailout because we had 42545 // no work that expires at this time. 42546 resetHydrationState(); 42547 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42548 } 42549 var root = workInProgress.stateNode; 42550 if ((current === null || current.child === null) && root.hydrate && enterHydrationState(workInProgress)) { 42551 // If we don't have any current children this might be the first pass. 42552 // We always try to hydrate. If this isn't a hydration pass there won't 42553 // be any children to hydrate which is effectively the same thing as 42554 // not hydrating. 42555 42556 // This is a bit of a hack. We track the host root as a placement to 42557 // know that we're currently in a mounting state. That way isMounted 42558 // works as expected. We must reset this before committing. 42559 // TODO: Delete this when we delete isMounted and findDOMNode. 42560 workInProgress.effectTag |= Placement; 42561 42562 // Ensure that children mount into this root without tracking 42563 // side-effects. This ensures that we don't store Placement effects on 42564 // nodes that will be hydrated. 42565 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 42566 } else { 42567 // Otherwise reset hydration state in case we aborted and resumed another 42568 // root. 42569 resetHydrationState(); 42570 reconcileChildren(current, workInProgress, nextChildren); 42571 } 42572 return workInProgress.child; 42573 } 42574 resetHydrationState(); 42575 // If there is no update queue, that's a bailout because the root has no props. 42576 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42577} 42578 42579function updateHostComponent(current, workInProgress, renderExpirationTime) { 42580 pushHostContext(workInProgress); 42581 42582 if (current === null) { 42583 tryToClaimNextHydratableInstance(workInProgress); 42584 } 42585 42586 var type = workInProgress.type; 42587 var memoizedProps = workInProgress.memoizedProps; 42588 var nextProps = workInProgress.pendingProps; 42589 var prevProps = current !== null ? current.memoizedProps : null; 42590 42591 if (hasContextChanged()) { 42592 // Normally we can bail out on props equality but if context has changed 42593 // we don't do the bailout and we have to reuse existing props instead. 42594 } else if (memoizedProps === nextProps) { 42595 var isHidden = workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps); 42596 if (isHidden) { 42597 // Before bailing out, make sure we've deprioritized a hidden component. 42598 workInProgress.expirationTime = Never; 42599 } 42600 if (!isHidden || renderExpirationTime !== Never) { 42601 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42602 } 42603 // If we're rendering a hidden node at hidden priority, don't bailout. The 42604 // parent is complete, but the children may not be. 42605 } 42606 42607 var nextChildren = nextProps.children; 42608 var isDirectTextChild = shouldSetTextContent(type, nextProps); 42609 42610 if (isDirectTextChild) { 42611 // We special case a direct text child of a host node. This is a common 42612 // case. We won't handle it as a reified child. We will instead handle 42613 // this in the host environment that also have access to this prop. That 42614 // avoids allocating another HostText fiber and traversing it. 42615 nextChildren = null; 42616 } else if (prevProps && shouldSetTextContent(type, prevProps)) { 42617 // If we're switching from a direct text child to a normal child, or to 42618 // empty, we need to schedule the text content to be reset. 42619 workInProgress.effectTag |= ContentReset; 42620 } 42621 42622 markRef(current, workInProgress); 42623 42624 // Check the host config to see if the children are offscreen/hidden. 42625 if (renderExpirationTime !== Never && workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps)) { 42626 // Down-prioritize the children. 42627 workInProgress.expirationTime = Never; 42628 // Bailout and come back to this fiber later. 42629 workInProgress.memoizedProps = nextProps; 42630 return null; 42631 } 42632 42633 reconcileChildren(current, workInProgress, nextChildren); 42634 memoizeProps(workInProgress, nextProps); 42635 return workInProgress.child; 42636} 42637 42638function updateHostText(current, workInProgress) { 42639 if (current === null) { 42640 tryToClaimNextHydratableInstance(workInProgress); 42641 } 42642 var nextProps = workInProgress.pendingProps; 42643 memoizeProps(workInProgress, nextProps); 42644 // Nothing to do here. This is terminal. We'll do the completion step 42645 // immediately after. 42646 return null; 42647} 42648 42649function mountIndeterminateComponent(current, workInProgress, renderExpirationTime) { 42650 !(current === null) ? invariant(false, 'An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue.') : void 0; 42651 var fn = workInProgress.type; 42652 var props = workInProgress.pendingProps; 42653 var unmaskedContext = getUnmaskedContext(workInProgress); 42654 var context = getMaskedContext(workInProgress, unmaskedContext); 42655 42656 var value = void 0; 42657 42658 { 42659 if (fn.prototype && typeof fn.prototype.render === 'function') { 42660 var componentName = getComponentName(workInProgress) || 'Unknown'; 42661 42662 if (!didWarnAboutBadClass[componentName]) { 42663 warning(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName); 42664 didWarnAboutBadClass[componentName] = true; 42665 } 42666 } 42667 42668 if (workInProgress.mode & StrictMode) { 42669 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null); 42670 } 42671 42672 ReactCurrentOwner.current = workInProgress; 42673 value = fn(props, context); 42674 } 42675 // React DevTools reads this flag. 42676 workInProgress.effectTag |= PerformedWork; 42677 42678 if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) { 42679 var Component = workInProgress.type; 42680 42681 // Proceed under the assumption that this is a class instance 42682 workInProgress.tag = ClassComponent; 42683 42684 workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; 42685 42686 var getDerivedStateFromProps = Component.getDerivedStateFromProps; 42687 if (typeof getDerivedStateFromProps === 'function') { 42688 applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, props); 42689 } 42690 42691 // Push context providers early to prevent context stack mismatches. 42692 // During mounting we don't know the child context yet as the instance doesn't exist. 42693 // We will invalidate the child context in finishClassComponent() right after rendering. 42694 var hasContext = pushContextProvider(workInProgress); 42695 adoptClassInstance(workInProgress, value); 42696 mountClassInstance(workInProgress, renderExpirationTime); 42697 return finishClassComponent(current, workInProgress, true, hasContext, renderExpirationTime); 42698 } else { 42699 // Proceed under the assumption that this is a functional component 42700 workInProgress.tag = FunctionalComponent; 42701 { 42702 var _Component = workInProgress.type; 42703 42704 if (_Component) { 42705 !!_Component.childContextTypes ? warning(false, '%s(...): childContextTypes cannot be defined on a functional component.', _Component.displayName || _Component.name || 'Component') : void 0; 42706 } 42707 if (workInProgress.ref !== null) { 42708 var info = ''; 42709 var ownerName = ReactDebugCurrentFiber.getCurrentFiberOwnerName(); 42710 if (ownerName) { 42711 info += '\n\nCheck the render method of `' + ownerName + '`.'; 42712 } 42713 42714 var warningKey = ownerName || workInProgress._debugID || ''; 42715 var debugSource = workInProgress._debugSource; 42716 if (debugSource) { 42717 warningKey = debugSource.fileName + ':' + debugSource.lineNumber; 42718 } 42719 if (!didWarnAboutStatelessRefs[warningKey]) { 42720 didWarnAboutStatelessRefs[warningKey] = true; 42721 warning(false, 'Stateless function components cannot be given refs. ' + 'Attempts to access this ref will fail.%s%s', info, ReactDebugCurrentFiber.getCurrentFiberStackAddendum()); 42722 } 42723 } 42724 42725 if (typeof fn.getDerivedStateFromProps === 'function') { 42726 var _componentName = getComponentName(workInProgress) || 'Unknown'; 42727 42728 if (!didWarnAboutGetDerivedStateOnFunctionalComponent[_componentName]) { 42729 warning(false, '%s: Stateless functional components do not support getDerivedStateFromProps.', _componentName); 42730 didWarnAboutGetDerivedStateOnFunctionalComponent[_componentName] = true; 42731 } 42732 } 42733 } 42734 reconcileChildren(current, workInProgress, value); 42735 memoizeProps(workInProgress, props); 42736 return workInProgress.child; 42737 } 42738} 42739 42740function updateTimeoutComponent(current, workInProgress, renderExpirationTime) { 42741 if (enableSuspense) { 42742 var nextProps = workInProgress.pendingProps; 42743 var prevProps = workInProgress.memoizedProps; 42744 42745 var prevDidTimeout = workInProgress.memoizedState; 42746 42747 // Check if we already attempted to render the normal state. If we did, 42748 // and we timed out, render the placeholder state. 42749 var alreadyCaptured = (workInProgress.effectTag & DidCapture) === NoEffect; 42750 var nextDidTimeout = !alreadyCaptured; 42751 42752 if (hasContextChanged()) { 42753 // Normally we can bail out on props equality but if context has changed 42754 // we don't do the bailout and we have to reuse existing props instead. 42755 } else if (nextProps === prevProps && nextDidTimeout === prevDidTimeout) { 42756 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42757 } 42758 42759 var render = nextProps.children; 42760 var nextChildren = render(nextDidTimeout); 42761 workInProgress.memoizedProps = nextProps; 42762 workInProgress.memoizedState = nextDidTimeout; 42763 reconcileChildren(current, workInProgress, nextChildren); 42764 return workInProgress.child; 42765 } else { 42766 return null; 42767 } 42768} 42769 42770function updatePortalComponent(current, workInProgress, renderExpirationTime) { 42771 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); 42772 var nextChildren = workInProgress.pendingProps; 42773 if (hasContextChanged()) { 42774 // Normally we can bail out on props equality but if context has changed 42775 // we don't do the bailout and we have to reuse existing props instead. 42776 } else if (workInProgress.memoizedProps === nextChildren) { 42777 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42778 } 42779 42780 if (current === null) { 42781 // Portals are special because we don't append the children during mount 42782 // but at commit. Therefore we need to track insertions which the normal 42783 // flow doesn't do during mount. This doesn't happen at the root because 42784 // the root always starts with a "current" with a null child. 42785 // TODO: Consider unifying this with how the root works. 42786 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 42787 memoizeProps(workInProgress, nextChildren); 42788 } else { 42789 reconcileChildren(current, workInProgress, nextChildren); 42790 memoizeProps(workInProgress, nextChildren); 42791 } 42792 return workInProgress.child; 42793} 42794 42795function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) { 42796 var fiber = workInProgress.child; 42797 if (fiber !== null) { 42798 // Set the return pointer of the child to the work-in-progress fiber. 42799 fiber.return = workInProgress; 42800 } 42801 while (fiber !== null) { 42802 var nextFiber = void 0; 42803 // Visit this fiber. 42804 switch (fiber.tag) { 42805 case ContextConsumer: 42806 // Check if the context matches. 42807 var observedBits = fiber.stateNode | 0; 42808 if (fiber.type === context && (observedBits & changedBits) !== 0) { 42809 // Update the expiration time of all the ancestors, including 42810 // the alternates. 42811 var node = fiber; 42812 while (node !== null) { 42813 var alternate = node.alternate; 42814 if (node.expirationTime === NoWork || node.expirationTime > renderExpirationTime) { 42815 node.expirationTime = renderExpirationTime; 42816 if (alternate !== null && (alternate.expirationTime === NoWork || alternate.expirationTime > renderExpirationTime)) { 42817 alternate.expirationTime = renderExpirationTime; 42818 } 42819 } else if (alternate !== null && (alternate.expirationTime === NoWork || alternate.expirationTime > renderExpirationTime)) { 42820 alternate.expirationTime = renderExpirationTime; 42821 } else { 42822 // Neither alternate was updated, which means the rest of the 42823 // ancestor path already has sufficient priority. 42824 break; 42825 } 42826 node = node.return; 42827 } 42828 // Don't scan deeper than a matching consumer. When we render the 42829 // consumer, we'll continue scanning from that point. This way the 42830 // scanning work is time-sliced. 42831 nextFiber = null; 42832 } else { 42833 // Traverse down. 42834 nextFiber = fiber.child; 42835 } 42836 break; 42837 case ContextProvider: 42838 // Don't scan deeper if this is a matching provider 42839 nextFiber = fiber.type === workInProgress.type ? null : fiber.child; 42840 break; 42841 default: 42842 // Traverse down. 42843 nextFiber = fiber.child; 42844 break; 42845 } 42846 if (nextFiber !== null) { 42847 // Set the return pointer of the child to the work-in-progress fiber. 42848 nextFiber.return = fiber; 42849 } else { 42850 // No child. Traverse to next sibling. 42851 nextFiber = fiber; 42852 while (nextFiber !== null) { 42853 if (nextFiber === workInProgress) { 42854 // We're back to the root of this subtree. Exit. 42855 nextFiber = null; 42856 break; 42857 } 42858 var sibling = nextFiber.sibling; 42859 if (sibling !== null) { 42860 // Set the return pointer of the sibling to the work-in-progress fiber. 42861 sibling.return = nextFiber.return; 42862 nextFiber = sibling; 42863 break; 42864 } 42865 // No more siblings. Traverse up. 42866 nextFiber = nextFiber.return; 42867 } 42868 } 42869 fiber = nextFiber; 42870 } 42871} 42872 42873function updateContextProvider(current, workInProgress, renderExpirationTime) { 42874 var providerType = workInProgress.type; 42875 var context = providerType._context; 42876 42877 var newProps = workInProgress.pendingProps; 42878 var oldProps = workInProgress.memoizedProps; 42879 var canBailOnProps = true; 42880 42881 if (hasContextChanged()) { 42882 canBailOnProps = false; 42883 // Normally we can bail out on props equality but if context has changed 42884 // we don't do the bailout and we have to reuse existing props instead. 42885 } else if (oldProps === newProps) { 42886 workInProgress.stateNode = 0; 42887 pushProvider(workInProgress); 42888 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42889 } 42890 42891 var newValue = newProps.value; 42892 workInProgress.memoizedProps = newProps; 42893 42894 { 42895 var providerPropTypes = workInProgress.type.propTypes; 42896 42897 if (providerPropTypes) { 42898 checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackAddendum$6); 42899 } 42900 } 42901 42902 var changedBits = void 0; 42903 if (oldProps === null) { 42904 // Initial render 42905 changedBits = MAX_SIGNED_31_BIT_INT; 42906 } else { 42907 if (oldProps.value === newProps.value) { 42908 // No change. Bailout early if children are the same. 42909 if (oldProps.children === newProps.children && canBailOnProps) { 42910 workInProgress.stateNode = 0; 42911 pushProvider(workInProgress); 42912 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42913 } 42914 changedBits = 0; 42915 } else { 42916 var oldValue = oldProps.value; 42917 // Use Object.is to compare the new context value to the old value. 42918 // Inlined Object.is polyfill. 42919 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is 42920 if (oldValue === newValue && (oldValue !== 0 || 1 / oldValue === 1 / newValue) || oldValue !== oldValue && newValue !== newValue // eslint-disable-line no-self-compare 42921 ) { 42922 // No change. Bailout early if children are the same. 42923 if (oldProps.children === newProps.children && canBailOnProps) { 42924 workInProgress.stateNode = 0; 42925 pushProvider(workInProgress); 42926 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42927 } 42928 changedBits = 0; 42929 } else { 42930 changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT; 42931 { 42932 !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) ? warning(false, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits) : void 0; 42933 } 42934 changedBits |= 0; 42935 42936 if (changedBits === 0) { 42937 // No change. Bailout early if children are the same. 42938 if (oldProps.children === newProps.children && canBailOnProps) { 42939 workInProgress.stateNode = 0; 42940 pushProvider(workInProgress); 42941 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42942 } 42943 } else { 42944 propagateContextChange(workInProgress, context, changedBits, renderExpirationTime); 42945 } 42946 } 42947 } 42948 } 42949 42950 workInProgress.stateNode = changedBits; 42951 pushProvider(workInProgress); 42952 42953 var newChildren = newProps.children; 42954 reconcileChildren(current, workInProgress, newChildren); 42955 return workInProgress.child; 42956} 42957 42958function updateContextConsumer(current, workInProgress, renderExpirationTime) { 42959 var context = workInProgress.type; 42960 var newProps = workInProgress.pendingProps; 42961 var oldProps = workInProgress.memoizedProps; 42962 42963 var newValue = getContextCurrentValue(context); 42964 var changedBits = getContextChangedBits(context); 42965 42966 if (hasContextChanged()) { 42967 // Normally we can bail out on props equality but if context has changed 42968 // we don't do the bailout and we have to reuse existing props instead. 42969 } else if (changedBits === 0 && oldProps === newProps) { 42970 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42971 } 42972 workInProgress.memoizedProps = newProps; 42973 42974 var observedBits = newProps.unstable_observedBits; 42975 if (observedBits === undefined || observedBits === null) { 42976 // Subscribe to all changes by default 42977 observedBits = MAX_SIGNED_31_BIT_INT; 42978 } 42979 // Store the observedBits on the fiber's stateNode for quick access. 42980 workInProgress.stateNode = observedBits; 42981 42982 if ((changedBits & observedBits) !== 0) { 42983 // Context change propagation stops at matching consumers, for time- 42984 // slicing. Continue the propagation here. 42985 propagateContextChange(workInProgress, context, changedBits, renderExpirationTime); 42986 } else if (oldProps === newProps) { 42987 // Skip over a memoized parent with a bitmask bailout even 42988 // if we began working on it because of a deeper matching child. 42989 return bailoutOnAlreadyFinishedWork(current, workInProgress); 42990 } 42991 // There is no bailout on `children` equality because we expect people 42992 // to often pass a bound method as a child, but it may reference 42993 // `this.state` or `this.props` (and thus needs to re-render on `setState`). 42994 42995 var render = newProps.children; 42996 42997 { 42998 !(typeof render === 'function') ? warning(false, 'A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.') : void 0; 42999 } 43000 43001 var newChildren = void 0; 43002 { 43003 ReactCurrentOwner.current = workInProgress; 43004 ReactDebugCurrentFiber.setCurrentPhase('render'); 43005 newChildren = render(newValue); 43006 ReactDebugCurrentFiber.setCurrentPhase(null); 43007 } 43008 43009 // React DevTools reads this flag. 43010 workInProgress.effectTag |= PerformedWork; 43011 reconcileChildren(current, workInProgress, newChildren); 43012 return workInProgress.child; 43013} 43014 43015/* 43016 function reuseChildrenEffects(returnFiber : Fiber, firstChild : Fiber) { 43017 let child = firstChild; 43018 do { 43019 // Ensure that the first and last effect of the parent corresponds 43020 // to the children's first and last effect. 43021 if (!returnFiber.firstEffect) { 43022 returnFiber.firstEffect = child.firstEffect; 43023 } 43024 if (child.lastEffect) { 43025 if (returnFiber.lastEffect) { 43026 returnFiber.lastEffect.nextEffect = child.firstEffect; 43027 } 43028 returnFiber.lastEffect = child.lastEffect; 43029 } 43030 } while (child = child.sibling); 43031 } 43032 */ 43033 43034function bailoutOnAlreadyFinishedWork(current, workInProgress) { 43035 cancelWorkTimer(workInProgress); 43036 43037 if (enableProfilerTimer) { 43038 // Don't update "base" render times for bailouts. 43039 stopBaseRenderTimerIfRunning(); 43040 } 43041 43042 // TODO: We should ideally be able to bail out early if the children have no 43043 // more work to do. However, since we don't have a separation of this 43044 // Fiber's priority and its children yet - we don't know without doing lots 43045 // of the same work we do anyway. Once we have that separation we can just 43046 // bail out here if the children has no more work at this priority level. 43047 // if (workInProgress.priorityOfChildren <= priorityLevel) { 43048 // // If there are side-effects in these children that have not yet been 43049 // // committed we need to ensure that they get properly transferred up. 43050 // if (current && current.child !== workInProgress.child) { 43051 // reuseChildrenEffects(workInProgress, child); 43052 // } 43053 // return null; 43054 // } 43055 43056 cloneChildFibers(current, workInProgress); 43057 return workInProgress.child; 43058} 43059 43060function bailoutOnLowPriority(current, workInProgress) { 43061 cancelWorkTimer(workInProgress); 43062 43063 if (enableProfilerTimer) { 43064 // Don't update "base" render times for bailouts. 43065 stopBaseRenderTimerIfRunning(); 43066 } 43067 43068 // TODO: Handle HostComponent tags here as well and call pushHostContext()? 43069 // See PR 8590 discussion for context 43070 switch (workInProgress.tag) { 43071 case HostRoot: 43072 pushHostRootContext(workInProgress); 43073 break; 43074 case ClassComponent: 43075 pushContextProvider(workInProgress); 43076 break; 43077 case HostPortal: 43078 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); 43079 break; 43080 case ContextProvider: 43081 pushProvider(workInProgress); 43082 break; 43083 } 43084 // TODO: What if this is currently in progress? 43085 // How can that happen? How is this not being cloned? 43086 return null; 43087} 43088 43089// TODO: Delete memoizeProps/State and move to reconcile/bailout instead 43090function memoizeProps(workInProgress, nextProps) { 43091 workInProgress.memoizedProps = nextProps; 43092} 43093 43094function memoizeState(workInProgress, nextState) { 43095 workInProgress.memoizedState = nextState; 43096 // Don't reset the updateQueue, in case there are pending updates. Resetting 43097 // is handled by processUpdateQueue. 43098} 43099 43100function beginWork(current, workInProgress, renderExpirationTime) { 43101 if (enableProfilerTimer) { 43102 if (workInProgress.mode & ProfileMode) { 43103 markActualRenderTimeStarted(workInProgress); 43104 } 43105 } 43106 43107 if (workInProgress.expirationTime === NoWork || workInProgress.expirationTime > renderExpirationTime) { 43108 return bailoutOnLowPriority(current, workInProgress); 43109 } 43110 43111 switch (workInProgress.tag) { 43112 case IndeterminateComponent: 43113 return mountIndeterminateComponent(current, workInProgress, renderExpirationTime); 43114 case FunctionalComponent: 43115 return updateFunctionalComponent(current, workInProgress); 43116 case ClassComponent: 43117 return updateClassComponent(current, workInProgress, renderExpirationTime); 43118 case HostRoot: 43119 return updateHostRoot(current, workInProgress, renderExpirationTime); 43120 case HostComponent: 43121 return updateHostComponent(current, workInProgress, renderExpirationTime); 43122 case HostText: 43123 return updateHostText(current, workInProgress); 43124 case TimeoutComponent: 43125 return updateTimeoutComponent(current, workInProgress, renderExpirationTime); 43126 case HostPortal: 43127 return updatePortalComponent(current, workInProgress, renderExpirationTime); 43128 case ForwardRef: 43129 return updateForwardRef(current, workInProgress); 43130 case Fragment: 43131 return updateFragment(current, workInProgress); 43132 case Mode: 43133 return updateMode(current, workInProgress); 43134 case Profiler: 43135 return updateProfiler(current, workInProgress); 43136 case ContextProvider: 43137 return updateContextProvider(current, workInProgress, renderExpirationTime); 43138 case ContextConsumer: 43139 return updateContextConsumer(current, workInProgress, renderExpirationTime); 43140 default: 43141 invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.'); 43142 } 43143} 43144 43145function markUpdate(workInProgress) { 43146 // Tag the fiber with an update effect. This turns a Placement into 43147 // a PlacementAndUpdate. 43148 workInProgress.effectTag |= Update; 43149} 43150 43151function markRef$1(workInProgress) { 43152 workInProgress.effectTag |= Ref; 43153} 43154 43155function appendAllChildren(parent, workInProgress) { 43156 // We only have the top Fiber that was created but we need recurse down its 43157 // children to find all the terminal nodes. 43158 var node = workInProgress.child; 43159 while (node !== null) { 43160 if (node.tag === HostComponent || node.tag === HostText) { 43161 appendInitialChild(parent, node.stateNode); 43162 } else if (node.tag === HostPortal) { 43163 // If we have a portal child, then we don't want to traverse 43164 // down its children. Instead, we'll get insertions from each child in 43165 // the portal directly. 43166 } else if (node.child !== null) { 43167 node.child.return = node; 43168 node = node.child; 43169 continue; 43170 } 43171 if (node === workInProgress) { 43172 return; 43173 } 43174 while (node.sibling === null) { 43175 if (node.return === null || node.return === workInProgress) { 43176 return; 43177 } 43178 node = node.return; 43179 } 43180 node.sibling.return = node.return; 43181 node = node.sibling; 43182 } 43183} 43184 43185var updateHostContainer = void 0; 43186var updateHostComponent$1 = void 0; 43187var updateHostText$1 = void 0; 43188if (supportsMutation) { 43189 // Mutation mode 43190 43191 updateHostContainer = function (workInProgress) { 43192 // Noop 43193 }; 43194 updateHostComponent$1 = function (current, workInProgress, updatePayload, type, oldProps, newProps, rootContainerInstance, currentHostContext) { 43195 // TODO: Type this specific to this type of component. 43196 workInProgress.updateQueue = updatePayload; 43197 // If the update payload indicates that there is a change or if there 43198 // is a new ref we mark this as an update. All the work is done in commitWork. 43199 if (updatePayload) { 43200 markUpdate(workInProgress); 43201 } 43202 }; 43203 updateHostText$1 = function (current, workInProgress, oldText, newText) { 43204 // If the text differs, mark it as an update. All the work in done in commitWork. 43205 if (oldText !== newText) { 43206 markUpdate(workInProgress); 43207 } 43208 }; 43209} else if (supportsPersistence) { 43210 // Persistent host tree mode 43211 43212 // An unfortunate fork of appendAllChildren because we have two different parent types. 43213 var appendAllChildrenToContainer = function (containerChildSet, workInProgress) { 43214 // We only have the top Fiber that was created but we need recurse down its 43215 // children to find all the terminal nodes. 43216 var node = workInProgress.child; 43217 while (node !== null) { 43218 if (node.tag === HostComponent || node.tag === HostText) { 43219 appendChildToContainerChildSet(containerChildSet, node.stateNode); 43220 } else if (node.tag === HostPortal) { 43221 // If we have a portal child, then we don't want to traverse 43222 // down its children. Instead, we'll get insertions from each child in 43223 // the portal directly. 43224 } else if (node.child !== null) { 43225 node.child.return = node; 43226 node = node.child; 43227 continue; 43228 } 43229 if (node === workInProgress) { 43230 return; 43231 } 43232 while (node.sibling === null) { 43233 if (node.return === null || node.return === workInProgress) { 43234 return; 43235 } 43236 node = node.return; 43237 } 43238 node.sibling.return = node.return; 43239 node = node.sibling; 43240 } 43241 }; 43242 updateHostContainer = function (workInProgress) { 43243 var portalOrRoot = workInProgress.stateNode; 43244 var childrenUnchanged = workInProgress.firstEffect === null; 43245 if (childrenUnchanged) { 43246 // No changes, just reuse the existing instance. 43247 } else { 43248 var container = portalOrRoot.containerInfo; 43249 var newChildSet = createContainerChildSet(container); 43250 // If children might have changed, we have to add them all to the set. 43251 appendAllChildrenToContainer(newChildSet, workInProgress); 43252 portalOrRoot.pendingChildren = newChildSet; 43253 // Schedule an update on the container to swap out the container. 43254 markUpdate(workInProgress); 43255 finalizeContainerChildren(container, newChildSet); 43256 } 43257 }; 43258 updateHostComponent$1 = function (current, workInProgress, updatePayload, type, oldProps, newProps, rootContainerInstance, currentHostContext) { 43259 // If there are no effects associated with this node, then none of our children had any updates. 43260 // This guarantees that we can reuse all of them. 43261 var childrenUnchanged = workInProgress.firstEffect === null; 43262 var currentInstance = current.stateNode; 43263 if (childrenUnchanged && updatePayload === null) { 43264 // No changes, just reuse the existing instance. 43265 // Note that this might release a previous clone. 43266 workInProgress.stateNode = currentInstance; 43267 } else { 43268 var recyclableInstance = workInProgress.stateNode; 43269 var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance); 43270 if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance, currentHostContext)) { 43271 markUpdate(workInProgress); 43272 } 43273 workInProgress.stateNode = newInstance; 43274 if (childrenUnchanged) { 43275 // If there are no other effects in this tree, we need to flag this node as having one. 43276 // Even though we're not going to use it for anything. 43277 // Otherwise parents won't know that there are new children to propagate upwards. 43278 markUpdate(workInProgress); 43279 } else { 43280 // If children might have changed, we have to add them all to the set. 43281 appendAllChildren(newInstance, workInProgress); 43282 } 43283 } 43284 }; 43285 updateHostText$1 = function (current, workInProgress, oldText, newText) { 43286 if (oldText !== newText) { 43287 // If the text content differs, we'll create a new text instance for it. 43288 var rootContainerInstance = getRootHostContainer(); 43289 var currentHostContext = getHostContext(); 43290 workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress); 43291 // We'll have to mark it as having an effect, even though we won't use the effect for anything. 43292 // This lets the parents know that at least one of their children has changed. 43293 markUpdate(workInProgress); 43294 } 43295 }; 43296} else { 43297 // No host operations 43298 updateHostContainer = function (workInProgress) { 43299 // Noop 43300 }; 43301 updateHostComponent$1 = function (current, workInProgress, updatePayload, type, oldProps, newProps, rootContainerInstance, currentHostContext) { 43302 // Noop 43303 }; 43304 updateHostText$1 = function (current, workInProgress, oldText, newText) { 43305 // Noop 43306 }; 43307} 43308 43309function completeWork(current, workInProgress, renderExpirationTime) { 43310 var newProps = workInProgress.pendingProps; 43311 43312 if (enableProfilerTimer) { 43313 if (workInProgress.mode & ProfileMode) { 43314 recordElapsedActualRenderTime(workInProgress); 43315 } 43316 } 43317 43318 switch (workInProgress.tag) { 43319 case FunctionalComponent: 43320 return null; 43321 case ClassComponent: 43322 { 43323 // We are leaving this subtree, so pop context if any. 43324 popContextProvider(workInProgress); 43325 return null; 43326 } 43327 case HostRoot: 43328 { 43329 popHostContainer(workInProgress); 43330 popTopLevelContextObject(workInProgress); 43331 var fiberRoot = workInProgress.stateNode; 43332 if (fiberRoot.pendingContext) { 43333 fiberRoot.context = fiberRoot.pendingContext; 43334 fiberRoot.pendingContext = null; 43335 } 43336 if (current === null || current.child === null) { 43337 // If we hydrated, pop so that we can delete any remaining children 43338 // that weren't hydrated. 43339 popHydrationState(workInProgress); 43340 // This resets the hacky state to fix isMounted before committing. 43341 // TODO: Delete this when we delete isMounted and findDOMNode. 43342 workInProgress.effectTag &= ~Placement; 43343 } 43344 updateHostContainer(workInProgress); 43345 return null; 43346 } 43347 case HostComponent: 43348 { 43349 popHostContext(workInProgress); 43350 var rootContainerInstance = getRootHostContainer(); 43351 var type = workInProgress.type; 43352 if (current !== null && workInProgress.stateNode != null) { 43353 // If we have an alternate, that means this is an update and we need to 43354 // schedule a side-effect to do the updates. 43355 var oldProps = current.memoizedProps; 43356 // If we get updated because one of our children updated, we don't 43357 // have newProps so we'll have to reuse them. 43358 // TODO: Split the update API as separate for the props vs. children. 43359 // Even better would be if children weren't special cased at all tho. 43360 var instance = workInProgress.stateNode; 43361 var currentHostContext = getHostContext(); 43362 // TODO: Experiencing an error where oldProps is null. Suggests a host 43363 // component is hitting the resume path. Figure out why. Possibly 43364 // related to `hidden`. 43365 var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); 43366 43367 updateHostComponent$1(current, workInProgress, updatePayload, type, oldProps, newProps, rootContainerInstance, currentHostContext); 43368 43369 if (current.ref !== workInProgress.ref) { 43370 markRef$1(workInProgress); 43371 } 43372 } else { 43373 if (!newProps) { 43374 !(workInProgress.stateNode !== null) ? invariant(false, 'We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.') : void 0; 43375 // This can happen when we abort work. 43376 return null; 43377 } 43378 43379 var _currentHostContext = getHostContext(); 43380 // TODO: Move createInstance to beginWork and keep it on a context 43381 // "stack" as the parent. Then append children as we go in beginWork 43382 // or completeWork depending on we want to add then top->down or 43383 // bottom->up. Top->down is faster in IE11. 43384 var wasHydrated = popHydrationState(workInProgress); 43385 if (wasHydrated) { 43386 // TODO: Move this and createInstance step into the beginPhase 43387 // to consolidate. 43388 if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, _currentHostContext)) { 43389 // If changes to the hydrated node needs to be applied at the 43390 // commit-phase we mark this as such. 43391 markUpdate(workInProgress); 43392 } 43393 } else { 43394 var _instance = createInstance(type, newProps, rootContainerInstance, _currentHostContext, workInProgress); 43395 43396 appendAllChildren(_instance, workInProgress); 43397 43398 // Certain renderers require commit-time effects for initial mount. 43399 // (eg DOM renderer supports auto-focus for certain elements). 43400 // Make sure such renderers get scheduled for later work. 43401 if (finalizeInitialChildren(_instance, type, newProps, rootContainerInstance, _currentHostContext)) { 43402 markUpdate(workInProgress); 43403 } 43404 workInProgress.stateNode = _instance; 43405 } 43406 43407 if (workInProgress.ref !== null) { 43408 // If there is a ref on a host node we need to schedule a callback 43409 markRef$1(workInProgress); 43410 } 43411 } 43412 return null; 43413 } 43414 case HostText: 43415 { 43416 var newText = newProps; 43417 if (current && workInProgress.stateNode != null) { 43418 var oldText = current.memoizedProps; 43419 // If we have an alternate, that means this is an update and we need 43420 // to schedule a side-effect to do the updates. 43421 updateHostText$1(current, workInProgress, oldText, newText); 43422 } else { 43423 if (typeof newText !== 'string') { 43424 !(workInProgress.stateNode !== null) ? invariant(false, 'We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.') : void 0; 43425 // This can happen when we abort work. 43426 return null; 43427 } 43428 var _rootContainerInstance = getRootHostContainer(); 43429 var _currentHostContext2 = getHostContext(); 43430 var _wasHydrated = popHydrationState(workInProgress); 43431 if (_wasHydrated) { 43432 if (prepareToHydrateHostTextInstance(workInProgress)) { 43433 markUpdate(workInProgress); 43434 } 43435 } else { 43436 workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext2, workInProgress); 43437 } 43438 } 43439 return null; 43440 } 43441 case ForwardRef: 43442 return null; 43443 case TimeoutComponent: 43444 return null; 43445 case Fragment: 43446 return null; 43447 case Mode: 43448 return null; 43449 case Profiler: 43450 return null; 43451 case HostPortal: 43452 popHostContainer(workInProgress); 43453 updateHostContainer(workInProgress); 43454 return null; 43455 case ContextProvider: 43456 // Pop provider fiber 43457 popProvider(workInProgress); 43458 return null; 43459 case ContextConsumer: 43460 return null; 43461 // Error cases 43462 case IndeterminateComponent: 43463 invariant(false, 'An indeterminate component should have become determinate before completing. This error is likely caused by a bug in React. Please file an issue.'); 43464 // eslint-disable-next-line no-fallthrough 43465 default: 43466 invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.'); 43467 } 43468} 43469 43470// This module is forked in different environments. 43471// By default, return `true` to log errors to the console. 43472// Forks can return `false` if this isn't desirable. 43473function showErrorDialog(capturedError) { 43474 return true; 43475} 43476 43477function logCapturedError(capturedError) { 43478 var logError = showErrorDialog(capturedError); 43479 43480 // Allow injected showErrorDialog() to prevent default console.error logging. 43481 // This enables renderers like ReactNative to better manage redbox behavior. 43482 if (logError === false) { 43483 return; 43484 } 43485 43486 var error = capturedError.error; 43487 var suppressLogging = error && error.suppressReactErrorLogging; 43488 if (suppressLogging) { 43489 return; 43490 } 43491 43492 { 43493 var componentName = capturedError.componentName, 43494 componentStack = capturedError.componentStack, 43495 errorBoundaryName = capturedError.errorBoundaryName, 43496 errorBoundaryFound = capturedError.errorBoundaryFound, 43497 willRetry = capturedError.willRetry; 43498 43499 43500 var componentNameMessage = componentName ? 'The above error occurred in the <' + componentName + '> component:' : 'The above error occurred in one of your React components:'; 43501 43502 var errorBoundaryMessage = void 0; 43503 // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow. 43504 if (errorBoundaryFound && errorBoundaryName) { 43505 if (willRetry) { 43506 errorBoundaryMessage = 'React will try to recreate this component tree from scratch ' + ('using the error boundary you provided, ' + errorBoundaryName + '.'); 43507 } else { 43508 errorBoundaryMessage = 'This error was initially handled by the error boundary ' + errorBoundaryName + '.\n' + 'Recreating the tree from scratch failed so React will unmount the tree.'; 43509 } 43510 } else { 43511 errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://fb.me/react-error-boundaries to learn more about error boundaries.'; 43512 } 43513 var combinedMessage = '' + componentNameMessage + componentStack + '\n\n' + ('' + errorBoundaryMessage); 43514 43515 // In development, we provide our own message with just the component stack. 43516 // We don't include the original error message and JS stack because the browser 43517 // has already printed it. Even if the application swallows the error, it is still 43518 // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. 43519 console.error(combinedMessage); 43520 } 43521} 43522 43523var invokeGuardedCallback$3 = ReactErrorUtils.invokeGuardedCallback; 43524var hasCaughtError$1 = ReactErrorUtils.hasCaughtError; 43525var clearCaughtError$1 = ReactErrorUtils.clearCaughtError; 43526 43527 43528var didWarnAboutUndefinedSnapshotBeforeUpdate = null; 43529{ 43530 didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); 43531} 43532 43533function logError(boundary, errorInfo) { 43534 var source = errorInfo.source; 43535 var stack = errorInfo.stack; 43536 if (stack === null && source !== null) { 43537 stack = getStackAddendumByWorkInProgressFiber(source); 43538 } 43539 43540 var capturedError = { 43541 componentName: source !== null ? getComponentName(source) : null, 43542 componentStack: stack !== null ? stack : '', 43543 error: errorInfo.value, 43544 errorBoundary: null, 43545 errorBoundaryName: null, 43546 errorBoundaryFound: false, 43547 willRetry: false 43548 }; 43549 43550 if (boundary !== null && boundary.tag === ClassComponent) { 43551 capturedError.errorBoundary = boundary.stateNode; 43552 capturedError.errorBoundaryName = getComponentName(boundary); 43553 capturedError.errorBoundaryFound = true; 43554 capturedError.willRetry = true; 43555 } 43556 43557 try { 43558 logCapturedError(capturedError); 43559 } catch (e) { 43560 // Prevent cycle if logCapturedError() throws. 43561 // A cycle may still occur if logCapturedError renders a component that throws. 43562 var suppressLogging = e && e.suppressReactErrorLogging; 43563 if (!suppressLogging) { 43564 console.error(e); 43565 } 43566 } 43567} 43568 43569var callComponentWillUnmountWithTimer = function (current, instance) { 43570 startPhaseTimer(current, 'componentWillUnmount'); 43571 instance.props = current.memoizedProps; 43572 instance.state = current.memoizedState; 43573 instance.componentWillUnmount(); 43574 stopPhaseTimer(); 43575}; 43576 43577// Capture errors so they don't interrupt unmounting. 43578function safelyCallComponentWillUnmount(current, instance) { 43579 { 43580 invokeGuardedCallback$3(null, callComponentWillUnmountWithTimer, null, current, instance); 43581 if (hasCaughtError$1()) { 43582 var unmountError = clearCaughtError$1(); 43583 captureCommitPhaseError(current, unmountError); 43584 } 43585 } 43586} 43587 43588function safelyDetachRef(current) { 43589 var ref = current.ref; 43590 if (ref !== null) { 43591 if (typeof ref === 'function') { 43592 { 43593 invokeGuardedCallback$3(null, ref, null, null); 43594 if (hasCaughtError$1()) { 43595 var refError = clearCaughtError$1(); 43596 captureCommitPhaseError(current, refError); 43597 } 43598 } 43599 } else { 43600 ref.current = null; 43601 } 43602 } 43603} 43604 43605function commitBeforeMutationLifeCycles(current, finishedWork) { 43606 switch (finishedWork.tag) { 43607 case ClassComponent: 43608 { 43609 if (finishedWork.effectTag & Snapshot) { 43610 if (current !== null) { 43611 var prevProps = current.memoizedProps; 43612 var prevState = current.memoizedState; 43613 startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate'); 43614 var instance = finishedWork.stateNode; 43615 instance.props = finishedWork.memoizedProps; 43616 instance.state = finishedWork.memoizedState; 43617 var snapshot = instance.getSnapshotBeforeUpdate(prevProps, prevState); 43618 { 43619 var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate; 43620 if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { 43621 didWarnSet.add(finishedWork.type); 43622 warning(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork)); 43623 } 43624 } 43625 instance.__reactInternalSnapshotBeforeUpdate = snapshot; 43626 stopPhaseTimer(); 43627 } 43628 } 43629 return; 43630 } 43631 case HostRoot: 43632 case HostComponent: 43633 case HostText: 43634 case HostPortal: 43635 // Nothing to do for these component types 43636 return; 43637 default: 43638 { 43639 invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.'); 43640 } 43641 } 43642} 43643 43644function commitLifeCycles(finishedRoot, current, finishedWork, currentTime, committedExpirationTime) { 43645 switch (finishedWork.tag) { 43646 case ClassComponent: 43647 { 43648 var instance = finishedWork.stateNode; 43649 if (finishedWork.effectTag & Update) { 43650 if (current === null) { 43651 startPhaseTimer(finishedWork, 'componentDidMount'); 43652 instance.props = finishedWork.memoizedProps; 43653 instance.state = finishedWork.memoizedState; 43654 instance.componentDidMount(); 43655 stopPhaseTimer(); 43656 } else { 43657 var prevProps = current.memoizedProps; 43658 var prevState = current.memoizedState; 43659 startPhaseTimer(finishedWork, 'componentDidUpdate'); 43660 instance.props = finishedWork.memoizedProps; 43661 instance.state = finishedWork.memoizedState; 43662 instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate); 43663 stopPhaseTimer(); 43664 } 43665 } 43666 var updateQueue = finishedWork.updateQueue; 43667 if (updateQueue !== null) { 43668 instance.props = finishedWork.memoizedProps; 43669 instance.state = finishedWork.memoizedState; 43670 commitUpdateQueue(finishedWork, updateQueue, instance, committedExpirationTime); 43671 } 43672 return; 43673 } 43674 case HostRoot: 43675 { 43676 var _updateQueue = finishedWork.updateQueue; 43677 if (_updateQueue !== null) { 43678 var _instance = null; 43679 if (finishedWork.child !== null) { 43680 switch (finishedWork.child.tag) { 43681 case HostComponent: 43682 _instance = getPublicInstance(finishedWork.child.stateNode); 43683 break; 43684 case ClassComponent: 43685 _instance = finishedWork.child.stateNode; 43686 break; 43687 } 43688 } 43689 commitUpdateQueue(finishedWork, _updateQueue, _instance, committedExpirationTime); 43690 } 43691 return; 43692 } 43693 case HostComponent: 43694 { 43695 var _instance2 = finishedWork.stateNode; 43696 43697 // Renderers may schedule work to be done after host components are mounted 43698 // (eg DOM renderer may schedule auto-focus for inputs and form controls). 43699 // These effects should only be committed when components are first mounted, 43700 // aka when there is no current/alternate. 43701 if (current === null && finishedWork.effectTag & Update) { 43702 var type = finishedWork.type; 43703 var props = finishedWork.memoizedProps; 43704 commitMount(_instance2, type, props, finishedWork); 43705 } 43706 43707 return; 43708 } 43709 case HostText: 43710 { 43711 // We have no life-cycles associated with text. 43712 return; 43713 } 43714 case HostPortal: 43715 { 43716 // We have no life-cycles associated with portals. 43717 return; 43718 } 43719 case Profiler: 43720 { 43721 // We have no life-cycles associated with Profiler. 43722 return; 43723 } 43724 case TimeoutComponent: 43725 { 43726 // We have no life-cycles associated with Timeouts. 43727 return; 43728 } 43729 default: 43730 { 43731 invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.'); 43732 } 43733 } 43734} 43735 43736function commitAttachRef(finishedWork) { 43737 var ref = finishedWork.ref; 43738 if (ref !== null) { 43739 var instance = finishedWork.stateNode; 43740 var instanceToUse = void 0; 43741 switch (finishedWork.tag) { 43742 case HostComponent: 43743 instanceToUse = getPublicInstance(instance); 43744 break; 43745 default: 43746 instanceToUse = instance; 43747 } 43748 if (typeof ref === 'function') { 43749 ref(instanceToUse); 43750 } else { 43751 { 43752 if (!ref.hasOwnProperty('current')) { 43753 warning(false, 'Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork), getStackAddendumByWorkInProgressFiber(finishedWork)); 43754 } 43755 } 43756 43757 ref.current = instanceToUse; 43758 } 43759 } 43760} 43761 43762function commitDetachRef(current) { 43763 var currentRef = current.ref; 43764 if (currentRef !== null) { 43765 if (typeof currentRef === 'function') { 43766 currentRef(null); 43767 } else { 43768 currentRef.current = null; 43769 } 43770 } 43771} 43772 43773// User-originating errors (lifecycles and refs) should not interrupt 43774// deletion, so don't let them throw. Host-originating errors should 43775// interrupt deletion, so it's okay 43776function commitUnmount(current) { 43777 if (typeof onCommitUnmount === 'function') { 43778 onCommitUnmount(current); 43779 } 43780 43781 switch (current.tag) { 43782 case ClassComponent: 43783 { 43784 safelyDetachRef(current); 43785 var instance = current.stateNode; 43786 if (typeof instance.componentWillUnmount === 'function') { 43787 safelyCallComponentWillUnmount(current, instance); 43788 } 43789 return; 43790 } 43791 case HostComponent: 43792 { 43793 safelyDetachRef(current); 43794 return; 43795 } 43796 case HostPortal: 43797 { 43798 // TODO: this is recursive. 43799 // We are also not using this parent because 43800 // the portal will get pushed immediately. 43801 if (supportsMutation) { 43802 unmountHostComponents(current); 43803 } else if (supportsPersistence) { 43804 emptyPortalContainer(current); 43805 } 43806 return; 43807 } 43808 } 43809} 43810 43811function commitNestedUnmounts(root) { 43812 // While we're inside a removed host node we don't want to call 43813 // removeChild on the inner nodes because they're removed by the top 43814 // call anyway. We also want to call componentWillUnmount on all 43815 // composites before this host node is removed from the tree. Therefore 43816 var node = root; 43817 while (true) { 43818 commitUnmount(node); 43819 // Visit children because they may contain more composite or host nodes. 43820 // Skip portals because commitUnmount() currently visits them recursively. 43821 if (node.child !== null && ( 43822 // If we use mutation we drill down into portals using commitUnmount above. 43823 // If we don't use mutation we drill down into portals here instead. 43824 !supportsMutation || node.tag !== HostPortal)) { 43825 node.child.return = node; 43826 node = node.child; 43827 continue; 43828 } 43829 if (node === root) { 43830 return; 43831 } 43832 while (node.sibling === null) { 43833 if (node.return === null || node.return === root) { 43834 return; 43835 } 43836 node = node.return; 43837 } 43838 node.sibling.return = node.return; 43839 node = node.sibling; 43840 } 43841} 43842 43843function detachFiber(current) { 43844 // Cut off the return pointers to disconnect it from the tree. Ideally, we 43845 // should clear the child pointer of the parent alternate to let this 43846 // get GC:ed but we don't know which for sure which parent is the current 43847 // one so we'll settle for GC:ing the subtree of this child. This child 43848 // itself will be GC:ed when the parent updates the next time. 43849 current.return = null; 43850 current.child = null; 43851 if (current.alternate) { 43852 current.alternate.child = null; 43853 current.alternate.return = null; 43854 } 43855} 43856 43857function emptyPortalContainer(current) { 43858 if (!supportsPersistence) { 43859 return; 43860 } 43861 43862 var portal = current.stateNode; 43863 var containerInfo = portal.containerInfo; 43864 43865 var emptyChildSet = createContainerChildSet(containerInfo); 43866 replaceContainerChildren(containerInfo, emptyChildSet); 43867} 43868 43869function commitContainer(finishedWork) { 43870 if (!supportsPersistence) { 43871 return; 43872 } 43873 43874 switch (finishedWork.tag) { 43875 case ClassComponent: 43876 { 43877 return; 43878 } 43879 case HostComponent: 43880 { 43881 return; 43882 } 43883 case HostText: 43884 { 43885 return; 43886 } 43887 case HostRoot: 43888 case HostPortal: 43889 { 43890 var portalOrRoot = finishedWork.stateNode; 43891 var containerInfo = portalOrRoot.containerInfo, 43892 _pendingChildren = portalOrRoot.pendingChildren; 43893 43894 replaceContainerChildren(containerInfo, _pendingChildren); 43895 return; 43896 } 43897 default: 43898 { 43899 invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.'); 43900 } 43901 } 43902} 43903 43904function getHostParentFiber(fiber) { 43905 var parent = fiber.return; 43906 while (parent !== null) { 43907 if (isHostParent(parent)) { 43908 return parent; 43909 } 43910 parent = parent.return; 43911 } 43912 invariant(false, 'Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.'); 43913} 43914 43915function isHostParent(fiber) { 43916 return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal; 43917} 43918 43919function getHostSibling(fiber) { 43920 // We're going to search forward into the tree until we find a sibling host 43921 // node. Unfortunately, if multiple insertions are done in a row we have to 43922 // search past them. This leads to exponential search for the next sibling. 43923 var node = fiber; 43924 siblings: while (true) { 43925 // If we didn't find anything, let's try the next sibling. 43926 while (node.sibling === null) { 43927 if (node.return === null || isHostParent(node.return)) { 43928 // If we pop out of the root or hit the parent the fiber we are the 43929 // last sibling. 43930 return null; 43931 } 43932 node = node.return; 43933 } 43934 node.sibling.return = node.return; 43935 node = node.sibling; 43936 while (node.tag !== HostComponent && node.tag !== HostText) { 43937 // If it is not host node and, we might have a host node inside it. 43938 // Try to search down until we find one. 43939 if (node.effectTag & Placement) { 43940 // If we don't have a child, try the siblings instead. 43941 continue siblings; 43942 } 43943 // If we don't have a child, try the siblings instead. 43944 // We also skip portals because they are not part of this host tree. 43945 if (node.child === null || node.tag === HostPortal) { 43946 continue siblings; 43947 } else { 43948 node.child.return = node; 43949 node = node.child; 43950 } 43951 } 43952 // Check if this host node is stable or about to be placed. 43953 if (!(node.effectTag & Placement)) { 43954 // Found it! 43955 return node.stateNode; 43956 } 43957 } 43958} 43959 43960function commitPlacement(finishedWork) { 43961 if (!supportsMutation) { 43962 return; 43963 } 43964 43965 // Recursively insert all host nodes into the parent. 43966 var parentFiber = getHostParentFiber(finishedWork); 43967 var parent = void 0; 43968 var isContainer = void 0; 43969 switch (parentFiber.tag) { 43970 case HostComponent: 43971 parent = parentFiber.stateNode; 43972 isContainer = false; 43973 break; 43974 case HostRoot: 43975 parent = parentFiber.stateNode.containerInfo; 43976 isContainer = true; 43977 break; 43978 case HostPortal: 43979 parent = parentFiber.stateNode.containerInfo; 43980 isContainer = true; 43981 break; 43982 default: 43983 invariant(false, 'Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.'); 43984 } 43985 if (parentFiber.effectTag & ContentReset) { 43986 // Reset the text content of the parent before doing any insertions 43987 resetTextContent(parent); 43988 // Clear ContentReset from the effect tag 43989 parentFiber.effectTag &= ~ContentReset; 43990 } 43991 43992 var before = getHostSibling(finishedWork); 43993 // We only have the top Fiber that was inserted but we need recurse down its 43994 // children to find all the terminal nodes. 43995 var node = finishedWork; 43996 while (true) { 43997 if (node.tag === HostComponent || node.tag === HostText) { 43998 if (before) { 43999 if (isContainer) { 44000 insertInContainerBefore(parent, node.stateNode, before); 44001 } else { 44002 insertBefore(parent, node.stateNode, before); 44003 } 44004 } else { 44005 if (isContainer) { 44006 appendChildToContainer(parent, node.stateNode); 44007 } else { 44008 appendChild(parent, node.stateNode); 44009 } 44010 } 44011 } else if (node.tag === HostPortal) { 44012 // If the insertion itself is a portal, then we don't want to traverse 44013 // down its children. Instead, we'll get insertions from each child in 44014 // the portal directly. 44015 } else if (node.child !== null) { 44016 node.child.return = node; 44017 node = node.child; 44018 continue; 44019 } 44020 if (node === finishedWork) { 44021 return; 44022 } 44023 while (node.sibling === null) { 44024 if (node.return === null || node.return === finishedWork) { 44025 return; 44026 } 44027 node = node.return; 44028 } 44029 node.sibling.return = node.return; 44030 node = node.sibling; 44031 } 44032} 44033 44034function unmountHostComponents(current) { 44035 // We only have the top Fiber that was inserted but we need recurse down its 44036 var node = current; 44037 44038 // Each iteration, currentParent is populated with node's host parent if not 44039 // currentParentIsValid. 44040 var currentParentIsValid = false; 44041 var currentParent = void 0; 44042 var currentParentIsContainer = void 0; 44043 44044 while (true) { 44045 if (!currentParentIsValid) { 44046 var parent = node.return; 44047 findParent: while (true) { 44048 !(parent !== null) ? invariant(false, 'Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.') : void 0; 44049 switch (parent.tag) { 44050 case HostComponent: 44051 currentParent = parent.stateNode; 44052 currentParentIsContainer = false; 44053 break findParent; 44054 case HostRoot: 44055 currentParent = parent.stateNode.containerInfo; 44056 currentParentIsContainer = true; 44057 break findParent; 44058 case HostPortal: 44059 currentParent = parent.stateNode.containerInfo; 44060 currentParentIsContainer = true; 44061 break findParent; 44062 } 44063 parent = parent.return; 44064 } 44065 currentParentIsValid = true; 44066 } 44067 44068 if (node.tag === HostComponent || node.tag === HostText) { 44069 commitNestedUnmounts(node); 44070 // After all the children have unmounted, it is now safe to remove the 44071 // node from the tree. 44072 if (currentParentIsContainer) { 44073 removeChildFromContainer(currentParent, node.stateNode); 44074 } else { 44075 removeChild(currentParent, node.stateNode); 44076 } 44077 // Don't visit children because we already visited them. 44078 } else if (node.tag === HostPortal) { 44079 // When we go into a portal, it becomes the parent to remove from. 44080 // We will reassign it back when we pop the portal on the way up. 44081 currentParent = node.stateNode.containerInfo; 44082 // Visit children because portals might contain host components. 44083 if (node.child !== null) { 44084 node.child.return = node; 44085 node = node.child; 44086 continue; 44087 } 44088 } else { 44089 commitUnmount(node); 44090 // Visit children because we may find more host components below. 44091 if (node.child !== null) { 44092 node.child.return = node; 44093 node = node.child; 44094 continue; 44095 } 44096 } 44097 if (node === current) { 44098 return; 44099 } 44100 while (node.sibling === null) { 44101 if (node.return === null || node.return === current) { 44102 return; 44103 } 44104 node = node.return; 44105 if (node.tag === HostPortal) { 44106 // When we go out of the portal, we need to restore the parent. 44107 // Since we don't keep a stack of them, we will search for it. 44108 currentParentIsValid = false; 44109 } 44110 } 44111 node.sibling.return = node.return; 44112 node = node.sibling; 44113 } 44114} 44115 44116function commitDeletion(current) { 44117 if (supportsMutation) { 44118 // Recursively delete all host nodes from the parent. 44119 // Detach refs and call componentWillUnmount() on the whole subtree. 44120 unmountHostComponents(current); 44121 } else { 44122 // Detach refs and call componentWillUnmount() on the whole subtree. 44123 commitNestedUnmounts(current); 44124 } 44125 detachFiber(current); 44126} 44127 44128function commitWork(current, finishedWork) { 44129 if (!supportsMutation) { 44130 commitContainer(finishedWork); 44131 return; 44132 } 44133 44134 switch (finishedWork.tag) { 44135 case ClassComponent: 44136 { 44137 return; 44138 } 44139 case HostComponent: 44140 { 44141 var instance = finishedWork.stateNode; 44142 if (instance != null) { 44143 // Commit the work prepared earlier. 44144 var newProps = finishedWork.memoizedProps; 44145 // For hydration we reuse the update path but we treat the oldProps 44146 // as the newProps. The updatePayload will contain the real change in 44147 // this case. 44148 var oldProps = current !== null ? current.memoizedProps : newProps; 44149 var type = finishedWork.type; 44150 // TODO: Type the updateQueue to be specific to host components. 44151 var updatePayload = finishedWork.updateQueue; 44152 finishedWork.updateQueue = null; 44153 if (updatePayload !== null) { 44154 commitUpdate(instance, updatePayload, type, oldProps, newProps, finishedWork); 44155 } 44156 } 44157 return; 44158 } 44159 case HostText: 44160 { 44161 !(finishedWork.stateNode !== null) ? invariant(false, 'This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.') : void 0; 44162 var textInstance = finishedWork.stateNode; 44163 var newText = finishedWork.memoizedProps; 44164 // For hydration we reuse the update path but we treat the oldProps 44165 // as the newProps. The updatePayload will contain the real change in 44166 // this case. 44167 var oldText = current !== null ? current.memoizedProps : newText; 44168 commitTextUpdate(textInstance, oldText, newText); 44169 return; 44170 } 44171 case HostRoot: 44172 { 44173 return; 44174 } 44175 case Profiler: 44176 { 44177 if (enableProfilerTimer) { 44178 var onRender = finishedWork.memoizedProps.onRender; 44179 onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseTime, finishedWork.actualStartTime, getCommitTime()); 44180 } 44181 return; 44182 } 44183 case TimeoutComponent: 44184 { 44185 return; 44186 } 44187 default: 44188 { 44189 invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.'); 44190 } 44191 } 44192} 44193 44194function commitResetTextContent(current) { 44195 if (!supportsMutation) { 44196 return; 44197 } 44198 resetTextContent(current.stateNode); 44199} 44200 44201function createRootErrorUpdate(fiber, errorInfo, expirationTime) { 44202 var update = createUpdate(expirationTime); 44203 // Unmount the root by rendering null. 44204 update.tag = CaptureUpdate; 44205 // Caution: React DevTools currently depends on this property 44206 // being called "element". 44207 update.payload = { element: null }; 44208 var error = errorInfo.value; 44209 update.callback = function () { 44210 onUncaughtError(error); 44211 logError(fiber, errorInfo); 44212 }; 44213 return update; 44214} 44215 44216function createClassErrorUpdate(fiber, errorInfo, expirationTime) { 44217 var update = createUpdate(expirationTime); 44218 update.tag = CaptureUpdate; 44219 var getDerivedStateFromCatch = fiber.type.getDerivedStateFromCatch; 44220 if (enableGetDerivedStateFromCatch && typeof getDerivedStateFromCatch === 'function') { 44221 var error = errorInfo.value; 44222 update.payload = function () { 44223 return getDerivedStateFromCatch(error); 44224 }; 44225 } 44226 44227 var inst = fiber.stateNode; 44228 if (inst !== null && typeof inst.componentDidCatch === 'function') { 44229 update.callback = function callback() { 44230 if (!enableGetDerivedStateFromCatch || getDerivedStateFromCatch !== 'function') { 44231 // To preserve the preexisting retry behavior of error boundaries, 44232 // we keep track of which ones already failed during this batch. 44233 // This gets reset before we yield back to the browser. 44234 // TODO: Warn in strict mode if getDerivedStateFromCatch is 44235 // not defined. 44236 markLegacyErrorBoundaryAsFailed(this); 44237 } 44238 var error = errorInfo.value; 44239 var stack = errorInfo.stack; 44240 logError(fiber, errorInfo); 44241 this.componentDidCatch(error, { 44242 componentStack: stack !== null ? stack : '' 44243 }); 44244 }; 44245 } 44246 return update; 44247} 44248 44249function schedulePing(finishedWork) { 44250 // Once the promise resolves, we should try rendering the non- 44251 // placeholder state again. 44252 var currentTime = recalculateCurrentTime(); 44253 var expirationTime = computeExpirationForFiber(currentTime, finishedWork); 44254 var recoveryUpdate = createUpdate(expirationTime); 44255 enqueueUpdate(finishedWork, recoveryUpdate, expirationTime); 44256 scheduleWork$1(finishedWork, expirationTime); 44257} 44258 44259function throwException(root, returnFiber, sourceFiber, value, renderIsExpired, renderExpirationTime, currentTimeMs) { 44260 // The source fiber did not complete. 44261 sourceFiber.effectTag |= Incomplete; 44262 // Its effect list is no longer valid. 44263 sourceFiber.firstEffect = sourceFiber.lastEffect = null; 44264 44265 if (enableSuspense && value !== null && typeof value === 'object' && typeof value.then === 'function') { 44266 // This is a thenable. 44267 var thenable = value; 44268 44269 var expirationTimeMs = expirationTimeToMs(renderExpirationTime); 44270 var startTimeMs = expirationTimeMs - 5000; 44271 var elapsedMs = currentTimeMs - startTimeMs; 44272 if (elapsedMs < 0) { 44273 elapsedMs = 0; 44274 } 44275 var remainingTimeMs = expirationTimeMs - currentTimeMs; 44276 44277 // Find the earliest timeout of all the timeouts in the ancestor path. 44278 // TODO: Alternatively, we could store the earliest timeout on the context 44279 // stack, rather than searching on every suspend. 44280 var _workInProgress = returnFiber; 44281 var earliestTimeoutMs = -1; 44282 searchForEarliestTimeout: do { 44283 if (_workInProgress.tag === TimeoutComponent) { 44284 var current = _workInProgress.alternate; 44285 if (current !== null && current.memoizedState === true) { 44286 // A parent Timeout already committed in a placeholder state. We 44287 // need to handle this promise immediately. In other words, we 44288 // should never suspend inside a tree that already expired. 44289 earliestTimeoutMs = 0; 44290 break searchForEarliestTimeout; 44291 } 44292 var timeoutPropMs = _workInProgress.pendingProps.ms; 44293 if (typeof timeoutPropMs === 'number') { 44294 if (timeoutPropMs <= 0) { 44295 earliestTimeoutMs = 0; 44296 break searchForEarliestTimeout; 44297 } else if (earliestTimeoutMs === -1 || timeoutPropMs < earliestTimeoutMs) { 44298 earliestTimeoutMs = timeoutPropMs; 44299 } 44300 } else if (earliestTimeoutMs === -1) { 44301 earliestTimeoutMs = remainingTimeMs; 44302 } 44303 } 44304 _workInProgress = _workInProgress.return; 44305 } while (_workInProgress !== null); 44306 44307 // Compute the remaining time until the timeout. 44308 var msUntilTimeout = earliestTimeoutMs - elapsedMs; 44309 44310 if (renderExpirationTime === Never || msUntilTimeout > 0) { 44311 // There's still time remaining. 44312 suspendRoot(root, thenable, msUntilTimeout, renderExpirationTime); 44313 var onResolveOrReject = function () { 44314 retrySuspendedRoot(root, renderExpirationTime); 44315 }; 44316 thenable.then(onResolveOrReject, onResolveOrReject); 44317 return; 44318 } else { 44319 // No time remaining. Need to fallback to placeholder. 44320 // Find the nearest timeout that can be retried. 44321 _workInProgress = returnFiber; 44322 do { 44323 switch (_workInProgress.tag) { 44324 case HostRoot: 44325 { 44326 // The root expired, but no fallback was provided. Throw a 44327 // helpful error. 44328 var message = renderExpirationTime === Sync ? 'A synchronous update was suspended, but no fallback UI ' + 'was provided.' : 'An update was suspended for longer than the timeout, ' + 'but no fallback UI was provided.'; 44329 value = new Error(message); 44330 break; 44331 } 44332 case TimeoutComponent: 44333 { 44334 if ((_workInProgress.effectTag & DidCapture) === NoEffect) { 44335 _workInProgress.effectTag |= ShouldCapture; 44336 var _onResolveOrReject = schedulePing.bind(null, _workInProgress); 44337 thenable.then(_onResolveOrReject, _onResolveOrReject); 44338 return; 44339 } 44340 // Already captured during this render. Continue to the next 44341 // Timeout ancestor. 44342 break; 44343 } 44344 } 44345 _workInProgress = _workInProgress.return; 44346 } while (_workInProgress !== null); 44347 } 44348 } 44349 44350 // We didn't find a boundary that could handle this type of exception. Start 44351 // over and traverse parent path again, this time treating the exception 44352 // as an error. 44353 value = createCapturedValue(value, sourceFiber); 44354 var workInProgress = returnFiber; 44355 do { 44356 switch (workInProgress.tag) { 44357 case HostRoot: 44358 { 44359 var _errorInfo = value; 44360 workInProgress.effectTag |= ShouldCapture; 44361 var update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime); 44362 enqueueCapturedUpdate(workInProgress, update, renderExpirationTime); 44363 return; 44364 } 44365 case ClassComponent: 44366 // Capture and retry 44367 var errorInfo = value; 44368 var ctor = workInProgress.type; 44369 var instance = workInProgress.stateNode; 44370 if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromCatch === 'function' && enableGetDerivedStateFromCatch || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) { 44371 workInProgress.effectTag |= ShouldCapture; 44372 // Schedule the error boundary to re-render using updated state 44373 var _update = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime); 44374 enqueueCapturedUpdate(workInProgress, _update, renderExpirationTime); 44375 return; 44376 } 44377 break; 44378 default: 44379 break; 44380 } 44381 workInProgress = workInProgress.return; 44382 } while (workInProgress !== null); 44383} 44384 44385function unwindWork(workInProgress, renderIsExpired, renderExpirationTime) { 44386 if (enableProfilerTimer) { 44387 if (workInProgress.mode & ProfileMode) { 44388 recordElapsedActualRenderTime(workInProgress); 44389 } 44390 } 44391 44392 switch (workInProgress.tag) { 44393 case ClassComponent: 44394 { 44395 popContextProvider(workInProgress); 44396 var effectTag = workInProgress.effectTag; 44397 if (effectTag & ShouldCapture) { 44398 workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture; 44399 return workInProgress; 44400 } 44401 return null; 44402 } 44403 case HostRoot: 44404 { 44405 popHostContainer(workInProgress); 44406 popTopLevelContextObject(workInProgress); 44407 var _effectTag = workInProgress.effectTag; 44408 if (_effectTag & ShouldCapture) { 44409 workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture; 44410 return workInProgress; 44411 } 44412 return null; 44413 } 44414 case HostComponent: 44415 { 44416 popHostContext(workInProgress); 44417 return null; 44418 } 44419 case TimeoutComponent: 44420 { 44421 var _effectTag2 = workInProgress.effectTag; 44422 if (_effectTag2 & ShouldCapture) { 44423 workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture; 44424 return workInProgress; 44425 } 44426 return null; 44427 } 44428 case HostPortal: 44429 popHostContainer(workInProgress); 44430 return null; 44431 case ContextProvider: 44432 popProvider(workInProgress); 44433 return null; 44434 default: 44435 return null; 44436 } 44437} 44438 44439function unwindInterruptedWork(interruptedWork) { 44440 if (enableProfilerTimer) { 44441 if (interruptedWork.mode & ProfileMode) { 44442 // Resume in case we're picking up on work that was paused. 44443 resumeActualRenderTimerIfPaused(); 44444 recordElapsedActualRenderTime(interruptedWork); 44445 } 44446 } 44447 44448 switch (interruptedWork.tag) { 44449 case ClassComponent: 44450 { 44451 popContextProvider(interruptedWork); 44452 break; 44453 } 44454 case HostRoot: 44455 { 44456 popHostContainer(interruptedWork); 44457 popTopLevelContextObject(interruptedWork); 44458 break; 44459 } 44460 case HostComponent: 44461 { 44462 popHostContext(interruptedWork); 44463 break; 44464 } 44465 case HostPortal: 44466 popHostContainer(interruptedWork); 44467 break; 44468 case ContextProvider: 44469 popProvider(interruptedWork); 44470 break; 44471 default: 44472 break; 44473 } 44474} 44475 44476var invokeGuardedCallback$2 = ReactErrorUtils.invokeGuardedCallback; 44477var hasCaughtError = ReactErrorUtils.hasCaughtError; 44478var clearCaughtError = ReactErrorUtils.clearCaughtError; 44479 44480 44481var didWarnAboutStateTransition = void 0; 44482var didWarnSetStateChildContext = void 0; 44483var warnAboutUpdateOnUnmounted = void 0; 44484var warnAboutInvalidUpdates = void 0; 44485 44486{ 44487 didWarnAboutStateTransition = false; 44488 didWarnSetStateChildContext = false; 44489 var didWarnStateUpdateForUnmountedComponent = {}; 44490 44491 warnAboutUpdateOnUnmounted = function (fiber) { 44492 // We show the whole stack but dedupe on the top component's name because 44493 // the problematic code almost always lies inside that component. 44494 var componentName = getComponentName(fiber) || 'ReactClass'; 44495 if (didWarnStateUpdateForUnmountedComponent[componentName]) { 44496 return; 44497 } 44498 warning(false, "Can't call setState (or forceUpdate) on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in the ' + 'componentWillUnmount method.%s', getStackAddendumByWorkInProgressFiber(fiber)); 44499 didWarnStateUpdateForUnmountedComponent[componentName] = true; 44500 }; 44501 44502 warnAboutInvalidUpdates = function (instance) { 44503 switch (ReactDebugCurrentFiber.phase) { 44504 case 'getChildContext': 44505 if (didWarnSetStateChildContext) { 44506 return; 44507 } 44508 warning(false, 'setState(...): Cannot call setState() inside getChildContext()'); 44509 didWarnSetStateChildContext = true; 44510 break; 44511 case 'render': 44512 if (didWarnAboutStateTransition) { 44513 return; 44514 } 44515 warning(false, 'Cannot update during an existing state transition (such as within ' + "`render` or another component's constructor). Render methods should " + 'be a pure function of props and state; constructor side-effects are ' + 'an anti-pattern, but can be moved to `componentWillMount`.'); 44516 didWarnAboutStateTransition = true; 44517 break; 44518 } 44519 }; 44520} 44521 44522// Represents the current time in ms. 44523var originalStartTimeMs = now(); 44524var mostRecentCurrentTime = msToExpirationTime(0); 44525var mostRecentCurrentTimeMs = originalStartTimeMs; 44526 44527// Used to ensure computeUniqueAsyncExpiration is monotonically increases. 44528var lastUniqueAsyncExpiration = 0; 44529 44530// Represents the expiration time that incoming updates should use. (If this 44531// is NoWork, use the default strategy: async updates in async mode, sync 44532// updates in sync mode.) 44533var expirationContext = NoWork; 44534 44535var isWorking = false; 44536 44537// The next work in progress fiber that we're currently working on. 44538var nextUnitOfWork = null; 44539var nextRoot = null; 44540// The time at which we're currently rendering work. 44541var nextRenderExpirationTime = NoWork; 44542var nextLatestTimeoutMs = -1; 44543var nextRenderIsExpired = false; 44544 44545// The next fiber with an effect that we're currently committing. 44546var nextEffect = null; 44547 44548var isCommitting$1 = false; 44549 44550var isRootReadyForCommit = false; 44551 44552var legacyErrorBoundariesThatAlreadyFailed = null; 44553 44554// Used for performance tracking. 44555var interruptedBy = null; 44556 44557var stashedWorkInProgressProperties = void 0; 44558var replayUnitOfWork = void 0; 44559var isReplayingFailedUnitOfWork = void 0; 44560var originalReplayError = void 0; 44561var rethrowOriginalError = void 0; 44562if ( true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { 44563 stashedWorkInProgressProperties = null; 44564 isReplayingFailedUnitOfWork = false; 44565 originalReplayError = null; 44566 replayUnitOfWork = function (failedUnitOfWork, thrownValue, isAsync) { 44567 if (thrownValue !== null && typeof thrownValue === 'object' && typeof thrownValue.then === 'function') { 44568 // Don't replay promises. Treat everything else like an error. 44569 // TODO: Need to figure out a different strategy if/when we add 44570 // support for catching other types. 44571 return; 44572 } 44573 44574 // Restore the original state of the work-in-progress 44575 if (stashedWorkInProgressProperties === null) { 44576 // This should never happen. Don't throw because this code is DEV-only. 44577 warning(false, 'Could not replay rendering after an error. This is likely a bug in React. ' + 'Please file an issue.'); 44578 return; 44579 } 44580 assignFiberPropertiesInDEV(failedUnitOfWork, stashedWorkInProgressProperties); 44581 44582 switch (failedUnitOfWork.tag) { 44583 case HostRoot: 44584 popHostContainer(failedUnitOfWork); 44585 popTopLevelContextObject(failedUnitOfWork); 44586 break; 44587 case HostComponent: 44588 popHostContext(failedUnitOfWork); 44589 break; 44590 case ClassComponent: 44591 popContextProvider(failedUnitOfWork); 44592 break; 44593 case HostPortal: 44594 popHostContainer(failedUnitOfWork); 44595 break; 44596 case ContextProvider: 44597 popProvider(failedUnitOfWork); 44598 break; 44599 } 44600 // Replay the begin phase. 44601 isReplayingFailedUnitOfWork = true; 44602 originalReplayError = thrownValue; 44603 invokeGuardedCallback$2(null, workLoop, null, isAsync); 44604 isReplayingFailedUnitOfWork = false; 44605 originalReplayError = null; 44606 if (hasCaughtError()) { 44607 clearCaughtError(); 44608 44609 if (enableProfilerTimer) { 44610 if (failedUnitOfWork.mode & ProfileMode) { 44611 recordElapsedActualRenderTime(failedUnitOfWork); 44612 } 44613 44614 // Stop "base" render timer again (after the re-thrown error). 44615 stopBaseRenderTimerIfRunning(); 44616 } 44617 } else { 44618 // If the begin phase did not fail the second time, set this pointer 44619 // back to the original value. 44620 nextUnitOfWork = failedUnitOfWork; 44621 } 44622 }; 44623 rethrowOriginalError = function () { 44624 throw originalReplayError; 44625 }; 44626} 44627 44628function resetStack() { 44629 if (nextUnitOfWork !== null) { 44630 var interruptedWork = nextUnitOfWork.return; 44631 while (interruptedWork !== null) { 44632 unwindInterruptedWork(interruptedWork); 44633 interruptedWork = interruptedWork.return; 44634 } 44635 } 44636 44637 { 44638 ReactStrictModeWarnings.discardPendingWarnings(); 44639 checkThatStackIsEmpty(); 44640 } 44641 44642 nextRoot = null; 44643 nextRenderExpirationTime = NoWork; 44644 nextLatestTimeoutMs = -1; 44645 nextRenderIsExpired = false; 44646 nextUnitOfWork = null; 44647 44648 isRootReadyForCommit = false; 44649} 44650 44651function commitAllHostEffects() { 44652 while (nextEffect !== null) { 44653 { 44654 ReactDebugCurrentFiber.setCurrentFiber(nextEffect); 44655 } 44656 recordEffect(); 44657 44658 var effectTag = nextEffect.effectTag; 44659 44660 if (effectTag & ContentReset) { 44661 commitResetTextContent(nextEffect); 44662 } 44663 44664 if (effectTag & Ref) { 44665 var current = nextEffect.alternate; 44666 if (current !== null) { 44667 commitDetachRef(current); 44668 } 44669 } 44670 44671 // The following switch statement is only concerned about placement, 44672 // updates, and deletions. To avoid needing to add a case for every 44673 // possible bitmap value, we remove the secondary effects from the 44674 // effect tag and switch on that value. 44675 var primaryEffectTag = effectTag & (Placement | Update | Deletion); 44676 switch (primaryEffectTag) { 44677 case Placement: 44678 { 44679 commitPlacement(nextEffect); 44680 // Clear the "placement" from effect tag so that we know that this is inserted, before 44681 // any life-cycles like componentDidMount gets called. 44682 // TODO: findDOMNode doesn't rely on this any more but isMounted 44683 // does and isMounted is deprecated anyway so we should be able 44684 // to kill this. 44685 nextEffect.effectTag &= ~Placement; 44686 break; 44687 } 44688 case PlacementAndUpdate: 44689 { 44690 // Placement 44691 commitPlacement(nextEffect); 44692 // Clear the "placement" from effect tag so that we know that this is inserted, before 44693 // any life-cycles like componentDidMount gets called. 44694 nextEffect.effectTag &= ~Placement; 44695 44696 // Update 44697 var _current = nextEffect.alternate; 44698 commitWork(_current, nextEffect); 44699 break; 44700 } 44701 case Update: 44702 { 44703 var _current2 = nextEffect.alternate; 44704 commitWork(_current2, nextEffect); 44705 break; 44706 } 44707 case Deletion: 44708 { 44709 commitDeletion(nextEffect); 44710 break; 44711 } 44712 } 44713 nextEffect = nextEffect.nextEffect; 44714 } 44715 44716 { 44717 ReactDebugCurrentFiber.resetCurrentFiber(); 44718 } 44719} 44720 44721function commitBeforeMutationLifecycles() { 44722 while (nextEffect !== null) { 44723 var effectTag = nextEffect.effectTag; 44724 44725 if (effectTag & Snapshot) { 44726 recordEffect(); 44727 var current = nextEffect.alternate; 44728 commitBeforeMutationLifeCycles(current, nextEffect); 44729 } 44730 44731 // Don't cleanup effects yet; 44732 // This will be done by commitAllLifeCycles() 44733 nextEffect = nextEffect.nextEffect; 44734 } 44735} 44736 44737function commitAllLifeCycles(finishedRoot, currentTime, committedExpirationTime) { 44738 { 44739 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); 44740 44741 if (warnAboutDeprecatedLifecycles) { 44742 ReactStrictModeWarnings.flushPendingDeprecationWarnings(); 44743 } 44744 44745 if (warnAboutLegacyContextAPI) { 44746 ReactStrictModeWarnings.flushLegacyContextWarning(); 44747 } 44748 } 44749 while (nextEffect !== null) { 44750 var effectTag = nextEffect.effectTag; 44751 44752 if (effectTag & (Update | Callback)) { 44753 recordEffect(); 44754 var current = nextEffect.alternate; 44755 commitLifeCycles(finishedRoot, current, nextEffect, currentTime, committedExpirationTime); 44756 } 44757 44758 if (effectTag & Ref) { 44759 recordEffect(); 44760 commitAttachRef(nextEffect); 44761 } 44762 44763 var next = nextEffect.nextEffect; 44764 // Ensure that we clean these up so that we don't accidentally keep them. 44765 // I'm not actually sure this matters because we can't reset firstEffect 44766 // and lastEffect since they're on every node, not just the effectful 44767 // ones. So we have to clean everything as we reuse nodes anyway. 44768 nextEffect.nextEffect = null; 44769 // Ensure that we reset the effectTag here so that we can rely on effect 44770 // tags to reason about the current life-cycle. 44771 nextEffect = next; 44772 } 44773} 44774 44775function isAlreadyFailedLegacyErrorBoundary(instance) { 44776 return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance); 44777} 44778 44779function markLegacyErrorBoundaryAsFailed(instance) { 44780 if (legacyErrorBoundariesThatAlreadyFailed === null) { 44781 legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); 44782 } else { 44783 legacyErrorBoundariesThatAlreadyFailed.add(instance); 44784 } 44785} 44786 44787function commitRoot(finishedWork) { 44788 isWorking = true; 44789 isCommitting$1 = true; 44790 startCommitTimer(); 44791 44792 var root = finishedWork.stateNode; 44793 !(root.current !== finishedWork) ? invariant(false, 'Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue.') : void 0; 44794 var committedExpirationTime = root.pendingCommitExpirationTime; 44795 !(committedExpirationTime !== NoWork) ? invariant(false, 'Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.') : void 0; 44796 root.pendingCommitExpirationTime = NoWork; 44797 44798 var currentTime = recalculateCurrentTime(); 44799 44800 // Reset this to null before calling lifecycles 44801 ReactCurrentOwner.current = null; 44802 44803 var firstEffect = void 0; 44804 if (finishedWork.effectTag > PerformedWork) { 44805 // A fiber's effect list consists only of its children, not itself. So if 44806 // the root has an effect, we need to add it to the end of the list. The 44807 // resulting list is the set that would belong to the root's parent, if 44808 // it had one; that is, all the effects in the tree including the root. 44809 if (finishedWork.lastEffect !== null) { 44810 finishedWork.lastEffect.nextEffect = finishedWork; 44811 firstEffect = finishedWork.firstEffect; 44812 } else { 44813 firstEffect = finishedWork; 44814 } 44815 } else { 44816 // There is no effect on the root. 44817 firstEffect = finishedWork.firstEffect; 44818 } 44819 44820 prepareForCommit(root.containerInfo); 44821 44822 // Invoke instances of getSnapshotBeforeUpdate before mutation. 44823 nextEffect = firstEffect; 44824 startCommitSnapshotEffectsTimer(); 44825 while (nextEffect !== null) { 44826 var didError = false; 44827 var error = void 0; 44828 { 44829 invokeGuardedCallback$2(null, commitBeforeMutationLifecycles, null); 44830 if (hasCaughtError()) { 44831 didError = true; 44832 error = clearCaughtError(); 44833 } 44834 } 44835 if (didError) { 44836 !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0; 44837 captureCommitPhaseError(nextEffect, error); 44838 // Clean-up 44839 if (nextEffect !== null) { 44840 nextEffect = nextEffect.nextEffect; 44841 } 44842 } 44843 } 44844 stopCommitSnapshotEffectsTimer(); 44845 44846 if (enableProfilerTimer) { 44847 // Mark the current commit time to be shared by all Profilers in this batch. 44848 // This enables them to be grouped later. 44849 recordCommitTime(); 44850 } 44851 44852 // Commit all the side-effects within a tree. We'll do this in two passes. 44853 // The first pass performs all the host insertions, updates, deletions and 44854 // ref unmounts. 44855 nextEffect = firstEffect; 44856 startCommitHostEffectsTimer(); 44857 while (nextEffect !== null) { 44858 var _didError = false; 44859 var _error = void 0; 44860 { 44861 invokeGuardedCallback$2(null, commitAllHostEffects, null); 44862 if (hasCaughtError()) { 44863 _didError = true; 44864 _error = clearCaughtError(); 44865 } 44866 } 44867 if (_didError) { 44868 !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0; 44869 captureCommitPhaseError(nextEffect, _error); 44870 // Clean-up 44871 if (nextEffect !== null) { 44872 nextEffect = nextEffect.nextEffect; 44873 } 44874 } 44875 } 44876 stopCommitHostEffectsTimer(); 44877 44878 resetAfterCommit(root.containerInfo); 44879 44880 // The work-in-progress tree is now the current tree. This must come after 44881 // the first pass of the commit phase, so that the previous tree is still 44882 // current during componentWillUnmount, but before the second pass, so that 44883 // the finished work is current during componentDidMount/Update. 44884 root.current = finishedWork; 44885 44886 // In the second pass we'll perform all life-cycles and ref callbacks. 44887 // Life-cycles happen as a separate pass so that all placements, updates, 44888 // and deletions in the entire tree have already been invoked. 44889 // This pass also triggers any renderer-specific initial effects. 44890 nextEffect = firstEffect; 44891 startCommitLifeCyclesTimer(); 44892 while (nextEffect !== null) { 44893 var _didError2 = false; 44894 var _error2 = void 0; 44895 { 44896 invokeGuardedCallback$2(null, commitAllLifeCycles, null, root, currentTime, committedExpirationTime); 44897 if (hasCaughtError()) { 44898 _didError2 = true; 44899 _error2 = clearCaughtError(); 44900 } 44901 } 44902 if (_didError2) { 44903 !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0; 44904 captureCommitPhaseError(nextEffect, _error2); 44905 if (nextEffect !== null) { 44906 nextEffect = nextEffect.nextEffect; 44907 } 44908 } 44909 } 44910 44911 if (enableProfilerTimer) { 44912 { 44913 checkActualRenderTimeStackEmpty(); 44914 } 44915 resetActualRenderTimer(); 44916 } 44917 44918 isCommitting$1 = false; 44919 isWorking = false; 44920 stopCommitLifeCyclesTimer(); 44921 stopCommitTimer(); 44922 if (typeof onCommitRoot === 'function') { 44923 onCommitRoot(finishedWork.stateNode); 44924 } 44925 if ( true && ReactFiberInstrumentation_1.debugTool) { 44926 ReactFiberInstrumentation_1.debugTool.onCommitWork(finishedWork); 44927 } 44928 44929 markCommittedPriorityLevels(root, currentTime, root.current.expirationTime); 44930 var remainingTime = findNextPendingPriorityLevel(root); 44931 if (remainingTime === NoWork) { 44932 // If there's no remaining work, we can clear the set of already failed 44933 // error boundaries. 44934 legacyErrorBoundariesThatAlreadyFailed = null; 44935 } 44936 return remainingTime; 44937} 44938 44939function resetExpirationTime(workInProgress, renderTime) { 44940 if (renderTime !== Never && workInProgress.expirationTime === Never) { 44941 // The children of this component are hidden. Don't bubble their 44942 // expiration times. 44943 return; 44944 } 44945 44946 // Check for pending updates. 44947 var newExpirationTime = NoWork; 44948 switch (workInProgress.tag) { 44949 case HostRoot: 44950 case ClassComponent: 44951 { 44952 var updateQueue = workInProgress.updateQueue; 44953 if (updateQueue !== null) { 44954 newExpirationTime = updateQueue.expirationTime; 44955 } 44956 } 44957 } 44958 44959 // TODO: Calls need to visit stateNode 44960 44961 // Bubble up the earliest expiration time. 44962 // (And "base" render timers if that feature flag is enabled) 44963 if (enableProfilerTimer && workInProgress.mode & ProfileMode) { 44964 var treeBaseTime = workInProgress.selfBaseTime; 44965 var child = workInProgress.child; 44966 while (child !== null) { 44967 treeBaseTime += child.treeBaseTime; 44968 if (child.expirationTime !== NoWork && (newExpirationTime === NoWork || newExpirationTime > child.expirationTime)) { 44969 newExpirationTime = child.expirationTime; 44970 } 44971 child = child.sibling; 44972 } 44973 workInProgress.treeBaseTime = treeBaseTime; 44974 } else { 44975 var _child = workInProgress.child; 44976 while (_child !== null) { 44977 if (_child.expirationTime !== NoWork && (newExpirationTime === NoWork || newExpirationTime > _child.expirationTime)) { 44978 newExpirationTime = _child.expirationTime; 44979 } 44980 _child = _child.sibling; 44981 } 44982 } 44983 44984 workInProgress.expirationTime = newExpirationTime; 44985} 44986 44987function completeUnitOfWork(workInProgress) { 44988 // Attempt to complete the current unit of work, then move to the 44989 // next sibling. If there are no more siblings, return to the 44990 // parent fiber. 44991 while (true) { 44992 // The current, flushed, state of this fiber is the alternate. 44993 // Ideally nothing should rely on this, but relying on it here 44994 // means that we don't need an additional field on the work in 44995 // progress. 44996 var current = workInProgress.alternate; 44997 { 44998 ReactDebugCurrentFiber.setCurrentFiber(workInProgress); 44999 } 45000 45001 var returnFiber = workInProgress.return; 45002 var siblingFiber = workInProgress.sibling; 45003 45004 if ((workInProgress.effectTag & Incomplete) === NoEffect) { 45005 // This fiber completed. 45006 var next = completeWork(current, workInProgress, nextRenderExpirationTime); 45007 stopWorkTimer(workInProgress); 45008 resetExpirationTime(workInProgress, nextRenderExpirationTime); 45009 { 45010 ReactDebugCurrentFiber.resetCurrentFiber(); 45011 } 45012 45013 if (next !== null) { 45014 stopWorkTimer(workInProgress); 45015 if ( true && ReactFiberInstrumentation_1.debugTool) { 45016 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); 45017 } 45018 // If completing this work spawned new work, do that next. We'll come 45019 // back here again. 45020 return next; 45021 } 45022 45023 if (returnFiber !== null && 45024 // Do not append effects to parents if a sibling failed to complete 45025 (returnFiber.effectTag & Incomplete) === NoEffect) { 45026 // Append all the effects of the subtree and this fiber onto the effect 45027 // list of the parent. The completion order of the children affects the 45028 // side-effect order. 45029 if (returnFiber.firstEffect === null) { 45030 returnFiber.firstEffect = workInProgress.firstEffect; 45031 } 45032 if (workInProgress.lastEffect !== null) { 45033 if (returnFiber.lastEffect !== null) { 45034 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; 45035 } 45036 returnFiber.lastEffect = workInProgress.lastEffect; 45037 } 45038 45039 // If this fiber had side-effects, we append it AFTER the children's 45040 // side-effects. We can perform certain side-effects earlier if 45041 // needed, by doing multiple passes over the effect list. We don't want 45042 // to schedule our own side-effect on our own list because if end up 45043 // reusing children we'll schedule this effect onto itself since we're 45044 // at the end. 45045 var effectTag = workInProgress.effectTag; 45046 // Skip both NoWork and PerformedWork tags when creating the effect list. 45047 // PerformedWork effect is read by React DevTools but shouldn't be committed. 45048 if (effectTag > PerformedWork) { 45049 if (returnFiber.lastEffect !== null) { 45050 returnFiber.lastEffect.nextEffect = workInProgress; 45051 } else { 45052 returnFiber.firstEffect = workInProgress; 45053 } 45054 returnFiber.lastEffect = workInProgress; 45055 } 45056 } 45057 45058 if ( true && ReactFiberInstrumentation_1.debugTool) { 45059 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); 45060 } 45061 45062 if (siblingFiber !== null) { 45063 // If there is more work to do in this returnFiber, do that next. 45064 return siblingFiber; 45065 } else if (returnFiber !== null) { 45066 // If there's no more work in this returnFiber. Complete the returnFiber. 45067 workInProgress = returnFiber; 45068 continue; 45069 } else { 45070 // We've reached the root. 45071 isRootReadyForCommit = true; 45072 return null; 45073 } 45074 } else { 45075 // This fiber did not complete because something threw. Pop values off 45076 // the stack without entering the complete phase. If this is a boundary, 45077 // capture values if possible. 45078 var _next = unwindWork(workInProgress, nextRenderIsExpired, nextRenderExpirationTime); 45079 // Because this fiber did not complete, don't reset its expiration time. 45080 if (workInProgress.effectTag & DidCapture) { 45081 // Restarting an error boundary 45082 stopFailedWorkTimer(workInProgress); 45083 } else { 45084 stopWorkTimer(workInProgress); 45085 } 45086 45087 { 45088 ReactDebugCurrentFiber.resetCurrentFiber(); 45089 } 45090 45091 if (_next !== null) { 45092 stopWorkTimer(workInProgress); 45093 if ( true && ReactFiberInstrumentation_1.debugTool) { 45094 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); 45095 } 45096 // If completing this work spawned new work, do that next. We'll come 45097 // back here again. 45098 // Since we're restarting, remove anything that is not a host effect 45099 // from the effect tag. 45100 _next.effectTag &= HostEffectMask; 45101 return _next; 45102 } 45103 45104 if (returnFiber !== null) { 45105 // Mark the parent fiber as incomplete and clear its effect list. 45106 returnFiber.firstEffect = returnFiber.lastEffect = null; 45107 returnFiber.effectTag |= Incomplete; 45108 } 45109 45110 if ( true && ReactFiberInstrumentation_1.debugTool) { 45111 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); 45112 } 45113 45114 if (siblingFiber !== null) { 45115 // If there is more work to do in this returnFiber, do that next. 45116 return siblingFiber; 45117 } else if (returnFiber !== null) { 45118 // If there's no more work in this returnFiber. Complete the returnFiber. 45119 workInProgress = returnFiber; 45120 continue; 45121 } else { 45122 return null; 45123 } 45124 } 45125 } 45126 45127 // Without this explicit null return Flow complains of invalid return type 45128 // TODO Remove the above while(true) loop 45129 // eslint-disable-next-line no-unreachable 45130 return null; 45131} 45132 45133function performUnitOfWork(workInProgress) { 45134 // The current, flushed, state of this fiber is the alternate. 45135 // Ideally nothing should rely on this, but relying on it here 45136 // means that we don't need an additional field on the work in 45137 // progress. 45138 var current = workInProgress.alternate; 45139 45140 // See if beginning this work spawns more work. 45141 startWorkTimer(workInProgress); 45142 { 45143 ReactDebugCurrentFiber.setCurrentFiber(workInProgress); 45144 } 45145 45146 if ( true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { 45147 stashedWorkInProgressProperties = assignFiberPropertiesInDEV(stashedWorkInProgressProperties, workInProgress); 45148 } 45149 45150 var next = void 0; 45151 if (enableProfilerTimer) { 45152 if (workInProgress.mode & ProfileMode) { 45153 startBaseRenderTimer(); 45154 } 45155 45156 next = beginWork(current, workInProgress, nextRenderExpirationTime); 45157 45158 if (workInProgress.mode & ProfileMode) { 45159 // Update "base" time if the render wasn't bailed out on. 45160 recordElapsedBaseRenderTimeIfRunning(workInProgress); 45161 stopBaseRenderTimerIfRunning(); 45162 } 45163 } else { 45164 next = beginWork(current, workInProgress, nextRenderExpirationTime); 45165 } 45166 45167 { 45168 ReactDebugCurrentFiber.resetCurrentFiber(); 45169 if (isReplayingFailedUnitOfWork) { 45170 // Currently replaying a failed unit of work. This should be unreachable, 45171 // because the render phase is meant to be idempotent, and it should 45172 // have thrown again. Since it didn't, rethrow the original error, so 45173 // React's internal stack is not misaligned. 45174 rethrowOriginalError(); 45175 } 45176 } 45177 if ( true && ReactFiberInstrumentation_1.debugTool) { 45178 ReactFiberInstrumentation_1.debugTool.onBeginWork(workInProgress); 45179 } 45180 45181 if (next === null) { 45182 // If this doesn't spawn new work, complete the current work. 45183 next = completeUnitOfWork(workInProgress); 45184 } 45185 45186 ReactCurrentOwner.current = null; 45187 45188 return next; 45189} 45190 45191function workLoop(isAsync) { 45192 if (!isAsync) { 45193 // Flush all expired work. 45194 while (nextUnitOfWork !== null) { 45195 nextUnitOfWork = performUnitOfWork(nextUnitOfWork); 45196 } 45197 } else { 45198 // Flush asynchronous work until the deadline runs out of time. 45199 while (nextUnitOfWork !== null && !shouldYield()) { 45200 nextUnitOfWork = performUnitOfWork(nextUnitOfWork); 45201 } 45202 45203 if (enableProfilerTimer) { 45204 // If we didn't finish, pause the "actual" render timer. 45205 // We'll restart it when we resume work. 45206 pauseActualRenderTimerIfRunning(); 45207 } 45208 } 45209} 45210 45211function renderRoot(root, expirationTime, isAsync) { 45212 !!isWorking ? invariant(false, 'renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0; 45213 isWorking = true; 45214 45215 // Check if we're starting from a fresh stack, or if we're resuming from 45216 // previously yielded work. 45217 if (expirationTime !== nextRenderExpirationTime || root !== nextRoot || nextUnitOfWork === null) { 45218 // Reset the stack and start working from the root. 45219 resetStack(); 45220 nextRoot = root; 45221 nextRenderExpirationTime = expirationTime; 45222 nextLatestTimeoutMs = -1; 45223 nextUnitOfWork = createWorkInProgress(nextRoot.current, null, nextRenderExpirationTime); 45224 root.pendingCommitExpirationTime = NoWork; 45225 } 45226 45227 var didFatal = false; 45228 45229 nextRenderIsExpired = !isAsync || nextRenderExpirationTime <= mostRecentCurrentTime; 45230 45231 startWorkLoopTimer(nextUnitOfWork); 45232 45233 do { 45234 try { 45235 workLoop(isAsync); 45236 } catch (thrownValue) { 45237 if (enableProfilerTimer) { 45238 // Stop "base" render timer in the event of an error. 45239 stopBaseRenderTimerIfRunning(); 45240 } 45241 45242 if (nextUnitOfWork === null) { 45243 // This is a fatal error. 45244 didFatal = true; 45245 onUncaughtError(thrownValue); 45246 } else { 45247 { 45248 // Reset global debug state 45249 // We assume this is defined in DEV 45250 resetCurrentlyProcessingQueue(); 45251 } 45252 45253 var failedUnitOfWork = nextUnitOfWork; 45254 if ( true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { 45255 replayUnitOfWork(failedUnitOfWork, thrownValue, isAsync); 45256 } 45257 45258 // TODO: we already know this isn't true in some cases. 45259 // At least this shows a nicer error message until we figure out the cause. 45260 // https://github.com/facebook/react/issues/12449#issuecomment-386727431 45261 !(nextUnitOfWork !== null) ? invariant(false, 'Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it.') : void 0; 45262 45263 var sourceFiber = nextUnitOfWork; 45264 var returnFiber = sourceFiber.return; 45265 if (returnFiber === null) { 45266 // This is the root. The root could capture its own errors. However, 45267 // we don't know if it errors before or after we pushed the host 45268 // context. This information is needed to avoid a stack mismatch. 45269 // Because we're not sure, treat this as a fatal error. We could track 45270 // which phase it fails in, but doesn't seem worth it. At least 45271 // for now. 45272 didFatal = true; 45273 onUncaughtError(thrownValue); 45274 break; 45275 } 45276 throwException(root, returnFiber, sourceFiber, thrownValue, nextRenderIsExpired, nextRenderExpirationTime, mostRecentCurrentTimeMs); 45277 nextUnitOfWork = completeUnitOfWork(sourceFiber); 45278 } 45279 } 45280 break; 45281 } while (true); 45282 45283 // We're done performing work. Time to clean up. 45284 var didCompleteRoot = false; 45285 isWorking = false; 45286 45287 // Yield back to main thread. 45288 if (didFatal) { 45289 stopWorkLoopTimer(interruptedBy, didCompleteRoot); 45290 interruptedBy = null; 45291 // There was a fatal error. 45292 { 45293 resetStackAfterFatalErrorInDev(); 45294 } 45295 return null; 45296 } else if (nextUnitOfWork === null) { 45297 // We reached the root. 45298 if (isRootReadyForCommit) { 45299 didCompleteRoot = true; 45300 stopWorkLoopTimer(interruptedBy, didCompleteRoot); 45301 interruptedBy = null; 45302 // The root successfully completed. It's ready for commit. 45303 root.pendingCommitExpirationTime = expirationTime; 45304 var finishedWork = root.current.alternate; 45305 return finishedWork; 45306 } else { 45307 // The root did not complete. 45308 stopWorkLoopTimer(interruptedBy, didCompleteRoot); 45309 interruptedBy = null; 45310 !!nextRenderIsExpired ? invariant(false, 'Expired work should have completed. This error is likely caused by a bug in React. Please file an issue.') : void 0; 45311 markSuspendedPriorityLevel(root, expirationTime); 45312 if (nextLatestTimeoutMs >= 0) { 45313 setTimeout(function () { 45314 retrySuspendedRoot(root, expirationTime); 45315 }, nextLatestTimeoutMs); 45316 } 45317 var firstUnblockedExpirationTime = findNextPendingPriorityLevel(root); 45318 onBlock(firstUnblockedExpirationTime); 45319 return null; 45320 } 45321 } else { 45322 stopWorkLoopTimer(interruptedBy, didCompleteRoot); 45323 interruptedBy = null; 45324 // There's more work to do, but we ran out of time. Yield back to 45325 // the renderer. 45326 return null; 45327 } 45328} 45329 45330function dispatch(sourceFiber, value, expirationTime) { 45331 !(!isWorking || isCommitting$1) ? invariant(false, 'dispatch: Cannot dispatch during the render phase.') : void 0; 45332 45333 var fiber = sourceFiber.return; 45334 while (fiber !== null) { 45335 switch (fiber.tag) { 45336 case ClassComponent: 45337 var ctor = fiber.type; 45338 var instance = fiber.stateNode; 45339 if (typeof ctor.getDerivedStateFromCatch === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) { 45340 var errorInfo = createCapturedValue(value, sourceFiber); 45341 var update = createClassErrorUpdate(fiber, errorInfo, expirationTime); 45342 enqueueUpdate(fiber, update, expirationTime); 45343 scheduleWork$1(fiber, expirationTime); 45344 return; 45345 } 45346 break; 45347 case HostRoot: 45348 { 45349 var _errorInfo = createCapturedValue(value, sourceFiber); 45350 var _update = createRootErrorUpdate(fiber, _errorInfo, expirationTime); 45351 enqueueUpdate(fiber, _update, expirationTime); 45352 scheduleWork$1(fiber, expirationTime); 45353 return; 45354 } 45355 } 45356 fiber = fiber.return; 45357 } 45358 45359 if (sourceFiber.tag === HostRoot) { 45360 // Error was thrown at the root. There is no parent, so the root 45361 // itself should capture it. 45362 var rootFiber = sourceFiber; 45363 var _errorInfo2 = createCapturedValue(value, rootFiber); 45364 var _update2 = createRootErrorUpdate(rootFiber, _errorInfo2, expirationTime); 45365 enqueueUpdate(rootFiber, _update2, expirationTime); 45366 scheduleWork$1(rootFiber, expirationTime); 45367 } 45368} 45369 45370function captureCommitPhaseError(fiber, error) { 45371 return dispatch(fiber, error, Sync); 45372} 45373 45374function computeAsyncExpiration(currentTime) { 45375 // Given the current clock time, returns an expiration time. We use rounding 45376 // to batch like updates together. 45377 // Should complete within ~5000ms. 5250ms max. 45378 var expirationMs = 5000; 45379 var bucketSizeMs = 250; 45380 return computeExpirationBucket(currentTime, expirationMs, bucketSizeMs); 45381} 45382 45383function computeInteractiveExpiration(currentTime) { 45384 var expirationMs = void 0; 45385 // We intentionally set a higher expiration time for interactive updates in 45386 // dev than in production. 45387 // If the main thread is being blocked so long that you hit the expiration, 45388 // it's a problem that could be solved with better scheduling. 45389 // People will be more likely to notice this and fix it with the long 45390 // expiration time in development. 45391 // In production we opt for better UX at the risk of masking scheduling 45392 // problems, by expiring fast. 45393 { 45394 // Should complete within ~500ms. 600ms max. 45395 expirationMs = 500; 45396 } 45397 var bucketSizeMs = 100; 45398 return computeExpirationBucket(currentTime, expirationMs, bucketSizeMs); 45399} 45400 45401// Creates a unique async expiration time. 45402function computeUniqueAsyncExpiration() { 45403 var currentTime = recalculateCurrentTime(); 45404 var result = computeAsyncExpiration(currentTime); 45405 if (result <= lastUniqueAsyncExpiration) { 45406 // Since we assume the current time monotonically increases, we only hit 45407 // this branch when computeUniqueAsyncExpiration is fired multiple times 45408 // within a 200ms window (or whatever the async bucket size is). 45409 result = lastUniqueAsyncExpiration + 1; 45410 } 45411 lastUniqueAsyncExpiration = result; 45412 return lastUniqueAsyncExpiration; 45413} 45414 45415function computeExpirationForFiber(currentTime, fiber) { 45416 var expirationTime = void 0; 45417 if (expirationContext !== NoWork) { 45418 // An explicit expiration context was set; 45419 expirationTime = expirationContext; 45420 } else if (isWorking) { 45421 if (isCommitting$1) { 45422 // Updates that occur during the commit phase should have sync priority 45423 // by default. 45424 expirationTime = Sync; 45425 } else { 45426 // Updates during the render phase should expire at the same time as 45427 // the work that is being rendered. 45428 expirationTime = nextRenderExpirationTime; 45429 } 45430 } else { 45431 // No explicit expiration context was set, and we're not currently 45432 // performing work. Calculate a new expiration time. 45433 if (fiber.mode & AsyncMode) { 45434 if (isBatchingInteractiveUpdates) { 45435 // This is an interactive update 45436 expirationTime = computeInteractiveExpiration(currentTime); 45437 } else { 45438 // This is an async update 45439 expirationTime = computeAsyncExpiration(currentTime); 45440 } 45441 } else { 45442 // This is a sync update 45443 expirationTime = Sync; 45444 } 45445 } 45446 if (isBatchingInteractiveUpdates) { 45447 // This is an interactive update. Keep track of the lowest pending 45448 // interactive expiration time. This allows us to synchronously flush 45449 // all interactive updates when needed. 45450 if (lowestPendingInteractiveExpirationTime === NoWork || expirationTime > lowestPendingInteractiveExpirationTime) { 45451 lowestPendingInteractiveExpirationTime = expirationTime; 45452 } 45453 } 45454 return expirationTime; 45455} 45456 45457// TODO: Rename this to scheduleTimeout or something 45458function suspendRoot(root, thenable, timeoutMs, suspendedTime) { 45459 // Schedule the timeout. 45460 if (timeoutMs >= 0 && nextLatestTimeoutMs < timeoutMs) { 45461 nextLatestTimeoutMs = timeoutMs; 45462 } 45463} 45464 45465function retrySuspendedRoot(root, suspendedTime) { 45466 markPingedPriorityLevel(root, suspendedTime); 45467 var retryTime = findNextPendingPriorityLevel(root); 45468 if (retryTime !== NoWork) { 45469 requestRetry(root, retryTime); 45470 } 45471} 45472 45473function scheduleWork$1(fiber, expirationTime) { 45474 recordScheduleUpdate(); 45475 45476 { 45477 if (fiber.tag === ClassComponent) { 45478 var instance = fiber.stateNode; 45479 warnAboutInvalidUpdates(instance); 45480 } 45481 } 45482 45483 var node = fiber; 45484 while (node !== null) { 45485 // Walk the parent path to the root and update each node's 45486 // expiration time. 45487 if (node.expirationTime === NoWork || node.expirationTime > expirationTime) { 45488 node.expirationTime = expirationTime; 45489 } 45490 if (node.alternate !== null) { 45491 if (node.alternate.expirationTime === NoWork || node.alternate.expirationTime > expirationTime) { 45492 node.alternate.expirationTime = expirationTime; 45493 } 45494 } 45495 if (node.return === null) { 45496 if (node.tag === HostRoot) { 45497 var root = node.stateNode; 45498 if (!isWorking && nextRenderExpirationTime !== NoWork && expirationTime < nextRenderExpirationTime) { 45499 // This is an interruption. (Used for performance tracking.) 45500 interruptedBy = fiber; 45501 resetStack(); 45502 } 45503 markPendingPriorityLevel(root, expirationTime); 45504 var nextExpirationTimeToWorkOn = findNextPendingPriorityLevel(root); 45505 if ( 45506 // If we're in the render phase, we don't need to schedule this root 45507 // for an update, because we'll do it before we exit... 45508 !isWorking || isCommitting$1 || 45509 // ...unless this is a different root than the one we're rendering. 45510 nextRoot !== root) { 45511 requestWork(root, nextExpirationTimeToWorkOn); 45512 } 45513 if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { 45514 invariant(false, 'Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.'); 45515 } 45516 } else { 45517 { 45518 if (fiber.tag === ClassComponent) { 45519 warnAboutUpdateOnUnmounted(fiber); 45520 } 45521 } 45522 return; 45523 } 45524 } 45525 node = node.return; 45526 } 45527} 45528 45529function recalculateCurrentTime() { 45530 // Subtract initial time so it fits inside 32bits 45531 mostRecentCurrentTimeMs = now() - originalStartTimeMs; 45532 mostRecentCurrentTime = msToExpirationTime(mostRecentCurrentTimeMs); 45533 return mostRecentCurrentTime; 45534} 45535 45536function deferredUpdates(fn) { 45537 var previousExpirationContext = expirationContext; 45538 var currentTime = recalculateCurrentTime(); 45539 expirationContext = computeAsyncExpiration(currentTime); 45540 try { 45541 return fn(); 45542 } finally { 45543 expirationContext = previousExpirationContext; 45544 } 45545} 45546function syncUpdates(fn, a, b, c, d) { 45547 var previousExpirationContext = expirationContext; 45548 expirationContext = Sync; 45549 try { 45550 return fn(a, b, c, d); 45551 } finally { 45552 expirationContext = previousExpirationContext; 45553 } 45554} 45555 45556// TODO: Everything below this is written as if it has been lifted to the 45557// renderers. I'll do this in a follow-up. 45558 45559// Linked-list of roots 45560var firstScheduledRoot = null; 45561var lastScheduledRoot = null; 45562 45563var callbackExpirationTime = NoWork; 45564var callbackID = void 0; 45565var isRendering = false; 45566var nextFlushedRoot = null; 45567var nextFlushedExpirationTime = NoWork; 45568var lowestPendingInteractiveExpirationTime = NoWork; 45569var deadlineDidExpire = false; 45570var hasUnhandledError = false; 45571var unhandledError = null; 45572var deadline = null; 45573 45574var isBatchingUpdates = false; 45575var isUnbatchingUpdates = false; 45576var isBatchingInteractiveUpdates = false; 45577 45578var completedBatches = null; 45579 45580// Use these to prevent an infinite loop of nested updates 45581var NESTED_UPDATE_LIMIT = 1000; 45582var nestedUpdateCount = 0; 45583 45584var timeHeuristicForUnitOfWork = 1; 45585 45586function scheduleCallbackWithExpiration(expirationTime) { 45587 if (callbackExpirationTime !== NoWork) { 45588 // A callback is already scheduled. Check its expiration time (timeout). 45589 if (expirationTime > callbackExpirationTime) { 45590 // Existing callback has sufficient timeout. Exit. 45591 return; 45592 } else { 45593 if (callbackID !== null) { 45594 // Existing callback has insufficient timeout. Cancel and schedule a 45595 // new one. 45596 cancelDeferredCallback(callbackID); 45597 } 45598 } 45599 // The request callback timer is already running. Don't start a new one. 45600 } else { 45601 startRequestCallbackTimer(); 45602 } 45603 45604 // Compute a timeout for the given expiration time. 45605 var currentMs = now() - originalStartTimeMs; 45606 var expirationMs = expirationTimeToMs(expirationTime); 45607 var timeout = expirationMs - currentMs; 45608 45609 callbackExpirationTime = expirationTime; 45610 callbackID = scheduleDeferredCallback(performAsyncWork, { timeout: timeout }); 45611} 45612 45613function requestRetry(root, expirationTime) { 45614 if (root.remainingExpirationTime === NoWork || root.remainingExpirationTime < expirationTime) { 45615 // For a retry, only update the remaining expiration time if it has a 45616 // *lower priority* than the existing value. This is because, on a retry, 45617 // we should attempt to coalesce as much as possible. 45618 requestWork(root, expirationTime); 45619 } 45620} 45621 45622// requestWork is called by the scheduler whenever a root receives an update. 45623// It's up to the renderer to call renderRoot at some point in the future. 45624function requestWork(root, expirationTime) { 45625 addRootToSchedule(root, expirationTime); 45626 45627 if (isRendering) { 45628 // Prevent reentrancy. Remaining work will be scheduled at the end of 45629 // the currently rendering batch. 45630 return; 45631 } 45632 45633 if (isBatchingUpdates) { 45634 // Flush work at the end of the batch. 45635 if (isUnbatchingUpdates) { 45636 // ...unless we're inside unbatchedUpdates, in which case we should 45637 // flush it now. 45638 nextFlushedRoot = root; 45639 nextFlushedExpirationTime = Sync; 45640 performWorkOnRoot(root, Sync, false); 45641 } 45642 return; 45643 } 45644 45645 // TODO: Get rid of Sync and use current time? 45646 if (expirationTime === Sync) { 45647 performSyncWork(); 45648 } else { 45649 scheduleCallbackWithExpiration(expirationTime); 45650 } 45651} 45652 45653function addRootToSchedule(root, expirationTime) { 45654 // Add the root to the schedule. 45655 // Check if this root is already part of the schedule. 45656 if (root.nextScheduledRoot === null) { 45657 // This root is not already scheduled. Add it. 45658 root.remainingExpirationTime = expirationTime; 45659 if (lastScheduledRoot === null) { 45660 firstScheduledRoot = lastScheduledRoot = root; 45661 root.nextScheduledRoot = root; 45662 } else { 45663 lastScheduledRoot.nextScheduledRoot = root; 45664 lastScheduledRoot = root; 45665 lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; 45666 } 45667 } else { 45668 // This root is already scheduled, but its priority may have increased. 45669 var remainingExpirationTime = root.remainingExpirationTime; 45670 if (remainingExpirationTime === NoWork || expirationTime < remainingExpirationTime) { 45671 // Update the priority. 45672 root.remainingExpirationTime = expirationTime; 45673 } 45674 } 45675} 45676 45677function findHighestPriorityRoot() { 45678 var highestPriorityWork = NoWork; 45679 var highestPriorityRoot = null; 45680 if (lastScheduledRoot !== null) { 45681 var previousScheduledRoot = lastScheduledRoot; 45682 var root = firstScheduledRoot; 45683 while (root !== null) { 45684 var remainingExpirationTime = root.remainingExpirationTime; 45685 if (remainingExpirationTime === NoWork) { 45686 // This root no longer has work. Remove it from the scheduler. 45687 45688 // TODO: This check is redudant, but Flow is confused by the branch 45689 // below where we set lastScheduledRoot to null, even though we break 45690 // from the loop right after. 45691 !(previousScheduledRoot !== null && lastScheduledRoot !== null) ? invariant(false, 'Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue.') : void 0; 45692 if (root === root.nextScheduledRoot) { 45693 // This is the only root in the list. 45694 root.nextScheduledRoot = null; 45695 firstScheduledRoot = lastScheduledRoot = null; 45696 break; 45697 } else if (root === firstScheduledRoot) { 45698 // This is the first root in the list. 45699 var next = root.nextScheduledRoot; 45700 firstScheduledRoot = next; 45701 lastScheduledRoot.nextScheduledRoot = next; 45702 root.nextScheduledRoot = null; 45703 } else if (root === lastScheduledRoot) { 45704 // This is the last root in the list. 45705 lastScheduledRoot = previousScheduledRoot; 45706 lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; 45707 root.nextScheduledRoot = null; 45708 break; 45709 } else { 45710 previousScheduledRoot.nextScheduledRoot = root.nextScheduledRoot; 45711 root.nextScheduledRoot = null; 45712 } 45713 root = previousScheduledRoot.nextScheduledRoot; 45714 } else { 45715 if (highestPriorityWork === NoWork || remainingExpirationTime < highestPriorityWork) { 45716 // Update the priority, if it's higher 45717 highestPriorityWork = remainingExpirationTime; 45718 highestPriorityRoot = root; 45719 } 45720 if (root === lastScheduledRoot) { 45721 break; 45722 } 45723 previousScheduledRoot = root; 45724 root = root.nextScheduledRoot; 45725 } 45726 } 45727 } 45728 45729 // If the next root is the same as the previous root, this is a nested 45730 // update. To prevent an infinite loop, increment the nested update count. 45731 var previousFlushedRoot = nextFlushedRoot; 45732 if (previousFlushedRoot !== null && previousFlushedRoot === highestPriorityRoot && highestPriorityWork === Sync) { 45733 nestedUpdateCount++; 45734 } else { 45735 // Reset whenever we switch roots. 45736 nestedUpdateCount = 0; 45737 } 45738 nextFlushedRoot = highestPriorityRoot; 45739 nextFlushedExpirationTime = highestPriorityWork; 45740} 45741 45742function performAsyncWork(dl) { 45743 performWork(NoWork, true, dl); 45744} 45745 45746function performSyncWork() { 45747 performWork(Sync, false, null); 45748} 45749 45750function performWork(minExpirationTime, isAsync, dl) { 45751 deadline = dl; 45752 45753 // Keep working on roots until there's no more work, or until the we reach 45754 // the deadline. 45755 findHighestPriorityRoot(); 45756 45757 if (enableProfilerTimer) { 45758 resumeActualRenderTimerIfPaused(); 45759 } 45760 45761 if (enableUserTimingAPI && deadline !== null) { 45762 var didExpire = nextFlushedExpirationTime < recalculateCurrentTime(); 45763 var timeout = expirationTimeToMs(nextFlushedExpirationTime); 45764 stopRequestCallbackTimer(didExpire, timeout); 45765 } 45766 45767 if (isAsync) { 45768 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime) && (!deadlineDidExpire || recalculateCurrentTime() >= nextFlushedExpirationTime)) { 45769 recalculateCurrentTime(); 45770 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !deadlineDidExpire); 45771 findHighestPriorityRoot(); 45772 } 45773 } else { 45774 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime)) { 45775 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); 45776 findHighestPriorityRoot(); 45777 } 45778 } 45779 45780 // We're done flushing work. Either we ran out of time in this callback, 45781 // or there's no more work left with sufficient priority. 45782 45783 // If we're inside a callback, set this to false since we just completed it. 45784 if (deadline !== null) { 45785 callbackExpirationTime = NoWork; 45786 callbackID = null; 45787 } 45788 // If there's work left over, schedule a new callback. 45789 if (nextFlushedExpirationTime !== NoWork) { 45790 scheduleCallbackWithExpiration(nextFlushedExpirationTime); 45791 } 45792 45793 // Clean-up. 45794 deadline = null; 45795 deadlineDidExpire = false; 45796 45797 finishRendering(); 45798} 45799 45800function flushRoot(root, expirationTime) { 45801 !!isRendering ? invariant(false, 'work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method.') : void 0; 45802 // Perform work on root as if the given expiration time is the current time. 45803 // This has the effect of synchronously flushing all work up to and 45804 // including the given time. 45805 nextFlushedRoot = root; 45806 nextFlushedExpirationTime = expirationTime; 45807 performWorkOnRoot(root, expirationTime, false); 45808 // Flush any sync work that was scheduled by lifecycles 45809 performSyncWork(); 45810 finishRendering(); 45811} 45812 45813function finishRendering() { 45814 nestedUpdateCount = 0; 45815 45816 if (completedBatches !== null) { 45817 var batches = completedBatches; 45818 completedBatches = null; 45819 for (var i = 0; i < batches.length; i++) { 45820 var batch = batches[i]; 45821 try { 45822 batch._onComplete(); 45823 } catch (error) { 45824 if (!hasUnhandledError) { 45825 hasUnhandledError = true; 45826 unhandledError = error; 45827 } 45828 } 45829 } 45830 } 45831 45832 if (hasUnhandledError) { 45833 var error = unhandledError; 45834 unhandledError = null; 45835 hasUnhandledError = false; 45836 throw error; 45837 } 45838} 45839 45840function performWorkOnRoot(root, expirationTime, isAsync) { 45841 !!isRendering ? invariant(false, 'performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0; 45842 45843 isRendering = true; 45844 45845 // Check if this is async work or sync/expired work. 45846 if (!isAsync) { 45847 // Flush sync work. 45848 var finishedWork = root.finishedWork; 45849 if (finishedWork !== null) { 45850 // This root is already complete. We can commit it. 45851 completeRoot(root, finishedWork, expirationTime); 45852 } else { 45853 finishedWork = renderRoot(root, expirationTime, false); 45854 if (finishedWork !== null) { 45855 // We've completed the root. Commit it. 45856 completeRoot(root, finishedWork, expirationTime); 45857 } 45858 } 45859 } else { 45860 // Flush async work. 45861 var _finishedWork = root.finishedWork; 45862 if (_finishedWork !== null) { 45863 // This root is already complete. We can commit it. 45864 completeRoot(root, _finishedWork, expirationTime); 45865 } else { 45866 _finishedWork = renderRoot(root, expirationTime, true); 45867 if (_finishedWork !== null) { 45868 // We've completed the root. Check the deadline one more time 45869 // before committing. 45870 if (!shouldYield()) { 45871 // Still time left. Commit the root. 45872 completeRoot(root, _finishedWork, expirationTime); 45873 } else { 45874 // There's no time left. Mark this root as complete. We'll come 45875 // back and commit it later. 45876 root.finishedWork = _finishedWork; 45877 45878 if (enableProfilerTimer) { 45879 // If we didn't finish, pause the "actual" render timer. 45880 // We'll restart it when we resume work. 45881 pauseActualRenderTimerIfRunning(); 45882 } 45883 } 45884 } 45885 } 45886 } 45887 45888 isRendering = false; 45889} 45890 45891function completeRoot(root, finishedWork, expirationTime) { 45892 // Check if there's a batch that matches this expiration time. 45893 var firstBatch = root.firstBatch; 45894 if (firstBatch !== null && firstBatch._expirationTime <= expirationTime) { 45895 if (completedBatches === null) { 45896 completedBatches = [firstBatch]; 45897 } else { 45898 completedBatches.push(firstBatch); 45899 } 45900 if (firstBatch._defer) { 45901 // This root is blocked from committing by a batch. Unschedule it until 45902 // we receive another update. 45903 root.finishedWork = finishedWork; 45904 root.remainingExpirationTime = NoWork; 45905 return; 45906 } 45907 } 45908 45909 // Commit the root. 45910 root.finishedWork = null; 45911 root.remainingExpirationTime = commitRoot(finishedWork); 45912} 45913 45914// When working on async work, the reconciler asks the renderer if it should 45915// yield execution. For DOM, we implement this with requestIdleCallback. 45916function shouldYield() { 45917 if (deadline === null) { 45918 return false; 45919 } 45920 if (deadline.timeRemaining() > timeHeuristicForUnitOfWork) { 45921 // Disregard deadline.didTimeout. Only expired work should be flushed 45922 // during a timeout. This path is only hit for non-expired work. 45923 return false; 45924 } 45925 deadlineDidExpire = true; 45926 return true; 45927} 45928 45929function onUncaughtError(error) { 45930 !(nextFlushedRoot !== null) ? invariant(false, 'Should be working on a root. This error is likely caused by a bug in React. Please file an issue.') : void 0; 45931 // Unschedule this root so we don't work on it again until there's 45932 // another update. 45933 nextFlushedRoot.remainingExpirationTime = NoWork; 45934 if (!hasUnhandledError) { 45935 hasUnhandledError = true; 45936 unhandledError = error; 45937 } 45938} 45939 45940function onBlock(remainingExpirationTime) { 45941 !(nextFlushedRoot !== null) ? invariant(false, 'Should be working on a root. This error is likely caused by a bug in React. Please file an issue.') : void 0; 45942 // This root was blocked. Unschedule it until there's another update. 45943 nextFlushedRoot.remainingExpirationTime = remainingExpirationTime; 45944} 45945 45946// TODO: Batching should be implemented at the renderer level, not inside 45947// the reconciler. 45948function batchedUpdates$1(fn, a) { 45949 var previousIsBatchingUpdates = isBatchingUpdates; 45950 isBatchingUpdates = true; 45951 try { 45952 return fn(a); 45953 } finally { 45954 isBatchingUpdates = previousIsBatchingUpdates; 45955 if (!isBatchingUpdates && !isRendering) { 45956 performSyncWork(); 45957 } 45958 } 45959} 45960 45961// TODO: Batching should be implemented at the renderer level, not inside 45962// the reconciler. 45963function unbatchedUpdates(fn, a) { 45964 if (isBatchingUpdates && !isUnbatchingUpdates) { 45965 isUnbatchingUpdates = true; 45966 try { 45967 return fn(a); 45968 } finally { 45969 isUnbatchingUpdates = false; 45970 } 45971 } 45972 return fn(a); 45973} 45974 45975// TODO: Batching should be implemented at the renderer level, not within 45976// the reconciler. 45977function flushSync(fn, a) { 45978 !!isRendering ? invariant(false, 'flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering.') : void 0; 45979 var previousIsBatchingUpdates = isBatchingUpdates; 45980 isBatchingUpdates = true; 45981 try { 45982 return syncUpdates(fn, a); 45983 } finally { 45984 isBatchingUpdates = previousIsBatchingUpdates; 45985 performSyncWork(); 45986 } 45987} 45988 45989function interactiveUpdates$1(fn, a, b) { 45990 if (isBatchingInteractiveUpdates) { 45991 return fn(a, b); 45992 } 45993 // If there are any pending interactive updates, synchronously flush them. 45994 // This needs to happen before we read any handlers, because the effect of 45995 // the previous event may influence which handlers are called during 45996 // this event. 45997 if (!isBatchingUpdates && !isRendering && lowestPendingInteractiveExpirationTime !== NoWork) { 45998 // Synchronously flush pending interactive updates. 45999 performWork(lowestPendingInteractiveExpirationTime, false, null); 46000 lowestPendingInteractiveExpirationTime = NoWork; 46001 } 46002 var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates; 46003 var previousIsBatchingUpdates = isBatchingUpdates; 46004 isBatchingInteractiveUpdates = true; 46005 isBatchingUpdates = true; 46006 try { 46007 return fn(a, b); 46008 } finally { 46009 isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates; 46010 isBatchingUpdates = previousIsBatchingUpdates; 46011 if (!isBatchingUpdates && !isRendering) { 46012 performSyncWork(); 46013 } 46014 } 46015} 46016 46017function flushInteractiveUpdates$1() { 46018 if (!isRendering && lowestPendingInteractiveExpirationTime !== NoWork) { 46019 // Synchronously flush pending interactive updates. 46020 performWork(lowestPendingInteractiveExpirationTime, false, null); 46021 lowestPendingInteractiveExpirationTime = NoWork; 46022 } 46023} 46024 46025function flushControlled(fn) { 46026 var previousIsBatchingUpdates = isBatchingUpdates; 46027 isBatchingUpdates = true; 46028 try { 46029 syncUpdates(fn); 46030 } finally { 46031 isBatchingUpdates = previousIsBatchingUpdates; 46032 if (!isBatchingUpdates && !isRendering) { 46033 performWork(Sync, false, null); 46034 } 46035 } 46036} 46037 46038// 0 is PROD, 1 is DEV. 46039// Might add PROFILE later. 46040 46041 46042var didWarnAboutNestedUpdates = void 0; 46043 46044{ 46045 didWarnAboutNestedUpdates = false; 46046} 46047 46048function getContextForSubtree(parentComponent) { 46049 if (!parentComponent) { 46050 return emptyObject; 46051 } 46052 46053 var fiber = get(parentComponent); 46054 var parentContext = findCurrentUnmaskedContext(fiber); 46055 return isContextProvider(fiber) ? processChildContext(fiber, parentContext) : parentContext; 46056} 46057 46058function scheduleRootUpdate(current, element, expirationTime, callback) { 46059 { 46060 if (ReactDebugCurrentFiber.phase === 'render' && ReactDebugCurrentFiber.current !== null && !didWarnAboutNestedUpdates) { 46061 didWarnAboutNestedUpdates = true; 46062 warning(false, 'Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentName(ReactDebugCurrentFiber.current) || 'Unknown'); 46063 } 46064 } 46065 46066 var update = createUpdate(expirationTime); 46067 // Caution: React DevTools currently depends on this property 46068 // being called "element". 46069 update.payload = { element: element }; 46070 46071 callback = callback === undefined ? null : callback; 46072 if (callback !== null) { 46073 !(typeof callback === 'function') ? warning(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0; 46074 update.callback = callback; 46075 } 46076 enqueueUpdate(current, update, expirationTime); 46077 46078 scheduleWork$1(current, expirationTime); 46079 return expirationTime; 46080} 46081 46082function updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, callback) { 46083 // TODO: If this is a nested container, this won't be the root. 46084 var current = container.current; 46085 46086 { 46087 if (ReactFiberInstrumentation_1.debugTool) { 46088 if (current.alternate === null) { 46089 ReactFiberInstrumentation_1.debugTool.onMountContainer(container); 46090 } else if (element === null) { 46091 ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container); 46092 } else { 46093 ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container); 46094 } 46095 } 46096 } 46097 46098 var context = getContextForSubtree(parentComponent); 46099 if (container.context === null) { 46100 container.context = context; 46101 } else { 46102 container.pendingContext = context; 46103 } 46104 46105 return scheduleRootUpdate(current, element, expirationTime, callback); 46106} 46107 46108function findHostInstance(component) { 46109 var fiber = get(component); 46110 if (fiber === undefined) { 46111 if (typeof component.render === 'function') { 46112 invariant(false, 'Unable to find node on an unmounted component.'); 46113 } else { 46114 invariant(false, 'Argument appears to not be a ReactComponent. Keys: %s', Object.keys(component)); 46115 } 46116 } 46117 var hostFiber = findCurrentHostFiber(fiber); 46118 if (hostFiber === null) { 46119 return null; 46120 } 46121 return hostFiber.stateNode; 46122} 46123 46124function createContainer(containerInfo, isAsync, hydrate) { 46125 return createFiberRoot(containerInfo, isAsync, hydrate); 46126} 46127 46128function updateContainer(element, container, parentComponent, callback) { 46129 var current = container.current; 46130 var currentTime = recalculateCurrentTime(); 46131 var expirationTime = computeExpirationForFiber(currentTime, current); 46132 return updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, callback); 46133} 46134 46135function getPublicRootInstance(container) { 46136 var containerFiber = container.current; 46137 if (!containerFiber.child) { 46138 return null; 46139 } 46140 switch (containerFiber.child.tag) { 46141 case HostComponent: 46142 return getPublicInstance(containerFiber.child.stateNode); 46143 default: 46144 return containerFiber.child.stateNode; 46145 } 46146} 46147 46148function findHostInstanceWithNoPortals(fiber) { 46149 var hostFiber = findCurrentHostFiberWithNoPortals(fiber); 46150 if (hostFiber === null) { 46151 return null; 46152 } 46153 return hostFiber.stateNode; 46154} 46155 46156function injectIntoDevTools(devToolsConfig) { 46157 var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; 46158 46159 return injectInternals(_assign({}, devToolsConfig, { 46160 findHostInstanceByFiber: function (fiber) { 46161 var hostFiber = findCurrentHostFiber(fiber); 46162 if (hostFiber === null) { 46163 return null; 46164 } 46165 return hostFiber.stateNode; 46166 }, 46167 findFiberByHostInstance: function (instance) { 46168 if (!findFiberByHostInstance) { 46169 // Might not be implemented by the renderer. 46170 return null; 46171 } 46172 return findFiberByHostInstance(instance); 46173 } 46174 })); 46175} 46176 46177// This file intentionally does *not* have the Flow annotation. 46178// Don't add it. See `./inline-typed.js` for an explanation. 46179 46180 46181 46182var DOMRenderer = Object.freeze({ 46183 updateContainerAtExpirationTime: updateContainerAtExpirationTime, 46184 createContainer: createContainer, 46185 updateContainer: updateContainer, 46186 flushRoot: flushRoot, 46187 requestWork: requestWork, 46188 computeUniqueAsyncExpiration: computeUniqueAsyncExpiration, 46189 batchedUpdates: batchedUpdates$1, 46190 unbatchedUpdates: unbatchedUpdates, 46191 deferredUpdates: deferredUpdates, 46192 syncUpdates: syncUpdates, 46193 interactiveUpdates: interactiveUpdates$1, 46194 flushInteractiveUpdates: flushInteractiveUpdates$1, 46195 flushControlled: flushControlled, 46196 flushSync: flushSync, 46197 getPublicRootInstance: getPublicRootInstance, 46198 findHostInstance: findHostInstance, 46199 findHostInstanceWithNoPortals: findHostInstanceWithNoPortals, 46200 injectIntoDevTools: injectIntoDevTools 46201}); 46202 46203function createPortal$1(children, containerInfo, 46204// TODO: figure out the API for cross-renderer implementation. 46205implementation) { 46206 var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; 46207 46208 return { 46209 // This tag allow us to uniquely identify this as a React Portal 46210 $$typeof: REACT_PORTAL_TYPE, 46211 key: key == null ? null : '' + key, 46212 children: children, 46213 containerInfo: containerInfo, 46214 implementation: implementation 46215 }; 46216} 46217 46218// TODO: this is special because it gets imported during build. 46219 46220var ReactVersion = '16.4.1'; 46221 46222// TODO: This type is shared between the reconciler and ReactDOM, but will 46223// eventually be lifted out to the renderer. 46224var topLevelUpdateWarnings = void 0; 46225var warnOnInvalidCallback = void 0; 46226var didWarnAboutUnstableCreatePortal = false; 46227 46228{ 46229 if (typeof Map !== 'function' || 46230 // $FlowIssue Flow incorrectly thinks Map has no prototype 46231 Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || 46232 // $FlowIssue Flow incorrectly thinks Set has no prototype 46233 Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') { 46234 warning(false, 'React depends on Map and Set built-in types. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); 46235 } 46236 46237 topLevelUpdateWarnings = function (container) { 46238 if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) { 46239 var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current); 46240 if (hostInstance) { 46241 !(hostInstance.parentNode === container) ? warning(false, 'render(...): It looks like the React-rendered content of this ' + 'container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + 'ReactDOM.unmountComponentAtNode to empty a container.') : void 0; 46242 } 46243 } 46244 46245 var isRootRenderedBySomeReact = !!container._reactRootContainer; 46246 var rootEl = getReactRootElementInContainer(container); 46247 var hasNonRootReactChild = !!(rootEl && getInstanceFromNode$1(rootEl)); 46248 46249 !(!hasNonRootReactChild || isRootRenderedBySomeReact) ? warning(false, 'render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.') : void 0; 46250 46251 !(container.nodeType !== ELEMENT_NODE || !container.tagName || container.tagName.toUpperCase() !== 'BODY') ? warning(false, 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : void 0; 46252 }; 46253 46254 warnOnInvalidCallback = function (callback, callerName) { 46255 !(callback === null || typeof callback === 'function') ? warning(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback) : void 0; 46256 }; 46257} 46258 46259injection$2.injectFiberControlledHostComponent(ReactDOMFiberComponent); 46260 46261function ReactBatch(root) { 46262 var expirationTime = computeUniqueAsyncExpiration(); 46263 this._expirationTime = expirationTime; 46264 this._root = root; 46265 this._next = null; 46266 this._callbacks = null; 46267 this._didComplete = false; 46268 this._hasChildren = false; 46269 this._children = null; 46270 this._defer = true; 46271} 46272ReactBatch.prototype.render = function (children) { 46273 !this._defer ? invariant(false, 'batch.render: Cannot render a batch that already committed.') : void 0; 46274 this._hasChildren = true; 46275 this._children = children; 46276 var internalRoot = this._root._internalRoot; 46277 var expirationTime = this._expirationTime; 46278 var work = new ReactWork(); 46279 updateContainerAtExpirationTime(children, internalRoot, null, expirationTime, work._onCommit); 46280 return work; 46281}; 46282ReactBatch.prototype.then = function (onComplete) { 46283 if (this._didComplete) { 46284 onComplete(); 46285 return; 46286 } 46287 var callbacks = this._callbacks; 46288 if (callbacks === null) { 46289 callbacks = this._callbacks = []; 46290 } 46291 callbacks.push(onComplete); 46292}; 46293ReactBatch.prototype.commit = function () { 46294 var internalRoot = this._root._internalRoot; 46295 var firstBatch = internalRoot.firstBatch; 46296 !(this._defer && firstBatch !== null) ? invariant(false, 'batch.commit: Cannot commit a batch multiple times.') : void 0; 46297 46298 if (!this._hasChildren) { 46299 // This batch is empty. Return. 46300 this._next = null; 46301 this._defer = false; 46302 return; 46303 } 46304 46305 var expirationTime = this._expirationTime; 46306 46307 // Ensure this is the first batch in the list. 46308 if (firstBatch !== this) { 46309 // This batch is not the earliest batch. We need to move it to the front. 46310 // Update its expiration time to be the expiration time of the earliest 46311 // batch, so that we can flush it without flushing the other batches. 46312 if (this._hasChildren) { 46313 expirationTime = this._expirationTime = firstBatch._expirationTime; 46314 // Rendering this batch again ensures its children will be the final state 46315 // when we flush (updates are processed in insertion order: last 46316 // update wins). 46317 // TODO: This forces a restart. Should we print a warning? 46318 this.render(this._children); 46319 } 46320 46321 // Remove the batch from the list. 46322 var previous = null; 46323 var batch = firstBatch; 46324 while (batch !== this) { 46325 previous = batch; 46326 batch = batch._next; 46327 } 46328 !(previous !== null) ? invariant(false, 'batch.commit: Cannot commit a batch multiple times.') : void 0; 46329 previous._next = batch._next; 46330 46331 // Add it to the front. 46332 this._next = firstBatch; 46333 firstBatch = internalRoot.firstBatch = this; 46334 } 46335 46336 // Synchronously flush all the work up to this batch's expiration time. 46337 this._defer = false; 46338 flushRoot(internalRoot, expirationTime); 46339 46340 // Pop the batch from the list. 46341 var next = this._next; 46342 this._next = null; 46343 firstBatch = internalRoot.firstBatch = next; 46344 46345 // Append the next earliest batch's children to the update queue. 46346 if (firstBatch !== null && firstBatch._hasChildren) { 46347 firstBatch.render(firstBatch._children); 46348 } 46349}; 46350ReactBatch.prototype._onComplete = function () { 46351 if (this._didComplete) { 46352 return; 46353 } 46354 this._didComplete = true; 46355 var callbacks = this._callbacks; 46356 if (callbacks === null) { 46357 return; 46358 } 46359 // TODO: Error handling. 46360 for (var i = 0; i < callbacks.length; i++) { 46361 var _callback = callbacks[i]; 46362 _callback(); 46363 } 46364}; 46365 46366function ReactWork() { 46367 this._callbacks = null; 46368 this._didCommit = false; 46369 // TODO: Avoid need to bind by replacing callbacks in the update queue with 46370 // list of Work objects. 46371 this._onCommit = this._onCommit.bind(this); 46372} 46373ReactWork.prototype.then = function (onCommit) { 46374 if (this._didCommit) { 46375 onCommit(); 46376 return; 46377 } 46378 var callbacks = this._callbacks; 46379 if (callbacks === null) { 46380 callbacks = this._callbacks = []; 46381 } 46382 callbacks.push(onCommit); 46383}; 46384ReactWork.prototype._onCommit = function () { 46385 if (this._didCommit) { 46386 return; 46387 } 46388 this._didCommit = true; 46389 var callbacks = this._callbacks; 46390 if (callbacks === null) { 46391 return; 46392 } 46393 // TODO: Error handling. 46394 for (var i = 0; i < callbacks.length; i++) { 46395 var _callback2 = callbacks[i]; 46396 !(typeof _callback2 === 'function') ? invariant(false, 'Invalid argument passed as callback. Expected a function. Instead received: %s', _callback2) : void 0; 46397 _callback2(); 46398 } 46399}; 46400 46401function ReactRoot(container, isAsync, hydrate) { 46402 var root = createContainer(container, isAsync, hydrate); 46403 this._internalRoot = root; 46404} 46405ReactRoot.prototype.render = function (children, callback) { 46406 var root = this._internalRoot; 46407 var work = new ReactWork(); 46408 callback = callback === undefined ? null : callback; 46409 { 46410 warnOnInvalidCallback(callback, 'render'); 46411 } 46412 if (callback !== null) { 46413 work.then(callback); 46414 } 46415 updateContainer(children, root, null, work._onCommit); 46416 return work; 46417}; 46418ReactRoot.prototype.unmount = function (callback) { 46419 var root = this._internalRoot; 46420 var work = new ReactWork(); 46421 callback = callback === undefined ? null : callback; 46422 { 46423 warnOnInvalidCallback(callback, 'render'); 46424 } 46425 if (callback !== null) { 46426 work.then(callback); 46427 } 46428 updateContainer(null, root, null, work._onCommit); 46429 return work; 46430}; 46431ReactRoot.prototype.legacy_renderSubtreeIntoContainer = function (parentComponent, children, callback) { 46432 var root = this._internalRoot; 46433 var work = new ReactWork(); 46434 callback = callback === undefined ? null : callback; 46435 { 46436 warnOnInvalidCallback(callback, 'render'); 46437 } 46438 if (callback !== null) { 46439 work.then(callback); 46440 } 46441 updateContainer(children, root, parentComponent, work._onCommit); 46442 return work; 46443}; 46444ReactRoot.prototype.createBatch = function () { 46445 var batch = new ReactBatch(this); 46446 var expirationTime = batch._expirationTime; 46447 46448 var internalRoot = this._internalRoot; 46449 var firstBatch = internalRoot.firstBatch; 46450 if (firstBatch === null) { 46451 internalRoot.firstBatch = batch; 46452 batch._next = null; 46453 } else { 46454 // Insert sorted by expiration time then insertion order 46455 var insertAfter = null; 46456 var insertBefore = firstBatch; 46457 while (insertBefore !== null && insertBefore._expirationTime <= expirationTime) { 46458 insertAfter = insertBefore; 46459 insertBefore = insertBefore._next; 46460 } 46461 batch._next = insertBefore; 46462 if (insertAfter !== null) { 46463 insertAfter._next = batch; 46464 } 46465 } 46466 46467 return batch; 46468}; 46469 46470/** 46471 * True if the supplied DOM node is a valid node element. 46472 * 46473 * @param {?DOMElement} node The candidate DOM node. 46474 * @return {boolean} True if the DOM is a valid DOM node. 46475 * @internal 46476 */ 46477function isValidContainer(node) { 46478 return !!(node && (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE || node.nodeType === COMMENT_NODE && node.nodeValue === ' react-mount-point-unstable ')); 46479} 46480 46481function getReactRootElementInContainer(container) { 46482 if (!container) { 46483 return null; 46484 } 46485 46486 if (container.nodeType === DOCUMENT_NODE) { 46487 return container.documentElement; 46488 } else { 46489 return container.firstChild; 46490 } 46491} 46492 46493function shouldHydrateDueToLegacyHeuristic(container) { 46494 var rootElement = getReactRootElementInContainer(container); 46495 return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME)); 46496} 46497 46498injection$3.injectRenderer(DOMRenderer); 46499 46500var warnedAboutHydrateAPI = false; 46501 46502function legacyCreateRootFromDOMContainer(container, forceHydrate) { 46503 var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container); 46504 // First clear any existing content. 46505 if (!shouldHydrate) { 46506 var warned = false; 46507 var rootSibling = void 0; 46508 while (rootSibling = container.lastChild) { 46509 { 46510 if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) { 46511 warned = true; 46512 warning(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.'); 46513 } 46514 } 46515 container.removeChild(rootSibling); 46516 } 46517 } 46518 { 46519 if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) { 46520 warnedAboutHydrateAPI = true; 46521 lowPriorityWarning$1(false, 'render(): Calling ReactDOM.render() to hydrate server-rendered markup ' + 'will stop working in React v17. Replace the ReactDOM.render() call ' + 'with ReactDOM.hydrate() if you want React to attach to the server HTML.'); 46522 } 46523 } 46524 // Legacy roots are not async by default. 46525 var isAsync = false; 46526 return new ReactRoot(container, isAsync, shouldHydrate); 46527} 46528 46529function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) { 46530 // TODO: Ensure all entry points contain this check 46531 !isValidContainer(container) ? invariant(false, 'Target container is not a DOM element.') : void 0; 46532 46533 { 46534 topLevelUpdateWarnings(container); 46535 } 46536 46537 // TODO: Without `any` type, Flow says "Property cannot be accessed on any 46538 // member of intersection type." Whyyyyyy. 46539 var root = container._reactRootContainer; 46540 if (!root) { 46541 // Initial mount 46542 root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate); 46543 if (typeof callback === 'function') { 46544 var originalCallback = callback; 46545 callback = function () { 46546 var instance = getPublicRootInstance(root._internalRoot); 46547 originalCallback.call(instance); 46548 }; 46549 } 46550 // Initial mount should not be batched. 46551 unbatchedUpdates(function () { 46552 if (parentComponent != null) { 46553 root.legacy_renderSubtreeIntoContainer(parentComponent, children, callback); 46554 } else { 46555 root.render(children, callback); 46556 } 46557 }); 46558 } else { 46559 if (typeof callback === 'function') { 46560 var _originalCallback = callback; 46561 callback = function () { 46562 var instance = getPublicRootInstance(root._internalRoot); 46563 _originalCallback.call(instance); 46564 }; 46565 } 46566 // Update 46567 if (parentComponent != null) { 46568 root.legacy_renderSubtreeIntoContainer(parentComponent, children, callback); 46569 } else { 46570 root.render(children, callback); 46571 } 46572 } 46573 return getPublicRootInstance(root._internalRoot); 46574} 46575 46576function createPortal(children, container) { 46577 var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 46578 46579 !isValidContainer(container) ? invariant(false, 'Target container is not a DOM element.') : void 0; 46580 // TODO: pass ReactDOM portal implementation as third argument 46581 return createPortal$1(children, container, null, key); 46582} 46583 46584var ReactDOM = { 46585 createPortal: createPortal, 46586 46587 findDOMNode: function (componentOrElement) { 46588 { 46589 var owner = ReactCurrentOwner.current; 46590 if (owner !== null && owner.stateNode !== null) { 46591 var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender; 46592 !warnedAboutRefsInRender ? warning(false, '%s is accessing findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(owner) || 'A component') : void 0; 46593 owner.stateNode._warnedAboutRefsInRender = true; 46594 } 46595 } 46596 if (componentOrElement == null) { 46597 return null; 46598 } 46599 if (componentOrElement.nodeType === ELEMENT_NODE) { 46600 return componentOrElement; 46601 } 46602 46603 return findHostInstance(componentOrElement); 46604 }, 46605 hydrate: function (element, container, callback) { 46606 // TODO: throw or warn if we couldn't hydrate? 46607 return legacyRenderSubtreeIntoContainer(null, element, container, true, callback); 46608 }, 46609 render: function (element, container, callback) { 46610 return legacyRenderSubtreeIntoContainer(null, element, container, false, callback); 46611 }, 46612 unstable_renderSubtreeIntoContainer: function (parentComponent, element, containerNode, callback) { 46613 !(parentComponent != null && has(parentComponent)) ? invariant(false, 'parentComponent must be a valid React Component') : void 0; 46614 return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback); 46615 }, 46616 unmountComponentAtNode: function (container) { 46617 !isValidContainer(container) ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : void 0; 46618 46619 if (container._reactRootContainer) { 46620 { 46621 var rootEl = getReactRootElementInContainer(container); 46622 var renderedByDifferentReact = rootEl && !getInstanceFromNode$1(rootEl); 46623 !!renderedByDifferentReact ? warning(false, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.') : void 0; 46624 } 46625 46626 // Unmount should not be batched. 46627 unbatchedUpdates(function () { 46628 legacyRenderSubtreeIntoContainer(null, null, container, false, function () { 46629 container._reactRootContainer = null; 46630 }); 46631 }); 46632 // If you call unmountComponentAtNode twice in quick succession, you'll 46633 // get `true` twice. That's probably fine? 46634 return true; 46635 } else { 46636 { 46637 var _rootEl = getReactRootElementInContainer(container); 46638 var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode$1(_rootEl)); 46639 46640 // Check if the container itself is a React root node. 46641 var isContainerReactRoot = container.nodeType === 1 && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer; 46642 46643 !!hasNonRootReactChild ? warning(false, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.') : void 0; 46644 } 46645 46646 return false; 46647 } 46648 }, 46649 46650 46651 // Temporary alias since we already shipped React 16 RC with it. 46652 // TODO: remove in React 17. 46653 unstable_createPortal: function () { 46654 if (!didWarnAboutUnstableCreatePortal) { 46655 didWarnAboutUnstableCreatePortal = true; 46656 lowPriorityWarning$1(false, 'The ReactDOM.unstable_createPortal() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactDOM.createPortal() instead. It has the exact same API, ' + 'but without the "unstable_" prefix.'); 46657 } 46658 return createPortal.apply(undefined, arguments); 46659 }, 46660 46661 46662 unstable_batchedUpdates: batchedUpdates$1, 46663 46664 unstable_deferredUpdates: deferredUpdates, 46665 46666 unstable_interactiveUpdates: interactiveUpdates$1, 46667 46668 flushSync: flushSync, 46669 46670 unstable_flushControlled: flushControlled, 46671 46672 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: { 46673 // For TapEventPlugin which is popular in open source 46674 EventPluginHub: EventPluginHub, 46675 // Used by test-utils 46676 EventPluginRegistry: EventPluginRegistry, 46677 EventPropagators: EventPropagators, 46678 ReactControlledComponent: ReactControlledComponent, 46679 ReactDOMComponentTree: ReactDOMComponentTree, 46680 ReactDOMEventListener: ReactDOMEventListener 46681 } 46682}; 46683 46684ReactDOM.unstable_createRoot = function createRoot(container, options) { 46685 var hydrate = options != null && options.hydrate === true; 46686 return new ReactRoot(container, true, hydrate); 46687}; 46688 46689var foundDevTools = injectIntoDevTools({ 46690 findFiberByHostInstance: getClosestInstanceFromNode, 46691 bundleType: 1, 46692 version: ReactVersion, 46693 rendererPackageName: 'react-dom' 46694}); 46695 46696{ 46697 if (!foundDevTools && ExecutionEnvironment.canUseDOM && window.top === window.self) { 46698 // If we're in Chrome or Firefox, provide a download link if not installed. 46699 if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) { 46700 var protocol = window.location.protocol; 46701 // Don't warn in exotic cases like chrome-extension://. 46702 if (/^(https?|file):$/.test(protocol)) { 46703 console.info('%cDownload the React DevTools ' + 'for a better development experience: ' + 'https://fb.me/react-devtools' + (protocol === 'file:' ? '\nYou might need to use a local HTTP server (instead of file://): ' + 'https://fb.me/react-devtools-faq' : ''), 'font-weight:bold'); 46704 } 46705 } 46706 } 46707} 46708 46709 46710 46711var ReactDOM$2 = Object.freeze({ 46712 default: ReactDOM 46713}); 46714 46715var ReactDOM$3 = ( ReactDOM$2 && ReactDOM ) || ReactDOM$2; 46716 46717// TODO: decide on the top-level export form. 46718// This is hacky but makes it work with both Rollup and Jest. 46719var reactDom = ReactDOM$3.default ? ReactDOM$3.default : ReactDOM$3; 46720 46721module.exports = reactDom; 46722 })(); 46723} 46724 46725 46726/***/ }), 46727
vendor: 1,447 bytes, lines 46728-46772
46728/***/ "./node_modules/react-dom/index.js": 46729/*!*****************************************!*\ 46730 !*** ./node_modules/react-dom/index.js ***! 46731 \*****************************************/ 46732/*! no static exports found */ 46733/***/ (function(module, exports, __webpack_require__) { 46734 46735"use strict"; 46736 46737 46738function checkDCE() { 46739 /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ 46740 if ( 46741 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' || 46742 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function' 46743 ) { 46744 return; 46745 } 46746 if (true) { 46747 // This branch is unreachable because this function is only called 46748 // in production, but the condition is true only in development. 46749 // Therefore if the branch is still here, dead code elimination wasn't 46750 // properly applied. 46751 // Don't change the message. React DevTools relies on it. Also make sure 46752 // this message doesn't occur elsewhere in this function, or it will cause 46753 // a false positive. 46754 throw new Error('^_^'); 46755 } 46756 try { 46757 // Verify that the code above has been dead code eliminated (DCE'd). 46758 __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE); 46759 } catch (err) { 46760 // DevTools shouldn't crash React, no matter what. 46761 // We should still report in case we break this code. 46762 console.error(err); 46763 } 46764} 46765 46766if (false) {} else { 46767 module.exports = __webpack_require__(/*! ./cjs/react-dom.development.js */ "./node_modules/react-dom/cjs/react-dom.development.js"); 46768} 46769 46770 46771/***/ }), 46772
vendor: 4,700 bytes, lines 46773-46863
46773/***/ "./node_modules/react-redux/es/components/Provider.js": 46774/*!************************************************************!*\ 46775 !*** ./node_modules/react-redux/es/components/Provider.js ***! 46776 \************************************************************/ 46777/*! exports provided: createProvider, default */ 46778/***/ (function(module, __webpack_exports__, __webpack_require__) { 46779 46780"use strict"; 46781__webpack_require__.r(__webpack_exports__); 46782/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createProvider", function() { return createProvider; }); 46783/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); 46784/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 46785/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js"); 46786/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); 46787/* harmony import */ var _utils_PropTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/PropTypes */ "./node_modules/react-redux/es/utils/PropTypes.js"); 46788/* harmony import */ var _utils_warning__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/warning */ "./node_modules/react-redux/es/utils/warning.js"); 46789function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 46790 46791function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 46792 46793function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 46794 46795 46796 46797 46798 46799 46800var didWarnAboutReceivingStore = false; 46801function warnAboutReceivingStore() { 46802 if (didWarnAboutReceivingStore) { 46803 return; 46804 } 46805 didWarnAboutReceivingStore = true; 46806 46807 Object(_utils_warning__WEBPACK_IMPORTED_MODULE_3__["default"])('<Provider> does not support changing `store` on the fly. ' + 'It is most likely that you see this error because you updated to ' + 'Redux 2.x and React Redux 2.x which no longer hot reload reducers ' + 'automatically. See https://github.com/reactjs/react-redux/releases/' + 'tag/v2.0.0 for the migration instructions.'); 46808} 46809 46810function createProvider() { 46811 var _Provider$childContex; 46812 46813 var storeKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'store'; 46814 var subKey = arguments[1]; 46815 46816 var subscriptionKey = subKey || storeKey + 'Subscription'; 46817 46818 var Provider = function (_Component) { 46819 _inherits(Provider, _Component); 46820 46821 Provider.prototype.getChildContext = function getChildContext() { 46822 var _ref; 46823 46824 return _ref = {}, _ref[storeKey] = this[storeKey], _ref[subscriptionKey] = null, _ref; 46825 }; 46826 46827 function Provider(props, context) { 46828 _classCallCheck(this, Provider); 46829 46830 var _this = _possibleConstructorReturn(this, _Component.call(this, props, context)); 46831 46832 _this[storeKey] = props.store; 46833 return _this; 46834 } 46835 46836 Provider.prototype.render = function render() { 46837 return react__WEBPACK_IMPORTED_MODULE_0__["Children"].only(this.props.children); 46838 }; 46839 46840 return Provider; 46841 }(react__WEBPACK_IMPORTED_MODULE_0__["Component"]); 46842 46843 if (true) { 46844 Provider.prototype.componentWillReceiveProps = function (nextProps) { 46845 if (this[storeKey] !== nextProps.store) { 46846 warnAboutReceivingStore(); 46847 } 46848 }; 46849 } 46850 46851 Provider.propTypes = { 46852 store: _utils_PropTypes__WEBPACK_IMPORTED_MODULE_2__["storeShape"].isRequired, 46853 children: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.element.isRequired 46854 }; 46855 Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[storeKey] = _utils_PropTypes__WEBPACK_IMPORTED_MODULE_2__["storeShape"].isRequired, _Provider$childContex[subscriptionKey] = _utils_PropTypes__WEBPACK_IMPORTED_MODULE_2__["subscriptionShape"], _Provider$childContex); 46856 46857 return Provider; 46858} 46859 46860/* harmony default export */ __webpack_exports__["default"] = (createProvider()); 46861 46862/***/ }), 46863
vendor: 16,294 bytes, lines 46864-47173
46864/***/ "./node_modules/react-redux/es/components/connectAdvanced.js": 46865/*!*******************************************************************!*\ 46866 !*** ./node_modules/react-redux/es/components/connectAdvanced.js ***! 46867 \*******************************************************************/ 46868/*! exports provided: default */ 46869/***/ (function(module, __webpack_exports__, __webpack_require__) { 46870 46871"use strict"; 46872__webpack_require__.r(__webpack_exports__); 46873/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return connectAdvanced; }); 46874/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! hoist-non-react-statics */ "./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js"); 46875/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_0__); 46876/* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! invariant */ "./node_modules/invariant/browser.js"); 46877/* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(invariant__WEBPACK_IMPORTED_MODULE_1__); 46878/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); 46879/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__); 46880/* harmony import */ var _utils_Subscription__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/Subscription */ "./node_modules/react-redux/es/utils/Subscription.js"); 46881/* harmony import */ var _utils_PropTypes__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/PropTypes */ "./node_modules/react-redux/es/utils/PropTypes.js"); 46882var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 46883 46884function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 46885 46886function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 46887 46888function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 46889 46890function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } 46891 46892 46893 46894 46895 46896 46897 46898 46899var hotReloadingVersion = 0; 46900var dummyState = {}; 46901function noop() {} 46902function makeSelectorStateful(sourceSelector, store) { 46903 // wrap the selector in an object that tracks its results between runs. 46904 var selector = { 46905 run: function runComponentSelector(props) { 46906 try { 46907 var nextProps = sourceSelector(store.getState(), props); 46908 if (nextProps !== selector.props || selector.error) { 46909 selector.shouldComponentUpdate = true; 46910 selector.props = nextProps; 46911 selector.error = null; 46912 } 46913 } catch (error) { 46914 selector.shouldComponentUpdate = true; 46915 selector.error = error; 46916 } 46917 } 46918 }; 46919 46920 return selector; 46921} 46922 46923function connectAdvanced( 46924/* 46925 selectorFactory is a func that is responsible for returning the selector function used to 46926 compute new props from state, props, and dispatch. For example: 46927 export default connectAdvanced((dispatch, options) => (state, props) => ({ 46928 thing: state.things[props.thingId], 46929 saveThing: fields => dispatch(actionCreators.saveThing(props.thingId, fields)), 46930 }))(YourComponent) 46931 Access to dispatch is provided to the factory so selectorFactories can bind actionCreators 46932 outside of their selector as an optimization. Options passed to connectAdvanced are passed to 46933 the selectorFactory, along with displayName and WrappedComponent, as the second argument. 46934 Note that selectorFactory is responsible for all caching/memoization of inbound and outbound 46935 props. Do not use connectAdvanced directly without memoizing results between calls to your 46936 selector, otherwise the Connect component will re-render on every state or props change. 46937*/ 46938selectorFactory) { 46939 var _contextTypes, _childContextTypes; 46940 46941 var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, 46942 _ref$getDisplayName = _ref.getDisplayName, 46943 getDisplayName = _ref$getDisplayName === undefined ? function (name) { 46944 return 'ConnectAdvanced(' + name + ')'; 46945 } : _ref$getDisplayName, 46946 _ref$methodName = _ref.methodName, 46947 methodName = _ref$methodName === undefined ? 'connectAdvanced' : _ref$methodName, 46948 _ref$renderCountProp = _ref.renderCountProp, 46949 renderCountProp = _ref$renderCountProp === undefined ? undefined : _ref$renderCountProp, 46950 _ref$shouldHandleStat = _ref.shouldHandleStateChanges, 46951 shouldHandleStateChanges = _ref$shouldHandleStat === undefined ? true : _ref$shouldHandleStat, 46952 _ref$storeKey = _ref.storeKey, 46953 storeKey = _ref$storeKey === undefined ? 'store' : _ref$storeKey, 46954 _ref$withRef = _ref.withRef, 46955 withRef = _ref$withRef === undefined ? false : _ref$withRef, 46956 connectOptions = _objectWithoutProperties(_ref, ['getDisplayName', 'methodName', 'renderCountProp', 'shouldHandleStateChanges', 'storeKey', 'withRef']); 46957 46958 var subscriptionKey = storeKey + 'Subscription'; 46959 var version = hotReloadingVersion++; 46960 46961 var contextTypes = (_contextTypes = {}, _contextTypes[storeKey] = _utils_PropTypes__WEBPACK_IMPORTED_MODULE_4__["storeShape"], _contextTypes[subscriptionKey] = _utils_PropTypes__WEBPACK_IMPORTED_MODULE_4__["subscriptionShape"], _contextTypes); 46962 var childContextTypes = (_childContextTypes = {}, _childContextTypes[subscriptionKey] = _utils_PropTypes__WEBPACK_IMPORTED_MODULE_4__["subscriptionShape"], _childContextTypes); 46963 46964 return function wrapWithConnect(WrappedComponent) { 46965 invariant__WEBPACK_IMPORTED_MODULE_1___default()(typeof WrappedComponent == 'function', 'You must pass a component to the function returned by ' + (methodName + '. Instead received ' + JSON.stringify(WrappedComponent))); 46966 46967 var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component'; 46968 46969 var displayName = getDisplayName(wrappedComponentName); 46970 46971 var selectorFactoryOptions = _extends({}, connectOptions, { 46972 getDisplayName: getDisplayName, 46973 methodName: methodName, 46974 renderCountProp: renderCountProp, 46975 shouldHandleStateChanges: shouldHandleStateChanges, 46976 storeKey: storeKey, 46977 withRef: withRef, 46978 displayName: displayName, 46979 wrappedComponentName: wrappedComponentName, 46980 WrappedComponent: WrappedComponent 46981 }); 46982 46983 var Connect = function (_Component) { 46984 _inherits(Connect, _Component); 46985 46986 function Connect(props, context) { 46987 _classCallCheck(this, Connect); 46988 46989 var _this = _possibleConstructorReturn(this, _Component.call(this, props, context)); 46990 46991 _this.version = version; 46992 _this.state = {}; 46993 _this.renderCount = 0; 46994 _this.store = props[storeKey] || context[storeKey]; 46995 _this.propsMode = Boolean(props[storeKey]); 46996 _this.setWrappedInstance = _this.setWrappedInstance.bind(_this); 46997 46998 invariant__WEBPACK_IMPORTED_MODULE_1___default()(_this.store, 'Could not find "' + storeKey + '" in either the context or props of ' + ('"' + displayName + '". Either wrap the root component in a <Provider>, ') + ('or explicitly pass "' + storeKey + '" as a prop to "' + displayName + '".')); 46999 47000 _this.initSelector(); 47001 _this.initSubscription(); 47002 return _this; 47003 } 47004 47005 Connect.prototype.getChildContext = function getChildContext() { 47006 var _ref2; 47007 47008 // If this component received store from props, its subscription should be transparent 47009 // to any descendants receiving store+subscription from context; it passes along 47010 // subscription passed to it. Otherwise, it shadows the parent subscription, which allows 47011 // Connect to control ordering of notifications to flow top-down. 47012 var subscription = this.propsMode ? null : this.subscription; 47013 return _ref2 = {}, _ref2[subscriptionKey] = subscription || this.context[subscriptionKey], _ref2; 47014 }; 47015 47016 Connect.prototype.componentDidMount = function componentDidMount() { 47017 if (!shouldHandleStateChanges) return; 47018 47019 // componentWillMount fires during server side rendering, but componentDidMount and 47020 // componentWillUnmount do not. Because of this, trySubscribe happens during ...didMount. 47021 // Otherwise, unsubscription would never take place during SSR, causing a memory leak. 47022 // To handle the case where a child component may have triggered a state change by 47023 // dispatching an action in its componentWillMount, we have to re-run the select and maybe 47024 // re-render. 47025 this.subscription.trySubscribe(); 47026 this.selector.run(this.props); 47027 if (this.selector.shouldComponentUpdate) this.forceUpdate(); 47028 }; 47029 47030 Connect.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { 47031 this.selector.run(nextProps); 47032 }; 47033 47034 Connect.prototype.shouldComponentUpdate = function shouldComponentUpdate() { 47035 return this.selector.shouldComponentUpdate; 47036 }; 47037 47038 Connect.prototype.componentWillUnmount = function componentWillUnmount() { 47039 if (this.subscription) this.subscription.tryUnsubscribe(); 47040 this.subscription = null; 47041 this.notifyNestedSubs = noop; 47042 this.store = null; 47043 this.selector.run = noop; 47044 this.selector.shouldComponentUpdate = false; 47045 }; 47046 47047 Connect.prototype.getWrappedInstance = function getWrappedInstance() { 47048 invariant__WEBPACK_IMPORTED_MODULE_1___default()(withRef, 'To access the wrapped instance, you need to specify ' + ('{ withRef: true } in the options argument of the ' + methodName + '() call.')); 47049 return this.wrappedInstance; 47050 }; 47051 47052 Connect.prototype.setWrappedInstance = function setWrappedInstance(ref) { 47053 this.wrappedInstance = ref; 47054 }; 47055 47056 Connect.prototype.initSelector = function initSelector() { 47057 var sourceSelector = selectorFactory(this.store.dispatch, selectorFactoryOptions); 47058 this.selector = makeSelectorStateful(sourceSelector, this.store); 47059 this.selector.run(this.props); 47060 }; 47061 47062 Connect.prototype.initSubscription = function initSubscription() { 47063 if (!shouldHandleStateChanges) return; 47064 47065 // parentSub's source should match where store came from: props vs. context. A component 47066 // connected to the store via props shouldn't use subscription from context, or vice versa. 47067 var parentSub = (this.propsMode ? this.props : this.context)[subscriptionKey]; 47068 this.subscription = new _utils_Subscription__WEBPACK_IMPORTED_MODULE_3__["default"](this.store, parentSub, this.onStateChange.bind(this)); 47069 47070 // `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in 47071 // the middle of the notification loop, where `this.subscription` will then be null. An 47072 // extra null check every change can be avoided by copying the method onto `this` and then 47073 // replacing it with a no-op on unmount. This can probably be avoided if Subscription's 47074 // listeners logic is changed to not call listeners that have been unsubscribed in the 47075 // middle of the notification loop. 47076 this.notifyNestedSubs = this.subscription.notifyNestedSubs.bind(this.subscription); 47077 }; 47078 47079 Connect.prototype.onStateChange = function onStateChange() { 47080 this.selector.run(this.props); 47081 47082 if (!this.selector.shouldComponentUpdate) { 47083 this.notifyNestedSubs(); 47084 } else { 47085 this.componentDidUpdate = this.notifyNestedSubsOnComponentDidUpdate; 47086 this.setState(dummyState); 47087 } 47088 }; 47089 47090 Connect.prototype.notifyNestedSubsOnComponentDidUpdate = function notifyNestedSubsOnComponentDidUpdate() { 47091 // `componentDidUpdate` is conditionally implemented when `onStateChange` determines it 47092 // needs to notify nested subs. Once called, it unimplements itself until further state 47093 // changes occur. Doing it this way vs having a permanent `componentDidUpdate` that does 47094 // a boolean check every time avoids an extra method call most of the time, resulting 47095 // in some perf boost. 47096 this.componentDidUpdate = undefined; 47097 this.notifyNestedSubs(); 47098 }; 47099 47100 Connect.prototype.isSubscribed = function isSubscribed() { 47101 return Boolean(this.subscription) && this.subscription.isSubscribed(); 47102 }; 47103 47104 Connect.prototype.addExtraProps = function addExtraProps(props) { 47105 if (!withRef && !renderCountProp && !(this.propsMode && this.subscription)) return props; 47106 // make a shallow copy so that fields added don't leak to the original selector. 47107 // this is especially important for 'ref' since that's a reference back to the component 47108 // instance. a singleton memoized selector would then be holding a reference to the 47109 // instance, preventing the instance from being garbage collected, and that would be bad 47110 var withExtras = _extends({}, props); 47111 if (withRef) withExtras.ref = this.setWrappedInstance; 47112 if (renderCountProp) withExtras[renderCountProp] = this.renderCount++; 47113 if (this.propsMode && this.subscription) withExtras[subscriptionKey] = this.subscription; 47114 return withExtras; 47115 }; 47116 47117 Connect.prototype.render = function render() { 47118 var selector = this.selector; 47119 selector.shouldComponentUpdate = false; 47120 47121 if (selector.error) { 47122 throw selector.error; 47123 } else { 47124 return Object(react__WEBPACK_IMPORTED_MODULE_2__["createElement"])(WrappedComponent, this.addExtraProps(selector.props)); 47125 } 47126 }; 47127 47128 return Connect; 47129 }(react__WEBPACK_IMPORTED_MODULE_2__["Component"]); 47130 47131 Connect.WrappedComponent = WrappedComponent; 47132 Connect.displayName = displayName; 47133 Connect.childContextTypes = childContextTypes; 47134 Connect.contextTypes = contextTypes; 47135 Connect.propTypes = contextTypes; 47136 47137 if (true) { 47138 Connect.prototype.componentWillUpdate = function componentWillUpdate() { 47139 var _this2 = this; 47140 47141 // We are hot reloading! 47142 if (this.version !== version) { 47143 this.version = version; 47144 this.initSelector(); 47145 47146 // If any connected descendants don't hot reload (and resubscribe in the process), their 47147 // listeners will be lost when we unsubscribe. Unfortunately, by copying over all 47148 // listeners, this does mean that the old versions of connected descendants will still be 47149 // notified of state changes; however, their onStateChange function is a no-op so this 47150 // isn't a huge deal. 47151 var oldListeners = []; 47152 47153 if (this.subscription) { 47154 oldListeners = this.subscription.listeners.get(); 47155 this.subscription.tryUnsubscribe(); 47156 } 47157 this.initSubscription(); 47158 if (shouldHandleStateChanges) { 47159 this.subscription.trySubscribe(); 47160 oldListeners.forEach(function (listener) { 47161 return _this2.subscription.listeners.subscribe(listener); 47162 }); 47163 } 47164 } 47165 }; 47166 } 47167 47168 return hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_0___default()(Connect, WrappedComponent); 47169 }; 47170} 47171 47172/***/ }), 47173
vendor: 6,993 bytes, lines 47174-47295
47174/***/ "./node_modules/react-redux/es/connect/connect.js": 47175/*!********************************************************!*\ 47176 !*** ./node_modules/react-redux/es/connect/connect.js ***! 47177 \********************************************************/ 47178/*! exports provided: createConnect, default */ 47179/***/ (function(module, __webpack_exports__, __webpack_require__) { 47180 47181"use strict"; 47182__webpack_require__.r(__webpack_exports__); 47183/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createConnect", function() { return createConnect; }); 47184/* harmony import */ var _components_connectAdvanced__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../components/connectAdvanced */ "./node_modules/react-redux/es/components/connectAdvanced.js"); 47185/* harmony import */ var _utils_shallowEqual__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/shallowEqual */ "./node_modules/react-redux/es/utils/shallowEqual.js"); 47186/* harmony import */ var _mapDispatchToProps__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./mapDispatchToProps */ "./node_modules/react-redux/es/connect/mapDispatchToProps.js"); 47187/* harmony import */ var _mapStateToProps__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mapStateToProps */ "./node_modules/react-redux/es/connect/mapStateToProps.js"); 47188/* harmony import */ var _mergeProps__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./mergeProps */ "./node_modules/react-redux/es/connect/mergeProps.js"); 47189/* harmony import */ var _selectorFactory__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./selectorFactory */ "./node_modules/react-redux/es/connect/selectorFactory.js"); 47190var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 47191 47192function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } 47193 47194 47195 47196 47197 47198 47199 47200 47201/* 47202 connect is a facade over connectAdvanced. It turns its args into a compatible 47203 selectorFactory, which has the signature: 47204 47205 (dispatch, options) => (nextState, nextOwnProps) => nextFinalProps 47206 47207 connect passes its args to connectAdvanced as options, which will in turn pass them to 47208 selectorFactory each time a Connect component instance is instantiated or hot reloaded. 47209 47210 selectorFactory returns a final props selector from its mapStateToProps, 47211 mapStateToPropsFactories, mapDispatchToProps, mapDispatchToPropsFactories, mergeProps, 47212 mergePropsFactories, and pure args. 47213 47214 The resulting final props selector is called by the Connect component instance whenever 47215 it receives new props or store state. 47216 */ 47217 47218function match(arg, factories, name) { 47219 for (var i = factories.length - 1; i >= 0; i--) { 47220 var result = factories[i](arg); 47221 if (result) return result; 47222 } 47223 47224 return function (dispatch, options) { 47225 throw new Error('Invalid value of type ' + typeof arg + ' for ' + name + ' argument when connecting component ' + options.wrappedComponentName + '.'); 47226 }; 47227} 47228 47229function strictEqual(a, b) { 47230 return a === b; 47231} 47232 47233// createConnect with default args builds the 'official' connect behavior. Calling it with 47234// different options opens up some testing and extensibility scenarios 47235function createConnect() { 47236 var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, 47237 _ref$connectHOC = _ref.connectHOC, 47238 connectHOC = _ref$connectHOC === undefined ? _components_connectAdvanced__WEBPACK_IMPORTED_MODULE_0__["default"] : _ref$connectHOC, 47239 _ref$mapStateToPropsF = _ref.mapStateToPropsFactories, 47240 mapStateToPropsFactories = _ref$mapStateToPropsF === undefined ? _mapStateToProps__WEBPACK_IMPORTED_MODULE_3__["default"] : _ref$mapStateToPropsF, 47241 _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories, 47242 mapDispatchToPropsFactories = _ref$mapDispatchToPro === undefined ? _mapDispatchToProps__WEBPACK_IMPORTED_MODULE_2__["default"] : _ref$mapDispatchToPro, 47243 _ref$mergePropsFactor = _ref.mergePropsFactories, 47244 mergePropsFactories = _ref$mergePropsFactor === undefined ? _mergeProps__WEBPACK_IMPORTED_MODULE_4__["default"] : _ref$mergePropsFactor, 47245 _ref$selectorFactory = _ref.selectorFactory, 47246 selectorFactory = _ref$selectorFactory === undefined ? _selectorFactory__WEBPACK_IMPORTED_MODULE_5__["default"] : _ref$selectorFactory; 47247 47248 return function connect(mapStateToProps, mapDispatchToProps, mergeProps) { 47249 var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}, 47250 _ref2$pure = _ref2.pure, 47251 pure = _ref2$pure === undefined ? true : _ref2$pure, 47252 _ref2$areStatesEqual = _ref2.areStatesEqual, 47253 areStatesEqual = _ref2$areStatesEqual === undefined ? strictEqual : _ref2$areStatesEqual, 47254 _ref2$areOwnPropsEqua = _ref2.areOwnPropsEqual, 47255 areOwnPropsEqual = _ref2$areOwnPropsEqua === undefined ? _utils_shallowEqual__WEBPACK_IMPORTED_MODULE_1__["default"] : _ref2$areOwnPropsEqua, 47256 _ref2$areStatePropsEq = _ref2.areStatePropsEqual, 47257 areStatePropsEqual = _ref2$areStatePropsEq === undefined ? _utils_shallowEqual__WEBPACK_IMPORTED_MODULE_1__["default"] : _ref2$areStatePropsEq, 47258 _ref2$areMergedPropsE = _ref2.areMergedPropsEqual, 47259 areMergedPropsEqual = _ref2$areMergedPropsE === undefined ? _utils_shallowEqual__WEBPACK_IMPORTED_MODULE_1__["default"] : _ref2$areMergedPropsE, 47260 extraOptions = _objectWithoutProperties(_ref2, ['pure', 'areStatesEqual', 'areOwnPropsEqual', 'areStatePropsEqual', 'areMergedPropsEqual']); 47261 47262 var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps'); 47263 var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps'); 47264 var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps'); 47265 47266 return connectHOC(selectorFactory, _extends({ 47267 // used in error messages 47268 methodName: 'connect', 47269 47270 // used to compute Connect's displayName from the wrapped component's displayName. 47271 getDisplayName: function getDisplayName(name) { 47272 return 'Connect(' + name + ')'; 47273 }, 47274 47275 // if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes 47276 shouldHandleStateChanges: Boolean(mapStateToProps), 47277 47278 // passed through to selectorFactory 47279 initMapStateToProps: initMapStateToProps, 47280 initMapDispatchToProps: initMapDispatchToProps, 47281 initMergeProps: initMergeProps, 47282 pure: pure, 47283 areStatesEqual: areStatesEqual, 47284 areOwnPropsEqual: areOwnPropsEqual, 47285 areStatePropsEqual: areStatePropsEqual, 47286 areMergedPropsEqual: areMergedPropsEqual 47287 47288 }, extraOptions)); 47289 }; 47290} 47291 47292/* harmony default export */ __webpack_exports__["default"] = (createConnect()); 47293 47294/***/ }), 47295
vendor: 2,395 bytes, lines 47296-47332
47296/***/ "./node_modules/react-redux/es/connect/mapDispatchToProps.js": 47297/*!*******************************************************************!*\ 47298 !*** ./node_modules/react-redux/es/connect/mapDispatchToProps.js ***! 47299 \*******************************************************************/ 47300/*! exports provided: whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject, default */ 47301/***/ (function(module, __webpack_exports__, __webpack_require__) { 47302 47303"use strict"; 47304__webpack_require__.r(__webpack_exports__); 47305/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "whenMapDispatchToPropsIsFunction", function() { return whenMapDispatchToPropsIsFunction; }); 47306/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "whenMapDispatchToPropsIsMissing", function() { return whenMapDispatchToPropsIsMissing; }); 47307/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "whenMapDispatchToPropsIsObject", function() { return whenMapDispatchToPropsIsObject; }); 47308/* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); 47309/* harmony import */ var _wrapMapToProps__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./wrapMapToProps */ "./node_modules/react-redux/es/connect/wrapMapToProps.js"); 47310 47311 47312 47313function whenMapDispatchToPropsIsFunction(mapDispatchToProps) { 47314 return typeof mapDispatchToProps === 'function' ? Object(_wrapMapToProps__WEBPACK_IMPORTED_MODULE_1__["wrapMapToPropsFunc"])(mapDispatchToProps, 'mapDispatchToProps') : undefined; 47315} 47316 47317function whenMapDispatchToPropsIsMissing(mapDispatchToProps) { 47318 return !mapDispatchToProps ? Object(_wrapMapToProps__WEBPACK_IMPORTED_MODULE_1__["wrapMapToPropsConstant"])(function (dispatch) { 47319 return { dispatch: dispatch }; 47320 }) : undefined; 47321} 47322 47323function whenMapDispatchToPropsIsObject(mapDispatchToProps) { 47324 return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? Object(_wrapMapToProps__WEBPACK_IMPORTED_MODULE_1__["wrapMapToPropsConstant"])(function (dispatch) { 47325 return Object(redux__WEBPACK_IMPORTED_MODULE_0__["bindActionCreators"])(mapDispatchToProps, dispatch); 47326 }) : undefined; 47327} 47328 47329/* harmony default export */ __webpack_exports__["default"] = ([whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject]); 47330 47331/***/ }), 47332
vendor: 1,583 bytes, lines 47333-47360
47333/***/ "./node_modules/react-redux/es/connect/mapStateToProps.js": 47334/*!****************************************************************!*\ 47335 !*** ./node_modules/react-redux/es/connect/mapStateToProps.js ***! 47336 \****************************************************************/ 47337/*! exports provided: whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing, default */ 47338/***/ (function(module, __webpack_exports__, __webpack_require__) { 47339 47340"use strict"; 47341__webpack_require__.r(__webpack_exports__); 47342/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "whenMapStateToPropsIsFunction", function() { return whenMapStateToPropsIsFunction; }); 47343/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "whenMapStateToPropsIsMissing", function() { return whenMapStateToPropsIsMissing; }); 47344/* harmony import */ var _wrapMapToProps__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./wrapMapToProps */ "./node_modules/react-redux/es/connect/wrapMapToProps.js"); 47345 47346 47347function whenMapStateToPropsIsFunction(mapStateToProps) { 47348 return typeof mapStateToProps === 'function' ? Object(_wrapMapToProps__WEBPACK_IMPORTED_MODULE_0__["wrapMapToPropsFunc"])(mapStateToProps, 'mapStateToProps') : undefined; 47349} 47350 47351function whenMapStateToPropsIsMissing(mapStateToProps) { 47352 return !mapStateToProps ? Object(_wrapMapToProps__WEBPACK_IMPORTED_MODULE_0__["wrapMapToPropsConstant"])(function () { 47353 return {}; 47354 }) : undefined; 47355} 47356 47357/* harmony default export */ __webpack_exports__["default"] = ([whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing]); 47358 47359/***/ }), 47360
vendor: 2,898 bytes, lines 47361-47422
47361/***/ "./node_modules/react-redux/es/connect/mergeProps.js": 47362/*!***********************************************************!*\ 47363 !*** ./node_modules/react-redux/es/connect/mergeProps.js ***! 47364 \***********************************************************/ 47365/*! exports provided: defaultMergeProps, wrapMergePropsFunc, whenMergePropsIsFunction, whenMergePropsIsOmitted, default */ 47366/***/ (function(module, __webpack_exports__, __webpack_require__) { 47367 47368"use strict"; 47369__webpack_require__.r(__webpack_exports__); 47370/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultMergeProps", function() { return defaultMergeProps; }); 47371/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "wrapMergePropsFunc", function() { return wrapMergePropsFunc; }); 47372/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "whenMergePropsIsFunction", function() { return whenMergePropsIsFunction; }); 47373/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "whenMergePropsIsOmitted", function() { return whenMergePropsIsOmitted; }); 47374/* harmony import */ var _utils_verifyPlainObject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/verifyPlainObject */ "./node_modules/react-redux/es/utils/verifyPlainObject.js"); 47375var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 47376 47377 47378 47379function defaultMergeProps(stateProps, dispatchProps, ownProps) { 47380 return _extends({}, ownProps, stateProps, dispatchProps); 47381} 47382 47383function wrapMergePropsFunc(mergeProps) { 47384 return function initMergePropsProxy(dispatch, _ref) { 47385 var displayName = _ref.displayName, 47386 pure = _ref.pure, 47387 areMergedPropsEqual = _ref.areMergedPropsEqual; 47388 47389 var hasRunOnce = false; 47390 var mergedProps = void 0; 47391 47392 return function mergePropsProxy(stateProps, dispatchProps, ownProps) { 47393 var nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps); 47394 47395 if (hasRunOnce) { 47396 if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps; 47397 } else { 47398 hasRunOnce = true; 47399 mergedProps = nextMergedProps; 47400 47401 if (true) Object(_utils_verifyPlainObject__WEBPACK_IMPORTED_MODULE_0__["default"])(mergedProps, displayName, 'mergeProps'); 47402 } 47403 47404 return mergedProps; 47405 }; 47406 }; 47407} 47408 47409function whenMergePropsIsFunction(mergeProps) { 47410 return typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : undefined; 47411} 47412 47413function whenMergePropsIsOmitted(mergeProps) { 47414 return !mergeProps ? function () { 47415 return defaultMergeProps; 47416 } : undefined; 47417} 47418 47419/* harmony default export */ __webpack_exports__["default"] = ([whenMergePropsIsFunction, whenMergePropsIsOmitted]); 47420 47421/***/ }), 47422
vendor: 5,209 bytes, lines 47423-47540
47423/***/ "./node_modules/react-redux/es/connect/selectorFactory.js": 47424/*!****************************************************************!*\ 47425 !*** ./node_modules/react-redux/es/connect/selectorFactory.js ***! 47426 \****************************************************************/ 47427/*! exports provided: impureFinalPropsSelectorFactory, pureFinalPropsSelectorFactory, default */ 47428/***/ (function(module, __webpack_exports__, __webpack_require__) { 47429 47430"use strict"; 47431__webpack_require__.r(__webpack_exports__); 47432/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "impureFinalPropsSelectorFactory", function() { return impureFinalPropsSelectorFactory; }); 47433/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pureFinalPropsSelectorFactory", function() { return pureFinalPropsSelectorFactory; }); 47434/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return finalPropsSelectorFactory; }); 47435/* harmony import */ var _verifySubselectors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./verifySubselectors */ "./node_modules/react-redux/es/connect/verifySubselectors.js"); 47436function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } 47437 47438 47439 47440function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch) { 47441 return function impureFinalPropsSelector(state, ownProps) { 47442 return mergeProps(mapStateToProps(state, ownProps), mapDispatchToProps(dispatch, ownProps), ownProps); 47443 }; 47444} 47445 47446function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, _ref) { 47447 var areStatesEqual = _ref.areStatesEqual, 47448 areOwnPropsEqual = _ref.areOwnPropsEqual, 47449 areStatePropsEqual = _ref.areStatePropsEqual; 47450 47451 var hasRunAtLeastOnce = false; 47452 var state = void 0; 47453 var ownProps = void 0; 47454 var stateProps = void 0; 47455 var dispatchProps = void 0; 47456 var mergedProps = void 0; 47457 47458 function handleFirstCall(firstState, firstOwnProps) { 47459 state = firstState; 47460 ownProps = firstOwnProps; 47461 stateProps = mapStateToProps(state, ownProps); 47462 dispatchProps = mapDispatchToProps(dispatch, ownProps); 47463 mergedProps = mergeProps(stateProps, dispatchProps, ownProps); 47464 hasRunAtLeastOnce = true; 47465 return mergedProps; 47466 } 47467 47468 function handleNewPropsAndNewState() { 47469 stateProps = mapStateToProps(state, ownProps); 47470 47471 if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps); 47472 47473 mergedProps = mergeProps(stateProps, dispatchProps, ownProps); 47474 return mergedProps; 47475 } 47476 47477 function handleNewProps() { 47478 if (mapStateToProps.dependsOnOwnProps) stateProps = mapStateToProps(state, ownProps); 47479 47480 if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps); 47481 47482 mergedProps = mergeProps(stateProps, dispatchProps, ownProps); 47483 return mergedProps; 47484 } 47485 47486 function handleNewState() { 47487 var nextStateProps = mapStateToProps(state, ownProps); 47488 var statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps); 47489 stateProps = nextStateProps; 47490 47491 if (statePropsChanged) mergedProps = mergeProps(stateProps, dispatchProps, ownProps); 47492 47493 return mergedProps; 47494 } 47495 47496 function handleSubsequentCalls(nextState, nextOwnProps) { 47497 var propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps); 47498 var stateChanged = !areStatesEqual(nextState, state); 47499 state = nextState; 47500 ownProps = nextOwnProps; 47501 47502 if (propsChanged && stateChanged) return handleNewPropsAndNewState(); 47503 if (propsChanged) return handleNewProps(); 47504 if (stateChanged) return handleNewState(); 47505 return mergedProps; 47506 } 47507 47508 return function pureFinalPropsSelector(nextState, nextOwnProps) { 47509 return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps); 47510 }; 47511} 47512 47513// TODO: Add more comments 47514 47515// If pure is true, the selector returned by selectorFactory will memoize its results, 47516// allowing connectAdvanced's shouldComponentUpdate to return false if final 47517// props have not changed. If false, the selector will always return a new 47518// object and shouldComponentUpdate will always return true. 47519 47520function finalPropsSelectorFactory(dispatch, _ref2) { 47521 var initMapStateToProps = _ref2.initMapStateToProps, 47522 initMapDispatchToProps = _ref2.initMapDispatchToProps, 47523 initMergeProps = _ref2.initMergeProps, 47524 options = _objectWithoutProperties(_ref2, ['initMapStateToProps', 'initMapDispatchToProps', 'initMergeProps']); 47525 47526 var mapStateToProps = initMapStateToProps(dispatch, options); 47527 var mapDispatchToProps = initMapDispatchToProps(dispatch, options); 47528 var mergeProps = initMergeProps(dispatch, options); 47529 47530 if (true) { 47531 Object(_verifySubselectors__WEBPACK_IMPORTED_MODULE_0__["default"])(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName); 47532 } 47533 47534 var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory; 47535 47536 return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options); 47537} 47538 47539/***/ }), 47540
vendor: 1,520 bytes, lines 47541-47571
47541/***/ "./node_modules/react-redux/es/connect/verifySubselectors.js": 47542/*!*******************************************************************!*\ 47543 !*** ./node_modules/react-redux/es/connect/verifySubselectors.js ***! 47544 \*******************************************************************/ 47545/*! exports provided: default */ 47546/***/ (function(module, __webpack_exports__, __webpack_require__) { 47547 47548"use strict"; 47549__webpack_require__.r(__webpack_exports__); 47550/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return verifySubselectors; }); 47551/* harmony import */ var _utils_warning__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/warning */ "./node_modules/react-redux/es/utils/warning.js"); 47552 47553 47554function verify(selector, methodName, displayName) { 47555 if (!selector) { 47556 throw new Error('Unexpected value for ' + methodName + ' in ' + displayName + '.'); 47557 } else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') { 47558 if (!selector.hasOwnProperty('dependsOnOwnProps')) { 47559 Object(_utils_warning__WEBPACK_IMPORTED_MODULE_0__["default"])('The selector for ' + methodName + ' of ' + displayName + ' did not specify a value for dependsOnOwnProps.'); 47560 } 47561 } 47562} 47563 47564function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, displayName) { 47565 verify(mapStateToProps, 'mapStateToProps', displayName); 47566 verify(mapDispatchToProps, 'mapDispatchToProps', displayName); 47567 verify(mergeProps, 'mergeProps', displayName); 47568} 47569 47570/***/ }), 47571
vendor: 3,868 bytes, lines 47572-47654
47572/***/ "./node_modules/react-redux/es/connect/wrapMapToProps.js": 47573/*!***************************************************************!*\ 47574 !*** ./node_modules/react-redux/es/connect/wrapMapToProps.js ***! 47575 \***************************************************************/ 47576/*! exports provided: wrapMapToPropsConstant, getDependsOnOwnProps, wrapMapToPropsFunc */ 47577/***/ (function(module, __webpack_exports__, __webpack_require__) { 47578 47579"use strict"; 47580__webpack_require__.r(__webpack_exports__); 47581/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "wrapMapToPropsConstant", function() { return wrapMapToPropsConstant; }); 47582/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDependsOnOwnProps", function() { return getDependsOnOwnProps; }); 47583/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "wrapMapToPropsFunc", function() { return wrapMapToPropsFunc; }); 47584/* harmony import */ var _utils_verifyPlainObject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/verifyPlainObject */ "./node_modules/react-redux/es/utils/verifyPlainObject.js"); 47585 47586 47587function wrapMapToPropsConstant(getConstant) { 47588 return function initConstantSelector(dispatch, options) { 47589 var constant = getConstant(dispatch, options); 47590 47591 function constantSelector() { 47592 return constant; 47593 } 47594 constantSelector.dependsOnOwnProps = false; 47595 return constantSelector; 47596 }; 47597} 47598 47599// dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args 47600// to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine 47601// whether mapToProps needs to be invoked when props have changed. 47602// 47603// A length of one signals that mapToProps does not depend on props from the parent component. 47604// A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and 47605// therefore not reporting its length accurately.. 47606function getDependsOnOwnProps(mapToProps) { 47607 return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1; 47608} 47609 47610// Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction, 47611// this function wraps mapToProps in a proxy function which does several things: 47612// 47613// * Detects whether the mapToProps function being called depends on props, which 47614// is used by selectorFactory to decide if it should reinvoke on props changes. 47615// 47616// * On first call, handles mapToProps if returns another function, and treats that 47617// new function as the true mapToProps for subsequent calls. 47618// 47619// * On first call, verifies the first result is a plain object, in order to warn 47620// the developer that their mapToProps function is not returning a valid result. 47621// 47622function wrapMapToPropsFunc(mapToProps, methodName) { 47623 return function initProxySelector(dispatch, _ref) { 47624 var displayName = _ref.displayName; 47625 47626 var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) { 47627 return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch); 47628 }; 47629 47630 // allow detectFactoryAndVerify to get ownProps 47631 proxy.dependsOnOwnProps = true; 47632 47633 proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) { 47634 proxy.mapToProps = mapToProps; 47635 proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps); 47636 var props = proxy(stateOrDispatch, ownProps); 47637 47638 if (typeof props === 'function') { 47639 proxy.mapToProps = props; 47640 proxy.dependsOnOwnProps = getDependsOnOwnProps(props); 47641 props = proxy(stateOrDispatch, ownProps); 47642 } 47643 47644 if (true) Object(_utils_verifyPlainObject__WEBPACK_IMPORTED_MODULE_0__["default"])(props, displayName, methodName); 47645 47646 return props; 47647 }; 47648 47649 return proxy; 47650 }; 47651} 47652 47653/***/ }), 47654
vendor: 1,691 bytes, lines 47655-47682
47655/***/ "./node_modules/react-redux/es/index.js": 47656/*!**********************************************!*\ 47657 !*** ./node_modules/react-redux/es/index.js ***! 47658 \**********************************************/ 47659/*! exports provided: Provider, createProvider, connectAdvanced, connect */ 47660/***/ (function(module, __webpack_exports__, __webpack_require__) { 47661 47662"use strict"; 47663__webpack_require__.r(__webpack_exports__); 47664/* harmony import */ var _components_Provider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./components/Provider */ "./node_modules/react-redux/es/components/Provider.js"); 47665/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Provider", function() { return _components_Provider__WEBPACK_IMPORTED_MODULE_0__["default"]; }); 47666 47667/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "createProvider", function() { return _components_Provider__WEBPACK_IMPORTED_MODULE_0__["createProvider"]; }); 47668 47669/* harmony import */ var _components_connectAdvanced__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/connectAdvanced */ "./node_modules/react-redux/es/components/connectAdvanced.js"); 47670/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "connectAdvanced", function() { return _components_connectAdvanced__WEBPACK_IMPORTED_MODULE_1__["default"]; }); 47671 47672/* harmony import */ var _connect_connect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./connect/connect */ "./node_modules/react-redux/es/connect/connect.js"); 47673/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "connect", function() { return _connect_connect__WEBPACK_IMPORTED_MODULE_2__["default"]; }); 47674 47675 47676 47677 47678 47679 47680 47681/***/ }), 47682
vendor: 1,737 bytes, lines 47683-47712
47683/***/ "./node_modules/react-redux/es/utils/PropTypes.js": 47684/*!********************************************************!*\ 47685 !*** ./node_modules/react-redux/es/utils/PropTypes.js ***! 47686 \********************************************************/ 47687/*! exports provided: subscriptionShape, storeShape */ 47688/***/ (function(module, __webpack_exports__, __webpack_require__) { 47689 47690"use strict"; 47691__webpack_require__.r(__webpack_exports__); 47692/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subscriptionShape", function() { return subscriptionShape; }); 47693/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "storeShape", function() { return storeShape; }); 47694/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js"); 47695/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_0__); 47696 47697 47698var subscriptionShape = prop_types__WEBPACK_IMPORTED_MODULE_0___default.a.shape({ 47699 trySubscribe: prop_types__WEBPACK_IMPORTED_MODULE_0___default.a.func.isRequired, 47700 tryUnsubscribe: prop_types__WEBPACK_IMPORTED_MODULE_0___default.a.func.isRequired, 47701 notifyNestedSubs: prop_types__WEBPACK_IMPORTED_MODULE_0___default.a.func.isRequired, 47702 isSubscribed: prop_types__WEBPACK_IMPORTED_MODULE_0___default.a.func.isRequired 47703}); 47704 47705var storeShape = prop_types__WEBPACK_IMPORTED_MODULE_0___default.a.shape({ 47706 subscribe: prop_types__WEBPACK_IMPORTED_MODULE_0___default.a.func.isRequired, 47707 dispatch: prop_types__WEBPACK_IMPORTED_MODULE_0___default.a.func.isRequired, 47708 getState: prop_types__WEBPACK_IMPORTED_MODULE_0___default.a.func.isRequired 47709}); 47710 47711/***/ }), 47712
vendor: 3,159 bytes, lines 47713-47817
47713/***/ "./node_modules/react-redux/es/utils/Subscription.js": 47714/*!***********************************************************!*\ 47715 !*** ./node_modules/react-redux/es/utils/Subscription.js ***! 47716 \***********************************************************/ 47717/*! exports provided: default */ 47718/***/ (function(module, __webpack_exports__, __webpack_require__) { 47719 47720"use strict"; 47721__webpack_require__.r(__webpack_exports__); 47722/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Subscription; }); 47723function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 47724 47725// encapsulates the subscription logic for connecting a component to the redux store, as 47726// well as nesting subscriptions of descendant components, so that we can ensure the 47727// ancestor components re-render before descendants 47728 47729var CLEARED = null; 47730var nullListeners = { 47731 notify: function notify() {} 47732}; 47733 47734function createListenerCollection() { 47735 // the current/next pattern is copied from redux's createStore code. 47736 // TODO: refactor+expose that code to be reusable here? 47737 var current = []; 47738 var next = []; 47739 47740 return { 47741 clear: function clear() { 47742 next = CLEARED; 47743 current = CLEARED; 47744 }, 47745 notify: function notify() { 47746 var listeners = current = next; 47747 for (var i = 0; i < listeners.length; i++) { 47748 listeners[i](); 47749 } 47750 }, 47751 get: function get() { 47752 return next; 47753 }, 47754 subscribe: function subscribe(listener) { 47755 var isSubscribed = true; 47756 if (next === current) next = current.slice(); 47757 next.push(listener); 47758 47759 return function unsubscribe() { 47760 if (!isSubscribed || current === CLEARED) return; 47761 isSubscribed = false; 47762 47763 if (next === current) next = current.slice(); 47764 next.splice(next.indexOf(listener), 1); 47765 }; 47766 } 47767 }; 47768} 47769 47770var Subscription = function () { 47771 function Subscription(store, parentSub, onStateChange) { 47772 _classCallCheck(this, Subscription); 47773 47774 this.store = store; 47775 this.parentSub = parentSub; 47776 this.onStateChange = onStateChange; 47777 this.unsubscribe = null; 47778 this.listeners = nullListeners; 47779 } 47780 47781 Subscription.prototype.addNestedSub = function addNestedSub(listener) { 47782 this.trySubscribe(); 47783 return this.listeners.subscribe(listener); 47784 }; 47785 47786 Subscription.prototype.notifyNestedSubs = function notifyNestedSubs() { 47787 this.listeners.notify(); 47788 }; 47789 47790 Subscription.prototype.isSubscribed = function isSubscribed() { 47791 return Boolean(this.unsubscribe); 47792 }; 47793 47794 Subscription.prototype.trySubscribe = function trySubscribe() { 47795 if (!this.unsubscribe) { 47796 this.unsubscribe = this.parentSub ? this.parentSub.addNestedSub(this.onStateChange) : this.store.subscribe(this.onStateChange); 47797 47798 this.listeners = createListenerCollection(); 47799 } 47800 }; 47801 47802 Subscription.prototype.tryUnsubscribe = function tryUnsubscribe() { 47803 if (this.unsubscribe) { 47804 this.unsubscribe(); 47805 this.unsubscribe = null; 47806 this.listeners.clear(); 47807 this.listeners = nullListeners; 47808 } 47809 }; 47810 47811 return Subscription; 47812}(); 47813 47814 47815 47816/***/ }), 47817
vendor: 1,213 bytes, lines 47818-47860
47818/***/ "./node_modules/react-redux/es/utils/shallowEqual.js": 47819/*!***********************************************************!*\ 47820 !*** ./node_modules/react-redux/es/utils/shallowEqual.js ***! 47821 \***********************************************************/ 47822/*! exports provided: default */ 47823/***/ (function(module, __webpack_exports__, __webpack_require__) { 47824 47825"use strict"; 47826__webpack_require__.r(__webpack_exports__); 47827/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return shallowEqual; }); 47828var hasOwn = Object.prototype.hasOwnProperty; 47829 47830function is(x, y) { 47831 if (x === y) { 47832 return x !== 0 || y !== 0 || 1 / x === 1 / y; 47833 } else { 47834 return x !== x && y !== y; 47835 } 47836} 47837 47838function shallowEqual(objA, objB) { 47839 if (is(objA, objB)) return true; 47840 47841 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { 47842 return false; 47843 } 47844 47845 var keysA = Object.keys(objA); 47846 var keysB = Object.keys(objB); 47847 47848 if (keysA.length !== keysB.length) return false; 47849 47850 for (var i = 0; i < keysA.length; i++) { 47851 if (!hasOwn.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) { 47852 return false; 47853 } 47854 } 47855 47856 return true; 47857} 47858 47859/***/ }), 47860
vendor: 1,228 bytes, lines 47861-47883
47861/***/ "./node_modules/react-redux/es/utils/verifyPlainObject.js": 47862/*!****************************************************************!*\ 47863 !*** ./node_modules/react-redux/es/utils/verifyPlainObject.js ***! 47864 \****************************************************************/ 47865/*! exports provided: default */ 47866/***/ (function(module, __webpack_exports__, __webpack_require__) { 47867 47868"use strict"; 47869__webpack_require__.r(__webpack_exports__); 47870/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return verifyPlainObject; }); 47871/* harmony import */ var lodash_es_isPlainObject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash-es/isPlainObject */ "./node_modules/lodash-es/isPlainObject.js"); 47872/* harmony import */ var _warning__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./warning */ "./node_modules/react-redux/es/utils/warning.js"); 47873 47874 47875 47876function verifyPlainObject(value, displayName, methodName) { 47877 if (!Object(lodash_es_isPlainObject__WEBPACK_IMPORTED_MODULE_0__["default"])(value)) { 47878 Object(_warning__WEBPACK_IMPORTED_MODULE_1__["default"])(methodName + '() in ' + displayName + ' must return a plain object. Instead received ' + value + '.'); 47879 } 47880} 47881 47882/***/ }), 47883
vendor: 1,148 bytes, lines 47884-47917
47884/***/ "./node_modules/react-redux/es/utils/warning.js": 47885/*!******************************************************!*\ 47886 !*** ./node_modules/react-redux/es/utils/warning.js ***! 47887 \******************************************************/ 47888/*! exports provided: default */ 47889/***/ (function(module, __webpack_exports__, __webpack_require__) { 47890 47891"use strict"; 47892__webpack_require__.r(__webpack_exports__); 47893/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return warning; }); 47894/** 47895 * Prints a warning in the console if it exists. 47896 * 47897 * @param {String} message The warning message. 47898 * @returns {void} 47899 */ 47900function warning(message) { 47901 /* eslint-disable no-console */ 47902 if (typeof console !== 'undefined' && typeof console.error === 'function') { 47903 console.error(message); 47904 } 47905 /* eslint-enable no-console */ 47906 try { 47907 // This error was thrown as a convenience so that if you enable 47908 // "break on all exceptions" in your console, 47909 // it would pause the execution at this line. 47910 throw new Error(message); 47911 /* eslint-disable no-empty */ 47912 } catch (e) {} 47913 /* eslint-enable no-empty */ 47914} 47915 47916/***/ }), 47917
vendor: 43,572 bytes, lines 47918-48677
47918/***/ "./node_modules/react-responsive/dist/react-responsive.js": 47919/*!****************************************************************!*\ 47920 !*** ./node_modules/react-responsive/dist/react-responsive.js ***! 47921 \****************************************************************/ 47922/*! no static exports found */ 47923/***/ (function(module, exports, __webpack_require__) { 47924 47925!function(root, factory) { 47926 true ? module.exports = factory(__webpack_require__(/*! react */ "./node_modules/react/index.js")) : undefined; 47927}("undefined" != typeof self ? self : this, function(__WEBPACK_EXTERNAL_MODULE_8__) { 47928 return function(modules) { 47929 function __webpack_require__(moduleId) { 47930 if (installedModules[moduleId]) return installedModules[moduleId].exports; 47931 var module = installedModules[moduleId] = { 47932 i: moduleId, 47933 l: !1, 47934 exports: {} 47935 }; 47936 return modules[moduleId].call(module.exports, module, module.exports, __webpack_require__), 47937 module.l = !0, module.exports; 47938 } 47939 var installedModules = {}; 47940 return __webpack_require__.m = modules, __webpack_require__.c = installedModules, 47941 __webpack_require__.d = function(exports, name, getter) { 47942 __webpack_require__.o(exports, name) || Object.defineProperty(exports, name, { 47943 configurable: !1, 47944 enumerable: !0, 47945 get: getter 47946 }); 47947 }, __webpack_require__.n = function(module) { 47948 var getter = module && module.__esModule ? function() { 47949 return module.default; 47950 } : function() { 47951 return module; 47952 }; 47953 return __webpack_require__.d(getter, "a", getter), getter; 47954 }, __webpack_require__.o = function(object, property) { 47955 return Object.prototype.hasOwnProperty.call(object, property); 47956 }, __webpack_require__.p = "", __webpack_require__(__webpack_require__.s = 7); 47957 }([ function(module, exports, __webpack_require__) { 47958 var REACT_ELEMENT_TYPE = "function" == typeof Symbol && Symbol.for && Symbol.for("react.element") || 60103, isValidElement = function(object) { 47959 return "object" == typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE; 47960 }; 47961 module.exports = __webpack_require__(9)(isValidElement, !0); 47962 }, function(module, exports, __webpack_require__) { 47963 "use strict"; 47964 function makeEmptyFunction(arg) { 47965 return function() { 47966 return arg; 47967 }; 47968 } 47969 var emptyFunction = function() {}; 47970 emptyFunction.thatReturns = makeEmptyFunction, emptyFunction.thatReturnsFalse = makeEmptyFunction(!1), 47971 emptyFunction.thatReturnsTrue = makeEmptyFunction(!0), emptyFunction.thatReturnsNull = makeEmptyFunction(null), 47972 emptyFunction.thatReturnsThis = function() { 47973 return this; 47974 }, emptyFunction.thatReturnsArgument = function(arg) { 47975 return arg; 47976 }, module.exports = emptyFunction; 47977 }, function(module, exports, __webpack_require__) { 47978 "use strict"; 47979 function invariant(condition, format, a, b, c, d, e, f) { 47980 if (validateFormat(format), !condition) { 47981 var error; 47982 if (void 0 === format) error = new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings."); else { 47983 var args = [ a, b, c, d, e, f ], argIndex = 0; 47984 error = new Error(format.replace(/%s/g, function() { 47985 return args[argIndex++]; 47986 })), error.name = "Invariant Violation"; 47987 } 47988 throw error.framesToPop = 1, error; 47989 } 47990 } 47991 var validateFormat = function(format) {}; 47992 validateFormat = function(format) { 47993 if (void 0 === format) throw new Error("invariant requires an error message argument"); 47994 }, module.exports = invariant; 47995 }, function(module, exports, __webpack_require__) { 47996 "use strict"; 47997 var emptyFunction = __webpack_require__(1), warning = emptyFunction, printWarning = function(format) { 47998 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) args[_key - 1] = arguments[_key]; 47999 var argIndex = 0, message = "Warning: " + format.replace(/%s/g, function() { 48000 return args[argIndex++]; 48001 }); 48002 "undefined" != typeof console && console.error(message); 48003 try { 48004 throw new Error(message); 48005 } catch (x) {} 48006 }; 48007 warning = function(condition, format) { 48008 if (void 0 === format) throw new Error("`warning(condition, format, ...args)` requires a warning message argument"); 48009 if (0 !== format.indexOf("Failed Composite propType: ") && !condition) { 48010 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) args[_key2 - 2] = arguments[_key2]; 48011 printWarning.apply(void 0, [ format ].concat(args)); 48012 } 48013 }, module.exports = warning; 48014 }, function(module, exports, __webpack_require__) { 48015 "use strict"; 48016 module.exports = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"; 48017 }, function(module, exports, __webpack_require__) { 48018 "use strict"; 48019 function hyphenateStyleName(string) { 48020 return string in cache ? cache[string] : cache[string] = string.replace(uppercasePattern, "-$&").toLowerCase().replace(msPattern, "-ms-"); 48021 } 48022 var uppercasePattern = /[A-Z]/g, msPattern = /^ms-/, cache = {}; 48023 module.exports = hyphenateStyleName; 48024 }, function(module, exports, __webpack_require__) { 48025 "use strict"; 48026 Object.defineProperty(exports, "__esModule", { 48027 value: !0 48028 }); 48029 var _extends = Object.assign || function(target) { 48030 for (var i = 1; i < arguments.length; i++) { 48031 var source = arguments[i]; 48032 for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); 48033 } 48034 return target; 48035 }, _propTypes = __webpack_require__(0), _propTypes2 = function(obj) { 48036 return obj && obj.__esModule ? obj : { 48037 default: obj 48038 }; 48039 }(_propTypes), stringOrNumber = _propTypes2.default.oneOfType([ _propTypes2.default.string, _propTypes2.default.number ]), matchers = { 48040 orientation: _propTypes2.default.oneOf([ "portrait", "landscape" ]), 48041 scan: _propTypes2.default.oneOf([ "progressive", "interlace" ]), 48042 aspectRatio: _propTypes2.default.string, 48043 deviceAspectRatio: _propTypes2.default.string, 48044 height: stringOrNumber, 48045 deviceHeight: stringOrNumber, 48046 width: stringOrNumber, 48047 deviceWidth: stringOrNumber, 48048 color: _propTypes2.default.bool, 48049 colorIndex: _propTypes2.default.bool, 48050 monochrome: _propTypes2.default.bool, 48051 resolution: stringOrNumber 48052 }, features = _extends({ 48053 minAspectRatio: _propTypes2.default.string, 48054 maxAspectRatio: _propTypes2.default.string, 48055 minDeviceAspectRatio: _propTypes2.default.string, 48056 maxDeviceAspectRatio: _propTypes2.default.string, 48057 minHeight: stringOrNumber, 48058 maxHeight: stringOrNumber, 48059 minDeviceHeight: stringOrNumber, 48060 maxDeviceHeight: stringOrNumber, 48061 minWidth: stringOrNumber, 48062 maxWidth: stringOrNumber, 48063 minDeviceWidth: stringOrNumber, 48064 maxDeviceWidth: stringOrNumber, 48065 minColor: _propTypes2.default.number, 48066 maxColor: _propTypes2.default.number, 48067 minColorIndex: _propTypes2.default.number, 48068 maxColorIndex: _propTypes2.default.number, 48069 minMonochrome: _propTypes2.default.number, 48070 maxMonochrome: _propTypes2.default.number, 48071 minResolution: stringOrNumber, 48072 maxResolution: stringOrNumber 48073 }, matchers), types = { 48074 all: _propTypes2.default.bool, 48075 grid: _propTypes2.default.bool, 48076 aural: _propTypes2.default.bool, 48077 braille: _propTypes2.default.bool, 48078 handheld: _propTypes2.default.bool, 48079 print: _propTypes2.default.bool, 48080 projection: _propTypes2.default.bool, 48081 screen: _propTypes2.default.bool, 48082 tty: _propTypes2.default.bool, 48083 tv: _propTypes2.default.bool, 48084 embossed: _propTypes2.default.bool 48085 }, all = _extends({}, types, features); 48086 matchers.type = Object.keys(types), exports.default = { 48087 all: all, 48088 types: types, 48089 matchers: matchers, 48090 features: features 48091 }, module.exports = exports.default; 48092 }, function(module, exports, __webpack_require__) { 48093 "use strict"; 48094 function _interopRequireDefault(obj) { 48095 return obj && obj.__esModule ? obj : { 48096 default: obj 48097 }; 48098 } 48099 function _classCallCheck(instance, Constructor) { 48100 if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); 48101 } 48102 function _possibleConstructorReturn(self, call) { 48103 if (!self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 48104 return !call || "object" != typeof call && "function" != typeof call ? self : call; 48105 } 48106 function _inherits(subClass, superClass) { 48107 if ("function" != typeof superClass && null !== superClass) throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); 48108 subClass.prototype = Object.create(superClass && superClass.prototype, { 48109 constructor: { 48110 value: subClass, 48111 enumerable: !1, 48112 writable: !0, 48113 configurable: !0 48114 } 48115 }), superClass && (Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass); 48116 } 48117 function omit(object, keys) { 48118 var newObject = _extends({}, object); 48119 return keys.forEach(function(key) { 48120 return delete newObject[key]; 48121 }), newObject; 48122 } 48123 Object.defineProperty(exports, "__esModule", { 48124 value: !0 48125 }), exports.toQuery = exports.default = void 0; 48126 var _createClass = function() { 48127 function defineProperties(target, props) { 48128 for (var i = 0; i < props.length; i++) { 48129 var descriptor = props[i]; 48130 descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, 48131 "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor); 48132 } 48133 } 48134 return function(Constructor, protoProps, staticProps) { 48135 return protoProps && defineProperties(Constructor.prototype, protoProps), staticProps && defineProperties(Constructor, staticProps), 48136 Constructor; 48137 }; 48138 }(), _extends = Object.assign || function(target) { 48139 for (var i = 1; i < arguments.length; i++) { 48140 var source = arguments[i]; 48141 for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); 48142 } 48143 return target; 48144 }, _react = __webpack_require__(8), _react2 = _interopRequireDefault(_react), _propTypes = __webpack_require__(0), _propTypes2 = _interopRequireDefault(_propTypes), _matchmediaquery = __webpack_require__(12), _matchmediaquery2 = _interopRequireDefault(_matchmediaquery), _hyphenateStyleName = __webpack_require__(5), _hyphenateStyleName2 = _interopRequireDefault(_hyphenateStyleName), _mediaQuery = __webpack_require__(6), _mediaQuery2 = _interopRequireDefault(_mediaQuery), _toQuery = __webpack_require__(14), _toQuery2 = _interopRequireDefault(_toQuery), defaultTypes = { 48145 component: _propTypes2.default.node, 48146 query: _propTypes2.default.string, 48147 values: _propTypes2.default.shape(_mediaQuery2.default.matchers), 48148 children: _propTypes2.default.oneOfType([ _propTypes2.default.node, _propTypes2.default.func ]), 48149 onChange: _propTypes2.default.func, 48150 onBeforeChange: _propTypes2.default.func 48151 }, mediaKeys = Object.keys(_mediaQuery2.default.all), excludedQueryKeys = Object.keys(defaultTypes), excludedPropKeys = excludedQueryKeys.concat(mediaKeys), MediaQuery = function(_React$Component) { 48152 function MediaQuery() { 48153 var _ref, _temp, _this, _ret; 48154 _classCallCheck(this, MediaQuery); 48155 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key]; 48156 return _temp = _this = _possibleConstructorReturn(this, (_ref = MediaQuery.__proto__ || Object.getPrototypeOf(MediaQuery)).call.apply(_ref, [ this ].concat(args))), 48157 _this.state = { 48158 matches: !1 48159 }, _this.updateMatches = function() { 48160 _this._mql.matches !== _this.state.matches && _this.setState({ 48161 matches: _this._mql.matches 48162 }); 48163 }, _this.removeMql = function() { 48164 _this._mql && (_this._mql.removeListener(_this.updateMatches), _this._mql.dispose()); 48165 }, _ret = _temp, _possibleConstructorReturn(_this, _ret); 48166 } 48167 return _inherits(MediaQuery, _React$Component), _createClass(MediaQuery, [ { 48168 key: "componentWillMount", 48169 value: function() { 48170 this.updateQuery(this.props); 48171 } 48172 }, { 48173 key: "componentWillReceiveProps", 48174 value: function(nextProps) { 48175 this.updateQuery(nextProps); 48176 } 48177 }, { 48178 key: "updateQuery", 48179 value: function(props) { 48180 var values = void 0; 48181 if (props.query ? this.query = props.query : this.query = (0, _toQuery2.default)(omit(props, excludedQueryKeys)), 48182 !this.query) throw new Error("Invalid or missing MediaQuery!"); 48183 props.values && (values = Object.keys(props.values).reduce(function(result, key) { 48184 return result[(0, _hyphenateStyleName2.default)(key)] = props.values[key], result; 48185 }, {})), this.removeMql(), this._mql = (0, _matchmediaquery2.default)(this.query, values), 48186 this._mql.addListener(this.updateMatches), this.updateMatches(); 48187 } 48188 }, { 48189 key: "componentWillUpdate", 48190 value: function(_, nextState) { 48191 this.props.onBeforeChange && this.state.matches !== nextState.matches && this.props.onBeforeChange(this.state.matches); 48192 } 48193 }, { 48194 key: "componentDidUpdate", 48195 value: function(_, prevState) { 48196 this.props.onChange && prevState.matches !== this.state.matches && this.props.onChange(this.state.matches); 48197 } 48198 }, { 48199 key: "componentWillUnmount", 48200 value: function() { 48201 this.removeMql(); 48202 } 48203 }, { 48204 key: "render", 48205 value: function() { 48206 if ("function" == typeof this.props.children) return this.props.children(this.state.matches); 48207 if (!1 === this.state.matches) return null; 48208 var props = omit(this.props, excludedPropKeys), hasMergeProps = Object.keys(props).length > 0, childrenCount = _react2.default.Children.count(this.props.children); 48209 return this.props.component || null == this.props.children || hasMergeProps && childrenCount > 1 ? _react2.default.createElement(this.props.component || "div", props, this.props.children) : hasMergeProps ? _react2.default.cloneElement(this.props.children, props) : childrenCount ? this.props.children : null; 48210 } 48211 } ]), MediaQuery; 48212 }(_react2.default.Component); 48213 MediaQuery.displayName = "MediaQuery", MediaQuery.defaultProps = { 48214 values: {} 48215 }, exports.default = MediaQuery, exports.toQuery = _toQuery2.default; 48216 }, function(module, exports) { 48217 module.exports = __WEBPACK_EXTERNAL_MODULE_8__; 48218 }, function(module, exports, __webpack_require__) { 48219 "use strict"; 48220 var emptyFunction = __webpack_require__(1), invariant = __webpack_require__(2), warning = __webpack_require__(3), assign = __webpack_require__(10), ReactPropTypesSecret = __webpack_require__(4), checkPropTypes = __webpack_require__(11); 48221 module.exports = function(isValidElement, throwOnDirectAccess) { 48222 function getIteratorFn(maybeIterable) { 48223 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); 48224 if ("function" == typeof iteratorFn) return iteratorFn; 48225 } 48226 function is(x, y) { 48227 return x === y ? 0 !== x || 1 / x == 1 / y : x !== x && y !== y; 48228 } 48229 function PropTypeError(message) { 48230 this.message = message, this.stack = ""; 48231 } 48232 function createChainableTypeChecker(validate) { 48233 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { 48234 if (componentName = componentName || ANONYMOUS, propFullName = propFullName || propName, 48235 secret !== ReactPropTypesSecret) if (throwOnDirectAccess) invariant(!1, "Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types"); else if ("undefined" != typeof console) { 48236 var cacheKey = componentName + ":" + propName; 48237 !manualPropTypeCallCache[cacheKey] && manualPropTypeWarningCount < 3 && (warning(!1, "You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.", propFullName, componentName), 48238 manualPropTypeCallCache[cacheKey] = !0, manualPropTypeWarningCount++); 48239 } 48240 return null == props[propName] ? isRequired ? new PropTypeError(null === props[propName] ? "The " + location + " `" + propFullName + "` is marked as required in `" + componentName + "`, but its value is `null`." : "The " + location + " `" + propFullName + "` is marked as required in `" + componentName + "`, but its value is `undefined`.") : null : validate(props, propName, componentName, location, propFullName); 48241 } 48242 var manualPropTypeCallCache = {}, manualPropTypeWarningCount = 0, chainedCheckType = checkType.bind(null, !1); 48243 return chainedCheckType.isRequired = checkType.bind(null, !0), chainedCheckType; 48244 } 48245 function createPrimitiveTypeChecker(expectedType) { 48246 function validate(props, propName, componentName, location, propFullName, secret) { 48247 var propValue = props[propName]; 48248 if (getPropType(propValue) !== expectedType) return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + getPreciseType(propValue) + "` supplied to `" + componentName + "`, expected `" + expectedType + "`."); 48249 return null; 48250 } 48251 return createChainableTypeChecker(validate); 48252 } 48253 function createArrayOfTypeChecker(typeChecker) { 48254 function validate(props, propName, componentName, location, propFullName) { 48255 if ("function" != typeof typeChecker) return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf."); 48256 var propValue = props[propName]; 48257 if (!Array.isArray(propValue)) { 48258 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + getPropType(propValue) + "` supplied to `" + componentName + "`, expected an array."); 48259 } 48260 for (var i = 0; i < propValue.length; i++) { 48261 var error = typeChecker(propValue, i, componentName, location, propFullName + "[" + i + "]", ReactPropTypesSecret); 48262 if (error instanceof Error) return error; 48263 } 48264 return null; 48265 } 48266 return createChainableTypeChecker(validate); 48267 } 48268 function createInstanceTypeChecker(expectedClass) { 48269 function validate(props, propName, componentName, location, propFullName) { 48270 if (!(props[propName] instanceof expectedClass)) { 48271 var expectedClassName = expectedClass.name || ANONYMOUS; 48272 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + getClassName(props[propName]) + "` supplied to `" + componentName + "`, expected instance of `" + expectedClassName + "`."); 48273 } 48274 return null; 48275 } 48276 return createChainableTypeChecker(validate); 48277 } 48278 function createEnumTypeChecker(expectedValues) { 48279 function validate(props, propName, componentName, location, propFullName) { 48280 for (var propValue = props[propName], i = 0; i < expectedValues.length; i++) if (is(propValue, expectedValues[i])) return null; 48281 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of value `" + propValue + "` supplied to `" + componentName + "`, expected one of " + JSON.stringify(expectedValues) + "."); 48282 } 48283 return Array.isArray(expectedValues) ? createChainableTypeChecker(validate) : (warning(!1, "Invalid argument supplied to oneOf, expected an instance of array."), 48284 emptyFunction.thatReturnsNull); 48285 } 48286 function createObjectOfTypeChecker(typeChecker) { 48287 function validate(props, propName, componentName, location, propFullName) { 48288 if ("function" != typeof typeChecker) return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside objectOf."); 48289 var propValue = props[propName], propType = getPropType(propValue); 48290 if ("object" !== propType) return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` supplied to `" + componentName + "`, expected an object."); 48291 for (var key in propValue) if (propValue.hasOwnProperty(key)) { 48292 var error = typeChecker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret); 48293 if (error instanceof Error) return error; 48294 } 48295 return null; 48296 } 48297 return createChainableTypeChecker(validate); 48298 } 48299 function createUnionTypeChecker(arrayOfTypeCheckers) { 48300 function validate(props, propName, componentName, location, propFullName) { 48301 for (var i = 0; i < arrayOfTypeCheckers.length; i++) { 48302 if (null == (0, arrayOfTypeCheckers[i])(props, propName, componentName, location, propFullName, ReactPropTypesSecret)) return null; 48303 } 48304 return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to `" + componentName + "`."); 48305 } 48306 if (!Array.isArray(arrayOfTypeCheckers)) return warning(!1, "Invalid argument supplied to oneOfType, expected an instance of array."), 48307 emptyFunction.thatReturnsNull; 48308 for (var i = 0; i < arrayOfTypeCheckers.length; i++) { 48309 var checker = arrayOfTypeCheckers[i]; 48310 if ("function" != typeof checker) return warning(!1, "Invalid argument supplied to oneOfType. Expected an array of check functions, but received %s at index %s.", getPostfixForTypeWarning(checker), i), 48311 emptyFunction.thatReturnsNull; 48312 } 48313 return createChainableTypeChecker(validate); 48314 } 48315 function createShapeTypeChecker(shapeTypes) { 48316 function validate(props, propName, componentName, location, propFullName) { 48317 var propValue = props[propName], propType = getPropType(propValue); 48318 if ("object" !== propType) return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` supplied to `" + componentName + "`, expected `object`."); 48319 for (var key in shapeTypes) { 48320 var checker = shapeTypes[key]; 48321 if (checker) { 48322 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret); 48323 if (error) return error; 48324 } 48325 } 48326 return null; 48327 } 48328 return createChainableTypeChecker(validate); 48329 } 48330 function createStrictShapeTypeChecker(shapeTypes) { 48331 function validate(props, propName, componentName, location, propFullName) { 48332 var propValue = props[propName], propType = getPropType(propValue); 48333 if ("object" !== propType) return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` supplied to `" + componentName + "`, expected `object`."); 48334 var allKeys = assign({}, props[propName], shapeTypes); 48335 for (var key in allKeys) { 48336 var checker = shapeTypes[key]; 48337 if (!checker) return new PropTypeError("Invalid " + location + " `" + propFullName + "` key `" + key + "` supplied to `" + componentName + "`.\nBad object: " + JSON.stringify(props[propName], null, " ") + "\nValid keys: " + JSON.stringify(Object.keys(shapeTypes), null, " ")); 48338 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret); 48339 if (error) return error; 48340 } 48341 return null; 48342 } 48343 return createChainableTypeChecker(validate); 48344 } 48345 function isNode(propValue) { 48346 switch (typeof propValue) { 48347 case "number": 48348 case "string": 48349 case "undefined": 48350 return !0; 48351 48352 case "boolean": 48353 return !propValue; 48354 48355 case "object": 48356 if (Array.isArray(propValue)) return propValue.every(isNode); 48357 if (null === propValue || isValidElement(propValue)) return !0; 48358 var iteratorFn = getIteratorFn(propValue); 48359 if (!iteratorFn) return !1; 48360 var step, iterator = iteratorFn.call(propValue); 48361 if (iteratorFn !== propValue.entries) { 48362 for (;!(step = iterator.next()).done; ) if (!isNode(step.value)) return !1; 48363 } else for (;!(step = iterator.next()).done; ) { 48364 var entry = step.value; 48365 if (entry && !isNode(entry[1])) return !1; 48366 } 48367 return !0; 48368 48369 default: 48370 return !1; 48371 } 48372 } 48373 function isSymbol(propType, propValue) { 48374 return "symbol" === propType || ("Symbol" === propValue["@@toStringTag"] || "function" == typeof Symbol && propValue instanceof Symbol); 48375 } 48376 function getPropType(propValue) { 48377 var propType = typeof propValue; 48378 return Array.isArray(propValue) ? "array" : propValue instanceof RegExp ? "object" : isSymbol(propType, propValue) ? "symbol" : propType; 48379 } 48380 function getPreciseType(propValue) { 48381 if (void 0 === propValue || null === propValue) return "" + propValue; 48382 var propType = getPropType(propValue); 48383 if ("object" === propType) { 48384 if (propValue instanceof Date) return "date"; 48385 if (propValue instanceof RegExp) return "regexp"; 48386 } 48387 return propType; 48388 } 48389 function getPostfixForTypeWarning(value) { 48390 var type = getPreciseType(value); 48391 switch (type) { 48392 case "array": 48393 case "object": 48394 return "an " + type; 48395 48396 case "boolean": 48397 case "date": 48398 case "regexp": 48399 return "a " + type; 48400 48401 default: 48402 return type; 48403 } 48404 } 48405 function getClassName(propValue) { 48406 return propValue.constructor && propValue.constructor.name ? propValue.constructor.name : ANONYMOUS; 48407 } 48408 var ITERATOR_SYMBOL = "function" == typeof Symbol && Symbol.iterator, FAUX_ITERATOR_SYMBOL = "@@iterator", ANONYMOUS = "<<anonymous>>", ReactPropTypes = { 48409 array: createPrimitiveTypeChecker("array"), 48410 bool: createPrimitiveTypeChecker("boolean"), 48411 func: createPrimitiveTypeChecker("function"), 48412 number: createPrimitiveTypeChecker("number"), 48413 object: createPrimitiveTypeChecker("object"), 48414 string: createPrimitiveTypeChecker("string"), 48415 symbol: createPrimitiveTypeChecker("symbol"), 48416 any: function() { 48417 return createChainableTypeChecker(emptyFunction.thatReturnsNull); 48418 }(), 48419 arrayOf: createArrayOfTypeChecker, 48420 element: function() { 48421 function validate(props, propName, componentName, location, propFullName) { 48422 var propValue = props[propName]; 48423 if (!isValidElement(propValue)) { 48424 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + getPropType(propValue) + "` supplied to `" + componentName + "`, expected a single ReactElement."); 48425 } 48426 return null; 48427 } 48428 return createChainableTypeChecker(validate); 48429 }(), 48430 instanceOf: createInstanceTypeChecker, 48431 node: function() { 48432 function validate(props, propName, componentName, location, propFullName) { 48433 return isNode(props[propName]) ? null : new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to `" + componentName + "`, expected a ReactNode."); 48434 } 48435 return createChainableTypeChecker(validate); 48436 }(), 48437 objectOf: createObjectOfTypeChecker, 48438 oneOf: createEnumTypeChecker, 48439 oneOfType: createUnionTypeChecker, 48440 shape: createShapeTypeChecker, 48441 exact: createStrictShapeTypeChecker 48442 }; 48443 return PropTypeError.prototype = Error.prototype, ReactPropTypes.checkPropTypes = checkPropTypes, 48444 ReactPropTypes.PropTypes = ReactPropTypes, ReactPropTypes; 48445 }; 48446 }, function(module, exports, __webpack_require__) { 48447 "use strict"; 48448 function toObject(val) { 48449 if (null === val || void 0 === val) throw new TypeError("Object.assign cannot be called with null or undefined"); 48450 return Object(val); 48451 } 48452 /* 48453object-assign 48454(c) Sindre Sorhus 48455@license MIT 48456*/ 48457 var getOwnPropertySymbols = Object.getOwnPropertySymbols, hasOwnProperty = Object.prototype.hasOwnProperty, propIsEnumerable = Object.prototype.propertyIsEnumerable; 48458 module.exports = function() { 48459 try { 48460 if (!Object.assign) return !1; 48461 var test1 = new String("abc"); 48462 if (test1[5] = "de", "5" === Object.getOwnPropertyNames(test1)[0]) return !1; 48463 for (var test2 = {}, i = 0; i < 10; i++) test2["_" + String.fromCharCode(i)] = i; 48464 if ("0123456789" !== Object.getOwnPropertyNames(test2).map(function(n) { 48465 return test2[n]; 48466 }).join("")) return !1; 48467 var test3 = {}; 48468 return "abcdefghijklmnopqrst".split("").forEach(function(letter) { 48469 test3[letter] = letter; 48470 }), "abcdefghijklmnopqrst" === Object.keys(Object.assign({}, test3)).join(""); 48471 } catch (err) { 48472 return !1; 48473 } 48474 }() ? Object.assign : function(target, source) { 48475 for (var from, symbols, to = toObject(target), s = 1; s < arguments.length; s++) { 48476 from = Object(arguments[s]); 48477 for (var key in from) hasOwnProperty.call(from, key) && (to[key] = from[key]); 48478 if (getOwnPropertySymbols) { 48479 symbols = getOwnPropertySymbols(from); 48480 for (var i = 0; i < symbols.length; i++) propIsEnumerable.call(from, symbols[i]) && (to[symbols[i]] = from[symbols[i]]); 48481 } 48482 } 48483 return to; 48484 }; 48485 }, function(module, exports, __webpack_require__) { 48486 "use strict"; 48487 function checkPropTypes(typeSpecs, values, location, componentName, getStack) { 48488 for (var typeSpecName in typeSpecs) if (typeSpecs.hasOwnProperty(typeSpecName)) { 48489 var error; 48490 try { 48491 invariant("function" == typeof typeSpecs[typeSpecName], "%s: %s type `%s` is invalid; it must be a function, usually from the `prop-types` package, but received `%s`.", componentName || "React class", location, typeSpecName, typeof typeSpecs[typeSpecName]), 48492 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); 48493 } catch (ex) { 48494 error = ex; 48495 } 48496 if (warning(!error || error instanceof Error, "%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error), 48497 error instanceof Error && !(error.message in loggedTypeFailures)) { 48498 loggedTypeFailures[error.message] = !0; 48499 var stack = getStack ? getStack() : ""; 48500 warning(!1, "Failed %s type: %s%s", location, error.message, null != stack ? stack : ""); 48501 } 48502 } 48503 } 48504 var invariant = __webpack_require__(2), warning = __webpack_require__(3), ReactPropTypesSecret = __webpack_require__(4), loggedTypeFailures = {}; 48505 module.exports = checkPropTypes; 48506 }, function(module, exports, __webpack_require__) { 48507 "use strict"; 48508 function Mql(query, values) { 48509 function addListener(listener) { 48510 mql && mql.addListener(listener); 48511 } 48512 function removeListener(listener) { 48513 mql && mql.removeListener(listener); 48514 } 48515 function update(evt) { 48516 self.matches = evt.matches, self.media = evt.media; 48517 } 48518 function dispose() { 48519 mql && mql.removeListener(update); 48520 } 48521 var self = this; 48522 if (dynamicMatch) { 48523 var mql = dynamicMatch.call(window, query); 48524 this.matches = mql.matches, this.media = mql.media, mql.addListener(update); 48525 } else this.matches = staticMatch(query, values), this.media = query; 48526 this.addListener = addListener, this.removeListener = removeListener, this.dispose = dispose; 48527 } 48528 function matchMedia(query, values) { 48529 return new Mql(query, values); 48530 } 48531 var staticMatch = __webpack_require__(13).match, dynamicMatch = "undefined" != typeof window ? window.matchMedia : null; 48532 module.exports = matchMedia; 48533 }, function(module, exports, __webpack_require__) { 48534 "use strict"; 48535 function matchQuery(mediaQuery, values) { 48536 return parseQuery(mediaQuery).some(function(query) { 48537 var inverse = query.inverse, typeMatch = "all" === query.type || values.type === query.type; 48538 if (typeMatch && inverse || !typeMatch && !inverse) return !1; 48539 var expressionsMatch = query.expressions.every(function(expression) { 48540 var feature = expression.feature, modifier = expression.modifier, expValue = expression.value, value = values[feature]; 48541 if (!value) return !1; 48542 switch (feature) { 48543 case "orientation": 48544 case "scan": 48545 return value.toLowerCase() === expValue.toLowerCase(); 48546 48547 case "width": 48548 case "height": 48549 case "device-width": 48550 case "device-height": 48551 expValue = toPx(expValue), value = toPx(value); 48552 break; 48553 48554 case "resolution": 48555 expValue = toDpi(expValue), value = toDpi(value); 48556 break; 48557 48558 case "aspect-ratio": 48559 case "device-aspect-ratio": 48560 case "device-pixel-ratio": 48561 expValue = toDecimal(expValue), value = toDecimal(value); 48562 break; 48563 48564 case "grid": 48565 case "color": 48566 case "color-index": 48567 case "monochrome": 48568 expValue = parseInt(expValue, 10) || 1, value = parseInt(value, 10) || 0; 48569 } 48570 switch (modifier) { 48571 case "min": 48572 return value >= expValue; 48573 48574 case "max": 48575 return value <= expValue; 48576 48577 default: 48578 return value === expValue; 48579 } 48580 }); 48581 return expressionsMatch && !inverse || !expressionsMatch && inverse; 48582 }); 48583 } 48584 function parseQuery(mediaQuery) { 48585 return mediaQuery.split(",").map(function(query) { 48586 query = query.trim(); 48587 var captures = query.match(RE_MEDIA_QUERY), modifier = captures[1], type = captures[2], expressions = captures[3] || "", parsed = {}; 48588 return parsed.inverse = !!modifier && "not" === modifier.toLowerCase(), parsed.type = type ? type.toLowerCase() : "all", 48589 expressions = expressions.match(/\([^\)]+\)/g) || [], parsed.expressions = expressions.map(function(expression) { 48590 var captures = expression.match(RE_MQ_EXPRESSION), feature = captures[1].toLowerCase().match(RE_MQ_FEATURE); 48591 return { 48592 modifier: feature[1], 48593 feature: feature[2], 48594 value: captures[2] 48595 }; 48596 }), parsed; 48597 }); 48598 } 48599 function toDecimal(ratio) { 48600 var numbers, decimal = Number(ratio); 48601 return decimal || (numbers = ratio.match(/^(\d+)\s*\/\s*(\d+)$/), decimal = numbers[1] / numbers[2]), 48602 decimal; 48603 } 48604 function toDpi(resolution) { 48605 var value = parseFloat(resolution); 48606 switch (String(resolution).match(RE_RESOLUTION_UNIT)[1]) { 48607 case "dpcm": 48608 return value / 2.54; 48609 48610 case "dppx": 48611 return 96 * value; 48612 48613 default: 48614 return value; 48615 } 48616 } 48617 function toPx(length) { 48618 var value = parseFloat(length); 48619 switch (String(length).match(RE_LENGTH_UNIT)[1]) { 48620 case "em": 48621 case "rem": 48622 return 16 * value; 48623 48624 case "cm": 48625 return 96 * value / 2.54; 48626 48627 case "mm": 48628 return 96 * value / 2.54 / 10; 48629 48630 case "in": 48631 return 96 * value; 48632 48633 case "pt": 48634 return 72 * value; 48635 48636 case "pc": 48637 return 72 * value / 12; 48638 48639 default: 48640 return value; 48641 } 48642 } 48643 exports.match = matchQuery, exports.parse = parseQuery; 48644 var RE_MEDIA_QUERY = /(?:(only|not)?\s*([^\s\(\)]+)(?:\s*and)?\s*)?(.+)?/i, RE_MQ_EXPRESSION = /\(\s*([^\s\:\)]+)\s*(?:\:\s*([^\s\)]+))?\s*\)/, RE_MQ_FEATURE = /^(?:(min|max)-)?(.+)/, RE_LENGTH_UNIT = /(em|rem|px|cm|mm|in|pt|pc)?$/, RE_RESOLUTION_UNIT = /(dpi|dpcm|dppx)?$/; 48645 }, function(module, exports, __webpack_require__) { 48646 "use strict"; 48647 function _interopRequireDefault(obj) { 48648 return obj && obj.__esModule ? obj : { 48649 default: obj 48650 }; 48651 } 48652 function keyVal(k, v) { 48653 var realKey = (0, _hyphenateStyleName2.default)(k); 48654 return "number" == typeof v && (v += "px"), !0 === v ? k : !1 === v ? negate(k) : "(" + realKey + ": " + v + ")"; 48655 } 48656 function join(conds) { 48657 return conds.join(" and "); 48658 } 48659 Object.defineProperty(exports, "__esModule", { 48660 value: !0 48661 }), exports.default = function(obj) { 48662 var rules = []; 48663 return Object.keys(_mediaQuery2.default.all).forEach(function(k) { 48664 var v = obj[k]; 48665 null != v && rules.push(keyVal(k, v)); 48666 }), join(rules); 48667 }; 48668 var _hyphenateStyleName = __webpack_require__(5), _hyphenateStyleName2 = _interopRequireDefault(_hyphenateStyleName), _mediaQuery = __webpack_require__(6), _mediaQuery2 = _interopRequireDefault(_mediaQuery), negate = function(cond) { 48669 return "not " + cond; 48670 }; 48671 module.exports = exports.default; 48672 } ]); 48673}); 48674//# sourceMappingURL=react-responsive.js.map 48675 48676/***/ }), 48677
vendor: 50,149 bytes, lines 48678-50175
48678/***/ "./node_modules/react/cjs/react.development.js": 48679/*!*****************************************************!*\ 48680 !*** ./node_modules/react/cjs/react.development.js ***! 48681 \*****************************************************/ 48682/*! no static exports found */ 48683/***/ (function(module, exports, __webpack_require__) { 48684 48685"use strict"; 48686/** @license React v16.4.1 48687 * react.development.js 48688 * 48689 * Copyright (c) 2013-present, Facebook, Inc. 48690 * 48691 * This source code is licensed under the MIT license found in the 48692 * LICENSE file in the root directory of this source tree. 48693 */ 48694 48695 48696 48697 48698 48699if (true) { 48700 (function() { 48701'use strict'; 48702 48703var _assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js"); 48704var invariant = __webpack_require__(/*! fbjs/lib/invariant */ "./node_modules/fbjs/lib/invariant.js"); 48705var emptyObject = __webpack_require__(/*! fbjs/lib/emptyObject */ "./node_modules/fbjs/lib/emptyObject.js"); 48706var warning = __webpack_require__(/*! fbjs/lib/warning */ "./node_modules/fbjs/lib/warning.js"); 48707var emptyFunction = __webpack_require__(/*! fbjs/lib/emptyFunction */ "./node_modules/fbjs/lib/emptyFunction.js"); 48708var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "./node_modules/prop-types/checkPropTypes.js"); 48709 48710// TODO: this is special because it gets imported during build. 48711 48712var ReactVersion = '16.4.1'; 48713 48714// The Symbol used to tag the ReactElement-like types. If there is no native Symbol 48715// nor polyfill, then a plain number is used for performance. 48716var hasSymbol = typeof Symbol === 'function' && Symbol.for; 48717 48718var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; 48719var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; 48720var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; 48721var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; 48722var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; 48723var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; 48724var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; 48725var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; 48726var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; 48727var REACT_TIMEOUT_TYPE = hasSymbol ? Symbol.for('react.timeout') : 0xead1; 48728 48729var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 48730var FAUX_ITERATOR_SYMBOL = '@@iterator'; 48731 48732function getIteratorFn(maybeIterable) { 48733 if (maybeIterable === null || typeof maybeIterable === 'undefined') { 48734 return null; 48735 } 48736 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 48737 if (typeof maybeIterator === 'function') { 48738 return maybeIterator; 48739 } 48740 return null; 48741} 48742 48743// Relying on the `invariant()` implementation lets us 48744// have preserve the format and params in the www builds. 48745 48746// Exports ReactDOM.createRoot 48747 48748 48749// Experimental error-boundary API that can recover from errors within a single 48750// render phase 48751 48752// Suspense 48753var enableSuspense = false; 48754// Helps identify side effects in begin-phase lifecycle hooks and setState reducers: 48755 48756 48757// In some cases, StrictMode should also double-render lifecycles. 48758// This can be confusing for tests though, 48759// And it can be bad for performance in production. 48760// This feature flag can be used to control the behavior: 48761 48762 48763// To preserve the "Pause on caught exceptions" behavior of the debugger, we 48764// replay the begin phase of a failed component inside invokeGuardedCallback. 48765 48766 48767// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6: 48768 48769 48770// Warn about legacy context API 48771 48772 48773// Gather advanced timing metrics for Profiler subtrees. 48774 48775 48776// Only used in www builds. 48777 48778/** 48779 * Forked from fbjs/warning: 48780 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js 48781 * 48782 * Only change is we use console.warn instead of console.error, 48783 * and do nothing when 'console' is not supported. 48784 * This really simplifies the code. 48785 * --- 48786 * Similar to invariant but only logs a warning if the condition is not met. 48787 * This can be used to log issues in development environments in critical 48788 * paths. Removing the logging code for production environments will keep the 48789 * same logic and follow the same code paths. 48790 */ 48791 48792var lowPriorityWarning = function () {}; 48793 48794{ 48795 var printWarning = function (format) { 48796 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 48797 args[_key - 1] = arguments[_key]; 48798 } 48799 48800 var argIndex = 0; 48801 var message = 'Warning: ' + format.replace(/%s/g, function () { 48802 return args[argIndex++]; 48803 }); 48804 if (typeof console !== 'undefined') { 48805 console.warn(message); 48806 } 48807 try { 48808 // --- Welcome to debugging React --- 48809 // This error was thrown as a convenience so that you can use this stack 48810 // to find the callsite that caused this warning to fire. 48811 throw new Error(message); 48812 } catch (x) {} 48813 }; 48814 48815 lowPriorityWarning = function (condition, format) { 48816 if (format === undefined) { 48817 throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); 48818 } 48819 if (!condition) { 48820 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { 48821 args[_key2 - 2] = arguments[_key2]; 48822 } 48823 48824 printWarning.apply(undefined, [format].concat(args)); 48825 } 48826 }; 48827} 48828 48829var lowPriorityWarning$1 = lowPriorityWarning; 48830 48831var didWarnStateUpdateForUnmountedComponent = {}; 48832 48833function warnNoop(publicInstance, callerName) { 48834 { 48835 var _constructor = publicInstance.constructor; 48836 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; 48837 var warningKey = componentName + '.' + callerName; 48838 if (didWarnStateUpdateForUnmountedComponent[warningKey]) { 48839 return; 48840 } 48841 warning(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName); 48842 didWarnStateUpdateForUnmountedComponent[warningKey] = true; 48843 } 48844} 48845 48846/** 48847 * This is the abstract API for an update queue. 48848 */ 48849var ReactNoopUpdateQueue = { 48850 /** 48851 * Checks whether or not this composite component is mounted. 48852 * @param {ReactClass} publicInstance The instance we want to test. 48853 * @return {boolean} True if mounted, false otherwise. 48854 * @protected 48855 * @final 48856 */ 48857 isMounted: function (publicInstance) { 48858 return false; 48859 }, 48860 48861 /** 48862 * Forces an update. This should only be invoked when it is known with 48863 * certainty that we are **not** in a DOM transaction. 48864 * 48865 * You may want to call this when you know that some deeper aspect of the 48866 * component's state has changed but `setState` was not called. 48867 * 48868 * This will not invoke `shouldComponentUpdate`, but it will invoke 48869 * `componentWillUpdate` and `componentDidUpdate`. 48870 * 48871 * @param {ReactClass} publicInstance The instance that should rerender. 48872 * @param {?function} callback Called after component is updated. 48873 * @param {?string} callerName name of the calling function in the public API. 48874 * @internal 48875 */ 48876 enqueueForceUpdate: function (publicInstance, callback, callerName) { 48877 warnNoop(publicInstance, 'forceUpdate'); 48878 }, 48879 48880 /** 48881 * Replaces all of the state. Always use this or `setState` to mutate state. 48882 * You should treat `this.state` as immutable. 48883 * 48884 * There is no guarantee that `this.state` will be immediately updated, so 48885 * accessing `this.state` after calling this method may return the old value. 48886 * 48887 * @param {ReactClass} publicInstance The instance that should rerender. 48888 * @param {object} completeState Next state. 48889 * @param {?function} callback Called after component is updated. 48890 * @param {?string} callerName name of the calling function in the public API. 48891 * @internal 48892 */ 48893 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { 48894 warnNoop(publicInstance, 'replaceState'); 48895 }, 48896 48897 /** 48898 * Sets a subset of the state. This only exists because _pendingState is 48899 * internal. This provides a merging strategy that is not available to deep 48900 * properties which is confusing. TODO: Expose pendingState or don't use it 48901 * during the merge. 48902 * 48903 * @param {ReactClass} publicInstance The instance that should rerender. 48904 * @param {object} partialState Next partial state to be merged with state. 48905 * @param {?function} callback Called after component is updated. 48906 * @param {?string} Name of the calling function in the public API. 48907 * @internal 48908 */ 48909 enqueueSetState: function (publicInstance, partialState, callback, callerName) { 48910 warnNoop(publicInstance, 'setState'); 48911 } 48912}; 48913 48914/** 48915 * Base class helpers for the updating state of a component. 48916 */ 48917function Component(props, context, updater) { 48918 this.props = props; 48919 this.context = context; 48920 this.refs = emptyObject; 48921 // We initialize the default updater but the real one gets injected by the 48922 // renderer. 48923 this.updater = updater || ReactNoopUpdateQueue; 48924} 48925 48926Component.prototype.isReactComponent = {}; 48927 48928/** 48929 * Sets a subset of the state. Always use this to mutate 48930 * state. You should treat `this.state` as immutable. 48931 * 48932 * There is no guarantee that `this.state` will be immediately updated, so 48933 * accessing `this.state` after calling this method may return the old value. 48934 * 48935 * There is no guarantee that calls to `setState` will run synchronously, 48936 * as they may eventually be batched together. You can provide an optional 48937 * callback that will be executed when the call to setState is actually 48938 * completed. 48939 * 48940 * When a function is provided to setState, it will be called at some point in 48941 * the future (not synchronously). It will be called with the up to date 48942 * component arguments (state, props, context). These values can be different 48943 * from this.* because your function may be called after receiveProps but before 48944 * shouldComponentUpdate, and this new state, props, and context will not yet be 48945 * assigned to this. 48946 * 48947 * @param {object|function} partialState Next partial state or function to 48948 * produce next partial state to be merged with current state. 48949 * @param {?function} callback Called after state is updated. 48950 * @final 48951 * @protected 48952 */ 48953Component.prototype.setState = function (partialState, callback) { 48954 !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0; 48955 this.updater.enqueueSetState(this, partialState, callback, 'setState'); 48956}; 48957 48958/** 48959 * Forces an update. This should only be invoked when it is known with 48960 * certainty that we are **not** in a DOM transaction. 48961 * 48962 * You may want to call this when you know that some deeper aspect of the 48963 * component's state has changed but `setState` was not called. 48964 * 48965 * This will not invoke `shouldComponentUpdate`, but it will invoke 48966 * `componentWillUpdate` and `componentDidUpdate`. 48967 * 48968 * @param {?function} callback Called after update is complete. 48969 * @final 48970 * @protected 48971 */ 48972Component.prototype.forceUpdate = function (callback) { 48973 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); 48974}; 48975 48976/** 48977 * Deprecated APIs. These APIs used to exist on classic React classes but since 48978 * we would like to deprecate them, we're not going to move them over to this 48979 * modern base class. Instead, we define a getter that warns if it's accessed. 48980 */ 48981{ 48982 var deprecatedAPIs = { 48983 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], 48984 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] 48985 }; 48986 var defineDeprecationWarning = function (methodName, info) { 48987 Object.defineProperty(Component.prototype, methodName, { 48988 get: function () { 48989 lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); 48990 return undefined; 48991 } 48992 }); 48993 }; 48994 for (var fnName in deprecatedAPIs) { 48995 if (deprecatedAPIs.hasOwnProperty(fnName)) { 48996 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); 48997 } 48998 } 48999} 49000 49001function ComponentDummy() {} 49002ComponentDummy.prototype = Component.prototype; 49003 49004/** 49005 * Convenience component with default shallow equality check for sCU. 49006 */ 49007function PureComponent(props, context, updater) { 49008 this.props = props; 49009 this.context = context; 49010 this.refs = emptyObject; 49011 this.updater = updater || ReactNoopUpdateQueue; 49012} 49013 49014var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); 49015pureComponentPrototype.constructor = PureComponent; 49016// Avoid an extra prototype jump for these methods. 49017_assign(pureComponentPrototype, Component.prototype); 49018pureComponentPrototype.isPureReactComponent = true; 49019 49020// an immutable object with a single mutable value 49021function createRef() { 49022 var refObject = { 49023 current: null 49024 }; 49025 { 49026 Object.seal(refObject); 49027 } 49028 return refObject; 49029} 49030 49031/** 49032 * Keeps track of the current owner. 49033 * 49034 * The current owner is the component who should own any components that are 49035 * currently being constructed. 49036 */ 49037var ReactCurrentOwner = { 49038 /** 49039 * @internal 49040 * @type {ReactComponent} 49041 */ 49042 current: null 49043}; 49044 49045var hasOwnProperty = Object.prototype.hasOwnProperty; 49046 49047var RESERVED_PROPS = { 49048 key: true, 49049 ref: true, 49050 __self: true, 49051 __source: true 49052}; 49053 49054var specialPropKeyWarningShown = void 0; 49055var specialPropRefWarningShown = void 0; 49056 49057function hasValidRef(config) { 49058 { 49059 if (hasOwnProperty.call(config, 'ref')) { 49060 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; 49061 if (getter && getter.isReactWarning) { 49062 return false; 49063 } 49064 } 49065 } 49066 return config.ref !== undefined; 49067} 49068 49069function hasValidKey(config) { 49070 { 49071 if (hasOwnProperty.call(config, 'key')) { 49072 var getter = Object.getOwnPropertyDescriptor(config, 'key').get; 49073 if (getter && getter.isReactWarning) { 49074 return false; 49075 } 49076 } 49077 } 49078 return config.key !== undefined; 49079} 49080 49081function defineKeyPropWarningGetter(props, displayName) { 49082 var warnAboutAccessingKey = function () { 49083 if (!specialPropKeyWarningShown) { 49084 specialPropKeyWarningShown = true; 49085 warning(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); 49086 } 49087 }; 49088 warnAboutAccessingKey.isReactWarning = true; 49089 Object.defineProperty(props, 'key', { 49090 get: warnAboutAccessingKey, 49091 configurable: true 49092 }); 49093} 49094 49095function defineRefPropWarningGetter(props, displayName) { 49096 var warnAboutAccessingRef = function () { 49097 if (!specialPropRefWarningShown) { 49098 specialPropRefWarningShown = true; 49099 warning(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); 49100 } 49101 }; 49102 warnAboutAccessingRef.isReactWarning = true; 49103 Object.defineProperty(props, 'ref', { 49104 get: warnAboutAccessingRef, 49105 configurable: true 49106 }); 49107} 49108 49109/** 49110 * Factory method to create a new React element. This no longer adheres to 49111 * the class pattern, so do not use new to call it. Also, no instanceof check 49112 * will work. Instead test $$typeof field against Symbol.for('react.element') to check 49113 * if something is a React Element. 49114 * 49115 * @param {*} type 49116 * @param {*} key 49117 * @param {string|object} ref 49118 * @param {*} self A *temporary* helper to detect places where `this` is 49119 * different from the `owner` when React.createElement is called, so that we 49120 * can warn. We want to get rid of owner and replace string `ref`s with arrow 49121 * functions, and as long as `this` and owner are the same, there will be no 49122 * change in behavior. 49123 * @param {*} source An annotation object (added by a transpiler or otherwise) 49124 * indicating filename, line number, and/or other information. 49125 * @param {*} owner 49126 * @param {*} props 49127 * @internal 49128 */ 49129var ReactElement = function (type, key, ref, self, source, owner, props) { 49130 var element = { 49131 // This tag allows us to uniquely identify this as a React Element 49132 $$typeof: REACT_ELEMENT_TYPE, 49133 49134 // Built-in properties that belong on the element 49135 type: type, 49136 key: key, 49137 ref: ref, 49138 props: props, 49139 49140 // Record the component responsible for creating this element. 49141 _owner: owner 49142 }; 49143 49144 { 49145 // The validation flag is currently mutative. We put it on 49146 // an external backing store so that we can freeze the whole object. 49147 // This can be replaced with a WeakMap once they are implemented in 49148 // commonly used development environments. 49149 element._store = {}; 49150 49151 // To make comparing ReactElements easier for testing purposes, we make 49152 // the validation flag non-enumerable (where possible, which should 49153 // include every environment we run tests in), so the test framework 49154 // ignores it. 49155 Object.defineProperty(element._store, 'validated', { 49156 configurable: false, 49157 enumerable: false, 49158 writable: true, 49159 value: false 49160 }); 49161 // self and source are DEV only properties. 49162 Object.defineProperty(element, '_self', { 49163 configurable: false, 49164 enumerable: false, 49165 writable: false, 49166 value: self 49167 }); 49168 // Two elements created in two different places should be considered 49169 // equal for testing purposes and therefore we hide it from enumeration. 49170 Object.defineProperty(element, '_source', { 49171 configurable: false, 49172 enumerable: false, 49173 writable: false, 49174 value: source 49175 }); 49176 if (Object.freeze) { 49177 Object.freeze(element.props); 49178 Object.freeze(element); 49179 } 49180 } 49181 49182 return element; 49183}; 49184 49185/** 49186 * Create and return a new ReactElement of the given type. 49187 * See https://reactjs.org/docs/react-api.html#createelement 49188 */ 49189function createElement(type, config, children) { 49190 var propName = void 0; 49191 49192 // Reserved names are extracted 49193 var props = {}; 49194 49195 var key = null; 49196 var ref = null; 49197 var self = null; 49198 var source = null; 49199 49200 if (config != null) { 49201 if (hasValidRef(config)) { 49202 ref = config.ref; 49203 } 49204 if (hasValidKey(config)) { 49205 key = '' + config.key; 49206 } 49207 49208 self = config.__self === undefined ? null : config.__self; 49209 source = config.__source === undefined ? null : config.__source; 49210 // Remaining properties are added to a new props object 49211 for (propName in config) { 49212 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 49213 props[propName] = config[propName]; 49214 } 49215 } 49216 } 49217 49218 // Children can be more than one argument, and those are transferred onto 49219 // the newly allocated props object. 49220 var childrenLength = arguments.length - 2; 49221 if (childrenLength === 1) { 49222 props.children = children; 49223 } else if (childrenLength > 1) { 49224 var childArray = Array(childrenLength); 49225 for (var i = 0; i < childrenLength; i++) { 49226 childArray[i] = arguments[i + 2]; 49227 } 49228 { 49229 if (Object.freeze) { 49230 Object.freeze(childArray); 49231 } 49232 } 49233 props.children = childArray; 49234 } 49235 49236 // Resolve default props 49237 if (type && type.defaultProps) { 49238 var defaultProps = type.defaultProps; 49239 for (propName in defaultProps) { 49240 if (props[propName] === undefined) { 49241 props[propName] = defaultProps[propName]; 49242 } 49243 } 49244 } 49245 { 49246 if (key || ref) { 49247 if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) { 49248 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; 49249 if (key) { 49250 defineKeyPropWarningGetter(props, displayName); 49251 } 49252 if (ref) { 49253 defineRefPropWarningGetter(props, displayName); 49254 } 49255 } 49256 } 49257 } 49258 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); 49259} 49260 49261/** 49262 * Return a function that produces ReactElements of a given type. 49263 * See https://reactjs.org/docs/react-api.html#createfactory 49264 */ 49265 49266 49267function cloneAndReplaceKey(oldElement, newKey) { 49268 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); 49269 49270 return newElement; 49271} 49272 49273/** 49274 * Clone and return a new ReactElement using element as the starting point. 49275 * See https://reactjs.org/docs/react-api.html#cloneelement 49276 */ 49277function cloneElement(element, config, children) { 49278 !!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0; 49279 49280 var propName = void 0; 49281 49282 // Original props are copied 49283 var props = _assign({}, element.props); 49284 49285 // Reserved names are extracted 49286 var key = element.key; 49287 var ref = element.ref; 49288 // Self is preserved since the owner is preserved. 49289 var self = element._self; 49290 // Source is preserved since cloneElement is unlikely to be targeted by a 49291 // transpiler, and the original source is probably a better indicator of the 49292 // true owner. 49293 var source = element._source; 49294 49295 // Owner will be preserved, unless ref is overridden 49296 var owner = element._owner; 49297 49298 if (config != null) { 49299 if (hasValidRef(config)) { 49300 // Silently steal the ref from the parent. 49301 ref = config.ref; 49302 owner = ReactCurrentOwner.current; 49303 } 49304 if (hasValidKey(config)) { 49305 key = '' + config.key; 49306 } 49307 49308 // Remaining properties override existing props 49309 var defaultProps = void 0; 49310 if (element.type && element.type.defaultProps) { 49311 defaultProps = element.type.defaultProps; 49312 } 49313 for (propName in config) { 49314 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 49315 if (config[propName] === undefined && defaultProps !== undefined) { 49316 // Resolve default props 49317 props[propName] = defaultProps[propName]; 49318 } else { 49319 props[propName] = config[propName]; 49320 } 49321 } 49322 } 49323 } 49324 49325 // Children can be more than one argument, and those are transferred onto 49326 // the newly allocated props object. 49327 var childrenLength = arguments.length - 2; 49328 if (childrenLength === 1) { 49329 props.children = children; 49330 } else if (childrenLength > 1) { 49331 var childArray = Array(childrenLength); 49332 for (var i = 0; i < childrenLength; i++) { 49333 childArray[i] = arguments[i + 2]; 49334 } 49335 props.children = childArray; 49336 } 49337 49338 return ReactElement(element.type, key, ref, self, source, owner, props); 49339} 49340 49341/** 49342 * Verifies the object is a ReactElement. 49343 * See https://reactjs.org/docs/react-api.html#isvalidelement 49344 * @param {?object} object 49345 * @return {boolean} True if `object` is a valid component. 49346 * @final 49347 */ 49348function isValidElement(object) { 49349 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; 49350} 49351 49352var ReactDebugCurrentFrame = {}; 49353 49354{ 49355 // Component that is being worked on 49356 ReactDebugCurrentFrame.getCurrentStack = null; 49357 49358 ReactDebugCurrentFrame.getStackAddendum = function () { 49359 var impl = ReactDebugCurrentFrame.getCurrentStack; 49360 if (impl) { 49361 return impl(); 49362 } 49363 return null; 49364 }; 49365} 49366 49367var SEPARATOR = '.'; 49368var SUBSEPARATOR = ':'; 49369 49370/** 49371 * Escape and wrap key so it is safe to use as a reactid 49372 * 49373 * @param {string} key to be escaped. 49374 * @return {string} the escaped key. 49375 */ 49376function escape(key) { 49377 var escapeRegex = /[=:]/g; 49378 var escaperLookup = { 49379 '=': '=0', 49380 ':': '=2' 49381 }; 49382 var escapedString = ('' + key).replace(escapeRegex, function (match) { 49383 return escaperLookup[match]; 49384 }); 49385 49386 return '$' + escapedString; 49387} 49388 49389/** 49390 * TODO: Test that a single child and an array with one item have the same key 49391 * pattern. 49392 */ 49393 49394var didWarnAboutMaps = false; 49395 49396var userProvidedKeyEscapeRegex = /\/+/g; 49397function escapeUserProvidedKey(text) { 49398 return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/'); 49399} 49400 49401var POOL_SIZE = 10; 49402var traverseContextPool = []; 49403function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) { 49404 if (traverseContextPool.length) { 49405 var traverseContext = traverseContextPool.pop(); 49406 traverseContext.result = mapResult; 49407 traverseContext.keyPrefix = keyPrefix; 49408 traverseContext.func = mapFunction; 49409 traverseContext.context = mapContext; 49410 traverseContext.count = 0; 49411 return traverseContext; 49412 } else { 49413 return { 49414 result: mapResult, 49415 keyPrefix: keyPrefix, 49416 func: mapFunction, 49417 context: mapContext, 49418 count: 0 49419 }; 49420 } 49421} 49422 49423function releaseTraverseContext(traverseContext) { 49424 traverseContext.result = null; 49425 traverseContext.keyPrefix = null; 49426 traverseContext.func = null; 49427 traverseContext.context = null; 49428 traverseContext.count = 0; 49429 if (traverseContextPool.length < POOL_SIZE) { 49430 traverseContextPool.push(traverseContext); 49431 } 49432} 49433 49434/** 49435 * @param {?*} children Children tree container. 49436 * @param {!string} nameSoFar Name of the key path so far. 49437 * @param {!function} callback Callback to invoke with each child found. 49438 * @param {?*} traverseContext Used to pass information throughout the traversal 49439 * process. 49440 * @return {!number} The number of children in this subtree. 49441 */ 49442function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { 49443 var type = typeof children; 49444 49445 if (type === 'undefined' || type === 'boolean') { 49446 // All of the above are perceived as null. 49447 children = null; 49448 } 49449 49450 var invokeCallback = false; 49451 49452 if (children === null) { 49453 invokeCallback = true; 49454 } else { 49455 switch (type) { 49456 case 'string': 49457 case 'number': 49458 invokeCallback = true; 49459 break; 49460 case 'object': 49461 switch (children.$$typeof) { 49462 case REACT_ELEMENT_TYPE: 49463 case REACT_PORTAL_TYPE: 49464 invokeCallback = true; 49465 } 49466 } 49467 } 49468 49469 if (invokeCallback) { 49470 callback(traverseContext, children, 49471 // If it's the only child, treat the name as if it was wrapped in an array 49472 // so that it's consistent if the number of children grows. 49473 nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); 49474 return 1; 49475 } 49476 49477 var child = void 0; 49478 var nextName = void 0; 49479 var subtreeCount = 0; // Count of children found in the current subtree. 49480 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; 49481 49482 if (Array.isArray(children)) { 49483 for (var i = 0; i < children.length; i++) { 49484 child = children[i]; 49485 nextName = nextNamePrefix + getComponentKey(child, i); 49486 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); 49487 } 49488 } else { 49489 var iteratorFn = getIteratorFn(children); 49490 if (typeof iteratorFn === 'function') { 49491 { 49492 // Warn about using Maps as children 49493 if (iteratorFn === children.entries) { 49494 !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', ReactDebugCurrentFrame.getStackAddendum()) : void 0; 49495 didWarnAboutMaps = true; 49496 } 49497 } 49498 49499 var iterator = iteratorFn.call(children); 49500 var step = void 0; 49501 var ii = 0; 49502 while (!(step = iterator.next()).done) { 49503 child = step.value; 49504 nextName = nextNamePrefix + getComponentKey(child, ii++); 49505 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); 49506 } 49507 } else if (type === 'object') { 49508 var addendum = ''; 49509 { 49510 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum(); 49511 } 49512 var childrenString = '' + children; 49513 invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum); 49514 } 49515 } 49516 49517 return subtreeCount; 49518} 49519 49520/** 49521 * Traverses children that are typically specified as `props.children`, but 49522 * might also be specified through attributes: 49523 * 49524 * - `traverseAllChildren(this.props.children, ...)` 49525 * - `traverseAllChildren(this.props.leftPanelChildren, ...)` 49526 * 49527 * The `traverseContext` is an optional argument that is passed through the 49528 * entire traversal. It can be used to store accumulations or anything else that 49529 * the callback might find relevant. 49530 * 49531 * @param {?*} children Children tree object. 49532 * @param {!function} callback To invoke upon traversing each child. 49533 * @param {?*} traverseContext Context for traversal. 49534 * @return {!number} The number of children in this subtree. 49535 */ 49536function traverseAllChildren(children, callback, traverseContext) { 49537 if (children == null) { 49538 return 0; 49539 } 49540 49541 return traverseAllChildrenImpl(children, '', callback, traverseContext); 49542} 49543 49544/** 49545 * Generate a key string that identifies a component within a set. 49546 * 49547 * @param {*} component A component that could contain a manual key. 49548 * @param {number} index Index that is used if a manual key is not provided. 49549 * @return {string} 49550 */ 49551function getComponentKey(component, index) { 49552 // Do some typechecking here since we call this blindly. We want to ensure 49553 // that we don't block potential future ES APIs. 49554 if (typeof component === 'object' && component !== null && component.key != null) { 49555 // Explicit key 49556 return escape(component.key); 49557 } 49558 // Implicit key determined by the index in the set 49559 return index.toString(36); 49560} 49561 49562function forEachSingleChild(bookKeeping, child, name) { 49563 var func = bookKeeping.func, 49564 context = bookKeeping.context; 49565 49566 func.call(context, child, bookKeeping.count++); 49567} 49568 49569/** 49570 * Iterates through children that are typically specified as `props.children`. 49571 * 49572 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach 49573 * 49574 * The provided forEachFunc(child, index) will be called for each 49575 * leaf child. 49576 * 49577 * @param {?*} children Children tree container. 49578 * @param {function(*, int)} forEachFunc 49579 * @param {*} forEachContext Context for forEachContext. 49580 */ 49581function forEachChildren(children, forEachFunc, forEachContext) { 49582 if (children == null) { 49583 return children; 49584 } 49585 var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext); 49586 traverseAllChildren(children, forEachSingleChild, traverseContext); 49587 releaseTraverseContext(traverseContext); 49588} 49589 49590function mapSingleChildIntoContext(bookKeeping, child, childKey) { 49591 var result = bookKeeping.result, 49592 keyPrefix = bookKeeping.keyPrefix, 49593 func = bookKeeping.func, 49594 context = bookKeeping.context; 49595 49596 49597 var mappedChild = func.call(context, child, bookKeeping.count++); 49598 if (Array.isArray(mappedChild)) { 49599 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument); 49600 } else if (mappedChild != null) { 49601 if (isValidElement(mappedChild)) { 49602 mappedChild = cloneAndReplaceKey(mappedChild, 49603 // Keep both the (mapped) and old keys if they differ, just as 49604 // traverseAllChildren used to do for objects as children 49605 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey); 49606 } 49607 result.push(mappedChild); 49608 } 49609} 49610 49611function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) { 49612 var escapedPrefix = ''; 49613 if (prefix != null) { 49614 escapedPrefix = escapeUserProvidedKey(prefix) + '/'; 49615 } 49616 var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context); 49617 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext); 49618 releaseTraverseContext(traverseContext); 49619} 49620 49621/** 49622 * Maps children that are typically specified as `props.children`. 49623 * 49624 * See https://reactjs.org/docs/react-api.html#reactchildrenmap 49625 * 49626 * The provided mapFunction(child, key, index) will be called for each 49627 * leaf child. 49628 * 49629 * @param {?*} children Children tree container. 49630 * @param {function(*, int)} func The map function. 49631 * @param {*} context Context for mapFunction. 49632 * @return {object} Object containing the ordered map of results. 49633 */ 49634function mapChildren(children, func, context) { 49635 if (children == null) { 49636 return children; 49637 } 49638 var result = []; 49639 mapIntoWithKeyPrefixInternal(children, result, null, func, context); 49640 return result; 49641} 49642 49643/** 49644 * Count the number of children that are typically specified as 49645 * `props.children`. 49646 * 49647 * See https://reactjs.org/docs/react-api.html#reactchildrencount 49648 * 49649 * @param {?*} children Children tree container. 49650 * @return {number} The number of children. 49651 */ 49652function countChildren(children) { 49653 return traverseAllChildren(children, emptyFunction.thatReturnsNull, null); 49654} 49655 49656/** 49657 * Flatten a children object (typically specified as `props.children`) and 49658 * return an array with appropriately re-keyed children. 49659 * 49660 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray 49661 */ 49662function toArray(children) { 49663 var result = []; 49664 mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument); 49665 return result; 49666} 49667 49668/** 49669 * Returns the first child in a collection of children and verifies that there 49670 * is only one child in the collection. 49671 * 49672 * See https://reactjs.org/docs/react-api.html#reactchildrenonly 49673 * 49674 * The current implementation of this function assumes that a single child gets 49675 * passed without a wrapper, but the purpose of this helper function is to 49676 * abstract away the particular structure of children. 49677 * 49678 * @param {?object} children Child collection structure. 49679 * @return {ReactElement} The first and only `ReactElement` contained in the 49680 * structure. 49681 */ 49682function onlyChild(children) { 49683 !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0; 49684 return children; 49685} 49686 49687function createContext(defaultValue, calculateChangedBits) { 49688 if (calculateChangedBits === undefined) { 49689 calculateChangedBits = null; 49690 } else { 49691 { 49692 !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warning(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0; 49693 } 49694 } 49695 49696 var context = { 49697 $$typeof: REACT_CONTEXT_TYPE, 49698 _calculateChangedBits: calculateChangedBits, 49699 _defaultValue: defaultValue, 49700 _currentValue: defaultValue, 49701 // As a workaround to support multiple concurrent renderers, we categorize 49702 // some renderers as primary and others as secondary. We only expect 49703 // there to be two concurrent renderers at most: React Native (primary) and 49704 // Fabric (secondary); React DOM (primary) and React ART (secondary). 49705 // Secondary renderers store their context values on separate fields. 49706 _currentValue2: defaultValue, 49707 _changedBits: 0, 49708 _changedBits2: 0, 49709 // These are circular 49710 Provider: null, 49711 Consumer: null 49712 }; 49713 49714 context.Provider = { 49715 $$typeof: REACT_PROVIDER_TYPE, 49716 _context: context 49717 }; 49718 context.Consumer = context; 49719 49720 { 49721 context._currentRenderer = null; 49722 context._currentRenderer2 = null; 49723 } 49724 49725 return context; 49726} 49727 49728function forwardRef(render) { 49729 { 49730 !(typeof render === 'function') ? warning(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render) : void 0; 49731 49732 if (render != null) { 49733 !(render.defaultProps == null && render.propTypes == null) ? warning(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0; 49734 } 49735 } 49736 49737 return { 49738 $$typeof: REACT_FORWARD_REF_TYPE, 49739 render: render 49740 }; 49741} 49742 49743var describeComponentFrame = function (name, source, ownerName) { 49744 return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : ''); 49745}; 49746 49747function isValidElementType(type) { 49748 return typeof type === 'string' || typeof type === 'function' || 49749 // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. 49750 type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_TIMEOUT_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE); 49751} 49752 49753function getComponentName(fiber) { 49754 var type = fiber.type; 49755 49756 if (typeof type === 'function') { 49757 return type.displayName || type.name; 49758 } 49759 if (typeof type === 'string') { 49760 return type; 49761 } 49762 switch (type) { 49763 case REACT_ASYNC_MODE_TYPE: 49764 return 'AsyncMode'; 49765 case REACT_CONTEXT_TYPE: 49766 return 'Context.Consumer'; 49767 case REACT_FRAGMENT_TYPE: 49768 return 'ReactFragment'; 49769 case REACT_PORTAL_TYPE: 49770 return 'ReactPortal'; 49771 case REACT_PROFILER_TYPE: 49772 return 'Profiler(' + fiber.pendingProps.id + ')'; 49773 case REACT_PROVIDER_TYPE: 49774 return 'Context.Provider'; 49775 case REACT_STRICT_MODE_TYPE: 49776 return 'StrictMode'; 49777 case REACT_TIMEOUT_TYPE: 49778 return 'Timeout'; 49779 } 49780 if (typeof type === 'object' && type !== null) { 49781 switch (type.$$typeof) { 49782 case REACT_FORWARD_REF_TYPE: 49783 var functionName = type.render.displayName || type.render.name || ''; 49784 return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef'; 49785 } 49786 } 49787 return null; 49788} 49789 49790/** 49791 * ReactElementValidator provides a wrapper around a element factory 49792 * which validates the props passed to the element. This is intended to be 49793 * used only in DEV and could be replaced by a static type checker for languages 49794 * that support it. 49795 */ 49796 49797var currentlyValidatingElement = void 0; 49798var propTypesMisspellWarningShown = void 0; 49799 49800var getDisplayName = function () {}; 49801var getStackAddendum = function () {}; 49802 49803{ 49804 currentlyValidatingElement = null; 49805 49806 propTypesMisspellWarningShown = false; 49807 49808 getDisplayName = function (element) { 49809 if (element == null) { 49810 return '#empty'; 49811 } else if (typeof element === 'string' || typeof element === 'number') { 49812 return '#text'; 49813 } else if (typeof element.type === 'string') { 49814 return element.type; 49815 } 49816 49817 var type = element.type; 49818 if (type === REACT_FRAGMENT_TYPE) { 49819 return 'React.Fragment'; 49820 } else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) { 49821 var functionName = type.render.displayName || type.render.name || ''; 49822 return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef'; 49823 } else { 49824 return type.displayName || type.name || 'Unknown'; 49825 } 49826 }; 49827 49828 getStackAddendum = function () { 49829 var stack = ''; 49830 if (currentlyValidatingElement) { 49831 var name = getDisplayName(currentlyValidatingElement); 49832 var owner = currentlyValidatingElement._owner; 49833 stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner)); 49834 } 49835 stack += ReactDebugCurrentFrame.getStackAddendum() || ''; 49836 return stack; 49837 }; 49838} 49839 49840function getDeclarationErrorAddendum() { 49841 if (ReactCurrentOwner.current) { 49842 var name = getComponentName(ReactCurrentOwner.current); 49843 if (name) { 49844 return '\n\nCheck the render method of `' + name + '`.'; 49845 } 49846 } 49847 return ''; 49848} 49849 49850function getSourceInfoErrorAddendum(elementProps) { 49851 if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) { 49852 var source = elementProps.__source; 49853 var fileName = source.fileName.replace(/^.*[\\\/]/, ''); 49854 var lineNumber = source.lineNumber; 49855 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; 49856 } 49857 return ''; 49858} 49859 49860/** 49861 * Warn if there's no key explicitly set on dynamic arrays of children or 49862 * object keys are not valid. This allows us to keep track of children between 49863 * updates. 49864 */ 49865var ownerHasKeyUseWarning = {}; 49866 49867function getCurrentComponentErrorInfo(parentType) { 49868 var info = getDeclarationErrorAddendum(); 49869 49870 if (!info) { 49871 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; 49872 if (parentName) { 49873 info = '\n\nCheck the top-level render call using <' + parentName + '>.'; 49874 } 49875 } 49876 return info; 49877} 49878 49879/** 49880 * Warn if the element doesn't have an explicit key assigned to it. 49881 * This element is in an array. The array could grow and shrink or be 49882 * reordered. All children that haven't already been validated are required to 49883 * have a "key" property assigned to it. Error statuses are cached so a warning 49884 * will only be shown once. 49885 * 49886 * @internal 49887 * @param {ReactElement} element Element that requires a key. 49888 * @param {*} parentType element's parent's type. 49889 */ 49890function validateExplicitKey(element, parentType) { 49891 if (!element._store || element._store.validated || element.key != null) { 49892 return; 49893 } 49894 element._store.validated = true; 49895 49896 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); 49897 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 49898 return; 49899 } 49900 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; 49901 49902 // Usually the current owner is the offender, but if it accepts children as a 49903 // property, it may be the creator of the child that's responsible for 49904 // assigning it a key. 49905 var childOwner = ''; 49906 if (element && element._owner && element._owner !== ReactCurrentOwner.current) { 49907 // Give the component that originally created this child. 49908 childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.'; 49909 } 49910 49911 currentlyValidatingElement = element; 49912 { 49913 warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, getStackAddendum()); 49914 } 49915 currentlyValidatingElement = null; 49916} 49917 49918/** 49919 * Ensure that every element either is passed in a static location, in an 49920 * array with an explicit keys property defined, or in an object literal 49921 * with valid key property. 49922 * 49923 * @internal 49924 * @param {ReactNode} node Statically passed child of any type. 49925 * @param {*} parentType node's parent's type. 49926 */ 49927function validateChildKeys(node, parentType) { 49928 if (typeof node !== 'object') { 49929 return; 49930 } 49931 if (Array.isArray(node)) { 49932 for (var i = 0; i < node.length; i++) { 49933 var child = node[i]; 49934 if (isValidElement(child)) { 49935 validateExplicitKey(child, parentType); 49936 } 49937 } 49938 } else if (isValidElement(node)) { 49939 // This element was passed in a valid location. 49940 if (node._store) { 49941 node._store.validated = true; 49942 } 49943 } else if (node) { 49944 var iteratorFn = getIteratorFn(node); 49945 if (typeof iteratorFn === 'function') { 49946 // Entry iterators used to provide implicit keys, 49947 // but now we print a separate warning for them later. 49948 if (iteratorFn !== node.entries) { 49949 var iterator = iteratorFn.call(node); 49950 var step = void 0; 49951 while (!(step = iterator.next()).done) { 49952 if (isValidElement(step.value)) { 49953 validateExplicitKey(step.value, parentType); 49954 } 49955 } 49956 } 49957 } 49958 } 49959} 49960 49961/** 49962 * Given an element, validate that its props follow the propTypes definition, 49963 * provided by the type. 49964 * 49965 * @param {ReactElement} element 49966 */ 49967function validatePropTypes(element) { 49968 var type = element.type; 49969 var name = void 0, 49970 propTypes = void 0; 49971 if (typeof type === 'function') { 49972 // Class or functional component 49973 name = type.displayName || type.name; 49974 propTypes = type.propTypes; 49975 } else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) { 49976 // ForwardRef 49977 var functionName = type.render.displayName || type.render.name || ''; 49978 name = functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef'; 49979 propTypes = type.propTypes; 49980 } else { 49981 return; 49982 } 49983 if (propTypes) { 49984 currentlyValidatingElement = element; 49985 checkPropTypes(propTypes, element.props, 'prop', name, getStackAddendum); 49986 currentlyValidatingElement = null; 49987 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { 49988 propTypesMisspellWarningShown = true; 49989 warning(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown'); 49990 } 49991 if (typeof type.getDefaultProps === 'function') { 49992 !type.getDefaultProps.isReactClassApproved ? warning(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0; 49993 } 49994} 49995 49996/** 49997 * Given a fragment, validate that it can only be provided with fragment props 49998 * @param {ReactElement} fragment 49999 */ 50000function validateFragmentProps(fragment) { 50001 currentlyValidatingElement = fragment; 50002 50003 var keys = Object.keys(fragment.props); 50004 for (var i = 0; i < keys.length; i++) { 50005 var key = keys[i]; 50006 if (key !== 'children' && key !== 'key') { 50007 warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum()); 50008 break; 50009 } 50010 } 50011 50012 if (fragment.ref !== null) { 50013 warning(false, 'Invalid attribute `ref` supplied to `React.Fragment`.%s', getStackAddendum()); 50014 } 50015 50016 currentlyValidatingElement = null; 50017} 50018 50019function createElementWithValidation(type, props, children) { 50020 var validType = isValidElementType(type); 50021 50022 // We warn in this case but don't throw. We expect the element creation to 50023 // succeed and there will likely be errors in render. 50024 if (!validType) { 50025 var info = ''; 50026 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 50027 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; 50028 } 50029 50030 var sourceInfo = getSourceInfoErrorAddendum(props); 50031 if (sourceInfo) { 50032 info += sourceInfo; 50033 } else { 50034 info += getDeclarationErrorAddendum(); 50035 } 50036 50037 info += getStackAddendum() || ''; 50038 50039 var typeString = void 0; 50040 if (type === null) { 50041 typeString = 'null'; 50042 } else if (Array.isArray(type)) { 50043 typeString = 'array'; 50044 } else { 50045 typeString = typeof type; 50046 } 50047 50048 warning(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); 50049 } 50050 50051 var element = createElement.apply(this, arguments); 50052 50053 // The result can be nullish if a mock or a custom function is used. 50054 // TODO: Drop this when these are no longer allowed as the type argument. 50055 if (element == null) { 50056 return element; 50057 } 50058 50059 // Skip key warning if the type isn't valid since our key validation logic 50060 // doesn't expect a non-string/function type and can throw confusing errors. 50061 // We don't want exception behavior to differ between dev and prod. 50062 // (Rendering will throw with a helpful message and as soon as the type is 50063 // fixed, the key warnings will appear.) 50064 if (validType) { 50065 for (var i = 2; i < arguments.length; i++) { 50066 validateChildKeys(arguments[i], type); 50067 } 50068 } 50069 50070 if (type === REACT_FRAGMENT_TYPE) { 50071 validateFragmentProps(element); 50072 } else { 50073 validatePropTypes(element); 50074 } 50075 50076 return element; 50077} 50078 50079function createFactoryWithValidation(type) { 50080 var validatedFactory = createElementWithValidation.bind(null, type); 50081 validatedFactory.type = type; 50082 // Legacy hook: remove it 50083 { 50084 Object.defineProperty(validatedFactory, 'type', { 50085 enumerable: false, 50086 get: function () { 50087 lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); 50088 Object.defineProperty(this, 'type', { 50089 value: type 50090 }); 50091 return type; 50092 } 50093 }); 50094 } 50095 50096 return validatedFactory; 50097} 50098 50099function cloneElementWithValidation(element, props, children) { 50100 var newElement = cloneElement.apply(this, arguments); 50101 for (var i = 2; i < arguments.length; i++) { 50102 validateChildKeys(arguments[i], newElement.type); 50103 } 50104 validatePropTypes(newElement); 50105 return newElement; 50106} 50107 50108var React = { 50109 Children: { 50110 map: mapChildren, 50111 forEach: forEachChildren, 50112 count: countChildren, 50113 toArray: toArray, 50114 only: onlyChild 50115 }, 50116 50117 createRef: createRef, 50118 Component: Component, 50119 PureComponent: PureComponent, 50120 50121 createContext: createContext, 50122 forwardRef: forwardRef, 50123 50124 Fragment: REACT_FRAGMENT_TYPE, 50125 StrictMode: REACT_STRICT_MODE_TYPE, 50126 unstable_AsyncMode: REACT_ASYNC_MODE_TYPE, 50127 unstable_Profiler: REACT_PROFILER_TYPE, 50128 50129 createElement: createElementWithValidation, 50130 cloneElement: cloneElementWithValidation, 50131 createFactory: createFactoryWithValidation, 50132 isValidElement: isValidElement, 50133 50134 version: ReactVersion, 50135 50136 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: { 50137 ReactCurrentOwner: ReactCurrentOwner, 50138 // Used by renderers to avoid bundling object-assign twice in UMD bundles: 50139 assign: _assign 50140 } 50141}; 50142 50143if (enableSuspense) { 50144 React.Timeout = REACT_TIMEOUT_TYPE; 50145} 50146 50147{ 50148 _assign(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, { 50149 // These should not be included in production. 50150 ReactDebugCurrentFrame: ReactDebugCurrentFrame, 50151 // Shim for React DOM 16.0.0 which still destructured (but not used) this. 50152 // TODO: remove in React 17.0. 50153 ReactComponentTreeHook: {} 50154 }); 50155} 50156 50157 50158 50159var React$2 = Object.freeze({ 50160 default: React 50161}); 50162 50163var React$3 = ( React$2 && React ) || React$2; 50164 50165// TODO: decide on the top-level export form. 50166// This is hacky but makes it work with both Rollup and Jest. 50167var react = React$3.default ? React$3.default : React$3; 50168 50169module.exports = react; 50170 })(); 50171} 50172 50173 50174/***/ }), 50175
vendor: 430 bytes, lines 50176-50192
50176/***/ "./node_modules/react/index.js": 50177/*!*************************************!*\ 50178 !*** ./node_modules/react/index.js ***! 50179 \*************************************/ 50180/*! no static exports found */ 50181/***/ (function(module, exports, __webpack_require__) { 50182 50183"use strict"; 50184 50185 50186if (false) {} else { 50187 module.exports = __webpack_require__(/*! ./cjs/react.development.js */ "./node_modules/react/cjs/react.development.js"); 50188} 50189 50190 50191/***/ }), 50192
vendor: 906 bytes, lines 50193-50224
50193/***/ "./node_modules/redux-thunk/es/index.js": 50194/*!**********************************************!*\ 50195 !*** ./node_modules/redux-thunk/es/index.js ***! 50196 \**********************************************/ 50197/*! exports provided: default */ 50198/***/ (function(module, __webpack_exports__, __webpack_require__) { 50199 50200"use strict"; 50201__webpack_require__.r(__webpack_exports__); 50202function createThunkMiddleware(extraArgument) { 50203 return function (_ref) { 50204 var dispatch = _ref.dispatch, 50205 getState = _ref.getState; 50206 return function (next) { 50207 return function (action) { 50208 if (typeof action === 'function') { 50209 return action(dispatch, getState, extraArgument); 50210 } 50211 50212 return next(action); 50213 }; 50214 }; 50215 }; 50216} 50217 50218var thunk = createThunkMiddleware(); 50219thunk.withExtraArgument = createThunkMiddleware; 50220 50221/* harmony default export */ __webpack_exports__["default"] = (thunk); 50222 50223/***/ }), 50224
vendor: 23,994 bytes, lines 50225-50832
50225/***/ "./node_modules/redux/es/redux.js": 50226/*!****************************************!*\ 50227 !*** ./node_modules/redux/es/redux.js ***! 50228 \****************************************/ 50229/*! exports provided: createStore, combineReducers, bindActionCreators, applyMiddleware, compose, __DO_NOT_USE__ActionTypes */ 50230/***/ (function(module, __webpack_exports__, __webpack_require__) { 50231 50232"use strict"; 50233__webpack_require__.r(__webpack_exports__); 50234/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createStore", function() { return createStore; }); 50235/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "combineReducers", function() { return combineReducers; }); 50236/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bindActionCreators", function() { return bindActionCreators; }); 50237/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "applyMiddleware", function() { return applyMiddleware; }); 50238/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compose", function() { return compose; }); 50239/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__DO_NOT_USE__ActionTypes", function() { return ActionTypes; }); 50240/* harmony import */ var symbol_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! symbol-observable */ "./node_modules/symbol-observable/es/index.js"); 50241 50242 50243/** 50244 * These are private action types reserved by Redux. 50245 * For any unknown actions, you must return the current state. 50246 * If the current state is undefined, you must return the initial state. 50247 * Do not reference these action types directly in your code. 50248 */ 50249var ActionTypes = { 50250 INIT: '@@redux/INIT' + Math.random().toString(36).substring(7).split('').join('.'), 50251 REPLACE: '@@redux/REPLACE' + Math.random().toString(36).substring(7).split('').join('.') 50252}; 50253 50254var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { 50255 return typeof obj; 50256} : function (obj) { 50257 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 50258}; 50259 50260var _extends = Object.assign || function (target) { 50261 for (var i = 1; i < arguments.length; i++) { 50262 var source = arguments[i]; 50263 50264 for (var key in source) { 50265 if (Object.prototype.hasOwnProperty.call(source, key)) { 50266 target[key] = source[key]; 50267 } 50268 } 50269 } 50270 50271 return target; 50272}; 50273 50274/** 50275 * @param {any} obj The object to inspect. 50276 * @returns {boolean} True if the argument appears to be a plain object. 50277 */ 50278function isPlainObject(obj) { 50279 if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) return false; 50280 50281 var proto = obj; 50282 while (Object.getPrototypeOf(proto) !== null) { 50283 proto = Object.getPrototypeOf(proto); 50284 } 50285 50286 return Object.getPrototypeOf(obj) === proto; 50287} 50288 50289/** 50290 * Creates a Redux store that holds the state tree. 50291 * The only way to change the data in the store is to call `dispatch()` on it. 50292 * 50293 * There should only be a single store in your app. To specify how different 50294 * parts of the state tree respond to actions, you may combine several reducers 50295 * into a single reducer function by using `combineReducers`. 50296 * 50297 * @param {Function} reducer A function that returns the next state tree, given 50298 * the current state tree and the action to handle. 50299 * 50300 * @param {any} [preloadedState] The initial state. You may optionally specify it 50301 * to hydrate the state from the server in universal apps, or to restore a 50302 * previously serialized user session. 50303 * If you use `combineReducers` to produce the root reducer function, this must be 50304 * an object with the same shape as `combineReducers` keys. 50305 * 50306 * @param {Function} [enhancer] The store enhancer. You may optionally specify it 50307 * to enhance the store with third-party capabilities such as middleware, 50308 * time travel, persistence, etc. The only store enhancer that ships with Redux 50309 * is `applyMiddleware()`. 50310 * 50311 * @returns {Store} A Redux store that lets you read the state, dispatch actions 50312 * and subscribe to changes. 50313 */ 50314function createStore(reducer, preloadedState, enhancer) { 50315 var _ref2; 50316 50317 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { 50318 enhancer = preloadedState; 50319 preloadedState = undefined; 50320 } 50321 50322 if (typeof enhancer !== 'undefined') { 50323 if (typeof enhancer !== 'function') { 50324 throw new Error('Expected the enhancer to be a function.'); 50325 } 50326 50327 return enhancer(createStore)(reducer, preloadedState); 50328 } 50329 50330 if (typeof reducer !== 'function') { 50331 throw new Error('Expected the reducer to be a function.'); 50332 } 50333 50334 var currentReducer = reducer; 50335 var currentState = preloadedState; 50336 var currentListeners = []; 50337 var nextListeners = currentListeners; 50338 var isDispatching = false; 50339 50340 function ensureCanMutateNextListeners() { 50341 if (nextListeners === currentListeners) { 50342 nextListeners = currentListeners.slice(); 50343 } 50344 } 50345 50346 /** 50347 * Reads the state tree managed by the store. 50348 * 50349 * @returns {any} The current state tree of your application. 50350 */ 50351 function getState() { 50352 if (isDispatching) { 50353 throw new Error('You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.'); 50354 } 50355 50356 return currentState; 50357 } 50358 50359 /** 50360 * Adds a change listener. It will be called any time an action is dispatched, 50361 * and some part of the state tree may potentially have changed. You may then 50362 * call `getState()` to read the current state tree inside the callback. 50363 * 50364 * You may call `dispatch()` from a change listener, with the following 50365 * caveats: 50366 * 50367 * 1. The subscriptions are snapshotted just before every `dispatch()` call. 50368 * If you subscribe or unsubscribe while the listeners are being invoked, this 50369 * will not have any effect on the `dispatch()` that is currently in progress. 50370 * However, the next `dispatch()` call, whether nested or not, will use a more 50371 * recent snapshot of the subscription list. 50372 * 50373 * 2. The listener should not expect to see all state changes, as the state 50374 * might have been updated multiple times during a nested `dispatch()` before 50375 * the listener is called. It is, however, guaranteed that all subscribers 50376 * registered before the `dispatch()` started will be called with the latest 50377 * state by the time it exits. 50378 * 50379 * @param {Function} listener A callback to be invoked on every dispatch. 50380 * @returns {Function} A function to remove this change listener. 50381 */ 50382 function subscribe(listener) { 50383 if (typeof listener !== 'function') { 50384 throw new Error('Expected the listener to be a function.'); 50385 } 50386 50387 if (isDispatching) { 50388 throw new Error('You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api-reference/store#subscribe(listener) for more details.'); 50389 } 50390 50391 var isSubscribed = true; 50392 50393 ensureCanMutateNextListeners(); 50394 nextListeners.push(listener); 50395 50396 return function unsubscribe() { 50397 if (!isSubscribed) { 50398 return; 50399 } 50400 50401 if (isDispatching) { 50402 throw new Error('You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api-reference/store#subscribe(listener) for more details.'); 50403 } 50404 50405 isSubscribed = false; 50406 50407 ensureCanMutateNextListeners(); 50408 var index = nextListeners.indexOf(listener); 50409 nextListeners.splice(index, 1); 50410 }; 50411 } 50412 50413 /** 50414 * Dispatches an action. It is the only way to trigger a state change. 50415 * 50416 * The `reducer` function, used to create the store, will be called with the 50417 * current state tree and the given `action`. Its return value will 50418 * be considered the **next** state of the tree, and the change listeners 50419 * will be notified. 50420 * 50421 * The base implementation only supports plain object actions. If you want to 50422 * dispatch a Promise, an Observable, a thunk, or something else, you need to 50423 * wrap your store creating function into the corresponding middleware. For 50424 * example, see the documentation for the `redux-thunk` package. Even the 50425 * middleware will eventually dispatch plain object actions using this method. 50426 * 50427 * @param {Object} action A plain object representing âwhat changedâ. It is 50428 * a good idea to keep actions serializable so you can record and replay user 50429 * sessions, or use the time travelling `redux-devtools`. An action must have 50430 * a `type` property which may not be `undefined`. It is a good idea to use 50431 * string constants for action types. 50432 * 50433 * @returns {Object} For convenience, the same action object you dispatched. 50434 * 50435 * Note that, if you use a custom middleware, it may wrap `dispatch()` to 50436 * return something else (for example, a Promise you can await). 50437 */ 50438 function dispatch(action) { 50439 if (!isPlainObject(action)) { 50440 throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.'); 50441 } 50442 50443 if (typeof action.type === 'undefined') { 50444 throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?'); 50445 } 50446 50447 if (isDispatching) { 50448 throw new Error('Reducers may not dispatch actions.'); 50449 } 50450 50451 try { 50452 isDispatching = true; 50453 currentState = currentReducer(currentState, action); 50454 } finally { 50455 isDispatching = false; 50456 } 50457 50458 var listeners = currentListeners = nextListeners; 50459 for (var i = 0; i < listeners.length; i++) { 50460 var listener = listeners[i]; 50461 listener(); 50462 } 50463 50464 return action; 50465 } 50466 50467 /** 50468 * Replaces the reducer currently used by the store to calculate the state. 50469 * 50470 * You might need this if your app implements code splitting and you want to 50471 * load some of the reducers dynamically. You might also need this if you 50472 * implement a hot reloading mechanism for Redux. 50473 * 50474 * @param {Function} nextReducer The reducer for the store to use instead. 50475 * @returns {void} 50476 */ 50477 function replaceReducer(nextReducer) { 50478 if (typeof nextReducer !== 'function') { 50479 throw new Error('Expected the nextReducer to be a function.'); 50480 } 50481 50482 currentReducer = nextReducer; 50483 dispatch({ type: ActionTypes.REPLACE }); 50484 } 50485 50486 /** 50487 * Interoperability point for observable/reactive libraries. 50488 * @returns {observable} A minimal observable of state changes. 50489 * For more information, see the observable proposal: 50490 * https://github.com/tc39/proposal-observable 50491 */ 50492 function observable() { 50493 var _ref; 50494 50495 var outerSubscribe = subscribe; 50496 return _ref = { 50497 /** 50498 * The minimal observable subscription method. 50499 * @param {Object} observer Any object that can be used as an observer. 50500 * The observer object should have a `next` method. 50501 * @returns {subscription} An object with an `unsubscribe` method that can 50502 * be used to unsubscribe the observable from the store, and prevent further 50503 * emission of values from the observable. 50504 */ 50505 subscribe: function subscribe(observer) { 50506 if ((typeof observer === 'undefined' ? 'undefined' : _typeof(observer)) !== 'object' || observer === null) { 50507 throw new TypeError('Expected the observer to be an object.'); 50508 } 50509 50510 function observeState() { 50511 if (observer.next) { 50512 observer.next(getState()); 50513 } 50514 } 50515 50516 observeState(); 50517 var unsubscribe = outerSubscribe(observeState); 50518 return { unsubscribe: unsubscribe }; 50519 } 50520 }, _ref[symbol_observable__WEBPACK_IMPORTED_MODULE_0__["default"]] = function () { 50521 return this; 50522 }, _ref; 50523 } 50524 50525 // When a store is created, an "INIT" action is dispatched so that every 50526 // reducer returns their initial state. This effectively populates 50527 // the initial state tree. 50528 dispatch({ type: ActionTypes.INIT }); 50529 50530 return _ref2 = { 50531 dispatch: dispatch, 50532 subscribe: subscribe, 50533 getState: getState, 50534 replaceReducer: replaceReducer 50535 }, _ref2[symbol_observable__WEBPACK_IMPORTED_MODULE_0__["default"]] = observable, _ref2; 50536} 50537 50538/** 50539 * Prints a warning in the console if it exists. 50540 * 50541 * @param {String} message The warning message. 50542 * @returns {void} 50543 */ 50544function warning(message) { 50545 /* eslint-disable no-console */ 50546 if (typeof console !== 'undefined' && typeof console.error === 'function') { 50547 console.error(message); 50548 } 50549 /* eslint-enable no-console */ 50550 try { 50551 // This error was thrown as a convenience so that if you enable 50552 // "break on all exceptions" in your console, 50553 // it would pause the execution at this line. 50554 throw new Error(message); 50555 } catch (e) {} // eslint-disable-line no-empty 50556} 50557 50558function getUndefinedStateErrorMessage(key, action) { 50559 var actionType = action && action.type; 50560 var actionDescription = actionType && 'action "' + String(actionType) + '"' || 'an action'; 50561 50562 return 'Given ' + actionDescription + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state. ' + 'If you want this reducer to hold no value, you can return null instead of undefined.'; 50563} 50564 50565function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) { 50566 var reducerKeys = Object.keys(reducers); 50567 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer'; 50568 50569 if (reducerKeys.length === 0) { 50570 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.'; 50571 } 50572 50573 if (!isPlainObject(inputState)) { 50574 return 'The ' + argumentName + ' has unexpected type of "' + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected argument to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"'); 50575 } 50576 50577 var unexpectedKeys = Object.keys(inputState).filter(function (key) { 50578 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]; 50579 }); 50580 50581 unexpectedKeys.forEach(function (key) { 50582 unexpectedKeyCache[key] = true; 50583 }); 50584 50585 if (action && action.type === ActionTypes.REPLACE) return; 50586 50587 if (unexpectedKeys.length > 0) { 50588 return 'Unexpected ' + (unexpectedKeys.length > 1 ? 'keys' : 'key') + ' ' + ('"' + unexpectedKeys.join('", "') + '" found in ' + argumentName + '. ') + 'Expected to find one of the known reducer keys instead: ' + ('"' + reducerKeys.join('", "') + '". Unexpected keys will be ignored.'); 50589 } 50590} 50591 50592function assertReducerShape(reducers) { 50593 Object.keys(reducers).forEach(function (key) { 50594 var reducer = reducers[key]; 50595 var initialState = reducer(undefined, { type: ActionTypes.INIT }); 50596 50597 if (typeof initialState === 'undefined') { 50598 throw new Error('Reducer "' + key + '" returned undefined during initialization. ' + 'If the state passed to the reducer is undefined, you must ' + 'explicitly return the initial state. The initial state may ' + 'not be undefined. If you don\'t want to set a value for this reducer, ' + 'you can use null instead of undefined.'); 50599 } 50600 50601 var type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.'); 50602 if (typeof reducer(undefined, { type: type }) === 'undefined') { 50603 throw new Error('Reducer "' + key + '" returned undefined when probed with a random type. ' + ('Don\'t try to handle ' + ActionTypes.INIT + ' or other actions in "redux/*" ') + 'namespace. They are considered private. Instead, you must return the ' + 'current state for any unknown actions, unless it is undefined, ' + 'in which case you must return the initial state, regardless of the ' + 'action type. The initial state may not be undefined, but can be null.'); 50604 } 50605 }); 50606} 50607 50608/** 50609 * Turns an object whose values are different reducer functions, into a single 50610 * reducer function. It will call every child reducer, and gather their results 50611 * into a single state object, whose keys correspond to the keys of the passed 50612 * reducer functions. 50613 * 50614 * @param {Object} reducers An object whose values correspond to different 50615 * reducer functions that need to be combined into one. One handy way to obtain 50616 * it is to use ES6 `import * as reducers` syntax. The reducers may never return 50617 * undefined for any action. Instead, they should return their initial state 50618 * if the state passed to them was undefined, and the current state for any 50619 * unrecognized action. 50620 * 50621 * @returns {Function} A reducer function that invokes every reducer inside the 50622 * passed object, and builds a state object with the same shape. 50623 */ 50624function combineReducers(reducers) { 50625 var reducerKeys = Object.keys(reducers); 50626 var finalReducers = {}; 50627 for (var i = 0; i < reducerKeys.length; i++) { 50628 var key = reducerKeys[i]; 50629 50630 if (true) { 50631 if (typeof reducers[key] === 'undefined') { 50632 warning('No reducer provided for key "' + key + '"'); 50633 } 50634 } 50635 50636 if (typeof reducers[key] === 'function') { 50637 finalReducers[key] = reducers[key]; 50638 } 50639 } 50640 var finalReducerKeys = Object.keys(finalReducers); 50641 50642 var unexpectedKeyCache = void 0; 50643 if (true) { 50644 unexpectedKeyCache = {}; 50645 } 50646 50647 var shapeAssertionError = void 0; 50648 try { 50649 assertReducerShape(finalReducers); 50650 } catch (e) { 50651 shapeAssertionError = e; 50652 } 50653 50654 return function combination() { 50655 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 50656 var action = arguments[1]; 50657 50658 if (shapeAssertionError) { 50659 throw shapeAssertionError; 50660 } 50661 50662 if (true) { 50663 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache); 50664 if (warningMessage) { 50665 warning(warningMessage); 50666 } 50667 } 50668 50669 var hasChanged = false; 50670 var nextState = {}; 50671 for (var _i = 0; _i < finalReducerKeys.length; _i++) { 50672 var _key = finalReducerKeys[_i]; 50673 var reducer = finalReducers[_key]; 50674 var previousStateForKey = state[_key]; 50675 var nextStateForKey = reducer(previousStateForKey, action); 50676 if (typeof nextStateForKey === 'undefined') { 50677 var errorMessage = getUndefinedStateErrorMessage(_key, action); 50678 throw new Error(errorMessage); 50679 } 50680 nextState[_key] = nextStateForKey; 50681 hasChanged = hasChanged || nextStateForKey !== previousStateForKey; 50682 } 50683 return hasChanged ? nextState : state; 50684 }; 50685} 50686 50687function bindActionCreator(actionCreator, dispatch) { 50688 return function () { 50689 return dispatch(actionCreator.apply(this, arguments)); 50690 }; 50691} 50692 50693/** 50694 * Turns an object whose values are action creators, into an object with the 50695 * same keys, but with every function wrapped into a `dispatch` call so they 50696 * may be invoked directly. This is just a convenience method, as you can call 50697 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine. 50698 * 50699 * For convenience, you can also pass a single function as the first argument, 50700 * and get a function in return. 50701 * 50702 * @param {Function|Object} actionCreators An object whose values are action 50703 * creator functions. One handy way to obtain it is to use ES6 `import * as` 50704 * syntax. You may also pass a single function. 50705 * 50706 * @param {Function} dispatch The `dispatch` function available on your Redux 50707 * store. 50708 * 50709 * @returns {Function|Object} The object mimicking the original object, but with 50710 * every action creator wrapped into the `dispatch` call. If you passed a 50711 * function as `actionCreators`, the return value will also be a single 50712 * function. 50713 */ 50714function bindActionCreators(actionCreators, dispatch) { 50715 if (typeof actionCreators === 'function') { 50716 return bindActionCreator(actionCreators, dispatch); 50717 } 50718 50719 if ((typeof actionCreators === 'undefined' ? 'undefined' : _typeof(actionCreators)) !== 'object' || actionCreators === null) { 50720 throw new Error('bindActionCreators expected an object or a function, instead received ' + (actionCreators === null ? 'null' : typeof actionCreators === 'undefined' ? 'undefined' : _typeof(actionCreators)) + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?'); 50721 } 50722 50723 var keys = Object.keys(actionCreators); 50724 var boundActionCreators = {}; 50725 for (var i = 0; i < keys.length; i++) { 50726 var key = keys[i]; 50727 var actionCreator = actionCreators[key]; 50728 if (typeof actionCreator === 'function') { 50729 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch); 50730 } 50731 } 50732 return boundActionCreators; 50733} 50734 50735/** 50736 * Composes single-argument functions from right to left. The rightmost 50737 * function can take multiple arguments as it provides the signature for 50738 * the resulting composite function. 50739 * 50740 * @param {...Function} funcs The functions to compose. 50741 * @returns {Function} A function obtained by composing the argument functions 50742 * from right to left. For example, compose(f, g, h) is identical to doing 50743 * (...args) => f(g(h(...args))). 50744 */ 50745 50746function compose() { 50747 for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { 50748 funcs[_key] = arguments[_key]; 50749 } 50750 50751 if (funcs.length === 0) { 50752 return function (arg) { 50753 return arg; 50754 }; 50755 } 50756 50757 if (funcs.length === 1) { 50758 return funcs[0]; 50759 } 50760 50761 return funcs.reduce(function (a, b) { 50762 return function () { 50763 return a(b.apply(undefined, arguments)); 50764 }; 50765 }); 50766} 50767 50768/** 50769 * Creates a store enhancer that applies middleware to the dispatch method 50770 * of the Redux store. This is handy for a variety of tasks, such as expressing 50771 * asynchronous actions in a concise manner, or logging every action payload. 50772 * 50773 * See `redux-thunk` package as an example of the Redux middleware. 50774 * 50775 * Because middleware is potentially asynchronous, this should be the first 50776 * store enhancer in the composition chain. 50777 * 50778 * Note that each middleware will be given the `dispatch` and `getState` functions 50779 * as named arguments. 50780 * 50781 * @param {...Function} middlewares The middleware chain to be applied. 50782 * @returns {Function} A store enhancer applying the middleware. 50783 */ 50784function applyMiddleware() { 50785 for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) { 50786 middlewares[_key] = arguments[_key]; 50787 } 50788 50789 return function (createStore) { 50790 return function () { 50791 for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 50792 args[_key2] = arguments[_key2]; 50793 } 50794 50795 var store = createStore.apply(undefined, args); 50796 var _dispatch = function dispatch() { 50797 throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.'); 50798 }; 50799 50800 var middlewareAPI = { 50801 getState: store.getState, 50802 dispatch: function dispatch() { 50803 return _dispatch.apply(undefined, arguments); 50804 } 50805 }; 50806 var chain = middlewares.map(function (middleware) { 50807 return middleware(middlewareAPI); 50808 }); 50809 _dispatch = compose.apply(undefined, chain)(store.dispatch); 50810 50811 return _extends({}, store, { 50812 dispatch: _dispatch 50813 }); 50814 }; 50815 }; 50816} 50817 50818/* 50819 * This is a dummy function to check if the function name has been altered by minification. 50820 * If the function has been minified and NODE_ENV !== 'production', warn the user. 50821 */ 50822function isCrushed() {} 50823 50824if ( true && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') { 50825 warning("You are currently using minified code outside of NODE_ENV === 'production'. " + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.'); 50826} 50827 50828 50829 50830 50831/***/ }), 50832
vendor: 16,381 bytes, lines 50833-51328
50833/***/ "./node_modules/sticky-js/dist/sticky.compile.js": 50834/*!*******************************************************!*\ 50835 !*** ./node_modules/sticky-js/dist/sticky.compile.js ***! 50836 \*******************************************************/ 50837/*! no static exports found */ 50838/***/ (function(module, exports, __webpack_require__) { 50839 50840function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 50841 50842function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 50843 50844function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 50845 50846/** 50847 * Sticky.js 50848 * Library for sticky elements written in vanilla javascript. With this library you can easily set sticky elements on your website. It's also responsive. 50849 * 50850 * @version 1.2.2 50851 * @author Rafal Galus <[email protected]> 50852 * @website https://rgalus.github.io/sticky-js/ 50853 * @repo https://github.com/rgalus/sticky-js 50854 * @license https://github.com/rgalus/sticky-js/blob/master/LICENSE 50855 */ 50856var Sticky = 50857/*#__PURE__*/ 50858function () { 50859 /** 50860 * Sticky instance constructor 50861 * @constructor 50862 * @param {string} selector - Selector which we can find elements 50863 * @param {string} options - Global options for sticky elements (could be overwritten by data-{option}="" attributes) 50864 */ 50865 function Sticky() { 50866 var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 50867 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 50868 50869 _classCallCheck(this, Sticky); 50870 50871 this.selector = selector; 50872 this.elements = []; 50873 this.version = '1.2.2'; 50874 this.vp = this.getViewportSize(); 50875 this.body = document.querySelector('body'); 50876 this.options = { 50877 wrap: options.wrap || false, 50878 marginTop: options.marginTop || 0, 50879 stickyFor: options.stickyFor || 0, 50880 stickyClass: options.stickyClass || null, 50881 stickyContainer: options.stickyContainer || 'body' 50882 }; 50883 this.updateScrollTopPosition = this.updateScrollTopPosition.bind(this); 50884 this.updateScrollTopPosition(); 50885 window.addEventListener('load', this.updateScrollTopPosition); 50886 window.addEventListener('scroll', this.updateScrollTopPosition); 50887 this.run(); 50888 } 50889 /** 50890 * Function that waits for page to be fully loaded and then renders & activates every sticky element found with specified selector 50891 * @function 50892 */ 50893 50894 50895 _createClass(Sticky, [{ 50896 key: "run", 50897 value: function run() { 50898 var _this = this; 50899 50900 // wait for page to be fully loaded 50901 var pageLoaded = setInterval(function () { 50902 if (document.readyState === 'complete') { 50903 clearInterval(pageLoaded); 50904 var elements = document.querySelectorAll(_this.selector); 50905 50906 _this.forEach(elements, function (element) { 50907 return _this.renderElement(element); 50908 }); 50909 } 50910 }, 10); 50911 } 50912 /** 50913 * Function that assign needed variables for sticky element, that are used in future for calculations and other 50914 * @function 50915 * @param {node} element - Element to be rendered 50916 */ 50917 50918 }, { 50919 key: "renderElement", 50920 value: function renderElement(element) { 50921 var _this2 = this; 50922 50923 // create container for variables needed in future 50924 element.sticky = {}; // set default variables 50925 50926 element.sticky.active = false; 50927 element.sticky.marginTop = parseInt(element.getAttribute('data-margin-top')) || this.options.marginTop; 50928 element.sticky.stickyFor = parseInt(element.getAttribute('data-sticky-for')) || this.options.stickyFor; 50929 element.sticky.stickyClass = element.getAttribute('data-sticky-class') || this.options.stickyClass; 50930 element.sticky.wrap = element.hasAttribute('data-sticky-wrap') ? true : this.options.wrap; // @todo attribute for stickyContainer 50931 // element.sticky.stickyContainer = element.getAttribute('data-sticky-container') || this.options.stickyContainer; 50932 50933 element.sticky.stickyContainer = this.options.stickyContainer; 50934 element.sticky.container = this.getStickyContainer(element); 50935 element.sticky.container.rect = this.getRectangle(element.sticky.container); 50936 element.sticky.rect = this.getRectangle(element); // fix when element is image that has not yet loaded and width, height = 0 50937 50938 if (element.tagName.toLowerCase() === 'img') { 50939 element.onload = function () { 50940 return element.sticky.rect = _this2.getRectangle(element); 50941 }; 50942 } 50943 50944 if (element.sticky.wrap) { 50945 this.wrapElement(element); 50946 } // activate rendered element 50947 50948 50949 this.activate(element); 50950 } 50951 /** 50952 * Wraps element into placeholder element 50953 * @function 50954 * @param {node} element - Element to be wrapped 50955 */ 50956 50957 }, { 50958 key: "wrapElement", 50959 value: function wrapElement(element) { 50960 element.insertAdjacentHTML('beforebegin', '<span></span>'); 50961 element.previousSibling.appendChild(element); 50962 } 50963 /** 50964 * Function that activates element when specified conditions are met and then initalise events 50965 * @function 50966 * @param {node} element - Element to be activated 50967 */ 50968 50969 }, { 50970 key: "activate", 50971 value: function activate(element) { 50972 if (element.sticky.rect.top + element.sticky.rect.height < element.sticky.container.rect.top + element.sticky.container.rect.height && element.sticky.stickyFor < this.vp.width && !element.sticky.active) { 50973 element.sticky.active = true; 50974 } 50975 50976 if (this.elements.indexOf(element) < 0) { 50977 this.elements.push(element); 50978 } 50979 50980 if (!element.sticky.resizeEvent) { 50981 this.initResizeEvents(element); 50982 element.sticky.resizeEvent = true; 50983 } 50984 50985 if (!element.sticky.scrollEvent) { 50986 this.initScrollEvents(element); 50987 element.sticky.scrollEvent = true; 50988 } 50989 50990 this.setPosition(element); 50991 } 50992 /** 50993 * Function which is adding onResizeEvents to window listener and assigns function to element as resizeListener 50994 * @function 50995 * @param {node} element - Element for which resize events are initialised 50996 */ 50997 50998 }, { 50999 key: "initResizeEvents", 51000 value: function initResizeEvents(element) { 51001 var _this3 = this; 51002 51003 element.sticky.resizeListener = function () { 51004 return _this3.onResizeEvents(element); 51005 }; 51006 51007 window.addEventListener('resize', element.sticky.resizeListener); 51008 } 51009 /** 51010 * Removes element listener from resize event 51011 * @function 51012 * @param {node} element - Element from which listener is deleted 51013 */ 51014 51015 }, { 51016 key: "destroyResizeEvents", 51017 value: function destroyResizeEvents(element) { 51018 window.removeEventListener('resize', element.sticky.resizeListener); 51019 } 51020 /** 51021 * Function which is fired when user resize window. It checks if element should be activated or deactivated and then run setPosition function 51022 * @function 51023 * @param {node} element - Element for which event function is fired 51024 */ 51025 51026 }, { 51027 key: "onResizeEvents", 51028 value: function onResizeEvents(element) { 51029 this.vp = this.getViewportSize(); 51030 element.sticky.rect = this.getRectangle(element); 51031 element.sticky.container.rect = this.getRectangle(element.sticky.container); 51032 51033 if (element.sticky.rect.top + element.sticky.rect.height < element.sticky.container.rect.top + element.sticky.container.rect.height && element.sticky.stickyFor < this.vp.width && !element.sticky.active) { 51034 element.sticky.active = true; 51035 } else if (element.sticky.rect.top + element.sticky.rect.height >= element.sticky.container.rect.top + element.sticky.container.rect.height || element.sticky.stickyFor >= this.vp.width && element.sticky.active) { 51036 element.sticky.active = false; 51037 } 51038 51039 this.setPosition(element); 51040 } 51041 /** 51042 * Function which is adding onScrollEvents to window listener and assigns function to element as scrollListener 51043 * @function 51044 * @param {node} element - Element for which scroll events are initialised 51045 */ 51046 51047 }, { 51048 key: "initScrollEvents", 51049 value: function initScrollEvents(element) { 51050 var _this4 = this; 51051 51052 element.sticky.scrollListener = function () { 51053 return _this4.onScrollEvents(element); 51054 }; 51055 51056 window.addEventListener('scroll', element.sticky.scrollListener); 51057 } 51058 /** 51059 * Removes element listener from scroll event 51060 * @function 51061 * @param {node} element - Element from which listener is deleted 51062 */ 51063 51064 }, { 51065 key: "destroyScrollEvents", 51066 value: function destroyScrollEvents(element) { 51067 window.removeEventListener('scroll', element.sticky.scrollListener); 51068 } 51069 /** 51070 * Function which is fired when user scroll window. If element is active, function is invoking setPosition function 51071 * @function 51072 * @param {node} element - Element for which event function is fired 51073 */ 51074 51075 }, { 51076 key: "onScrollEvents", 51077 value: function onScrollEvents(element) { 51078 if (element.sticky.active) { 51079 this.setPosition(element); 51080 } 51081 } 51082 /** 51083 * Main function for the library. Here are some condition calculations and css appending for sticky element when user scroll window 51084 * @function 51085 * @param {node} element - Element that will be positioned if it's active 51086 */ 51087 51088 }, { 51089 key: "setPosition", 51090 value: function setPosition(element) { 51091 this.css(element, { 51092 position: '', 51093 width: '', 51094 top: '', 51095 left: '' 51096 }); 51097 51098 if (this.vp.height < element.sticky.rect.height || !element.sticky.active) { 51099 return; 51100 } 51101 51102 if (!element.sticky.rect.width) { 51103 element.sticky.rect = this.getRectangle(element); 51104 } 51105 51106 if (element.sticky.wrap) { 51107 this.css(element.parentNode, { 51108 display: 'block', 51109 width: element.sticky.rect.width + 'px', 51110 height: element.sticky.rect.height + 'px' 51111 }); 51112 } 51113 51114 if (element.sticky.rect.top === 0 && element.sticky.container === this.body) { 51115 this.css(element, { 51116 position: 'fixed', 51117 top: element.sticky.rect.top + 'px', 51118 left: element.sticky.rect.left + 'px', 51119 width: element.sticky.rect.width + 'px' 51120 }); 51121 } else if (this.scrollTop > element.sticky.rect.top - element.sticky.marginTop) { 51122 this.css(element, { 51123 position: 'fixed', 51124 width: element.sticky.rect.width + 'px', 51125 left: element.sticky.rect.left + 'px' 51126 }); 51127 51128 if (this.scrollTop + element.sticky.rect.height + element.sticky.marginTop > element.sticky.container.rect.top + element.sticky.container.offsetHeight) { 51129 if (element.sticky.stickyClass) { 51130 element.classList.remove(element.sticky.stickyClass); 51131 } 51132 51133 this.css(element, { 51134 top: element.sticky.container.rect.top + element.sticky.container.offsetHeight - (this.scrollTop + element.sticky.rect.height) + 'px' 51135 }); 51136 } else { 51137 if (element.sticky.stickyClass) { 51138 element.classList.add(element.sticky.stickyClass); 51139 } 51140 51141 this.css(element, { 51142 top: element.sticky.marginTop + 'px' 51143 }); 51144 } 51145 } else { 51146 if (element.sticky.stickyClass) { 51147 element.classList.remove(element.sticky.stickyClass); 51148 } 51149 51150 this.css(element, { 51151 position: '', 51152 width: '', 51153 top: '', 51154 left: '' 51155 }); 51156 51157 if (element.sticky.wrap) { 51158 this.css(element.parentNode, { 51159 display: '', 51160 width: '', 51161 height: '' 51162 }); 51163 } 51164 } 51165 } 51166 /** 51167 * Function that updates element sticky rectangle (with sticky container), then activate or deactivate element, then update position if it's active 51168 * @function 51169 */ 51170 51171 }, { 51172 key: "update", 51173 value: function update() { 51174 var _this5 = this; 51175 51176 this.forEach(this.elements, function (element) { 51177 element.sticky.rect = _this5.getRectangle(element); 51178 element.sticky.container.rect = _this5.getRectangle(element.sticky.container); 51179 51180 _this5.activate(element); 51181 51182 _this5.setPosition(element); 51183 }); 51184 } 51185 /** 51186 * Destroys sticky element, remove listeners 51187 * @function 51188 */ 51189 51190 }, { 51191 key: "destroy", 51192 value: function destroy() { 51193 var _this6 = this; 51194 51195 window.removeEventListener('load', this.updateScrollTopPosition); 51196 window.removeEventListener('scroll', this.updateScrollTopPosition); 51197 this.forEach(this.elements, function (element) { 51198 _this6.destroyResizeEvents(element); 51199 51200 _this6.destroyScrollEvents(element); 51201 51202 delete element.sticky; 51203 }); 51204 } 51205 /** 51206 * Function that returns container element in which sticky element is stuck (if is not specified, then it's stuck to body) 51207 * @function 51208 * @param {node} element - Element which sticky container are looked for 51209 * @return {node} element - Sticky container 51210 */ 51211 51212 }, { 51213 key: "getStickyContainer", 51214 value: function getStickyContainer(element) { 51215 var container = element.parentNode; 51216 51217 while (!container.hasAttribute('data-sticky-container') && !container.parentNode.querySelector(element.sticky.stickyContainer) && container !== this.body) { 51218 container = container.parentNode; 51219 } 51220 51221 return container; 51222 } 51223 /** 51224 * Function that returns element rectangle & position (width, height, top, left) 51225 * @function 51226 * @param {node} element - Element which position & rectangle are returned 51227 * @return {object} 51228 */ 51229 51230 }, { 51231 key: "getRectangle", 51232 value: function getRectangle(element) { 51233 this.css(element, { 51234 position: '', 51235 width: '', 51236 top: '', 51237 left: '' 51238 }); 51239 var width = Math.max(element.offsetWidth, element.clientWidth, element.scrollWidth); 51240 var height = Math.max(element.offsetHeight, element.clientHeight, element.scrollHeight); 51241 var top = 0; 51242 var left = 0; 51243 51244 do { 51245 top += element.offsetTop || 0; 51246 left += element.offsetLeft || 0; 51247 element = element.offsetParent; 51248 } while (element); 51249 51250 return { 51251 top: top, 51252 left: left, 51253 width: width, 51254 height: height 51255 }; 51256 } 51257 /** 51258 * Function that returns viewport dimensions 51259 * @function 51260 * @return {object} 51261 */ 51262 51263 }, { 51264 key: "getViewportSize", 51265 value: function getViewportSize() { 51266 return { 51267 width: Math.max(document.documentElement.clientWidth, window.innerWidth || 0), 51268 height: Math.max(document.documentElement.clientHeight, window.innerHeight || 0) 51269 }; 51270 } 51271 /** 51272 * Function that updates window scroll position 51273 * @function 51274 * @return {number} 51275 */ 51276 51277 }, { 51278 key: "updateScrollTopPosition", 51279 value: function updateScrollTopPosition() { 51280 this.scrollTop = (window.pageYOffset || document.scrollTop) - (document.clientTop || 0) || 0; 51281 } 51282 /** 51283 * Helper function for loops 51284 * @helper 51285 * @param {array} 51286 * @param {function} callback - Callback function (no need for explanation) 51287 */ 51288 51289 }, { 51290 key: "forEach", 51291 value: function forEach(array, callback) { 51292 for (var i = 0, len = array.length; i < len; i++) { 51293 callback(array[i]); 51294 } 51295 } 51296 /** 51297 * Helper function to add/remove css properties for specified element. 51298 * @helper 51299 * @param {node} element - DOM element 51300 * @param {object} properties - CSS properties that will be added/removed from specified element 51301 */ 51302 51303 }, { 51304 key: "css", 51305 value: function css(element, properties) { 51306 for (var property in properties) { 51307 if (properties.hasOwnProperty(property)) { 51308 element.style[property] = properties[property]; 51309 } 51310 } 51311 } 51312 }]); 51313 51314 return Sticky; 51315}(); 51316/** 51317 * Export function that supports AMD, CommonJS and Plain Browser. 51318 */ 51319 51320 51321(function (root, factory) { 51322 if (true) { 51323 module.exports = factory; 51324 } else {} 51325})(this, Sticky); 51326 51327/***/ }), 51328
vendor: 428 bytes, lines 51329-51343
51329/***/ "./node_modules/sticky-js/index.js": 51330/*!*****************************************!*\ 51331 !*** ./node_modules/sticky-js/index.js ***! 51332 \*****************************************/ 51333/*! no static exports found */ 51334/***/ (function(module, exports, __webpack_require__) { 51335 51336 51337var Sticky = __webpack_require__(/*! ./dist/sticky.compile.js */ "./node_modules/sticky-js/dist/sticky.compile.js"); 51338 51339module.exports = Sticky; 51340 51341 51342/***/ }), 51343
vendor: 1,298 bytes, lines 51344-51375
51344/***/ "./node_modules/symbol-observable/es/index.js": 51345/*!****************************************************!*\ 51346 !*** ./node_modules/symbol-observable/es/index.js ***! 51347 \****************************************************/ 51348/*! exports provided: default */ 51349/***/ (function(module, __webpack_exports__, __webpack_require__) { 51350 51351"use strict"; 51352__webpack_require__.r(__webpack_exports__); 51353/* WEBPACK VAR INJECTION */(function(global, module) {/* harmony import */ var _ponyfill_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ponyfill.js */ "./node_modules/symbol-observable/es/ponyfill.js"); 51354/* global window */ 51355 51356 51357var root; 51358 51359if (typeof self !== 'undefined') { 51360 root = self; 51361} else if (typeof window !== 'undefined') { 51362 root = window; 51363} else if (typeof global !== 'undefined') { 51364 root = global; 51365} else if (true) { 51366 root = module; 51367} else {} 51368 51369var result = Object(_ponyfill_js__WEBPACK_IMPORTED_MODULE_0__["default"])(root); 51370/* harmony default export */ __webpack_exports__["default"] = (result); 51371 51372/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../../webpack/buildin/harmony-module.js */ "./node_modules/webpack/buildin/harmony-module.js")(module))) 51373 51374/***/ }), 51375
vendor: 865 bytes, lines 51376-51406
51376/***/ "./node_modules/symbol-observable/es/ponyfill.js": 51377/*!*******************************************************!*\ 51378 !*** ./node_modules/symbol-observable/es/ponyfill.js ***! 51379 \*******************************************************/ 51380/*! exports provided: default */ 51381/***/ (function(module, __webpack_exports__, __webpack_require__) { 51382 51383"use strict"; 51384__webpack_require__.r(__webpack_exports__); 51385/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return symbolObservablePonyfill; }); 51386function symbolObservablePonyfill(root) { 51387 var result; 51388 var Symbol = root.Symbol; 51389 51390 if (typeof Symbol === 'function') { 51391 if (Symbol.observable) { 51392 result = Symbol.observable; 51393 } else { 51394 result = Symbol('observable'); 51395 Symbol.observable = result; 51396 } 51397 } else { 51398 result = '@@observable'; 51399 } 51400 51401 return result; 51402}; 51403 51404 51405/***/ }), 51406
vendor: 724 bytes, lines 51407-51437
51407/***/ "./node_modules/webpack/buildin/global.js": 51408/*!***********************************!*\ 51409 !*** (webpack)/buildin/global.js ***! 51410 \***********************************/ 51411/*! no static exports found */ 51412/***/ (function(module, exports) { 51413 51414var g; 51415 51416// This works in non-strict mode 51417g = (function() { 51418 return this; 51419})(); 51420 51421try { 51422 // This works if eval is allowed (see CSP) 51423 g = g || new Function("return this")(); 51424} catch (e) { 51425 // This works if the window reference is available 51426 if (typeof window === "object") g = window; 51427} 51428 51429// g can still be undefined, but nothing to do about it... 51430// We return undefined, instead of nothing here, so it's 51431// easier to handle this case. if(!global) { ...} 51432 51433module.exports = g; 51434 51435 51436/***/ }), 51437
vendor: 857 bytes, lines 51438-51472
51438/***/ "./node_modules/webpack/buildin/harmony-module.js": 51439/*!*******************************************!*\ 51440 !*** (webpack)/buildin/harmony-module.js ***! 51441 \*******************************************/ 51442/*! no static exports found */ 51443/***/ (function(module, exports) { 51444 51445module.exports = function(originalModule) { 51446 if (!originalModule.webpackPolyfill) { 51447 var module = Object.create(originalModule); 51448 // module.parent = undefined by default 51449 if (!module.children) module.children = []; 51450 Object.defineProperty(module, "loaded", { 51451 enumerable: true, 51452 get: function() { 51453 return module.l; 51454 } 51455 }); 51456 Object.defineProperty(module, "id", { 51457 enumerable: true, 51458 get: function() { 51459 return module.i; 51460 } 51461 }); 51462 Object.defineProperty(module, "exports", { 51463 enumerable: true 51464 }); 51465 module.webpackPolyfill = 1; 51466 } 51467 return module; 51468}; 51469 51470 51471/***/ }), 51472
vendor: 746 bytes, lines 51473-51504
51473/***/ "./node_modules/webpack/buildin/module.js": 51474/*!***********************************!*\ 51475 !*** (webpack)/buildin/module.js ***! 51476 \***********************************/ 51477/*! no static exports found */ 51478/***/ (function(module, exports) { 51479 51480module.exports = function(module) { 51481 if (!module.webpackPolyfill) { 51482 module.deprecate = function() {}; 51483 module.paths = []; 51484 // module.parent = undefined by default 51485 if (!module.children) module.children = []; 51486 Object.defineProperty(module, "loaded", { 51487 enumerable: true, 51488 get: function() { 51489 return module.l; 51490 } 51491 }); 51492 Object.defineProperty(module, "id", { 51493 enumerable: true, 51494 get: function() { 51495 return module.i; 51496 } 51497 }); 51498 module.webpackPolyfill = 1; 51499 } 51500 return module; 51501}; 51502 51503 51504/***/ })
51504 51505 51506}]); 51507//# sourceMappingURL=ace-common.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.