vendor: 3,595 bytes, lines 1-88
1/******/ (function(modules) { // webpackBootstrap 2/******/ // The module cache 3/******/ var installedModules = {}; 4/******/ 5/******/ // The require function 6/******/ function __webpack_require__(moduleId) { 7/******/ 8/******/ // Check if module is in cache 9/******/ if(installedModules[moduleId]) { 10/******/ return installedModules[moduleId].exports; 11/******/ } 12/******/ // Create a new module (and put it into the cache) 13/******/ var module = installedModules[moduleId] = { 14/******/ i: moduleId, 15/******/ l: false, 16/******/ exports: {} 17/******/ }; 18/******/ 19/******/ // Execute the module function 20/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21/******/ 22/******/ // Flag the module as loaded 23/******/ module.l = true; 24/******/ 25/******/ // Return the exports of the module 26/******/ return module.exports; 27/******/ } 28/******/ 29/******/ 30/******/ // expose the modules object (__webpack_modules__) 31/******/ __webpack_require__.m = modules; 32/******/ 33/******/ // expose the module cache 34/******/ __webpack_require__.c = installedModules; 35/******/ 36/******/ // define getter function for harmony exports 37/******/ __webpack_require__.d = function(exports, name, getter) { 38/******/ if(!__webpack_require__.o(exports, name)) { 39/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 40/******/ } 41/******/ }; 42/******/ 43/******/ // define __esModule on exports 44/******/ __webpack_require__.r = function(exports) { 45/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 46/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 47/******/ } 48/******/ Object.defineProperty(exports, '__esModule', { value: true }); 49/******/ }; 50/******/ 51/******/ // create a fake namespace object 52/******/ // mode & 1: value is a module id, require it 53/******/ // mode & 2: merge all properties of value into the ns 54/******/ // mode & 4: return value when already ns object 55/******/ // mode & 8|1: behave like require 56/******/ __webpack_require__.t = function(value, mode) { 57/******/ if(mode & 1) value = __webpack_require__(value); 58/******/ if(mode & 8) return value; 59/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 60/******/ var ns = Object.create(null); 61/******/ __webpack_require__.r(ns); 62/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 63/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 64/******/ return ns; 65/******/ }; 66/******/ 67/******/ // getDefaultExport function for compatibility with non-harmony modules 68/******/ __webpack_require__.n = function(module) { 69/******/ var getter = module && module.__esModule ? 70/******/ function getDefault() { return module['default']; } : 71/******/ function getModuleExports() { return module; }; 72/******/ __webpack_require__.d(getter, 'a', getter); 73/******/ return getter; 74/******/ }; 75/******/ 76/******/ // Object.prototype.hasOwnProperty.call 77/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 78/******/ 79/******/ // __webpack_public_path__ 80/******/ __webpack_require__.p = "/"; 81/******/ 82/******/ 83/******/ // Load entry module and return exports 84/******/ return __webpack_require__(__webpack_require__.s = 0); 85/******/ }) 86/************************************************************************/ 87/******/ ({ 88
vendor: 361 bytes, lines 89-99
89/***/ "./node_modules/axios/index.js": 90/*!*************************************!*\ 91 !*** ./node_modules/axios/index.js ***! 92 \*************************************/ 93/*! no static exports found */ 94/***/ (function(module, exports, __webpack_require__) { 95 96module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js"); 97 98/***/ }), 99
vendor: 6,658 bytes, lines 100-291
100/***/ "./node_modules/axios/lib/adapters/xhr.js": 101/*!************************************************!*\ 102 !*** ./node_modules/axios/lib/adapters/xhr.js ***! 103 \************************************************/ 104/*! no static exports found */ 105/***/ (function(module, exports, __webpack_require__) { 106 107"use strict"; 108 109 110var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 111var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js"); 112var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js"); 113var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js"); 114var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js"); 115var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js"); 116var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js"); 117 118module.exports = function xhrAdapter(config) { 119 return new Promise(function dispatchXhrRequest(resolve, reject) { 120 var requestData = config.data; 121 var requestHeaders = config.headers; 122 123 if (utils.isFormData(requestData)) { 124 delete requestHeaders['Content-Type']; // Let the browser set it 125 } 126 127 var request = new XMLHttpRequest(); 128 129 // HTTP basic authentication 130 if (config.auth) { 131 var username = config.auth.username || ''; 132 var password = config.auth.password || ''; 133 requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); 134 } 135 136 var fullPath = buildFullPath(config.baseURL, config.url); 137 request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); 138 139 // Set the request timeout in MS 140 request.timeout = config.timeout; 141 142 // Listen for ready state 143 request.onreadystatechange = function handleLoad() { 144 if (!request || request.readyState !== 4) { 145 return; 146 } 147 148 // The request errored out and we didn't get a response, this will be 149 // handled by onerror instead 150 // With one exception: request that using file: protocol, most browsers 151 // will return status as 0 even though it's a successful request 152 if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { 153 return; 154 } 155 156 // Prepare the response 157 var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; 158 var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; 159 var response = { 160 data: responseData, 161 status: request.status, 162 statusText: request.statusText, 163 headers: responseHeaders, 164 config: config, 165 request: request 166 }; 167 168 settle(resolve, reject, response); 169 170 // Clean up request 171 request = null; 172 }; 173 174 // Handle browser request cancellation (as opposed to a manual cancellation) 175 request.onabort = function handleAbort() { 176 if (!request) { 177 return; 178 } 179 180 reject(createError('Request aborted', config, 'ECONNABORTED', request)); 181 182 // Clean up request 183 request = null; 184 }; 185 186 // Handle low level network errors 187 request.onerror = function handleError() { 188 // Real errors are hidden from us by the browser 189 // onerror should only fire if it's a network error 190 reject(createError('Network Error', config, null, request)); 191 192 // Clean up request 193 request = null; 194 }; 195 196 // Handle timeout 197 request.ontimeout = function handleTimeout() { 198 var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; 199 if (config.timeoutErrorMessage) { 200 timeoutErrorMessage = config.timeoutErrorMessage; 201 } 202 reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', 203 request)); 204 205 // Clean up request 206 request = null; 207 }; 208 209 // Add xsrf header 210 // This is only done if running in a standard browser environment. 211 // Specifically not if we're in a web worker, or react-native. 212 if (utils.isStandardBrowserEnv()) { 213 var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js"); 214 215 // Add xsrf header 216 var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? 217 cookies.read(config.xsrfCookieName) : 218 undefined; 219 220 if (xsrfValue) { 221 requestHeaders[config.xsrfHeaderName] = xsrfValue; 222 } 223 } 224 225 // Add headers to the request 226 if ('setRequestHeader' in request) { 227 utils.forEach(requestHeaders, function setRequestHeader(val, key) { 228 if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { 229 // Remove Content-Type if data is undefined 230 delete requestHeaders[key]; 231 } else { 232 // Otherwise add header to the request 233 request.setRequestHeader(key, val); 234 } 235 }); 236 } 237 238 // Add withCredentials to request if needed 239 if (!utils.isUndefined(config.withCredentials)) { 240 request.withCredentials = !!config.withCredentials; 241 } 242 243 // Add responseType to request if needed 244 if (config.responseType) { 245 try { 246 request.responseType = config.responseType; 247 } catch (e) { 248 // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. 249 // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. 250 if (config.responseType !== 'json') { 251 throw e; 252 } 253 } 254 } 255 256 // Handle progress if needed 257 if (typeof config.onDownloadProgress === 'function') { 258 request.addEventListener('progress', config.onDownloadProgress); 259 } 260 261 // Not all browsers support upload events 262 if (typeof config.onUploadProgress === 'function' && request.upload) { 263 request.upload.addEventListener('progress', config.onUploadProgress); 264 } 265 266 if (config.cancelToken) { 267 // Handle cancellation 268 config.cancelToken.promise.then(function onCanceled(cancel) { 269 if (!request) { 270 return; 271 } 272 273 request.abort(); 274 reject(cancel); 275 // Clean up request 276 request = null; 277 }); 278 } 279 280 if (requestData === undefined) { 281 requestData = null; 282 } 283 284 // Send the request 285 request.send(requestData); 286 }); 287}; 288 289 290/***/ }), 291
vendor: 2,251 bytes, lines 292-356
292/***/ "./node_modules/axios/lib/axios.js": 293/*!*****************************************!*\ 294 !*** ./node_modules/axios/lib/axios.js ***! 295 \*****************************************/ 296/*! no static exports found */ 297/***/ (function(module, exports, __webpack_require__) { 298 299"use strict"; 300 301 302var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js"); 303var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js"); 304var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js"); 305var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js"); 306var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js"); 307 308/** 309 * Create an instance of Axios 310 * 311 * @param {Object} defaultConfig The default config for the instance 312 * @return {Axios} A new instance of Axios 313 */ 314function createInstance(defaultConfig) { 315 var context = new Axios(defaultConfig); 316 var instance = bind(Axios.prototype.request, context); 317 318 // Copy axios.prototype to instance 319 utils.extend(instance, Axios.prototype, context); 320 321 // Copy context to instance 322 utils.extend(instance, context); 323 324 return instance; 325} 326 327// Create the default instance to be exported 328var axios = createInstance(defaults); 329 330// Expose Axios class to allow class inheritance 331axios.Axios = Axios; 332 333// Factory for creating new instances 334axios.create = function create(instanceConfig) { 335 return createInstance(mergeConfig(axios.defaults, instanceConfig)); 336}; 337 338// Expose Cancel & CancelToken 339axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 340axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js"); 341axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js"); 342 343// Expose all/spread 344axios.all = function all(promises) { 345 return Promise.all(promises); 346}; 347axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js"); 348 349module.exports = axios; 350 351// Allow use of default import syntax in TypeScript 352module.exports.default = axios; 353 354 355/***/ }), 356
vendor: 702 bytes, lines 357-387
357/***/ "./node_modules/axios/lib/cancel/Cancel.js": 358/*!*************************************************!*\ 359 !*** ./node_modules/axios/lib/cancel/Cancel.js ***! 360 \*************************************************/ 361/*! no static exports found */ 362/***/ (function(module, exports, __webpack_require__) { 363 364"use strict"; 365 366 367/** 368 * A `Cancel` is an object that is thrown when an operation is canceled. 369 * 370 * @class 371 * @param {string=} message The message. 372 */ 373function Cancel(message) { 374 this.message = message; 375} 376 377Cancel.prototype.toString = function toString() { 378 return 'Cancel' + (this.message ? ': ' + this.message : ''); 379}; 380 381Cancel.prototype.__CANCEL__ = true; 382 383module.exports = Cancel; 384 385 386/***/ }), 387
vendor: 1,638 bytes, lines 388-456
388/***/ "./node_modules/axios/lib/cancel/CancelToken.js": 389/*!******************************************************!*\ 390 !*** ./node_modules/axios/lib/cancel/CancelToken.js ***! 391 \******************************************************/ 392/*! no static exports found */ 393/***/ (function(module, exports, __webpack_require__) { 394 395"use strict"; 396 397 398var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 399 400/** 401 * A `CancelToken` is an object that can be used to request cancellation of an operation. 402 * 403 * @class 404 * @param {Function} executor The executor function. 405 */ 406function CancelToken(executor) { 407 if (typeof executor !== 'function') { 408 throw new TypeError('executor must be a function.'); 409 } 410 411 var resolvePromise; 412 this.promise = new Promise(function promiseExecutor(resolve) { 413 resolvePromise = resolve; 414 }); 415 416 var token = this; 417 executor(function cancel(message) { 418 if (token.reason) { 419 // Cancellation has already been requested 420 return; 421 } 422 423 token.reason = new Cancel(message); 424 resolvePromise(token.reason); 425 }); 426} 427 428/** 429 * Throws a `Cancel` if cancellation has been requested. 430 */ 431CancelToken.prototype.throwIfRequested = function throwIfRequested() { 432 if (this.reason) { 433 throw this.reason; 434 } 435}; 436 437/** 438 * Returns an object that contains a new `CancelToken` and a function that, when called, 439 * cancels the `CancelToken`. 440 */ 441CancelToken.source = function source() { 442 var cancel; 443 var token = new CancelToken(function executor(c) { 444 cancel = c; 445 }); 446 return { 447 token: token, 448 cancel: cancel 449 }; 450}; 451 452module.exports = CancelToken; 453 454 455/***/ }), 456
vendor: 427 bytes, lines 457-473
457/***/ "./node_modules/axios/lib/cancel/isCancel.js": 458/*!***************************************************!*\ 459 !*** ./node_modules/axios/lib/cancel/isCancel.js ***! 460 \***************************************************/ 461/*! no static exports found */ 462/***/ (function(module, exports, __webpack_require__) { 463 464"use strict"; 465 466 467module.exports = function isCancel(value) { 468 return !!(value && value.__CANCEL__); 469}; 470 471 472/***/ }), 473
vendor: 3,240 bytes, lines 474-579
474/***/ "./node_modules/axios/lib/core/Axios.js": 475/*!**********************************************!*\ 476 !*** ./node_modules/axios/lib/core/Axios.js ***! 477 \**********************************************/ 478/*! no static exports found */ 479/***/ (function(module, exports, __webpack_require__) { 480 481"use strict"; 482 483 484var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 485var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js"); 486var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js"); 487var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js"); 488var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js"); 489 490/** 491 * Create a new instance of Axios 492 * 493 * @param {Object} instanceConfig The default config for the instance 494 */ 495function Axios(instanceConfig) { 496 this.defaults = instanceConfig; 497 this.interceptors = { 498 request: new InterceptorManager(), 499 response: new InterceptorManager() 500 }; 501} 502 503/** 504 * Dispatch a request 505 * 506 * @param {Object} config The config specific for this request (merged with this.defaults) 507 */ 508Axios.prototype.request = function request(config) { 509 /*eslint no-param-reassign:0*/ 510 // Allow for axios('example/url'[, config]) a la fetch API 511 if (typeof config === 'string') { 512 config = arguments[1] || {}; 513 config.url = arguments[0]; 514 } else { 515 config = config || {}; 516 } 517 518 config = mergeConfig(this.defaults, config); 519 520 // Set config.method 521 if (config.method) { 522 config.method = config.method.toLowerCase(); 523 } else if (this.defaults.method) { 524 config.method = this.defaults.method.toLowerCase(); 525 } else { 526 config.method = 'get'; 527 } 528 529 // Hook up interceptors middleware 530 var chain = [dispatchRequest, undefined]; 531 var promise = Promise.resolve(config); 532 533 this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { 534 chain.unshift(interceptor.fulfilled, interceptor.rejected); 535 }); 536 537 this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { 538 chain.push(interceptor.fulfilled, interceptor.rejected); 539 }); 540 541 while (chain.length) { 542 promise = promise.then(chain.shift(), chain.shift()); 543 } 544 545 return promise; 546}; 547 548Axios.prototype.getUri = function getUri(config) { 549 config = mergeConfig(this.defaults, config); 550 return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); 551}; 552 553// Provide aliases for supported request methods 554utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { 555 /*eslint func-names:0*/ 556 Axios.prototype[method] = function(url, config) { 557 return this.request(utils.merge(config || {}, { 558 method: method, 559 url: url 560 })); 561 }; 562}); 563 564utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 565 /*eslint func-names:0*/ 566 Axios.prototype[method] = function(url, data, config) { 567 return this.request(utils.merge(config || {}, { 568 method: method, 569 url: url, 570 data: data 571 })); 572 }; 573}); 574 575module.exports = Axios; 576 577 578/***/ }), 579
vendor: 1,661 bytes, lines 580-643
580/***/ "./node_modules/axios/lib/core/InterceptorManager.js": 581/*!***********************************************************!*\ 582 !*** ./node_modules/axios/lib/core/InterceptorManager.js ***! 583 \***********************************************************/ 584/*! no static exports found */ 585/***/ (function(module, exports, __webpack_require__) { 586 587"use strict"; 588 589 590var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 591 592function InterceptorManager() { 593 this.handlers = []; 594} 595 596/** 597 * Add a new interceptor to the stack 598 * 599 * @param {Function} fulfilled The function to handle `then` for a `Promise` 600 * @param {Function} rejected The function to handle `reject` for a `Promise` 601 * 602 * @return {Number} An ID used to remove interceptor later 603 */ 604InterceptorManager.prototype.use = function use(fulfilled, rejected) { 605 this.handlers.push({ 606 fulfilled: fulfilled, 607 rejected: rejected 608 }); 609 return this.handlers.length - 1; 610}; 611 612/** 613 * Remove an interceptor from the stack 614 * 615 * @param {Number} id The ID that was returned by `use` 616 */ 617InterceptorManager.prototype.eject = function eject(id) { 618 if (this.handlers[id]) { 619 this.handlers[id] = null; 620 } 621}; 622 623/** 624 * Iterate over all the registered interceptors 625 * 626 * This method is particularly useful for skipping over any 627 * interceptors that may have become `null` calling `eject`. 628 * 629 * @param {Function} fn The function to call for each interceptor 630 */ 631InterceptorManager.prototype.forEach = function forEach(fn) { 632 utils.forEach(this.handlers, function forEachHandler(h) { 633 if (h !== null) { 634 fn(h); 635 } 636 }); 637}; 638 639module.exports = InterceptorManager; 640 641 642/***/ }), 643
vendor: 1,168 bytes, lines 644-675
644/***/ "./node_modules/axios/lib/core/buildFullPath.js": 645/*!******************************************************!*\ 646 !*** ./node_modules/axios/lib/core/buildFullPath.js ***! 647 \******************************************************/ 648/*! no static exports found */ 649/***/ (function(module, exports, __webpack_require__) { 650 651"use strict"; 652 653 654var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js"); 655var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js"); 656 657/** 658 * Creates a new URL by combining the baseURL with the requestedURL, 659 * only when the requestedURL is not already an absolute URL. 660 * If the requestURL is absolute, this function returns the requestedURL untouched. 661 * 662 * @param {string} baseURL The base URL 663 * @param {string} requestedURL Absolute or relative URL to combine 664 * @returns {string} The combined full path 665 */ 666module.exports = function buildFullPath(baseURL, requestedURL) { 667 if (baseURL && !isAbsoluteURL(requestedURL)) { 668 return combineURLs(baseURL, requestedURL); 669 } 670 return requestedURL; 671}; 672 673 674/***/ }), 675
vendor: 1,019 bytes, lines 676-705
676/***/ "./node_modules/axios/lib/core/createError.js": 677/*!****************************************************!*\ 678 !*** ./node_modules/axios/lib/core/createError.js ***! 679 \****************************************************/ 680/*! no static exports found */ 681/***/ (function(module, exports, __webpack_require__) { 682 683"use strict"; 684 685 686var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js"); 687 688/** 689 * Create an Error with the specified message, config, error code, request and response. 690 * 691 * @param {string} message The error message. 692 * @param {Object} config The config. 693 * @param {string} [code] The error code (for example, 'ECONNABORTED'). 694 * @param {Object} [request] The request. 695 * @param {Object} [response] The response. 696 * @returns {Error} The created error. 697 */ 698module.exports = function createError(message, config, code, request, response) { 699 var error = new Error(message); 700 return enhanceError(error, config, code, request, response); 701}; 702 703 704/***/ }), 705
vendor: 2,517 bytes, lines 706-796
706/***/ "./node_modules/axios/lib/core/dispatchRequest.js": 707/*!********************************************************!*\ 708 !*** ./node_modules/axios/lib/core/dispatchRequest.js ***! 709 \********************************************************/ 710/*! no static exports found */ 711/***/ (function(module, exports, __webpack_require__) { 712 713"use strict"; 714 715 716var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 717var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js"); 718var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js"); 719var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js"); 720 721/** 722 * Throws a `Cancel` if cancellation has been requested. 723 */ 724function throwIfCancellationRequested(config) { 725 if (config.cancelToken) { 726 config.cancelToken.throwIfRequested(); 727 } 728} 729 730/** 731 * Dispatch a request to the server using the configured adapter. 732 * 733 * @param {object} config The config that is to be used for the request 734 * @returns {Promise} The Promise to be fulfilled 735 */ 736module.exports = function dispatchRequest(config) { 737 throwIfCancellationRequested(config); 738 739 // Ensure headers exist 740 config.headers = config.headers || {}; 741 742 // Transform request data 743 config.data = transformData( 744 config.data, 745 config.headers, 746 config.transformRequest 747 ); 748 749 // Flatten headers 750 config.headers = utils.merge( 751 config.headers.common || {}, 752 config.headers[config.method] || {}, 753 config.headers 754 ); 755 756 utils.forEach( 757 ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], 758 function cleanHeaderConfig(method) { 759 delete config.headers[method]; 760 } 761 ); 762 763 var adapter = config.adapter || defaults.adapter; 764 765 return adapter(config).then(function onAdapterResolution(response) { 766 throwIfCancellationRequested(config); 767 768 // Transform response data 769 response.data = transformData( 770 response.data, 771 response.headers, 772 config.transformResponse 773 ); 774 775 return response; 776 }, function onAdapterRejection(reason) { 777 if (!isCancel(reason)) { 778 throwIfCancellationRequested(config); 779 780 // Transform response data 781 if (reason && reason.response) { 782 reason.response.data = transformData( 783 reason.response.data, 784 reason.response.headers, 785 config.transformResponse 786 ); 787 } 788 } 789 790 return Promise.reject(reason); 791 }); 792}; 793 794 795/***/ }), 796
vendor: 1,375 bytes, lines 797-850
797/***/ "./node_modules/axios/lib/core/enhanceError.js": 798/*!*****************************************************!*\ 799 !*** ./node_modules/axios/lib/core/enhanceError.js ***! 800 \*****************************************************/ 801/*! no static exports found */ 802/***/ (function(module, exports, __webpack_require__) { 803 804"use strict"; 805 806 807/** 808 * Update an Error with the specified config, error code, and response. 809 * 810 * @param {Error} error The error to update. 811 * @param {Object} config The config. 812 * @param {string} [code] The error code (for example, 'ECONNABORTED'). 813 * @param {Object} [request] The request. 814 * @param {Object} [response] The response. 815 * @returns {Error} The error. 816 */ 817module.exports = function enhanceError(error, config, code, request, response) { 818 error.config = config; 819 if (code) { 820 error.code = code; 821 } 822 823 error.request = request; 824 error.response = response; 825 error.isAxiosError = true; 826 827 error.toJSON = function() { 828 return { 829 // Standard 830 message: this.message, 831 name: this.name, 832 // Microsoft 833 description: this.description, 834 number: this.number, 835 // Mozilla 836 fileName: this.fileName, 837 lineNumber: this.lineNumber, 838 columnNumber: this.columnNumber, 839 stack: this.stack, 840 // Axios 841 config: this.config, 842 code: this.code 843 }; 844 }; 845 return error; 846}; 847 848 849/***/ }), 850
vendor: 2,792 bytes, lines 851-935
851/***/ "./node_modules/axios/lib/core/mergeConfig.js": 852/*!****************************************************!*\ 853 !*** ./node_modules/axios/lib/core/mergeConfig.js ***! 854 \****************************************************/ 855/*! no static exports found */ 856/***/ (function(module, exports, __webpack_require__) { 857 858"use strict"; 859 860 861var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js"); 862 863/** 864 * Config-specific merge-function which creates a new config-object 865 * by merging two configuration objects together. 866 * 867 * @param {Object} config1 868 * @param {Object} config2 869 * @returns {Object} New object resulting from merging config2 to config1 870 */ 871module.exports = function mergeConfig(config1, config2) { 872 // eslint-disable-next-line no-param-reassign 873 config2 = config2 || {}; 874 var config = {}; 875 876 var valueFromConfig2Keys = ['url', 'method', 'params', 'data']; 877 var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy']; 878 var defaultToConfig2Keys = [ 879 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer', 880 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', 881 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 882 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent', 883 'httpsAgent', 'cancelToken', 'socketPath' 884 ]; 885 886 utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) { 887 if (typeof config2[prop] !== 'undefined') { 888 config[prop] = config2[prop]; 889 } 890 }); 891 892 utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) { 893 if (utils.isObject(config2[prop])) { 894 config[prop] = utils.deepMerge(config1[prop], config2[prop]); 895 } else if (typeof config2[prop] !== 'undefined') { 896 config[prop] = config2[prop]; 897 } else if (utils.isObject(config1[prop])) { 898 config[prop] = utils.deepMerge(config1[prop]); 899 } else if (typeof config1[prop] !== 'undefined') { 900 config[prop] = config1[prop]; 901 } 902 }); 903 904 utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) { 905 if (typeof config2[prop] !== 'undefined') { 906 config[prop] = config2[prop]; 907 } else if (typeof config1[prop] !== 'undefined') { 908 config[prop] = config1[prop]; 909 } 910 }); 911 912 var axiosKeys = valueFromConfig2Keys 913 .concat(mergeDeepPropertiesKeys) 914 .concat(defaultToConfig2Keys); 915 916 var otherKeys = Object 917 .keys(config2) 918 .filter(function filterAxiosKeys(key) { 919 return axiosKeys.indexOf(key) === -1; 920 }); 921 922 utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) { 923 if (typeof config2[prop] !== 'undefined') { 924 config[prop] = config2[prop]; 925 } else if (typeof config1[prop] !== 'undefined') { 926 config[prop] = config1[prop]; 927 } 928 }); 929 930 return config; 931}; 932 933 934/***/ }), 935
vendor: 1,059 bytes, lines 936-972
936/***/ "./node_modules/axios/lib/core/settle.js": 937/*!***********************************************!*\ 938 !*** ./node_modules/axios/lib/core/settle.js ***! 939 \***********************************************/ 940/*! no static exports found */ 941/***/ (function(module, exports, __webpack_require__) { 942 943"use strict"; 944 945 946var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js"); 947 948/** 949 * Resolve or reject a Promise based on response status. 950 * 951 * @param {Function} resolve A function that resolves the promise. 952 * @param {Function} reject A function that rejects the promise. 953 * @param {object} response The response. 954 */ 955module.exports = function settle(resolve, reject, response) { 956 var validateStatus = response.config.validateStatus; 957 if (!validateStatus || validateStatus(response.status)) { 958 resolve(response); 959 } else { 960 reject(createError( 961 'Request failed with status code ' + response.status, 962 response.config, 963 null, 964 response.request, 965 response 966 )); 967 } 968}; 969 970 971/***/ }), 972
vendor: 940 bytes, lines 973-1004
973/***/ "./node_modules/axios/lib/core/transformData.js": 974/*!******************************************************!*\ 975 !*** ./node_modules/axios/lib/core/transformData.js ***! 976 \******************************************************/ 977/*! no static exports found */ 978/***/ (function(module, exports, __webpack_require__) { 979 980"use strict"; 981 982 983var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 984 985/** 986 * Transform the data for a request or a response 987 * 988 * @param {Object|String} data The data to be transformed 989 * @param {Array} headers The headers for the request or response 990 * @param {Array|Function} fns A single function or Array of functions 991 * @returns {*} The resulting transformed data 992 */ 993module.exports = function transformData(data, headers, fns) { 994 /*eslint no-param-reassign:0*/ 995 utils.forEach(fns, function transform(fn) { 996 data = fn(data, headers); 997 }); 998 999 return data; 1000}; 1001 1002 1003/***/ }), 1004
vendor: 3,267 bytes, lines 1005-1114
1005/***/ "./node_modules/axios/lib/defaults.js": 1006/*!********************************************!*\ 1007 !*** ./node_modules/axios/lib/defaults.js ***! 1008 \********************************************/ 1009/*! no static exports found */ 1010/***/ (function(module, exports, __webpack_require__) { 1011 1012"use strict"; 1013/* WEBPACK VAR INJECTION */(function(process) { 1014 1015var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js"); 1016var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js"); 1017 1018var DEFAULT_CONTENT_TYPE = { 1019 'Content-Type': 'application/x-www-form-urlencoded' 1020}; 1021 1022function setContentTypeIfUnset(headers, value) { 1023 if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { 1024 headers['Content-Type'] = value; 1025 } 1026} 1027 1028function getDefaultAdapter() { 1029 var adapter; 1030 if (typeof XMLHttpRequest !== 'undefined') { 1031 // For browsers use XHR adapter 1032 adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js"); 1033 } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { 1034 // For node use HTTP adapter 1035 adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js"); 1036 } 1037 return adapter; 1038} 1039 1040var defaults = { 1041 adapter: getDefaultAdapter(), 1042 1043 transformRequest: [function transformRequest(data, headers) { 1044 normalizeHeaderName(headers, 'Accept'); 1045 normalizeHeaderName(headers, 'Content-Type'); 1046 if (utils.isFormData(data) || 1047 utils.isArrayBuffer(data) || 1048 utils.isBuffer(data) || 1049 utils.isStream(data) || 1050 utils.isFile(data) || 1051 utils.isBlob(data) 1052 ) { 1053 return data; 1054 } 1055 if (utils.isArrayBufferView(data)) { 1056 return data.buffer; 1057 } 1058 if (utils.isURLSearchParams(data)) { 1059 setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); 1060 return data.toString(); 1061 } 1062 if (utils.isObject(data)) { 1063 setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); 1064 return JSON.stringify(data); 1065 } 1066 return data; 1067 }], 1068 1069 transformResponse: [function transformResponse(data) { 1070 /*eslint no-param-reassign:0*/ 1071 if (typeof data === 'string') { 1072 try { 1073 data = JSON.parse(data); 1074 } catch (e) { /* Ignore */ } 1075 } 1076 return data; 1077 }], 1078 1079 /** 1080 * A timeout in milliseconds to abort a request. If set to 0 (default) a 1081 * timeout is not created. 1082 */ 1083 timeout: 0, 1084 1085 xsrfCookieName: 'XSRF-TOKEN', 1086 xsrfHeaderName: 'X-XSRF-TOKEN', 1087 1088 maxContentLength: -1, 1089 1090 validateStatus: function validateStatus(status) { 1091 return status >= 200 && status < 300; 1092 } 1093}; 1094 1095defaults.headers = { 1096 common: { 1097 'Accept': 'application/json, text/plain, */*' 1098 } 1099}; 1100 1101utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { 1102 defaults.headers[method] = {}; 1103}); 1104 1105utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 1106 defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); 1107}); 1108 1109module.exports = defaults; 1110 1111/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js"))) 1112 1113/***/ }), 1114
vendor: 569 bytes, lines 1115-1137
1115/***/ "./node_modules/axios/lib/helpers/bind.js": 1116/*!************************************************!*\ 1117 !*** ./node_modules/axios/lib/helpers/bind.js ***! 1118 \************************************************/ 1119/*! no static exports found */ 1120/***/ (function(module, exports, __webpack_require__) { 1121 1122"use strict"; 1123 1124 1125module.exports = function bind(fn, thisArg) { 1126 return function wrap() { 1127 var args = new Array(arguments.length); 1128 for (var i = 0; i < args.length; i++) { 1129 args[i] = arguments[i]; 1130 } 1131 return fn.apply(thisArg, args); 1132 }; 1133}; 1134 1135 1136/***/ }), 1137
vendor: 2,053 bytes, lines 1138-1220
1138/***/ "./node_modules/axios/lib/helpers/buildURL.js": 1139/*!****************************************************!*\ 1140 !*** ./node_modules/axios/lib/helpers/buildURL.js ***! 1141 \****************************************************/ 1142/*! no static exports found */ 1143/***/ (function(module, exports, __webpack_require__) { 1144 1145"use strict"; 1146 1147 1148var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1149 1150function encode(val) { 1151 return encodeURIComponent(val). 1152 replace(/%40/gi, '@'). 1153 replace(/%3A/gi, ':'). 1154 replace(/%24/g, '$'). 1155 replace(/%2C/gi, ','). 1156 replace(/%20/g, '+'). 1157 replace(/%5B/gi, '['). 1158 replace(/%5D/gi, ']'); 1159} 1160 1161/** 1162 * Build a URL by appending params to the end 1163 * 1164 * @param {string} url The base of the url (e.g., http://www.google.com) 1165 * @param {object} [params] The params to be appended 1166 * @returns {string} The formatted url 1167 */ 1168module.exports = function buildURL(url, params, paramsSerializer) { 1169 /*eslint no-param-reassign:0*/ 1170 if (!params) { 1171 return url; 1172 } 1173 1174 var serializedParams; 1175 if (paramsSerializer) { 1176 serializedParams = paramsSerializer(params); 1177 } else if (utils.isURLSearchParams(params)) { 1178 serializedParams = params.toString(); 1179 } else { 1180 var parts = []; 1181 1182 utils.forEach(params, function serialize(val, key) { 1183 if (val === null || typeof val === 'undefined') { 1184 return; 1185 } 1186 1187 if (utils.isArray(val)) { 1188 key = key + '[]'; 1189 } else { 1190 val = [val]; 1191 } 1192 1193 utils.forEach(val, function parseValue(v) { 1194 if (utils.isDate(v)) { 1195 v = v.toISOString(); 1196 } else if (utils.isObject(v)) { 1197 v = JSON.stringify(v); 1198 } 1199 parts.push(encode(key) + '=' + encode(v)); 1200 }); 1201 }); 1202 1203 serializedParams = parts.join('&'); 1204 } 1205 1206 if (serializedParams) { 1207 var hashmarkIndex = url.indexOf('#'); 1208 if (hashmarkIndex !== -1) { 1209 url = url.slice(0, hashmarkIndex); 1210 } 1211 1212 url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; 1213 } 1214 1215 return url; 1216}; 1217 1218 1219/***/ }), 1220
vendor: 721 bytes, lines 1221-1246
1221/***/ "./node_modules/axios/lib/helpers/combineURLs.js": 1222/*!*******************************************************!*\ 1223 !*** ./node_modules/axios/lib/helpers/combineURLs.js ***! 1224 \*******************************************************/ 1225/*! no static exports found */ 1226/***/ (function(module, exports, __webpack_require__) { 1227 1228"use strict"; 1229 1230 1231/** 1232 * Creates a new URL by combining the specified URLs 1233 * 1234 * @param {string} baseURL The base URL 1235 * @param {string} relativeURL The relative URL 1236 * @returns {string} The combined URL 1237 */ 1238module.exports = function combineURLs(baseURL, relativeURL) { 1239 return relativeURL 1240 ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') 1241 : baseURL; 1242}; 1243 1244 1245/***/ }), 1246
vendor: 1,813 bytes, lines 1247-1311
1247/***/ "./node_modules/axios/lib/helpers/cookies.js": 1248/*!***************************************************!*\ 1249 !*** ./node_modules/axios/lib/helpers/cookies.js ***! 1250 \***************************************************/ 1251/*! no static exports found */ 1252/***/ (function(module, exports, __webpack_require__) { 1253 1254"use strict"; 1255 1256 1257var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1258 1259module.exports = ( 1260 utils.isStandardBrowserEnv() ? 1261 1262 // Standard browser envs support document.cookie 1263 (function standardBrowserEnv() { 1264 return { 1265 write: function write(name, value, expires, path, domain, secure) { 1266 var cookie = []; 1267 cookie.push(name + '=' + encodeURIComponent(value)); 1268 1269 if (utils.isNumber(expires)) { 1270 cookie.push('expires=' + new Date(expires).toGMTString()); 1271 } 1272 1273 if (utils.isString(path)) { 1274 cookie.push('path=' + path); 1275 } 1276 1277 if (utils.isString(domain)) { 1278 cookie.push('domain=' + domain); 1279 } 1280 1281 if (secure === true) { 1282 cookie.push('secure'); 1283 } 1284 1285 document.cookie = cookie.join('; '); 1286 }, 1287 1288 read: function read(name) { 1289 var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); 1290 return (match ? decodeURIComponent(match[3]) : null); 1291 }, 1292 1293 remove: function remove(name) { 1294 this.write(name, '', Date.now() - 86400000); 1295 } 1296 }; 1297 })() : 1298 1299 // Non standard browser env (web workers, react-native) lack needed support. 1300 (function nonStandardBrowserEnv() { 1301 return { 1302 write: function write() {}, 1303 read: function read() { return null; }, 1304 remove: function remove() {} 1305 }; 1306 })() 1307); 1308 1309 1310/***/ }), 1311
vendor: 912 bytes, lines 1312-1337
1312/***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js": 1313/*!*********************************************************!*\ 1314 !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***! 1315 \*********************************************************/ 1316/*! no static exports found */ 1317/***/ (function(module, exports, __webpack_require__) { 1318 1319"use strict"; 1320 1321 1322/** 1323 * Determines whether the specified URL is absolute 1324 * 1325 * @param {string} url The URL to test 1326 * @returns {boolean} True if the specified URL is absolute, otherwise false 1327 */ 1328module.exports = function isAbsoluteURL(url) { 1329 // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL). 1330 // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed 1331 // by any combination of letters, digits, plus, period, or hyphen. 1332 return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); 1333}; 1334 1335 1336/***/ }), 1337
vendor: 2,715 bytes, lines 1338-1417
1338/***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js": 1339/*!***********************************************************!*\ 1340 !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***! 1341 \***********************************************************/ 1342/*! no static exports found */ 1343/***/ (function(module, exports, __webpack_require__) { 1344 1345"use strict"; 1346 1347 1348var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1349 1350module.exports = ( 1351 utils.isStandardBrowserEnv() ? 1352 1353 // Standard browser envs have full support of the APIs needed to test 1354 // whether the request URL is of the same origin as current location. 1355 (function standardBrowserEnv() { 1356 var msie = /(msie|trident)/i.test(navigator.userAgent); 1357 var urlParsingNode = document.createElement('a'); 1358 var originURL; 1359 1360 /** 1361 * Parse a URL to discover it's components 1362 * 1363 * @param {String} url The URL to be parsed 1364 * @returns {Object} 1365 */ 1366 function resolveURL(url) { 1367 var href = url; 1368 1369 if (msie) { 1370 // IE needs attribute set twice to normalize properties 1371 urlParsingNode.setAttribute('href', href); 1372 href = urlParsingNode.href; 1373 } 1374 1375 urlParsingNode.setAttribute('href', href); 1376 1377 // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 1378 return { 1379 href: urlParsingNode.href, 1380 protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 1381 host: urlParsingNode.host, 1382 search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 1383 hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 1384 hostname: urlParsingNode.hostname, 1385 port: urlParsingNode.port, 1386 pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 1387 urlParsingNode.pathname : 1388 '/' + urlParsingNode.pathname 1389 }; 1390 } 1391 1392 originURL = resolveURL(window.location.href); 1393 1394 /** 1395 * Determine if a URL shares the same origin as the current location 1396 * 1397 * @param {String} requestURL The URL to test 1398 * @returns {boolean} True if URL shares the same origin, otherwise false 1399 */ 1400 return function isURLSameOrigin(requestURL) { 1401 var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; 1402 return (parsed.protocol === originURL.protocol && 1403 parsed.host === originURL.host); 1404 }; 1405 })() : 1406 1407 // Non standard browser envs (web workers, react-native) lack needed support. 1408 (function nonStandardBrowserEnv() { 1409 return function isURLSameOrigin() { 1410 return true; 1411 }; 1412 })() 1413); 1414 1415 1416/***/ }), 1417
vendor: 783 bytes, lines 1418-1441
1418/***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js": 1419/*!***************************************************************!*\ 1420 !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***! 1421 \***************************************************************/ 1422/*! no static exports found */ 1423/***/ (function(module, exports, __webpack_require__) { 1424 1425"use strict"; 1426 1427 1428var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js"); 1429 1430module.exports = function normalizeHeaderName(headers, normalizedName) { 1431 utils.forEach(headers, function processHeader(value, name) { 1432 if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { 1433 headers[normalizedName] = value; 1434 delete headers[name]; 1435 } 1436 }); 1437}; 1438 1439 1440/***/ }), 1441
vendor: 1,791 bytes, lines 1442-1506
1442/***/ "./node_modules/axios/lib/helpers/parseHeaders.js": 1443/*!********************************************************!*\ 1444 !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***! 1445 \********************************************************/ 1446/*! no static exports found */ 1447/***/ (function(module, exports, __webpack_require__) { 1448 1449"use strict"; 1450 1451 1452var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1453 1454// Headers whose duplicates are ignored by node 1455// c.f. https://nodejs.org/api/http.html#http_message_headers 1456var ignoreDuplicateOf = [ 1457 'age', 'authorization', 'content-length', 'content-type', 'etag', 1458 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 1459 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 1460 'referer', 'retry-after', 'user-agent' 1461]; 1462 1463/** 1464 * Parse headers into an object 1465 * 1466 * ``` 1467 * Date: Wed, 27 Aug 2014 08:58:49 GMT 1468 * Content-Type: application/json 1469 * Connection: keep-alive 1470 * Transfer-Encoding: chunked 1471 * ``` 1472 * 1473 * @param {String} headers Headers needing to be parsed 1474 * @returns {Object} Headers parsed into an object 1475 */ 1476module.exports = function parseHeaders(headers) { 1477 var parsed = {}; 1478 var key; 1479 var val; 1480 var i; 1481 1482 if (!headers) { return parsed; } 1483 1484 utils.forEach(headers.split('\n'), function parser(line) { 1485 i = line.indexOf(':'); 1486 key = utils.trim(line.substr(0, i)).toLowerCase(); 1487 val = utils.trim(line.substr(i + 1)); 1488 1489 if (key) { 1490 if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { 1491 return; 1492 } 1493 if (key === 'set-cookie') { 1494 parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); 1495 } else { 1496 parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 1497 } 1498 } 1499 }); 1500 1501 return parsed; 1502}; 1503 1504 1505/***/ }), 1506
vendor: 885 bytes, lines 1507-1545
1507/***/ "./node_modules/axios/lib/helpers/spread.js": 1508/*!**************************************************!*\ 1509 !*** ./node_modules/axios/lib/helpers/spread.js ***! 1510 \**************************************************/ 1511/*! no static exports found */ 1512/***/ (function(module, exports, __webpack_require__) { 1513 1514"use strict"; 1515 1516 1517/** 1518 * Syntactic sugar for invoking a function and expanding an array for arguments. 1519 * 1520 * Common use case would be to use `Function.prototype.apply`. 1521 * 1522 * ```js 1523 * function f(x, y, z) {} 1524 * var args = [1, 2, 3]; 1525 * f.apply(null, args); 1526 * ``` 1527 * 1528 * With `spread` this example can be re-written. 1529 * 1530 * ```js 1531 * spread(function(x, y, z) {})([1, 2, 3]); 1532 * ``` 1533 * 1534 * @param {Function} callback 1535 * @returns {Function} 1536 */ 1537module.exports = function spread(callback) { 1538 return function wrap(arr) { 1539 return callback.apply(null, arr); 1540 }; 1541}; 1542 1543 1544/***/ }), 1545
vendor: 9,160 bytes, lines 1546-1901
1546/***/ "./node_modules/axios/lib/utils.js": 1547/*!*****************************************!*\ 1548 !*** ./node_modules/axios/lib/utils.js ***! 1549 \*****************************************/ 1550/*! no static exports found */ 1551/***/ (function(module, exports, __webpack_require__) { 1552 1553"use strict"; 1554 1555 1556var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js"); 1557 1558/*global toString:true*/ 1559 1560// utils is a library of generic helper functions non-specific to axios 1561 1562var toString = Object.prototype.toString; 1563 1564/** 1565 * Determine if a value is an Array 1566 * 1567 * @param {Object} val The value to test 1568 * @returns {boolean} True if value is an Array, otherwise false 1569 */ 1570function isArray(val) { 1571 return toString.call(val) === '[object Array]'; 1572} 1573 1574/** 1575 * Determine if a value is undefined 1576 * 1577 * @param {Object} val The value to test 1578 * @returns {boolean} True if the value is undefined, otherwise false 1579 */ 1580function isUndefined(val) { 1581 return typeof val === 'undefined'; 1582} 1583 1584/** 1585 * Determine if a value is a Buffer 1586 * 1587 * @param {Object} val The value to test 1588 * @returns {boolean} True if value is a Buffer, otherwise false 1589 */ 1590function isBuffer(val) { 1591 return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) 1592 && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); 1593} 1594 1595/** 1596 * Determine if a value is an ArrayBuffer 1597 * 1598 * @param {Object} val The value to test 1599 * @returns {boolean} True if value is an ArrayBuffer, otherwise false 1600 */ 1601function isArrayBuffer(val) { 1602 return toString.call(val) === '[object ArrayBuffer]'; 1603} 1604 1605/** 1606 * Determine if a value is a FormData 1607 * 1608 * @param {Object} val The value to test 1609 * @returns {boolean} True if value is an FormData, otherwise false 1610 */ 1611function isFormData(val) { 1612 return (typeof FormData !== 'undefined') && (val instanceof FormData); 1613} 1614 1615/** 1616 * Determine if a value is a view on an ArrayBuffer 1617 * 1618 * @param {Object} val The value to test 1619 * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false 1620 */ 1621function isArrayBufferView(val) { 1622 var result; 1623 if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { 1624 result = ArrayBuffer.isView(val); 1625 } else { 1626 result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); 1627 } 1628 return result; 1629} 1630 1631/** 1632 * Determine if a value is a String 1633 * 1634 * @param {Object} val The value to test 1635 * @returns {boolean} True if value is a String, otherwise false 1636 */ 1637function isString(val) { 1638 return typeof val === 'string'; 1639} 1640 1641/** 1642 * Determine if a value is a Number 1643 * 1644 * @param {Object} val The value to test 1645 * @returns {boolean} True if value is a Number, otherwise false 1646 */ 1647function isNumber(val) { 1648 return typeof val === 'number'; 1649} 1650 1651/** 1652 * Determine if a value is an Object 1653 * 1654 * @param {Object} val The value to test 1655 * @returns {boolean} True if value is an Object, otherwise false 1656 */ 1657function isObject(val) { 1658 return val !== null && typeof val === 'object'; 1659} 1660 1661/** 1662 * Determine if a value is a Date 1663 * 1664 * @param {Object} val The value to test 1665 * @returns {boolean} True if value is a Date, otherwise false 1666 */ 1667function isDate(val) { 1668 return toString.call(val) === '[object Date]'; 1669} 1670 1671/** 1672 * Determine if a value is a File 1673 * 1674 * @param {Object} val The value to test 1675 * @returns {boolean} True if value is a File, otherwise false 1676 */ 1677function isFile(val) { 1678 return toString.call(val) === '[object File]'; 1679} 1680 1681/** 1682 * Determine if a value is a Blob 1683 * 1684 * @param {Object} val The value to test 1685 * @returns {boolean} True if value is a Blob, otherwise false 1686 */ 1687function isBlob(val) { 1688 return toString.call(val) === '[object Blob]'; 1689} 1690 1691/** 1692 * Determine if a value is a Function 1693 * 1694 * @param {Object} val The value to test 1695 * @returns {boolean} True if value is a Function, otherwise false 1696 */ 1697function isFunction(val) { 1698 return toString.call(val) === '[object Function]'; 1699} 1700 1701/** 1702 * Determine if a value is a Stream 1703 * 1704 * @param {Object} val The value to test 1705 * @returns {boolean} True if value is a Stream, otherwise false 1706 */ 1707function isStream(val) { 1708 return isObject(val) && isFunction(val.pipe); 1709} 1710 1711/** 1712 * Determine if a value is a URLSearchParams object 1713 * 1714 * @param {Object} val The value to test 1715 * @returns {boolean} True if value is a URLSearchParams object, otherwise false 1716 */ 1717function isURLSearchParams(val) { 1718 return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; 1719} 1720 1721/** 1722 * Trim excess whitespace off the beginning and end of a string 1723 * 1724 * @param {String} str The String to trim 1725 * @returns {String} The String freed of excess whitespace 1726 */ 1727function trim(str) { 1728 return str.replace(/^\s*/, '').replace(/\s*$/, ''); 1729} 1730 1731/** 1732 * Determine if we're running in a standard browser environment 1733 * 1734 * This allows axios to run in a web worker, and react-native. 1735 * Both environments support XMLHttpRequest, but not fully standard globals. 1736 * 1737 * web workers: 1738 * typeof window -> undefined 1739 * typeof document -> undefined 1740 * 1741 * react-native: 1742 * navigator.product -> 'ReactNative' 1743 * nativescript 1744 * navigator.product -> 'NativeScript' or 'NS' 1745 */ 1746function isStandardBrowserEnv() { 1747 if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || 1748 navigator.product === 'NativeScript' || 1749 navigator.product === 'NS')) { 1750 return false; 1751 } 1752 return ( 1753 typeof window !== 'undefined' && 1754 typeof document !== 'undefined' 1755 ); 1756} 1757 1758/** 1759 * Iterate over an Array or an Object invoking a function for each item. 1760 * 1761 * If `obj` is an Array callback will be called passing 1762 * the value, index, and complete array for each item. 1763 * 1764 * If 'obj' is an Object callback will be called passing 1765 * the value, key, and complete object for each property. 1766 * 1767 * @param {Object|Array} obj The object to iterate 1768 * @param {Function} fn The callback to invoke for each item 1769 */ 1770function forEach(obj, fn) { 1771 // Don't bother if no value provided 1772 if (obj === null || typeof obj === 'undefined') { 1773 return; 1774 } 1775 1776 // Force an array if not already something iterable 1777 if (typeof obj !== 'object') { 1778 /*eslint no-param-reassign:0*/ 1779 obj = [obj]; 1780 } 1781 1782 if (isArray(obj)) { 1783 // Iterate over array values 1784 for (var i = 0, l = obj.length; i < l; i++) { 1785 fn.call(null, obj[i], i, obj); 1786 } 1787 } else { 1788 // Iterate over object keys 1789 for (var key in obj) { 1790 if (Object.prototype.hasOwnProperty.call(obj, key)) { 1791 fn.call(null, obj[key], key, obj); 1792 } 1793 } 1794 } 1795} 1796 1797/** 1798 * Accepts varargs expecting each argument to be an object, then 1799 * immutably merges the properties of each object and returns result. 1800 * 1801 * When multiple objects contain the same key the later object in 1802 * the arguments list will take precedence. 1803 * 1804 * Example: 1805 * 1806 * ```js 1807 * var result = merge({foo: 123}, {foo: 456}); 1808 * console.log(result.foo); // outputs 456 1809 * ``` 1810 * 1811 * @param {Object} obj1 Object to merge 1812 * @returns {Object} Result of all merge properties 1813 */ 1814function merge(/* obj1, obj2, obj3, ... */) { 1815 var result = {}; 1816 function assignValue(val, key) { 1817 if (typeof result[key] === 'object' && typeof val === 'object') { 1818 result[key] = merge(result[key], val); 1819 } else { 1820 result[key] = val; 1821 } 1822 } 1823 1824 for (var i = 0, l = arguments.length; i < l; i++) { 1825 forEach(arguments[i], assignValue); 1826 } 1827 return result; 1828} 1829 1830/** 1831 * Function equal to merge with the difference being that no reference 1832 * to original objects is kept. 1833 * 1834 * @see merge 1835 * @param {Object} obj1 Object to merge 1836 * @returns {Object} Result of all merge properties 1837 */ 1838function deepMerge(/* obj1, obj2, obj3, ... */) { 1839 var result = {}; 1840 function assignValue(val, key) { 1841 if (typeof result[key] === 'object' && typeof val === 'object') { 1842 result[key] = deepMerge(result[key], val); 1843 } else if (typeof val === 'object') { 1844 result[key] = deepMerge({}, val); 1845 } else { 1846 result[key] = val; 1847 } 1848 } 1849 1850 for (var i = 0, l = arguments.length; i < l; i++) { 1851 forEach(arguments[i], assignValue); 1852 } 1853 return result; 1854} 1855 1856/** 1857 * Extends object a by mutably adding to it the properties of object b. 1858 * 1859 * @param {Object} a The object to be extended 1860 * @param {Object} b The object to copy properties from 1861 * @param {Object} thisArg The object to bind function to 1862 * @return {Object} The resulting value of object a 1863 */ 1864function extend(a, b, thisArg) { 1865 forEach(b, function assignValue(val, key) { 1866 if (thisArg && typeof val === 'function') { 1867 a[key] = bind(val, thisArg); 1868 } else { 1869 a[key] = val; 1870 } 1871 }); 1872 return a; 1873} 1874 1875module.exports = { 1876 isArray: isArray, 1877 isArrayBuffer: isArrayBuffer, 1878 isBuffer: isBuffer, 1879 isFormData: isFormData, 1880 isArrayBufferView: isArrayBufferView, 1881 isString: isString, 1882 isNumber: isNumber, 1883 isObject: isObject, 1884 isUndefined: isUndefined, 1885 isDate: isDate, 1886 isFile: isFile, 1887 isBlob: isBlob, 1888 isFunction: isFunction, 1889 isStream: isStream, 1890 isURLSearchParams: isURLSearchParams, 1891 isStandardBrowserEnv: isStandardBrowserEnv, 1892 forEach: forEach, 1893 merge: merge, 1894 deepMerge: deepMerge, 1895 extend: extend, 1896 trim: trim 1897}; 1898 1899 1900/***/ }), 1901
vendor: 144,201 bytes, lines 1902-6343
1902/***/ "./node_modules/bootstrap/dist/js/bootstrap.js": 1903/*!*****************************************************!*\ 1904 !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***! 1905 \*****************************************************/ 1906/*! no static exports found */ 1907/***/ (function(module, exports, __webpack_require__) { 1908 1909/*! 1910 * Bootstrap v4.6.0 (https://getbootstrap.com/) 1911 * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) 1912 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 1913 */ 1914(function (global, factory) { 1915 true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) : 1916 undefined; 1917}(this, (function (exports, $, Popper) { 'use strict'; 1918 1919 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } 1920 1921 var $__default = /*#__PURE__*/_interopDefaultLegacy($); 1922 var Popper__default = /*#__PURE__*/_interopDefaultLegacy(Popper); 1923 1924 function _defineProperties(target, props) { 1925 for (var i = 0; i < props.length; i++) { 1926 var descriptor = props[i]; 1927 descriptor.enumerable = descriptor.enumerable || false; 1928 descriptor.configurable = true; 1929 if ("value" in descriptor) descriptor.writable = true; 1930 Object.defineProperty(target, descriptor.key, descriptor); 1931 } 1932 } 1933 1934 function _createClass(Constructor, protoProps, staticProps) { 1935 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 1936 if (staticProps) _defineProperties(Constructor, staticProps); 1937 return Constructor; 1938 } 1939 1940 function _extends() { 1941 _extends = Object.assign || function (target) { 1942 for (var i = 1; i < arguments.length; i++) { 1943 var source = arguments[i]; 1944 1945 for (var key in source) { 1946 if (Object.prototype.hasOwnProperty.call(source, key)) { 1947 target[key] = source[key]; 1948 } 1949 } 1950 } 1951 1952 return target; 1953 }; 1954 1955 return _extends.apply(this, arguments); 1956 } 1957 1958 function _inheritsLoose(subClass, superClass) { 1959 subClass.prototype = Object.create(superClass.prototype); 1960 subClass.prototype.constructor = subClass; 1961 subClass.__proto__ = superClass; 1962 } 1963 1964 /** 1965 * -------------------------------------------------------------------------- 1966 * Bootstrap (v4.6.0): util.js 1967 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 1968 * -------------------------------------------------------------------------- 1969 */ 1970 /** 1971 * ------------------------------------------------------------------------ 1972 * Private TransitionEnd Helpers 1973 * ------------------------------------------------------------------------ 1974 */ 1975 1976 var TRANSITION_END = 'transitionend'; 1977 var MAX_UID = 1000000; 1978 var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp) 1979 1980 function toType(obj) { 1981 if (obj === null || typeof obj === 'undefined') { 1982 return "" + obj; 1983 } 1984 1985 return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); 1986 } 1987 1988 function getSpecialTransitionEndEvent() { 1989 return { 1990 bindType: TRANSITION_END, 1991 delegateType: TRANSITION_END, 1992 handle: function handle(event) { 1993 if ($__default['default'](event.target).is(this)) { 1994 return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params 1995 } 1996 1997 return undefined; 1998 } 1999 }; 2000 } 2001 2002 function transitionEndEmulator(duration) { 2003 var _this = this; 2004 2005 var called = false; 2006 $__default['default'](this).one(Util.TRANSITION_END, function () { 2007 called = true; 2008 }); 2009 setTimeout(function () { 2010 if (!called) { 2011 Util.triggerTransitionEnd(_this); 2012 } 2013 }, duration); 2014 return this; 2015 } 2016 2017 function setTransitionEndSupport() { 2018 $__default['default'].fn.emulateTransitionEnd = transitionEndEmulator; 2019 $__default['default'].event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent(); 2020 } 2021 /** 2022 * -------------------------------------------------------------------------- 2023 * Public Util Api 2024 * -------------------------------------------------------------------------- 2025 */ 2026 2027 2028 var Util = { 2029 TRANSITION_END: 'bsTransitionEnd', 2030 getUID: function getUID(prefix) { 2031 do { 2032 prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here 2033 } while (document.getElementById(prefix)); 2034 2035 return prefix; 2036 }, 2037 getSelectorFromElement: function getSelectorFromElement(element) { 2038 var selector = element.getAttribute('data-target'); 2039 2040 if (!selector || selector === '#') { 2041 var hrefAttr = element.getAttribute('href'); 2042 selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : ''; 2043 } 2044 2045 try { 2046 return document.querySelector(selector) ? selector : null; 2047 } catch (_) { 2048 return null; 2049 } 2050 }, 2051 getTransitionDurationFromElement: function getTransitionDurationFromElement(element) { 2052 if (!element) { 2053 return 0; 2054 } // Get transition-duration of the element 2055 2056 2057 var transitionDuration = $__default['default'](element).css('transition-duration'); 2058 var transitionDelay = $__default['default'](element).css('transition-delay'); 2059 var floatTransitionDuration = parseFloat(transitionDuration); 2060 var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found 2061 2062 if (!floatTransitionDuration && !floatTransitionDelay) { 2063 return 0; 2064 } // If multiple durations are defined, take the first 2065 2066 2067 transitionDuration = transitionDuration.split(',')[0]; 2068 transitionDelay = transitionDelay.split(',')[0]; 2069 return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; 2070 }, 2071 reflow: function reflow(element) { 2072 return element.offsetHeight; 2073 }, 2074 triggerTransitionEnd: function triggerTransitionEnd(element) { 2075 $__default['default'](element).trigger(TRANSITION_END); 2076 }, 2077 supportsTransitionEnd: function supportsTransitionEnd() { 2078 return Boolean(TRANSITION_END); 2079 }, 2080 isElement: function isElement(obj) { 2081 return (obj[0] || obj).nodeType; 2082 }, 2083 typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) { 2084 for (var property in configTypes) { 2085 if (Object.prototype.hasOwnProperty.call(configTypes, property)) { 2086 var expectedTypes = configTypes[property]; 2087 var value = config[property]; 2088 var valueType = value && Util.isElement(value) ? 'element' : toType(value); 2089 2090 if (!new RegExp(expectedTypes).test(valueType)) { 2091 throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\".")); 2092 } 2093 } 2094 } 2095 }, 2096 findShadowRoot: function findShadowRoot(element) { 2097 if (!document.documentElement.attachShadow) { 2098 return null; 2099 } // Can find the shadow root otherwise it'll return the document 2100 2101 2102 if (typeof element.getRootNode === 'function') { 2103 var root = element.getRootNode(); 2104 return root instanceof ShadowRoot ? root : null; 2105 } 2106 2107 if (element instanceof ShadowRoot) { 2108 return element; 2109 } // when we don't find a shadow root 2110 2111 2112 if (!element.parentNode) { 2113 return null; 2114 } 2115 2116 return Util.findShadowRoot(element.parentNode); 2117 }, 2118 jQueryDetection: function jQueryDetection() { 2119 if (typeof $__default['default'] === 'undefined') { 2120 throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.'); 2121 } 2122 2123 var version = $__default['default'].fn.jquery.split(' ')[0].split('.'); 2124 var minMajor = 1; 2125 var ltMajor = 2; 2126 var minMinor = 9; 2127 var minPatch = 1; 2128 var maxMajor = 4; 2129 2130 if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) { 2131 throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0'); 2132 } 2133 } 2134 }; 2135 Util.jQueryDetection(); 2136 setTransitionEndSupport(); 2137 2138 /** 2139 * ------------------------------------------------------------------------ 2140 * Constants 2141 * ------------------------------------------------------------------------ 2142 */ 2143 2144 var NAME = 'alert'; 2145 var VERSION = '4.6.0'; 2146 var DATA_KEY = 'bs.alert'; 2147 var EVENT_KEY = "." + DATA_KEY; 2148 var DATA_API_KEY = '.data-api'; 2149 var JQUERY_NO_CONFLICT = $__default['default'].fn[NAME]; 2150 var SELECTOR_DISMISS = '[data-dismiss="alert"]'; 2151 var EVENT_CLOSE = "close" + EVENT_KEY; 2152 var EVENT_CLOSED = "closed" + EVENT_KEY; 2153 var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY; 2154 var CLASS_NAME_ALERT = 'alert'; 2155 var CLASS_NAME_FADE = 'fade'; 2156 var CLASS_NAME_SHOW = 'show'; 2157 /** 2158 * ------------------------------------------------------------------------ 2159 * Class Definition 2160 * ------------------------------------------------------------------------ 2161 */ 2162 2163 var Alert = /*#__PURE__*/function () { 2164 function Alert(element) { 2165 this._element = element; 2166 } // Getters 2167 2168 2169 var _proto = Alert.prototype; 2170 2171 // Public 2172 _proto.close = function close(element) { 2173 var rootElement = this._element; 2174 2175 if (element) { 2176 rootElement = this._getRootElement(element); 2177 } 2178 2179 var customEvent = this._triggerCloseEvent(rootElement); 2180 2181 if (customEvent.isDefaultPrevented()) { 2182 return; 2183 } 2184 2185 this._removeElement(rootElement); 2186 }; 2187 2188 _proto.dispose = function dispose() { 2189 $__default['default'].removeData(this._element, DATA_KEY); 2190 this._element = null; 2191 } // Private 2192 ; 2193 2194 _proto._getRootElement = function _getRootElement(element) { 2195 var selector = Util.getSelectorFromElement(element); 2196 var parent = false; 2197 2198 if (selector) { 2199 parent = document.querySelector(selector); 2200 } 2201 2202 if (!parent) { 2203 parent = $__default['default'](element).closest("." + CLASS_NAME_ALERT)[0]; 2204 } 2205 2206 return parent; 2207 }; 2208 2209 _proto._triggerCloseEvent = function _triggerCloseEvent(element) { 2210 var closeEvent = $__default['default'].Event(EVENT_CLOSE); 2211 $__default['default'](element).trigger(closeEvent); 2212 return closeEvent; 2213 }; 2214 2215 _proto._removeElement = function _removeElement(element) { 2216 var _this = this; 2217 2218 $__default['default'](element).removeClass(CLASS_NAME_SHOW); 2219 2220 if (!$__default['default'](element).hasClass(CLASS_NAME_FADE)) { 2221 this._destroyElement(element); 2222 2223 return; 2224 } 2225 2226 var transitionDuration = Util.getTransitionDurationFromElement(element); 2227 $__default['default'](element).one(Util.TRANSITION_END, function (event) { 2228 return _this._destroyElement(element, event); 2229 }).emulateTransitionEnd(transitionDuration); 2230 }; 2231 2232 _proto._destroyElement = function _destroyElement(element) { 2233 $__default['default'](element).detach().trigger(EVENT_CLOSED).remove(); 2234 } // Static 2235 ; 2236 2237 Alert._jQueryInterface = function _jQueryInterface(config) { 2238 return this.each(function () { 2239 var $element = $__default['default'](this); 2240 var data = $element.data(DATA_KEY); 2241 2242 if (!data) { 2243 data = new Alert(this); 2244 $element.data(DATA_KEY, data); 2245 } 2246 2247 if (config === 'close') { 2248 data[config](this); 2249 } 2250 }); 2251 }; 2252 2253 Alert._handleDismiss = function _handleDismiss(alertInstance) { 2254 return function (event) { 2255 if (event) { 2256 event.preventDefault(); 2257 } 2258 2259 alertInstance.close(this); 2260 }; 2261 }; 2262 2263 _createClass(Alert, null, [{ 2264 key: "VERSION", 2265 get: function get() { 2266 return VERSION; 2267 } 2268 }]); 2269 2270 return Alert; 2271 }(); 2272 /** 2273 * ------------------------------------------------------------------------ 2274 * Data Api implementation 2275 * ------------------------------------------------------------------------ 2276 */ 2277 2278 2279 $__default['default'](document).on(EVENT_CLICK_DATA_API, SELECTOR_DISMISS, Alert._handleDismiss(new Alert())); 2280 /** 2281 * ------------------------------------------------------------------------ 2282 * jQuery 2283 * ------------------------------------------------------------------------ 2284 */ 2285 2286 $__default['default'].fn[NAME] = Alert._jQueryInterface; 2287 $__default['default'].fn[NAME].Constructor = Alert; 2288 2289 $__default['default'].fn[NAME].noConflict = function () { 2290 $__default['default'].fn[NAME] = JQUERY_NO_CONFLICT; 2291 return Alert._jQueryInterface; 2292 }; 2293 2294 /** 2295 * ------------------------------------------------------------------------ 2296 * Constants 2297 * ------------------------------------------------------------------------ 2298 */ 2299 2300 var NAME$1 = 'button'; 2301 var VERSION$1 = '4.6.0'; 2302 var DATA_KEY$1 = 'bs.button'; 2303 var EVENT_KEY$1 = "." + DATA_KEY$1; 2304 var DATA_API_KEY$1 = '.data-api'; 2305 var JQUERY_NO_CONFLICT$1 = $__default['default'].fn[NAME$1]; 2306 var CLASS_NAME_ACTIVE = 'active'; 2307 var CLASS_NAME_BUTTON = 'btn'; 2308 var CLASS_NAME_FOCUS = 'focus'; 2309 var SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^="button"]'; 2310 var SELECTOR_DATA_TOGGLES = '[data-toggle="buttons"]'; 2311 var SELECTOR_DATA_TOGGLE = '[data-toggle="button"]'; 2312 var SELECTOR_DATA_TOGGLES_BUTTONS = '[data-toggle="buttons"] .btn'; 2313 var SELECTOR_INPUT = 'input:not([type="hidden"])'; 2314 var SELECTOR_ACTIVE = '.active'; 2315 var SELECTOR_BUTTON = '.btn'; 2316 var EVENT_CLICK_DATA_API$1 = "click" + EVENT_KEY$1 + DATA_API_KEY$1; 2317 var EVENT_FOCUS_BLUR_DATA_API = "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1); 2318 var EVENT_LOAD_DATA_API = "load" + EVENT_KEY$1 + DATA_API_KEY$1; 2319 /** 2320 * ------------------------------------------------------------------------ 2321 * Class Definition 2322 * ------------------------------------------------------------------------ 2323 */ 2324 2325 var Button = /*#__PURE__*/function () { 2326 function Button(element) { 2327 this._element = element; 2328 this.shouldAvoidTriggerChange = false; 2329 } // Getters 2330 2331 2332 var _proto = Button.prototype; 2333 2334 // Public 2335 _proto.toggle = function toggle() { 2336 var triggerChangeEvent = true; 2337 var addAriaPressed = true; 2338 var rootElement = $__default['default'](this._element).closest(SELECTOR_DATA_TOGGLES)[0]; 2339 2340 if (rootElement) { 2341 var input = this._element.querySelector(SELECTOR_INPUT); 2342 2343 if (input) { 2344 if (input.type === 'radio') { 2345 if (input.checked && this._element.classList.contains(CLASS_NAME_ACTIVE)) { 2346 triggerChangeEvent = false; 2347 } else { 2348 var activeElement = rootElement.querySelector(SELECTOR_ACTIVE); 2349 2350 if (activeElement) { 2351 $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE); 2352 } 2353 } 2354 } 2355 2356 if (triggerChangeEvent) { 2357 // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input 2358 if (input.type === 'checkbox' || input.type === 'radio') { 2359 input.checked = !this._element.classList.contains(CLASS_NAME_ACTIVE); 2360 } 2361 2362 if (!this.shouldAvoidTriggerChange) { 2363 $__default['default'](input).trigger('change'); 2364 } 2365 } 2366 2367 input.focus(); 2368 addAriaPressed = false; 2369 } 2370 } 2371 2372 if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) { 2373 if (addAriaPressed) { 2374 this._element.setAttribute('aria-pressed', !this._element.classList.contains(CLASS_NAME_ACTIVE)); 2375 } 2376 2377 if (triggerChangeEvent) { 2378 $__default['default'](this._element).toggleClass(CLASS_NAME_ACTIVE); 2379 } 2380 } 2381 }; 2382 2383 _proto.dispose = function dispose() { 2384 $__default['default'].removeData(this._element, DATA_KEY$1); 2385 this._element = null; 2386 } // Static 2387 ; 2388 2389 Button._jQueryInterface = function _jQueryInterface(config, avoidTriggerChange) { 2390 return this.each(function () { 2391 var $element = $__default['default'](this); 2392 var data = $element.data(DATA_KEY$1); 2393 2394 if (!data) { 2395 data = new Button(this); 2396 $element.data(DATA_KEY$1, data); 2397 } 2398 2399 data.shouldAvoidTriggerChange = avoidTriggerChange; 2400 2401 if (config === 'toggle') { 2402 data[config](); 2403 } 2404 }); 2405 }; 2406 2407 _createClass(Button, null, [{ 2408 key: "VERSION", 2409 get: function get() { 2410 return VERSION$1; 2411 } 2412 }]); 2413 2414 return Button; 2415 }(); 2416 /** 2417 * ------------------------------------------------------------------------ 2418 * Data Api implementation 2419 * ------------------------------------------------------------------------ 2420 */ 2421 2422 2423 $__default['default'](document).on(EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE_CARROT, function (event) { 2424 var button = event.target; 2425 var initialButton = button; 2426 2427 if (!$__default['default'](button).hasClass(CLASS_NAME_BUTTON)) { 2428 button = $__default['default'](button).closest(SELECTOR_BUTTON)[0]; 2429 } 2430 2431 if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) { 2432 event.preventDefault(); // work around Firefox bug #1540995 2433 } else { 2434 var inputBtn = button.querySelector(SELECTOR_INPUT); 2435 2436 if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) { 2437 event.preventDefault(); // work around Firefox bug #1540995 2438 2439 return; 2440 } 2441 2442 if (initialButton.tagName === 'INPUT' || button.tagName !== 'LABEL') { 2443 Button._jQueryInterface.call($__default['default'](button), 'toggle', initialButton.tagName === 'INPUT'); 2444 } 2445 } 2446 }).on(EVENT_FOCUS_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, function (event) { 2447 var button = $__default['default'](event.target).closest(SELECTOR_BUTTON)[0]; 2448 $__default['default'](button).toggleClass(CLASS_NAME_FOCUS, /^focus(in)?$/.test(event.type)); 2449 }); 2450 $__default['default'](window).on(EVENT_LOAD_DATA_API, function () { 2451 // ensure correct active class is set to match the controls' actual values/states 2452 // find all checkboxes/readio buttons inside data-toggle groups 2453 var buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLES_BUTTONS)); 2454 2455 for (var i = 0, len = buttons.length; i < len; i++) { 2456 var button = buttons[i]; 2457 var input = button.querySelector(SELECTOR_INPUT); 2458 2459 if (input.checked || input.hasAttribute('checked')) { 2460 button.classList.add(CLASS_NAME_ACTIVE); 2461 } else { 2462 button.classList.remove(CLASS_NAME_ACTIVE); 2463 } 2464 } // find all button toggles 2465 2466 2467 buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE)); 2468 2469 for (var _i = 0, _len = buttons.length; _i < _len; _i++) { 2470 var _button = buttons[_i]; 2471 2472 if (_button.getAttribute('aria-pressed') === 'true') { 2473 _button.classList.add(CLASS_NAME_ACTIVE); 2474 } else { 2475 _button.classList.remove(CLASS_NAME_ACTIVE); 2476 } 2477 } 2478 }); 2479 /** 2480 * ------------------------------------------------------------------------ 2481 * jQuery 2482 * ------------------------------------------------------------------------ 2483 */ 2484 2485 $__default['default'].fn[NAME$1] = Button._jQueryInterface; 2486 $__default['default'].fn[NAME$1].Constructor = Button; 2487 2488 $__default['default'].fn[NAME$1].noConflict = function () { 2489 $__default['default'].fn[NAME$1] = JQUERY_NO_CONFLICT$1; 2490 return Button._jQueryInterface; 2491 }; 2492 2493 /** 2494 * ------------------------------------------------------------------------ 2495 * Constants 2496 * ------------------------------------------------------------------------ 2497 */ 2498 2499 var NAME$2 = 'carousel'; 2500 var VERSION$2 = '4.6.0'; 2501 var DATA_KEY$2 = 'bs.carousel'; 2502 var EVENT_KEY$2 = "." + DATA_KEY$2; 2503 var DATA_API_KEY$2 = '.data-api'; 2504 var JQUERY_NO_CONFLICT$2 = $__default['default'].fn[NAME$2]; 2505 var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key 2506 2507 var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key 2508 2509 var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch 2510 2511 var SWIPE_THRESHOLD = 40; 2512 var Default = { 2513 interval: 5000, 2514 keyboard: true, 2515 slide: false, 2516 pause: 'hover', 2517 wrap: true, 2518 touch: true 2519 }; 2520 var DefaultType = { 2521 interval: '(number|boolean)', 2522 keyboard: 'boolean', 2523 slide: '(boolean|string)', 2524 pause: '(string|boolean)', 2525 wrap: 'boolean', 2526 touch: 'boolean' 2527 }; 2528 var DIRECTION_NEXT = 'next'; 2529 var DIRECTION_PREV = 'prev'; 2530 var DIRECTION_LEFT = 'left'; 2531 var DIRECTION_RIGHT = 'right'; 2532 var EVENT_SLIDE = "slide" + EVENT_KEY$2; 2533 var EVENT_SLID = "slid" + EVENT_KEY$2; 2534 var EVENT_KEYDOWN = "keydown" + EVENT_KEY$2; 2535 var EVENT_MOUSEENTER = "mouseenter" + EVENT_KEY$2; 2536 var EVENT_MOUSELEAVE = "mouseleave" + EVENT_KEY$2; 2537 var EVENT_TOUCHSTART = "touchstart" + EVENT_KEY$2; 2538 var EVENT_TOUCHMOVE = "touchmove" + EVENT_KEY$2; 2539 var EVENT_TOUCHEND = "touchend" + EVENT_KEY$2; 2540 var EVENT_POINTERDOWN = "pointerdown" + EVENT_KEY$2; 2541 var EVENT_POINTERUP = "pointerup" + EVENT_KEY$2; 2542 var EVENT_DRAG_START = "dragstart" + EVENT_KEY$2; 2543 var EVENT_LOAD_DATA_API$1 = "load" + EVENT_KEY$2 + DATA_API_KEY$2; 2544 var EVENT_CLICK_DATA_API$2 = "click" + EVENT_KEY$2 + DATA_API_KEY$2; 2545 var CLASS_NAME_CAROUSEL = 'carousel'; 2546 var CLASS_NAME_ACTIVE$1 = 'active'; 2547 var CLASS_NAME_SLIDE = 'slide'; 2548 var CLASS_NAME_RIGHT = 'carousel-item-right'; 2549 var CLASS_NAME_LEFT = 'carousel-item-left'; 2550 var CLASS_NAME_NEXT = 'carousel-item-next'; 2551 var CLASS_NAME_PREV = 'carousel-item-prev'; 2552 var CLASS_NAME_POINTER_EVENT = 'pointer-event'; 2553 var SELECTOR_ACTIVE$1 = '.active'; 2554 var SELECTOR_ACTIVE_ITEM = '.active.carousel-item'; 2555 var SELECTOR_ITEM = '.carousel-item'; 2556 var SELECTOR_ITEM_IMG = '.carousel-item img'; 2557 var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev'; 2558 var SELECTOR_INDICATORS = '.carousel-indicators'; 2559 var SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]'; 2560 var SELECTOR_DATA_RIDE = '[data-ride="carousel"]'; 2561 var PointerType = { 2562 TOUCH: 'touch', 2563 PEN: 'pen' 2564 }; 2565 /** 2566 * ------------------------------------------------------------------------ 2567 * Class Definition 2568 * ------------------------------------------------------------------------ 2569 */ 2570 2571 var Carousel = /*#__PURE__*/function () { 2572 function Carousel(element, config) { 2573 this._items = null; 2574 this._interval = null; 2575 this._activeElement = null; 2576 this._isPaused = false; 2577 this._isSliding = false; 2578 this.touchTimeout = null; 2579 this.touchStartX = 0; 2580 this.touchDeltaX = 0; 2581 this._config = this._getConfig(config); 2582 this._element = element; 2583 this._indicatorsElement = this._element.querySelector(SELECTOR_INDICATORS); 2584 this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; 2585 this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent); 2586 2587 this._addEventListeners(); 2588 } // Getters 2589 2590 2591 var _proto = Carousel.prototype; 2592 2593 // Public 2594 _proto.next = function next() { 2595 if (!this._isSliding) { 2596 this._slide(DIRECTION_NEXT); 2597 } 2598 }; 2599 2600 _proto.nextWhenVisible = function nextWhenVisible() { 2601 var $element = $__default['default'](this._element); // Don't call next when the page isn't visible 2602 // or the carousel or its parent isn't visible 2603 2604 if (!document.hidden && $element.is(':visible') && $element.css('visibility') !== 'hidden') { 2605 this.next(); 2606 } 2607 }; 2608 2609 _proto.prev = function prev() { 2610 if (!this._isSliding) { 2611 this._slide(DIRECTION_PREV); 2612 } 2613 }; 2614 2615 _proto.pause = function pause(event) { 2616 if (!event) { 2617 this._isPaused = true; 2618 } 2619 2620 if (this._element.querySelector(SELECTOR_NEXT_PREV)) { 2621 Util.triggerTransitionEnd(this._element); 2622 this.cycle(true); 2623 } 2624 2625 clearInterval(this._interval); 2626 this._interval = null; 2627 }; 2628 2629 _proto.cycle = function cycle(event) { 2630 if (!event) { 2631 this._isPaused = false; 2632 } 2633 2634 if (this._interval) { 2635 clearInterval(this._interval); 2636 this._interval = null; 2637 } 2638 2639 if (this._config.interval && !this._isPaused) { 2640 this._updateInterval(); 2641 2642 this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); 2643 } 2644 }; 2645 2646 _proto.to = function to(index) { 2647 var _this = this; 2648 2649 this._activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM); 2650 2651 var activeIndex = this._getItemIndex(this._activeElement); 2652 2653 if (index > this._items.length - 1 || index < 0) { 2654 return; 2655 } 2656 2657 if (this._isSliding) { 2658 $__default['default'](this._element).one(EVENT_SLID, function () { 2659 return _this.to(index); 2660 }); 2661 return; 2662 } 2663 2664 if (activeIndex === index) { 2665 this.pause(); 2666 this.cycle(); 2667 return; 2668 } 2669 2670 var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV; 2671 2672 this._slide(direction, this._items[index]); 2673 }; 2674 2675 _proto.dispose = function dispose() { 2676 $__default['default'](this._element).off(EVENT_KEY$2); 2677 $__default['default'].removeData(this._element, DATA_KEY$2); 2678 this._items = null; 2679 this._config = null; 2680 this._element = null; 2681 this._interval = null; 2682 this._isPaused = null; 2683 this._isSliding = null; 2684 this._activeElement = null; 2685 this._indicatorsElement = null; 2686 } // Private 2687 ; 2688 2689 _proto._getConfig = function _getConfig(config) { 2690 config = _extends({}, Default, config); 2691 Util.typeCheckConfig(NAME$2, config, DefaultType); 2692 return config; 2693 }; 2694 2695 _proto._handleSwipe = function _handleSwipe() { 2696 var absDeltax = Math.abs(this.touchDeltaX); 2697 2698 if (absDeltax <= SWIPE_THRESHOLD) { 2699 return; 2700 } 2701 2702 var direction = absDeltax / this.touchDeltaX; 2703 this.touchDeltaX = 0; // swipe left 2704 2705 if (direction > 0) { 2706 this.prev(); 2707 } // swipe right 2708 2709 2710 if (direction < 0) { 2711 this.next(); 2712 } 2713 }; 2714 2715 _proto._addEventListeners = function _addEventListeners() { 2716 var _this2 = this; 2717 2718 if (this._config.keyboard) { 2719 $__default['default'](this._element).on(EVENT_KEYDOWN, function (event) { 2720 return _this2._keydown(event); 2721 }); 2722 } 2723 2724 if (this._config.pause === 'hover') { 2725 $__default['default'](this._element).on(EVENT_MOUSEENTER, function (event) { 2726 return _this2.pause(event); 2727 }).on(EVENT_MOUSELEAVE, function (event) { 2728 return _this2.cycle(event); 2729 }); 2730 } 2731 2732 if (this._config.touch) { 2733 this._addTouchEventListeners(); 2734 } 2735 }; 2736 2737 _proto._addTouchEventListeners = function _addTouchEventListeners() { 2738 var _this3 = this; 2739 2740 if (!this._touchSupported) { 2741 return; 2742 } 2743 2744 var start = function start(event) { 2745 if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) { 2746 _this3.touchStartX = event.originalEvent.clientX; 2747 } else if (!_this3._pointerEvent) { 2748 _this3.touchStartX = event.originalEvent.touches[0].clientX; 2749 } 2750 }; 2751 2752 var move = function move(event) { 2753 // ensure swiping with one touch and not pinching 2754 if (event.originalEvent.touches && event.originalEvent.touches.length > 1) { 2755 _this3.touchDeltaX = 0; 2756 } else { 2757 _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX; 2758 } 2759 }; 2760 2761 var end = function end(event) { 2762 if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) { 2763 _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX; 2764 } 2765 2766 _this3._handleSwipe(); 2767 2768 if (_this3._config.pause === 'hover') { 2769 // If it's a touch-enabled device, mouseenter/leave are fired as 2770 // part of the mouse compatibility events on first tap - the carousel 2771 // would stop cycling until user tapped out of it; 2772 // here, we listen for touchend, explicitly pause the carousel 2773 // (as if it's the second time we tap on it, mouseenter compat event 2774 // is NOT fired) and after a timeout (to allow for mouse compatibility 2775 // events to fire) we explicitly restart cycling 2776 _this3.pause(); 2777 2778 if (_this3.touchTimeout) { 2779 clearTimeout(_this3.touchTimeout); 2780 } 2781 2782 _this3.touchTimeout = setTimeout(function (event) { 2783 return _this3.cycle(event); 2784 }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval); 2785 } 2786 }; 2787 2788 $__default['default'](this._element.querySelectorAll(SELECTOR_ITEM_IMG)).on(EVENT_DRAG_START, function (e) { 2789 return e.preventDefault(); 2790 }); 2791 2792 if (this._pointerEvent) { 2793 $__default['default'](this._element).on(EVENT_POINTERDOWN, function (event) { 2794 return start(event); 2795 }); 2796 $__default['default'](this._element).on(EVENT_POINTERUP, function (event) { 2797 return end(event); 2798 }); 2799 2800 this._element.classList.add(CLASS_NAME_POINTER_EVENT); 2801 } else { 2802 $__default['default'](this._element).on(EVENT_TOUCHSTART, function (event) { 2803 return start(event); 2804 }); 2805 $__default['default'](this._element).on(EVENT_TOUCHMOVE, function (event) { 2806 return move(event); 2807 }); 2808 $__default['default'](this._element).on(EVENT_TOUCHEND, function (event) { 2809 return end(event); 2810 }); 2811 } 2812 }; 2813 2814 _proto._keydown = function _keydown(event) { 2815 if (/input|textarea/i.test(event.target.tagName)) { 2816 return; 2817 } 2818 2819 switch (event.which) { 2820 case ARROW_LEFT_KEYCODE: 2821 event.preventDefault(); 2822 this.prev(); 2823 break; 2824 2825 case ARROW_RIGHT_KEYCODE: 2826 event.preventDefault(); 2827 this.next(); 2828 break; 2829 } 2830 }; 2831 2832 _proto._getItemIndex = function _getItemIndex(element) { 2833 this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(SELECTOR_ITEM)) : []; 2834 return this._items.indexOf(element); 2835 }; 2836 2837 _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) { 2838 var isNextDirection = direction === DIRECTION_NEXT; 2839 var isPrevDirection = direction === DIRECTION_PREV; 2840 2841 var activeIndex = this._getItemIndex(activeElement); 2842 2843 var lastItemIndex = this._items.length - 1; 2844 var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex; 2845 2846 if (isGoingToWrap && !this._config.wrap) { 2847 return activeElement; 2848 } 2849 2850 var delta = direction === DIRECTION_PREV ? -1 : 1; 2851 var itemIndex = (activeIndex + delta) % this._items.length; 2852 return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex]; 2853 }; 2854 2855 _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) { 2856 var targetIndex = this._getItemIndex(relatedTarget); 2857 2858 var fromIndex = this._getItemIndex(this._element.querySelector(SELECTOR_ACTIVE_ITEM)); 2859 2860 var slideEvent = $__default['default'].Event(EVENT_SLIDE, { 2861 relatedTarget: relatedTarget, 2862 direction: eventDirectionName, 2863 from: fromIndex, 2864 to: targetIndex 2865 }); 2866 $__default['default'](this._element).trigger(slideEvent); 2867 return slideEvent; 2868 }; 2869 2870 _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) { 2871 if (this._indicatorsElement) { 2872 var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(SELECTOR_ACTIVE$1)); 2873 $__default['default'](indicators).removeClass(CLASS_NAME_ACTIVE$1); 2874 2875 var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)]; 2876 2877 if (nextIndicator) { 2878 $__default['default'](nextIndicator).addClass(CLASS_NAME_ACTIVE$1); 2879 } 2880 } 2881 }; 2882 2883 _proto._updateInterval = function _updateInterval() { 2884 var element = this._activeElement || this._element.querySelector(SELECTOR_ACTIVE_ITEM); 2885 2886 if (!element) { 2887 return; 2888 } 2889 2890 var elementInterval = parseInt(element.getAttribute('data-interval'), 10); 2891 2892 if (elementInterval) { 2893 this._config.defaultInterval = this._config.defaultInterval || this._config.interval; 2894 this._config.interval = elementInterval; 2895 } else { 2896 this._config.interval = this._config.defaultInterval || this._config.interval; 2897 } 2898 }; 2899 2900 _proto._slide = function _slide(direction, element) { 2901 var _this4 = this; 2902 2903 var activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM); 2904 2905 var activeElementIndex = this._getItemIndex(activeElement); 2906 2907 var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement); 2908 2909 var nextElementIndex = this._getItemIndex(nextElement); 2910 2911 var isCycling = Boolean(this._interval); 2912 var directionalClassName; 2913 var orderClassName; 2914 var eventDirectionName; 2915 2916 if (direction === DIRECTION_NEXT) { 2917 directionalClassName = CLASS_NAME_LEFT; 2918 orderClassName = CLASS_NAME_NEXT; 2919 eventDirectionName = DIRECTION_LEFT; 2920 } else { 2921 directionalClassName = CLASS_NAME_RIGHT; 2922 orderClassName = CLASS_NAME_PREV; 2923 eventDirectionName = DIRECTION_RIGHT; 2924 } 2925 2926 if (nextElement && $__default['default'](nextElement).hasClass(CLASS_NAME_ACTIVE$1)) { 2927 this._isSliding = false; 2928 return; 2929 } 2930 2931 var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName); 2932 2933 if (slideEvent.isDefaultPrevented()) { 2934 return; 2935 } 2936 2937 if (!activeElement || !nextElement) { 2938 // Some weirdness is happening, so we bail 2939 return; 2940 } 2941 2942 this._isSliding = true; 2943 2944 if (isCycling) { 2945 this.pause(); 2946 } 2947 2948 this._setActiveIndicatorElement(nextElement); 2949 2950 this._activeElement = nextElement; 2951 var slidEvent = $__default['default'].Event(EVENT_SLID, { 2952 relatedTarget: nextElement, 2953 direction: eventDirectionName, 2954 from: activeElementIndex, 2955 to: nextElementIndex 2956 }); 2957 2958 if ($__default['default'](this._element).hasClass(CLASS_NAME_SLIDE)) { 2959 $__default['default'](nextElement).addClass(orderClassName); 2960 Util.reflow(nextElement); 2961 $__default['default'](activeElement).addClass(directionalClassName); 2962 $__default['default'](nextElement).addClass(directionalClassName); 2963 var transitionDuration = Util.getTransitionDurationFromElement(activeElement); 2964 $__default['default'](activeElement).one(Util.TRANSITION_END, function () { 2965 $__default['default'](nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(CLASS_NAME_ACTIVE$1); 2966 $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE$1 + " " + orderClassName + " " + directionalClassName); 2967 _this4._isSliding = false; 2968 setTimeout(function () { 2969 return $__default['default'](_this4._element).trigger(slidEvent); 2970 }, 0); 2971 }).emulateTransitionEnd(transitionDuration); 2972 } else { 2973 $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE$1); 2974 $__default['default'](nextElement).addClass(CLASS_NAME_ACTIVE$1); 2975 this._isSliding = false; 2976 $__default['default'](this._element).trigger(slidEvent); 2977 } 2978 2979 if (isCycling) { 2980 this.cycle(); 2981 } 2982 } // Static 2983 ; 2984 2985 Carousel._jQueryInterface = function _jQueryInterface(config) { 2986 return this.each(function () { 2987 var data = $__default['default'](this).data(DATA_KEY$2); 2988 2989 var _config = _extends({}, Default, $__default['default'](this).data()); 2990 2991 if (typeof config === 'object') { 2992 _config = _extends({}, _config, config); 2993 } 2994 2995 var action = typeof config === 'string' ? config : _config.slide; 2996 2997 if (!data) { 2998 data = new Carousel(this, _config); 2999 $__default['default'](this).data(DATA_KEY$2, data); 3000 } 3001 3002 if (typeof config === 'number') { 3003 data.to(config); 3004 } else if (typeof action === 'string') { 3005 if (typeof data[action] === 'undefined') { 3006 throw new TypeError("No method named \"" + action + "\""); 3007 } 3008 3009 data[action](); 3010 } else if (_config.interval && _config.ride) { 3011 data.pause(); 3012 data.cycle(); 3013 } 3014 }); 3015 }; 3016 3017 Carousel._dataApiClickHandler = function _dataApiClickHandler(event) { 3018 var selector = Util.getSelectorFromElement(this); 3019 3020 if (!selector) { 3021 return; 3022 } 3023 3024 var target = $__default['default'](selector)[0]; 3025 3026 if (!target || !$__default['default'](target).hasClass(CLASS_NAME_CAROUSEL)) { 3027 return; 3028 } 3029 3030 var config = _extends({}, $__default['default'](target).data(), $__default['default'](this).data()); 3031 3032 var slideIndex = this.getAttribute('data-slide-to'); 3033 3034 if (slideIndex) { 3035 config.interval = false; 3036 } 3037 3038 Carousel._jQueryInterface.call($__default['default'](target), config); 3039 3040 if (slideIndex) { 3041 $__default['default'](target).data(DATA_KEY$2).to(slideIndex); 3042 } 3043 3044 event.preventDefault(); 3045 }; 3046 3047 _createClass(Carousel, null, [{ 3048 key: "VERSION", 3049 get: function get() { 3050 return VERSION$2; 3051 } 3052 }, { 3053 key: "Default", 3054 get: function get() { 3055 return Default; 3056 } 3057 }]); 3058 3059 return Carousel; 3060 }(); 3061 /** 3062 * ------------------------------------------------------------------------ 3063 * Data Api implementation 3064 * ------------------------------------------------------------------------ 3065 */ 3066 3067 3068 $__default['default'](document).on(EVENT_CLICK_DATA_API$2, SELECTOR_DATA_SLIDE, Carousel._dataApiClickHandler); 3069 $__default['default'](window).on(EVENT_LOAD_DATA_API$1, function () { 3070 var carousels = [].slice.call(document.querySelectorAll(SELECTOR_DATA_RIDE)); 3071 3072 for (var i = 0, len = carousels.length; i < len; i++) { 3073 var $carousel = $__default['default'](carousels[i]); 3074 3075 Carousel._jQueryInterface.call($carousel, $carousel.data()); 3076 } 3077 }); 3078 /** 3079 * ------------------------------------------------------------------------ 3080 * jQuery 3081 * ------------------------------------------------------------------------ 3082 */ 3083 3084 $__default['default'].fn[NAME$2] = Carousel._jQueryInterface; 3085 $__default['default'].fn[NAME$2].Constructor = Carousel; 3086 3087 $__default['default'].fn[NAME$2].noConflict = function () { 3088 $__default['default'].fn[NAME$2] = JQUERY_NO_CONFLICT$2; 3089 return Carousel._jQueryInterface; 3090 }; 3091 3092 /** 3093 * ------------------------------------------------------------------------ 3094 * Constants 3095 * ------------------------------------------------------------------------ 3096 */ 3097 3098 var NAME$3 = 'collapse'; 3099 var VERSION$3 = '4.6.0'; 3100 var DATA_KEY$3 = 'bs.collapse'; 3101 var EVENT_KEY$3 = "." + DATA_KEY$3; 3102 var DATA_API_KEY$3 = '.data-api'; 3103 var JQUERY_NO_CONFLICT$3 = $__default['default'].fn[NAME$3]; 3104 var Default$1 = { 3105 toggle: true, 3106 parent: '' 3107 }; 3108 var DefaultType$1 = { 3109 toggle: 'boolean', 3110 parent: '(string|element)' 3111 }; 3112 var EVENT_SHOW = "show" + EVENT_KEY$3; 3113 var EVENT_SHOWN = "shown" + EVENT_KEY$3; 3114 var EVENT_HIDE = "hide" + EVENT_KEY$3; 3115 var EVENT_HIDDEN = "hidden" + EVENT_KEY$3; 3116 var EVENT_CLICK_DATA_API$3 = "click" + EVENT_KEY$3 + DATA_API_KEY$3; 3117 var CLASS_NAME_SHOW$1 = 'show'; 3118 var CLASS_NAME_COLLAPSE = 'collapse'; 3119 var CLASS_NAME_COLLAPSING = 'collapsing'; 3120 var CLASS_NAME_COLLAPSED = 'collapsed'; 3121 var DIMENSION_WIDTH = 'width'; 3122 var DIMENSION_HEIGHT = 'height'; 3123 var SELECTOR_ACTIVES = '.show, .collapsing'; 3124 var SELECTOR_DATA_TOGGLE$1 = '[data-toggle="collapse"]'; 3125 /** 3126 * ------------------------------------------------------------------------ 3127 * Class Definition 3128 * ------------------------------------------------------------------------ 3129 */ 3130 3131 var Collapse = /*#__PURE__*/function () { 3132 function Collapse(element, config) { 3133 this._isTransitioning = false; 3134 this._element = element; 3135 this._config = this._getConfig(config); 3136 this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]"))); 3137 var toggleList = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE$1)); 3138 3139 for (var i = 0, len = toggleList.length; i < len; i++) { 3140 var elem = toggleList[i]; 3141 var selector = Util.getSelectorFromElement(elem); 3142 var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) { 3143 return foundElem === element; 3144 }); 3145 3146 if (selector !== null && filterElement.length > 0) { 3147 this._selector = selector; 3148 3149 this._triggerArray.push(elem); 3150 } 3151 } 3152 3153 this._parent = this._config.parent ? this._getParent() : null; 3154 3155 if (!this._config.parent) { 3156 this._addAriaAndCollapsedClass(this._element, this._triggerArray); 3157 } 3158 3159 if (this._config.toggle) { 3160 this.toggle(); 3161 } 3162 } // Getters 3163 3164 3165 var _proto = Collapse.prototype; 3166 3167 // Public 3168 _proto.toggle = function toggle() { 3169 if ($__default['default'](this._element).hasClass(CLASS_NAME_SHOW$1)) { 3170 this.hide(); 3171 } else { 3172 this.show(); 3173 } 3174 }; 3175 3176 _proto.show = function show() { 3177 var _this = this; 3178 3179 if (this._isTransitioning || $__default['default'](this._element).hasClass(CLASS_NAME_SHOW$1)) { 3180 return; 3181 } 3182 3183 var actives; 3184 var activesData; 3185 3186 if (this._parent) { 3187 actives = [].slice.call(this._parent.querySelectorAll(SELECTOR_ACTIVES)).filter(function (elem) { 3188 if (typeof _this._config.parent === 'string') { 3189 return elem.getAttribute('data-parent') === _this._config.parent; 3190 } 3191 3192 return elem.classList.contains(CLASS_NAME_COLLAPSE); 3193 }); 3194 3195 if (actives.length === 0) { 3196 actives = null; 3197 } 3198 } 3199 3200 if (actives) { 3201 activesData = $__default['default'](actives).not(this._selector).data(DATA_KEY$3); 3202 3203 if (activesData && activesData._isTransitioning) { 3204 return; 3205 } 3206 } 3207 3208 var startEvent = $__default['default'].Event(EVENT_SHOW); 3209 $__default['default'](this._element).trigger(startEvent); 3210 3211 if (startEvent.isDefaultPrevented()) { 3212 return; 3213 } 3214 3215 if (actives) { 3216 Collapse._jQueryInterface.call($__default['default'](actives).not(this._selector), 'hide'); 3217 3218 if (!activesData) { 3219 $__default['default'](actives).data(DATA_KEY$3, null); 3220 } 3221 } 3222 3223 var dimension = this._getDimension(); 3224 3225 $__default['default'](this._element).removeClass(CLASS_NAME_COLLAPSE).addClass(CLASS_NAME_COLLAPSING); 3226 this._element.style[dimension] = 0; 3227 3228 if (this._triggerArray.length) { 3229 $__default['default'](this._triggerArray).removeClass(CLASS_NAME_COLLAPSED).attr('aria-expanded', true); 3230 } 3231 3232 this.setTransitioning(true); 3233 3234 var complete = function complete() { 3235 $__default['default'](_this._element).removeClass(CLASS_NAME_COLLAPSING).addClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW$1); 3236 _this._element.style[dimension] = ''; 3237 3238 _this.setTransitioning(false); 3239 3240 $__default['default'](_this._element).trigger(EVENT_SHOWN); 3241 }; 3242 3243 var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); 3244 var scrollSize = "scroll" + capitalizedDimension; 3245 var transitionDuration = Util.getTransitionDurationFromElement(this._element); 3246 $__default['default'](this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 3247 this._element.style[dimension] = this._element[scrollSize] + "px"; 3248 }; 3249 3250 _proto.hide = function hide() { 3251 var _this2 = this; 3252 3253 if (this._isTransitioning || !$__default['default'](this._element).hasClass(CLASS_NAME_SHOW$1)) { 3254 return; 3255 } 3256 3257 var startEvent = $__default['default'].Event(EVENT_HIDE); 3258 $__default['default'](this._element).trigger(startEvent); 3259 3260 if (startEvent.isDefaultPrevented()) { 3261 return; 3262 } 3263 3264 var dimension = this._getDimension(); 3265 3266 this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px"; 3267 Util.reflow(this._element); 3268 $__default['default'](this._element).addClass(CLASS_NAME_COLLAPSING).removeClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW$1); 3269 var triggerArrayLength = this._triggerArray.length; 3270 3271 if (triggerArrayLength > 0) { 3272 for (var i = 0; i < triggerArrayLength; i++) { 3273 var trigger = this._triggerArray[i]; 3274 var selector = Util.getSelectorFromElement(trigger); 3275 3276 if (selector !== null) { 3277 var $elem = $__default['default']([].slice.call(document.querySelectorAll(selector))); 3278 3279 if (!$elem.hasClass(CLASS_NAME_SHOW$1)) { 3280 $__default['default'](trigger).addClass(CLASS_NAME_COLLAPSED).attr('aria-expanded', false); 3281 } 3282 } 3283 } 3284 } 3285 3286 this.setTransitioning(true); 3287 3288 var complete = function complete() { 3289 _this2.setTransitioning(false); 3290 3291 $__default['default'](_this2._element).removeClass(CLASS_NAME_COLLAPSING).addClass(CLASS_NAME_COLLAPSE).trigger(EVENT_HIDDEN); 3292 }; 3293 3294 this._element.style[dimension] = ''; 3295 var transitionDuration = Util.getTransitionDurationFromElement(this._element); 3296 $__default['default'](this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 3297 }; 3298 3299 _proto.setTransitioning = function setTransitioning(isTransitioning) { 3300 this._isTransitioning = isTransitioning; 3301 }; 3302 3303 _proto.dispose = function dispose() { 3304 $__default['default'].removeData(this._element, DATA_KEY$3); 3305 this._config = null; 3306 this._parent = null; 3307 this._element = null; 3308 this._triggerArray = null; 3309 this._isTransitioning = null; 3310 } // Private 3311 ; 3312 3313 _proto._getConfig = function _getConfig(config) { 3314 config = _extends({}, Default$1, config); 3315 config.toggle = Boolean(config.toggle); // Coerce string values 3316 3317 Util.typeCheckConfig(NAME$3, config, DefaultType$1); 3318 return config; 3319 }; 3320 3321 _proto._getDimension = function _getDimension() { 3322 var hasWidth = $__default['default'](this._element).hasClass(DIMENSION_WIDTH); 3323 return hasWidth ? DIMENSION_WIDTH : DIMENSION_HEIGHT; 3324 }; 3325 3326 _proto._getParent = function _getParent() { 3327 var _this3 = this; 3328 3329 var parent; 3330 3331 if (Util.isElement(this._config.parent)) { 3332 parent = this._config.parent; // It's a jQuery object 3333 3334 if (typeof this._config.parent.jquery !== 'undefined') { 3335 parent = this._config.parent[0]; 3336 } 3337 } else { 3338 parent = document.querySelector(this._config.parent); 3339 } 3340 3341 var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]"; 3342 var children = [].slice.call(parent.querySelectorAll(selector)); 3343 $__default['default'](children).each(function (i, element) { 3344 _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); 3345 }); 3346 return parent; 3347 }; 3348 3349 _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) { 3350 var isOpen = $__default['default'](element).hasClass(CLASS_NAME_SHOW$1); 3351 3352 if (triggerArray.length) { 3353 $__default['default'](triggerArray).toggleClass(CLASS_NAME_COLLAPSED, !isOpen).attr('aria-expanded', isOpen); 3354 } 3355 } // Static 3356 ; 3357 3358 Collapse._getTargetFromElement = function _getTargetFromElement(element) { 3359 var selector = Util.getSelectorFromElement(element); 3360 return selector ? document.querySelector(selector) : null; 3361 }; 3362 3363 Collapse._jQueryInterface = function _jQueryInterface(config) { 3364 return this.each(function () { 3365 var $element = $__default['default'](this); 3366 var data = $element.data(DATA_KEY$3); 3367 3368 var _config = _extends({}, Default$1, $element.data(), typeof config === 'object' && config ? config : {}); 3369 3370 if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) { 3371 _config.toggle = false; 3372 } 3373 3374 if (!data) { 3375 data = new Collapse(this, _config); 3376 $element.data(DATA_KEY$3, data); 3377 } 3378 3379 if (typeof config === 'string') { 3380 if (typeof data[config] === 'undefined') { 3381 throw new TypeError("No method named \"" + config + "\""); 3382 } 3383 3384 data[config](); 3385 } 3386 }); 3387 }; 3388 3389 _createClass(Collapse, null, [{ 3390 key: "VERSION", 3391 get: function get() { 3392 return VERSION$3; 3393 } 3394 }, { 3395 key: "Default", 3396 get: function get() { 3397 return Default$1; 3398 } 3399 }]); 3400 3401 return Collapse; 3402 }(); 3403 /** 3404 * ------------------------------------------------------------------------ 3405 * Data Api implementation 3406 * ------------------------------------------------------------------------ 3407 */ 3408 3409 3410 $__default['default'](document).on(EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$1, function (event) { 3411 // preventDefault only for <a> elements (which change the URL) not inside the collapsible element 3412 if (event.currentTarget.tagName === 'A') { 3413 event.preventDefault(); 3414 } 3415 3416 var $trigger = $__default['default'](this); 3417 var selector = Util.getSelectorFromElement(this); 3418 var selectors = [].slice.call(document.querySelectorAll(selector)); 3419 $__default['default'](selectors).each(function () { 3420 var $target = $__default['default'](this); 3421 var data = $target.data(DATA_KEY$3); 3422 var config = data ? 'toggle' : $trigger.data(); 3423 3424 Collapse._jQueryInterface.call($target, config); 3425 }); 3426 }); 3427 /** 3428 * ------------------------------------------------------------------------ 3429 * jQuery 3430 * ------------------------------------------------------------------------ 3431 */ 3432 3433 $__default['default'].fn[NAME$3] = Collapse._jQueryInterface; 3434 $__default['default'].fn[NAME$3].Constructor = Collapse; 3435 3436 $__default['default'].fn[NAME$3].noConflict = function () { 3437 $__default['default'].fn[NAME$3] = JQUERY_NO_CONFLICT$3; 3438 return Collapse._jQueryInterface; 3439 }; 3440 3441 /** 3442 * ------------------------------------------------------------------------ 3443 * Constants 3444 * ------------------------------------------------------------------------ 3445 */ 3446 3447 var NAME$4 = 'dropdown'; 3448 var VERSION$4 = '4.6.0'; 3449 var DATA_KEY$4 = 'bs.dropdown'; 3450 var EVENT_KEY$4 = "." + DATA_KEY$4; 3451 var DATA_API_KEY$4 = '.data-api'; 3452 var JQUERY_NO_CONFLICT$4 = $__default['default'].fn[NAME$4]; 3453 var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key 3454 3455 var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key 3456 3457 var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key 3458 3459 var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key 3460 3461 var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key 3462 3463 var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse) 3464 3465 var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE); 3466 var EVENT_HIDE$1 = "hide" + EVENT_KEY$4; 3467 var EVENT_HIDDEN$1 = "hidden" + EVENT_KEY$4; 3468 var EVENT_SHOW$1 = "show" + EVENT_KEY$4; 3469 var EVENT_SHOWN$1 = "shown" + EVENT_KEY$4; 3470 var EVENT_CLICK = "click" + EVENT_KEY$4; 3471 var EVENT_CLICK_DATA_API$4 = "click" + EVENT_KEY$4 + DATA_API_KEY$4; 3472 var EVENT_KEYDOWN_DATA_API = "keydown" + EVENT_KEY$4 + DATA_API_KEY$4; 3473 var EVENT_KEYUP_DATA_API = "keyup" + EVENT_KEY$4 + DATA_API_KEY$4; 3474 var CLASS_NAME_DISABLED = 'disabled'; 3475 var CLASS_NAME_SHOW$2 = 'show'; 3476 var CLASS_NAME_DROPUP = 'dropup'; 3477 var CLASS_NAME_DROPRIGHT = 'dropright'; 3478 var CLASS_NAME_DROPLEFT = 'dropleft'; 3479 var CLASS_NAME_MENURIGHT = 'dropdown-menu-right'; 3480 var CLASS_NAME_POSITION_STATIC = 'position-static'; 3481 var SELECTOR_DATA_TOGGLE$2 = '[data-toggle="dropdown"]'; 3482 var SELECTOR_FORM_CHILD = '.dropdown form'; 3483 var SELECTOR_MENU = '.dropdown-menu'; 3484 var SELECTOR_NAVBAR_NAV = '.navbar-nav'; 3485 var SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'; 3486 var PLACEMENT_TOP = 'top-start'; 3487 var PLACEMENT_TOPEND = 'top-end'; 3488 var PLACEMENT_BOTTOM = 'bottom-start'; 3489 var PLACEMENT_BOTTOMEND = 'bottom-end'; 3490 var PLACEMENT_RIGHT = 'right-start'; 3491 var PLACEMENT_LEFT = 'left-start'; 3492 var Default$2 = { 3493 offset: 0, 3494 flip: true, 3495 boundary: 'scrollParent', 3496 reference: 'toggle', 3497 display: 'dynamic', 3498 popperConfig: null 3499 }; 3500 var DefaultType$2 = { 3501 offset: '(number|string|function)', 3502 flip: 'boolean', 3503 boundary: '(string|element)', 3504 reference: '(string|element)', 3505 display: 'string', 3506 popperConfig: '(null|object)' 3507 }; 3508 /** 3509 * ------------------------------------------------------------------------ 3510 * Class Definition 3511 * ------------------------------------------------------------------------ 3512 */ 3513 3514 var Dropdown = /*#__PURE__*/function () { 3515 function Dropdown(element, config) { 3516 this._element = element; 3517 this._popper = null; 3518 this._config = this._getConfig(config); 3519 this._menu = this._getMenuElement(); 3520 this._inNavbar = this._detectNavbar(); 3521 3522 this._addEventListeners(); 3523 } // Getters 3524 3525 3526 var _proto = Dropdown.prototype; 3527 3528 // Public 3529 _proto.toggle = function toggle() { 3530 if (this._element.disabled || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED)) { 3531 return; 3532 } 3533 3534 var isActive = $__default['default'](this._menu).hasClass(CLASS_NAME_SHOW$2); 3535 3536 Dropdown._clearMenus(); 3537 3538 if (isActive) { 3539 return; 3540 } 3541 3542 this.show(true); 3543 }; 3544 3545 _proto.show = function show(usePopper) { 3546 if (usePopper === void 0) { 3547 usePopper = false; 3548 } 3549 3550 if (this._element.disabled || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED) || $__default['default'](this._menu).hasClass(CLASS_NAME_SHOW$2)) { 3551 return; 3552 } 3553 3554 var relatedTarget = { 3555 relatedTarget: this._element 3556 }; 3557 var showEvent = $__default['default'].Event(EVENT_SHOW$1, relatedTarget); 3558 3559 var parent = Dropdown._getParentFromElement(this._element); 3560 3561 $__default['default'](parent).trigger(showEvent); 3562 3563 if (showEvent.isDefaultPrevented()) { 3564 return; 3565 } // Totally disable Popper for Dropdowns in Navbar 3566 3567 3568 if (!this._inNavbar && usePopper) { 3569 /** 3570 * Check for Popper dependency 3571 * Popper - https://popper.js.org 3572 */ 3573 if (typeof Popper__default['default'] === 'undefined') { 3574 throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)'); 3575 } 3576 3577 var referenceElement = this._element; 3578 3579 if (this._config.reference === 'parent') { 3580 referenceElement = parent; 3581 } else if (Util.isElement(this._config.reference)) { 3582 referenceElement = this._config.reference; // Check if it's jQuery element 3583 3584 if (typeof this._config.reference.jquery !== 'undefined') { 3585 referenceElement = this._config.reference[0]; 3586 } 3587 } // If boundary is not `scrollParent`, then set position to `static` 3588 // to allow the menu to "escape" the scroll parent's boundaries 3589 // https://github.com/twbs/bootstrap/issues/24251 3590 3591 3592 if (this._config.boundary !== 'scrollParent') { 3593 $__default['default'](parent).addClass(CLASS_NAME_POSITION_STATIC); 3594 } 3595 3596 this._popper = new Popper__default['default'](referenceElement, this._menu, this._getPopperConfig()); 3597 } // If this is a touch-enabled device we add extra 3598 // empty mouseover listeners to the body's immediate children; 3599 // only needed because of broken event delegation on iOS 3600 // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html 3601 3602 3603 if ('ontouchstart' in document.documentElement && $__default['default'](parent).closest(SELECTOR_NAVBAR_NAV).length === 0) { 3604 $__default['default'](document.body).children().on('mouseover', null, $__default['default'].noop); 3605 } 3606 3607 this._element.focus(); 3608 3609 this._element.setAttribute('aria-expanded', true); 3610 3611 $__default['default'](this._menu).toggleClass(CLASS_NAME_SHOW$2); 3612 $__default['default'](parent).toggleClass(CLASS_NAME_SHOW$2).trigger($__default['default'].Event(EVENT_SHOWN$1, relatedTarget)); 3613 }; 3614 3615 _proto.hide = function hide() { 3616 if (this._element.disabled || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED) || !$__default['default'](this._menu).hasClass(CLASS_NAME_SHOW$2)) { 3617 return; 3618 } 3619 3620 var relatedTarget = { 3621 relatedTarget: this._element 3622 }; 3623 var hideEvent = $__default['default'].Event(EVENT_HIDE$1, relatedTarget); 3624 3625 var parent = Dropdown._getParentFromElement(this._element); 3626 3627 $__default['default'](parent).trigger(hideEvent); 3628 3629 if (hideEvent.isDefaultPrevented()) { 3630 return; 3631 } 3632 3633 if (this._popper) { 3634 this._popper.destroy(); 3635 } 3636 3637 $__default['default'](this._menu).toggleClass(CLASS_NAME_SHOW$2); 3638 $__default['default'](parent).toggleClass(CLASS_NAME_SHOW$2).trigger($__default['default'].Event(EVENT_HIDDEN$1, relatedTarget)); 3639 }; 3640 3641 _proto.dispose = function dispose() { 3642 $__default['default'].removeData(this._element, DATA_KEY$4); 3643 $__default['default'](this._element).off(EVENT_KEY$4); 3644 this._element = null; 3645 this._menu = null; 3646 3647 if (this._popper !== null) { 3648 this._popper.destroy(); 3649 3650 this._popper = null; 3651 } 3652 }; 3653 3654 _proto.update = function update() { 3655 this._inNavbar = this._detectNavbar(); 3656 3657 if (this._popper !== null) { 3658 this._popper.scheduleUpdate(); 3659 } 3660 } // Private 3661 ; 3662 3663 _proto._addEventListeners = function _addEventListeners() { 3664 var _this = this; 3665 3666 $__default['default'](this._element).on(EVENT_CLICK, function (event) { 3667 event.preventDefault(); 3668 event.stopPropagation(); 3669 3670 _this.toggle(); 3671 }); 3672 }; 3673 3674 _proto._getConfig = function _getConfig(config) { 3675 config = _extends({}, this.constructor.Default, $__default['default'](this._element).data(), config); 3676 Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType); 3677 return config; 3678 }; 3679 3680 _proto._getMenuElement = function _getMenuElement() { 3681 if (!this._menu) { 3682 var parent = Dropdown._getParentFromElement(this._element); 3683 3684 if (parent) { 3685 this._menu = parent.querySelector(SELECTOR_MENU); 3686 } 3687 } 3688 3689 return this._menu; 3690 }; 3691 3692 _proto._getPlacement = function _getPlacement() { 3693 var $parentDropdown = $__default['default'](this._element.parentNode); 3694 var placement = PLACEMENT_BOTTOM; // Handle dropup 3695 3696 if ($parentDropdown.hasClass(CLASS_NAME_DROPUP)) { 3697 placement = $__default['default'](this._menu).hasClass(CLASS_NAME_MENURIGHT) ? PLACEMENT_TOPEND : PLACEMENT_TOP; 3698 } else if ($parentDropdown.hasClass(CLASS_NAME_DROPRIGHT)) { 3699 placement = PLACEMENT_RIGHT; 3700 } else if ($parentDropdown.hasClass(CLASS_NAME_DROPLEFT)) { 3701 placement = PLACEMENT_LEFT; 3702 } else if ($__default['default'](this._menu).hasClass(CLASS_NAME_MENURIGHT)) { 3703 placement = PLACEMENT_BOTTOMEND; 3704 } 3705 3706 return placement; 3707 }; 3708 3709 _proto._detectNavbar = function _detectNavbar() { 3710 return $__default['default'](this._element).closest('.navbar').length > 0; 3711 }; 3712 3713 _proto._getOffset = function _getOffset() { 3714 var _this2 = this; 3715 3716 var offset = {}; 3717 3718 if (typeof this._config.offset === 'function') { 3719 offset.fn = function (data) { 3720 data.offsets = _extends({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {}); 3721 return data; 3722 }; 3723 } else { 3724 offset.offset = this._config.offset; 3725 } 3726 3727 return offset; 3728 }; 3729 3730 _proto._getPopperConfig = function _getPopperConfig() { 3731 var popperConfig = { 3732 placement: this._getPlacement(), 3733 modifiers: { 3734 offset: this._getOffset(), 3735 flip: { 3736 enabled: this._config.flip 3737 }, 3738 preventOverflow: { 3739 boundariesElement: this._config.boundary 3740 } 3741 } 3742 }; // Disable Popper if we have a static display 3743 3744 if (this._config.display === 'static') { 3745 popperConfig.modifiers.applyStyle = { 3746 enabled: false 3747 }; 3748 } 3749 3750 return _extends({}, popperConfig, this._config.popperConfig); 3751 } // Static 3752 ; 3753 3754 Dropdown._jQueryInterface = function _jQueryInterface(config) { 3755 return this.each(function () { 3756 var data = $__default['default'](this).data(DATA_KEY$4); 3757 3758 var _config = typeof config === 'object' ? config : null; 3759 3760 if (!data) { 3761 data = new Dropdown(this, _config); 3762 $__default['default'](this).data(DATA_KEY$4, data); 3763 } 3764 3765 if (typeof config === 'string') { 3766 if (typeof data[config] === 'undefined') { 3767 throw new TypeError("No method named \"" + config + "\""); 3768 } 3769 3770 data[config](); 3771 } 3772 }); 3773 }; 3774 3775 Dropdown._clearMenus = function _clearMenus(event) { 3776 if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) { 3777 return; 3778 } 3779 3780 var toggles = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE$2)); 3781 3782 for (var i = 0, len = toggles.length; i < len; i++) { 3783 var parent = Dropdown._getParentFromElement(toggles[i]); 3784 3785 var context = $__default['default'](toggles[i]).data(DATA_KEY$4); 3786 var relatedTarget = { 3787 relatedTarget: toggles[i] 3788 }; 3789 3790 if (event && event.type === 'click') { 3791 relatedTarget.clickEvent = event; 3792 } 3793 3794 if (!context) { 3795 continue; 3796 } 3797 3798 var dropdownMenu = context._menu; 3799 3800 if (!$__default['default'](parent).hasClass(CLASS_NAME_SHOW$2)) { 3801 continue; 3802 } 3803 3804 if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $__default['default'].contains(parent, event.target)) { 3805 continue; 3806 } 3807 3808 var hideEvent = $__default['default'].Event(EVENT_HIDE$1, relatedTarget); 3809 $__default['default'](parent).trigger(hideEvent); 3810 3811 if (hideEvent.isDefaultPrevented()) { 3812 continue; 3813 } // If this is a touch-enabled device we remove the extra 3814 // empty mouseover listeners we added for iOS support 3815 3816 3817 if ('ontouchstart' in document.documentElement) { 3818 $__default['default'](document.body).children().off('mouseover', null, $__default['default'].noop); 3819 } 3820 3821 toggles[i].setAttribute('aria-expanded', 'false'); 3822 3823 if (context._popper) { 3824 context._popper.destroy(); 3825 } 3826 3827 $__default['default'](dropdownMenu).removeClass(CLASS_NAME_SHOW$2); 3828 $__default['default'](parent).removeClass(CLASS_NAME_SHOW$2).trigger($__default['default'].Event(EVENT_HIDDEN$1, relatedTarget)); 3829 } 3830 }; 3831 3832 Dropdown._getParentFromElement = function _getParentFromElement(element) { 3833 var parent; 3834 var selector = Util.getSelectorFromElement(element); 3835 3836 if (selector) { 3837 parent = document.querySelector(selector); 3838 } 3839 3840 return parent || element.parentNode; 3841 } // eslint-disable-next-line complexity 3842 ; 3843 3844 Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) { 3845 // If not input/textarea: 3846 // - And not a key in REGEXP_KEYDOWN => not a dropdown command 3847 // If input/textarea: 3848 // - If space key => not a dropdown command 3849 // - If key is other than escape 3850 // - If key is not up or down => not a dropdown command 3851 // - If trigger inside the menu => not a dropdown command 3852 if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $__default['default'](event.target).closest(SELECTOR_MENU).length) : !REGEXP_KEYDOWN.test(event.which)) { 3853 return; 3854 } 3855 3856 if (this.disabled || $__default['default'](this).hasClass(CLASS_NAME_DISABLED)) { 3857 return; 3858 } 3859 3860 var parent = Dropdown._getParentFromElement(this); 3861 3862 var isActive = $__default['default'](parent).hasClass(CLASS_NAME_SHOW$2); 3863 3864 if (!isActive && event.which === ESCAPE_KEYCODE) { 3865 return; 3866 } 3867 3868 event.preventDefault(); 3869 event.stopPropagation(); 3870 3871 if (!isActive || event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE) { 3872 if (event.which === ESCAPE_KEYCODE) { 3873 $__default['default'](parent.querySelector(SELECTOR_DATA_TOGGLE$2)).trigger('focus'); 3874 } 3875 3876 $__default['default'](this).trigger('click'); 3877 return; 3878 } 3879 3880 var items = [].slice.call(parent.querySelectorAll(SELECTOR_VISIBLE_ITEMS)).filter(function (item) { 3881 return $__default['default'](item).is(':visible'); 3882 }); 3883 3884 if (items.length === 0) { 3885 return; 3886 } 3887 3888 var index = items.indexOf(event.target); 3889 3890 if (event.which === ARROW_UP_KEYCODE && index > 0) { 3891 // Up 3892 index--; 3893 } 3894 3895 if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { 3896 // Down 3897 index++; 3898 } 3899 3900 if (index < 0) { 3901 index = 0; 3902 } 3903 3904 items[index].focus(); 3905 }; 3906 3907 _createClass(Dropdown, null, [{ 3908 key: "VERSION", 3909 get: function get() { 3910 return VERSION$4; 3911 } 3912 }, { 3913 key: "Default", 3914 get: function get() { 3915 return Default$2; 3916 } 3917 }, { 3918 key: "DefaultType", 3919 get: function get() { 3920 return DefaultType$2; 3921 } 3922 }]); 3923 3924 return Dropdown; 3925 }(); 3926 /** 3927 * ------------------------------------------------------------------------ 3928 * Data Api implementation 3929 * ------------------------------------------------------------------------ 3930 */ 3931 3932 3933 $__default['default'](document).on(EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$2, Dropdown._dataApiKeydownHandler).on(EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown._dataApiKeydownHandler).on(EVENT_CLICK_DATA_API$4 + " " + EVENT_KEYUP_DATA_API, Dropdown._clearMenus).on(EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$2, function (event) { 3934 event.preventDefault(); 3935 event.stopPropagation(); 3936 3937 Dropdown._jQueryInterface.call($__default['default'](this), 'toggle'); 3938 }).on(EVENT_CLICK_DATA_API$4, SELECTOR_FORM_CHILD, function (e) { 3939 e.stopPropagation(); 3940 }); 3941 /** 3942 * ------------------------------------------------------------------------ 3943 * jQuery 3944 * ------------------------------------------------------------------------ 3945 */ 3946 3947 $__default['default'].fn[NAME$4] = Dropdown._jQueryInterface; 3948 $__default['default'].fn[NAME$4].Constructor = Dropdown; 3949 3950 $__default['default'].fn[NAME$4].noConflict = function () { 3951 $__default['default'].fn[NAME$4] = JQUERY_NO_CONFLICT$4; 3952 return Dropdown._jQueryInterface; 3953 }; 3954 3955 /** 3956 * ------------------------------------------------------------------------ 3957 * Constants 3958 * ------------------------------------------------------------------------ 3959 */ 3960 3961 var NAME$5 = 'modal'; 3962 var VERSION$5 = '4.6.0'; 3963 var DATA_KEY$5 = 'bs.modal'; 3964 var EVENT_KEY$5 = "." + DATA_KEY$5; 3965 var DATA_API_KEY$5 = '.data-api'; 3966 var JQUERY_NO_CONFLICT$5 = $__default['default'].fn[NAME$5]; 3967 var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key 3968 3969 var Default$3 = { 3970 backdrop: true, 3971 keyboard: true, 3972 focus: true, 3973 show: true 3974 }; 3975 var DefaultType$3 = { 3976 backdrop: '(boolean|string)', 3977 keyboard: 'boolean', 3978 focus: 'boolean', 3979 show: 'boolean' 3980 }; 3981 var EVENT_HIDE$2 = "hide" + EVENT_KEY$5; 3982 var EVENT_HIDE_PREVENTED = "hidePrevented" + EVENT_KEY$5; 3983 var EVENT_HIDDEN$2 = "hidden" + EVENT_KEY$5; 3984 var EVENT_SHOW$2 = "show" + EVENT_KEY$5; 3985 var EVENT_SHOWN$2 = "shown" + EVENT_KEY$5; 3986 var EVENT_FOCUSIN = "focusin" + EVENT_KEY$5; 3987 var EVENT_RESIZE = "resize" + EVENT_KEY$5; 3988 var EVENT_CLICK_DISMISS = "click.dismiss" + EVENT_KEY$5; 3989 var EVENT_KEYDOWN_DISMISS = "keydown.dismiss" + EVENT_KEY$5; 3990 var EVENT_MOUSEUP_DISMISS = "mouseup.dismiss" + EVENT_KEY$5; 3991 var EVENT_MOUSEDOWN_DISMISS = "mousedown.dismiss" + EVENT_KEY$5; 3992 var EVENT_CLICK_DATA_API$5 = "click" + EVENT_KEY$5 + DATA_API_KEY$5; 3993 var CLASS_NAME_SCROLLABLE = 'modal-dialog-scrollable'; 3994 var CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure'; 3995 var CLASS_NAME_BACKDROP = 'modal-backdrop'; 3996 var CLASS_NAME_OPEN = 'modal-open'; 3997 var CLASS_NAME_FADE$1 = 'fade'; 3998 var CLASS_NAME_SHOW$3 = 'show'; 3999 var CLASS_NAME_STATIC = 'modal-static'; 4000 var SELECTOR_DIALOG = '.modal-dialog'; 4001 var SELECTOR_MODAL_BODY = '.modal-body'; 4002 var SELECTOR_DATA_TOGGLE$3 = '[data-toggle="modal"]'; 4003 var SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]'; 4004 var SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'; 4005 var SELECTOR_STICKY_CONTENT = '.sticky-top'; 4006 /** 4007 * ------------------------------------------------------------------------ 4008 * Class Definition 4009 * ------------------------------------------------------------------------ 4010 */ 4011 4012 var Modal = /*#__PURE__*/function () { 4013 function Modal(element, config) { 4014 this._config = this._getConfig(config); 4015 this._element = element; 4016 this._dialog = element.querySelector(SELECTOR_DIALOG); 4017 this._backdrop = null; 4018 this._isShown = false; 4019 this._isBodyOverflowing = false; 4020 this._ignoreBackdropClick = false; 4021 this._isTransitioning = false; 4022 this._scrollbarWidth = 0; 4023 } // Getters 4024 4025 4026 var _proto = Modal.prototype; 4027 4028 // Public 4029 _proto.toggle = function toggle(relatedTarget) { 4030 return this._isShown ? this.hide() : this.show(relatedTarget); 4031 }; 4032 4033 _proto.show = function show(relatedTarget) { 4034 var _this = this; 4035 4036 if (this._isShown || this._isTransitioning) { 4037 return; 4038 } 4039 4040 if ($__default['default'](this._element).hasClass(CLASS_NAME_FADE$1)) { 4041 this._isTransitioning = true; 4042 } 4043 4044 var showEvent = $__default['default'].Event(EVENT_SHOW$2, { 4045 relatedTarget: relatedTarget 4046 }); 4047 $__default['default'](this._element).trigger(showEvent); 4048 4049 if (this._isShown || showEvent.isDefaultPrevented()) { 4050 return; 4051 } 4052 4053 this._isShown = true; 4054 4055 this._checkScrollbar(); 4056 4057 this._setScrollbar(); 4058 4059 this._adjustDialog(); 4060 4061 this._setEscapeEvent(); 4062 4063 this._setResizeEvent(); 4064 4065 $__default['default'](this._element).on(EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) { 4066 return _this.hide(event); 4067 }); 4068 $__default['default'](this._dialog).on(EVENT_MOUSEDOWN_DISMISS, function () { 4069 $__default['default'](_this._element).one(EVENT_MOUSEUP_DISMISS, function (event) { 4070 if ($__default['default'](event.target).is(_this._element)) { 4071 _this._ignoreBackdropClick = true; 4072 } 4073 }); 4074 }); 4075 4076 this._showBackdrop(function () { 4077 return _this._showElement(relatedTarget); 4078 }); 4079 }; 4080 4081 _proto.hide = function hide(event) { 4082 var _this2 = this; 4083 4084 if (event) { 4085 event.preventDefault(); 4086 } 4087 4088 if (!this._isShown || this._isTransitioning) { 4089 return; 4090 } 4091 4092 var hideEvent = $__default['default'].Event(EVENT_HIDE$2); 4093 $__default['default'](this._element).trigger(hideEvent); 4094 4095 if (!this._isShown || hideEvent.isDefaultPrevented()) { 4096 return; 4097 } 4098 4099 this._isShown = false; 4100 var transition = $__default['default'](this._element).hasClass(CLASS_NAME_FADE$1); 4101 4102 if (transition) { 4103 this._isTransitioning = true; 4104 } 4105 4106 this._setEscapeEvent(); 4107 4108 this._setResizeEvent(); 4109 4110 $__default['default'](document).off(EVENT_FOCUSIN); 4111 $__default['default'](this._element).removeClass(CLASS_NAME_SHOW$3); 4112 $__default['default'](this._element).off(EVENT_CLICK_DISMISS); 4113 $__default['default'](this._dialog).off(EVENT_MOUSEDOWN_DISMISS); 4114 4115 if (transition) { 4116 var transitionDuration = Util.getTransitionDurationFromElement(this._element); 4117 $__default['default'](this._element).one(Util.TRANSITION_END, function (event) { 4118 return _this2._hideModal(event); 4119 }).emulateTransitionEnd(transitionDuration); 4120 } else { 4121 this._hideModal(); 4122 } 4123 }; 4124 4125 _proto.dispose = function dispose() { 4126 [window, this._element, this._dialog].forEach(function (htmlElement) { 4127 return $__default['default'](htmlElement).off(EVENT_KEY$5); 4128 }); 4129 /** 4130 * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API` 4131 * Do not move `document` in `htmlElements` array 4132 * It will remove `EVENT_CLICK_DATA_API` event that should remain 4133 */ 4134 4135 $__default['default'](document).off(EVENT_FOCUSIN); 4136 $__default['default'].removeData(this._element, DATA_KEY$5); 4137 this._config = null; 4138 this._element = null; 4139 this._dialog = null; 4140 this._backdrop = null; 4141 this._isShown = null; 4142 this._isBodyOverflowing = null; 4143 this._ignoreBackdropClick = null; 4144 this._isTransitioning = null; 4145 this._scrollbarWidth = null; 4146 }; 4147 4148 _proto.handleUpdate = function handleUpdate() { 4149 this._adjustDialog(); 4150 } // Private 4151 ; 4152 4153 _proto._getConfig = function _getConfig(config) { 4154 config = _extends({}, Default$3, config); 4155 Util.typeCheckConfig(NAME$5, config, DefaultType$3); 4156 return config; 4157 }; 4158 4159 _proto._triggerBackdropTransition = function _triggerBackdropTransition() { 4160 var _this3 = this; 4161 4162 var hideEventPrevented = $__default['default'].Event(EVENT_HIDE_PREVENTED); 4163 $__default['default'](this._element).trigger(hideEventPrevented); 4164 4165 if (hideEventPrevented.isDefaultPrevented()) { 4166 return; 4167 } 4168 4169 var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; 4170 4171 if (!isModalOverflowing) { 4172 this._element.style.overflowY = 'hidden'; 4173 } 4174 4175 this._element.classList.add(CLASS_NAME_STATIC); 4176 4177 var modalTransitionDuration = Util.getTransitionDurationFromElement(this._dialog); 4178 $__default['default'](this._element).off(Util.TRANSITION_END); 4179 $__default['default'](this._element).one(Util.TRANSITION_END, function () { 4180 _this3._element.classList.remove(CLASS_NAME_STATIC); 4181 4182 if (!isModalOverflowing) { 4183 $__default['default'](_this3._element).one(Util.TRANSITION_END, function () { 4184 _this3._element.style.overflowY = ''; 4185 }).emulateTransitionEnd(_this3._element, modalTransitionDuration); 4186 } 4187 }).emulateTransitionEnd(modalTransitionDuration); 4188 4189 this._element.focus(); 4190 }; 4191 4192 _proto._showElement = function _showElement(relatedTarget) { 4193 var _this4 = this; 4194 4195 var transition = $__default['default'](this._element).hasClass(CLASS_NAME_FADE$1); 4196 var modalBody = this._dialog ? this._dialog.querySelector(SELECTOR_MODAL_BODY) : null; 4197 4198 if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { 4199 // Don't move modal's DOM position 4200 document.body.appendChild(this._element); 4201 } 4202 4203 this._element.style.display = 'block'; 4204 4205 this._element.removeAttribute('aria-hidden'); 4206 4207 this._element.setAttribute('aria-modal', true); 4208 4209 this._element.setAttribute('role', 'dialog'); 4210 4211 if ($__default['default'](this._dialog).hasClass(CLASS_NAME_SCROLLABLE) && modalBody) { 4212 modalBody.scrollTop = 0; 4213 } else { 4214 this._element.scrollTop = 0; 4215 } 4216 4217 if (transition) { 4218 Util.reflow(this._element); 4219 } 4220 4221 $__default['default'](this._element).addClass(CLASS_NAME_SHOW$3); 4222 4223 if (this._config.focus) { 4224 this._enforceFocus(); 4225 } 4226 4227 var shownEvent = $__default['default'].Event(EVENT_SHOWN$2, { 4228 relatedTarget: relatedTarget 4229 }); 4230 4231 var transitionComplete = function transitionComplete() { 4232 if (_this4._config.focus) { 4233 _this4._element.focus(); 4234 } 4235 4236 _this4._isTransitioning = false; 4237 $__default['default'](_this4._element).trigger(shownEvent); 4238 }; 4239 4240 if (transition) { 4241 var transitionDuration = Util.getTransitionDurationFromElement(this._dialog); 4242 $__default['default'](this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration); 4243 } else { 4244 transitionComplete(); 4245 } 4246 }; 4247 4248 _proto._enforceFocus = function _enforceFocus() { 4249 var _this5 = this; 4250 4251 $__default['default'](document).off(EVENT_FOCUSIN) // Guard against infinite focus loop 4252 .on(EVENT_FOCUSIN, function (event) { 4253 if (document !== event.target && _this5._element !== event.target && $__default['default'](_this5._element).has(event.target).length === 0) { 4254 _this5._element.focus(); 4255 } 4256 }); 4257 }; 4258 4259 _proto._setEscapeEvent = function _setEscapeEvent() { 4260 var _this6 = this; 4261 4262 if (this._isShown) { 4263 $__default['default'](this._element).on(EVENT_KEYDOWN_DISMISS, function (event) { 4264 if (_this6._config.keyboard && event.which === ESCAPE_KEYCODE$1) { 4265 event.preventDefault(); 4266 4267 _this6.hide(); 4268 } else if (!_this6._config.keyboard && event.which === ESCAPE_KEYCODE$1) { 4269 _this6._triggerBackdropTransition(); 4270 } 4271 }); 4272 } else if (!this._isShown) { 4273 $__default['default'](this._element).off(EVENT_KEYDOWN_DISMISS); 4274 } 4275 }; 4276 4277 _proto._setResizeEvent = function _setResizeEvent() { 4278 var _this7 = this; 4279 4280 if (this._isShown) { 4281 $__default['default'](window).on(EVENT_RESIZE, function (event) { 4282 return _this7.handleUpdate(event); 4283 }); 4284 } else { 4285 $__default['default'](window).off(EVENT_RESIZE); 4286 } 4287 }; 4288 4289 _proto._hideModal = function _hideModal() { 4290 var _this8 = this; 4291 4292 this._element.style.display = 'none'; 4293 4294 this._element.setAttribute('aria-hidden', true); 4295 4296 this._element.removeAttribute('aria-modal'); 4297 4298 this._element.removeAttribute('role'); 4299 4300 this._isTransitioning = false; 4301 4302 this._showBackdrop(function () { 4303 $__default['default'](document.body).removeClass(CLASS_NAME_OPEN); 4304 4305 _this8._resetAdjustments(); 4306 4307 _this8._resetScrollbar(); 4308 4309 $__default['default'](_this8._element).trigger(EVENT_HIDDEN$2); 4310 }); 4311 }; 4312 4313 _proto._removeBackdrop = function _removeBackdrop() { 4314 if (this._backdrop) { 4315 $__default['default'](this._backdrop).remove(); 4316 this._backdrop = null; 4317 } 4318 }; 4319 4320 _proto._showBackdrop = function _showBackdrop(callback) { 4321 var _this9 = this; 4322 4323 var animate = $__default['default'](this._element).hasClass(CLASS_NAME_FADE$1) ? CLASS_NAME_FADE$1 : ''; 4324 4325 if (this._isShown && this._config.backdrop) { 4326 this._backdrop = document.createElement('div'); 4327 this._backdrop.className = CLASS_NAME_BACKDROP; 4328 4329 if (animate) { 4330 this._backdrop.classList.add(animate); 4331 } 4332 4333 $__default['default'](this._backdrop).appendTo(document.body); 4334 $__default['default'](this._element).on(EVENT_CLICK_DISMISS, function (event) { 4335 if (_this9._ignoreBackdropClick) { 4336 _this9._ignoreBackdropClick = false; 4337 return; 4338 } 4339 4340 if (event.target !== event.currentTarget) { 4341 return; 4342 } 4343 4344 if (_this9._config.backdrop === 'static') { 4345 _this9._triggerBackdropTransition(); 4346 } else { 4347 _this9.hide(); 4348 } 4349 }); 4350 4351 if (animate) { 4352 Util.reflow(this._backdrop); 4353 } 4354 4355 $__default['default'](this._backdrop).addClass(CLASS_NAME_SHOW$3); 4356 4357 if (!callback) { 4358 return; 4359 } 4360 4361 if (!animate) { 4362 callback(); 4363 return; 4364 } 4365 4366 var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop); 4367 $__default['default'](this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration); 4368 } else if (!this._isShown && this._backdrop) { 4369 $__default['default'](this._backdrop).removeClass(CLASS_NAME_SHOW$3); 4370 4371 var callbackRemove = function callbackRemove() { 4372 _this9._removeBackdrop(); 4373 4374 if (callback) { 4375 callback(); 4376 } 4377 }; 4378 4379 if ($__default['default'](this._element).hasClass(CLASS_NAME_FADE$1)) { 4380 var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop); 4381 4382 $__default['default'](this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration); 4383 } else { 4384 callbackRemove(); 4385 } 4386 } else if (callback) { 4387 callback(); 4388 } 4389 } // ---------------------------------------------------------------------- 4390 // the following methods are used to handle overflowing modals 4391 // todo (fat): these should probably be refactored out of modal.js 4392 // ---------------------------------------------------------------------- 4393 ; 4394 4395 _proto._adjustDialog = function _adjustDialog() { 4396 var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; 4397 4398 if (!this._isBodyOverflowing && isModalOverflowing) { 4399 this._element.style.paddingLeft = this._scrollbarWidth + "px"; 4400 } 4401 4402 if (this._isBodyOverflowing && !isModalOverflowing) { 4403 this._element.style.paddingRight = this._scrollbarWidth + "px"; 4404 } 4405 }; 4406 4407 _proto._resetAdjustments = function _resetAdjustments() { 4408 this._element.style.paddingLeft = ''; 4409 this._element.style.paddingRight = ''; 4410 }; 4411 4412 _proto._checkScrollbar = function _checkScrollbar() { 4413 var rect = document.body.getBoundingClientRect(); 4414 this._isBodyOverflowing = Math.round(rect.left + rect.right) < window.innerWidth; 4415 this._scrollbarWidth = this._getScrollbarWidth(); 4416 }; 4417 4418 _proto._setScrollbar = function _setScrollbar() { 4419 var _this10 = this; 4420 4421 if (this._isBodyOverflowing) { 4422 // Note: DOMNode.style.paddingRight returns the actual value or '' if not set 4423 // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set 4424 var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT)); 4425 var stickyContent = [].slice.call(document.querySelectorAll(SELECTOR_STICKY_CONTENT)); // Adjust fixed content padding 4426 4427 $__default['default'](fixedContent).each(function (index, element) { 4428 var actualPadding = element.style.paddingRight; 4429 var calculatedPadding = $__default['default'](element).css('padding-right'); 4430 $__default['default'](element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px"); 4431 }); // Adjust sticky content margin 4432 4433 $__default['default'](stickyContent).each(function (index, element) { 4434 var actualMargin = element.style.marginRight; 4435 var calculatedMargin = $__default['default'](element).css('margin-right'); 4436 $__default['default'](element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px"); 4437 }); // Adjust body padding 4438 4439 var actualPadding = document.body.style.paddingRight; 4440 var calculatedPadding = $__default['default'](document.body).css('padding-right'); 4441 $__default['default'](document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px"); 4442 } 4443 4444 $__default['default'](document.body).addClass(CLASS_NAME_OPEN); 4445 }; 4446 4447 _proto._resetScrollbar = function _resetScrollbar() { 4448 // Restore fixed content padding 4449 var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT)); 4450 $__default['default'](fixedContent).each(function (index, element) { 4451 var padding = $__default['default'](element).data('padding-right'); 4452 $__default['default'](element).removeData('padding-right'); 4453 element.style.paddingRight = padding ? padding : ''; 4454 }); // Restore sticky content 4455 4456 var elements = [].slice.call(document.querySelectorAll("" + SELECTOR_STICKY_CONTENT)); 4457 $__default['default'](elements).each(function (index, element) { 4458 var margin = $__default['default'](element).data('margin-right'); 4459 4460 if (typeof margin !== 'undefined') { 4461 $__default['default'](element).css('margin-right', margin).removeData('margin-right'); 4462 } 4463 }); // Restore body padding 4464 4465 var padding = $__default['default'](document.body).data('padding-right'); 4466 $__default['default'](document.body).removeData('padding-right'); 4467 document.body.style.paddingRight = padding ? padding : ''; 4468 }; 4469 4470 _proto._getScrollbarWidth = function _getScrollbarWidth() { 4471 // thx d.walsh 4472 var scrollDiv = document.createElement('div'); 4473 scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER; 4474 document.body.appendChild(scrollDiv); 4475 var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth; 4476 document.body.removeChild(scrollDiv); 4477 return scrollbarWidth; 4478 } // Static 4479 ; 4480 4481 Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) { 4482 return this.each(function () { 4483 var data = $__default['default'](this).data(DATA_KEY$5); 4484 4485 var _config = _extends({}, Default$3, $__default['default'](this).data(), typeof config === 'object' && config ? config : {}); 4486 4487 if (!data) { 4488 data = new Modal(this, _config); 4489 $__default['default'](this).data(DATA_KEY$5, data); 4490 } 4491 4492 if (typeof config === 'string') { 4493 if (typeof data[config] === 'undefined') { 4494 throw new TypeError("No method named \"" + config + "\""); 4495 } 4496 4497 data[config](relatedTarget); 4498 } else if (_config.show) { 4499 data.show(relatedTarget); 4500 } 4501 }); 4502 }; 4503 4504 _createClass(Modal, null, [{ 4505 key: "VERSION", 4506 get: function get() { 4507 return VERSION$5; 4508 } 4509 }, { 4510 key: "Default", 4511 get: function get() { 4512 return Default$3; 4513 } 4514 }]); 4515 4516 return Modal; 4517 }(); 4518 /** 4519 * ------------------------------------------------------------------------ 4520 * Data Api implementation 4521 * ------------------------------------------------------------------------ 4522 */ 4523 4524 4525 $__default['default'](document).on(EVENT_CLICK_DATA_API$5, SELECTOR_DATA_TOGGLE$3, function (event) { 4526 var _this11 = this; 4527 4528 var target; 4529 var selector = Util.getSelectorFromElement(this); 4530 4531 if (selector) { 4532 target = document.querySelector(selector); 4533 } 4534 4535 var config = $__default['default'](target).data(DATA_KEY$5) ? 'toggle' : _extends({}, $__default['default'](target).data(), $__default['default'](this).data()); 4536 4537 if (this.tagName === 'A' || this.tagName === 'AREA') { 4538 event.preventDefault(); 4539 } 4540 4541 var $target = $__default['default'](target).one(EVENT_SHOW$2, function (showEvent) { 4542 if (showEvent.isDefaultPrevented()) { 4543 // Only register focus restorer if modal will actually get shown 4544 return; 4545 } 4546 4547 $target.one(EVENT_HIDDEN$2, function () { 4548 if ($__default['default'](_this11).is(':visible')) { 4549 _this11.focus(); 4550 } 4551 }); 4552 }); 4553 4554 Modal._jQueryInterface.call($__default['default'](target), config, this); 4555 }); 4556 /** 4557 * ------------------------------------------------------------------------ 4558 * jQuery 4559 * ------------------------------------------------------------------------ 4560 */ 4561 4562 $__default['default'].fn[NAME$5] = Modal._jQueryInterface; 4563 $__default['default'].fn[NAME$5].Constructor = Modal; 4564 4565 $__default['default'].fn[NAME$5].noConflict = function () { 4566 $__default['default'].fn[NAME$5] = JQUERY_NO_CONFLICT$5; 4567 return Modal._jQueryInterface; 4568 }; 4569 4570 /** 4571 * -------------------------------------------------------------------------- 4572 * Bootstrap (v4.6.0): tools/sanitizer.js 4573 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 4574 * -------------------------------------------------------------------------- 4575 */ 4576 var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']; 4577 var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; 4578 var DefaultWhitelist = { 4579 // Global attributes allowed on any supplied element below. 4580 '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN], 4581 a: ['target', 'href', 'title', 'rel'], 4582 area: [], 4583 b: [], 4584 br: [], 4585 col: [], 4586 code: [], 4587 div: [], 4588 em: [], 4589 hr: [], 4590 h1: [], 4591 h2: [], 4592 h3: [], 4593 h4: [], 4594 h5: [], 4595 h6: [], 4596 i: [], 4597 img: ['src', 'srcset', 'alt', 'title', 'width', 'height'], 4598 li: [], 4599 ol: [], 4600 p: [], 4601 pre: [], 4602 s: [], 4603 small: [], 4604 span: [], 4605 sub: [], 4606 sup: [], 4607 strong: [], 4608 u: [], 4609 ul: [] 4610 }; 4611 /** 4612 * A pattern that recognizes a commonly useful subset of URLs that are safe. 4613 * 4614 * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts 4615 */ 4616 4617 var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi; 4618 /** 4619 * A pattern that matches safe data URLs. Only matches image, video and audio types. 4620 * 4621 * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts 4622 */ 4623 4624 var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i; 4625 4626 function allowedAttribute(attr, allowedAttributeList) { 4627 var attrName = attr.nodeName.toLowerCase(); 4628 4629 if (allowedAttributeList.indexOf(attrName) !== -1) { 4630 if (uriAttrs.indexOf(attrName) !== -1) { 4631 return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)); 4632 } 4633 4634 return true; 4635 } 4636 4637 var regExp = allowedAttributeList.filter(function (attrRegex) { 4638 return attrRegex instanceof RegExp; 4639 }); // Check if a regular expression validates the attribute. 4640 4641 for (var i = 0, len = regExp.length; i < len; i++) { 4642 if (attrName.match(regExp[i])) { 4643 return true; 4644 } 4645 } 4646 4647 return false; 4648 } 4649 4650 function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) { 4651 if (unsafeHtml.length === 0) { 4652 return unsafeHtml; 4653 } 4654 4655 if (sanitizeFn && typeof sanitizeFn === 'function') { 4656 return sanitizeFn(unsafeHtml); 4657 } 4658 4659 var domParser = new window.DOMParser(); 4660 var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html'); 4661 var whitelistKeys = Object.keys(whiteList); 4662 var elements = [].slice.call(createdDocument.body.querySelectorAll('*')); 4663 4664 var _loop = function _loop(i, len) { 4665 var el = elements[i]; 4666 var elName = el.nodeName.toLowerCase(); 4667 4668 if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) { 4669 el.parentNode.removeChild(el); 4670 return "continue"; 4671 } 4672 4673 var attributeList = [].slice.call(el.attributes); 4674 var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []); 4675 attributeList.forEach(function (attr) { 4676 if (!allowedAttribute(attr, whitelistedAttributes)) { 4677 el.removeAttribute(attr.nodeName); 4678 } 4679 }); 4680 }; 4681 4682 for (var i = 0, len = elements.length; i < len; i++) { 4683 var _ret = _loop(i); 4684 4685 if (_ret === "continue") continue; 4686 } 4687 4688 return createdDocument.body.innerHTML; 4689 } 4690 4691 /** 4692 * ------------------------------------------------------------------------ 4693 * Constants 4694 * ------------------------------------------------------------------------ 4695 */ 4696 4697 var NAME$6 = 'tooltip'; 4698 var VERSION$6 = '4.6.0'; 4699 var DATA_KEY$6 = 'bs.tooltip'; 4700 var EVENT_KEY$6 = "." + DATA_KEY$6; 4701 var JQUERY_NO_CONFLICT$6 = $__default['default'].fn[NAME$6]; 4702 var CLASS_PREFIX = 'bs-tooltip'; 4703 var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g'); 4704 var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn']; 4705 var DefaultType$4 = { 4706 animation: 'boolean', 4707 template: 'string', 4708 title: '(string|element|function)', 4709 trigger: 'string', 4710 delay: '(number|object)', 4711 html: 'boolean', 4712 selector: '(string|boolean)', 4713 placement: '(string|function)', 4714 offset: '(number|string|function)', 4715 container: '(string|element|boolean)', 4716 fallbackPlacement: '(string|array)', 4717 boundary: '(string|element)', 4718 customClass: '(string|function)', 4719 sanitize: 'boolean', 4720 sanitizeFn: '(null|function)', 4721 whiteList: 'object', 4722 popperConfig: '(null|object)' 4723 }; 4724 var AttachmentMap = { 4725 AUTO: 'auto', 4726 TOP: 'top', 4727 RIGHT: 'right', 4728 BOTTOM: 'bottom', 4729 LEFT: 'left' 4730 }; 4731 var Default$4 = { 4732 animation: true, 4733 template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>', 4734 trigger: 'hover focus', 4735 title: '', 4736 delay: 0, 4737 html: false, 4738 selector: false, 4739 placement: 'top', 4740 offset: 0, 4741 container: false, 4742 fallbackPlacement: 'flip', 4743 boundary: 'scrollParent', 4744 customClass: '', 4745 sanitize: true, 4746 sanitizeFn: null, 4747 whiteList: DefaultWhitelist, 4748 popperConfig: null 4749 }; 4750 var HOVER_STATE_SHOW = 'show'; 4751 var HOVER_STATE_OUT = 'out'; 4752 var Event = { 4753 HIDE: "hide" + EVENT_KEY$6, 4754 HIDDEN: "hidden" + EVENT_KEY$6, 4755 SHOW: "show" + EVENT_KEY$6, 4756 SHOWN: "shown" + EVENT_KEY$6, 4757 INSERTED: "inserted" + EVENT_KEY$6, 4758 CLICK: "click" + EVENT_KEY$6, 4759 FOCUSIN: "focusin" + EVENT_KEY$6, 4760 FOCUSOUT: "focusout" + EVENT_KEY$6, 4761 MOUSEENTER: "mouseenter" + EVENT_KEY$6, 4762 MOUSELEAVE: "mouseleave" + EVENT_KEY$6 4763 }; 4764 var CLASS_NAME_FADE$2 = 'fade'; 4765 var CLASS_NAME_SHOW$4 = 'show'; 4766 var SELECTOR_TOOLTIP_INNER = '.tooltip-inner'; 4767 var SELECTOR_ARROW = '.arrow'; 4768 var TRIGGER_HOVER = 'hover'; 4769 var TRIGGER_FOCUS = 'focus'; 4770 var TRIGGER_CLICK = 'click'; 4771 var TRIGGER_MANUAL = 'manual'; 4772 /** 4773 * ------------------------------------------------------------------------ 4774 * Class Definition 4775 * ------------------------------------------------------------------------ 4776 */ 4777 4778 var Tooltip = /*#__PURE__*/function () { 4779 function Tooltip(element, config) { 4780 if (typeof Popper__default['default'] === 'undefined') { 4781 throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)'); 4782 } // private 4783 4784 4785 this._isEnabled = true; 4786 this._timeout = 0; 4787 this._hoverState = ''; 4788 this._activeTrigger = {}; 4789 this._popper = null; // Protected 4790 4791 this.element = element; 4792 this.config = this._getConfig(config); 4793 this.tip = null; 4794 4795 this._setListeners(); 4796 } // Getters 4797 4798 4799 var _proto = Tooltip.prototype; 4800 4801 // Public 4802 _proto.enable = function enable() { 4803 this._isEnabled = true; 4804 }; 4805 4806 _proto.disable = function disable() { 4807 this._isEnabled = false; 4808 }; 4809 4810 _proto.toggleEnabled = function toggleEnabled() { 4811 this._isEnabled = !this._isEnabled; 4812 }; 4813 4814 _proto.toggle = function toggle(event) { 4815 if (!this._isEnabled) { 4816 return; 4817 } 4818 4819 if (event) { 4820 var dataKey = this.constructor.DATA_KEY; 4821 var context = $__default['default'](event.currentTarget).data(dataKey); 4822 4823 if (!context) { 4824 context = new this.constructor(event.currentTarget, this._getDelegateConfig()); 4825 $__default['default'](event.currentTarget).data(dataKey, context); 4826 } 4827 4828 context._activeTrigger.click = !context._activeTrigger.click; 4829 4830 if (context._isWithActiveTrigger()) { 4831 context._enter(null, context); 4832 } else { 4833 context._leave(null, context); 4834 } 4835 } else { 4836 if ($__default['default'](this.getTipElement()).hasClass(CLASS_NAME_SHOW$4)) { 4837 this._leave(null, this); 4838 4839 return; 4840 } 4841 4842 this._enter(null, this); 4843 } 4844 }; 4845 4846 _proto.dispose = function dispose() { 4847 clearTimeout(this._timeout); 4848 $__default['default'].removeData(this.element, this.constructor.DATA_KEY); 4849 $__default['default'](this.element).off(this.constructor.EVENT_KEY); 4850 $__default['default'](this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler); 4851 4852 if (this.tip) { 4853 $__default['default'](this.tip).remove(); 4854 } 4855 4856 this._isEnabled = null; 4857 this._timeout = null; 4858 this._hoverState = null; 4859 this._activeTrigger = null; 4860 4861 if (this._popper) { 4862 this._popper.destroy(); 4863 } 4864 4865 this._popper = null; 4866 this.element = null; 4867 this.config = null; 4868 this.tip = null; 4869 }; 4870 4871 _proto.show = function show() { 4872 var _this = this; 4873 4874 if ($__default['default'](this.element).css('display') === 'none') { 4875 throw new Error('Please use show on visible elements'); 4876 } 4877 4878 var showEvent = $__default['default'].Event(this.constructor.Event.SHOW); 4879 4880 if (this.isWithContent() && this._isEnabled) { 4881 $__default['default'](this.element).trigger(showEvent); 4882 var shadowRoot = Util.findShadowRoot(this.element); 4883 var isInTheDom = $__default['default'].contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element); 4884 4885 if (showEvent.isDefaultPrevented() || !isInTheDom) { 4886 return; 4887 } 4888 4889 var tip = this.getTipElement(); 4890 var tipId = Util.getUID(this.constructor.NAME); 4891 tip.setAttribute('id', tipId); 4892 this.element.setAttribute('aria-describedby', tipId); 4893 this.setContent(); 4894 4895 if (this.config.animation) { 4896 $__default['default'](tip).addClass(CLASS_NAME_FADE$2); 4897 } 4898 4899 var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement; 4900 4901 var attachment = this._getAttachment(placement); 4902 4903 this.addAttachmentClass(attachment); 4904 4905 var container = this._getContainer(); 4906 4907 $__default['default'](tip).data(this.constructor.DATA_KEY, this); 4908 4909 if (!$__default['default'].contains(this.element.ownerDocument.documentElement, this.tip)) { 4910 $__default['default'](tip).appendTo(container); 4911 } 4912 4913 $__default['default'](this.element).trigger(this.constructor.Event.INSERTED); 4914 this._popper = new Popper__default['default'](this.element, tip, this._getPopperConfig(attachment)); 4915 $__default['default'](tip).addClass(CLASS_NAME_SHOW$4); 4916 $__default['default'](tip).addClass(this.config.customClass); // If this is a touch-enabled device we add extra 4917 // empty mouseover listeners to the body's immediate children; 4918 // only needed because of broken event delegation on iOS 4919 // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html 4920 4921 if ('ontouchstart' in document.documentElement) { 4922 $__default['default'](document.body).children().on('mouseover', null, $__default['default'].noop); 4923 } 4924 4925 var complete = function complete() { 4926 if (_this.config.animation) { 4927 _this._fixTransition(); 4928 } 4929 4930 var prevHoverState = _this._hoverState; 4931 _this._hoverState = null; 4932 $__default['default'](_this.element).trigger(_this.constructor.Event.SHOWN); 4933 4934 if (prevHoverState === HOVER_STATE_OUT) { 4935 _this._leave(null, _this); 4936 } 4937 }; 4938 4939 if ($__default['default'](this.tip).hasClass(CLASS_NAME_FADE$2)) { 4940 var transitionDuration = Util.getTransitionDurationFromElement(this.tip); 4941 $__default['default'](this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 4942 } else { 4943 complete(); 4944 } 4945 } 4946 }; 4947 4948 _proto.hide = function hide(callback) { 4949 var _this2 = this; 4950 4951 var tip = this.getTipElement(); 4952 var hideEvent = $__default['default'].Event(this.constructor.Event.HIDE); 4953 4954 var complete = function complete() { 4955 if (_this2._hoverState !== HOVER_STATE_SHOW && tip.parentNode) { 4956 tip.parentNode.removeChild(tip); 4957 } 4958 4959 _this2._cleanTipClass(); 4960 4961 _this2.element.removeAttribute('aria-describedby'); 4962 4963 $__default['default'](_this2.element).trigger(_this2.constructor.Event.HIDDEN); 4964 4965 if (_this2._popper !== null) { 4966 _this2._popper.destroy(); 4967 } 4968 4969 if (callback) { 4970 callback(); 4971 } 4972 }; 4973 4974 $__default['default'](this.element).trigger(hideEvent); 4975 4976 if (hideEvent.isDefaultPrevented()) { 4977 return; 4978 } 4979 4980 $__default['default'](tip).removeClass(CLASS_NAME_SHOW$4); // If this is a touch-enabled device we remove the extra 4981 // empty mouseover listeners we added for iOS support 4982 4983 if ('ontouchstart' in document.documentElement) { 4984 $__default['default'](document.body).children().off('mouseover', null, $__default['default'].noop); 4985 } 4986 4987 this._activeTrigger[TRIGGER_CLICK] = false; 4988 this._activeTrigger[TRIGGER_FOCUS] = false; 4989 this._activeTrigger[TRIGGER_HOVER] = false; 4990 4991 if ($__default['default'](this.tip).hasClass(CLASS_NAME_FADE$2)) { 4992 var transitionDuration = Util.getTransitionDurationFromElement(tip); 4993 $__default['default'](tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 4994 } else { 4995 complete(); 4996 } 4997 4998 this._hoverState = ''; 4999 }; 5000 5001 _proto.update = function update() { 5002 if (this._popper !== null) { 5003 this._popper.scheduleUpdate(); 5004 } 5005 } // Protected 5006 ; 5007 5008 _proto.isWithContent = function isWithContent() { 5009 return Boolean(this.getTitle()); 5010 }; 5011 5012 _proto.addAttachmentClass = function addAttachmentClass(attachment) { 5013 $__default['default'](this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment); 5014 }; 5015 5016 _proto.getTipElement = function getTipElement() { 5017 this.tip = this.tip || $__default['default'](this.config.template)[0]; 5018 return this.tip; 5019 }; 5020 5021 _proto.setContent = function setContent() { 5022 var tip = this.getTipElement(); 5023 this.setElementContent($__default['default'](tip.querySelectorAll(SELECTOR_TOOLTIP_INNER)), this.getTitle()); 5024 $__default['default'](tip).removeClass(CLASS_NAME_FADE$2 + " " + CLASS_NAME_SHOW$4); 5025 }; 5026 5027 _proto.setElementContent = function setElementContent($element, content) { 5028 if (typeof content === 'object' && (content.nodeType || content.jquery)) { 5029 // Content is a DOM node or a jQuery 5030 if (this.config.html) { 5031 if (!$__default['default'](content).parent().is($element)) { 5032 $element.empty().append(content); 5033 } 5034 } else { 5035 $element.text($__default['default'](content).text()); 5036 } 5037 5038 return; 5039 } 5040 5041 if (this.config.html) { 5042 if (this.config.sanitize) { 5043 content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn); 5044 } 5045 5046 $element.html(content); 5047 } else { 5048 $element.text(content); 5049 } 5050 }; 5051 5052 _proto.getTitle = function getTitle() { 5053 var title = this.element.getAttribute('data-original-title'); 5054 5055 if (!title) { 5056 title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title; 5057 } 5058 5059 return title; 5060 } // Private 5061 ; 5062 5063 _proto._getPopperConfig = function _getPopperConfig(attachment) { 5064 var _this3 = this; 5065 5066 var defaultBsConfig = { 5067 placement: attachment, 5068 modifiers: { 5069 offset: this._getOffset(), 5070 flip: { 5071 behavior: this.config.fallbackPlacement 5072 }, 5073 arrow: { 5074 element: SELECTOR_ARROW 5075 }, 5076 preventOverflow: { 5077 boundariesElement: this.config.boundary 5078 } 5079 }, 5080 onCreate: function onCreate(data) { 5081 if (data.originalPlacement !== data.placement) { 5082 _this3._handlePopperPlacementChange(data); 5083 } 5084 }, 5085 onUpdate: function onUpdate(data) { 5086 return _this3._handlePopperPlacementChange(data); 5087 } 5088 }; 5089 return _extends({}, defaultBsConfig, this.config.popperConfig); 5090 }; 5091 5092 _proto._getOffset = function _getOffset() { 5093 var _this4 = this; 5094 5095 var offset = {}; 5096 5097 if (typeof this.config.offset === 'function') { 5098 offset.fn = function (data) { 5099 data.offsets = _extends({}, data.offsets, _this4.config.offset(data.offsets, _this4.element) || {}); 5100 return data; 5101 }; 5102 } else { 5103 offset.offset = this.config.offset; 5104 } 5105 5106 return offset; 5107 }; 5108 5109 _proto._getContainer = function _getContainer() { 5110 if (this.config.container === false) { 5111 return document.body; 5112 } 5113 5114 if (Util.isElement(this.config.container)) { 5115 return $__default['default'](this.config.container); 5116 } 5117 5118 return $__default['default'](document).find(this.config.container); 5119 }; 5120 5121 _proto._getAttachment = function _getAttachment(placement) { 5122 return AttachmentMap[placement.toUpperCase()]; 5123 }; 5124 5125 _proto._setListeners = function _setListeners() { 5126 var _this5 = this; 5127 5128 var triggers = this.config.trigger.split(' '); 5129 triggers.forEach(function (trigger) { 5130 if (trigger === 'click') { 5131 $__default['default'](_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) { 5132 return _this5.toggle(event); 5133 }); 5134 } else if (trigger !== TRIGGER_MANUAL) { 5135 var eventIn = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN; 5136 var eventOut = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT; 5137 $__default['default'](_this5.element).on(eventIn, _this5.config.selector, function (event) { 5138 return _this5._enter(event); 5139 }).on(eventOut, _this5.config.selector, function (event) { 5140 return _this5._leave(event); 5141 }); 5142 } 5143 }); 5144 5145 this._hideModalHandler = function () { 5146 if (_this5.element) { 5147 _this5.hide(); 5148 } 5149 }; 5150 5151 $__default['default'](this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler); 5152 5153 if (this.config.selector) { 5154 this.config = _extends({}, this.config, { 5155 trigger: 'manual', 5156 selector: '' 5157 }); 5158 } else { 5159 this._fixTitle(); 5160 } 5161 }; 5162 5163 _proto._fixTitle = function _fixTitle() { 5164 var titleType = typeof this.element.getAttribute('data-original-title'); 5165 5166 if (this.element.getAttribute('title') || titleType !== 'string') { 5167 this.element.setAttribute('data-original-title', this.element.getAttribute('title') || ''); 5168 this.element.setAttribute('title', ''); 5169 } 5170 }; 5171 5172 _proto._enter = function _enter(event, context) { 5173 var dataKey = this.constructor.DATA_KEY; 5174 context = context || $__default['default'](event.currentTarget).data(dataKey); 5175 5176 if (!context) { 5177 context = new this.constructor(event.currentTarget, this._getDelegateConfig()); 5178 $__default['default'](event.currentTarget).data(dataKey, context); 5179 } 5180 5181 if (event) { 5182 context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true; 5183 } 5184 5185 if ($__default['default'](context.getTipElement()).hasClass(CLASS_NAME_SHOW$4) || context._hoverState === HOVER_STATE_SHOW) { 5186 context._hoverState = HOVER_STATE_SHOW; 5187 return; 5188 } 5189 5190 clearTimeout(context._timeout); 5191 context._hoverState = HOVER_STATE_SHOW; 5192 5193 if (!context.config.delay || !context.config.delay.show) { 5194 context.show(); 5195 return; 5196 } 5197 5198 context._timeout = setTimeout(function () { 5199 if (context._hoverState === HOVER_STATE_SHOW) { 5200 context.show(); 5201 } 5202 }, context.config.delay.show); 5203 }; 5204 5205 _proto._leave = function _leave(event, context) { 5206 var dataKey = this.constructor.DATA_KEY; 5207 context = context || $__default['default'](event.currentTarget).data(dataKey); 5208 5209 if (!context) { 5210 context = new this.constructor(event.currentTarget, this._getDelegateConfig()); 5211 $__default['default'](event.currentTarget).data(dataKey, context); 5212 } 5213 5214 if (event) { 5215 context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false; 5216 } 5217 5218 if (context._isWithActiveTrigger()) { 5219 return; 5220 } 5221 5222 clearTimeout(context._timeout); 5223 context._hoverState = HOVER_STATE_OUT; 5224 5225 if (!context.config.delay || !context.config.delay.hide) { 5226 context.hide(); 5227 return; 5228 } 5229 5230 context._timeout = setTimeout(function () { 5231 if (context._hoverState === HOVER_STATE_OUT) { 5232 context.hide(); 5233 } 5234 }, context.config.delay.hide); 5235 }; 5236 5237 _proto._isWithActiveTrigger = function _isWithActiveTrigger() { 5238 for (var trigger in this._activeTrigger) { 5239 if (this._activeTrigger[trigger]) { 5240 return true; 5241 } 5242 } 5243 5244 return false; 5245 }; 5246 5247 _proto._getConfig = function _getConfig(config) { 5248 var dataAttributes = $__default['default'](this.element).data(); 5249 Object.keys(dataAttributes).forEach(function (dataAttr) { 5250 if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) { 5251 delete dataAttributes[dataAttr]; 5252 } 5253 }); 5254 config = _extends({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {}); 5255 5256 if (typeof config.delay === 'number') { 5257 config.delay = { 5258 show: config.delay, 5259 hide: config.delay 5260 }; 5261 } 5262 5263 if (typeof config.title === 'number') { 5264 config.title = config.title.toString(); 5265 } 5266 5267 if (typeof config.content === 'number') { 5268 config.content = config.content.toString(); 5269 } 5270 5271 Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType); 5272 5273 if (config.sanitize) { 5274 config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn); 5275 } 5276 5277 return config; 5278 }; 5279 5280 _proto._getDelegateConfig = function _getDelegateConfig() { 5281 var config = {}; 5282 5283 if (this.config) { 5284 for (var key in this.config) { 5285 if (this.constructor.Default[key] !== this.config[key]) { 5286 config[key] = this.config[key]; 5287 } 5288 } 5289 } 5290 5291 return config; 5292 }; 5293 5294 _proto._cleanTipClass = function _cleanTipClass() { 5295 var $tip = $__default['default'](this.getTipElement()); 5296 var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX); 5297 5298 if (tabClass !== null && tabClass.length) { 5299 $tip.removeClass(tabClass.join('')); 5300 } 5301 }; 5302 5303 _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) { 5304 this.tip = popperData.instance.popper; 5305 5306 this._cleanTipClass(); 5307 5308 this.addAttachmentClass(this._getAttachment(popperData.placement)); 5309 }; 5310 5311 _proto._fixTransition = function _fixTransition() { 5312 var tip = this.getTipElement(); 5313 var initConfigAnimation = this.config.animation; 5314 5315 if (tip.getAttribute('x-placement') !== null) { 5316 return; 5317 } 5318 5319 $__default['default'](tip).removeClass(CLASS_NAME_FADE$2); 5320 this.config.animation = false; 5321 this.hide(); 5322 this.show(); 5323 this.config.animation = initConfigAnimation; 5324 } // Static 5325 ; 5326 5327 Tooltip._jQueryInterface = function _jQueryInterface(config) { 5328 return this.each(function () { 5329 var $element = $__default['default'](this); 5330 var data = $element.data(DATA_KEY$6); 5331 5332 var _config = typeof config === 'object' && config; 5333 5334 if (!data && /dispose|hide/.test(config)) { 5335 return; 5336 } 5337 5338 if (!data) { 5339 data = new Tooltip(this, _config); 5340 $element.data(DATA_KEY$6, data); 5341 } 5342 5343 if (typeof config === 'string') { 5344 if (typeof data[config] === 'undefined') { 5345 throw new TypeError("No method named \"" + config + "\""); 5346 } 5347 5348 data[config](); 5349 } 5350 }); 5351 }; 5352 5353 _createClass(Tooltip, null, [{ 5354 key: "VERSION", 5355 get: function get() { 5356 return VERSION$6; 5357 } 5358 }, { 5359 key: "Default", 5360 get: function get() { 5361 return Default$4; 5362 } 5363 }, { 5364 key: "NAME", 5365 get: function get() { 5366 return NAME$6; 5367 } 5368 }, { 5369 key: "DATA_KEY", 5370 get: function get() { 5371 return DATA_KEY$6; 5372 } 5373 }, { 5374 key: "Event", 5375 get: function get() { 5376 return Event; 5377 } 5378 }, { 5379 key: "EVENT_KEY", 5380 get: function get() { 5381 return EVENT_KEY$6; 5382 } 5383 }, { 5384 key: "DefaultType", 5385 get: function get() { 5386 return DefaultType$4; 5387 } 5388 }]); 5389 5390 return Tooltip; 5391 }(); 5392 /** 5393 * ------------------------------------------------------------------------ 5394 * jQuery 5395 * ------------------------------------------------------------------------ 5396 */ 5397 5398 5399 $__default['default'].fn[NAME$6] = Tooltip._jQueryInterface; 5400 $__default['default'].fn[NAME$6].Constructor = Tooltip; 5401 5402 $__default['default'].fn[NAME$6].noConflict = function () { 5403 $__default['default'].fn[NAME$6] = JQUERY_NO_CONFLICT$6; 5404 return Tooltip._jQueryInterface; 5405 }; 5406 5407 /** 5408 * ------------------------------------------------------------------------ 5409 * Constants 5410 * ------------------------------------------------------------------------ 5411 */ 5412 5413 var NAME$7 = 'popover'; 5414 var VERSION$7 = '4.6.0'; 5415 var DATA_KEY$7 = 'bs.popover'; 5416 var EVENT_KEY$7 = "." + DATA_KEY$7; 5417 var JQUERY_NO_CONFLICT$7 = $__default['default'].fn[NAME$7]; 5418 var CLASS_PREFIX$1 = 'bs-popover'; 5419 var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g'); 5420 5421 var Default$5 = _extends({}, Tooltip.Default, { 5422 placement: 'right', 5423 trigger: 'click', 5424 content: '', 5425 template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>' 5426 }); 5427 5428 var DefaultType$5 = _extends({}, Tooltip.DefaultType, { 5429 content: '(string|element|function)' 5430 }); 5431 5432 var CLASS_NAME_FADE$3 = 'fade'; 5433 var CLASS_NAME_SHOW$5 = 'show'; 5434 var SELECTOR_TITLE = '.popover-header'; 5435 var SELECTOR_CONTENT = '.popover-body'; 5436 var Event$1 = { 5437 HIDE: "hide" + EVENT_KEY$7, 5438 HIDDEN: "hidden" + EVENT_KEY$7, 5439 SHOW: "show" + EVENT_KEY$7, 5440 SHOWN: "shown" + EVENT_KEY$7, 5441 INSERTED: "inserted" + EVENT_KEY$7, 5442 CLICK: "click" + EVENT_KEY$7, 5443 FOCUSIN: "focusin" + EVENT_KEY$7, 5444 FOCUSOUT: "focusout" + EVENT_KEY$7, 5445 MOUSEENTER: "mouseenter" + EVENT_KEY$7, 5446 MOUSELEAVE: "mouseleave" + EVENT_KEY$7 5447 }; 5448 /** 5449 * ------------------------------------------------------------------------ 5450 * Class Definition 5451 * ------------------------------------------------------------------------ 5452 */ 5453 5454 var Popover = /*#__PURE__*/function (_Tooltip) { 5455 _inheritsLoose(Popover, _Tooltip); 5456 5457 function Popover() { 5458 return _Tooltip.apply(this, arguments) || this; 5459 } 5460 5461 var _proto = Popover.prototype; 5462 5463 // Overrides 5464 _proto.isWithContent = function isWithContent() { 5465 return this.getTitle() || this._getContent(); 5466 }; 5467 5468 _proto.addAttachmentClass = function addAttachmentClass(attachment) { 5469 $__default['default'](this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment); 5470 }; 5471 5472 _proto.getTipElement = function getTipElement() { 5473 this.tip = this.tip || $__default['default'](this.config.template)[0]; 5474 return this.tip; 5475 }; 5476 5477 _proto.setContent = function setContent() { 5478 var $tip = $__default['default'](this.getTipElement()); // We use append for html objects to maintain js events 5479 5480 this.setElementContent($tip.find(SELECTOR_TITLE), this.getTitle()); 5481 5482 var content = this._getContent(); 5483 5484 if (typeof content === 'function') { 5485 content = content.call(this.element); 5486 } 5487 5488 this.setElementContent($tip.find(SELECTOR_CONTENT), content); 5489 $tip.removeClass(CLASS_NAME_FADE$3 + " " + CLASS_NAME_SHOW$5); 5490 } // Private 5491 ; 5492 5493 _proto._getContent = function _getContent() { 5494 return this.element.getAttribute('data-content') || this.config.content; 5495 }; 5496 5497 _proto._cleanTipClass = function _cleanTipClass() { 5498 var $tip = $__default['default'](this.getTipElement()); 5499 var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1); 5500 5501 if (tabClass !== null && tabClass.length > 0) { 5502 $tip.removeClass(tabClass.join('')); 5503 } 5504 } // Static 5505 ; 5506 5507 Popover._jQueryInterface = function _jQueryInterface(config) { 5508 return this.each(function () { 5509 var data = $__default['default'](this).data(DATA_KEY$7); 5510 5511 var _config = typeof config === 'object' ? config : null; 5512 5513 if (!data && /dispose|hide/.test(config)) { 5514 return; 5515 } 5516 5517 if (!data) { 5518 data = new Popover(this, _config); 5519 $__default['default'](this).data(DATA_KEY$7, data); 5520 } 5521 5522 if (typeof config === 'string') { 5523 if (typeof data[config] === 'undefined') { 5524 throw new TypeError("No method named \"" + config + "\""); 5525 } 5526 5527 data[config](); 5528 } 5529 }); 5530 }; 5531 5532 _createClass(Popover, null, [{ 5533 key: "VERSION", 5534 // Getters 5535 get: function get() { 5536 return VERSION$7; 5537 } 5538 }, { 5539 key: "Default", 5540 get: function get() { 5541 return Default$5; 5542 } 5543 }, { 5544 key: "NAME", 5545 get: function get() { 5546 return NAME$7; 5547 } 5548 }, { 5549 key: "DATA_KEY", 5550 get: function get() { 5551 return DATA_KEY$7; 5552 } 5553 }, { 5554 key: "Event", 5555 get: function get() { 5556 return Event$1; 5557 } 5558 }, { 5559 key: "EVENT_KEY", 5560 get: function get() { 5561 return EVENT_KEY$7; 5562 } 5563 }, { 5564 key: "DefaultType", 5565 get: function get() { 5566 return DefaultType$5; 5567 } 5568 }]); 5569 5570 return Popover; 5571 }(Tooltip); 5572 /** 5573 * ------------------------------------------------------------------------ 5574 * jQuery 5575 * ------------------------------------------------------------------------ 5576 */ 5577 5578 5579 $__default['default'].fn[NAME$7] = Popover._jQueryInterface; 5580 $__default['default'].fn[NAME$7].Constructor = Popover; 5581 5582 $__default['default'].fn[NAME$7].noConflict = function () { 5583 $__default['default'].fn[NAME$7] = JQUERY_NO_CONFLICT$7; 5584 return Popover._jQueryInterface; 5585 }; 5586 5587 /** 5588 * ------------------------------------------------------------------------ 5589 * Constants 5590 * ------------------------------------------------------------------------ 5591 */ 5592 5593 var NAME$8 = 'scrollspy'; 5594 var VERSION$8 = '4.6.0'; 5595 var DATA_KEY$8 = 'bs.scrollspy'; 5596 var EVENT_KEY$8 = "." + DATA_KEY$8; 5597 var DATA_API_KEY$6 = '.data-api'; 5598 var JQUERY_NO_CONFLICT$8 = $__default['default'].fn[NAME$8]; 5599 var Default$6 = { 5600 offset: 10, 5601 method: 'auto', 5602 target: '' 5603 }; 5604 var DefaultType$6 = { 5605 offset: 'number', 5606 method: 'string', 5607 target: '(string|element)' 5608 }; 5609 var EVENT_ACTIVATE = "activate" + EVENT_KEY$8; 5610 var EVENT_SCROLL = "scroll" + EVENT_KEY$8; 5611 var EVENT_LOAD_DATA_API$2 = "load" + EVENT_KEY$8 + DATA_API_KEY$6; 5612 var CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item'; 5613 var CLASS_NAME_ACTIVE$2 = 'active'; 5614 var SELECTOR_DATA_SPY = '[data-spy="scroll"]'; 5615 var SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'; 5616 var SELECTOR_NAV_LINKS = '.nav-link'; 5617 var SELECTOR_NAV_ITEMS = '.nav-item'; 5618 var SELECTOR_LIST_ITEMS = '.list-group-item'; 5619 var SELECTOR_DROPDOWN = '.dropdown'; 5620 var SELECTOR_DROPDOWN_ITEMS = '.dropdown-item'; 5621 var SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'; 5622 var METHOD_OFFSET = 'offset'; 5623 var METHOD_POSITION = 'position'; 5624 /** 5625 * ------------------------------------------------------------------------ 5626 * Class Definition 5627 * ------------------------------------------------------------------------ 5628 */ 5629 5630 var ScrollSpy = /*#__PURE__*/function () { 5631 function ScrollSpy(element, config) { 5632 var _this = this; 5633 5634 this._element = element; 5635 this._scrollElement = element.tagName === 'BODY' ? window : element; 5636 this._config = this._getConfig(config); 5637 this._selector = this._config.target + " " + SELECTOR_NAV_LINKS + "," + (this._config.target + " " + SELECTOR_LIST_ITEMS + ",") + (this._config.target + " " + SELECTOR_DROPDOWN_ITEMS); 5638 this._offsets = []; 5639 this._targets = []; 5640 this._activeTarget = null; 5641 this._scrollHeight = 0; 5642 $__default['default'](this._scrollElement).on(EVENT_SCROLL, function (event) { 5643 return _this._process(event); 5644 }); 5645 this.refresh(); 5646 5647 this._process(); 5648 } // Getters 5649 5650 5651 var _proto = ScrollSpy.prototype; 5652 5653 // Public 5654 _proto.refresh = function refresh() { 5655 var _this2 = this; 5656 5657 var autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION; 5658 var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; 5659 var offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0; 5660 this._offsets = []; 5661 this._targets = []; 5662 this._scrollHeight = this._getScrollHeight(); 5663 var targets = [].slice.call(document.querySelectorAll(this._selector)); 5664 targets.map(function (element) { 5665 var target; 5666 var targetSelector = Util.getSelectorFromElement(element); 5667 5668 if (targetSelector) { 5669 target = document.querySelector(targetSelector); 5670 } 5671 5672 if (target) { 5673 var targetBCR = target.getBoundingClientRect(); 5674 5675 if (targetBCR.width || targetBCR.height) { 5676 // TODO (fat): remove sketch reliance on jQuery position/offset 5677 return [$__default['default'](target)[offsetMethod]().top + offsetBase, targetSelector]; 5678 } 5679 } 5680 5681 return null; 5682 }).filter(function (item) { 5683 return item; 5684 }).sort(function (a, b) { 5685 return a[0] - b[0]; 5686 }).forEach(function (item) { 5687 _this2._offsets.push(item[0]); 5688 5689 _this2._targets.push(item[1]); 5690 }); 5691 }; 5692 5693 _proto.dispose = function dispose() { 5694 $__default['default'].removeData(this._element, DATA_KEY$8); 5695 $__default['default'](this._scrollElement).off(EVENT_KEY$8); 5696 this._element = null; 5697 this._scrollElement = null; 5698 this._config = null; 5699 this._selector = null; 5700 this._offsets = null; 5701 this._targets = null; 5702 this._activeTarget = null; 5703 this._scrollHeight = null; 5704 } // Private 5705 ; 5706 5707 _proto._getConfig = function _getConfig(config) { 5708 config = _extends({}, Default$6, typeof config === 'object' && config ? config : {}); 5709 5710 if (typeof config.target !== 'string' && Util.isElement(config.target)) { 5711 var id = $__default['default'](config.target).attr('id'); 5712 5713 if (!id) { 5714 id = Util.getUID(NAME$8); 5715 $__default['default'](config.target).attr('id', id); 5716 } 5717 5718 config.target = "#" + id; 5719 } 5720 5721 Util.typeCheckConfig(NAME$8, config, DefaultType$6); 5722 return config; 5723 }; 5724 5725 _proto._getScrollTop = function _getScrollTop() { 5726 return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop; 5727 }; 5728 5729 _proto._getScrollHeight = function _getScrollHeight() { 5730 return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); 5731 }; 5732 5733 _proto._getOffsetHeight = function _getOffsetHeight() { 5734 return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height; 5735 }; 5736 5737 _proto._process = function _process() { 5738 var scrollTop = this._getScrollTop() + this._config.offset; 5739 5740 var scrollHeight = this._getScrollHeight(); 5741 5742 var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight(); 5743 5744 if (this._scrollHeight !== scrollHeight) { 5745 this.refresh(); 5746 } 5747 5748 if (scrollTop >= maxScroll) { 5749 var target = this._targets[this._targets.length - 1]; 5750 5751 if (this._activeTarget !== target) { 5752 this._activate(target); 5753 } 5754 5755 return; 5756 } 5757 5758 if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { 5759 this._activeTarget = null; 5760 5761 this._clear(); 5762 5763 return; 5764 } 5765 5766 for (var i = this._offsets.length; i--;) { 5767 var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]); 5768 5769 if (isActiveTarget) { 5770 this._activate(this._targets[i]); 5771 } 5772 } 5773 }; 5774 5775 _proto._activate = function _activate(target) { 5776 this._activeTarget = target; 5777 5778 this._clear(); 5779 5780 var queries = this._selector.split(',').map(function (selector) { 5781 return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]"; 5782 }); 5783 5784 var $link = $__default['default']([].slice.call(document.querySelectorAll(queries.join(',')))); 5785 5786 if ($link.hasClass(CLASS_NAME_DROPDOWN_ITEM)) { 5787 $link.closest(SELECTOR_DROPDOWN).find(SELECTOR_DROPDOWN_TOGGLE).addClass(CLASS_NAME_ACTIVE$2); 5788 $link.addClass(CLASS_NAME_ACTIVE$2); 5789 } else { 5790 // Set triggered link as active 5791 $link.addClass(CLASS_NAME_ACTIVE$2); // Set triggered links parents as active 5792 // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor 5793 5794 $link.parents(SELECTOR_NAV_LIST_GROUP).prev(SELECTOR_NAV_LINKS + ", " + SELECTOR_LIST_ITEMS).addClass(CLASS_NAME_ACTIVE$2); // Handle special case when .nav-link is inside .nav-item 5795 5796 $link.parents(SELECTOR_NAV_LIST_GROUP).prev(SELECTOR_NAV_ITEMS).children(SELECTOR_NAV_LINKS).addClass(CLASS_NAME_ACTIVE$2); 5797 } 5798 5799 $__default['default'](this._scrollElement).trigger(EVENT_ACTIVATE, { 5800 relatedTarget: target 5801 }); 5802 }; 5803 5804 _proto._clear = function _clear() { 5805 [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) { 5806 return node.classList.contains(CLASS_NAME_ACTIVE$2); 5807 }).forEach(function (node) { 5808 return node.classList.remove(CLASS_NAME_ACTIVE$2); 5809 }); 5810 } // Static 5811 ; 5812 5813 ScrollSpy._jQueryInterface = function _jQueryInterface(config) { 5814 return this.each(function () { 5815 var data = $__default['default'](this).data(DATA_KEY$8); 5816 5817 var _config = typeof config === 'object' && config; 5818 5819 if (!data) { 5820 data = new ScrollSpy(this, _config); 5821 $__default['default'](this).data(DATA_KEY$8, data); 5822 } 5823 5824 if (typeof config === 'string') { 5825 if (typeof data[config] === 'undefined') { 5826 throw new TypeError("No method named \"" + config + "\""); 5827 } 5828 5829 data[config](); 5830 } 5831 }); 5832 }; 5833 5834 _createClass(ScrollSpy, null, [{ 5835 key: "VERSION", 5836 get: function get() { 5837 return VERSION$8; 5838 } 5839 }, { 5840 key: "Default", 5841 get: function get() { 5842 return Default$6; 5843 } 5844 }]); 5845 5846 return ScrollSpy; 5847 }(); 5848 /** 5849 * ------------------------------------------------------------------------ 5850 * Data Api implementation 5851 * ------------------------------------------------------------------------ 5852 */ 5853 5854 5855 $__default['default'](window).on(EVENT_LOAD_DATA_API$2, function () { 5856 var scrollSpys = [].slice.call(document.querySelectorAll(SELECTOR_DATA_SPY)); 5857 var scrollSpysLength = scrollSpys.length; 5858 5859 for (var i = scrollSpysLength; i--;) { 5860 var $spy = $__default['default'](scrollSpys[i]); 5861 5862 ScrollSpy._jQueryInterface.call($spy, $spy.data()); 5863 } 5864 }); 5865 /** 5866 * ------------------------------------------------------------------------ 5867 * jQuery 5868 * ------------------------------------------------------------------------ 5869 */ 5870 5871 $__default['default'].fn[NAME$8] = ScrollSpy._jQueryInterface; 5872 $__default['default'].fn[NAME$8].Constructor = ScrollSpy; 5873 5874 $__default['default'].fn[NAME$8].noConflict = function () { 5875 $__default['default'].fn[NAME$8] = JQUERY_NO_CONFLICT$8; 5876 return ScrollSpy._jQueryInterface; 5877 }; 5878 5879 /** 5880 * ------------------------------------------------------------------------ 5881 * Constants 5882 * ------------------------------------------------------------------------ 5883 */ 5884 5885 var NAME$9 = 'tab'; 5886 var VERSION$9 = '4.6.0'; 5887 var DATA_KEY$9 = 'bs.tab'; 5888 var EVENT_KEY$9 = "." + DATA_KEY$9; 5889 var DATA_API_KEY$7 = '.data-api'; 5890 var JQUERY_NO_CONFLICT$9 = $__default['default'].fn[NAME$9]; 5891 var EVENT_HIDE$3 = "hide" + EVENT_KEY$9; 5892 var EVENT_HIDDEN$3 = "hidden" + EVENT_KEY$9; 5893 var EVENT_SHOW$3 = "show" + EVENT_KEY$9; 5894 var EVENT_SHOWN$3 = "shown" + EVENT_KEY$9; 5895 var EVENT_CLICK_DATA_API$6 = "click" + EVENT_KEY$9 + DATA_API_KEY$7; 5896 var CLASS_NAME_DROPDOWN_MENU = 'dropdown-menu'; 5897 var CLASS_NAME_ACTIVE$3 = 'active'; 5898 var CLASS_NAME_DISABLED$1 = 'disabled'; 5899 var CLASS_NAME_FADE$4 = 'fade'; 5900 var CLASS_NAME_SHOW$6 = 'show'; 5901 var SELECTOR_DROPDOWN$1 = '.dropdown'; 5902 var SELECTOR_NAV_LIST_GROUP$1 = '.nav, .list-group'; 5903 var SELECTOR_ACTIVE$2 = '.active'; 5904 var SELECTOR_ACTIVE_UL = '> li > .active'; 5905 var SELECTOR_DATA_TOGGLE$4 = '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]'; 5906 var SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle'; 5907 var SELECTOR_DROPDOWN_ACTIVE_CHILD = '> .dropdown-menu .active'; 5908 /** 5909 * ------------------------------------------------------------------------ 5910 * Class Definition 5911 * ------------------------------------------------------------------------ 5912 */ 5913 5914 var Tab = /*#__PURE__*/function () { 5915 function Tab(element) { 5916 this._element = element; 5917 } // Getters 5918 5919 5920 var _proto = Tab.prototype; 5921 5922 // Public 5923 _proto.show = function show() { 5924 var _this = this; 5925 5926 if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $__default['default'](this._element).hasClass(CLASS_NAME_ACTIVE$3) || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED$1)) { 5927 return; 5928 } 5929 5930 var target; 5931 var previous; 5932 var listElement = $__default['default'](this._element).closest(SELECTOR_NAV_LIST_GROUP$1)[0]; 5933 var selector = Util.getSelectorFromElement(this._element); 5934 5935 if (listElement) { 5936 var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE$2; 5937 previous = $__default['default'].makeArray($__default['default'](listElement).find(itemSelector)); 5938 previous = previous[previous.length - 1]; 5939 } 5940 5941 var hideEvent = $__default['default'].Event(EVENT_HIDE$3, { 5942 relatedTarget: this._element 5943 }); 5944 var showEvent = $__default['default'].Event(EVENT_SHOW$3, { 5945 relatedTarget: previous 5946 }); 5947 5948 if (previous) { 5949 $__default['default'](previous).trigger(hideEvent); 5950 } 5951 5952 $__default['default'](this._element).trigger(showEvent); 5953 5954 if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) { 5955 return; 5956 } 5957 5958 if (selector) { 5959 target = document.querySelector(selector); 5960 } 5961 5962 this._activate(this._element, listElement); 5963 5964 var complete = function complete() { 5965 var hiddenEvent = $__default['default'].Event(EVENT_HIDDEN$3, { 5966 relatedTarget: _this._element 5967 }); 5968 var shownEvent = $__default['default'].Event(EVENT_SHOWN$3, { 5969 relatedTarget: previous 5970 }); 5971 $__default['default'](previous).trigger(hiddenEvent); 5972 $__default['default'](_this._element).trigger(shownEvent); 5973 }; 5974 5975 if (target) { 5976 this._activate(target, target.parentNode, complete); 5977 } else { 5978 complete(); 5979 } 5980 }; 5981 5982 _proto.dispose = function dispose() { 5983 $__default['default'].removeData(this._element, DATA_KEY$9); 5984 this._element = null; 5985 } // Private 5986 ; 5987 5988 _proto._activate = function _activate(element, container, callback) { 5989 var _this2 = this; 5990 5991 var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $__default['default'](container).find(SELECTOR_ACTIVE_UL) : $__default['default'](container).children(SELECTOR_ACTIVE$2); 5992 var active = activeElements[0]; 5993 var isTransitioning = callback && active && $__default['default'](active).hasClass(CLASS_NAME_FADE$4); 5994 5995 var complete = function complete() { 5996 return _this2._transitionComplete(element, active, callback); 5997 }; 5998 5999 if (active && isTransitioning) { 6000 var transitionDuration = Util.getTransitionDurationFromElement(active); 6001 $__default['default'](active).removeClass(CLASS_NAME_SHOW$6).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 6002 } else { 6003 complete(); 6004 } 6005 }; 6006 6007 _proto._transitionComplete = function _transitionComplete(element, active, callback) { 6008 if (active) { 6009 $__default['default'](active).removeClass(CLASS_NAME_ACTIVE$3); 6010 var dropdownChild = $__default['default'](active.parentNode).find(SELECTOR_DROPDOWN_ACTIVE_CHILD)[0]; 6011 6012 if (dropdownChild) { 6013 $__default['default'](dropdownChild).removeClass(CLASS_NAME_ACTIVE$3); 6014 } 6015 6016 if (active.getAttribute('role') === 'tab') { 6017 active.setAttribute('aria-selected', false); 6018 } 6019 } 6020 6021 $__default['default'](element).addClass(CLASS_NAME_ACTIVE$3); 6022 6023 if (element.getAttribute('role') === 'tab') { 6024 element.setAttribute('aria-selected', true); 6025 } 6026 6027 Util.reflow(element); 6028 6029 if (element.classList.contains(CLASS_NAME_FADE$4)) { 6030 element.classList.add(CLASS_NAME_SHOW$6); 6031 } 6032 6033 if (element.parentNode && $__default['default'](element.parentNode).hasClass(CLASS_NAME_DROPDOWN_MENU)) { 6034 var dropdownElement = $__default['default'](element).closest(SELECTOR_DROPDOWN$1)[0]; 6035 6036 if (dropdownElement) { 6037 var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(SELECTOR_DROPDOWN_TOGGLE$1)); 6038 $__default['default'](dropdownToggleList).addClass(CLASS_NAME_ACTIVE$3); 6039 } 6040 6041 element.setAttribute('aria-expanded', true); 6042 } 6043 6044 if (callback) { 6045 callback(); 6046 } 6047 } // Static 6048 ; 6049 6050 Tab._jQueryInterface = function _jQueryInterface(config) { 6051 return this.each(function () { 6052 var $this = $__default['default'](this); 6053 var data = $this.data(DATA_KEY$9); 6054 6055 if (!data) { 6056 data = new Tab(this); 6057 $this.data(DATA_KEY$9, data); 6058 } 6059 6060 if (typeof config === 'string') { 6061 if (typeof data[config] === 'undefined') { 6062 throw new TypeError("No method named \"" + config + "\""); 6063 } 6064 6065 data[config](); 6066 } 6067 }); 6068 }; 6069 6070 _createClass(Tab, null, [{ 6071 key: "VERSION", 6072 get: function get() { 6073 return VERSION$9; 6074 } 6075 }]); 6076 6077 return Tab; 6078 }(); 6079 /** 6080 * ------------------------------------------------------------------------ 6081 * Data Api implementation 6082 * ------------------------------------------------------------------------ 6083 */ 6084 6085 6086 $__default['default'](document).on(EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$4, function (event) { 6087 event.preventDefault(); 6088 6089 Tab._jQueryInterface.call($__default['default'](this), 'show'); 6090 }); 6091 /** 6092 * ------------------------------------------------------------------------ 6093 * jQuery 6094 * ------------------------------------------------------------------------ 6095 */ 6096 6097 $__default['default'].fn[NAME$9] = Tab._jQueryInterface; 6098 $__default['default'].fn[NAME$9].Constructor = Tab; 6099 6100 $__default['default'].fn[NAME$9].noConflict = function () { 6101 $__default['default'].fn[NAME$9] = JQUERY_NO_CONFLICT$9; 6102 return Tab._jQueryInterface; 6103 }; 6104 6105 /** 6106 * ------------------------------------------------------------------------ 6107 * Constants 6108 * ------------------------------------------------------------------------ 6109 */ 6110 6111 var NAME$a = 'toast'; 6112 var VERSION$a = '4.6.0'; 6113 var DATA_KEY$a = 'bs.toast'; 6114 var EVENT_KEY$a = "." + DATA_KEY$a; 6115 var JQUERY_NO_CONFLICT$a = $__default['default'].fn[NAME$a]; 6116 var EVENT_CLICK_DISMISS$1 = "click.dismiss" + EVENT_KEY$a; 6117 var EVENT_HIDE$4 = "hide" + EVENT_KEY$a; 6118 var EVENT_HIDDEN$4 = "hidden" + EVENT_KEY$a; 6119 var EVENT_SHOW$4 = "show" + EVENT_KEY$a; 6120 var EVENT_SHOWN$4 = "shown" + EVENT_KEY$a; 6121 var CLASS_NAME_FADE$5 = 'fade'; 6122 var CLASS_NAME_HIDE = 'hide'; 6123 var CLASS_NAME_SHOW$7 = 'show'; 6124 var CLASS_NAME_SHOWING = 'showing'; 6125 var DefaultType$7 = { 6126 animation: 'boolean', 6127 autohide: 'boolean', 6128 delay: 'number' 6129 }; 6130 var Default$7 = { 6131 animation: true, 6132 autohide: true, 6133 delay: 500 6134 }; 6135 var SELECTOR_DATA_DISMISS$1 = '[data-dismiss="toast"]'; 6136 /** 6137 * ------------------------------------------------------------------------ 6138 * Class Definition 6139 * ------------------------------------------------------------------------ 6140 */ 6141 6142 var Toast = /*#__PURE__*/function () { 6143 function Toast(element, config) { 6144 this._element = element; 6145 this._config = this._getConfig(config); 6146 this._timeout = null; 6147 6148 this._setListeners(); 6149 } // Getters 6150 6151 6152 var _proto = Toast.prototype; 6153 6154 // Public 6155 _proto.show = function show() { 6156 var _this = this; 6157 6158 var showEvent = $__default['default'].Event(EVENT_SHOW$4); 6159 $__default['default'](this._element).trigger(showEvent); 6160 6161 if (showEvent.isDefaultPrevented()) { 6162 return; 6163 } 6164 6165 this._clearTimeout(); 6166 6167 if (this._config.animation) { 6168 this._element.classList.add(CLASS_NAME_FADE$5); 6169 } 6170 6171 var complete = function complete() { 6172 _this._element.classList.remove(CLASS_NAME_SHOWING); 6173 6174 _this._element.classList.add(CLASS_NAME_SHOW$7); 6175 6176 $__default['default'](_this._element).trigger(EVENT_SHOWN$4); 6177 6178 if (_this._config.autohide) { 6179 _this._timeout = setTimeout(function () { 6180 _this.hide(); 6181 }, _this._config.delay); 6182 } 6183 }; 6184 6185 this._element.classList.remove(CLASS_NAME_HIDE); 6186 6187 Util.reflow(this._element); 6188 6189 this._element.classList.add(CLASS_NAME_SHOWING); 6190 6191 if (this._config.animation) { 6192 var transitionDuration = Util.getTransitionDurationFromElement(this._element); 6193 $__default['default'](this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 6194 } else { 6195 complete(); 6196 } 6197 }; 6198 6199 _proto.hide = function hide() { 6200 if (!this._element.classList.contains(CLASS_NAME_SHOW$7)) { 6201 return; 6202 } 6203 6204 var hideEvent = $__default['default'].Event(EVENT_HIDE$4); 6205 $__default['default'](this._element).trigger(hideEvent); 6206 6207 if (hideEvent.isDefaultPrevented()) { 6208 return; 6209 } 6210 6211 this._close(); 6212 }; 6213 6214 _proto.dispose = function dispose() { 6215 this._clearTimeout(); 6216 6217 if (this._element.classList.contains(CLASS_NAME_SHOW$7)) { 6218 this._element.classList.remove(CLASS_NAME_SHOW$7); 6219 } 6220 6221 $__default['default'](this._element).off(EVENT_CLICK_DISMISS$1); 6222 $__default['default'].removeData(this._element, DATA_KEY$a); 6223 this._element = null; 6224 this._config = null; 6225 } // Private 6226 ; 6227 6228 _proto._getConfig = function _getConfig(config) { 6229 config = _extends({}, Default$7, $__default['default'](this._element).data(), typeof config === 'object' && config ? config : {}); 6230 Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType); 6231 return config; 6232 }; 6233 6234 _proto._setListeners = function _setListeners() { 6235 var _this2 = this; 6236 6237 $__default['default'](this._element).on(EVENT_CLICK_DISMISS$1, SELECTOR_DATA_DISMISS$1, function () { 6238 return _this2.hide(); 6239 }); 6240 }; 6241 6242 _proto._close = function _close() { 6243 var _this3 = this; 6244 6245 var complete = function complete() { 6246 _this3._element.classList.add(CLASS_NAME_HIDE); 6247 6248 $__default['default'](_this3._element).trigger(EVENT_HIDDEN$4); 6249 }; 6250 6251 this._element.classList.remove(CLASS_NAME_SHOW$7); 6252 6253 if (this._config.animation) { 6254 var transitionDuration = Util.getTransitionDurationFromElement(this._element); 6255 $__default['default'](this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); 6256 } else { 6257 complete(); 6258 } 6259 }; 6260 6261 _proto._clearTimeout = function _clearTimeout() { 6262 clearTimeout(this._timeout); 6263 this._timeout = null; 6264 } // Static 6265 ; 6266 6267 Toast._jQueryInterface = function _jQueryInterface(config) { 6268 return this.each(function () { 6269 var $element = $__default['default'](this); 6270 var data = $element.data(DATA_KEY$a); 6271 6272 var _config = typeof config === 'object' && config; 6273 6274 if (!data) { 6275 data = new Toast(this, _config); 6276 $element.data(DATA_KEY$a, data); 6277 } 6278 6279 if (typeof config === 'string') { 6280 if (typeof data[config] === 'undefined') { 6281 throw new TypeError("No method named \"" + config + "\""); 6282 } 6283 6284 data[config](this); 6285 } 6286 }); 6287 }; 6288 6289 _createClass(Toast, null, [{ 6290 key: "VERSION", 6291 get: function get() { 6292 return VERSION$a; 6293 } 6294 }, { 6295 key: "DefaultType", 6296 get: function get() { 6297 return DefaultType$7; 6298 } 6299 }, { 6300 key: "Default", 6301 get: function get() { 6302 return Default$7; 6303 } 6304 }]); 6305 6306 return Toast; 6307 }(); 6308 /** 6309 * ------------------------------------------------------------------------ 6310 * jQuery 6311 * ------------------------------------------------------------------------ 6312 */ 6313 6314 6315 $__default['default'].fn[NAME$a] = Toast._jQueryInterface; 6316 $__default['default'].fn[NAME$a].Constructor = Toast; 6317 6318 $__default['default'].fn[NAME$a].noConflict = function () { 6319 $__default['default'].fn[NAME$a] = JQUERY_NO_CONFLICT$a; 6320 return Toast._jQueryInterface; 6321 }; 6322 6323 exports.Alert = Alert; 6324 exports.Button = Button; 6325 exports.Carousel = Carousel; 6326 exports.Collapse = Collapse; 6327 exports.Dropdown = Dropdown; 6328 exports.Modal = Modal; 6329 exports.Popover = Popover; 6330 exports.Scrollspy = ScrollSpy; 6331 exports.Tab = Tab; 6332 exports.Toast = Toast; 6333 exports.Tooltip = Tooltip; 6334 exports.Util = Util; 6335 6336 Object.defineProperty(exports, '__esModule', { value: true }); 6337 6338}))); 6339//# sourceMappingURL=bootstrap.js.map 6340 6341 6342/***/ }), 6343
vendor: 288,125 bytes, lines 6344-17227
6344/***/ "./node_modules/jquery/dist/jquery.js": 6345/*!********************************************!*\ 6346 !*** ./node_modules/jquery/dist/jquery.js ***! 6347 \********************************************/ 6348/*! no static exports found */ 6349/***/ (function(module, exports, __webpack_require__) { 6350 6351var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 6352 * jQuery JavaScript Library v3.5.1 6353 * https://jquery.com/ 6354 * 6355 * Includes Sizzle.js 6356 * https://sizzlejs.com/ 6357 * 6358 * Copyright JS Foundation and other contributors 6359 * Released under the MIT license 6360 * https://jquery.org/license 6361 * 6362 * Date: 2020-05-04T22:49Z 6363 */ 6364( function( global, factory ) { 6365 6366 "use strict"; 6367 6368 if ( true && typeof module.exports === "object" ) { 6369 6370 // For CommonJS and CommonJS-like environments where a proper `window` 6371 // is present, execute the factory and get jQuery. 6372 // For environments that do not have a `window` with a `document` 6373 // (such as Node.js), expose a factory as module.exports. 6374 // This accentuates the need for the creation of a real `window`. 6375 // e.g. var jQuery = require("jquery")(window); 6376 // See ticket #14549 for more info. 6377 module.exports = global.document ? 6378 factory( global, true ) : 6379 function( w ) { 6380 if ( !w.document ) { 6381 throw new Error( "jQuery requires a window with a document" ); 6382 } 6383 return factory( w ); 6384 }; 6385 } else { 6386 factory( global ); 6387 } 6388 6389// Pass this if window is not defined yet 6390} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { 6391 6392// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1 6393// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode 6394// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common 6395// enough that all such attempts are guarded in a try block. 6396"use strict"; 6397 6398var arr = []; 6399 6400var getProto = Object.getPrototypeOf; 6401 6402var slice = arr.slice; 6403 6404var flat = arr.flat ? function( array ) { 6405 return arr.flat.call( array ); 6406} : function( array ) { 6407 return arr.concat.apply( [], array ); 6408}; 6409 6410 6411var push = arr.push; 6412 6413var indexOf = arr.indexOf; 6414 6415var class2type = {}; 6416 6417var toString = class2type.toString; 6418 6419var hasOwn = class2type.hasOwnProperty; 6420 6421var fnToString = hasOwn.toString; 6422 6423var ObjectFunctionString = fnToString.call( Object ); 6424 6425var support = {}; 6426 6427var isFunction = function isFunction( obj ) { 6428 6429 // Support: Chrome <=57, Firefox <=52 6430 // In some browsers, typeof returns "function" for HTML <object> elements 6431 // (i.e., `typeof document.createElement( "object" ) === "function"`). 6432 // We don't want to classify *any* DOM node as a function. 6433 return typeof obj === "function" && typeof obj.nodeType !== "number"; 6434 }; 6435 6436 6437var isWindow = function isWindow( obj ) { 6438 return obj != null && obj === obj.window; 6439 }; 6440 6441 6442var document = window.document; 6443 6444 6445 6446 var preservedScriptAttributes = { 6447 type: true, 6448 src: true, 6449 nonce: true, 6450 noModule: true 6451 }; 6452 6453 function DOMEval( code, node, doc ) { 6454 doc = doc || document; 6455 6456 var i, val, 6457 script = doc.createElement( "script" ); 6458 6459 script.text = code; 6460 if ( node ) { 6461 for ( i in preservedScriptAttributes ) { 6462 6463 // Support: Firefox 64+, Edge 18+ 6464 // Some browsers don't support the "nonce" property on scripts. 6465 // On the other hand, just using `getAttribute` is not enough as 6466 // the `nonce` attribute is reset to an empty string whenever it 6467 // becomes browsing-context connected. 6468 // See https://github.com/whatwg/html/issues/2369 6469 // See https://html.spec.whatwg.org/#nonce-attributes 6470 // The `node.getAttribute` check was added for the sake of 6471 // `jQuery.globalEval` so that it can fake a nonce-containing node 6472 // via an object. 6473 val = node[ i ] || node.getAttribute && node.getAttribute( i ); 6474 if ( val ) { 6475 script.setAttribute( i, val ); 6476 } 6477 } 6478 } 6479 doc.head.appendChild( script ).parentNode.removeChild( script ); 6480 } 6481 6482 6483function toType( obj ) { 6484 if ( obj == null ) { 6485 return obj + ""; 6486 } 6487 6488 // Support: Android <=2.3 only (functionish RegExp) 6489 return typeof obj === "object" || typeof obj === "function" ? 6490 class2type[ toString.call( obj ) ] || "object" : 6491 typeof obj; 6492} 6493/* global Symbol */ 6494// Defining this global in .eslintrc.json would create a danger of using the global 6495// unguarded in another place, it seems safer to define global only for this module 6496 6497 6498 6499var 6500 version = "3.5.1", 6501 6502 // Define a local copy of jQuery 6503 jQuery = function( selector, context ) { 6504 6505 // The jQuery object is actually just the init constructor 'enhanced' 6506 // Need init if jQuery is called (just allow error to be thrown if not included) 6507 return new jQuery.fn.init( selector, context ); 6508 }; 6509 6510jQuery.fn = jQuery.prototype = { 6511 6512 // The current version of jQuery being used 6513 jquery: version, 6514 6515 constructor: jQuery, 6516 6517 // The default length of a jQuery object is 0 6518 length: 0, 6519 6520 toArray: function() { 6521 return slice.call( this ); 6522 }, 6523 6524 // Get the Nth element in the matched element set OR 6525 // Get the whole matched element set as a clean array 6526 get: function( num ) { 6527 6528 // Return all the elements in a clean array 6529 if ( num == null ) { 6530 return slice.call( this ); 6531 } 6532 6533 // Return just the one element from the set 6534 return num < 0 ? this[ num + this.length ] : this[ num ]; 6535 }, 6536 6537 // Take an array of elements and push it onto the stack 6538 // (returning the new matched element set) 6539 pushStack: function( elems ) { 6540 6541 // Build a new jQuery matched element set 6542 var ret = jQuery.merge( this.constructor(), elems ); 6543 6544 // Add the old object onto the stack (as a reference) 6545 ret.prevObject = this; 6546 6547 // Return the newly-formed element set 6548 return ret; 6549 }, 6550 6551 // Execute a callback for every element in the matched set. 6552 each: function( callback ) { 6553 return jQuery.each( this, callback ); 6554 }, 6555 6556 map: function( callback ) { 6557 return this.pushStack( jQuery.map( this, function( elem, i ) { 6558 return callback.call( elem, i, elem ); 6559 } ) ); 6560 }, 6561 6562 slice: function() { 6563 return this.pushStack( slice.apply( this, arguments ) ); 6564 }, 6565 6566 first: function() { 6567 return this.eq( 0 ); 6568 }, 6569 6570 last: function() { 6571 return this.eq( -1 ); 6572 }, 6573 6574 even: function() { 6575 return this.pushStack( jQuery.grep( this, function( _elem, i ) { 6576 return ( i + 1 ) % 2; 6577 } ) ); 6578 }, 6579 6580 odd: function() { 6581 return this.pushStack( jQuery.grep( this, function( _elem, i ) { 6582 return i % 2; 6583 } ) ); 6584 }, 6585 6586 eq: function( i ) { 6587 var len = this.length, 6588 j = +i + ( i < 0 ? len : 0 ); 6589 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); 6590 }, 6591 6592 end: function() { 6593 return this.prevObject || this.constructor(); 6594 }, 6595 6596 // For internal use only. 6597 // Behaves like an Array's method, not like a jQuery method. 6598 push: push, 6599 sort: arr.sort, 6600 splice: arr.splice 6601}; 6602 6603jQuery.extend = jQuery.fn.extend = function() { 6604 var options, name, src, copy, copyIsArray, clone, 6605 target = arguments[ 0 ] || {}, 6606 i = 1, 6607 length = arguments.length, 6608 deep = false; 6609 6610 // Handle a deep copy situation 6611 if ( typeof target === "boolean" ) { 6612 deep = target; 6613 6614 // Skip the boolean and the target 6615 target = arguments[ i ] || {}; 6616 i++; 6617 } 6618 6619 // Handle case when target is a string or something (possible in deep copy) 6620 if ( typeof target !== "object" && !isFunction( target ) ) { 6621 target = {}; 6622 } 6623 6624 // Extend jQuery itself if only one argument is passed 6625 if ( i === length ) { 6626 target = this; 6627 i--; 6628 } 6629 6630 for ( ; i < length; i++ ) { 6631 6632 // Only deal with non-null/undefined values 6633 if ( ( options = arguments[ i ] ) != null ) { 6634 6635 // Extend the base object 6636 for ( name in options ) { 6637 copy = options[ name ]; 6638 6639 // Prevent Object.prototype pollution 6640 // Prevent never-ending loop 6641 if ( name === "__proto__" || target === copy ) { 6642 continue; 6643 } 6644 6645 // Recurse if we're merging plain objects or arrays 6646 if ( deep && copy && ( jQuery.isPlainObject( copy ) || 6647 ( copyIsArray = Array.isArray( copy ) ) ) ) { 6648 src = target[ name ]; 6649 6650 // Ensure proper type for the source value 6651 if ( copyIsArray && !Array.isArray( src ) ) { 6652 clone = []; 6653 } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) { 6654 clone = {}; 6655 } else { 6656 clone = src; 6657 } 6658 copyIsArray = false; 6659 6660 // Never move original objects, clone them 6661 target[ name ] = jQuery.extend( deep, clone, copy ); 6662 6663 // Don't bring in undefined values 6664 } else if ( copy !== undefined ) { 6665 target[ name ] = copy; 6666 } 6667 } 6668 } 6669 } 6670 6671 // Return the modified object 6672 return target; 6673}; 6674 6675jQuery.extend( { 6676 6677 // Unique for each copy of jQuery on the page 6678 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), 6679 6680 // Assume jQuery is ready without the ready module 6681 isReady: true, 6682 6683 error: function( msg ) { 6684 throw new Error( msg ); 6685 }, 6686 6687 noop: function() {}, 6688 6689 isPlainObject: function( obj ) { 6690 var proto, Ctor; 6691 6692 // Detect obvious negatives 6693 // Use toString instead of jQuery.type to catch host objects 6694 if ( !obj || toString.call( obj ) !== "[object Object]" ) { 6695 return false; 6696 } 6697 6698 proto = getProto( obj ); 6699 6700 // Objects with no prototype (e.g., `Object.create( null )`) are plain 6701 if ( !proto ) { 6702 return true; 6703 } 6704 6705 // Objects with prototype are plain iff they were constructed by a global Object function 6706 Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; 6707 return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; 6708 }, 6709 6710 isEmptyObject: function( obj ) { 6711 var name; 6712 6713 for ( name in obj ) { 6714 return false; 6715 } 6716 return true; 6717 }, 6718 6719 // Evaluates a script in a provided context; falls back to the global one 6720 // if not specified. 6721 globalEval: function( code, options, doc ) { 6722 DOMEval( code, { nonce: options && options.nonce }, doc ); 6723 }, 6724 6725 each: function( obj, callback ) { 6726 var length, i = 0; 6727 6728 if ( isArrayLike( obj ) ) { 6729 length = obj.length; 6730 for ( ; i < length; i++ ) { 6731 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 6732 break; 6733 } 6734 } 6735 } else { 6736 for ( i in obj ) { 6737 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 6738 break; 6739 } 6740 } 6741 } 6742 6743 return obj; 6744 }, 6745 6746 // results is for internal usage only 6747 makeArray: function( arr, results ) { 6748 var ret = results || []; 6749 6750 if ( arr != null ) { 6751 if ( isArrayLike( Object( arr ) ) ) { 6752 jQuery.merge( ret, 6753 typeof arr === "string" ? 6754 [ arr ] : arr 6755 ); 6756 } else { 6757 push.call( ret, arr ); 6758 } 6759 } 6760 6761 return ret; 6762 }, 6763 6764 inArray: function( elem, arr, i ) { 6765 return arr == null ? -1 : indexOf.call( arr, elem, i ); 6766 }, 6767 6768 // Support: Android <=4.0 only, PhantomJS 1 only 6769 // push.apply(_, arraylike) throws on ancient WebKit 6770 merge: function( first, second ) { 6771 var len = +second.length, 6772 j = 0, 6773 i = first.length; 6774 6775 for ( ; j < len; j++ ) { 6776 first[ i++ ] = second[ j ]; 6777 } 6778 6779 first.length = i; 6780 6781 return first; 6782 }, 6783 6784 grep: function( elems, callback, invert ) { 6785 var callbackInverse, 6786 matches = [], 6787 i = 0, 6788 length = elems.length, 6789 callbackExpect = !invert; 6790 6791 // Go through the array, only saving the items 6792 // that pass the validator function 6793 for ( ; i < length; i++ ) { 6794 callbackInverse = !callback( elems[ i ], i ); 6795 if ( callbackInverse !== callbackExpect ) { 6796 matches.push( elems[ i ] ); 6797 } 6798 } 6799 6800 return matches; 6801 }, 6802 6803 // arg is for internal usage only 6804 map: function( elems, callback, arg ) { 6805 var length, value, 6806 i = 0, 6807 ret = []; 6808 6809 // Go through the array, translating each of the items to their new values 6810 if ( isArrayLike( elems ) ) { 6811 length = elems.length; 6812 for ( ; i < length; i++ ) { 6813 value = callback( elems[ i ], i, arg ); 6814 6815 if ( value != null ) { 6816 ret.push( value ); 6817 } 6818 } 6819 6820 // Go through every key on the object, 6821 } else { 6822 for ( i in elems ) { 6823 value = callback( elems[ i ], i, arg ); 6824 6825 if ( value != null ) { 6826 ret.push( value ); 6827 } 6828 } 6829 } 6830 6831 // Flatten any nested arrays 6832 return flat( ret ); 6833 }, 6834 6835 // A global GUID counter for objects 6836 guid: 1, 6837 6838 // jQuery.support is not used in Core but other projects attach their 6839 // properties to it so it needs to exist. 6840 support: support 6841} ); 6842 6843if ( typeof Symbol === "function" ) { 6844 jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; 6845} 6846 6847// Populate the class2type map 6848jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), 6849function( _i, name ) { 6850 class2type[ "[object " + name + "]" ] = name.toLowerCase(); 6851} ); 6852 6853function isArrayLike( obj ) { 6854 6855 // Support: real iOS 8.2 only (not reproducible in simulator) 6856 // `in` check used to prevent JIT error (gh-2145) 6857 // hasOwn isn't used here due to false negatives 6858 // regarding Nodelist length in IE 6859 var length = !!obj && "length" in obj && obj.length, 6860 type = toType( obj ); 6861 6862 if ( isFunction( obj ) || isWindow( obj ) ) { 6863 return false; 6864 } 6865 6866 return type === "array" || length === 0 || 6867 typeof length === "number" && length > 0 && ( length - 1 ) in obj; 6868} 6869var Sizzle = 6870/*! 6871 * Sizzle CSS Selector Engine v2.3.5 6872 * https://sizzlejs.com/ 6873 * 6874 * Copyright JS Foundation and other contributors 6875 * Released under the MIT license 6876 * https://js.foundation/ 6877 * 6878 * Date: 2020-03-14 6879 */ 6880( function( window ) { 6881var i, 6882 support, 6883 Expr, 6884 getText, 6885 isXML, 6886 tokenize, 6887 compile, 6888 select, 6889 outermostContext, 6890 sortInput, 6891 hasDuplicate, 6892 6893 // Local document vars 6894 setDocument, 6895 document, 6896 docElem, 6897 documentIsHTML, 6898 rbuggyQSA, 6899 rbuggyMatches, 6900 matches, 6901 contains, 6902 6903 // Instance-specific data 6904 expando = "sizzle" + 1 * new Date(), 6905 preferredDoc = window.document, 6906 dirruns = 0, 6907 done = 0, 6908 classCache = createCache(), 6909 tokenCache = createCache(), 6910 compilerCache = createCache(), 6911 nonnativeSelectorCache = createCache(), 6912 sortOrder = function( a, b ) { 6913 if ( a === b ) { 6914 hasDuplicate = true; 6915 } 6916 return 0; 6917 }, 6918 6919 // Instance methods 6920 hasOwn = ( {} ).hasOwnProperty, 6921 arr = [], 6922 pop = arr.pop, 6923 pushNative = arr.push, 6924 push = arr.push, 6925 slice = arr.slice, 6926 6927 // Use a stripped-down indexOf as it's faster than native 6928 // https://jsperf.com/thor-indexof-vs-for/5 6929 indexOf = function( list, elem ) { 6930 var i = 0, 6931 len = list.length; 6932 for ( ; i < len; i++ ) { 6933 if ( list[ i ] === elem ) { 6934 return i; 6935 } 6936 } 6937 return -1; 6938 }, 6939 6940 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" + 6941 "ismap|loop|multiple|open|readonly|required|scoped", 6942 6943 // Regular expressions 6944 6945 // http://www.w3.org/TR/css3-selectors/#whitespace 6946 whitespace = "[\\x20\\t\\r\\n\\f]", 6947 6948 // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram 6949 identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + 6950 "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", 6951 6952 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors 6953 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + 6954 6955 // Operator (capture 2) 6956 "*([*^$|!~]?=)" + whitespace + 6957 6958 // "Attribute values must be CSS identifiers [capture 5] 6959 // or strings [capture 3 or capture 4]" 6960 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + 6961 whitespace + "*\\]", 6962 6963 pseudos = ":(" + identifier + ")(?:\\((" + 6964 6965 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: 6966 // 1. quoted (capture 3; capture 4 or capture 5) 6967 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + 6968 6969 // 2. simple (capture 6) 6970 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + 6971 6972 // 3. anything else (capture 2) 6973 ".*" + 6974 ")\\)|)", 6975 6976 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter 6977 rwhitespace = new RegExp( whitespace + "+", "g" ), 6978 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + 6979 whitespace + "+$", "g" ), 6980 6981 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), 6982 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + 6983 "*" ), 6984 rdescend = new RegExp( whitespace + "|>" ), 6985 6986 rpseudo = new RegExp( pseudos ), 6987 ridentifier = new RegExp( "^" + identifier + "$" ), 6988 6989 matchExpr = { 6990 "ID": new RegExp( "^#(" + identifier + ")" ), 6991 "CLASS": new RegExp( "^\\.(" + identifier + ")" ), 6992 "TAG": new RegExp( "^(" + identifier + "|[*])" ), 6993 "ATTR": new RegExp( "^" + attributes ), 6994 "PSEUDO": new RegExp( "^" + pseudos ), 6995 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + 6996 whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + 6997 whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), 6998 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), 6999 7000 // For use in libraries implementing .is() 7001 // We use this for POS matching in `select` 7002 "needsContext": new RegExp( "^" + whitespace + 7003 "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + 7004 "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) 7005 }, 7006 7007 rhtml = /HTML$/i, 7008 rinputs = /^(?:input|select|textarea|button)$/i, 7009 rheader = /^h\d$/i, 7010 7011 rnative = /^[^{]+\{\s*\[native \w/, 7012 7013 // Easily-parseable/retrievable ID or TAG or CLASS selectors 7014 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, 7015 7016 rsibling = /[+~]/, 7017 7018 // CSS escapes 7019 // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters 7020 runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ), 7021 funescape = function( escape, nonHex ) { 7022 var high = "0x" + escape.slice( 1 ) - 0x10000; 7023 7024 return nonHex ? 7025 7026 // Strip the backslash prefix from a non-hex escape sequence 7027 nonHex : 7028 7029 // Replace a hexadecimal escape sequence with the encoded Unicode code point 7030 // Support: IE <=11+ 7031 // For values outside the Basic Multilingual Plane (BMP), manually construct a 7032 // surrogate pair 7033 high < 0 ? 7034 String.fromCharCode( high + 0x10000 ) : 7035 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); 7036 }, 7037 7038 // CSS string/identifier serialization 7039 // https://drafts.csswg.org/cssom/#common-serializing-idioms 7040 rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g, 7041 fcssescape = function( ch, asCodePoint ) { 7042 if ( asCodePoint ) { 7043 7044 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER 7045 if ( ch === "\0" ) { 7046 return "\uFFFD"; 7047 } 7048 7049 // Control characters and (dependent upon position) numbers get escaped as code points 7050 return ch.slice( 0, -1 ) + "\\" + 7051 ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; 7052 } 7053 7054 // Other potentially-special ASCII characters get backslash-escaped 7055 return "\\" + ch; 7056 }, 7057 7058 // Used for iframes 7059 // See setDocument() 7060 // Removing the function wrapper causes a "Permission Denied" 7061 // error in IE 7062 unloadHandler = function() { 7063 setDocument(); 7064 }, 7065 7066 inDisabledFieldset = addCombinator( 7067 function( elem ) { 7068 return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset"; 7069 }, 7070 { dir: "parentNode", next: "legend" } 7071 ); 7072 7073// Optimize for push.apply( _, NodeList ) 7074try { 7075 push.apply( 7076 ( arr = slice.call( preferredDoc.childNodes ) ), 7077 preferredDoc.childNodes 7078 ); 7079 7080 // Support: Android<4.0 7081 // Detect silently failing push.apply 7082 // eslint-disable-next-line no-unused-expressions 7083 arr[ preferredDoc.childNodes.length ].nodeType; 7084} catch ( e ) { 7085 push = { apply: arr.length ? 7086 7087 // Leverage slice if possible 7088 function( target, els ) { 7089 pushNative.apply( target, slice.call( els ) ); 7090 } : 7091 7092 // Support: IE<9 7093 // Otherwise append directly 7094 function( target, els ) { 7095 var j = target.length, 7096 i = 0; 7097 7098 // Can't trust NodeList.length 7099 while ( ( target[ j++ ] = els[ i++ ] ) ) {} 7100 target.length = j - 1; 7101 } 7102 }; 7103} 7104 7105function Sizzle( selector, context, results, seed ) { 7106 var m, i, elem, nid, match, groups, newSelector, 7107 newContext = context && context.ownerDocument, 7108 7109 // nodeType defaults to 9, since context defaults to document 7110 nodeType = context ? context.nodeType : 9; 7111 7112 results = results || []; 7113 7114 // Return early from calls with invalid selector or context 7115 if ( typeof selector !== "string" || !selector || 7116 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { 7117 7118 return results; 7119 } 7120 7121 // Try to shortcut find operations (as opposed to filters) in HTML documents 7122 if ( !seed ) { 7123 setDocument( context ); 7124 context = context || document; 7125 7126 if ( documentIsHTML ) { 7127 7128 // If the selector is sufficiently simple, try using a "get*By*" DOM method 7129 // (excepting DocumentFragment context, where the methods don't exist) 7130 if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) { 7131 7132 // ID selector 7133 if ( ( m = match[ 1 ] ) ) { 7134 7135 // Document context 7136 if ( nodeType === 9 ) { 7137 if ( ( elem = context.getElementById( m ) ) ) { 7138 7139 // Support: IE, Opera, Webkit 7140 // TODO: identify versions 7141 // getElementById can match elements by name instead of ID 7142 if ( elem.id === m ) { 7143 results.push( elem ); 7144 return results; 7145 } 7146 } else { 7147 return results; 7148 } 7149 7150 // Element context 7151 } else { 7152 7153 // Support: IE, Opera, Webkit 7154 // TODO: identify versions 7155 // getElementById can match elements by name instead of ID 7156 if ( newContext && ( elem = newContext.getElementById( m ) ) && 7157 contains( context, elem ) && 7158 elem.id === m ) { 7159 7160 results.push( elem ); 7161 return results; 7162 } 7163 } 7164 7165 // Type selector 7166 } else if ( match[ 2 ] ) { 7167 push.apply( results, context.getElementsByTagName( selector ) ); 7168 return results; 7169 7170 // Class selector 7171 } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName && 7172 context.getElementsByClassName ) { 7173 7174 push.apply( results, context.getElementsByClassName( m ) ); 7175 return results; 7176 } 7177 } 7178 7179 // Take advantage of querySelectorAll 7180 if ( support.qsa && 7181 !nonnativeSelectorCache[ selector + " " ] && 7182 ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) && 7183 7184 // Support: IE 8 only 7185 // Exclude object elements 7186 ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) { 7187 7188 newSelector = selector; 7189 newContext = context; 7190 7191 // qSA considers elements outside a scoping root when evaluating child or 7192 // descendant combinators, which is not what we want. 7193 // In such cases, we work around the behavior by prefixing every selector in the 7194 // list with an ID selector referencing the scope context. 7195 // The technique has to be used as well when a leading combinator is used 7196 // as such selectors are not recognized by querySelectorAll. 7197 // Thanks to Andrew Dupont for this technique. 7198 if ( nodeType === 1 && 7199 ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) { 7200 7201 // Expand context for sibling selectors 7202 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || 7203 context; 7204 7205 // We can use :scope instead of the ID hack if the browser 7206 // supports it & if we're not changing the context. 7207 if ( newContext !== context || !support.scope ) { 7208 7209 // Capture the context ID, setting it first if necessary 7210 if ( ( nid = context.getAttribute( "id" ) ) ) { 7211 nid = nid.replace( rcssescape, fcssescape ); 7212 } else { 7213 context.setAttribute( "id", ( nid = expando ) ); 7214 } 7215 } 7216 7217 // Prefix every selector in the list 7218 groups = tokenize( selector ); 7219 i = groups.length; 7220 while ( i-- ) { 7221 groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " + 7222 toSelector( groups[ i ] ); 7223 } 7224 newSelector = groups.join( "," ); 7225 } 7226 7227 try { 7228 push.apply( results, 7229 newContext.querySelectorAll( newSelector ) 7230 ); 7231 return results; 7232 } catch ( qsaError ) { 7233 nonnativeSelectorCache( selector, true ); 7234 } finally { 7235 if ( nid === expando ) { 7236 context.removeAttribute( "id" ); 7237 } 7238 } 7239 } 7240 } 7241 } 7242 7243 // All others 7244 return select( selector.replace( rtrim, "$1" ), context, results, seed ); 7245} 7246 7247/** 7248 * Create key-value caches of limited size 7249 * @returns {function(string, object)} Returns the Object data after storing it on itself with 7250 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) 7251 * deleting the oldest entry 7252 */ 7253function createCache() { 7254 var keys = []; 7255 7256 function cache( key, value ) { 7257 7258 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) 7259 if ( keys.push( key + " " ) > Expr.cacheLength ) { 7260 7261 // Only keep the most recent entries 7262 delete cache[ keys.shift() ]; 7263 } 7264 return ( cache[ key + " " ] = value ); 7265 } 7266 return cache; 7267} 7268 7269/** 7270 * Mark a function for special use by Sizzle 7271 * @param {Function} fn The function to mark 7272 */ 7273function markFunction( fn ) { 7274 fn[ expando ] = true; 7275 return fn; 7276} 7277 7278/** 7279 * Support testing using an element 7280 * @param {Function} fn Passed the created element and returns a boolean result 7281 */ 7282function assert( fn ) { 7283 var el = document.createElement( "fieldset" ); 7284 7285 try { 7286 return !!fn( el ); 7287 } catch ( e ) { 7288 return false; 7289 } finally { 7290 7291 // Remove from its parent by default 7292 if ( el.parentNode ) { 7293 el.parentNode.removeChild( el ); 7294 } 7295 7296 // release memory in IE 7297 el = null; 7298 } 7299} 7300 7301/** 7302 * Adds the same handler for all of the specified attrs 7303 * @param {String} attrs Pipe-separated list of attributes 7304 * @param {Function} handler The method that will be applied 7305 */ 7306function addHandle( attrs, handler ) { 7307 var arr = attrs.split( "|" ), 7308 i = arr.length; 7309 7310 while ( i-- ) { 7311 Expr.attrHandle[ arr[ i ] ] = handler; 7312 } 7313} 7314 7315/** 7316 * Checks document order of two siblings 7317 * @param {Element} a 7318 * @param {Element} b 7319 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b 7320 */ 7321function siblingCheck( a, b ) { 7322 var cur = b && a, 7323 diff = cur && a.nodeType === 1 && b.nodeType === 1 && 7324 a.sourceIndex - b.sourceIndex; 7325 7326 // Use IE sourceIndex if available on both nodes 7327 if ( diff ) { 7328 return diff; 7329 } 7330 7331 // Check if b follows a 7332 if ( cur ) { 7333 while ( ( cur = cur.nextSibling ) ) { 7334 if ( cur === b ) { 7335 return -1; 7336 } 7337 } 7338 } 7339 7340 return a ? 1 : -1; 7341} 7342 7343/** 7344 * Returns a function to use in pseudos for input types 7345 * @param {String} type 7346 */ 7347function createInputPseudo( type ) { 7348 return function( elem ) { 7349 var name = elem.nodeName.toLowerCase(); 7350 return name === "input" && elem.type === type; 7351 }; 7352} 7353 7354/** 7355 * Returns a function to use in pseudos for buttons 7356 * @param {String} type 7357 */ 7358function createButtonPseudo( type ) { 7359 return function( elem ) { 7360 var name = elem.nodeName.toLowerCase(); 7361 return ( name === "input" || name === "button" ) && elem.type === type; 7362 }; 7363} 7364 7365/** 7366 * Returns a function to use in pseudos for :enabled/:disabled 7367 * @param {Boolean} disabled true for :disabled; false for :enabled 7368 */ 7369function createDisabledPseudo( disabled ) { 7370 7371 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable 7372 return function( elem ) { 7373 7374 // Only certain elements can match :enabled or :disabled 7375 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled 7376 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled 7377 if ( "form" in elem ) { 7378 7379 // Check for inherited disabledness on relevant non-disabled elements: 7380 // * listed form-associated elements in a disabled fieldset 7381 // https://html.spec.whatwg.org/multipage/forms.html#category-listed 7382 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled 7383 // * option elements in a disabled optgroup 7384 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled 7385 // All such elements have a "form" property. 7386 if ( elem.parentNode && elem.disabled === false ) { 7387 7388 // Option elements defer to a parent optgroup if present 7389 if ( "label" in elem ) { 7390 if ( "label" in elem.parentNode ) { 7391 return elem.parentNode.disabled === disabled; 7392 } else { 7393 return elem.disabled === disabled; 7394 } 7395 } 7396 7397 // Support: IE 6 - 11 7398 // Use the isDisabled shortcut property to check for disabled fieldset ancestors 7399 return elem.isDisabled === disabled || 7400 7401 // Where there is no isDisabled, check manually 7402 /* jshint -W018 */ 7403 elem.isDisabled !== !disabled && 7404 inDisabledFieldset( elem ) === disabled; 7405 } 7406 7407 return elem.disabled === disabled; 7408 7409 // Try to winnow out elements that can't be disabled before trusting the disabled property. 7410 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't 7411 // even exist on them, let alone have a boolean value. 7412 } else if ( "label" in elem ) { 7413 return elem.disabled === disabled; 7414 } 7415 7416 // Remaining elements are neither :enabled nor :disabled 7417 return false; 7418 }; 7419} 7420 7421/** 7422 * Returns a function to use in pseudos for positionals 7423 * @param {Function} fn 7424 */ 7425function createPositionalPseudo( fn ) { 7426 return markFunction( function( argument ) { 7427 argument = +argument; 7428 return markFunction( function( seed, matches ) { 7429 var j, 7430 matchIndexes = fn( [], seed.length, argument ), 7431 i = matchIndexes.length; 7432 7433 // Match elements found at the specified indexes 7434 while ( i-- ) { 7435 if ( seed[ ( j = matchIndexes[ i ] ) ] ) { 7436 seed[ j ] = !( matches[ j ] = seed[ j ] ); 7437 } 7438 } 7439 } ); 7440 } ); 7441} 7442 7443/** 7444 * Checks a node for validity as a Sizzle context 7445 * @param {Element|Object=} context 7446 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value 7447 */ 7448function testContext( context ) { 7449 return context && typeof context.getElementsByTagName !== "undefined" && context; 7450} 7451 7452// Expose support vars for convenience 7453support = Sizzle.support = {}; 7454 7455/** 7456 * Detects XML nodes 7457 * @param {Element|Object} elem An element or a document 7458 * @returns {Boolean} True iff elem is a non-HTML XML node 7459 */ 7460isXML = Sizzle.isXML = function( elem ) { 7461 var namespace = elem.namespaceURI, 7462 docElem = ( elem.ownerDocument || elem ).documentElement; 7463 7464 // Support: IE <=8 7465 // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes 7466 // https://bugs.jquery.com/ticket/4833 7467 return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" ); 7468}; 7469 7470/** 7471 * Sets document-related variables once based on the current document 7472 * @param {Element|Object} [doc] An element or document object to use to set the document 7473 * @returns {Object} Returns the current document 7474 */ 7475setDocument = Sizzle.setDocument = function( node ) { 7476 var hasCompare, subWindow, 7477 doc = node ? node.ownerDocument || node : preferredDoc; 7478 7479 // Return early if doc is invalid or already selected 7480 // Support: IE 11+, Edge 17 - 18+ 7481 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 7482 // two documents; shallow comparisons work. 7483 // eslint-disable-next-line eqeqeq 7484 if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) { 7485 return document; 7486 } 7487 7488 // Update global variables 7489 document = doc; 7490 docElem = document.documentElement; 7491 documentIsHTML = !isXML( document ); 7492 7493 // Support: IE 9 - 11+, Edge 12 - 18+ 7494 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) 7495 // Support: IE 11+, Edge 17 - 18+ 7496 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 7497 // two documents; shallow comparisons work. 7498 // eslint-disable-next-line eqeqeq 7499 if ( preferredDoc != document && 7500 ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { 7501 7502 // Support: IE 11, Edge 7503 if ( subWindow.addEventListener ) { 7504 subWindow.addEventListener( "unload", unloadHandler, false ); 7505 7506 // Support: IE 9 - 10 only 7507 } else if ( subWindow.attachEvent ) { 7508 subWindow.attachEvent( "onunload", unloadHandler ); 7509 } 7510 } 7511 7512 // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only, 7513 // Safari 4 - 5 only, Opera <=11.6 - 12.x only 7514 // IE/Edge & older browsers don't support the :scope pseudo-class. 7515 // Support: Safari 6.0 only 7516 // Safari 6.0 supports :scope but it's an alias of :root there. 7517 support.scope = assert( function( el ) { 7518 docElem.appendChild( el ).appendChild( document.createElement( "div" ) ); 7519 return typeof el.querySelectorAll !== "undefined" && 7520 !el.querySelectorAll( ":scope fieldset div" ).length; 7521 } ); 7522 7523 /* Attributes 7524 ---------------------------------------------------------------------- */ 7525 7526 // Support: IE<8 7527 // Verify that getAttribute really returns attributes and not properties 7528 // (excepting IE8 booleans) 7529 support.attributes = assert( function( el ) { 7530 el.className = "i"; 7531 return !el.getAttribute( "className" ); 7532 } ); 7533 7534 /* getElement(s)By* 7535 ---------------------------------------------------------------------- */ 7536 7537 // Check if getElementsByTagName("*") returns only elements 7538 support.getElementsByTagName = assert( function( el ) { 7539 el.appendChild( document.createComment( "" ) ); 7540 return !el.getElementsByTagName( "*" ).length; 7541 } ); 7542 7543 // Support: IE<9 7544 support.getElementsByClassName = rnative.test( document.getElementsByClassName ); 7545 7546 // Support: IE<10 7547 // Check if getElementById returns elements by name 7548 // The broken getElementById methods don't pick up programmatically-set names, 7549 // so use a roundabout getElementsByName test 7550 support.getById = assert( function( el ) { 7551 docElem.appendChild( el ).id = expando; 7552 return !document.getElementsByName || !document.getElementsByName( expando ).length; 7553 } ); 7554 7555 // ID filter and find 7556 if ( support.getById ) { 7557 Expr.filter[ "ID" ] = function( id ) { 7558 var attrId = id.replace( runescape, funescape ); 7559 return function( elem ) { 7560 return elem.getAttribute( "id" ) === attrId; 7561 }; 7562 }; 7563 Expr.find[ "ID" ] = function( id, context ) { 7564 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 7565 var elem = context.getElementById( id ); 7566 return elem ? [ elem ] : []; 7567 } 7568 }; 7569 } else { 7570 Expr.filter[ "ID" ] = function( id ) { 7571 var attrId = id.replace( runescape, funescape ); 7572 return function( elem ) { 7573 var node = typeof elem.getAttributeNode !== "undefined" && 7574 elem.getAttributeNode( "id" ); 7575 return node && node.value === attrId; 7576 }; 7577 }; 7578 7579 // Support: IE 6 - 7 only 7580 // getElementById is not reliable as a find shortcut 7581 Expr.find[ "ID" ] = function( id, context ) { 7582 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 7583 var node, i, elems, 7584 elem = context.getElementById( id ); 7585 7586 if ( elem ) { 7587 7588 // Verify the id attribute 7589 node = elem.getAttributeNode( "id" ); 7590 if ( node && node.value === id ) { 7591 return [ elem ]; 7592 } 7593 7594 // Fall back on getElementsByName 7595 elems = context.getElementsByName( id ); 7596 i = 0; 7597 while ( ( elem = elems[ i++ ] ) ) { 7598 node = elem.getAttributeNode( "id" ); 7599 if ( node && node.value === id ) { 7600 return [ elem ]; 7601 } 7602 } 7603 } 7604 7605 return []; 7606 } 7607 }; 7608 } 7609 7610 // Tag 7611 Expr.find[ "TAG" ] = support.getElementsByTagName ? 7612 function( tag, context ) { 7613 if ( typeof context.getElementsByTagName !== "undefined" ) { 7614 return context.getElementsByTagName( tag ); 7615 7616 // DocumentFragment nodes don't have gEBTN 7617 } else if ( support.qsa ) { 7618 return context.querySelectorAll( tag ); 7619 } 7620 } : 7621 7622 function( tag, context ) { 7623 var elem, 7624 tmp = [], 7625 i = 0, 7626 7627 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too 7628 results = context.getElementsByTagName( tag ); 7629 7630 // Filter out possible comments 7631 if ( tag === "*" ) { 7632 while ( ( elem = results[ i++ ] ) ) { 7633 if ( elem.nodeType === 1 ) { 7634 tmp.push( elem ); 7635 } 7636 } 7637 7638 return tmp; 7639 } 7640 return results; 7641 }; 7642 7643 // Class 7644 Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) { 7645 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { 7646 return context.getElementsByClassName( className ); 7647 } 7648 }; 7649 7650 /* QSA/matchesSelector 7651 ---------------------------------------------------------------------- */ 7652 7653 // QSA and matchesSelector support 7654 7655 // matchesSelector(:active) reports false when true (IE9/Opera 11.5) 7656 rbuggyMatches = []; 7657 7658 // qSa(:focus) reports false when true (Chrome 21) 7659 // We allow this because of a bug in IE8/9 that throws an error 7660 // whenever `document.activeElement` is accessed on an iframe 7661 // So, we allow :focus to pass through QSA all the time to avoid the IE error 7662 // See https://bugs.jquery.com/ticket/13378 7663 rbuggyQSA = []; 7664 7665 if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) { 7666 7667 // Build QSA regex 7668 // Regex strategy adopted from Diego Perini 7669 assert( function( el ) { 7670 7671 var input; 7672 7673 // Select is set to empty string on purpose 7674 // This is to test IE's treatment of not explicitly 7675 // setting a boolean content attribute, 7676 // since its presence should be enough 7677 // https://bugs.jquery.com/ticket/12359 7678 docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" + 7679 "<select id='" + expando + "-\r\\' msallowcapture=''>" + 7680 "<option selected=''></option></select>"; 7681 7682 // Support: IE8, Opera 11-12.16 7683 // Nothing should be selected when empty strings follow ^= or $= or *= 7684 // The test attribute must be unknown in Opera but "safe" for WinRT 7685 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section 7686 if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) { 7687 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); 7688 } 7689 7690 // Support: IE8 7691 // Boolean attributes and "value" are not treated correctly 7692 if ( !el.querySelectorAll( "[selected]" ).length ) { 7693 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); 7694 } 7695 7696 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ 7697 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { 7698 rbuggyQSA.push( "~=" ); 7699 } 7700 7701 // Support: IE 11+, Edge 15 - 18+ 7702 // IE 11/Edge don't find elements on a `[name='']` query in some cases. 7703 // Adding a temporary attribute to the document before the selection works 7704 // around the issue. 7705 // Interestingly, IE 10 & older don't seem to have the issue. 7706 input = document.createElement( "input" ); 7707 input.setAttribute( "name", "" ); 7708 el.appendChild( input ); 7709 if ( !el.querySelectorAll( "[name='']" ).length ) { 7710 rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" + 7711 whitespace + "*(?:''|\"\")" ); 7712 } 7713 7714 // Webkit/Opera - :checked should return selected option elements 7715 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 7716 // IE8 throws error here and will not see later tests 7717 if ( !el.querySelectorAll( ":checked" ).length ) { 7718 rbuggyQSA.push( ":checked" ); 7719 } 7720 7721 // Support: Safari 8+, iOS 8+ 7722 // https://bugs.webkit.org/show_bug.cgi?id=136851 7723 // In-page `selector#id sibling-combinator selector` fails 7724 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { 7725 rbuggyQSA.push( ".#.+[+~]" ); 7726 } 7727 7728 // Support: Firefox <=3.6 - 5 only 7729 // Old Firefox doesn't throw on a badly-escaped identifier. 7730 el.querySelectorAll( "\\\f" ); 7731 rbuggyQSA.push( "[\\r\\n\\f]" ); 7732 } ); 7733 7734 assert( function( el ) { 7735 el.innerHTML = "<a href='' disabled='disabled'></a>" + 7736 "<select disabled='disabled'><option/></select>"; 7737 7738 // Support: Windows 8 Native Apps 7739 // The type and name attributes are restricted during .innerHTML assignment 7740 var input = document.createElement( "input" ); 7741 input.setAttribute( "type", "hidden" ); 7742 el.appendChild( input ).setAttribute( "name", "D" ); 7743 7744 // Support: IE8 7745 // Enforce case-sensitivity of name attribute 7746 if ( el.querySelectorAll( "[name=d]" ).length ) { 7747 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); 7748 } 7749 7750 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) 7751 // IE8 throws error here and will not see later tests 7752 if ( el.querySelectorAll( ":enabled" ).length !== 2 ) { 7753 rbuggyQSA.push( ":enabled", ":disabled" ); 7754 } 7755 7756 // Support: IE9-11+ 7757 // IE's :disabled selector does not pick up the children of disabled fieldsets 7758 docElem.appendChild( el ).disabled = true; 7759 if ( el.querySelectorAll( ":disabled" ).length !== 2 ) { 7760 rbuggyQSA.push( ":enabled", ":disabled" ); 7761 } 7762 7763 // Support: Opera 10 - 11 only 7764 // Opera 10-11 does not throw on post-comma invalid pseudos 7765 el.querySelectorAll( "*,:x" ); 7766 rbuggyQSA.push( ",.*:" ); 7767 } ); 7768 } 7769 7770 if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches || 7771 docElem.webkitMatchesSelector || 7772 docElem.mozMatchesSelector || 7773 docElem.oMatchesSelector || 7774 docElem.msMatchesSelector ) ) ) ) { 7775 7776 assert( function( el ) { 7777 7778 // Check to see if it's possible to do matchesSelector 7779 // on a disconnected node (IE 9) 7780 support.disconnectedMatch = matches.call( el, "*" ); 7781 7782 // This should fail with an exception 7783 // Gecko does not error, returns false instead 7784 matches.call( el, "[s!='']:x" ); 7785 rbuggyMatches.push( "!=", pseudos ); 7786 } ); 7787 } 7788 7789 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); 7790 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) ); 7791 7792 /* Contains 7793 ---------------------------------------------------------------------- */ 7794 hasCompare = rnative.test( docElem.compareDocumentPosition ); 7795 7796 // Element contains another 7797 // Purposefully self-exclusive 7798 // As in, an element does not contain itself 7799 contains = hasCompare || rnative.test( docElem.contains ) ? 7800 function( a, b ) { 7801 var adown = a.nodeType === 9 ? a.documentElement : a, 7802 bup = b && b.parentNode; 7803 return a === bup || !!( bup && bup.nodeType === 1 && ( 7804 adown.contains ? 7805 adown.contains( bup ) : 7806 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 7807 ) ); 7808 } : 7809 function( a, b ) { 7810 if ( b ) { 7811 while ( ( b = b.parentNode ) ) { 7812 if ( b === a ) { 7813 return true; 7814 } 7815 } 7816 } 7817 return false; 7818 }; 7819 7820 /* Sorting 7821 ---------------------------------------------------------------------- */ 7822 7823 // Document order sorting 7824 sortOrder = hasCompare ? 7825 function( a, b ) { 7826 7827 // Flag for duplicate removal 7828 if ( a === b ) { 7829 hasDuplicate = true; 7830 return 0; 7831 } 7832 7833 // Sort on method existence if only one input has compareDocumentPosition 7834 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; 7835 if ( compare ) { 7836 return compare; 7837 } 7838 7839 // Calculate position if both inputs belong to the same document 7840 // Support: IE 11+, Edge 17 - 18+ 7841 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 7842 // two documents; shallow comparisons work. 7843 // eslint-disable-next-line eqeqeq 7844 compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ? 7845 a.compareDocumentPosition( b ) : 7846 7847 // Otherwise we know they are disconnected 7848 1; 7849 7850 // Disconnected nodes 7851 if ( compare & 1 || 7852 ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) { 7853 7854 // Choose the first element that is related to our preferred document 7855 // Support: IE 11+, Edge 17 - 18+ 7856 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 7857 // two documents; shallow comparisons work. 7858 // eslint-disable-next-line eqeqeq 7859 if ( a == document || a.ownerDocument == preferredDoc && 7860 contains( preferredDoc, a ) ) { 7861 return -1; 7862 } 7863 7864 // Support: IE 11+, Edge 17 - 18+ 7865 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 7866 // two documents; shallow comparisons work. 7867 // eslint-disable-next-line eqeqeq 7868 if ( b == document || b.ownerDocument == preferredDoc && 7869 contains( preferredDoc, b ) ) { 7870 return 1; 7871 } 7872 7873 // Maintain original order 7874 return sortInput ? 7875 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 7876 0; 7877 } 7878 7879 return compare & 4 ? -1 : 1; 7880 } : 7881 function( a, b ) { 7882 7883 // Exit early if the nodes are identical 7884 if ( a === b ) { 7885 hasDuplicate = true; 7886 return 0; 7887 } 7888 7889 var cur, 7890 i = 0, 7891 aup = a.parentNode, 7892 bup = b.parentNode, 7893 ap = [ a ], 7894 bp = [ b ]; 7895 7896 // Parentless nodes are either documents or disconnected 7897 if ( !aup || !bup ) { 7898 7899 // Support: IE 11+, Edge 17 - 18+ 7900 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 7901 // two documents; shallow comparisons work. 7902 /* eslint-disable eqeqeq */ 7903 return a == document ? -1 : 7904 b == document ? 1 : 7905 /* eslint-enable eqeqeq */ 7906 aup ? -1 : 7907 bup ? 1 : 7908 sortInput ? 7909 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 7910 0; 7911 7912 // If the nodes are siblings, we can do a quick check 7913 } else if ( aup === bup ) { 7914 return siblingCheck( a, b ); 7915 } 7916 7917 // Otherwise we need full lists of their ancestors for comparison 7918 cur = a; 7919 while ( ( cur = cur.parentNode ) ) { 7920 ap.unshift( cur ); 7921 } 7922 cur = b; 7923 while ( ( cur = cur.parentNode ) ) { 7924 bp.unshift( cur ); 7925 } 7926 7927 // Walk down the tree looking for a discrepancy 7928 while ( ap[ i ] === bp[ i ] ) { 7929 i++; 7930 } 7931 7932 return i ? 7933 7934 // Do a sibling check if the nodes have a common ancestor 7935 siblingCheck( ap[ i ], bp[ i ] ) : 7936 7937 // Otherwise nodes in our document sort first 7938 // Support: IE 11+, Edge 17 - 18+ 7939 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 7940 // two documents; shallow comparisons work. 7941 /* eslint-disable eqeqeq */ 7942 ap[ i ] == preferredDoc ? -1 : 7943 bp[ i ] == preferredDoc ? 1 : 7944 /* eslint-enable eqeqeq */ 7945 0; 7946 }; 7947 7948 return document; 7949}; 7950 7951Sizzle.matches = function( expr, elements ) { 7952 return Sizzle( expr, null, null, elements ); 7953}; 7954 7955Sizzle.matchesSelector = function( elem, expr ) { 7956 setDocument( elem ); 7957 7958 if ( support.matchesSelector && documentIsHTML && 7959 !nonnativeSelectorCache[ expr + " " ] && 7960 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && 7961 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { 7962 7963 try { 7964 var ret = matches.call( elem, expr ); 7965 7966 // IE 9's matchesSelector returns false on disconnected nodes 7967 if ( ret || support.disconnectedMatch || 7968 7969 // As well, disconnected nodes are said to be in a document 7970 // fragment in IE 9 7971 elem.document && elem.document.nodeType !== 11 ) { 7972 return ret; 7973 } 7974 } catch ( e ) { 7975 nonnativeSelectorCache( expr, true ); 7976 } 7977 } 7978 7979 return Sizzle( expr, document, null, [ elem ] ).length > 0; 7980}; 7981 7982Sizzle.contains = function( context, elem ) { 7983 7984 // Set document vars if needed 7985 // Support: IE 11+, Edge 17 - 18+ 7986 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 7987 // two documents; shallow comparisons work. 7988 // eslint-disable-next-line eqeqeq 7989 if ( ( context.ownerDocument || context ) != document ) { 7990 setDocument( context ); 7991 } 7992 return contains( context, elem ); 7993}; 7994 7995Sizzle.attr = function( elem, name ) { 7996 7997 // Set document vars if needed 7998 // Support: IE 11+, Edge 17 - 18+ 7999 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 8000 // two documents; shallow comparisons work. 8001 // eslint-disable-next-line eqeqeq 8002 if ( ( elem.ownerDocument || elem ) != document ) { 8003 setDocument( elem ); 8004 } 8005 8006 var fn = Expr.attrHandle[ name.toLowerCase() ], 8007 8008 // Don't get fooled by Object.prototype properties (jQuery #13807) 8009 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? 8010 fn( elem, name, !documentIsHTML ) : 8011 undefined; 8012 8013 return val !== undefined ? 8014 val : 8015 support.attributes || !documentIsHTML ? 8016 elem.getAttribute( name ) : 8017 ( val = elem.getAttributeNode( name ) ) && val.specified ? 8018 val.value : 8019 null; 8020}; 8021 8022Sizzle.escape = function( sel ) { 8023 return ( sel + "" ).replace( rcssescape, fcssescape ); 8024}; 8025 8026Sizzle.error = function( msg ) { 8027 throw new Error( "Syntax error, unrecognized expression: " + msg ); 8028}; 8029 8030/** 8031 * Document sorting and removing duplicates 8032 * @param {ArrayLike} results 8033 */ 8034Sizzle.uniqueSort = function( results ) { 8035 var elem, 8036 duplicates = [], 8037 j = 0, 8038 i = 0; 8039 8040 // Unless we *know* we can detect duplicates, assume their presence 8041 hasDuplicate = !support.detectDuplicates; 8042 sortInput = !support.sortStable && results.slice( 0 ); 8043 results.sort( sortOrder ); 8044 8045 if ( hasDuplicate ) { 8046 while ( ( elem = results[ i++ ] ) ) { 8047 if ( elem === results[ i ] ) { 8048 j = duplicates.push( i ); 8049 } 8050 } 8051 while ( j-- ) { 8052 results.splice( duplicates[ j ], 1 ); 8053 } 8054 } 8055 8056 // Clear input after sorting to release objects 8057 // See https://github.com/jquery/sizzle/pull/225 8058 sortInput = null; 8059 8060 return results; 8061}; 8062 8063/** 8064 * Utility function for retrieving the text value of an array of DOM nodes 8065 * @param {Array|Element} elem 8066 */ 8067getText = Sizzle.getText = function( elem ) { 8068 var node, 8069 ret = "", 8070 i = 0, 8071 nodeType = elem.nodeType; 8072 8073 if ( !nodeType ) { 8074 8075 // If no nodeType, this is expected to be an array 8076 while ( ( node = elem[ i++ ] ) ) { 8077 8078 // Do not traverse comment nodes 8079 ret += getText( node ); 8080 } 8081 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { 8082 8083 // Use textContent for elements 8084 // innerText usage removed for consistency of new lines (jQuery #11153) 8085 if ( typeof elem.textContent === "string" ) { 8086 return elem.textContent; 8087 } else { 8088 8089 // Traverse its children 8090 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 8091 ret += getText( elem ); 8092 } 8093 } 8094 } else if ( nodeType === 3 || nodeType === 4 ) { 8095 return elem.nodeValue; 8096 } 8097 8098 // Do not include comment or processing instruction nodes 8099 8100 return ret; 8101}; 8102 8103Expr = Sizzle.selectors = { 8104 8105 // Can be adjusted by the user 8106 cacheLength: 50, 8107 8108 createPseudo: markFunction, 8109 8110 match: matchExpr, 8111 8112 attrHandle: {}, 8113 8114 find: {}, 8115 8116 relative: { 8117 ">": { dir: "parentNode", first: true }, 8118 " ": { dir: "parentNode" }, 8119 "+": { dir: "previousSibling", first: true }, 8120 "~": { dir: "previousSibling" } 8121 }, 8122 8123 preFilter: { 8124 "ATTR": function( match ) { 8125 match[ 1 ] = match[ 1 ].replace( runescape, funescape ); 8126 8127 // Move the given value to match[3] whether quoted or unquoted 8128 match[ 3 ] = ( match[ 3 ] || match[ 4 ] || 8129 match[ 5 ] || "" ).replace( runescape, funescape ); 8130 8131 if ( match[ 2 ] === "~=" ) { 8132 match[ 3 ] = " " + match[ 3 ] + " "; 8133 } 8134 8135 return match.slice( 0, 4 ); 8136 }, 8137 8138 "CHILD": function( match ) { 8139 8140 /* matches from matchExpr["CHILD"] 8141 1 type (only|nth|...) 8142 2 what (child|of-type) 8143 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) 8144 4 xn-component of xn+y argument ([+-]?\d*n|) 8145 5 sign of xn-component 8146 6 x of xn-component 8147 7 sign of y-component 8148 8 y of y-component 8149 */ 8150 match[ 1 ] = match[ 1 ].toLowerCase(); 8151 8152 if ( match[ 1 ].slice( 0, 3 ) === "nth" ) { 8153 8154 // nth-* requires argument 8155 if ( !match[ 3 ] ) { 8156 Sizzle.error( match[ 0 ] ); 8157 } 8158 8159 // numeric x and y parameters for Expr.filter.CHILD 8160 // remember that false/true cast respectively to 0/1 8161 match[ 4 ] = +( match[ 4 ] ? 8162 match[ 5 ] + ( match[ 6 ] || 1 ) : 8163 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) ); 8164 match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" ); 8165 8166 // other types prohibit arguments 8167 } else if ( match[ 3 ] ) { 8168 Sizzle.error( match[ 0 ] ); 8169 } 8170 8171 return match; 8172 }, 8173 8174 "PSEUDO": function( match ) { 8175 var excess, 8176 unquoted = !match[ 6 ] && match[ 2 ]; 8177 8178 if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) { 8179 return null; 8180 } 8181 8182 // Accept quoted arguments as-is 8183 if ( match[ 3 ] ) { 8184 match[ 2 ] = match[ 4 ] || match[ 5 ] || ""; 8185 8186 // Strip excess characters from unquoted arguments 8187 } else if ( unquoted && rpseudo.test( unquoted ) && 8188 8189 // Get excess from tokenize (recursively) 8190 ( excess = tokenize( unquoted, true ) ) && 8191 8192 // advance to the next closing parenthesis 8193 ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) { 8194 8195 // excess is a negative index 8196 match[ 0 ] = match[ 0 ].slice( 0, excess ); 8197 match[ 2 ] = unquoted.slice( 0, excess ); 8198 } 8199 8200 // Return only captures needed by the pseudo filter method (type and argument) 8201 return match.slice( 0, 3 ); 8202 } 8203 }, 8204 8205 filter: { 8206 8207 "TAG": function( nodeNameSelector ) { 8208 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); 8209 return nodeNameSelector === "*" ? 8210 function() { 8211 return true; 8212 } : 8213 function( elem ) { 8214 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; 8215 }; 8216 }, 8217 8218 "CLASS": function( className ) { 8219 var pattern = classCache[ className + " " ]; 8220 8221 return pattern || 8222 ( pattern = new RegExp( "(^|" + whitespace + 8223 ")" + className + "(" + whitespace + "|$)" ) ) && classCache( 8224 className, function( elem ) { 8225 return pattern.test( 8226 typeof elem.className === "string" && elem.className || 8227 typeof elem.getAttribute !== "undefined" && 8228 elem.getAttribute( "class" ) || 8229 "" 8230 ); 8231 } ); 8232 }, 8233 8234 "ATTR": function( name, operator, check ) { 8235 return function( elem ) { 8236 var result = Sizzle.attr( elem, name ); 8237 8238 if ( result == null ) { 8239 return operator === "!="; 8240 } 8241 if ( !operator ) { 8242 return true; 8243 } 8244 8245 result += ""; 8246 8247 /* eslint-disable max-len */ 8248 8249 return operator === "=" ? result === check : 8250 operator === "!=" ? result !== check : 8251 operator === "^=" ? check && result.indexOf( check ) === 0 : 8252 operator === "*=" ? check && result.indexOf( check ) > -1 : 8253 operator === "$=" ? check && result.slice( -check.length ) === check : 8254 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : 8255 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : 8256 false; 8257 /* eslint-enable max-len */ 8258 8259 }; 8260 }, 8261 8262 "CHILD": function( type, what, _argument, first, last ) { 8263 var simple = type.slice( 0, 3 ) !== "nth", 8264 forward = type.slice( -4 ) !== "last", 8265 ofType = what === "of-type"; 8266 8267 return first === 1 && last === 0 ? 8268 8269 // Shortcut for :nth-*(n) 8270 function( elem ) { 8271 return !!elem.parentNode; 8272 } : 8273 8274 function( elem, _context, xml ) { 8275 var cache, uniqueCache, outerCache, node, nodeIndex, start, 8276 dir = simple !== forward ? "nextSibling" : "previousSibling", 8277 parent = elem.parentNode, 8278 name = ofType && elem.nodeName.toLowerCase(), 8279 useCache = !xml && !ofType, 8280 diff = false; 8281 8282 if ( parent ) { 8283 8284 // :(first|last|only)-(child|of-type) 8285 if ( simple ) { 8286 while ( dir ) { 8287 node = elem; 8288 while ( ( node = node[ dir ] ) ) { 8289 if ( ofType ? 8290 node.nodeName.toLowerCase() === name : 8291 node.nodeType === 1 ) { 8292 8293 return false; 8294 } 8295 } 8296 8297 // Reverse direction for :only-* (if we haven't yet done so) 8298 start = dir = type === "only" && !start && "nextSibling"; 8299 } 8300 return true; 8301 } 8302 8303 start = [ forward ? parent.firstChild : parent.lastChild ]; 8304 8305 // non-xml :nth-child(...) stores cache data on `parent` 8306 if ( forward && useCache ) { 8307 8308 // Seek `elem` from a previously-cached index 8309 8310 // ...in a gzip-friendly way 8311 node = parent; 8312 outerCache = node[ expando ] || ( node[ expando ] = {} ); 8313 8314 // Support: IE <9 only 8315 // Defend against cloned attroperties (jQuery gh-1709) 8316 uniqueCache = outerCache[ node.uniqueID ] || 8317 ( outerCache[ node.uniqueID ] = {} ); 8318 8319 cache = uniqueCache[ type ] || []; 8320 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 8321 diff = nodeIndex && cache[ 2 ]; 8322 node = nodeIndex && parent.childNodes[ nodeIndex ]; 8323 8324 while ( ( node = ++nodeIndex && node && node[ dir ] || 8325 8326 // Fallback to seeking `elem` from the start 8327 ( diff = nodeIndex = 0 ) || start.pop() ) ) { 8328 8329 // When found, cache indexes on `parent` and break 8330 if ( node.nodeType === 1 && ++diff && node === elem ) { 8331 uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; 8332 break; 8333 } 8334 } 8335 8336 } else { 8337 8338 // Use previously-cached element index if available 8339 if ( useCache ) { 8340 8341 // ...in a gzip-friendly way 8342 node = elem; 8343 outerCache = node[ expando ] || ( node[ expando ] = {} ); 8344 8345 // Support: IE <9 only 8346 // Defend against cloned attroperties (jQuery gh-1709) 8347 uniqueCache = outerCache[ node.uniqueID ] || 8348 ( outerCache[ node.uniqueID ] = {} ); 8349 8350 cache = uniqueCache[ type ] || []; 8351 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 8352 diff = nodeIndex; 8353 } 8354 8355 // xml :nth-child(...) 8356 // or :nth-last-child(...) or :nth(-last)?-of-type(...) 8357 if ( diff === false ) { 8358 8359 // Use the same loop as above to seek `elem` from the start 8360 while ( ( node = ++nodeIndex && node && node[ dir ] || 8361 ( diff = nodeIndex = 0 ) || start.pop() ) ) { 8362 8363 if ( ( ofType ? 8364 node.nodeName.toLowerCase() === name : 8365 node.nodeType === 1 ) && 8366 ++diff ) { 8367 8368 // Cache the index of each encountered element 8369 if ( useCache ) { 8370 outerCache = node[ expando ] || 8371 ( node[ expando ] = {} ); 8372 8373 // Support: IE <9 only 8374 // Defend against cloned attroperties (jQuery gh-1709) 8375 uniqueCache = outerCache[ node.uniqueID ] || 8376 ( outerCache[ node.uniqueID ] = {} ); 8377 8378 uniqueCache[ type ] = [ dirruns, diff ]; 8379 } 8380 8381 if ( node === elem ) { 8382 break; 8383 } 8384 } 8385 } 8386 } 8387 } 8388 8389 // Incorporate the offset, then check against cycle size 8390 diff -= last; 8391 return diff === first || ( diff % first === 0 && diff / first >= 0 ); 8392 } 8393 }; 8394 }, 8395 8396 "PSEUDO": function( pseudo, argument ) { 8397 8398 // pseudo-class names are case-insensitive 8399 // http://www.w3.org/TR/selectors/#pseudo-classes 8400 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters 8401 // Remember that setFilters inherits from pseudos 8402 var args, 8403 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || 8404 Sizzle.error( "unsupported pseudo: " + pseudo ); 8405 8406 // The user may use createPseudo to indicate that 8407 // arguments are needed to create the filter function 8408 // just as Sizzle does 8409 if ( fn[ expando ] ) { 8410 return fn( argument ); 8411 } 8412 8413 // But maintain support for old signatures 8414 if ( fn.length > 1 ) { 8415 args = [ pseudo, pseudo, "", argument ]; 8416 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? 8417 markFunction( function( seed, matches ) { 8418 var idx, 8419 matched = fn( seed, argument ), 8420 i = matched.length; 8421 while ( i-- ) { 8422 idx = indexOf( seed, matched[ i ] ); 8423 seed[ idx ] = !( matches[ idx ] = matched[ i ] ); 8424 } 8425 } ) : 8426 function( elem ) { 8427 return fn( elem, 0, args ); 8428 }; 8429 } 8430 8431 return fn; 8432 } 8433 }, 8434 8435 pseudos: { 8436 8437 // Potentially complex pseudos 8438 "not": markFunction( function( selector ) { 8439 8440 // Trim the selector passed to compile 8441 // to avoid treating leading and trailing 8442 // spaces as combinators 8443 var input = [], 8444 results = [], 8445 matcher = compile( selector.replace( rtrim, "$1" ) ); 8446 8447 return matcher[ expando ] ? 8448 markFunction( function( seed, matches, _context, xml ) { 8449 var elem, 8450 unmatched = matcher( seed, null, xml, [] ), 8451 i = seed.length; 8452 8453 // Match elements unmatched by `matcher` 8454 while ( i-- ) { 8455 if ( ( elem = unmatched[ i ] ) ) { 8456 seed[ i ] = !( matches[ i ] = elem ); 8457 } 8458 } 8459 } ) : 8460 function( elem, _context, xml ) { 8461 input[ 0 ] = elem; 8462 matcher( input, null, xml, results ); 8463 8464 // Don't keep the element (issue #299) 8465 input[ 0 ] = null; 8466 return !results.pop(); 8467 }; 8468 } ), 8469 8470 "has": markFunction( function( selector ) { 8471 return function( elem ) { 8472 return Sizzle( selector, elem ).length > 0; 8473 }; 8474 } ), 8475 8476 "contains": markFunction( function( text ) { 8477 text = text.replace( runescape, funescape ); 8478 return function( elem ) { 8479 return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1; 8480 }; 8481 } ), 8482 8483 // "Whether an element is represented by a :lang() selector 8484 // is based solely on the element's language value 8485 // being equal to the identifier C, 8486 // or beginning with the identifier C immediately followed by "-". 8487 // The matching of C against the element's language value is performed case-insensitively. 8488 // The identifier C does not have to be a valid language name." 8489 // http://www.w3.org/TR/selectors/#lang-pseudo 8490 "lang": markFunction( function( lang ) { 8491 8492 // lang value must be a valid identifier 8493 if ( !ridentifier.test( lang || "" ) ) { 8494 Sizzle.error( "unsupported lang: " + lang ); 8495 } 8496 lang = lang.replace( runescape, funescape ).toLowerCase(); 8497 return function( elem ) { 8498 var elemLang; 8499 do { 8500 if ( ( elemLang = documentIsHTML ? 8501 elem.lang : 8502 elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) { 8503 8504 elemLang = elemLang.toLowerCase(); 8505 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; 8506 } 8507 } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 ); 8508 return false; 8509 }; 8510 } ), 8511 8512 // Miscellaneous 8513 "target": function( elem ) { 8514 var hash = window.location && window.location.hash; 8515 return hash && hash.slice( 1 ) === elem.id; 8516 }, 8517 8518 "root": function( elem ) { 8519 return elem === docElem; 8520 }, 8521 8522 "focus": function( elem ) { 8523 return elem === document.activeElement && 8524 ( !document.hasFocus || document.hasFocus() ) && 8525 !!( elem.type || elem.href || ~elem.tabIndex ); 8526 }, 8527 8528 // Boolean properties 8529 "enabled": createDisabledPseudo( false ), 8530 "disabled": createDisabledPseudo( true ), 8531 8532 "checked": function( elem ) { 8533 8534 // In CSS3, :checked should return both checked and selected elements 8535 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 8536 var nodeName = elem.nodeName.toLowerCase(); 8537 return ( nodeName === "input" && !!elem.checked ) || 8538 ( nodeName === "option" && !!elem.selected ); 8539 }, 8540 8541 "selected": function( elem ) { 8542 8543 // Accessing this property makes selected-by-default 8544 // options in Safari work properly 8545 if ( elem.parentNode ) { 8546 // eslint-disable-next-line no-unused-expressions 8547 elem.parentNode.selectedIndex; 8548 } 8549 8550 return elem.selected === true; 8551 }, 8552 8553 // Contents 8554 "empty": function( elem ) { 8555 8556 // http://www.w3.org/TR/selectors/#empty-pseudo 8557 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), 8558 // but not by others (comment: 8; processing instruction: 7; etc.) 8559 // nodeType < 6 works because attributes (2) do not appear as children 8560 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 8561 if ( elem.nodeType < 6 ) { 8562 return false; 8563 } 8564 } 8565 return true; 8566 }, 8567 8568 "parent": function( elem ) { 8569 return !Expr.pseudos[ "empty" ]( elem ); 8570 }, 8571 8572 // Element/input types 8573 "header": function( elem ) { 8574 return rheader.test( elem.nodeName ); 8575 }, 8576 8577 "input": function( elem ) { 8578 return rinputs.test( elem.nodeName ); 8579 }, 8580 8581 "button": function( elem ) { 8582 var name = elem.nodeName.toLowerCase(); 8583 return name === "input" && elem.type === "button" || name === "button"; 8584 }, 8585 8586 "text": function( elem ) { 8587 var attr; 8588 return elem.nodeName.toLowerCase() === "input" && 8589 elem.type === "text" && 8590 8591 // Support: IE<8 8592 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" 8593 ( ( attr = elem.getAttribute( "type" ) ) == null || 8594 attr.toLowerCase() === "text" ); 8595 }, 8596 8597 // Position-in-collection 8598 "first": createPositionalPseudo( function() { 8599 return [ 0 ]; 8600 } ), 8601 8602 "last": createPositionalPseudo( function( _matchIndexes, length ) { 8603 return [ length - 1 ]; 8604 } ), 8605 8606 "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) { 8607 return [ argument < 0 ? argument + length : argument ]; 8608 } ), 8609 8610 "even": createPositionalPseudo( function( matchIndexes, length ) { 8611 var i = 0; 8612 for ( ; i < length; i += 2 ) { 8613 matchIndexes.push( i ); 8614 } 8615 return matchIndexes; 8616 } ), 8617 8618 "odd": createPositionalPseudo( function( matchIndexes, length ) { 8619 var i = 1; 8620 for ( ; i < length; i += 2 ) { 8621 matchIndexes.push( i ); 8622 } 8623 return matchIndexes; 8624 } ), 8625 8626 "lt": createPositionalPseudo( function( matchIndexes, length, argument ) { 8627 var i = argument < 0 ? 8628 argument + length : 8629 argument > length ? 8630 length : 8631 argument; 8632 for ( ; --i >= 0; ) { 8633 matchIndexes.push( i ); 8634 } 8635 return matchIndexes; 8636 } ), 8637 8638 "gt": createPositionalPseudo( function( matchIndexes, length, argument ) { 8639 var i = argument < 0 ? argument + length : argument; 8640 for ( ; ++i < length; ) { 8641 matchIndexes.push( i ); 8642 } 8643 return matchIndexes; 8644 } ) 8645 } 8646}; 8647 8648Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ]; 8649 8650// Add button/input type pseudos 8651for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { 8652 Expr.pseudos[ i ] = createInputPseudo( i ); 8653} 8654for ( i in { submit: true, reset: true } ) { 8655 Expr.pseudos[ i ] = createButtonPseudo( i ); 8656} 8657 8658// Easy API for creating new setFilters 8659function setFilters() {} 8660setFilters.prototype = Expr.filters = Expr.pseudos; 8661Expr.setFilters = new setFilters(); 8662 8663tokenize = Sizzle.tokenize = function( selector, parseOnly ) { 8664 var matched, match, tokens, type, 8665 soFar, groups, preFilters, 8666 cached = tokenCache[ selector + " " ]; 8667 8668 if ( cached ) { 8669 return parseOnly ? 0 : cached.slice( 0 ); 8670 } 8671 8672 soFar = selector; 8673 groups = []; 8674 preFilters = Expr.preFilter; 8675 8676 while ( soFar ) { 8677 8678 // Comma and first run 8679 if ( !matched || ( match = rcomma.exec( soFar ) ) ) { 8680 if ( match ) { 8681 8682 // Don't consume trailing commas as valid 8683 soFar = soFar.slice( match[ 0 ].length ) || soFar; 8684 } 8685 groups.push( ( tokens = [] ) ); 8686 } 8687 8688 matched = false; 8689 8690 // Combinators 8691 if ( ( match = rcombinators.exec( soFar ) ) ) { 8692 matched = match.shift(); 8693 tokens.push( { 8694 value: matched, 8695 8696 // Cast descendant combinators to space 8697 type: match[ 0 ].replace( rtrim, " " ) 8698 } ); 8699 soFar = soFar.slice( matched.length ); 8700 } 8701 8702 // Filters 8703 for ( type in Expr.filter ) { 8704 if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] || 8705 ( match = preFilters[ type ]( match ) ) ) ) { 8706 matched = match.shift(); 8707 tokens.push( { 8708 value: matched, 8709 type: type, 8710 matches: match 8711 } ); 8712 soFar = soFar.slice( matched.length ); 8713 } 8714 } 8715 8716 if ( !matched ) { 8717 break; 8718 } 8719 } 8720 8721 // Return the length of the invalid excess 8722 // if we're just parsing 8723 // Otherwise, throw an error or return tokens 8724 return parseOnly ? 8725 soFar.length : 8726 soFar ? 8727 Sizzle.error( selector ) : 8728 8729 // Cache the tokens 8730 tokenCache( selector, groups ).slice( 0 ); 8731}; 8732 8733function toSelector( tokens ) { 8734 var i = 0, 8735 len = tokens.length, 8736 selector = ""; 8737 for ( ; i < len; i++ ) { 8738 selector += tokens[ i ].value; 8739 } 8740 return selector; 8741} 8742 8743function addCombinator( matcher, combinator, base ) { 8744 var dir = combinator.dir, 8745 skip = combinator.next, 8746 key = skip || dir, 8747 checkNonElements = base && key === "parentNode", 8748 doneName = done++; 8749 8750 return combinator.first ? 8751 8752 // Check against closest ancestor/preceding element 8753 function( elem, context, xml ) { 8754 while ( ( elem = elem[ dir ] ) ) { 8755 if ( elem.nodeType === 1 || checkNonElements ) { 8756 return matcher( elem, context, xml ); 8757 } 8758 } 8759 return false; 8760 } : 8761 8762 // Check against all ancestor/preceding elements 8763 function( elem, context, xml ) { 8764 var oldCache, uniqueCache, outerCache, 8765 newCache = [ dirruns, doneName ]; 8766 8767 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching 8768 if ( xml ) { 8769 while ( ( elem = elem[ dir ] ) ) { 8770 if ( elem.nodeType === 1 || checkNonElements ) { 8771 if ( matcher( elem, context, xml ) ) { 8772 return true; 8773 } 8774 } 8775 } 8776 } else { 8777 while ( ( elem = elem[ dir ] ) ) { 8778 if ( elem.nodeType === 1 || checkNonElements ) { 8779 outerCache = elem[ expando ] || ( elem[ expando ] = {} ); 8780 8781 // Support: IE <9 only 8782 // Defend against cloned attroperties (jQuery gh-1709) 8783 uniqueCache = outerCache[ elem.uniqueID ] || 8784 ( outerCache[ elem.uniqueID ] = {} ); 8785 8786 if ( skip && skip === elem.nodeName.toLowerCase() ) { 8787 elem = elem[ dir ] || elem; 8788 } else if ( ( oldCache = uniqueCache[ key ] ) && 8789 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { 8790 8791 // Assign to newCache so results back-propagate to previous elements 8792 return ( newCache[ 2 ] = oldCache[ 2 ] ); 8793 } else { 8794 8795 // Reuse newcache so results back-propagate to previous elements 8796 uniqueCache[ key ] = newCache; 8797 8798 // A match means we're done; a fail means we have to keep checking 8799 if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) { 8800 return true; 8801 } 8802 } 8803 } 8804 } 8805 } 8806 return false; 8807 }; 8808} 8809 8810function elementMatcher( matchers ) { 8811 return matchers.length > 1 ? 8812 function( elem, context, xml ) { 8813 var i = matchers.length; 8814 while ( i-- ) { 8815 if ( !matchers[ i ]( elem, context, xml ) ) { 8816 return false; 8817 } 8818 } 8819 return true; 8820 } : 8821 matchers[ 0 ]; 8822} 8823 8824function multipleContexts( selector, contexts, results ) { 8825 var i = 0, 8826 len = contexts.length; 8827 for ( ; i < len; i++ ) { 8828 Sizzle( selector, contexts[ i ], results ); 8829 } 8830 return results; 8831} 8832 8833function condense( unmatched, map, filter, context, xml ) { 8834 var elem, 8835 newUnmatched = [], 8836 i = 0, 8837 len = unmatched.length, 8838 mapped = map != null; 8839 8840 for ( ; i < len; i++ ) { 8841 if ( ( elem = unmatched[ i ] ) ) { 8842 if ( !filter || filter( elem, context, xml ) ) { 8843 newUnmatched.push( elem ); 8844 if ( mapped ) { 8845 map.push( i ); 8846 } 8847 } 8848 } 8849 } 8850 8851 return newUnmatched; 8852} 8853 8854function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { 8855 if ( postFilter && !postFilter[ expando ] ) { 8856 postFilter = setMatcher( postFilter ); 8857 } 8858 if ( postFinder && !postFinder[ expando ] ) { 8859 postFinder = setMatcher( postFinder, postSelector ); 8860 } 8861 return markFunction( function( seed, results, context, xml ) { 8862 var temp, i, elem, 8863 preMap = [], 8864 postMap = [], 8865 preexisting = results.length, 8866 8867 // Get initial elements from seed or context 8868 elems = seed || multipleContexts( 8869 selector || "*", 8870 context.nodeType ? [ context ] : context, 8871 [] 8872 ), 8873 8874 // Prefilter to get matcher input, preserving a map for seed-results synchronization 8875 matcherIn = preFilter && ( seed || !selector ) ? 8876 condense( elems, preMap, preFilter, context, xml ) : 8877 elems, 8878 8879 matcherOut = matcher ? 8880 8881 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, 8882 postFinder || ( seed ? preFilter : preexisting || postFilter ) ? 8883 8884 // ...intermediate processing is necessary 8885 [] : 8886 8887 // ...otherwise use results directly 8888 results : 8889 matcherIn; 8890 8891 // Find primary matches 8892 if ( matcher ) { 8893 matcher( matcherIn, matcherOut, context, xml ); 8894 } 8895 8896 // Apply postFilter 8897 if ( postFilter ) { 8898 temp = condense( matcherOut, postMap ); 8899 postFilter( temp, [], context, xml ); 8900 8901 // Un-match failing elements by moving them back to matcherIn 8902 i = temp.length; 8903 while ( i-- ) { 8904 if ( ( elem = temp[ i ] ) ) { 8905 matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem ); 8906 } 8907 } 8908 } 8909 8910 if ( seed ) { 8911 if ( postFinder || preFilter ) { 8912 if ( postFinder ) { 8913 8914 // Get the final matcherOut by condensing this intermediate into postFinder contexts 8915 temp = []; 8916 i = matcherOut.length; 8917 while ( i-- ) { 8918 if ( ( elem = matcherOut[ i ] ) ) { 8919 8920 // Restore matcherIn since elem is not yet a final match 8921 temp.push( ( matcherIn[ i ] = elem ) ); 8922 } 8923 } 8924 postFinder( null, ( matcherOut = [] ), temp, xml ); 8925 } 8926 8927 // Move matched elements from seed to results to keep them synchronized 8928 i = matcherOut.length; 8929 while ( i-- ) { 8930 if ( ( elem = matcherOut[ i ] ) && 8931 ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) { 8932 8933 seed[ temp ] = !( results[ temp ] = elem ); 8934 } 8935 } 8936 } 8937 8938 // Add elements to results, through postFinder if defined 8939 } else { 8940 matcherOut = condense( 8941 matcherOut === results ? 8942 matcherOut.splice( preexisting, matcherOut.length ) : 8943 matcherOut 8944 ); 8945 if ( postFinder ) { 8946 postFinder( null, results, matcherOut, xml ); 8947 } else { 8948 push.apply( results, matcherOut ); 8949 } 8950 } 8951 } ); 8952} 8953 8954function matcherFromTokens( tokens ) { 8955 var checkContext, matcher, j, 8956 len = tokens.length, 8957 leadingRelative = Expr.relative[ tokens[ 0 ].type ], 8958 implicitRelative = leadingRelative || Expr.relative[ " " ], 8959 i = leadingRelative ? 1 : 0, 8960 8961 // The foundational matcher ensures that elements are reachable from top-level context(s) 8962 matchContext = addCombinator( function( elem ) { 8963 return elem === checkContext; 8964 }, implicitRelative, true ), 8965 matchAnyContext = addCombinator( function( elem ) { 8966 return indexOf( checkContext, elem ) > -1; 8967 }, implicitRelative, true ), 8968 matchers = [ function( elem, context, xml ) { 8969 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( 8970 ( checkContext = context ).nodeType ? 8971 matchContext( elem, context, xml ) : 8972 matchAnyContext( elem, context, xml ) ); 8973 8974 // Avoid hanging onto element (issue #299) 8975 checkContext = null; 8976 return ret; 8977 } ]; 8978 8979 for ( ; i < len; i++ ) { 8980 if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) { 8981 matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; 8982 } else { 8983 matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches ); 8984 8985 // Return special upon seeing a positional matcher 8986 if ( matcher[ expando ] ) { 8987 8988 // Find the next relative operator (if any) for proper handling 8989 j = ++i; 8990 for ( ; j < len; j++ ) { 8991 if ( Expr.relative[ tokens[ j ].type ] ) { 8992 break; 8993 } 8994 } 8995 return setMatcher( 8996 i > 1 && elementMatcher( matchers ), 8997 i > 1 && toSelector( 8998 8999 // If the preceding token was a descendant combinator, insert an implicit any-element `*` 9000 tokens 9001 .slice( 0, i - 1 ) 9002 .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } ) 9003 ).replace( rtrim, "$1" ), 9004 matcher, 9005 i < j && matcherFromTokens( tokens.slice( i, j ) ), 9006 j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ), 9007 j < len && toSelector( tokens ) 9008 ); 9009 } 9010 matchers.push( matcher ); 9011 } 9012 } 9013 9014 return elementMatcher( matchers ); 9015} 9016 9017function matcherFromGroupMatchers( elementMatchers, setMatchers ) { 9018 var bySet = setMatchers.length > 0, 9019 byElement = elementMatchers.length > 0, 9020 superMatcher = function( seed, context, xml, results, outermost ) { 9021 var elem, j, matcher, 9022 matchedCount = 0, 9023 i = "0", 9024 unmatched = seed && [], 9025 setMatched = [], 9026 contextBackup = outermostContext, 9027 9028 // We must always have either seed elements or outermost context 9029 elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ), 9030 9031 // Use integer dirruns iff this is the outermost matcher 9032 dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ), 9033 len = elems.length; 9034 9035 if ( outermost ) { 9036 9037 // Support: IE 11+, Edge 17 - 18+ 9038 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 9039 // two documents; shallow comparisons work. 9040 // eslint-disable-next-line eqeqeq 9041 outermostContext = context == document || context || outermost; 9042 } 9043 9044 // Add elements passing elementMatchers directly to results 9045 // Support: IE<9, Safari 9046 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id 9047 for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) { 9048 if ( byElement && elem ) { 9049 j = 0; 9050 9051 // Support: IE 11+, Edge 17 - 18+ 9052 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 9053 // two documents; shallow comparisons work. 9054 // eslint-disable-next-line eqeqeq 9055 if ( !context && elem.ownerDocument != document ) { 9056 setDocument( elem ); 9057 xml = !documentIsHTML; 9058 } 9059 while ( ( matcher = elementMatchers[ j++ ] ) ) { 9060 if ( matcher( elem, context || document, xml ) ) { 9061 results.push( elem ); 9062 break; 9063 } 9064 } 9065 if ( outermost ) { 9066 dirruns = dirrunsUnique; 9067 } 9068 } 9069 9070 // Track unmatched elements for set filters 9071 if ( bySet ) { 9072 9073 // They will have gone through all possible matchers 9074 if ( ( elem = !matcher && elem ) ) { 9075 matchedCount--; 9076 } 9077 9078 // Lengthen the array for every element, matched or not 9079 if ( seed ) { 9080 unmatched.push( elem ); 9081 } 9082 } 9083 } 9084 9085 // `i` is now the count of elements visited above, and adding it to `matchedCount` 9086 // makes the latter nonnegative. 9087 matchedCount += i; 9088 9089 // Apply set filters to unmatched elements 9090 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` 9091 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have 9092 // no element matchers and no seed. 9093 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that 9094 // case, which will result in a "00" `matchedCount` that differs from `i` but is also 9095 // numerically zero. 9096 if ( bySet && i !== matchedCount ) { 9097 j = 0; 9098 while ( ( matcher = setMatchers[ j++ ] ) ) { 9099 matcher( unmatched, setMatched, context, xml ); 9100 } 9101 9102 if ( seed ) { 9103 9104 // Reintegrate element matches to eliminate the need for sorting 9105 if ( matchedCount > 0 ) { 9106 while ( i-- ) { 9107 if ( !( unmatched[ i ] || setMatched[ i ] ) ) { 9108 setMatched[ i ] = pop.call( results ); 9109 } 9110 } 9111 } 9112 9113 // Discard index placeholder values to get only actual matches 9114 setMatched = condense( setMatched ); 9115 } 9116 9117 // Add matches to results 9118 push.apply( results, setMatched ); 9119 9120 // Seedless set matches succeeding multiple successful matchers stipulate sorting 9121 if ( outermost && !seed && setMatched.length > 0 && 9122 ( matchedCount + setMatchers.length ) > 1 ) { 9123 9124 Sizzle.uniqueSort( results ); 9125 } 9126 } 9127 9128 // Override manipulation of globals by nested matchers 9129 if ( outermost ) { 9130 dirruns = dirrunsUnique; 9131 outermostContext = contextBackup; 9132 } 9133 9134 return unmatched; 9135 }; 9136 9137 return bySet ? 9138 markFunction( superMatcher ) : 9139 superMatcher; 9140} 9141 9142compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { 9143 var i, 9144 setMatchers = [], 9145 elementMatchers = [], 9146 cached = compilerCache[ selector + " " ]; 9147 9148 if ( !cached ) { 9149 9150 // Generate a function of recursive functions that can be used to check each element 9151 if ( !match ) { 9152 match = tokenize( selector ); 9153 } 9154 i = match.length; 9155 while ( i-- ) { 9156 cached = matcherFromTokens( match[ i ] ); 9157 if ( cached[ expando ] ) { 9158 setMatchers.push( cached ); 9159 } else { 9160 elementMatchers.push( cached ); 9161 } 9162 } 9163 9164 // Cache the compiled function 9165 cached = compilerCache( 9166 selector, 9167 matcherFromGroupMatchers( elementMatchers, setMatchers ) 9168 ); 9169 9170 // Save selector and tokenization 9171 cached.selector = selector; 9172 } 9173 return cached; 9174}; 9175 9176/** 9177 * A low-level selection function that works with Sizzle's compiled 9178 * selector functions 9179 * @param {String|Function} selector A selector or a pre-compiled 9180 * selector function built with Sizzle.compile 9181 * @param {Element} context 9182 * @param {Array} [results] 9183 * @param {Array} [seed] A set of elements to match against 9184 */ 9185select = Sizzle.select = function( selector, context, results, seed ) { 9186 var i, tokens, token, type, find, 9187 compiled = typeof selector === "function" && selector, 9188 match = !seed && tokenize( ( selector = compiled.selector || selector ) ); 9189 9190 results = results || []; 9191 9192 // Try to minimize operations if there is only one selector in the list and no seed 9193 // (the latter of which guarantees us context) 9194 if ( match.length === 1 ) { 9195 9196 // Reduce context if the leading compound selector is an ID 9197 tokens = match[ 0 ] = match[ 0 ].slice( 0 ); 9198 if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" && 9199 context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) { 9200 9201 context = ( Expr.find[ "ID" ]( token.matches[ 0 ] 9202 .replace( runescape, funescape ), context ) || [] )[ 0 ]; 9203 if ( !context ) { 9204 return results; 9205 9206 // Precompiled matchers will still verify ancestry, so step up a level 9207 } else if ( compiled ) { 9208 context = context.parentNode; 9209 } 9210 9211 selector = selector.slice( tokens.shift().value.length ); 9212 } 9213 9214 // Fetch a seed set for right-to-left matching 9215 i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length; 9216 while ( i-- ) { 9217 token = tokens[ i ]; 9218 9219 // Abort if we hit a combinator 9220 if ( Expr.relative[ ( type = token.type ) ] ) { 9221 break; 9222 } 9223 if ( ( find = Expr.find[ type ] ) ) { 9224 9225 // Search, expanding context for leading sibling combinators 9226 if ( ( seed = find( 9227 token.matches[ 0 ].replace( runescape, funescape ), 9228 rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) || 9229 context 9230 ) ) ) { 9231 9232 // If seed is empty or no tokens remain, we can return early 9233 tokens.splice( i, 1 ); 9234 selector = seed.length && toSelector( tokens ); 9235 if ( !selector ) { 9236 push.apply( results, seed ); 9237 return results; 9238 } 9239 9240 break; 9241 } 9242 } 9243 } 9244 } 9245 9246 // Compile and execute a filtering function if one is not provided 9247 // Provide `match` to avoid retokenization if we modified the selector above 9248 ( compiled || compile( selector, match ) )( 9249 seed, 9250 context, 9251 !documentIsHTML, 9252 results, 9253 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context 9254 ); 9255 return results; 9256}; 9257 9258// One-time assignments 9259 9260// Sort stability 9261support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando; 9262 9263// Support: Chrome 14-35+ 9264// Always assume duplicates if they aren't passed to the comparison function 9265support.detectDuplicates = !!hasDuplicate; 9266 9267// Initialize against the default document 9268setDocument(); 9269 9270// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) 9271// Detached nodes confoundingly follow *each other* 9272support.sortDetached = assert( function( el ) { 9273 9274 // Should return 1, but returns 4 (following) 9275 return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1; 9276} ); 9277 9278// Support: IE<8 9279// Prevent attribute/property "interpolation" 9280// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx 9281if ( !assert( function( el ) { 9282 el.innerHTML = "<a href='#'></a>"; 9283 return el.firstChild.getAttribute( "href" ) === "#"; 9284} ) ) { 9285 addHandle( "type|href|height|width", function( elem, name, isXML ) { 9286 if ( !isXML ) { 9287 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); 9288 } 9289 } ); 9290} 9291 9292// Support: IE<9 9293// Use defaultValue in place of getAttribute("value") 9294if ( !support.attributes || !assert( function( el ) { 9295 el.innerHTML = "<input/>"; 9296 el.firstChild.setAttribute( "value", "" ); 9297 return el.firstChild.getAttribute( "value" ) === ""; 9298} ) ) { 9299 addHandle( "value", function( elem, _name, isXML ) { 9300 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { 9301 return elem.defaultValue; 9302 } 9303 } ); 9304} 9305 9306// Support: IE<9 9307// Use getAttributeNode to fetch booleans when getAttribute lies 9308if ( !assert( function( el ) { 9309 return el.getAttribute( "disabled" ) == null; 9310} ) ) { 9311 addHandle( booleans, function( elem, name, isXML ) { 9312 var val; 9313 if ( !isXML ) { 9314 return elem[ name ] === true ? name.toLowerCase() : 9315 ( val = elem.getAttributeNode( name ) ) && val.specified ? 9316 val.value : 9317 null; 9318 } 9319 } ); 9320} 9321 9322return Sizzle; 9323 9324} )( window ); 9325 9326 9327 9328jQuery.find = Sizzle; 9329jQuery.expr = Sizzle.selectors; 9330 9331// Deprecated 9332jQuery.expr[ ":" ] = jQuery.expr.pseudos; 9333jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; 9334jQuery.text = Sizzle.getText; 9335jQuery.isXMLDoc = Sizzle.isXML; 9336jQuery.contains = Sizzle.contains; 9337jQuery.escapeSelector = Sizzle.escape; 9338 9339 9340 9341 9342var dir = function( elem, dir, until ) { 9343 var matched = [], 9344 truncate = until !== undefined; 9345 9346 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { 9347 if ( elem.nodeType === 1 ) { 9348 if ( truncate && jQuery( elem ).is( until ) ) { 9349 break; 9350 } 9351 matched.push( elem ); 9352 } 9353 } 9354 return matched; 9355}; 9356 9357 9358var siblings = function( n, elem ) { 9359 var matched = []; 9360 9361 for ( ; n; n = n.nextSibling ) { 9362 if ( n.nodeType === 1 && n !== elem ) { 9363 matched.push( n ); 9364 } 9365 } 9366 9367 return matched; 9368}; 9369 9370 9371var rneedsContext = jQuery.expr.match.needsContext; 9372 9373 9374 9375function nodeName( elem, name ) { 9376 9377 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); 9378 9379}; 9380var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); 9381 9382 9383 9384// Implement the identical functionality for filter and not 9385function winnow( elements, qualifier, not ) { 9386 if ( isFunction( qualifier ) ) { 9387 return jQuery.grep( elements, function( elem, i ) { 9388 return !!qualifier.call( elem, i, elem ) !== not; 9389 } ); 9390 } 9391 9392 // Single element 9393 if ( qualifier.nodeType ) { 9394 return jQuery.grep( elements, function( elem ) { 9395 return ( elem === qualifier ) !== not; 9396 } ); 9397 } 9398 9399 // Arraylike of elements (jQuery, arguments, Array) 9400 if ( typeof qualifier !== "string" ) { 9401 return jQuery.grep( elements, function( elem ) { 9402 return ( indexOf.call( qualifier, elem ) > -1 ) !== not; 9403 } ); 9404 } 9405 9406 // Filtered directly for both simple and complex selectors 9407 return jQuery.filter( qualifier, elements, not ); 9408} 9409 9410jQuery.filter = function( expr, elems, not ) { 9411 var elem = elems[ 0 ]; 9412 9413 if ( not ) { 9414 expr = ":not(" + expr + ")"; 9415 } 9416 9417 if ( elems.length === 1 && elem.nodeType === 1 ) { 9418 return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; 9419 } 9420 9421 return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { 9422 return elem.nodeType === 1; 9423 } ) ); 9424}; 9425 9426jQuery.fn.extend( { 9427 find: function( selector ) { 9428 var i, ret, 9429 len = this.length, 9430 self = this; 9431 9432 if ( typeof selector !== "string" ) { 9433 return this.pushStack( jQuery( selector ).filter( function() { 9434 for ( i = 0; i < len; i++ ) { 9435 if ( jQuery.contains( self[ i ], this ) ) { 9436 return true; 9437 } 9438 } 9439 } ) ); 9440 } 9441 9442 ret = this.pushStack( [] ); 9443 9444 for ( i = 0; i < len; i++ ) { 9445 jQuery.find( selector, self[ i ], ret ); 9446 } 9447 9448 return len > 1 ? jQuery.uniqueSort( ret ) : ret; 9449 }, 9450 filter: function( selector ) { 9451 return this.pushStack( winnow( this, selector || [], false ) ); 9452 }, 9453 not: function( selector ) { 9454 return this.pushStack( winnow( this, selector || [], true ) ); 9455 }, 9456 is: function( selector ) { 9457 return !!winnow( 9458 this, 9459 9460 // If this is a positional/relative selector, check membership in the returned set 9461 // so $("p:first").is("p:last") won't return true for a doc with two "p". 9462 typeof selector === "string" && rneedsContext.test( selector ) ? 9463 jQuery( selector ) : 9464 selector || [], 9465 false 9466 ).length; 9467 } 9468} ); 9469 9470 9471// Initialize a jQuery object 9472 9473 9474// A central reference to the root jQuery(document) 9475var rootjQuery, 9476 9477 // A simple way to check for HTML strings 9478 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) 9479 // Strict HTML recognition (#11290: must start with <) 9480 // Shortcut simple #id case for speed 9481 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, 9482 9483 init = jQuery.fn.init = function( selector, context, root ) { 9484 var match, elem; 9485 9486 // HANDLE: $(""), $(null), $(undefined), $(false) 9487 if ( !selector ) { 9488 return this; 9489 } 9490 9491 // Method init() accepts an alternate rootjQuery 9492 // so migrate can support jQuery.sub (gh-2101) 9493 root = root || rootjQuery; 9494 9495 // Handle HTML strings 9496 if ( typeof selector === "string" ) { 9497 if ( selector[ 0 ] === "<" && 9498 selector[ selector.length - 1 ] === ">" && 9499 selector.length >= 3 ) { 9500 9501 // Assume that strings that start and end with <> are HTML and skip the regex check 9502 match = [ null, selector, null ]; 9503 9504 } else { 9505 match = rquickExpr.exec( selector ); 9506 } 9507 9508 // Match html or make sure no context is specified for #id 9509 if ( match && ( match[ 1 ] || !context ) ) { 9510 9511 // HANDLE: $(html) -> $(array) 9512 if ( match[ 1 ] ) { 9513 context = context instanceof jQuery ? context[ 0 ] : context; 9514 9515 // Option to run scripts is true for back-compat 9516 // Intentionally let the error be thrown if parseHTML is not present 9517 jQuery.merge( this, jQuery.parseHTML( 9518 match[ 1 ], 9519 context && context.nodeType ? context.ownerDocument || context : document, 9520 true 9521 ) ); 9522 9523 // HANDLE: $(html, props) 9524 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { 9525 for ( match in context ) { 9526 9527 // Properties of context are called as methods if possible 9528 if ( isFunction( this[ match ] ) ) { 9529 this[ match ]( context[ match ] ); 9530 9531 // ...and otherwise set as attributes 9532 } else { 9533 this.attr( match, context[ match ] ); 9534 } 9535 } 9536 } 9537 9538 return this; 9539 9540 // HANDLE: $(#id) 9541 } else { 9542 elem = document.getElementById( match[ 2 ] ); 9543 9544 if ( elem ) { 9545 9546 // Inject the element directly into the jQuery object 9547 this[ 0 ] = elem; 9548 this.length = 1; 9549 } 9550 return this; 9551 } 9552 9553 // HANDLE: $(expr, $(...)) 9554 } else if ( !context || context.jquery ) { 9555 return ( context || root ).find( selector ); 9556 9557 // HANDLE: $(expr, context) 9558 // (which is just equivalent to: $(context).find(expr) 9559 } else { 9560 return this.constructor( context ).find( selector ); 9561 } 9562 9563 // HANDLE: $(DOMElement) 9564 } else if ( selector.nodeType ) { 9565 this[ 0 ] = selector; 9566 this.length = 1; 9567 return this; 9568 9569 // HANDLE: $(function) 9570 // Shortcut for document ready 9571 } else if ( isFunction( selector ) ) { 9572 return root.ready !== undefined ? 9573 root.ready( selector ) : 9574 9575 // Execute immediately if ready is not present 9576 selector( jQuery ); 9577 } 9578 9579 return jQuery.makeArray( selector, this ); 9580 }; 9581 9582// Give the init function the jQuery prototype for later instantiation 9583init.prototype = jQuery.fn; 9584 9585// Initialize central reference 9586rootjQuery = jQuery( document ); 9587 9588 9589var rparentsprev = /^(?:parents|prev(?:Until|All))/, 9590 9591 // Methods guaranteed to produce a unique set when starting from a unique set 9592 guaranteedUnique = { 9593 children: true, 9594 contents: true, 9595 next: true, 9596 prev: true 9597 }; 9598 9599jQuery.fn.extend( { 9600 has: function( target ) { 9601 var targets = jQuery( target, this ), 9602 l = targets.length; 9603 9604 return this.filter( function() { 9605 var i = 0; 9606 for ( ; i < l; i++ ) { 9607 if ( jQuery.contains( this, targets[ i ] ) ) { 9608 return true; 9609 } 9610 } 9611 } ); 9612 }, 9613 9614 closest: function( selectors, context ) { 9615 var cur, 9616 i = 0, 9617 l = this.length, 9618 matched = [], 9619 targets = typeof selectors !== "string" && jQuery( selectors ); 9620 9621 // Positional selectors never match, since there's no _selection_ context 9622 if ( !rneedsContext.test( selectors ) ) { 9623 for ( ; i < l; i++ ) { 9624 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { 9625 9626 // Always skip document fragments 9627 if ( cur.nodeType < 11 && ( targets ? 9628 targets.index( cur ) > -1 : 9629 9630 // Don't pass non-elements to Sizzle 9631 cur.nodeType === 1 && 9632 jQuery.find.matchesSelector( cur, selectors ) ) ) { 9633 9634 matched.push( cur ); 9635 break; 9636 } 9637 } 9638 } 9639 } 9640 9641 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); 9642 }, 9643 9644 // Determine the position of an element within the set 9645 index: function( elem ) { 9646 9647 // No argument, return index in parent 9648 if ( !elem ) { 9649 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; 9650 } 9651 9652 // Index in selector 9653 if ( typeof elem === "string" ) { 9654 return indexOf.call( jQuery( elem ), this[ 0 ] ); 9655 } 9656 9657 // Locate the position of the desired element 9658 return indexOf.call( this, 9659 9660 // If it receives a jQuery object, the first element is used 9661 elem.jquery ? elem[ 0 ] : elem 9662 ); 9663 }, 9664 9665 add: function( selector, context ) { 9666 return this.pushStack( 9667 jQuery.uniqueSort( 9668 jQuery.merge( this.get(), jQuery( selector, context ) ) 9669 ) 9670 ); 9671 }, 9672 9673 addBack: function( selector ) { 9674 return this.add( selector == null ? 9675 this.prevObject : this.prevObject.filter( selector ) 9676 ); 9677 } 9678} ); 9679 9680function sibling( cur, dir ) { 9681 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} 9682 return cur; 9683} 9684 9685jQuery.each( { 9686 parent: function( elem ) { 9687 var parent = elem.parentNode; 9688 return parent && parent.nodeType !== 11 ? parent : null; 9689 }, 9690 parents: function( elem ) { 9691 return dir( elem, "parentNode" ); 9692 }, 9693 parentsUntil: function( elem, _i, until ) { 9694 return dir( elem, "parentNode", until ); 9695 }, 9696 next: function( elem ) { 9697 return sibling( elem, "nextSibling" ); 9698 }, 9699 prev: function( elem ) { 9700 return sibling( elem, "previousSibling" ); 9701 }, 9702 nextAll: function( elem ) { 9703 return dir( elem, "nextSibling" ); 9704 }, 9705 prevAll: function( elem ) { 9706 return dir( elem, "previousSibling" ); 9707 }, 9708 nextUntil: function( elem, _i, until ) { 9709 return dir( elem, "nextSibling", until ); 9710 }, 9711 prevUntil: function( elem, _i, until ) { 9712 return dir( elem, "previousSibling", until ); 9713 }, 9714 siblings: function( elem ) { 9715 return siblings( ( elem.parentNode || {} ).firstChild, elem ); 9716 }, 9717 children: function( elem ) { 9718 return siblings( elem.firstChild ); 9719 }, 9720 contents: function( elem ) { 9721 if ( elem.contentDocument != null && 9722 9723 // Support: IE 11+ 9724 // <object> elements with no `data` attribute has an object 9725 // `contentDocument` with a `null` prototype. 9726 getProto( elem.contentDocument ) ) { 9727 9728 return elem.contentDocument; 9729 } 9730 9731 // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only 9732 // Treat the template element as a regular one in browsers that 9733 // don't support it. 9734 if ( nodeName( elem, "template" ) ) { 9735 elem = elem.content || elem; 9736 } 9737 9738 return jQuery.merge( [], elem.childNodes ); 9739 } 9740}, function( name, fn ) { 9741 jQuery.fn[ name ] = function( until, selector ) { 9742 var matched = jQuery.map( this, fn, until ); 9743 9744 if ( name.slice( -5 ) !== "Until" ) { 9745 selector = until; 9746 } 9747 9748 if ( selector && typeof selector === "string" ) { 9749 matched = jQuery.filter( selector, matched ); 9750 } 9751 9752 if ( this.length > 1 ) { 9753 9754 // Remove duplicates 9755 if ( !guaranteedUnique[ name ] ) { 9756 jQuery.uniqueSort( matched ); 9757 } 9758 9759 // Reverse order for parents* and prev-derivatives 9760 if ( rparentsprev.test( name ) ) { 9761 matched.reverse(); 9762 } 9763 } 9764 9765 return this.pushStack( matched ); 9766 }; 9767} ); 9768var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g ); 9769 9770 9771 9772// Convert String-formatted options into Object-formatted ones 9773function createOptions( options ) { 9774 var object = {}; 9775 jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) { 9776 object[ flag ] = true; 9777 } ); 9778 return object; 9779} 9780 9781/* 9782 * Create a callback list using the following parameters: 9783 * 9784 * options: an optional list of space-separated options that will change how 9785 * the callback list behaves or a more traditional option object 9786 * 9787 * By default a callback list will act like an event callback list and can be 9788 * "fired" multiple times. 9789 * 9790 * Possible options: 9791 * 9792 * once: will ensure the callback list can only be fired once (like a Deferred) 9793 * 9794 * memory: will keep track of previous values and will call any callback added 9795 * after the list has been fired right away with the latest "memorized" 9796 * values (like a Deferred) 9797 * 9798 * unique: will ensure a callback can only be added once (no duplicate in the list) 9799 * 9800 * stopOnFalse: interrupt callings when a callback returns false 9801 * 9802 */ 9803jQuery.Callbacks = function( options ) { 9804 9805 // Convert options from String-formatted to Object-formatted if needed 9806 // (we check in cache first) 9807 options = typeof options === "string" ? 9808 createOptions( options ) : 9809 jQuery.extend( {}, options ); 9810 9811 var // Flag to know if list is currently firing 9812 firing, 9813 9814 // Last fire value for non-forgettable lists 9815 memory, 9816 9817 // Flag to know if list was already fired 9818 fired, 9819 9820 // Flag to prevent firing 9821 locked, 9822 9823 // Actual callback list 9824 list = [], 9825 9826 // Queue of execution data for repeatable lists 9827 queue = [], 9828 9829 // Index of currently firing callback (modified by add/remove as needed) 9830 firingIndex = -1, 9831 9832 // Fire callbacks 9833 fire = function() { 9834 9835 // Enforce single-firing 9836 locked = locked || options.once; 9837 9838 // Execute callbacks for all pending executions, 9839 // respecting firingIndex overrides and runtime changes 9840 fired = firing = true; 9841 for ( ; queue.length; firingIndex = -1 ) { 9842 memory = queue.shift(); 9843 while ( ++firingIndex < list.length ) { 9844 9845 // Run callback and check for early termination 9846 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && 9847 options.stopOnFalse ) { 9848 9849 // Jump to end and forget the data so .add doesn't re-fire 9850 firingIndex = list.length; 9851 memory = false; 9852 } 9853 } 9854 } 9855 9856 // Forget the data if we're done with it 9857 if ( !options.memory ) { 9858 memory = false; 9859 } 9860 9861 firing = false; 9862 9863 // Clean up if we're done firing for good 9864 if ( locked ) { 9865 9866 // Keep an empty list if we have data for future add calls 9867 if ( memory ) { 9868 list = []; 9869 9870 // Otherwise, this object is spent 9871 } else { 9872 list = ""; 9873 } 9874 } 9875 }, 9876 9877 // Actual Callbacks object 9878 self = { 9879 9880 // Add a callback or a collection of callbacks to the list 9881 add: function() { 9882 if ( list ) { 9883 9884 // If we have memory from a past run, we should fire after adding 9885 if ( memory && !firing ) { 9886 firingIndex = list.length - 1; 9887 queue.push( memory ); 9888 } 9889 9890 ( function add( args ) { 9891 jQuery.each( args, function( _, arg ) { 9892 if ( isFunction( arg ) ) { 9893 if ( !options.unique || !self.has( arg ) ) { 9894 list.push( arg ); 9895 } 9896 } else if ( arg && arg.length && toType( arg ) !== "string" ) { 9897 9898 // Inspect recursively 9899 add( arg ); 9900 } 9901 } ); 9902 } )( arguments ); 9903 9904 if ( memory && !firing ) { 9905 fire(); 9906 } 9907 } 9908 return this; 9909 }, 9910 9911 // Remove a callback from the list 9912 remove: function() { 9913 jQuery.each( arguments, function( _, arg ) { 9914 var index; 9915 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { 9916 list.splice( index, 1 ); 9917 9918 // Handle firing indexes 9919 if ( index <= firingIndex ) { 9920 firingIndex--; 9921 } 9922 } 9923 } ); 9924 return this; 9925 }, 9926 9927 // Check if a given callback is in the list. 9928 // If no argument is given, return whether or not list has callbacks attached. 9929 has: function( fn ) { 9930 return fn ? 9931 jQuery.inArray( fn, list ) > -1 : 9932 list.length > 0; 9933 }, 9934 9935 // Remove all callbacks from the list 9936 empty: function() { 9937 if ( list ) { 9938 list = []; 9939 } 9940 return this; 9941 }, 9942 9943 // Disable .fire and .add 9944 // Abort any current/pending executions 9945 // Clear all callbacks and values 9946 disable: function() { 9947 locked = queue = []; 9948 list = memory = ""; 9949 return this; 9950 }, 9951 disabled: function() { 9952 return !list; 9953 }, 9954 9955 // Disable .fire 9956 // Also disable .add unless we have memory (since it would have no effect) 9957 // Abort any pending executions 9958 lock: function() { 9959 locked = queue = []; 9960 if ( !memory && !firing ) { 9961 list = memory = ""; 9962 } 9963 return this; 9964 }, 9965 locked: function() { 9966 return !!locked; 9967 }, 9968 9969 // Call all callbacks with the given context and arguments 9970 fireWith: function( context, args ) { 9971 if ( !locked ) { 9972 args = args || []; 9973 args = [ context, args.slice ? args.slice() : args ]; 9974 queue.push( args ); 9975 if ( !firing ) { 9976 fire(); 9977 } 9978 } 9979 return this; 9980 }, 9981 9982 // Call all the callbacks with the given arguments 9983 fire: function() { 9984 self.fireWith( this, arguments ); 9985 return this; 9986 }, 9987 9988 // To know if the callbacks have already been called at least once 9989 fired: function() { 9990 return !!fired; 9991 } 9992 }; 9993 9994 return self; 9995}; 9996 9997 9998function Identity( v ) { 9999 return v; 10000} 10001function Thrower( ex ) { 10002 throw ex; 10003} 10004 10005function adoptValue( value, resolve, reject, noValue ) { 10006 var method; 10007 10008 try { 10009 10010 // Check for promise aspect first to privilege synchronous behavior 10011 if ( value && isFunction( ( method = value.promise ) ) ) { 10012 method.call( value ).done( resolve ).fail( reject ); 10013 10014 // Other thenables 10015 } else if ( value && isFunction( ( method = value.then ) ) ) { 10016 method.call( value, resolve, reject ); 10017 10018 // Other non-thenables 10019 } else { 10020 10021 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: 10022 // * false: [ value ].slice( 0 ) => resolve( value ) 10023 // * true: [ value ].slice( 1 ) => resolve() 10024 resolve.apply( undefined, [ value ].slice( noValue ) ); 10025 } 10026 10027 // For Promises/A+, convert exceptions into rejections 10028 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in 10029 // Deferred#then to conditionally suppress rejection. 10030 } catch ( value ) { 10031 10032 // Support: Android 4.0 only 10033 // Strict mode functions invoked without .call/.apply get global-object context 10034 reject.apply( undefined, [ value ] ); 10035 } 10036} 10037 10038jQuery.extend( { 10039 10040 Deferred: function( func ) { 10041 var tuples = [ 10042 10043 // action, add listener, callbacks, 10044 // ... .then handlers, argument index, [final state] 10045 [ "notify", "progress", jQuery.Callbacks( "memory" ), 10046 jQuery.Callbacks( "memory" ), 2 ], 10047 [ "resolve", "done", jQuery.Callbacks( "once memory" ), 10048 jQuery.Callbacks( "once memory" ), 0, "resolved" ], 10049 [ "reject", "fail", jQuery.Callbacks( "once memory" ), 10050 jQuery.Callbacks( "once memory" ), 1, "rejected" ] 10051 ], 10052 state = "pending", 10053 promise = { 10054 state: function() { 10055 return state; 10056 }, 10057 always: function() { 10058 deferred.done( arguments ).fail( arguments ); 10059 return this; 10060 }, 10061 "catch": function( fn ) { 10062 return promise.then( null, fn ); 10063 }, 10064 10065 // Keep pipe for back-compat 10066 pipe: function( /* fnDone, fnFail, fnProgress */ ) { 10067 var fns = arguments; 10068 10069 return jQuery.Deferred( function( newDefer ) { 10070 jQuery.each( tuples, function( _i, tuple ) { 10071 10072 // Map tuples (progress, done, fail) to arguments (done, fail, progress) 10073 var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; 10074 10075 // deferred.progress(function() { bind to newDefer or newDefer.notify }) 10076 // deferred.done(function() { bind to newDefer or newDefer.resolve }) 10077 // deferred.fail(function() { bind to newDefer or newDefer.reject }) 10078 deferred[ tuple[ 1 ] ]( function() { 10079 var returned = fn && fn.apply( this, arguments ); 10080 if ( returned && isFunction( returned.promise ) ) { 10081 returned.promise() 10082 .progress( newDefer.notify ) 10083 .done( newDefer.resolve ) 10084 .fail( newDefer.reject ); 10085 } else { 10086 newDefer[ tuple[ 0 ] + "With" ]( 10087 this, 10088 fn ? [ returned ] : arguments 10089 ); 10090 } 10091 } ); 10092 } ); 10093 fns = null; 10094 } ).promise(); 10095 }, 10096 then: function( onFulfilled, onRejected, onProgress ) { 10097 var maxDepth = 0; 10098 function resolve( depth, deferred, handler, special ) { 10099 return function() { 10100 var that = this, 10101 args = arguments, 10102 mightThrow = function() { 10103 var returned, then; 10104 10105 // Support: Promises/A+ section 2.3.3.3.3 10106 // https://promisesaplus.com/#point-59 10107 // Ignore double-resolution attempts 10108 if ( depth < maxDepth ) { 10109 return; 10110 } 10111 10112 returned = handler.apply( that, args ); 10113 10114 // Support: Promises/A+ section 2.3.1 10115 // https://promisesaplus.com/#point-48 10116 if ( returned === deferred.promise() ) { 10117 throw new TypeError( "Thenable self-resolution" ); 10118 } 10119 10120 // Support: Promises/A+ sections 2.3.3.1, 3.5 10121 // https://promisesaplus.com/#point-54 10122 // https://promisesaplus.com/#point-75 10123 // Retrieve `then` only once 10124 then = returned && 10125 10126 // Support: Promises/A+ section 2.3.4 10127 // https://promisesaplus.com/#point-64 10128 // Only check objects and functions for thenability 10129 ( typeof returned === "object" || 10130 typeof returned === "function" ) && 10131 returned.then; 10132 10133 // Handle a returned thenable 10134 if ( isFunction( then ) ) { 10135 10136 // Special processors (notify) just wait for resolution 10137 if ( special ) { 10138 then.call( 10139 returned, 10140 resolve( maxDepth, deferred, Identity, special ), 10141 resolve( maxDepth, deferred, Thrower, special ) 10142 ); 10143 10144 // Normal processors (resolve) also hook into progress 10145 } else { 10146 10147 // ...and disregard older resolution values 10148 maxDepth++; 10149 10150 then.call( 10151 returned, 10152 resolve( maxDepth, deferred, Identity, special ), 10153 resolve( maxDepth, deferred, Thrower, special ), 10154 resolve( maxDepth, deferred, Identity, 10155 deferred.notifyWith ) 10156 ); 10157 } 10158 10159 // Handle all other returned values 10160 } else { 10161 10162 // Only substitute handlers pass on context 10163 // and multiple values (non-spec behavior) 10164 if ( handler !== Identity ) { 10165 that = undefined; 10166 args = [ returned ]; 10167 } 10168 10169 // Process the value(s) 10170 // Default process is resolve 10171 ( special || deferred.resolveWith )( that, args ); 10172 } 10173 }, 10174 10175 // Only normal processors (resolve) catch and reject exceptions 10176 process = special ? 10177 mightThrow : 10178 function() { 10179 try { 10180 mightThrow(); 10181 } catch ( e ) { 10182 10183 if ( jQuery.Deferred.exceptionHook ) { 10184 jQuery.Deferred.exceptionHook( e, 10185 process.stackTrace ); 10186 } 10187 10188 // Support: Promises/A+ section 2.3.3.3.4.1 10189 // https://promisesaplus.com/#point-61 10190 // Ignore post-resolution exceptions 10191 if ( depth + 1 >= maxDepth ) { 10192 10193 // Only substitute handlers pass on context 10194 // and multiple values (non-spec behavior) 10195 if ( handler !== Thrower ) { 10196 that = undefined; 10197 args = [ e ]; 10198 } 10199 10200 deferred.rejectWith( that, args ); 10201 } 10202 } 10203 }; 10204 10205 // Support: Promises/A+ section 2.3.3.3.1 10206 // https://promisesaplus.com/#point-57 10207 // Re-resolve promises immediately to dodge false rejection from 10208 // subsequent errors 10209 if ( depth ) { 10210 process(); 10211 } else { 10212 10213 // Call an optional hook to record the stack, in case of exception 10214 // since it's otherwise lost when execution goes async 10215 if ( jQuery.Deferred.getStackHook ) { 10216 process.stackTrace = jQuery.Deferred.getStackHook(); 10217 } 10218 window.setTimeout( process ); 10219 } 10220 }; 10221 } 10222 10223 return jQuery.Deferred( function( newDefer ) { 10224 10225 // progress_handlers.add( ... ) 10226 tuples[ 0 ][ 3 ].add( 10227 resolve( 10228 0, 10229 newDefer, 10230 isFunction( onProgress ) ? 10231 onProgress : 10232 Identity, 10233 newDefer.notifyWith 10234 ) 10235 ); 10236 10237 // fulfilled_handlers.add( ... ) 10238 tuples[ 1 ][ 3 ].add( 10239 resolve( 10240 0, 10241 newDefer, 10242 isFunction( onFulfilled ) ? 10243 onFulfilled : 10244 Identity 10245 ) 10246 ); 10247 10248 // rejected_handlers.add( ... ) 10249 tuples[ 2 ][ 3 ].add( 10250 resolve( 10251 0, 10252 newDefer, 10253 isFunction( onRejected ) ? 10254 onRejected : 10255 Thrower 10256 ) 10257 ); 10258 } ).promise(); 10259 }, 10260 10261 // Get a promise for this deferred 10262 // If obj is provided, the promise aspect is added to the object 10263 promise: function( obj ) { 10264 return obj != null ? jQuery.extend( obj, promise ) : promise; 10265 } 10266 }, 10267 deferred = {}; 10268 10269 // Add list-specific methods 10270 jQuery.each( tuples, function( i, tuple ) { 10271 var list = tuple[ 2 ], 10272 stateString = tuple[ 5 ]; 10273 10274 // promise.progress = list.add 10275 // promise.done = list.add 10276 // promise.fail = list.add 10277 promise[ tuple[ 1 ] ] = list.add; 10278 10279 // Handle state 10280 if ( stateString ) { 10281 list.add( 10282 function() { 10283 10284 // state = "resolved" (i.e., fulfilled) 10285 // state = "rejected" 10286 state = stateString; 10287 }, 10288 10289 // rejected_callbacks.disable 10290 // fulfilled_callbacks.disable 10291 tuples[ 3 - i ][ 2 ].disable, 10292 10293 // rejected_handlers.disable 10294 // fulfilled_handlers.disable 10295 tuples[ 3 - i ][ 3 ].disable, 10296 10297 // progress_callbacks.lock 10298 tuples[ 0 ][ 2 ].lock, 10299 10300 // progress_handlers.lock 10301 tuples[ 0 ][ 3 ].lock 10302 ); 10303 } 10304 10305 // progress_handlers.fire 10306 // fulfilled_handlers.fire 10307 // rejected_handlers.fire 10308 list.add( tuple[ 3 ].fire ); 10309 10310 // deferred.notify = function() { deferred.notifyWith(...) } 10311 // deferred.resolve = function() { deferred.resolveWith(...) } 10312 // deferred.reject = function() { deferred.rejectWith(...) } 10313 deferred[ tuple[ 0 ] ] = function() { 10314 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); 10315 return this; 10316 }; 10317 10318 // deferred.notifyWith = list.fireWith 10319 // deferred.resolveWith = list.fireWith 10320 // deferred.rejectWith = list.fireWith 10321 deferred[ tuple[ 0 ] + "With" ] = list.fireWith; 10322 } ); 10323 10324 // Make the deferred a promise 10325 promise.promise( deferred ); 10326 10327 // Call given func if any 10328 if ( func ) { 10329 func.call( deferred, deferred ); 10330 } 10331 10332 // All done! 10333 return deferred; 10334 }, 10335 10336 // Deferred helper 10337 when: function( singleValue ) { 10338 var 10339 10340 // count of uncompleted subordinates 10341 remaining = arguments.length, 10342 10343 // count of unprocessed arguments 10344 i = remaining, 10345 10346 // subordinate fulfillment data 10347 resolveContexts = Array( i ), 10348 resolveValues = slice.call( arguments ), 10349 10350 // the master Deferred 10351 master = jQuery.Deferred(), 10352 10353 // subordinate callback factory 10354 updateFunc = function( i ) { 10355 return function( value ) { 10356 resolveContexts[ i ] = this; 10357 resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; 10358 if ( !( --remaining ) ) { 10359 master.resolveWith( resolveContexts, resolveValues ); 10360 } 10361 }; 10362 }; 10363 10364 // Single- and empty arguments are adopted like Promise.resolve 10365 if ( remaining <= 1 ) { 10366 adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject, 10367 !remaining ); 10368 10369 // Use .then() to unwrap secondary thenables (cf. gh-3000) 10370 if ( master.state() === "pending" || 10371 isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { 10372 10373 return master.then(); 10374 } 10375 } 10376 10377 // Multiple arguments are aggregated like Promise.all array elements 10378 while ( i-- ) { 10379 adoptValue( resolveValues[ i ], updateFunc( i ), master.reject ); 10380 } 10381 10382 return master.promise(); 10383 } 10384} ); 10385 10386 10387// These usually indicate a programmer mistake during development, 10388// warn about them ASAP rather than swallowing them by default. 10389var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; 10390 10391jQuery.Deferred.exceptionHook = function( error, stack ) { 10392 10393 // Support: IE 8 - 9 only 10394 // Console exists when dev tools are open, which can happen at any time 10395 if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { 10396 window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack ); 10397 } 10398}; 10399 10400 10401 10402 10403jQuery.readyException = function( error ) { 10404 window.setTimeout( function() { 10405 throw error; 10406 } ); 10407}; 10408 10409 10410 10411 10412// The deferred used on DOM ready 10413var readyList = jQuery.Deferred(); 10414 10415jQuery.fn.ready = function( fn ) { 10416 10417 readyList 10418 .then( fn ) 10419 10420 // Wrap jQuery.readyException in a function so that the lookup 10421 // happens at the time of error handling instead of callback 10422 // registration. 10423 .catch( function( error ) { 10424 jQuery.readyException( error ); 10425 } ); 10426 10427 return this; 10428}; 10429 10430jQuery.extend( { 10431 10432 // Is the DOM ready to be used? Set to true once it occurs. 10433 isReady: false, 10434 10435 // A counter to track how many items to wait for before 10436 // the ready event fires. See #6781 10437 readyWait: 1, 10438 10439 // Handle when the DOM is ready 10440 ready: function( wait ) { 10441 10442 // Abort if there are pending holds or we're already ready 10443 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { 10444 return; 10445 } 10446 10447 // Remember that the DOM is ready 10448 jQuery.isReady = true; 10449 10450 // If a normal DOM Ready event fired, decrement, and wait if need be 10451 if ( wait !== true && --jQuery.readyWait > 0 ) { 10452 return; 10453 } 10454 10455 // If there are functions bound, to execute 10456 readyList.resolveWith( document, [ jQuery ] ); 10457 } 10458} ); 10459 10460jQuery.ready.then = readyList.then; 10461 10462// The ready event handler and self cleanup method 10463function completed() { 10464 document.removeEventListener( "DOMContentLoaded", completed ); 10465 window.removeEventListener( "load", completed ); 10466 jQuery.ready(); 10467} 10468 10469// Catch cases where $(document).ready() is called 10470// after the browser event has already occurred. 10471// Support: IE <=9 - 10 only 10472// Older IE sometimes signals "interactive" too soon 10473if ( document.readyState === "complete" || 10474 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { 10475 10476 // Handle it asynchronously to allow scripts the opportunity to delay ready 10477 window.setTimeout( jQuery.ready ); 10478 10479} else { 10480 10481 // Use the handy event callback 10482 document.addEventListener( "DOMContentLoaded", completed ); 10483 10484 // A fallback to window.onload, that will always work 10485 window.addEventListener( "load", completed ); 10486} 10487 10488 10489 10490 10491// Multifunctional method to get and set values of a collection 10492// The value/s can optionally be executed if it's a function 10493var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { 10494 var i = 0, 10495 len = elems.length, 10496 bulk = key == null; 10497 10498 // Sets many values 10499 if ( toType( key ) === "object" ) { 10500 chainable = true; 10501 for ( i in key ) { 10502 access( elems, fn, i, key[ i ], true, emptyGet, raw ); 10503 } 10504 10505 // Sets one value 10506 } else if ( value !== undefined ) { 10507 chainable = true; 10508 10509 if ( !isFunction( value ) ) { 10510 raw = true; 10511 } 10512 10513 if ( bulk ) { 10514 10515 // Bulk operations run against the entire set 10516 if ( raw ) { 10517 fn.call( elems, value ); 10518 fn = null; 10519 10520 // ...except when executing function values 10521 } else { 10522 bulk = fn; 10523 fn = function( elem, _key, value ) { 10524 return bulk.call( jQuery( elem ), value ); 10525 }; 10526 } 10527 } 10528 10529 if ( fn ) { 10530 for ( ; i < len; i++ ) { 10531 fn( 10532 elems[ i ], key, raw ? 10533 value : 10534 value.call( elems[ i ], i, fn( elems[ i ], key ) ) 10535 ); 10536 } 10537 } 10538 } 10539 10540 if ( chainable ) { 10541 return elems; 10542 } 10543 10544 // Gets 10545 if ( bulk ) { 10546 return fn.call( elems ); 10547 } 10548 10549 return len ? fn( elems[ 0 ], key ) : emptyGet; 10550}; 10551 10552 10553// Matches dashed string for camelizing 10554var rmsPrefix = /^-ms-/, 10555 rdashAlpha = /-([a-z])/g; 10556 10557// Used by camelCase as callback to replace() 10558function fcamelCase( _all, letter ) { 10559 return letter.toUpperCase(); 10560} 10561 10562// Convert dashed to camelCase; used by the css and data modules 10563// Support: IE <=9 - 11, Edge 12 - 15 10564// Microsoft forgot to hump their vendor prefix (#9572) 10565function camelCase( string ) { 10566 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); 10567} 10568var acceptData = function( owner ) { 10569 10570 // Accepts only: 10571 // - Node 10572 // - Node.ELEMENT_NODE 10573 // - Node.DOCUMENT_NODE 10574 // - Object 10575 // - Any 10576 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); 10577}; 10578 10579 10580 10581 10582function Data() { 10583 this.expando = jQuery.expando + Data.uid++; 10584} 10585 10586Data.uid = 1; 10587 10588Data.prototype = { 10589 10590 cache: function( owner ) { 10591 10592 // Check if the owner object already has a cache 10593 var value = owner[ this.expando ]; 10594 10595 // If not, create one 10596 if ( !value ) { 10597 value = {}; 10598 10599 // We can accept data for non-element nodes in modern browsers, 10600 // but we should not, see #8335. 10601 // Always return an empty object. 10602 if ( acceptData( owner ) ) { 10603 10604 // If it is a node unlikely to be stringify-ed or looped over 10605 // use plain assignment 10606 if ( owner.nodeType ) { 10607 owner[ this.expando ] = value; 10608 10609 // Otherwise secure it in a non-enumerable property 10610 // configurable must be true to allow the property to be 10611 // deleted when data is removed 10612 } else { 10613 Object.defineProperty( owner, this.expando, { 10614 value: value, 10615 configurable: true 10616 } ); 10617 } 10618 } 10619 } 10620 10621 return value; 10622 }, 10623 set: function( owner, data, value ) { 10624 var prop, 10625 cache = this.cache( owner ); 10626 10627 // Handle: [ owner, key, value ] args 10628 // Always use camelCase key (gh-2257) 10629 if ( typeof data === "string" ) { 10630 cache[ camelCase( data ) ] = value; 10631 10632 // Handle: [ owner, { properties } ] args 10633 } else { 10634 10635 // Copy the properties one-by-one to the cache object 10636 for ( prop in data ) { 10637 cache[ camelCase( prop ) ] = data[ prop ]; 10638 } 10639 } 10640 return cache; 10641 }, 10642 get: function( owner, key ) { 10643 return key === undefined ? 10644 this.cache( owner ) : 10645 10646 // Always use camelCase key (gh-2257) 10647 owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; 10648 }, 10649 access: function( owner, key, value ) { 10650 10651 // In cases where either: 10652 // 10653 // 1. No key was specified 10654 // 2. A string key was specified, but no value provided 10655 // 10656 // Take the "read" path and allow the get method to determine 10657 // which value to return, respectively either: 10658 // 10659 // 1. The entire cache object 10660 // 2. The data stored at the key 10661 // 10662 if ( key === undefined || 10663 ( ( key && typeof key === "string" ) && value === undefined ) ) { 10664 10665 return this.get( owner, key ); 10666 } 10667 10668 // When the key is not a string, or both a key and value 10669 // are specified, set or extend (existing objects) with either: 10670 // 10671 // 1. An object of properties 10672 // 2. A key and value 10673 // 10674 this.set( owner, key, value ); 10675 10676 // Since the "set" path can have two possible entry points 10677 // return the expected data based on which path was taken[*] 10678 return value !== undefined ? value : key; 10679 }, 10680 remove: function( owner, key ) { 10681 var i, 10682 cache = owner[ this.expando ]; 10683 10684 if ( cache === undefined ) { 10685 return; 10686 } 10687 10688 if ( key !== undefined ) { 10689 10690 // Support array or space separated string of keys 10691 if ( Array.isArray( key ) ) { 10692 10693 // If key is an array of keys... 10694 // We always set camelCase keys, so remove that. 10695 key = key.map( camelCase ); 10696 } else { 10697 key = camelCase( key ); 10698 10699 // If a key with the spaces exists, use it. 10700 // Otherwise, create an array by matching non-whitespace 10701 key = key in cache ? 10702 [ key ] : 10703 ( key.match( rnothtmlwhite ) || [] ); 10704 } 10705 10706 i = key.length; 10707 10708 while ( i-- ) { 10709 delete cache[ key[ i ] ]; 10710 } 10711 } 10712 10713 // Remove the expando if there's no more data 10714 if ( key === undefined || jQuery.isEmptyObject( cache ) ) { 10715 10716 // Support: Chrome <=35 - 45 10717 // Webkit & Blink performance suffers when deleting properties 10718 // from DOM nodes, so set to undefined instead 10719 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) 10720 if ( owner.nodeType ) { 10721 owner[ this.expando ] = undefined; 10722 } else { 10723 delete owner[ this.expando ]; 10724 } 10725 } 10726 }, 10727 hasData: function( owner ) { 10728 var cache = owner[ this.expando ]; 10729 return cache !== undefined && !jQuery.isEmptyObject( cache ); 10730 } 10731}; 10732var dataPriv = new Data(); 10733 10734var dataUser = new Data(); 10735 10736 10737 10738// Implementation Summary 10739// 10740// 1. Enforce API surface and semantic compatibility with 1.9.x branch 10741// 2. Improve the module's maintainability by reducing the storage 10742// paths to a single mechanism. 10743// 3. Use the same single mechanism to support "private" and "user" data. 10744// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) 10745// 5. Avoid exposing implementation details on user objects (eg. expando properties) 10746// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 10747 10748var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, 10749 rmultiDash = /[A-Z]/g; 10750 10751function getData( data ) { 10752 if ( data === "true" ) { 10753 return true; 10754 } 10755 10756 if ( data === "false" ) { 10757 return false; 10758 } 10759 10760 if ( data === "null" ) { 10761 return null; 10762 } 10763 10764 // Only convert to a number if it doesn't change the string 10765 if ( data === +data + "" ) { 10766 return +data; 10767 } 10768 10769 if ( rbrace.test( data ) ) { 10770 return JSON.parse( data ); 10771 } 10772 10773 return data; 10774} 10775 10776function dataAttr( elem, key, data ) { 10777 var name; 10778 10779 // If nothing was found internally, try to fetch any 10780 // data from the HTML5 data-* attribute 10781 if ( data === undefined && elem.nodeType === 1 ) { 10782 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); 10783 data = elem.getAttribute( name ); 10784 10785 if ( typeof data === "string" ) { 10786 try { 10787 data = getData( data ); 10788 } catch ( e ) {} 10789 10790 // Make sure we set the data so it isn't changed later 10791 dataUser.set( elem, key, data ); 10792 } else { 10793 data = undefined; 10794 } 10795 } 10796 return data; 10797} 10798 10799jQuery.extend( { 10800 hasData: function( elem ) { 10801 return dataUser.hasData( elem ) || dataPriv.hasData( elem ); 10802 }, 10803 10804 data: function( elem, name, data ) { 10805 return dataUser.access( elem, name, data ); 10806 }, 10807 10808 removeData: function( elem, name ) { 10809 dataUser.remove( elem, name ); 10810 }, 10811 10812 // TODO: Now that all calls to _data and _removeData have been replaced 10813 // with direct calls to dataPriv methods, these can be deprecated. 10814 _data: function( elem, name, data ) { 10815 return dataPriv.access( elem, name, data ); 10816 }, 10817 10818 _removeData: function( elem, name ) { 10819 dataPriv.remove( elem, name ); 10820 } 10821} ); 10822 10823jQuery.fn.extend( { 10824 data: function( key, value ) { 10825 var i, name, data, 10826 elem = this[ 0 ], 10827 attrs = elem && elem.attributes; 10828 10829 // Gets all values 10830 if ( key === undefined ) { 10831 if ( this.length ) { 10832 data = dataUser.get( elem ); 10833 10834 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { 10835 i = attrs.length; 10836 while ( i-- ) { 10837 10838 // Support: IE 11 only 10839 // The attrs elements can be null (#14894) 10840 if ( attrs[ i ] ) { 10841 name = attrs[ i ].name; 10842 if ( name.indexOf( "data-" ) === 0 ) { 10843 name = camelCase( name.slice( 5 ) ); 10844 dataAttr( elem, name, data[ name ] ); 10845 } 10846 } 10847 } 10848 dataPriv.set( elem, "hasDataAttrs", true ); 10849 } 10850 } 10851 10852 return data; 10853 } 10854 10855 // Sets multiple values 10856 if ( typeof key === "object" ) { 10857 return this.each( function() { 10858 dataUser.set( this, key ); 10859 } ); 10860 } 10861 10862 return access( this, function( value ) { 10863 var data; 10864 10865 // The calling jQuery object (element matches) is not empty 10866 // (and therefore has an element appears at this[ 0 ]) and the 10867 // `value` parameter was not undefined. An empty jQuery object 10868 // will result in `undefined` for elem = this[ 0 ] which will 10869 // throw an exception if an attempt to read a data cache is made. 10870 if ( elem && value === undefined ) { 10871 10872 // Attempt to get data from the cache 10873 // The key will always be camelCased in Data 10874 data = dataUser.get( elem, key ); 10875 if ( data !== undefined ) { 10876 return data; 10877 } 10878 10879 // Attempt to "discover" the data in 10880 // HTML5 custom data-* attrs 10881 data = dataAttr( elem, key ); 10882 if ( data !== undefined ) { 10883 return data; 10884 } 10885 10886 // We tried really hard, but the data doesn't exist. 10887 return; 10888 } 10889 10890 // Set the data... 10891 this.each( function() { 10892 10893 // We always store the camelCased key 10894 dataUser.set( this, key, value ); 10895 } ); 10896 }, null, value, arguments.length > 1, null, true ); 10897 }, 10898 10899 removeData: function( key ) { 10900 return this.each( function() { 10901 dataUser.remove( this, key ); 10902 } ); 10903 } 10904} ); 10905 10906 10907jQuery.extend( { 10908 queue: function( elem, type, data ) { 10909 var queue; 10910 10911 if ( elem ) { 10912 type = ( type || "fx" ) + "queue"; 10913 queue = dataPriv.get( elem, type ); 10914 10915 // Speed up dequeue by getting out quickly if this is just a lookup 10916 if ( data ) { 10917 if ( !queue || Array.isArray( data ) ) { 10918 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); 10919 } else { 10920 queue.push( data ); 10921 } 10922 } 10923 return queue || []; 10924 } 10925 }, 10926 10927 dequeue: function( elem, type ) { 10928 type = type || "fx"; 10929 10930 var queue = jQuery.queue( elem, type ), 10931 startLength = queue.length, 10932 fn = queue.shift(), 10933 hooks = jQuery._queueHooks( elem, type ), 10934 next = function() { 10935 jQuery.dequeue( elem, type ); 10936 }; 10937 10938 // If the fx queue is dequeued, always remove the progress sentinel 10939 if ( fn === "inprogress" ) { 10940 fn = queue.shift(); 10941 startLength--; 10942 } 10943 10944 if ( fn ) { 10945 10946 // Add a progress sentinel to prevent the fx queue from being 10947 // automatically dequeued 10948 if ( type === "fx" ) { 10949 queue.unshift( "inprogress" ); 10950 } 10951 10952 // Clear up the last queue stop function 10953 delete hooks.stop; 10954 fn.call( elem, next, hooks ); 10955 } 10956 10957 if ( !startLength && hooks ) { 10958 hooks.empty.fire(); 10959 } 10960 }, 10961 10962 // Not public - generate a queueHooks object, or return the current one 10963 _queueHooks: function( elem, type ) { 10964 var key = type + "queueHooks"; 10965 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { 10966 empty: jQuery.Callbacks( "once memory" ).add( function() { 10967 dataPriv.remove( elem, [ type + "queue", key ] ); 10968 } ) 10969 } ); 10970 } 10971} ); 10972 10973jQuery.fn.extend( { 10974 queue: function( type, data ) { 10975 var setter = 2; 10976 10977 if ( typeof type !== "string" ) { 10978 data = type; 10979 type = "fx"; 10980 setter--; 10981 } 10982 10983 if ( arguments.length < setter ) { 10984 return jQuery.queue( this[ 0 ], type ); 10985 } 10986 10987 return data === undefined ? 10988 this : 10989 this.each( function() { 10990 var queue = jQuery.queue( this, type, data ); 10991 10992 // Ensure a hooks for this queue 10993 jQuery._queueHooks( this, type ); 10994 10995 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { 10996 jQuery.dequeue( this, type ); 10997 } 10998 } ); 10999 }, 11000 dequeue: function( type ) { 11001 return this.each( function() { 11002 jQuery.dequeue( this, type ); 11003 } ); 11004 }, 11005 clearQueue: function( type ) { 11006 return this.queue( type || "fx", [] ); 11007 }, 11008 11009 // Get a promise resolved when queues of a certain type 11010 // are emptied (fx is the type by default) 11011 promise: function( type, obj ) { 11012 var tmp, 11013 count = 1, 11014 defer = jQuery.Deferred(), 11015 elements = this, 11016 i = this.length, 11017 resolve = function() { 11018 if ( !( --count ) ) { 11019 defer.resolveWith( elements, [ elements ] ); 11020 } 11021 }; 11022 11023 if ( typeof type !== "string" ) { 11024 obj = type; 11025 type = undefined; 11026 } 11027 type = type || "fx"; 11028 11029 while ( i-- ) { 11030 tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); 11031 if ( tmp && tmp.empty ) { 11032 count++; 11033 tmp.empty.add( resolve ); 11034 } 11035 } 11036 resolve(); 11037 return defer.promise( obj ); 11038 } 11039} ); 11040var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; 11041 11042var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); 11043 11044 11045var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; 11046 11047var documentElement = document.documentElement; 11048 11049 11050 11051 var isAttached = function( elem ) { 11052 return jQuery.contains( elem.ownerDocument, elem ); 11053 }, 11054 composed = { composed: true }; 11055 11056 // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only 11057 // Check attachment across shadow DOM boundaries when possible (gh-3504) 11058 // Support: iOS 10.0-10.2 only 11059 // Early iOS 10 versions support `attachShadow` but not `getRootNode`, 11060 // leading to errors. We need to check for `getRootNode`. 11061 if ( documentElement.getRootNode ) { 11062 isAttached = function( elem ) { 11063 return jQuery.contains( elem.ownerDocument, elem ) || 11064 elem.getRootNode( composed ) === elem.ownerDocument; 11065 }; 11066 } 11067var isHiddenWithinTree = function( elem, el ) { 11068 11069 // isHiddenWithinTree might be called from jQuery#filter function; 11070 // in that case, element will be second argument 11071 elem = el || elem; 11072 11073 // Inline style trumps all 11074 return elem.style.display === "none" || 11075 elem.style.display === "" && 11076 11077 // Otherwise, check computed style 11078 // Support: Firefox <=43 - 45 11079 // Disconnected elements can have computed display: none, so first confirm that elem is 11080 // in the document. 11081 isAttached( elem ) && 11082 11083 jQuery.css( elem, "display" ) === "none"; 11084 }; 11085 11086 11087 11088function adjustCSS( elem, prop, valueParts, tween ) { 11089 var adjusted, scale, 11090 maxIterations = 20, 11091 currentValue = tween ? 11092 function() { 11093 return tween.cur(); 11094 } : 11095 function() { 11096 return jQuery.css( elem, prop, "" ); 11097 }, 11098 initial = currentValue(), 11099 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), 11100 11101 // Starting value computation is required for potential unit mismatches 11102 initialInUnit = elem.nodeType && 11103 ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && 11104 rcssNum.exec( jQuery.css( elem, prop ) ); 11105 11106 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { 11107 11108 // Support: Firefox <=54 11109 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) 11110 initial = initial / 2; 11111 11112 // Trust units reported by jQuery.css 11113 unit = unit || initialInUnit[ 3 ]; 11114 11115 // Iteratively approximate from a nonzero starting point 11116 initialInUnit = +initial || 1; 11117 11118 while ( maxIterations-- ) { 11119 11120 // Evaluate and update our best guess (doubling guesses that zero out). 11121 // Finish if the scale equals or crosses 1 (making the old*new product non-positive). 11122 jQuery.style( elem, prop, initialInUnit + unit ); 11123 if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { 11124 maxIterations = 0; 11125 } 11126 initialInUnit = initialInUnit / scale; 11127 11128 } 11129 11130 initialInUnit = initialInUnit * 2; 11131 jQuery.style( elem, prop, initialInUnit + unit ); 11132 11133 // Make sure we update the tween properties later on 11134 valueParts = valueParts || []; 11135 } 11136 11137 if ( valueParts ) { 11138 initialInUnit = +initialInUnit || +initial || 0; 11139 11140 // Apply relative offset (+=/-=) if specified 11141 adjusted = valueParts[ 1 ] ? 11142 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : 11143 +valueParts[ 2 ]; 11144 if ( tween ) { 11145 tween.unit = unit; 11146 tween.start = initialInUnit; 11147 tween.end = adjusted; 11148 } 11149 } 11150 return adjusted; 11151} 11152 11153 11154var defaultDisplayMap = {}; 11155 11156function getDefaultDisplay( elem ) { 11157 var temp, 11158 doc = elem.ownerDocument, 11159 nodeName = elem.nodeName, 11160 display = defaultDisplayMap[ nodeName ]; 11161 11162 if ( display ) { 11163 return display; 11164 } 11165 11166 temp = doc.body.appendChild( doc.createElement( nodeName ) ); 11167 display = jQuery.css( temp, "display" ); 11168 11169 temp.parentNode.removeChild( temp ); 11170 11171 if ( display === "none" ) { 11172 display = "block"; 11173 } 11174 defaultDisplayMap[ nodeName ] = display; 11175 11176 return display; 11177} 11178 11179function showHide( elements, show ) { 11180 var display, elem, 11181 values = [], 11182 index = 0, 11183 length = elements.length; 11184 11185 // Determine new display value for elements that need to change 11186 for ( ; index < length; index++ ) { 11187 elem = elements[ index ]; 11188 if ( !elem.style ) { 11189 continue; 11190 } 11191 11192 display = elem.style.display; 11193 if ( show ) { 11194 11195 // Since we force visibility upon cascade-hidden elements, an immediate (and slow) 11196 // check is required in this first loop unless we have a nonempty display value (either 11197 // inline or about-to-be-restored) 11198 if ( display === "none" ) { 11199 values[ index ] = dataPriv.get( elem, "display" ) || null; 11200 if ( !values[ index ] ) { 11201 elem.style.display = ""; 11202 } 11203 } 11204 if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { 11205 values[ index ] = getDefaultDisplay( elem ); 11206 } 11207 } else { 11208 if ( display !== "none" ) { 11209 values[ index ] = "none"; 11210 11211 // Remember what we're overwriting 11212 dataPriv.set( elem, "display", display ); 11213 } 11214 } 11215 } 11216 11217 // Set the display of the elements in a second loop to avoid constant reflow 11218 for ( index = 0; index < length; index++ ) { 11219 if ( values[ index ] != null ) { 11220 elements[ index ].style.display = values[ index ]; 11221 } 11222 } 11223 11224 return elements; 11225} 11226 11227jQuery.fn.extend( { 11228 show: function() { 11229 return showHide( this, true ); 11230 }, 11231 hide: function() { 11232 return showHide( this ); 11233 }, 11234 toggle: function( state ) { 11235 if ( typeof state === "boolean" ) { 11236 return state ? this.show() : this.hide(); 11237 } 11238 11239 return this.each( function() { 11240 if ( isHiddenWithinTree( this ) ) { 11241 jQuery( this ).show(); 11242 } else { 11243 jQuery( this ).hide(); 11244 } 11245 } ); 11246 } 11247} ); 11248var rcheckableType = ( /^(?:checkbox|radio)$/i ); 11249 11250var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i ); 11251 11252var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); 11253 11254 11255 11256( function() { 11257 var fragment = document.createDocumentFragment(), 11258 div = fragment.appendChild( document.createElement( "div" ) ), 11259 input = document.createElement( "input" ); 11260 11261 // Support: Android 4.0 - 4.3 only 11262 // Check state lost if the name is set (#11217) 11263 // Support: Windows Web Apps (WWA) 11264 // `name` and `type` must use .setAttribute for WWA (#14901) 11265 input.setAttribute( "type", "radio" ); 11266 input.setAttribute( "checked", "checked" ); 11267 input.setAttribute( "name", "t" ); 11268 11269 div.appendChild( input ); 11270 11271 // Support: Android <=4.1 only 11272 // Older WebKit doesn't clone checked state correctly in fragments 11273 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; 11274 11275 // Support: IE <=11 only 11276 // Make sure textarea (and checkbox) defaultValue is properly cloned 11277 div.innerHTML = "<textarea>x</textarea>"; 11278 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; 11279 11280 // Support: IE <=9 only 11281 // IE <=9 replaces <option> tags with their contents when inserted outside of 11282 // the select element. 11283 div.innerHTML = "<option></option>"; 11284 support.option = !!div.lastChild; 11285} )(); 11286 11287 11288// We have to close these tags to support XHTML (#13200) 11289var wrapMap = { 11290 11291 // XHTML parsers do not magically insert elements in the 11292 // same way that tag soup parsers do. So we cannot shorten 11293 // this by omitting <tbody> or other required elements. 11294 thead: [ 1, "<table>", "</table>" ], 11295 col: [ 2, "<table><colgroup>", "</colgroup></table>" ], 11296 tr: [ 2, "<table><tbody>", "</tbody></table>" ], 11297 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], 11298 11299 _default: [ 0, "", "" ] 11300}; 11301 11302wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; 11303wrapMap.th = wrapMap.td; 11304 11305// Support: IE <=9 only 11306if ( !support.option ) { 11307 wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ]; 11308} 11309 11310 11311function getAll( context, tag ) { 11312 11313 // Support: IE <=9 - 11 only 11314 // Use typeof to avoid zero-argument method invocation on host objects (#15151) 11315 var ret; 11316 11317 if ( typeof context.getElementsByTagName !== "undefined" ) { 11318 ret = context.getElementsByTagName( tag || "*" ); 11319 11320 } else if ( typeof context.querySelectorAll !== "undefined" ) { 11321 ret = context.querySelectorAll( tag || "*" ); 11322 11323 } else { 11324 ret = []; 11325 } 11326 11327 if ( tag === undefined || tag && nodeName( context, tag ) ) { 11328 return jQuery.merge( [ context ], ret ); 11329 } 11330 11331 return ret; 11332} 11333 11334 11335// Mark scripts as having already been evaluated 11336function setGlobalEval( elems, refElements ) { 11337 var i = 0, 11338 l = elems.length; 11339 11340 for ( ; i < l; i++ ) { 11341 dataPriv.set( 11342 elems[ i ], 11343 "globalEval", 11344 !refElements || dataPriv.get( refElements[ i ], "globalEval" ) 11345 ); 11346 } 11347} 11348 11349 11350var rhtml = /<|&#?\w+;/; 11351 11352function buildFragment( elems, context, scripts, selection, ignored ) { 11353 var elem, tmp, tag, wrap, attached, j, 11354 fragment = context.createDocumentFragment(), 11355 nodes = [], 11356 i = 0, 11357 l = elems.length; 11358 11359 for ( ; i < l; i++ ) { 11360 elem = elems[ i ]; 11361 11362 if ( elem || elem === 0 ) { 11363 11364 // Add nodes directly 11365 if ( toType( elem ) === "object" ) { 11366 11367 // Support: Android <=4.0 only, PhantomJS 1 only 11368 // push.apply(_, arraylike) throws on ancient WebKit 11369 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); 11370 11371 // Convert non-html into a text node 11372 } else if ( !rhtml.test( elem ) ) { 11373 nodes.push( context.createTextNode( elem ) ); 11374 11375 // Convert html into DOM nodes 11376 } else { 11377 tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); 11378 11379 // Deserialize a standard representation 11380 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); 11381 wrap = wrapMap[ tag ] || wrapMap._default; 11382 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; 11383 11384 // Descend through wrappers to the right content 11385 j = wrap[ 0 ]; 11386 while ( j-- ) { 11387 tmp = tmp.lastChild; 11388 } 11389 11390 // Support: Android <=4.0 only, PhantomJS 1 only 11391 // push.apply(_, arraylike) throws on ancient WebKit 11392 jQuery.merge( nodes, tmp.childNodes ); 11393 11394 // Remember the top-level container 11395 tmp = fragment.firstChild; 11396 11397 // Ensure the created nodes are orphaned (#12392) 11398 tmp.textContent = ""; 11399 } 11400 } 11401 } 11402 11403 // Remove wrapper from fragment 11404 fragment.textContent = ""; 11405 11406 i = 0; 11407 while ( ( elem = nodes[ i++ ] ) ) { 11408 11409 // Skip elements already in the context collection (trac-4087) 11410 if ( selection && jQuery.inArray( elem, selection ) > -1 ) { 11411 if ( ignored ) { 11412 ignored.push( elem ); 11413 } 11414 continue; 11415 } 11416 11417 attached = isAttached( elem ); 11418 11419 // Append to fragment 11420 tmp = getAll( fragment.appendChild( elem ), "script" ); 11421 11422 // Preserve script evaluation history 11423 if ( attached ) { 11424 setGlobalEval( tmp ); 11425 } 11426 11427 // Capture executables 11428 if ( scripts ) { 11429 j = 0; 11430 while ( ( elem = tmp[ j++ ] ) ) { 11431 if ( rscriptType.test( elem.type || "" ) ) { 11432 scripts.push( elem ); 11433 } 11434 } 11435 } 11436 } 11437 11438 return fragment; 11439} 11440 11441 11442var 11443 rkeyEvent = /^key/, 11444 rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, 11445 rtypenamespace = /^([^.]*)(?:\.(.+)|)/; 11446 11447function returnTrue() { 11448 return true; 11449} 11450 11451function returnFalse() { 11452 return false; 11453} 11454 11455// Support: IE <=9 - 11+ 11456// focus() and blur() are asynchronous, except when they are no-op. 11457// So expect focus to be synchronous when the element is already active, 11458// and blur to be synchronous when the element is not already active. 11459// (focus and blur are always synchronous in other supported browsers, 11460// this just defines when we can count on it). 11461function expectSync( elem, type ) { 11462 return ( elem === safeActiveElement() ) === ( type === "focus" ); 11463} 11464 11465// Support: IE <=9 only 11466// Accessing document.activeElement can throw unexpectedly 11467// https://bugs.jquery.com/ticket/13393 11468function safeActiveElement() { 11469 try { 11470 return document.activeElement; 11471 } catch ( err ) { } 11472} 11473 11474function on( elem, types, selector, data, fn, one ) { 11475 var origFn, type; 11476 11477 // Types can be a map of types/handlers 11478 if ( typeof types === "object" ) { 11479 11480 // ( types-Object, selector, data ) 11481 if ( typeof selector !== "string" ) { 11482 11483 // ( types-Object, data ) 11484 data = data || selector; 11485 selector = undefined; 11486 } 11487 for ( type in types ) { 11488 on( elem, type, selector, data, types[ type ], one ); 11489 } 11490 return elem; 11491 } 11492 11493 if ( data == null && fn == null ) { 11494 11495 // ( types, fn ) 11496 fn = selector; 11497 data = selector = undefined; 11498 } else if ( fn == null ) { 11499 if ( typeof selector === "string" ) { 11500 11501 // ( types, selector, fn ) 11502 fn = data; 11503 data = undefined; 11504 } else { 11505 11506 // ( types, data, fn ) 11507 fn = data; 11508 data = selector; 11509 selector = undefined; 11510 } 11511 } 11512 if ( fn === false ) { 11513 fn = returnFalse; 11514 } else if ( !fn ) { 11515 return elem; 11516 } 11517 11518 if ( one === 1 ) { 11519 origFn = fn; 11520 fn = function( event ) { 11521 11522 // Can use an empty set, since event contains the info 11523 jQuery().off( event ); 11524 return origFn.apply( this, arguments ); 11525 }; 11526 11527 // Use same guid so caller can remove using origFn 11528 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); 11529 } 11530 return elem.each( function() { 11531 jQuery.event.add( this, types, fn, data, selector ); 11532 } ); 11533} 11534 11535/* 11536 * Helper functions for managing events -- not part of the public interface. 11537 * Props to Dean Edwards' addEvent library for many of the ideas. 11538 */ 11539jQuery.event = { 11540 11541 global: {}, 11542 11543 add: function( elem, types, handler, data, selector ) { 11544 11545 var handleObjIn, eventHandle, tmp, 11546 events, t, handleObj, 11547 special, handlers, type, namespaces, origType, 11548 elemData = dataPriv.get( elem ); 11549 11550 // Only attach events to objects that accept data 11551 if ( !acceptData( elem ) ) { 11552 return; 11553 } 11554 11555 // Caller can pass in an object of custom data in lieu of the handler 11556 if ( handler.handler ) { 11557 handleObjIn = handler; 11558 handler = handleObjIn.handler; 11559 selector = handleObjIn.selector; 11560 } 11561 11562 // Ensure that invalid selectors throw exceptions at attach time 11563 // Evaluate against documentElement in case elem is a non-element node (e.g., document) 11564 if ( selector ) { 11565 jQuery.find.matchesSelector( documentElement, selector ); 11566 } 11567 11568 // Make sure that the handler has a unique ID, used to find/remove it later 11569 if ( !handler.guid ) { 11570 handler.guid = jQuery.guid++; 11571 } 11572 11573 // Init the element's event structure and main handler, if this is the first 11574 if ( !( events = elemData.events ) ) { 11575 events = elemData.events = Object.create( null ); 11576 } 11577 if ( !( eventHandle = elemData.handle ) ) { 11578 eventHandle = elemData.handle = function( e ) { 11579 11580 // Discard the second event of a jQuery.event.trigger() and 11581 // when an event is called after a page has unloaded 11582 return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? 11583 jQuery.event.dispatch.apply( elem, arguments ) : undefined; 11584 }; 11585 } 11586 11587 // Handle multiple events separated by a space 11588 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; 11589 t = types.length; 11590 while ( t-- ) { 11591 tmp = rtypenamespace.exec( types[ t ] ) || []; 11592 type = origType = tmp[ 1 ]; 11593 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 11594 11595 // There *must* be a type, no attaching namespace-only handlers 11596 if ( !type ) { 11597 continue; 11598 } 11599 11600 // If event changes its type, use the special event handlers for the changed type 11601 special = jQuery.event.special[ type ] || {}; 11602 11603 // If selector defined, determine special event api type, otherwise given type 11604 type = ( selector ? special.delegateType : special.bindType ) || type; 11605 11606 // Update special based on newly reset type 11607 special = jQuery.event.special[ type ] || {}; 11608 11609 // handleObj is passed to all event handlers 11610 handleObj = jQuery.extend( { 11611 type: type, 11612 origType: origType, 11613 data: data, 11614 handler: handler, 11615 guid: handler.guid, 11616 selector: selector, 11617 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), 11618 namespace: namespaces.join( "." ) 11619 }, handleObjIn ); 11620 11621 // Init the event handler queue if we're the first 11622 if ( !( handlers = events[ type ] ) ) { 11623 handlers = events[ type ] = []; 11624 handlers.delegateCount = 0; 11625 11626 // Only use addEventListener if the special events handler returns false 11627 if ( !special.setup || 11628 special.setup.call( elem, data, namespaces, eventHandle ) === false ) { 11629 11630 if ( elem.addEventListener ) { 11631 elem.addEventListener( type, eventHandle ); 11632 } 11633 } 11634 } 11635 11636 if ( special.add ) { 11637 special.add.call( elem, handleObj ); 11638 11639 if ( !handleObj.handler.guid ) { 11640 handleObj.handler.guid = handler.guid; 11641 } 11642 } 11643 11644 // Add to the element's handler list, delegates in front 11645 if ( selector ) { 11646 handlers.splice( handlers.delegateCount++, 0, handleObj ); 11647 } else { 11648 handlers.push( handleObj ); 11649 } 11650 11651 // Keep track of which events have ever been used, for event optimization 11652 jQuery.event.global[ type ] = true; 11653 } 11654 11655 }, 11656 11657 // Detach an event or set of events from an element 11658 remove: function( elem, types, handler, selector, mappedTypes ) { 11659 11660 var j, origCount, tmp, 11661 events, t, handleObj, 11662 special, handlers, type, namespaces, origType, 11663 elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); 11664 11665 if ( !elemData || !( events = elemData.events ) ) { 11666 return; 11667 } 11668 11669 // Once for each type.namespace in types; type may be omitted 11670 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; 11671 t = types.length; 11672 while ( t-- ) { 11673 tmp = rtypenamespace.exec( types[ t ] ) || []; 11674 type = origType = tmp[ 1 ]; 11675 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 11676 11677 // Unbind all events (on this namespace, if provided) for the element 11678 if ( !type ) { 11679 for ( type in events ) { 11680 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); 11681 } 11682 continue; 11683 } 11684 11685 special = jQuery.event.special[ type ] || {}; 11686 type = ( selector ? special.delegateType : special.bindType ) || type; 11687 handlers = events[ type ] || []; 11688 tmp = tmp[ 2 ] && 11689 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); 11690 11691 // Remove matching events 11692 origCount = j = handlers.length; 11693 while ( j-- ) { 11694 handleObj = handlers[ j ]; 11695 11696 if ( ( mappedTypes || origType === handleObj.origType ) && 11697 ( !handler || handler.guid === handleObj.guid ) && 11698 ( !tmp || tmp.test( handleObj.namespace ) ) && 11699 ( !selector || selector === handleObj.selector || 11700 selector === "**" && handleObj.selector ) ) { 11701 handlers.splice( j, 1 ); 11702 11703 if ( handleObj.selector ) { 11704 handlers.delegateCount--; 11705 } 11706 if ( special.remove ) { 11707 special.remove.call( elem, handleObj ); 11708 } 11709 } 11710 } 11711 11712 // Remove generic event handler if we removed something and no more handlers exist 11713 // (avoids potential for endless recursion during removal of special event handlers) 11714 if ( origCount && !handlers.length ) { 11715 if ( !special.teardown || 11716 special.teardown.call( elem, namespaces, elemData.handle ) === false ) { 11717 11718 jQuery.removeEvent( elem, type, elemData.handle ); 11719 } 11720 11721 delete events[ type ]; 11722 } 11723 } 11724 11725 // Remove data and the expando if it's no longer used 11726 if ( jQuery.isEmptyObject( events ) ) { 11727 dataPriv.remove( elem, "handle events" ); 11728 } 11729 }, 11730 11731 dispatch: function( nativeEvent ) { 11732 11733 var i, j, ret, matched, handleObj, handlerQueue, 11734 args = new Array( arguments.length ), 11735 11736 // Make a writable jQuery.Event from the native event object 11737 event = jQuery.event.fix( nativeEvent ), 11738 11739 handlers = ( 11740 dataPriv.get( this, "events" ) || Object.create( null ) 11741 )[ event.type ] || [], 11742 special = jQuery.event.special[ event.type ] || {}; 11743 11744 // Use the fix-ed jQuery.Event rather than the (read-only) native event 11745 args[ 0 ] = event; 11746 11747 for ( i = 1; i < arguments.length; i++ ) { 11748 args[ i ] = arguments[ i ]; 11749 } 11750 11751 event.delegateTarget = this; 11752 11753 // Call the preDispatch hook for the mapped type, and let it bail if desired 11754 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { 11755 return; 11756 } 11757 11758 // Determine handlers 11759 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); 11760 11761 // Run delegates first; they may want to stop propagation beneath us 11762 i = 0; 11763 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { 11764 event.currentTarget = matched.elem; 11765 11766 j = 0; 11767 while ( ( handleObj = matched.handlers[ j++ ] ) && 11768 !event.isImmediatePropagationStopped() ) { 11769 11770 // If the event is namespaced, then each handler is only invoked if it is 11771 // specially universal or its namespaces are a superset of the event's. 11772 if ( !event.rnamespace || handleObj.namespace === false || 11773 event.rnamespace.test( handleObj.namespace ) ) { 11774 11775 event.handleObj = handleObj; 11776 event.data = handleObj.data; 11777 11778 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || 11779 handleObj.handler ).apply( matched.elem, args ); 11780 11781 if ( ret !== undefined ) { 11782 if ( ( event.result = ret ) === false ) { 11783 event.preventDefault(); 11784 event.stopPropagation(); 11785 } 11786 } 11787 } 11788 } 11789 } 11790 11791 // Call the postDispatch hook for the mapped type 11792 if ( special.postDispatch ) { 11793 special.postDispatch.call( this, event ); 11794 } 11795 11796 return event.result; 11797 }, 11798 11799 handlers: function( event, handlers ) { 11800 var i, handleObj, sel, matchedHandlers, matchedSelectors, 11801 handlerQueue = [], 11802 delegateCount = handlers.delegateCount, 11803 cur = event.target; 11804 11805 // Find delegate handlers 11806 if ( delegateCount && 11807 11808 // Support: IE <=9 11809 // Black-hole SVG <use> instance trees (trac-13180) 11810 cur.nodeType && 11811 11812 // Support: Firefox <=42 11813 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861) 11814 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click 11815 // Support: IE 11 only 11816 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343) 11817 !( event.type === "click" && event.button >= 1 ) ) { 11818 11819 for ( ; cur !== this; cur = cur.parentNode || this ) { 11820 11821 // Don't check non-elements (#13208) 11822 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) 11823 if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) { 11824 matchedHandlers = []; 11825 matchedSelectors = {}; 11826 for ( i = 0; i < delegateCount; i++ ) { 11827 handleObj = handlers[ i ]; 11828 11829 // Don't conflict with Object.prototype properties (#13203) 11830 sel = handleObj.selector + " "; 11831 11832 if ( matchedSelectors[ sel ] === undefined ) { 11833 matchedSelectors[ sel ] = handleObj.needsContext ? 11834 jQuery( sel, this ).index( cur ) > -1 : 11835 jQuery.find( sel, this, null, [ cur ] ).length; 11836 } 11837 if ( matchedSelectors[ sel ] ) { 11838 matchedHandlers.push( handleObj ); 11839 } 11840 } 11841 if ( matchedHandlers.length ) { 11842 handlerQueue.push( { elem: cur, handlers: matchedHandlers } ); 11843 } 11844 } 11845 } 11846 } 11847 11848 // Add the remaining (directly-bound) handlers 11849 cur = this; 11850 if ( delegateCount < handlers.length ) { 11851 handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } ); 11852 } 11853 11854 return handlerQueue; 11855 }, 11856 11857 addProp: function( name, hook ) { 11858 Object.defineProperty( jQuery.Event.prototype, name, { 11859 enumerable: true, 11860 configurable: true, 11861 11862 get: isFunction( hook ) ? 11863 function() { 11864 if ( this.originalEvent ) { 11865 return hook( this.originalEvent ); 11866 } 11867 } : 11868 function() { 11869 if ( this.originalEvent ) { 11870 return this.originalEvent[ name ]; 11871 } 11872 }, 11873 11874 set: function( value ) { 11875 Object.defineProperty( this, name, { 11876 enumerable: true, 11877 configurable: true, 11878 writable: true, 11879 value: value 11880 } ); 11881 } 11882 } ); 11883 }, 11884 11885 fix: function( originalEvent ) { 11886 return originalEvent[ jQuery.expando ] ? 11887 originalEvent : 11888 new jQuery.Event( originalEvent ); 11889 }, 11890 11891 special: { 11892 load: { 11893 11894 // Prevent triggered image.load events from bubbling to window.load 11895 noBubble: true 11896 }, 11897 click: { 11898 11899 // Utilize native event to ensure correct state for checkable inputs 11900 setup: function( data ) { 11901 11902 // For mutual compressibility with _default, replace `this` access with a local var. 11903 // `|| data` is dead code meant only to preserve the variable through minification. 11904 var el = this || data; 11905 11906 // Claim the first handler 11907 if ( rcheckableType.test( el.type ) && 11908 el.click && nodeName( el, "input" ) ) { 11909 11910 // dataPriv.set( el, "click", ... ) 11911 leverageNative( el, "click", returnTrue ); 11912 } 11913 11914 // Return false to allow normal processing in the caller 11915 return false; 11916 }, 11917 trigger: function( data ) { 11918 11919 // For mutual compressibility with _default, replace `this` access with a local var. 11920 // `|| data` is dead code meant only to preserve the variable through minification. 11921 var el = this || data; 11922 11923 // Force setup before triggering a click 11924 if ( rcheckableType.test( el.type ) && 11925 el.click && nodeName( el, "input" ) ) { 11926 11927 leverageNative( el, "click" ); 11928 } 11929 11930 // Return non-false to allow normal event-path propagation 11931 return true; 11932 }, 11933 11934 // For cross-browser consistency, suppress native .click() on links 11935 // Also prevent it if we're currently inside a leveraged native-event stack 11936 _default: function( event ) { 11937 var target = event.target; 11938 return rcheckableType.test( target.type ) && 11939 target.click && nodeName( target, "input" ) && 11940 dataPriv.get( target, "click" ) || 11941 nodeName( target, "a" ); 11942 } 11943 }, 11944 11945 beforeunload: { 11946 postDispatch: function( event ) { 11947 11948 // Support: Firefox 20+ 11949 // Firefox doesn't alert if the returnValue field is not set. 11950 if ( event.result !== undefined && event.originalEvent ) { 11951 event.originalEvent.returnValue = event.result; 11952 } 11953 } 11954 } 11955 } 11956}; 11957 11958// Ensure the presence of an event listener that handles manually-triggered 11959// synthetic events by interrupting progress until reinvoked in response to 11960// *native* events that it fires directly, ensuring that state changes have 11961// already occurred before other listeners are invoked. 11962function leverageNative( el, type, expectSync ) { 11963 11964 // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add 11965 if ( !expectSync ) { 11966 if ( dataPriv.get( el, type ) === undefined ) { 11967 jQuery.event.add( el, type, returnTrue ); 11968 } 11969 return; 11970 } 11971 11972 // Register the controller as a special universal handler for all event namespaces 11973 dataPriv.set( el, type, false ); 11974 jQuery.event.add( el, type, { 11975 namespace: false, 11976 handler: function( event ) { 11977 var notAsync, result, 11978 saved = dataPriv.get( this, type ); 11979 11980 if ( ( event.isTrigger & 1 ) && this[ type ] ) { 11981 11982 // Interrupt processing of the outer synthetic .trigger()ed event 11983 // Saved data should be false in such cases, but might be a leftover capture object 11984 // from an async native handler (gh-4350) 11985 if ( !saved.length ) { 11986 11987 // Store arguments for use when handling the inner native event 11988 // There will always be at least one argument (an event object), so this array 11989 // will not be confused with a leftover capture object. 11990 saved = slice.call( arguments ); 11991 dataPriv.set( this, type, saved ); 11992 11993 // Trigger the native event and capture its result 11994 // Support: IE <=9 - 11+ 11995 // focus() and blur() are asynchronous 11996 notAsync = expectSync( this, type ); 11997 this[ type ](); 11998 result = dataPriv.get( this, type ); 11999 if ( saved !== result || notAsync ) { 12000 dataPriv.set( this, type, false ); 12001 } else { 12002 result = {}; 12003 } 12004 if ( saved !== result ) { 12005 12006 // Cancel the outer synthetic event 12007 event.stopImmediatePropagation(); 12008 event.preventDefault(); 12009 return result.value; 12010 } 12011 12012 // If this is an inner synthetic event for an event with a bubbling surrogate 12013 // (focus or blur), assume that the surrogate already propagated from triggering the 12014 // native event and prevent that from happening again here. 12015 // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the 12016 // bubbling surrogate propagates *after* the non-bubbling base), but that seems 12017 // less bad than duplication. 12018 } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) { 12019 event.stopPropagation(); 12020 } 12021 12022 // If this is a native event triggered above, everything is now in order 12023 // Fire an inner synthetic event with the original arguments 12024 } else if ( saved.length ) { 12025 12026 // ...and capture the result 12027 dataPriv.set( this, type, { 12028 value: jQuery.event.trigger( 12029 12030 // Support: IE <=9 - 11+ 12031 // Extend with the prototype to reset the above stopImmediatePropagation() 12032 jQuery.extend( saved[ 0 ], jQuery.Event.prototype ), 12033 saved.slice( 1 ), 12034 this 12035 ) 12036 } ); 12037 12038 // Abort handling of the native event 12039 event.stopImmediatePropagation(); 12040 } 12041 } 12042 } ); 12043} 12044 12045jQuery.removeEvent = function( elem, type, handle ) { 12046 12047 // This "if" is needed for plain objects 12048 if ( elem.removeEventListener ) { 12049 elem.removeEventListener( type, handle ); 12050 } 12051}; 12052 12053jQuery.Event = function( src, props ) { 12054 12055 // Allow instantiation without the 'new' keyword 12056 if ( !( this instanceof jQuery.Event ) ) { 12057 return new jQuery.Event( src, props ); 12058 } 12059 12060 // Event object 12061 if ( src && src.type ) { 12062 this.originalEvent = src; 12063 this.type = src.type; 12064 12065 // Events bubbling up the document may have been marked as prevented 12066 // by a handler lower down the tree; reflect the correct value. 12067 this.isDefaultPrevented = src.defaultPrevented || 12068 src.defaultPrevented === undefined && 12069 12070 // Support: Android <=2.3 only 12071 src.returnValue === false ? 12072 returnTrue : 12073 returnFalse; 12074 12075 // Create target properties 12076 // Support: Safari <=6 - 7 only 12077 // Target should not be a text node (#504, #13143) 12078 this.target = ( src.target && src.target.nodeType === 3 ) ? 12079 src.target.parentNode : 12080 src.target; 12081 12082 this.currentTarget = src.currentTarget; 12083 this.relatedTarget = src.relatedTarget; 12084 12085 // Event type 12086 } else { 12087 this.type = src; 12088 } 12089 12090 // Put explicitly provided properties onto the event object 12091 if ( props ) { 12092 jQuery.extend( this, props ); 12093 } 12094 12095 // Create a timestamp if incoming event doesn't have one 12096 this.timeStamp = src && src.timeStamp || Date.now(); 12097 12098 // Mark it as fixed 12099 this[ jQuery.expando ] = true; 12100}; 12101 12102// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding 12103// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html 12104jQuery.Event.prototype = { 12105 constructor: jQuery.Event, 12106 isDefaultPrevented: returnFalse, 12107 isPropagationStopped: returnFalse, 12108 isImmediatePropagationStopped: returnFalse, 12109 isSimulated: false, 12110 12111 preventDefault: function() { 12112 var e = this.originalEvent; 12113 12114 this.isDefaultPrevented = returnTrue; 12115 12116 if ( e && !this.isSimulated ) { 12117 e.preventDefault(); 12118 } 12119 }, 12120 stopPropagation: function() { 12121 var e = this.originalEvent; 12122 12123 this.isPropagationStopped = returnTrue; 12124 12125 if ( e && !this.isSimulated ) { 12126 e.stopPropagation(); 12127 } 12128 }, 12129 stopImmediatePropagation: function() { 12130 var e = this.originalEvent; 12131 12132 this.isImmediatePropagationStopped = returnTrue; 12133 12134 if ( e && !this.isSimulated ) { 12135 e.stopImmediatePropagation(); 12136 } 12137 12138 this.stopPropagation(); 12139 } 12140}; 12141 12142// Includes all common event props including KeyEvent and MouseEvent specific props 12143jQuery.each( { 12144 altKey: true, 12145 bubbles: true, 12146 cancelable: true, 12147 changedTouches: true, 12148 ctrlKey: true, 12149 detail: true, 12150 eventPhase: true, 12151 metaKey: true, 12152 pageX: true, 12153 pageY: true, 12154 shiftKey: true, 12155 view: true, 12156 "char": true, 12157 code: true, 12158 charCode: true, 12159 key: true, 12160 keyCode: true, 12161 button: true, 12162 buttons: true, 12163 clientX: true, 12164 clientY: true, 12165 offsetX: true, 12166 offsetY: true, 12167 pointerId: true, 12168 pointerType: true, 12169 screenX: true, 12170 screenY: true, 12171 targetTouches: true, 12172 toElement: true, 12173 touches: true, 12174 12175 which: function( event ) { 12176 var button = event.button; 12177 12178 // Add which for key events 12179 if ( event.which == null && rkeyEvent.test( event.type ) ) { 12180 return event.charCode != null ? event.charCode : event.keyCode; 12181 } 12182 12183 // Add which for click: 1 === left; 2 === middle; 3 === right 12184 if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) { 12185 if ( button & 1 ) { 12186 return 1; 12187 } 12188 12189 if ( button & 2 ) { 12190 return 3; 12191 } 12192 12193 if ( button & 4 ) { 12194 return 2; 12195 } 12196 12197 return 0; 12198 } 12199 12200 return event.which; 12201 } 12202}, jQuery.event.addProp ); 12203 12204jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) { 12205 jQuery.event.special[ type ] = { 12206 12207 // Utilize native event if possible so blur/focus sequence is correct 12208 setup: function() { 12209 12210 // Claim the first handler 12211 // dataPriv.set( this, "focus", ... ) 12212 // dataPriv.set( this, "blur", ... ) 12213 leverageNative( this, type, expectSync ); 12214 12215 // Return false to allow normal processing in the caller 12216 return false; 12217 }, 12218 trigger: function() { 12219 12220 // Force setup before trigger 12221 leverageNative( this, type ); 12222 12223 // Return non-false to allow normal event-path propagation 12224 return true; 12225 }, 12226 12227 delegateType: delegateType 12228 }; 12229} ); 12230 12231// Create mouseenter/leave events using mouseover/out and event-time checks 12232// so that event delegation works in jQuery. 12233// Do the same for pointerenter/pointerleave and pointerover/pointerout 12234// 12235// Support: Safari 7 only 12236// Safari sends mouseenter too often; see: 12237// https://bugs.chromium.org/p/chromium/issues/detail?id=470258 12238// for the description of the bug (it existed in older Chrome versions as well). 12239jQuery.each( { 12240 mouseenter: "mouseover", 12241 mouseleave: "mouseout", 12242 pointerenter: "pointerover", 12243 pointerleave: "pointerout" 12244}, function( orig, fix ) { 12245 jQuery.event.special[ orig ] = { 12246 delegateType: fix, 12247 bindType: fix, 12248 12249 handle: function( event ) { 12250 var ret, 12251 target = this, 12252 related = event.relatedTarget, 12253 handleObj = event.handleObj; 12254 12255 // For mouseenter/leave call the handler if related is outside the target. 12256 // NB: No relatedTarget if the mouse left/entered the browser window 12257 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { 12258 event.type = handleObj.origType; 12259 ret = handleObj.handler.apply( this, arguments ); 12260 event.type = fix; 12261 } 12262 return ret; 12263 } 12264 }; 12265} ); 12266 12267jQuery.fn.extend( { 12268 12269 on: function( types, selector, data, fn ) { 12270 return on( this, types, selector, data, fn ); 12271 }, 12272 one: function( types, selector, data, fn ) { 12273 return on( this, types, selector, data, fn, 1 ); 12274 }, 12275 off: function( types, selector, fn ) { 12276 var handleObj, type; 12277 if ( types && types.preventDefault && types.handleObj ) { 12278 12279 // ( event ) dispatched jQuery.Event 12280 handleObj = types.handleObj; 12281 jQuery( types.delegateTarget ).off( 12282 handleObj.namespace ? 12283 handleObj.origType + "." + handleObj.namespace : 12284 handleObj.origType, 12285 handleObj.selector, 12286 handleObj.handler 12287 ); 12288 return this; 12289 } 12290 if ( typeof types === "object" ) { 12291 12292 // ( types-object [, selector] ) 12293 for ( type in types ) { 12294 this.off( type, selector, types[ type ] ); 12295 } 12296 return this; 12297 } 12298 if ( selector === false || typeof selector === "function" ) { 12299 12300 // ( types [, fn] ) 12301 fn = selector; 12302 selector = undefined; 12303 } 12304 if ( fn === false ) { 12305 fn = returnFalse; 12306 } 12307 return this.each( function() { 12308 jQuery.event.remove( this, types, fn, selector ); 12309 } ); 12310 } 12311} ); 12312 12313 12314var 12315 12316 // Support: IE <=10 - 11, Edge 12 - 13 only 12317 // In IE/Edge using regex groups here causes severe slowdowns. 12318 // See https://connect.microsoft.com/IE/feedback/details/1736512/ 12319 rnoInnerhtml = /<script|<style|<link/i, 12320 12321 // checked="checked" or checked 12322 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, 12323 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; 12324 12325// Prefer a tbody over its parent table for containing new rows 12326function manipulationTarget( elem, content ) { 12327 if ( nodeName( elem, "table" ) && 12328 nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { 12329 12330 return jQuery( elem ).children( "tbody" )[ 0 ] || elem; 12331 } 12332 12333 return elem; 12334} 12335 12336// Replace/restore the type attribute of script elements for safe DOM manipulation 12337function disableScript( elem ) { 12338 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; 12339 return elem; 12340} 12341function restoreScript( elem ) { 12342 if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) { 12343 elem.type = elem.type.slice( 5 ); 12344 } else { 12345 elem.removeAttribute( "type" ); 12346 } 12347 12348 return elem; 12349} 12350 12351function cloneCopyEvent( src, dest ) { 12352 var i, l, type, pdataOld, udataOld, udataCur, events; 12353 12354 if ( dest.nodeType !== 1 ) { 12355 return; 12356 } 12357 12358 // 1. Copy private data: events, handlers, etc. 12359 if ( dataPriv.hasData( src ) ) { 12360 pdataOld = dataPriv.get( src ); 12361 events = pdataOld.events; 12362 12363 if ( events ) { 12364 dataPriv.remove( dest, "handle events" ); 12365 12366 for ( type in events ) { 12367 for ( i = 0, l = events[ type ].length; i < l; i++ ) { 12368 jQuery.event.add( dest, type, events[ type ][ i ] ); 12369 } 12370 } 12371 } 12372 } 12373 12374 // 2. Copy user data 12375 if ( dataUser.hasData( src ) ) { 12376 udataOld = dataUser.access( src ); 12377 udataCur = jQuery.extend( {}, udataOld ); 12378 12379 dataUser.set( dest, udataCur ); 12380 } 12381} 12382 12383// Fix IE bugs, see support tests 12384function fixInput( src, dest ) { 12385 var nodeName = dest.nodeName.toLowerCase(); 12386 12387 // Fails to persist the checked state of a cloned checkbox or radio button. 12388 if ( nodeName === "input" && rcheckableType.test( src.type ) ) { 12389 dest.checked = src.checked; 12390 12391 // Fails to return the selected option to the default selected state when cloning options 12392 } else if ( nodeName === "input" || nodeName === "textarea" ) { 12393 dest.defaultValue = src.defaultValue; 12394 } 12395} 12396 12397function domManip( collection, args, callback, ignored ) { 12398 12399 // Flatten any nested arrays 12400 args = flat( args ); 12401 12402 var fragment, first, scripts, hasScripts, node, doc, 12403 i = 0, 12404 l = collection.length, 12405 iNoClone = l - 1, 12406 value = args[ 0 ], 12407 valueIsFunction = isFunction( value ); 12408 12409 // We can't cloneNode fragments that contain checked, in WebKit 12410 if ( valueIsFunction || 12411 ( l > 1 && typeof value === "string" && 12412 !support.checkClone && rchecked.test( value ) ) ) { 12413 return collection.each( function( index ) { 12414 var self = collection.eq( index ); 12415 if ( valueIsFunction ) { 12416 args[ 0 ] = value.call( this, index, self.html() ); 12417 } 12418 domManip( self, args, callback, ignored ); 12419 } ); 12420 } 12421 12422 if ( l ) { 12423 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); 12424 first = fragment.firstChild; 12425 12426 if ( fragment.childNodes.length === 1 ) { 12427 fragment = first; 12428 } 12429 12430 // Require either new content or an interest in ignored elements to invoke the callback 12431 if ( first || ignored ) { 12432 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); 12433 hasScripts = scripts.length; 12434 12435 // Use the original fragment for the last item 12436 // instead of the first because it can end up 12437 // being emptied incorrectly in certain situations (#8070). 12438 for ( ; i < l; i++ ) { 12439 node = fragment; 12440 12441 if ( i !== iNoClone ) { 12442 node = jQuery.clone( node, true, true ); 12443 12444 // Keep references to cloned scripts for later restoration 12445 if ( hasScripts ) { 12446 12447 // Support: Android <=4.0 only, PhantomJS 1 only 12448 // push.apply(_, arraylike) throws on ancient WebKit 12449 jQuery.merge( scripts, getAll( node, "script" ) ); 12450 } 12451 } 12452 12453 callback.call( collection[ i ], node, i ); 12454 } 12455 12456 if ( hasScripts ) { 12457 doc = scripts[ scripts.length - 1 ].ownerDocument; 12458 12459 // Reenable scripts 12460 jQuery.map( scripts, restoreScript ); 12461 12462 // Evaluate executable scripts on first document insertion 12463 for ( i = 0; i < hasScripts; i++ ) { 12464 node = scripts[ i ]; 12465 if ( rscriptType.test( node.type || "" ) && 12466 !dataPriv.access( node, "globalEval" ) && 12467 jQuery.contains( doc, node ) ) { 12468 12469 if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) { 12470 12471 // Optional AJAX dependency, but won't run scripts if not present 12472 if ( jQuery._evalUrl && !node.noModule ) { 12473 jQuery._evalUrl( node.src, { 12474 nonce: node.nonce || node.getAttribute( "nonce" ) 12475 }, doc ); 12476 } 12477 } else { 12478 DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc ); 12479 } 12480 } 12481 } 12482 } 12483 } 12484 } 12485 12486 return collection; 12487} 12488 12489function remove( elem, selector, keepData ) { 12490 var node, 12491 nodes = selector ? jQuery.filter( selector, elem ) : elem, 12492 i = 0; 12493 12494 for ( ; ( node = nodes[ i ] ) != null; i++ ) { 12495 if ( !keepData && node.nodeType === 1 ) { 12496 jQuery.cleanData( getAll( node ) ); 12497 } 12498 12499 if ( node.parentNode ) { 12500 if ( keepData && isAttached( node ) ) { 12501 setGlobalEval( getAll( node, "script" ) ); 12502 } 12503 node.parentNode.removeChild( node ); 12504 } 12505 } 12506 12507 return elem; 12508} 12509 12510jQuery.extend( { 12511 htmlPrefilter: function( html ) { 12512 return html; 12513 }, 12514 12515 clone: function( elem, dataAndEvents, deepDataAndEvents ) { 12516 var i, l, srcElements, destElements, 12517 clone = elem.cloneNode( true ), 12518 inPage = isAttached( elem ); 12519 12520 // Fix IE cloning issues 12521 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && 12522 !jQuery.isXMLDoc( elem ) ) { 12523 12524 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 12525 destElements = getAll( clone ); 12526 srcElements = getAll( elem ); 12527 12528 for ( i = 0, l = srcElements.length; i < l; i++ ) { 12529 fixInput( srcElements[ i ], destElements[ i ] ); 12530 } 12531 } 12532 12533 // Copy the events from the original to the clone 12534 if ( dataAndEvents ) { 12535 if ( deepDataAndEvents ) { 12536 srcElements = srcElements || getAll( elem ); 12537 destElements = destElements || getAll( clone ); 12538 12539 for ( i = 0, l = srcElements.length; i < l; i++ ) { 12540 cloneCopyEvent( srcElements[ i ], destElements[ i ] ); 12541 } 12542 } else { 12543 cloneCopyEvent( elem, clone ); 12544 } 12545 } 12546 12547 // Preserve script evaluation history 12548 destElements = getAll( clone, "script" ); 12549 if ( destElements.length > 0 ) { 12550 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); 12551 } 12552 12553 // Return the cloned set 12554 return clone; 12555 }, 12556 12557 cleanData: function( elems ) { 12558 var data, elem, type, 12559 special = jQuery.event.special, 12560 i = 0; 12561 12562 for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { 12563 if ( acceptData( elem ) ) { 12564 if ( ( data = elem[ dataPriv.expando ] ) ) { 12565 if ( data.events ) { 12566 for ( type in data.events ) { 12567 if ( special[ type ] ) { 12568 jQuery.event.remove( elem, type ); 12569 12570 // This is a shortcut to avoid jQuery.event.remove's overhead 12571 } else { 12572 jQuery.removeEvent( elem, type, data.handle ); 12573 } 12574 } 12575 } 12576 12577 // Support: Chrome <=35 - 45+ 12578 // Assign undefined instead of using delete, see Data#remove 12579 elem[ dataPriv.expando ] = undefined; 12580 } 12581 if ( elem[ dataUser.expando ] ) { 12582 12583 // Support: Chrome <=35 - 45+ 12584 // Assign undefined instead of using delete, see Data#remove 12585 elem[ dataUser.expando ] = undefined; 12586 } 12587 } 12588 } 12589 } 12590} ); 12591 12592jQuery.fn.extend( { 12593 detach: function( selector ) { 12594 return remove( this, selector, true ); 12595 }, 12596 12597 remove: function( selector ) { 12598 return remove( this, selector ); 12599 }, 12600 12601 text: function( value ) { 12602 return access( this, function( value ) { 12603 return value === undefined ? 12604 jQuery.text( this ) : 12605 this.empty().each( function() { 12606 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 12607 this.textContent = value; 12608 } 12609 } ); 12610 }, null, value, arguments.length ); 12611 }, 12612 12613 append: function() { 12614 return domManip( this, arguments, function( elem ) { 12615 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 12616 var target = manipulationTarget( this, elem ); 12617 target.appendChild( elem ); 12618 } 12619 } ); 12620 }, 12621 12622 prepend: function() { 12623 return domManip( this, arguments, function( elem ) { 12624 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 12625 var target = manipulationTarget( this, elem ); 12626 target.insertBefore( elem, target.firstChild ); 12627 } 12628 } ); 12629 }, 12630 12631 before: function() { 12632 return domManip( this, arguments, function( elem ) { 12633 if ( this.parentNode ) { 12634 this.parentNode.insertBefore( elem, this ); 12635 } 12636 } ); 12637 }, 12638 12639 after: function() { 12640 return domManip( this, arguments, function( elem ) { 12641 if ( this.parentNode ) { 12642 this.parentNode.insertBefore( elem, this.nextSibling ); 12643 } 12644 } ); 12645 }, 12646 12647 empty: function() { 12648 var elem, 12649 i = 0; 12650 12651 for ( ; ( elem = this[ i ] ) != null; i++ ) { 12652 if ( elem.nodeType === 1 ) { 12653 12654 // Prevent memory leaks 12655 jQuery.cleanData( getAll( elem, false ) ); 12656 12657 // Remove any remaining nodes 12658 elem.textContent = ""; 12659 } 12660 } 12661 12662 return this; 12663 }, 12664 12665 clone: function( dataAndEvents, deepDataAndEvents ) { 12666 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; 12667 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; 12668 12669 return this.map( function() { 12670 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); 12671 } ); 12672 }, 12673 12674 html: function( value ) { 12675 return access( this, function( value ) { 12676 var elem = this[ 0 ] || {}, 12677 i = 0, 12678 l = this.length; 12679 12680 if ( value === undefined && elem.nodeType === 1 ) { 12681 return elem.innerHTML; 12682 } 12683 12684 // See if we can take a shortcut and just use innerHTML 12685 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && 12686 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { 12687 12688 value = jQuery.htmlPrefilter( value ); 12689 12690 try { 12691 for ( ; i < l; i++ ) { 12692 elem = this[ i ] || {}; 12693 12694 // Remove element nodes and prevent memory leaks 12695 if ( elem.nodeType === 1 ) { 12696 jQuery.cleanData( getAll( elem, false ) ); 12697 elem.innerHTML = value; 12698 } 12699 } 12700 12701 elem = 0; 12702 12703 // If using innerHTML throws an exception, use the fallback method 12704 } catch ( e ) {} 12705 } 12706 12707 if ( elem ) { 12708 this.empty().append( value ); 12709 } 12710 }, null, value, arguments.length ); 12711 }, 12712 12713 replaceWith: function() { 12714 var ignored = []; 12715 12716 // Make the changes, replacing each non-ignored context element with the new content 12717 return domManip( this, arguments, function( elem ) { 12718 var parent = this.parentNode; 12719 12720 if ( jQuery.inArray( this, ignored ) < 0 ) { 12721 jQuery.cleanData( getAll( this ) ); 12722 if ( parent ) { 12723 parent.replaceChild( elem, this ); 12724 } 12725 } 12726 12727 // Force callback invocation 12728 }, ignored ); 12729 } 12730} ); 12731 12732jQuery.each( { 12733 appendTo: "append", 12734 prependTo: "prepend", 12735 insertBefore: "before", 12736 insertAfter: "after", 12737 replaceAll: "replaceWith" 12738}, function( name, original ) { 12739 jQuery.fn[ name ] = function( selector ) { 12740 var elems, 12741 ret = [], 12742 insert = jQuery( selector ), 12743 last = insert.length - 1, 12744 i = 0; 12745 12746 for ( ; i <= last; i++ ) { 12747 elems = i === last ? this : this.clone( true ); 12748 jQuery( insert[ i ] )[ original ]( elems ); 12749 12750 // Support: Android <=4.0 only, PhantomJS 1 only 12751 // .get() because push.apply(_, arraylike) throws on ancient WebKit 12752 push.apply( ret, elems.get() ); 12753 } 12754 12755 return this.pushStack( ret ); 12756 }; 12757} ); 12758var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); 12759 12760var getStyles = function( elem ) { 12761 12762 // Support: IE <=11 only, Firefox <=30 (#15098, #14150) 12763 // IE throws on elements created in popups 12764 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" 12765 var view = elem.ownerDocument.defaultView; 12766 12767 if ( !view || !view.opener ) { 12768 view = window; 12769 } 12770 12771 return view.getComputedStyle( elem ); 12772 }; 12773 12774var swap = function( elem, options, callback ) { 12775 var ret, name, 12776 old = {}; 12777 12778 // Remember the old values, and insert the new ones 12779 for ( name in options ) { 12780 old[ name ] = elem.style[ name ]; 12781 elem.style[ name ] = options[ name ]; 12782 } 12783 12784 ret = callback.call( elem ); 12785 12786 // Revert the old values 12787 for ( name in options ) { 12788 elem.style[ name ] = old[ name ]; 12789 } 12790 12791 return ret; 12792}; 12793 12794 12795var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); 12796 12797 12798 12799( function() { 12800 12801 // Executing both pixelPosition & boxSizingReliable tests require only one layout 12802 // so they're executed at the same time to save the second computation. 12803 function computeStyleTests() { 12804 12805 // This is a singleton, we need to execute it only once 12806 if ( !div ) { 12807 return; 12808 } 12809 12810 container.style.cssText = "position:absolute;left:-11111px;width:60px;" + 12811 "margin-top:1px;padding:0;border:0"; 12812 div.style.cssText = 12813 "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + 12814 "margin:auto;border:1px;padding:1px;" + 12815 "width:60%;top:1%"; 12816 documentElement.appendChild( container ).appendChild( div ); 12817 12818 var divStyle = window.getComputedStyle( div ); 12819 pixelPositionVal = divStyle.top !== "1%"; 12820 12821 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 12822 reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; 12823 12824 // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 12825 // Some styles come back with percentage values, even though they shouldn't 12826 div.style.right = "60%"; 12827 pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; 12828 12829 // Support: IE 9 - 11 only 12830 // Detect misreporting of content dimensions for box-sizing:border-box elements 12831 boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; 12832 12833 // Support: IE 9 only 12834 // Detect overflow:scroll screwiness (gh-3699) 12835 // Support: Chrome <=64 12836 // Don't get tricked when zoom affects offsetWidth (gh-4029) 12837 div.style.position = "absolute"; 12838 scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12; 12839 12840 documentElement.removeChild( container ); 12841 12842 // Nullify the div so it wouldn't be stored in the memory and 12843 // it will also be a sign that checks already performed 12844 div = null; 12845 } 12846 12847 function roundPixelMeasures( measure ) { 12848 return Math.round( parseFloat( measure ) ); 12849 } 12850 12851 var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, 12852 reliableTrDimensionsVal, reliableMarginLeftVal, 12853 container = document.createElement( "div" ), 12854 div = document.createElement( "div" ); 12855 12856 // Finish early in limited (non-browser) environments 12857 if ( !div.style ) { 12858 return; 12859 } 12860 12861 // Support: IE <=9 - 11 only 12862 // Style of cloned element affects source element cloned (#8908) 12863 div.style.backgroundClip = "content-box"; 12864 div.cloneNode( true ).style.backgroundClip = ""; 12865 support.clearCloneStyle = div.style.backgroundClip === "content-box"; 12866 12867 jQuery.extend( support, { 12868 boxSizingReliable: function() { 12869 computeStyleTests(); 12870 return boxSizingReliableVal; 12871 }, 12872 pixelBoxStyles: function() { 12873 computeStyleTests(); 12874 return pixelBoxStylesVal; 12875 }, 12876 pixelPosition: function() { 12877 computeStyleTests(); 12878 return pixelPositionVal; 12879 }, 12880 reliableMarginLeft: function() { 12881 computeStyleTests(); 12882 return reliableMarginLeftVal; 12883 }, 12884 scrollboxSize: function() { 12885 computeStyleTests(); 12886 return scrollboxSizeVal; 12887 }, 12888 12889 // Support: IE 9 - 11+, Edge 15 - 18+ 12890 // IE/Edge misreport `getComputedStyle` of table rows with width/height 12891 // set in CSS while `offset*` properties report correct values. 12892 // Behavior in IE 9 is more subtle than in newer versions & it passes 12893 // some versions of this test; make sure not to make it pass there! 12894 reliableTrDimensions: function() { 12895 var table, tr, trChild, trStyle; 12896 if ( reliableTrDimensionsVal == null ) { 12897 table = document.createElement( "table" ); 12898 tr = document.createElement( "tr" ); 12899 trChild = document.createElement( "div" ); 12900 12901 table.style.cssText = "position:absolute;left:-11111px"; 12902 tr.style.height = "1px"; 12903 trChild.style.height = "9px"; 12904 12905 documentElement 12906 .appendChild( table ) 12907 .appendChild( tr ) 12908 .appendChild( trChild ); 12909 12910 trStyle = window.getComputedStyle( tr ); 12911 reliableTrDimensionsVal = parseInt( trStyle.height ) > 3; 12912 12913 documentElement.removeChild( table ); 12914 } 12915 return reliableTrDimensionsVal; 12916 } 12917 } ); 12918} )(); 12919 12920 12921function curCSS( elem, name, computed ) { 12922 var width, minWidth, maxWidth, ret, 12923 12924 // Support: Firefox 51+ 12925 // Retrieving style before computed somehow 12926 // fixes an issue with getting wrong values 12927 // on detached elements 12928 style = elem.style; 12929 12930 computed = computed || getStyles( elem ); 12931 12932 // getPropertyValue is needed for: 12933 // .css('filter') (IE 9 only, #12537) 12934 // .css('--customProperty) (#3144) 12935 if ( computed ) { 12936 ret = computed.getPropertyValue( name ) || computed[ name ]; 12937 12938 if ( ret === "" && !isAttached( elem ) ) { 12939 ret = jQuery.style( elem, name ); 12940 } 12941 12942 // A tribute to the "awesome hack by Dean Edwards" 12943 // Android Browser returns percentage for some values, 12944 // but width seems to be reliably pixels. 12945 // This is against the CSSOM draft spec: 12946 // https://drafts.csswg.org/cssom/#resolved-values 12947 if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) { 12948 12949 // Remember the original values 12950 width = style.width; 12951 minWidth = style.minWidth; 12952 maxWidth = style.maxWidth; 12953 12954 // Put in the new values to get a computed value out 12955 style.minWidth = style.maxWidth = style.width = ret; 12956 ret = computed.width; 12957 12958 // Revert the changed values 12959 style.width = width; 12960 style.minWidth = minWidth; 12961 style.maxWidth = maxWidth; 12962 } 12963 } 12964 12965 return ret !== undefined ? 12966 12967 // Support: IE <=9 - 11 only 12968 // IE returns zIndex value as an integer. 12969 ret + "" : 12970 ret; 12971} 12972 12973 12974function addGetHookIf( conditionFn, hookFn ) { 12975 12976 // Define the hook, we'll check on the first run if it's really needed. 12977 return { 12978 get: function() { 12979 if ( conditionFn() ) { 12980 12981 // Hook not needed (or it's not possible to use it due 12982 // to missing dependency), remove it. 12983 delete this.get; 12984 return; 12985 } 12986 12987 // Hook needed; redefine it so that the support test is not executed again. 12988 return ( this.get = hookFn ).apply( this, arguments ); 12989 } 12990 }; 12991} 12992 12993 12994var cssPrefixes = [ "Webkit", "Moz", "ms" ], 12995 emptyStyle = document.createElement( "div" ).style, 12996 vendorProps = {}; 12997 12998// Return a vendor-prefixed property or undefined 12999function vendorPropName( name ) { 13000 13001 // Check for vendor prefixed names 13002 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), 13003 i = cssPrefixes.length; 13004 13005 while ( i-- ) { 13006 name = cssPrefixes[ i ] + capName; 13007 if ( name in emptyStyle ) { 13008 return name; 13009 } 13010 } 13011} 13012 13013// Return a potentially-mapped jQuery.cssProps or vendor prefixed property 13014function finalPropName( name ) { 13015 var final = jQuery.cssProps[ name ] || vendorProps[ name ]; 13016 13017 if ( final ) { 13018 return final; 13019 } 13020 if ( name in emptyStyle ) { 13021 return name; 13022 } 13023 return vendorProps[ name ] = vendorPropName( name ) || name; 13024} 13025 13026 13027var 13028 13029 // Swappable if display is none or starts with table 13030 // except "table", "table-cell", or "table-caption" 13031 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display 13032 rdisplayswap = /^(none|table(?!-c[ea]).+)/, 13033 rcustomProp = /^--/, 13034 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, 13035 cssNormalTransform = { 13036 letterSpacing: "0", 13037 fontWeight: "400" 13038 }; 13039 13040function setPositiveNumber( _elem, value, subtract ) { 13041 13042 // Any relative (+/-) values have already been 13043 // normalized at this point 13044 var matches = rcssNum.exec( value ); 13045 return matches ? 13046 13047 // Guard against undefined "subtract", e.g., when used as in cssHooks 13048 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : 13049 value; 13050} 13051 13052function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { 13053 var i = dimension === "width" ? 1 : 0, 13054 extra = 0, 13055 delta = 0; 13056 13057 // Adjustment may not be necessary 13058 if ( box === ( isBorderBox ? "border" : "content" ) ) { 13059 return 0; 13060 } 13061 13062 for ( ; i < 4; i += 2 ) { 13063 13064 // Both box models exclude margin 13065 if ( box === "margin" ) { 13066 delta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); 13067 } 13068 13069 // If we get here with a content-box, we're seeking "padding" or "border" or "margin" 13070 if ( !isBorderBox ) { 13071 13072 // Add padding 13073 delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 13074 13075 // For "border" or "margin", add border 13076 if ( box !== "padding" ) { 13077 delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 13078 13079 // But still keep track of it otherwise 13080 } else { 13081 extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 13082 } 13083 13084 // If we get here with a border-box (content + padding + border), we're seeking "content" or 13085 // "padding" or "margin" 13086 } else { 13087 13088 // For "content", subtract padding 13089 if ( box === "content" ) { 13090 delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 13091 } 13092 13093 // For "content" or "padding", subtract border 13094 if ( box !== "margin" ) { 13095 delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 13096 } 13097 } 13098 } 13099 13100 // Account for positive content-box scroll gutter when requested by providing computedVal 13101 if ( !isBorderBox && computedVal >= 0 ) { 13102 13103 // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border 13104 // Assuming integer scroll gutter, subtract the rest and round down 13105 delta += Math.max( 0, Math.ceil( 13106 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - 13107 computedVal - 13108 delta - 13109 extra - 13110 0.5 13111 13112 // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter 13113 // Use an explicit zero to avoid NaN (gh-3964) 13114 ) ) || 0; 13115 } 13116 13117 return delta; 13118} 13119 13120function getWidthOrHeight( elem, dimension, extra ) { 13121 13122 // Start with computed style 13123 var styles = getStyles( elem ), 13124 13125 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). 13126 // Fake content-box until we know it's needed to know the true value. 13127 boxSizingNeeded = !support.boxSizingReliable() || extra, 13128 isBorderBox = boxSizingNeeded && 13129 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 13130 valueIsBorderBox = isBorderBox, 13131 13132 val = curCSS( elem, dimension, styles ), 13133 offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); 13134 13135 // Support: Firefox <=54 13136 // Return a confounding non-pixel value or feign ignorance, as appropriate. 13137 if ( rnumnonpx.test( val ) ) { 13138 if ( !extra ) { 13139 return val; 13140 } 13141 val = "auto"; 13142 } 13143 13144 13145 // Support: IE 9 - 11 only 13146 // Use offsetWidth/offsetHeight for when box sizing is unreliable. 13147 // In those cases, the computed value can be trusted to be border-box. 13148 if ( ( !support.boxSizingReliable() && isBorderBox || 13149 13150 // Support: IE 10 - 11+, Edge 15 - 18+ 13151 // IE/Edge misreport `getComputedStyle` of table rows with width/height 13152 // set in CSS while `offset*` properties report correct values. 13153 // Interestingly, in some cases IE 9 doesn't suffer from this issue. 13154 !support.reliableTrDimensions() && nodeName( elem, "tr" ) || 13155 13156 // Fall back to offsetWidth/offsetHeight when value is "auto" 13157 // This happens for inline elements with no explicit setting (gh-3571) 13158 val === "auto" || 13159 13160 // Support: Android <=4.1 - 4.3 only 13161 // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) 13162 !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && 13163 13164 // Make sure the element is visible & connected 13165 elem.getClientRects().length ) { 13166 13167 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; 13168 13169 // Where available, offsetWidth/offsetHeight approximate border box dimensions. 13170 // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the 13171 // retrieved value as a content box dimension. 13172 valueIsBorderBox = offsetProp in elem; 13173 if ( valueIsBorderBox ) { 13174 val = elem[ offsetProp ]; 13175 } 13176 } 13177 13178 // Normalize "" and auto 13179 val = parseFloat( val ) || 0; 13180 13181 // Adjust for the element's box model 13182 return ( val + 13183 boxModelAdjustment( 13184 elem, 13185 dimension, 13186 extra || ( isBorderBox ? "border" : "content" ), 13187 valueIsBorderBox, 13188 styles, 13189 13190 // Provide the current computed size to request scroll gutter calculation (gh-3589) 13191 val 13192 ) 13193 ) + "px"; 13194} 13195 13196jQuery.extend( { 13197 13198 // Add in style property hooks for overriding the default 13199 // behavior of getting and setting a style property 13200 cssHooks: { 13201 opacity: { 13202 get: function( elem, computed ) { 13203 if ( computed ) { 13204 13205 // We should always get a number back from opacity 13206 var ret = curCSS( elem, "opacity" ); 13207 return ret === "" ? "1" : ret; 13208 } 13209 } 13210 } 13211 }, 13212 13213 // Don't automatically add "px" to these possibly-unitless properties 13214 cssNumber: { 13215 "animationIterationCount": true, 13216 "columnCount": true, 13217 "fillOpacity": true, 13218 "flexGrow": true, 13219 "flexShrink": true, 13220 "fontWeight": true, 13221 "gridArea": true, 13222 "gridColumn": true, 13223 "gridColumnEnd": true, 13224 "gridColumnStart": true, 13225 "gridRow": true, 13226 "gridRowEnd": true, 13227 "gridRowStart": true, 13228 "lineHeight": true, 13229 "opacity": true, 13230 "order": true, 13231 "orphans": true, 13232 "widows": true, 13233 "zIndex": true, 13234 "zoom": true 13235 }, 13236 13237 // Add in properties whose names you wish to fix before 13238 // setting or getting the value 13239 cssProps: {}, 13240 13241 // Get and set the style property on a DOM Node 13242 style: function( elem, name, value, extra ) { 13243 13244 // Don't set styles on text and comment nodes 13245 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { 13246 return; 13247 } 13248 13249 // Make sure that we're working with the right name 13250 var ret, type, hooks, 13251 origName = camelCase( name ), 13252 isCustomProp = rcustomProp.test( name ), 13253 style = elem.style; 13254 13255 // Make sure that we're working with the right name. We don't 13256 // want to query the value if it is a CSS custom property 13257 // since they are user-defined. 13258 if ( !isCustomProp ) { 13259 name = finalPropName( origName ); 13260 } 13261 13262 // Gets hook for the prefixed version, then unprefixed version 13263 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 13264 13265 // Check if we're setting a value 13266 if ( value !== undefined ) { 13267 type = typeof value; 13268 13269 // Convert "+=" or "-=" to relative numbers (#7345) 13270 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { 13271 value = adjustCSS( elem, name, ret ); 13272 13273 // Fixes bug #9237 13274 type = "number"; 13275 } 13276 13277 // Make sure that null and NaN values aren't set (#7116) 13278 if ( value == null || value !== value ) { 13279 return; 13280 } 13281 13282 // If a number was passed in, add the unit (except for certain CSS properties) 13283 // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append 13284 // "px" to a few hardcoded values. 13285 if ( type === "number" && !isCustomProp ) { 13286 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); 13287 } 13288 13289 // background-* props affect original clone's values 13290 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { 13291 style[ name ] = "inherit"; 13292 } 13293 13294 // If a hook was provided, use that value, otherwise just set the specified value 13295 if ( !hooks || !( "set" in hooks ) || 13296 ( value = hooks.set( elem, value, extra ) ) !== undefined ) { 13297 13298 if ( isCustomProp ) { 13299 style.setProperty( name, value ); 13300 } else { 13301 style[ name ] = value; 13302 } 13303 } 13304 13305 } else { 13306 13307 // If a hook was provided get the non-computed value from there 13308 if ( hooks && "get" in hooks && 13309 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { 13310 13311 return ret; 13312 } 13313 13314 // Otherwise just get the value from the style object 13315 return style[ name ]; 13316 } 13317 }, 13318 13319 css: function( elem, name, extra, styles ) { 13320 var val, num, hooks, 13321 origName = camelCase( name ), 13322 isCustomProp = rcustomProp.test( name ); 13323 13324 // Make sure that we're working with the right name. We don't 13325 // want to modify the value if it is a CSS custom property 13326 // since they are user-defined. 13327 if ( !isCustomProp ) { 13328 name = finalPropName( origName ); 13329 } 13330 13331 // Try prefixed name followed by the unprefixed name 13332 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 13333 13334 // If a hook was provided get the computed value from there 13335 if ( hooks && "get" in hooks ) { 13336 val = hooks.get( elem, true, extra ); 13337 } 13338 13339 // Otherwise, if a way to get the computed value exists, use that 13340 if ( val === undefined ) { 13341 val = curCSS( elem, name, styles ); 13342 } 13343 13344 // Convert "normal" to computed value 13345 if ( val === "normal" && name in cssNormalTransform ) { 13346 val = cssNormalTransform[ name ]; 13347 } 13348 13349 // Make numeric if forced or a qualifier was provided and val looks numeric 13350 if ( extra === "" || extra ) { 13351 num = parseFloat( val ); 13352 return extra === true || isFinite( num ) ? num || 0 : val; 13353 } 13354 13355 return val; 13356 } 13357} ); 13358 13359jQuery.each( [ "height", "width" ], function( _i, dimension ) { 13360 jQuery.cssHooks[ dimension ] = { 13361 get: function( elem, computed, extra ) { 13362 if ( computed ) { 13363 13364 // Certain elements can have dimension info if we invisibly show them 13365 // but it must have a current display style that would benefit 13366 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && 13367 13368 // Support: Safari 8+ 13369 // Table columns in Safari have non-zero offsetWidth & zero 13370 // getBoundingClientRect().width unless display is changed. 13371 // Support: IE <=11 only 13372 // Running getBoundingClientRect on a disconnected node 13373 // in IE throws an error. 13374 ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? 13375 swap( elem, cssShow, function() { 13376 return getWidthOrHeight( elem, dimension, extra ); 13377 } ) : 13378 getWidthOrHeight( elem, dimension, extra ); 13379 } 13380 }, 13381 13382 set: function( elem, value, extra ) { 13383 var matches, 13384 styles = getStyles( elem ), 13385 13386 // Only read styles.position if the test has a chance to fail 13387 // to avoid forcing a reflow. 13388 scrollboxSizeBuggy = !support.scrollboxSize() && 13389 styles.position === "absolute", 13390 13391 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991) 13392 boxSizingNeeded = scrollboxSizeBuggy || extra, 13393 isBorderBox = boxSizingNeeded && 13394 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 13395 subtract = extra ? 13396 boxModelAdjustment( 13397 elem, 13398 dimension, 13399 extra, 13400 isBorderBox, 13401 styles 13402 ) : 13403 0; 13404 13405 // Account for unreliable border-box dimensions by comparing offset* to computed and 13406 // faking a content-box to get border and padding (gh-3699) 13407 if ( isBorderBox && scrollboxSizeBuggy ) { 13408 subtract -= Math.ceil( 13409 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - 13410 parseFloat( styles[ dimension ] ) - 13411 boxModelAdjustment( elem, dimension, "border", false, styles ) - 13412 0.5 13413 ); 13414 } 13415 13416 // Convert to pixels if value adjustment is needed 13417 if ( subtract && ( matches = rcssNum.exec( value ) ) && 13418 ( matches[ 3 ] || "px" ) !== "px" ) { 13419 13420 elem.style[ dimension ] = value; 13421 value = jQuery.css( elem, dimension ); 13422 } 13423 13424 return setPositiveNumber( elem, value, subtract ); 13425 } 13426 }; 13427} ); 13428 13429jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, 13430 function( elem, computed ) { 13431 if ( computed ) { 13432 return ( parseFloat( curCSS( elem, "marginLeft" ) ) || 13433 elem.getBoundingClientRect().left - 13434 swap( elem, { marginLeft: 0 }, function() { 13435 return elem.getBoundingClientRect().left; 13436 } ) 13437 ) + "px"; 13438 } 13439 } 13440); 13441 13442// These hooks are used by animate to expand properties 13443jQuery.each( { 13444 margin: "", 13445 padding: "", 13446 border: "Width" 13447}, function( prefix, suffix ) { 13448 jQuery.cssHooks[ prefix + suffix ] = { 13449 expand: function( value ) { 13450 var i = 0, 13451 expanded = {}, 13452 13453 // Assumes a single number if not a string 13454 parts = typeof value === "string" ? value.split( " " ) : [ value ]; 13455 13456 for ( ; i < 4; i++ ) { 13457 expanded[ prefix + cssExpand[ i ] + suffix ] = 13458 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; 13459 } 13460 13461 return expanded; 13462 } 13463 }; 13464 13465 if ( prefix !== "margin" ) { 13466 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; 13467 } 13468} ); 13469 13470jQuery.fn.extend( { 13471 css: function( name, value ) { 13472 return access( this, function( elem, name, value ) { 13473 var styles, len, 13474 map = {}, 13475 i = 0; 13476 13477 if ( Array.isArray( name ) ) { 13478 styles = getStyles( elem ); 13479 len = name.length; 13480 13481 for ( ; i < len; i++ ) { 13482 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); 13483 } 13484 13485 return map; 13486 } 13487 13488 return value !== undefined ? 13489 jQuery.style( elem, name, value ) : 13490 jQuery.css( elem, name ); 13491 }, name, value, arguments.length > 1 ); 13492 } 13493} ); 13494 13495 13496function Tween( elem, options, prop, end, easing ) { 13497 return new Tween.prototype.init( elem, options, prop, end, easing ); 13498} 13499jQuery.Tween = Tween; 13500 13501Tween.prototype = { 13502 constructor: Tween, 13503 init: function( elem, options, prop, end, easing, unit ) { 13504 this.elem = elem; 13505 this.prop = prop; 13506 this.easing = easing || jQuery.easing._default; 13507 this.options = options; 13508 this.start = this.now = this.cur(); 13509 this.end = end; 13510 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); 13511 }, 13512 cur: function() { 13513 var hooks = Tween.propHooks[ this.prop ]; 13514 13515 return hooks && hooks.get ? 13516 hooks.get( this ) : 13517 Tween.propHooks._default.get( this ); 13518 }, 13519 run: function( percent ) { 13520 var eased, 13521 hooks = Tween.propHooks[ this.prop ]; 13522 13523 if ( this.options.duration ) { 13524 this.pos = eased = jQuery.easing[ this.easing ]( 13525 percent, this.options.duration * percent, 0, 1, this.options.duration 13526 ); 13527 } else { 13528 this.pos = eased = percent; 13529 } 13530 this.now = ( this.end - this.start ) * eased + this.start; 13531 13532 if ( this.options.step ) { 13533 this.options.step.call( this.elem, this.now, this ); 13534 } 13535 13536 if ( hooks && hooks.set ) { 13537 hooks.set( this ); 13538 } else { 13539 Tween.propHooks._default.set( this ); 13540 } 13541 return this; 13542 } 13543}; 13544 13545Tween.prototype.init.prototype = Tween.prototype; 13546 13547Tween.propHooks = { 13548 _default: { 13549 get: function( tween ) { 13550 var result; 13551 13552 // Use a property on the element directly when it is not a DOM element, 13553 // or when there is no matching style property that exists. 13554 if ( tween.elem.nodeType !== 1 || 13555 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { 13556 return tween.elem[ tween.prop ]; 13557 } 13558 13559 // Passing an empty string as a 3rd parameter to .css will automatically 13560 // attempt a parseFloat and fallback to a string if the parse fails. 13561 // Simple values such as "10px" are parsed to Float; 13562 // complex values such as "rotate(1rad)" are returned as-is. 13563 result = jQuery.css( tween.elem, tween.prop, "" ); 13564 13565 // Empty strings, null, undefined and "auto" are converted to 0. 13566 return !result || result === "auto" ? 0 : result; 13567 }, 13568 set: function( tween ) { 13569 13570 // Use step hook for back compat. 13571 // Use cssHook if its there. 13572 // Use .style if available and use plain properties where available. 13573 if ( jQuery.fx.step[ tween.prop ] ) { 13574 jQuery.fx.step[ tween.prop ]( tween ); 13575 } else if ( tween.elem.nodeType === 1 && ( 13576 jQuery.cssHooks[ tween.prop ] || 13577 tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) { 13578 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); 13579 } else { 13580 tween.elem[ tween.prop ] = tween.now; 13581 } 13582 } 13583 } 13584}; 13585 13586// Support: IE <=9 only 13587// Panic based approach to setting things on disconnected nodes 13588Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { 13589 set: function( tween ) { 13590 if ( tween.elem.nodeType && tween.elem.parentNode ) { 13591 tween.elem[ tween.prop ] = tween.now; 13592 } 13593 } 13594}; 13595 13596jQuery.easing = { 13597 linear: function( p ) { 13598 return p; 13599 }, 13600 swing: function( p ) { 13601 return 0.5 - Math.cos( p * Math.PI ) / 2; 13602 }, 13603 _default: "swing" 13604}; 13605 13606jQuery.fx = Tween.prototype.init; 13607 13608// Back compat <1.8 extension point 13609jQuery.fx.step = {}; 13610 13611 13612 13613 13614var 13615 fxNow, inProgress, 13616 rfxtypes = /^(?:toggle|show|hide)$/, 13617 rrun = /queueHooks$/; 13618 13619function schedule() { 13620 if ( inProgress ) { 13621 if ( document.hidden === false && window.requestAnimationFrame ) { 13622 window.requestAnimationFrame( schedule ); 13623 } else { 13624 window.setTimeout( schedule, jQuery.fx.interval ); 13625 } 13626 13627 jQuery.fx.tick(); 13628 } 13629} 13630 13631// Animations created synchronously will run synchronously 13632function createFxNow() { 13633 window.setTimeout( function() { 13634 fxNow = undefined; 13635 } ); 13636 return ( fxNow = Date.now() ); 13637} 13638 13639// Generate parameters to create a standard animation 13640function genFx( type, includeWidth ) { 13641 var which, 13642 i = 0, 13643 attrs = { height: type }; 13644 13645 // If we include width, step value is 1 to do all cssExpand values, 13646 // otherwise step value is 2 to skip over Left and Right 13647 includeWidth = includeWidth ? 1 : 0; 13648 for ( ; i < 4; i += 2 - includeWidth ) { 13649 which = cssExpand[ i ]; 13650 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; 13651 } 13652 13653 if ( includeWidth ) { 13654 attrs.opacity = attrs.width = type; 13655 } 13656 13657 return attrs; 13658} 13659 13660function createTween( value, prop, animation ) { 13661 var tween, 13662 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), 13663 index = 0, 13664 length = collection.length; 13665 for ( ; index < length; index++ ) { 13666 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { 13667 13668 // We're done with this property 13669 return tween; 13670 } 13671 } 13672} 13673 13674function defaultPrefilter( elem, props, opts ) { 13675 var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, 13676 isBox = "width" in props || "height" in props, 13677 anim = this, 13678 orig = {}, 13679 style = elem.style, 13680 hidden = elem.nodeType && isHiddenWithinTree( elem ), 13681 dataShow = dataPriv.get( elem, "fxshow" ); 13682 13683 // Queue-skipping animations hijack the fx hooks 13684 if ( !opts.queue ) { 13685 hooks = jQuery._queueHooks( elem, "fx" ); 13686 if ( hooks.unqueued == null ) { 13687 hooks.unqueued = 0; 13688 oldfire = hooks.empty.fire; 13689 hooks.empty.fire = function() { 13690 if ( !hooks.unqueued ) { 13691 oldfire(); 13692 } 13693 }; 13694 } 13695 hooks.unqueued++; 13696 13697 anim.always( function() { 13698 13699 // Ensure the complete handler is called before this completes 13700 anim.always( function() { 13701 hooks.unqueued--; 13702 if ( !jQuery.queue( elem, "fx" ).length ) { 13703 hooks.empty.fire(); 13704 } 13705 } ); 13706 } ); 13707 } 13708 13709 // Detect show/hide animations 13710 for ( prop in props ) { 13711 value = props[ prop ]; 13712 if ( rfxtypes.test( value ) ) { 13713 delete props[ prop ]; 13714 toggle = toggle || value === "toggle"; 13715 if ( value === ( hidden ? "hide" : "show" ) ) { 13716 13717 // Pretend to be hidden if this is a "show" and 13718 // there is still data from a stopped show/hide 13719 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { 13720 hidden = true; 13721 13722 // Ignore all other no-op show/hide data 13723 } else { 13724 continue; 13725 } 13726 } 13727 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); 13728 } 13729 } 13730 13731 // Bail out if this is a no-op like .hide().hide() 13732 propTween = !jQuery.isEmptyObject( props ); 13733 if ( !propTween && jQuery.isEmptyObject( orig ) ) { 13734 return; 13735 } 13736 13737 // Restrict "overflow" and "display" styles during box animations 13738 if ( isBox && elem.nodeType === 1 ) { 13739 13740 // Support: IE <=9 - 11, Edge 12 - 15 13741 // Record all 3 overflow attributes because IE does not infer the shorthand 13742 // from identically-valued overflowX and overflowY and Edge just mirrors 13743 // the overflowX value there. 13744 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; 13745 13746 // Identify a display type, preferring old show/hide data over the CSS cascade 13747 restoreDisplay = dataShow && dataShow.display; 13748 if ( restoreDisplay == null ) { 13749 restoreDisplay = dataPriv.get( elem, "display" ); 13750 } 13751 display = jQuery.css( elem, "display" ); 13752 if ( display === "none" ) { 13753 if ( restoreDisplay ) { 13754 display = restoreDisplay; 13755 } else { 13756 13757 // Get nonempty value(s) by temporarily forcing visibility 13758 showHide( [ elem ], true ); 13759 restoreDisplay = elem.style.display || restoreDisplay; 13760 display = jQuery.css( elem, "display" ); 13761 showHide( [ elem ] ); 13762 } 13763 } 13764 13765 // Animate inline elements as inline-block 13766 if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { 13767 if ( jQuery.css( elem, "float" ) === "none" ) { 13768 13769 // Restore the original display value at the end of pure show/hide animations 13770 if ( !propTween ) { 13771 anim.done( function() { 13772 style.display = restoreDisplay; 13773 } ); 13774 if ( restoreDisplay == null ) { 13775 display = style.display; 13776 restoreDisplay = display === "none" ? "" : display; 13777 } 13778 } 13779 style.display = "inline-block"; 13780 } 13781 } 13782 } 13783 13784 if ( opts.overflow ) { 13785 style.overflow = "hidden"; 13786 anim.always( function() { 13787 style.overflow = opts.overflow[ 0 ]; 13788 style.overflowX = opts.overflow[ 1 ]; 13789 style.overflowY = opts.overflow[ 2 ]; 13790 } ); 13791 } 13792 13793 // Implement show/hide animations 13794 propTween = false; 13795 for ( prop in orig ) { 13796 13797 // General show/hide setup for this element animation 13798 if ( !propTween ) { 13799 if ( dataShow ) { 13800 if ( "hidden" in dataShow ) { 13801 hidden = dataShow.hidden; 13802 } 13803 } else { 13804 dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); 13805 } 13806 13807 // Store hidden/visible for toggle so `.stop().toggle()` "reverses" 13808 if ( toggle ) { 13809 dataShow.hidden = !hidden; 13810 } 13811 13812 // Show elements before animating them 13813 if ( hidden ) { 13814 showHide( [ elem ], true ); 13815 } 13816 13817 /* eslint-disable no-loop-func */ 13818 13819 anim.done( function() { 13820 13821 /* eslint-enable no-loop-func */ 13822 13823 // The final step of a "hide" animation is actually hiding the element 13824 if ( !hidden ) { 13825 showHide( [ elem ] ); 13826 } 13827 dataPriv.remove( elem, "fxshow" ); 13828 for ( prop in orig ) { 13829 jQuery.style( elem, prop, orig[ prop ] ); 13830 } 13831 } ); 13832 } 13833 13834 // Per-property setup 13835 propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); 13836 if ( !( prop in dataShow ) ) { 13837 dataShow[ prop ] = propTween.start; 13838 if ( hidden ) { 13839 propTween.end = propTween.start; 13840 propTween.start = 0; 13841 } 13842 } 13843 } 13844} 13845 13846function propFilter( props, specialEasing ) { 13847 var index, name, easing, value, hooks; 13848 13849 // camelCase, specialEasing and expand cssHook pass 13850 for ( index in props ) { 13851 name = camelCase( index ); 13852 easing = specialEasing[ name ]; 13853 value = props[ index ]; 13854 if ( Array.isArray( value ) ) { 13855 easing = value[ 1 ]; 13856 value = props[ index ] = value[ 0 ]; 13857 } 13858 13859 if ( index !== name ) { 13860 props[ name ] = value; 13861 delete props[ index ]; 13862 } 13863 13864 hooks = jQuery.cssHooks[ name ]; 13865 if ( hooks && "expand" in hooks ) { 13866 value = hooks.expand( value ); 13867 delete props[ name ]; 13868 13869 // Not quite $.extend, this won't overwrite existing keys. 13870 // Reusing 'index' because we have the correct "name" 13871 for ( index in value ) { 13872 if ( !( index in props ) ) { 13873 props[ index ] = value[ index ]; 13874 specialEasing[ index ] = easing; 13875 } 13876 } 13877 } else { 13878 specialEasing[ name ] = easing; 13879 } 13880 } 13881} 13882 13883function Animation( elem, properties, options ) { 13884 var result, 13885 stopped, 13886 index = 0, 13887 length = Animation.prefilters.length, 13888 deferred = jQuery.Deferred().always( function() { 13889 13890 // Don't match elem in the :animated selector 13891 delete tick.elem; 13892 } ), 13893 tick = function() { 13894 if ( stopped ) { 13895 return false; 13896 } 13897 var currentTime = fxNow || createFxNow(), 13898 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), 13899 13900 // Support: Android 2.3 only 13901 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) 13902 temp = remaining / animation.duration || 0, 13903 percent = 1 - temp, 13904 index = 0, 13905 length = animation.tweens.length; 13906 13907 for ( ; index < length; index++ ) { 13908 animation.tweens[ index ].run( percent ); 13909 } 13910 13911 deferred.notifyWith( elem, [ animation, percent, remaining ] ); 13912 13913 // If there's more to do, yield 13914 if ( percent < 1 && length ) { 13915 return remaining; 13916 } 13917 13918 // If this was an empty animation, synthesize a final progress notification 13919 if ( !length ) { 13920 deferred.notifyWith( elem, [ animation, 1, 0 ] ); 13921 } 13922 13923 // Resolve the animation and report its conclusion 13924 deferred.resolveWith( elem, [ animation ] ); 13925 return false; 13926 }, 13927 animation = deferred.promise( { 13928 elem: elem, 13929 props: jQuery.extend( {}, properties ), 13930 opts: jQuery.extend( true, { 13931 specialEasing: {}, 13932 easing: jQuery.easing._default 13933 }, options ), 13934 originalProperties: properties, 13935 originalOptions: options, 13936 startTime: fxNow || createFxNow(), 13937 duration: options.duration, 13938 tweens: [], 13939 createTween: function( prop, end ) { 13940 var tween = jQuery.Tween( elem, animation.opts, prop, end, 13941 animation.opts.specialEasing[ prop ] || animation.opts.easing ); 13942 animation.tweens.push( tween ); 13943 return tween; 13944 }, 13945 stop: function( gotoEnd ) { 13946 var index = 0, 13947 13948 // If we are going to the end, we want to run all the tweens 13949 // otherwise we skip this part 13950 length = gotoEnd ? animation.tweens.length : 0; 13951 if ( stopped ) { 13952 return this; 13953 } 13954 stopped = true; 13955 for ( ; index < length; index++ ) { 13956 animation.tweens[ index ].run( 1 ); 13957 } 13958 13959 // Resolve when we played the last frame; otherwise, reject 13960 if ( gotoEnd ) { 13961 deferred.notifyWith( elem, [ animation, 1, 0 ] ); 13962 deferred.resolveWith( elem, [ animation, gotoEnd ] ); 13963 } else { 13964 deferred.rejectWith( elem, [ animation, gotoEnd ] ); 13965 } 13966 return this; 13967 } 13968 } ), 13969 props = animation.props; 13970 13971 propFilter( props, animation.opts.specialEasing ); 13972 13973 for ( ; index < length; index++ ) { 13974 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); 13975 if ( result ) { 13976 if ( isFunction( result.stop ) ) { 13977 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = 13978 result.stop.bind( result ); 13979 } 13980 return result; 13981 } 13982 } 13983 13984 jQuery.map( props, createTween, animation ); 13985 13986 if ( isFunction( animation.opts.start ) ) { 13987 animation.opts.start.call( elem, animation ); 13988 } 13989 13990 // Attach callbacks from options 13991 animation 13992 .progress( animation.opts.progress ) 13993 .done( animation.opts.done, animation.opts.complete ) 13994 .fail( animation.opts.fail ) 13995 .always( animation.opts.always ); 13996 13997 jQuery.fx.timer( 13998 jQuery.extend( tick, { 13999 elem: elem, 14000 anim: animation, 14001 queue: animation.opts.queue 14002 } ) 14003 ); 14004 14005 return animation; 14006} 14007 14008jQuery.Animation = jQuery.extend( Animation, { 14009 14010 tweeners: { 14011 "*": [ function( prop, value ) { 14012 var tween = this.createTween( prop, value ); 14013 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); 14014 return tween; 14015 } ] 14016 }, 14017 14018 tweener: function( props, callback ) { 14019 if ( isFunction( props ) ) { 14020 callback = props; 14021 props = [ "*" ]; 14022 } else { 14023 props = props.match( rnothtmlwhite ); 14024 } 14025 14026 var prop, 14027 index = 0, 14028 length = props.length; 14029 14030 for ( ; index < length; index++ ) { 14031 prop = props[ index ]; 14032 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; 14033 Animation.tweeners[ prop ].unshift( callback ); 14034 } 14035 }, 14036 14037 prefilters: [ defaultPrefilter ], 14038 14039 prefilter: function( callback, prepend ) { 14040 if ( prepend ) { 14041 Animation.prefilters.unshift( callback ); 14042 } else { 14043 Animation.prefilters.push( callback ); 14044 } 14045 } 14046} ); 14047 14048jQuery.speed = function( speed, easing, fn ) { 14049 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { 14050 complete: fn || !fn && easing || 14051 isFunction( speed ) && speed, 14052 duration: speed, 14053 easing: fn && easing || easing && !isFunction( easing ) && easing 14054 }; 14055 14056 // Go to the end state if fx are off 14057 if ( jQuery.fx.off ) { 14058 opt.duration = 0; 14059 14060 } else { 14061 if ( typeof opt.duration !== "number" ) { 14062 if ( opt.duration in jQuery.fx.speeds ) { 14063 opt.duration = jQuery.fx.speeds[ opt.duration ]; 14064 14065 } else { 14066 opt.duration = jQuery.fx.speeds._default; 14067 } 14068 } 14069 } 14070 14071 // Normalize opt.queue - true/undefined/null -> "fx" 14072 if ( opt.queue == null || opt.queue === true ) { 14073 opt.queue = "fx"; 14074 } 14075 14076 // Queueing 14077 opt.old = opt.complete; 14078 14079 opt.complete = function() { 14080 if ( isFunction( opt.old ) ) { 14081 opt.old.call( this ); 14082 } 14083 14084 if ( opt.queue ) { 14085 jQuery.dequeue( this, opt.queue ); 14086 } 14087 }; 14088 14089 return opt; 14090}; 14091 14092jQuery.fn.extend( { 14093 fadeTo: function( speed, to, easing, callback ) { 14094 14095 // Show any hidden elements after setting opacity to 0 14096 return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show() 14097 14098 // Animate to the value specified 14099 .end().animate( { opacity: to }, speed, easing, callback ); 14100 }, 14101 animate: function( prop, speed, easing, callback ) { 14102 var empty = jQuery.isEmptyObject( prop ), 14103 optall = jQuery.speed( speed, easing, callback ), 14104 doAnimation = function() { 14105 14106 // Operate on a copy of prop so per-property easing won't be lost 14107 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); 14108 14109 // Empty animations, or finishing resolves immediately 14110 if ( empty || dataPriv.get( this, "finish" ) ) { 14111 anim.stop( true ); 14112 } 14113 }; 14114 doAnimation.finish = doAnimation; 14115 14116 return empty || optall.queue === false ? 14117 this.each( doAnimation ) : 14118 this.queue( optall.queue, doAnimation ); 14119 }, 14120 stop: function( type, clearQueue, gotoEnd ) { 14121 var stopQueue = function( hooks ) { 14122 var stop = hooks.stop; 14123 delete hooks.stop; 14124 stop( gotoEnd ); 14125 }; 14126 14127 if ( typeof type !== "string" ) { 14128 gotoEnd = clearQueue; 14129 clearQueue = type; 14130 type = undefined; 14131 } 14132 if ( clearQueue ) { 14133 this.queue( type || "fx", [] ); 14134 } 14135 14136 return this.each( function() { 14137 var dequeue = true, 14138 index = type != null && type + "queueHooks", 14139 timers = jQuery.timers, 14140 data = dataPriv.get( this ); 14141 14142 if ( index ) { 14143 if ( data[ index ] && data[ index ].stop ) { 14144 stopQueue( data[ index ] ); 14145 } 14146 } else { 14147 for ( index in data ) { 14148 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { 14149 stopQueue( data[ index ] ); 14150 } 14151 } 14152 } 14153 14154 for ( index = timers.length; index--; ) { 14155 if ( timers[ index ].elem === this && 14156 ( type == null || timers[ index ].queue === type ) ) { 14157 14158 timers[ index ].anim.stop( gotoEnd ); 14159 dequeue = false; 14160 timers.splice( index, 1 ); 14161 } 14162 } 14163 14164 // Start the next in the queue if the last step wasn't forced. 14165 // Timers currently will call their complete callbacks, which 14166 // will dequeue but only if they were gotoEnd. 14167 if ( dequeue || !gotoEnd ) { 14168 jQuery.dequeue( this, type ); 14169 } 14170 } ); 14171 }, 14172 finish: function( type ) { 14173 if ( type !== false ) { 14174 type = type || "fx"; 14175 } 14176 return this.each( function() { 14177 var index, 14178 data = dataPriv.get( this ), 14179 queue = data[ type + "queue" ], 14180 hooks = data[ type + "queueHooks" ], 14181 timers = jQuery.timers, 14182 length = queue ? queue.length : 0; 14183 14184 // Enable finishing flag on private data 14185 data.finish = true; 14186 14187 // Empty the queue first 14188 jQuery.queue( this, type, [] ); 14189 14190 if ( hooks && hooks.stop ) { 14191 hooks.stop.call( this, true ); 14192 } 14193 14194 // Look for any active animations, and finish them 14195 for ( index = timers.length; index--; ) { 14196 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { 14197 timers[ index ].anim.stop( true ); 14198 timers.splice( index, 1 ); 14199 } 14200 } 14201 14202 // Look for any animations in the old queue and finish them 14203 for ( index = 0; index < length; index++ ) { 14204 if ( queue[ index ] && queue[ index ].finish ) { 14205 queue[ index ].finish.call( this ); 14206 } 14207 } 14208 14209 // Turn off finishing flag 14210 delete data.finish; 14211 } ); 14212 } 14213} ); 14214 14215jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) { 14216 var cssFn = jQuery.fn[ name ]; 14217 jQuery.fn[ name ] = function( speed, easing, callback ) { 14218 return speed == null || typeof speed === "boolean" ? 14219 cssFn.apply( this, arguments ) : 14220 this.animate( genFx( name, true ), speed, easing, callback ); 14221 }; 14222} ); 14223 14224// Generate shortcuts for custom animations 14225jQuery.each( { 14226 slideDown: genFx( "show" ), 14227 slideUp: genFx( "hide" ), 14228 slideToggle: genFx( "toggle" ), 14229 fadeIn: { opacity: "show" }, 14230 fadeOut: { opacity: "hide" }, 14231 fadeToggle: { opacity: "toggle" } 14232}, function( name, props ) { 14233 jQuery.fn[ name ] = function( speed, easing, callback ) { 14234 return this.animate( props, speed, easing, callback ); 14235 }; 14236} ); 14237 14238jQuery.timers = []; 14239jQuery.fx.tick = function() { 14240 var timer, 14241 i = 0, 14242 timers = jQuery.timers; 14243 14244 fxNow = Date.now(); 14245 14246 for ( ; i < timers.length; i++ ) { 14247 timer = timers[ i ]; 14248 14249 // Run the timer and safely remove it when done (allowing for external removal) 14250 if ( !timer() && timers[ i ] === timer ) { 14251 timers.splice( i--, 1 ); 14252 } 14253 } 14254 14255 if ( !timers.length ) { 14256 jQuery.fx.stop(); 14257 } 14258 fxNow = undefined; 14259}; 14260 14261jQuery.fx.timer = function( timer ) { 14262 jQuery.timers.push( timer ); 14263 jQuery.fx.start(); 14264}; 14265 14266jQuery.fx.interval = 13; 14267jQuery.fx.start = function() { 14268 if ( inProgress ) { 14269 return; 14270 } 14271 14272 inProgress = true; 14273 schedule(); 14274}; 14275 14276jQuery.fx.stop = function() { 14277 inProgress = null; 14278}; 14279 14280jQuery.fx.speeds = { 14281 slow: 600, 14282 fast: 200, 14283 14284 // Default speed 14285 _default: 400 14286}; 14287 14288 14289// Based off of the plugin by Clint Helfers, with permission. 14290// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ 14291jQuery.fn.delay = function( time, type ) { 14292 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; 14293 type = type || "fx"; 14294 14295 return this.queue( type, function( next, hooks ) { 14296 var timeout = window.setTimeout( next, time ); 14297 hooks.stop = function() { 14298 window.clearTimeout( timeout ); 14299 }; 14300 } ); 14301}; 14302 14303 14304( function() { 14305 var input = document.createElement( "input" ), 14306 select = document.createElement( "select" ), 14307 opt = select.appendChild( document.createElement( "option" ) ); 14308 14309 input.type = "checkbox"; 14310 14311 // Support: Android <=4.3 only 14312 // Default value for a checkbox should be "on" 14313 support.checkOn = input.value !== ""; 14314 14315 // Support: IE <=11 only 14316 // Must access selectedIndex to make default options select 14317 support.optSelected = opt.selected; 14318 14319 // Support: IE <=11 only 14320 // An input loses its value after becoming a radio 14321 input = document.createElement( "input" ); 14322 input.value = "t"; 14323 input.type = "radio"; 14324 support.radioValue = input.value === "t"; 14325} )(); 14326 14327 14328var boolHook, 14329 attrHandle = jQuery.expr.attrHandle; 14330 14331jQuery.fn.extend( { 14332 attr: function( name, value ) { 14333 return access( this, jQuery.attr, name, value, arguments.length > 1 ); 14334 }, 14335 14336 removeAttr: function( name ) { 14337 return this.each( function() { 14338 jQuery.removeAttr( this, name ); 14339 } ); 14340 } 14341} ); 14342 14343jQuery.extend( { 14344 attr: function( elem, name, value ) { 14345 var ret, hooks, 14346 nType = elem.nodeType; 14347 14348 // Don't get/set attributes on text, comment and attribute nodes 14349 if ( nType === 3 || nType === 8 || nType === 2 ) { 14350 return; 14351 } 14352 14353 // Fallback to prop when attributes are not supported 14354 if ( typeof elem.getAttribute === "undefined" ) { 14355 return jQuery.prop( elem, name, value ); 14356 } 14357 14358 // Attribute hooks are determined by the lowercase version 14359 // Grab necessary hook if one is defined 14360 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 14361 hooks = jQuery.attrHooks[ name.toLowerCase() ] || 14362 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); 14363 } 14364 14365 if ( value !== undefined ) { 14366 if ( value === null ) { 14367 jQuery.removeAttr( elem, name ); 14368 return; 14369 } 14370 14371 if ( hooks && "set" in hooks && 14372 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 14373 return ret; 14374 } 14375 14376 elem.setAttribute( name, value + "" ); 14377 return value; 14378 } 14379 14380 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 14381 return ret; 14382 } 14383 14384 ret = jQuery.find.attr( elem, name ); 14385 14386 // Non-existent attributes return null, we normalize to undefined 14387 return ret == null ? undefined : ret; 14388 }, 14389 14390 attrHooks: { 14391 type: { 14392 set: function( elem, value ) { 14393 if ( !support.radioValue && value === "radio" && 14394 nodeName( elem, "input" ) ) { 14395 var val = elem.value; 14396 elem.setAttribute( "type", value ); 14397 if ( val ) { 14398 elem.value = val; 14399 } 14400 return value; 14401 } 14402 } 14403 } 14404 }, 14405 14406 removeAttr: function( elem, value ) { 14407 var name, 14408 i = 0, 14409 14410 // Attribute names can contain non-HTML whitespace characters 14411 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 14412 attrNames = value && value.match( rnothtmlwhite ); 14413 14414 if ( attrNames && elem.nodeType === 1 ) { 14415 while ( ( name = attrNames[ i++ ] ) ) { 14416 elem.removeAttribute( name ); 14417 } 14418 } 14419 } 14420} ); 14421 14422// Hooks for boolean attributes 14423boolHook = { 14424 set: function( elem, value, name ) { 14425 if ( value === false ) { 14426 14427 // Remove boolean attributes when set to false 14428 jQuery.removeAttr( elem, name ); 14429 } else { 14430 elem.setAttribute( name, name ); 14431 } 14432 return name; 14433 } 14434}; 14435 14436jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) { 14437 var getter = attrHandle[ name ] || jQuery.find.attr; 14438 14439 attrHandle[ name ] = function( elem, name, isXML ) { 14440 var ret, handle, 14441 lowercaseName = name.toLowerCase(); 14442 14443 if ( !isXML ) { 14444 14445 // Avoid an infinite loop by temporarily removing this function from the getter 14446 handle = attrHandle[ lowercaseName ]; 14447 attrHandle[ lowercaseName ] = ret; 14448 ret = getter( elem, name, isXML ) != null ? 14449 lowercaseName : 14450 null; 14451 attrHandle[ lowercaseName ] = handle; 14452 } 14453 return ret; 14454 }; 14455} ); 14456 14457 14458 14459 14460var rfocusable = /^(?:input|select|textarea|button)$/i, 14461 rclickable = /^(?:a|area)$/i; 14462 14463jQuery.fn.extend( { 14464 prop: function( name, value ) { 14465 return access( this, jQuery.prop, name, value, arguments.length > 1 ); 14466 }, 14467 14468 removeProp: function( name ) { 14469 return this.each( function() { 14470 delete this[ jQuery.propFix[ name ] || name ]; 14471 } ); 14472 } 14473} ); 14474 14475jQuery.extend( { 14476 prop: function( elem, name, value ) { 14477 var ret, hooks, 14478 nType = elem.nodeType; 14479 14480 // Don't get/set properties on text, comment and attribute nodes 14481 if ( nType === 3 || nType === 8 || nType === 2 ) { 14482 return; 14483 } 14484 14485 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 14486 14487 // Fix name and attach hooks 14488 name = jQuery.propFix[ name ] || name; 14489 hooks = jQuery.propHooks[ name ]; 14490 } 14491 14492 if ( value !== undefined ) { 14493 if ( hooks && "set" in hooks && 14494 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 14495 return ret; 14496 } 14497 14498 return ( elem[ name ] = value ); 14499 } 14500 14501 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 14502 return ret; 14503 } 14504 14505 return elem[ name ]; 14506 }, 14507 14508 propHooks: { 14509 tabIndex: { 14510 get: function( elem ) { 14511 14512 // Support: IE <=9 - 11 only 14513 // elem.tabIndex doesn't always return the 14514 // correct value when it hasn't been explicitly set 14515 // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ 14516 // Use proper attribute retrieval(#12072) 14517 var tabindex = jQuery.find.attr( elem, "tabindex" ); 14518 14519 if ( tabindex ) { 14520 return parseInt( tabindex, 10 ); 14521 } 14522 14523 if ( 14524 rfocusable.test( elem.nodeName ) || 14525 rclickable.test( elem.nodeName ) && 14526 elem.href 14527 ) { 14528 return 0; 14529 } 14530 14531 return -1; 14532 } 14533 } 14534 }, 14535 14536 propFix: { 14537 "for": "htmlFor", 14538 "class": "className" 14539 } 14540} ); 14541 14542// Support: IE <=11 only 14543// Accessing the selectedIndex property 14544// forces the browser to respect setting selected 14545// on the option 14546// The getter ensures a default option is selected 14547// when in an optgroup 14548// eslint rule "no-unused-expressions" is disabled for this code 14549// since it considers such accessions noop 14550if ( !support.optSelected ) { 14551 jQuery.propHooks.selected = { 14552 get: function( elem ) { 14553 14554 /* eslint no-unused-expressions: "off" */ 14555 14556 var parent = elem.parentNode; 14557 if ( parent && parent.parentNode ) { 14558 parent.parentNode.selectedIndex; 14559 } 14560 return null; 14561 }, 14562 set: function( elem ) { 14563 14564 /* eslint no-unused-expressions: "off" */ 14565 14566 var parent = elem.parentNode; 14567 if ( parent ) { 14568 parent.selectedIndex; 14569 14570 if ( parent.parentNode ) { 14571 parent.parentNode.selectedIndex; 14572 } 14573 } 14574 } 14575 }; 14576} 14577 14578jQuery.each( [ 14579 "tabIndex", 14580 "readOnly", 14581 "maxLength", 14582 "cellSpacing", 14583 "cellPadding", 14584 "rowSpan", 14585 "colSpan", 14586 "useMap", 14587 "frameBorder", 14588 "contentEditable" 14589], function() { 14590 jQuery.propFix[ this.toLowerCase() ] = this; 14591} ); 14592 14593 14594 14595 14596 // Strip and collapse whitespace according to HTML spec 14597 // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace 14598 function stripAndCollapse( value ) { 14599 var tokens = value.match( rnothtmlwhite ) || []; 14600 return tokens.join( " " ); 14601 } 14602 14603 14604function getClass( elem ) { 14605 return elem.getAttribute && elem.getAttribute( "class" ) || ""; 14606} 14607 14608function classesToArray( value ) { 14609 if ( Array.isArray( value ) ) { 14610 return value; 14611 } 14612 if ( typeof value === "string" ) { 14613 return value.match( rnothtmlwhite ) || []; 14614 } 14615 return []; 14616} 14617 14618jQuery.fn.extend( { 14619 addClass: function( value ) { 14620 var classes, elem, cur, curValue, clazz, j, finalValue, 14621 i = 0; 14622 14623 if ( isFunction( value ) ) { 14624 return this.each( function( j ) { 14625 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); 14626 } ); 14627 } 14628 14629 classes = classesToArray( value ); 14630 14631 if ( classes.length ) { 14632 while ( ( elem = this[ i++ ] ) ) { 14633 curValue = getClass( elem ); 14634 cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); 14635 14636 if ( cur ) { 14637 j = 0; 14638 while ( ( clazz = classes[ j++ ] ) ) { 14639 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { 14640 cur += clazz + " "; 14641 } 14642 } 14643 14644 // Only assign if different to avoid unneeded rendering. 14645 finalValue = stripAndCollapse( cur ); 14646 if ( curValue !== finalValue ) { 14647 elem.setAttribute( "class", finalValue ); 14648 } 14649 } 14650 } 14651 } 14652 14653 return this; 14654 }, 14655 14656 removeClass: function( value ) { 14657 var classes, elem, cur, curValue, clazz, j, finalValue, 14658 i = 0; 14659 14660 if ( isFunction( value ) ) { 14661 return this.each( function( j ) { 14662 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); 14663 } ); 14664 } 14665 14666 if ( !arguments.length ) { 14667 return this.attr( "class", "" ); 14668 } 14669 14670 classes = classesToArray( value ); 14671 14672 if ( classes.length ) { 14673 while ( ( elem = this[ i++ ] ) ) { 14674 curValue = getClass( elem ); 14675 14676 // This expression is here for better compressibility (see addClass) 14677 cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); 14678 14679 if ( cur ) { 14680 j = 0; 14681 while ( ( clazz = classes[ j++ ] ) ) { 14682 14683 // Remove *all* instances 14684 while ( cur.indexOf( " " + clazz + " " ) > -1 ) { 14685 cur = cur.replace( " " + clazz + " ", " " ); 14686 } 14687 } 14688 14689 // Only assign if different to avoid unneeded rendering. 14690 finalValue = stripAndCollapse( cur ); 14691 if ( curValue !== finalValue ) { 14692 elem.setAttribute( "class", finalValue ); 14693 } 14694 } 14695 } 14696 } 14697 14698 return this; 14699 }, 14700 14701 toggleClass: function( value, stateVal ) { 14702 var type = typeof value, 14703 isValidValue = type === "string" || Array.isArray( value ); 14704 14705 if ( typeof stateVal === "boolean" && isValidValue ) { 14706 return stateVal ? this.addClass( value ) : this.removeClass( value ); 14707 } 14708 14709 if ( isFunction( value ) ) { 14710 return this.each( function( i ) { 14711 jQuery( this ).toggleClass( 14712 value.call( this, i, getClass( this ), stateVal ), 14713 stateVal 14714 ); 14715 } ); 14716 } 14717 14718 return this.each( function() { 14719 var className, i, self, classNames; 14720 14721 if ( isValidValue ) { 14722 14723 // Toggle individual class names 14724 i = 0; 14725 self = jQuery( this ); 14726 classNames = classesToArray( value ); 14727 14728 while ( ( className = classNames[ i++ ] ) ) { 14729 14730 // Check each className given, space separated list 14731 if ( self.hasClass( className ) ) { 14732 self.removeClass( className ); 14733 } else { 14734 self.addClass( className ); 14735 } 14736 } 14737 14738 // Toggle whole class name 14739 } else if ( value === undefined || type === "boolean" ) { 14740 className = getClass( this ); 14741 if ( className ) { 14742 14743 // Store className if set 14744 dataPriv.set( this, "__className__", className ); 14745 } 14746 14747 // If the element has a class name or if we're passed `false`, 14748 // then remove the whole classname (if there was one, the above saved it). 14749 // Otherwise bring back whatever was previously saved (if anything), 14750 // falling back to the empty string if nothing was stored. 14751 if ( this.setAttribute ) { 14752 this.setAttribute( "class", 14753 className || value === false ? 14754 "" : 14755 dataPriv.get( this, "__className__" ) || "" 14756 ); 14757 } 14758 } 14759 } ); 14760 }, 14761 14762 hasClass: function( selector ) { 14763 var className, elem, 14764 i = 0; 14765 14766 className = " " + selector + " "; 14767 while ( ( elem = this[ i++ ] ) ) { 14768 if ( elem.nodeType === 1 && 14769 ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { 14770 return true; 14771 } 14772 } 14773 14774 return false; 14775 } 14776} ); 14777 14778 14779 14780 14781var rreturn = /\r/g; 14782 14783jQuery.fn.extend( { 14784 val: function( value ) { 14785 var hooks, ret, valueIsFunction, 14786 elem = this[ 0 ]; 14787 14788 if ( !arguments.length ) { 14789 if ( elem ) { 14790 hooks = jQuery.valHooks[ elem.type ] || 14791 jQuery.valHooks[ elem.nodeName.toLowerCase() ]; 14792 14793 if ( hooks && 14794 "get" in hooks && 14795 ( ret = hooks.get( elem, "value" ) ) !== undefined 14796 ) { 14797 return ret; 14798 } 14799 14800 ret = elem.value; 14801 14802 // Handle most common string cases 14803 if ( typeof ret === "string" ) { 14804 return ret.replace( rreturn, "" ); 14805 } 14806 14807 // Handle cases where value is null/undef or number 14808 return ret == null ? "" : ret; 14809 } 14810 14811 return; 14812 } 14813 14814 valueIsFunction = isFunction( value ); 14815 14816 return this.each( function( i ) { 14817 var val; 14818 14819 if ( this.nodeType !== 1 ) { 14820 return; 14821 } 14822 14823 if ( valueIsFunction ) { 14824 val = value.call( this, i, jQuery( this ).val() ); 14825 } else { 14826 val = value; 14827 } 14828 14829 // Treat null/undefined as ""; convert numbers to string 14830 if ( val == null ) { 14831 val = ""; 14832 14833 } else if ( typeof val === "number" ) { 14834 val += ""; 14835 14836 } else if ( Array.isArray( val ) ) { 14837 val = jQuery.map( val, function( value ) { 14838 return value == null ? "" : value + ""; 14839 } ); 14840 } 14841 14842 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; 14843 14844 // If set returns undefined, fall back to normal setting 14845 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { 14846 this.value = val; 14847 } 14848 } ); 14849 } 14850} ); 14851 14852jQuery.extend( { 14853 valHooks: { 14854 option: { 14855 get: function( elem ) { 14856 14857 var val = jQuery.find.attr( elem, "value" ); 14858 return val != null ? 14859 val : 14860 14861 // Support: IE <=10 - 11 only 14862 // option.text throws exceptions (#14686, #14858) 14863 // Strip and collapse whitespace 14864 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace 14865 stripAndCollapse( jQuery.text( elem ) ); 14866 } 14867 }, 14868 select: { 14869 get: function( elem ) { 14870 var value, option, i, 14871 options = elem.options, 14872 index = elem.selectedIndex, 14873 one = elem.type === "select-one", 14874 values = one ? null : [], 14875 max = one ? index + 1 : options.length; 14876 14877 if ( index < 0 ) { 14878 i = max; 14879 14880 } else { 14881 i = one ? index : 0; 14882 } 14883 14884 // Loop through all the selected options 14885 for ( ; i < max; i++ ) { 14886 option = options[ i ]; 14887 14888 // Support: IE <=9 only 14889 // IE8-9 doesn't update selected after form reset (#2551) 14890 if ( ( option.selected || i === index ) && 14891 14892 // Don't return options that are disabled or in a disabled optgroup 14893 !option.disabled && 14894 ( !option.parentNode.disabled || 14895 !nodeName( option.parentNode, "optgroup" ) ) ) { 14896 14897 // Get the specific value for the option 14898 value = jQuery( option ).val(); 14899 14900 // We don't need an array for one selects 14901 if ( one ) { 14902 return value; 14903 } 14904 14905 // Multi-Selects return an array 14906 values.push( value ); 14907 } 14908 } 14909 14910 return values; 14911 }, 14912 14913 set: function( elem, value ) { 14914 var optionSet, option, 14915 options = elem.options, 14916 values = jQuery.makeArray( value ), 14917 i = options.length; 14918 14919 while ( i-- ) { 14920 option = options[ i ]; 14921 14922 /* eslint-disable no-cond-assign */ 14923 14924 if ( option.selected = 14925 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 14926 ) { 14927 optionSet = true; 14928 } 14929 14930 /* eslint-enable no-cond-assign */ 14931 } 14932 14933 // Force browsers to behave consistently when non-matching value is set 14934 if ( !optionSet ) { 14935 elem.selectedIndex = -1; 14936 } 14937 return values; 14938 } 14939 } 14940 } 14941} ); 14942 14943// Radios and checkboxes getter/setter 14944jQuery.each( [ "radio", "checkbox" ], function() { 14945 jQuery.valHooks[ this ] = { 14946 set: function( elem, value ) { 14947 if ( Array.isArray( value ) ) { 14948 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); 14949 } 14950 } 14951 }; 14952 if ( !support.checkOn ) { 14953 jQuery.valHooks[ this ].get = function( elem ) { 14954 return elem.getAttribute( "value" ) === null ? "on" : elem.value; 14955 }; 14956 } 14957} ); 14958 14959 14960 14961 14962// Return jQuery for attributes-only inclusion 14963 14964 14965support.focusin = "onfocusin" in window; 14966 14967 14968var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, 14969 stopPropagationCallback = function( e ) { 14970 e.stopPropagation(); 14971 }; 14972 14973jQuery.extend( jQuery.event, { 14974 14975 trigger: function( event, data, elem, onlyHandlers ) { 14976 14977 var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, 14978 eventPath = [ elem || document ], 14979 type = hasOwn.call( event, "type" ) ? event.type : event, 14980 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; 14981 14982 cur = lastElement = tmp = elem = elem || document; 14983 14984 // Don't do events on text and comment nodes 14985 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { 14986 return; 14987 } 14988 14989 // focus/blur morphs to focusin/out; ensure we're not firing them right now 14990 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { 14991 return; 14992 } 14993 14994 if ( type.indexOf( "." ) > -1 ) { 14995 14996 // Namespaced trigger; create a regexp to match event type in handle() 14997 namespaces = type.split( "." ); 14998 type = namespaces.shift(); 14999 namespaces.sort(); 15000 } 15001 ontype = type.indexOf( ":" ) < 0 && "on" + type; 15002 15003 // Caller can pass in a jQuery.Event object, Object, or just an event type string 15004 event = event[ jQuery.expando ] ? 15005 event : 15006 new jQuery.Event( type, typeof event === "object" && event ); 15007 15008 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) 15009 event.isTrigger = onlyHandlers ? 2 : 3; 15010 event.namespace = namespaces.join( "." ); 15011 event.rnamespace = event.namespace ? 15012 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : 15013 null; 15014 15015 // Clean up the event in case it is being reused 15016 event.result = undefined; 15017 if ( !event.target ) { 15018 event.target = elem; 15019 } 15020 15021 // Clone any incoming data and prepend the event, creating the handler arg list 15022 data = data == null ? 15023 [ event ] : 15024 jQuery.makeArray( data, [ event ] ); 15025 15026 // Allow special events to draw outside the lines 15027 special = jQuery.event.special[ type ] || {}; 15028 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { 15029 return; 15030 } 15031 15032 // Determine event propagation path in advance, per W3C events spec (#9951) 15033 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) 15034 if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { 15035 15036 bubbleType = special.delegateType || type; 15037 if ( !rfocusMorph.test( bubbleType + type ) ) { 15038 cur = cur.parentNode; 15039 } 15040 for ( ; cur; cur = cur.parentNode ) { 15041 eventPath.push( cur ); 15042 tmp = cur; 15043 } 15044 15045 // Only add window if we got to document (e.g., not plain obj or detached DOM) 15046 if ( tmp === ( elem.ownerDocument || document ) ) { 15047 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); 15048 } 15049 } 15050 15051 // Fire handlers on the event path 15052 i = 0; 15053 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { 15054 lastElement = cur; 15055 event.type = i > 1 ? 15056 bubbleType : 15057 special.bindType || type; 15058 15059 // jQuery handler 15060 handle = ( 15061 dataPriv.get( cur, "events" ) || Object.create( null ) 15062 )[ event.type ] && 15063 dataPriv.get( cur, "handle" ); 15064 if ( handle ) { 15065 handle.apply( cur, data ); 15066 } 15067 15068 // Native handler 15069 handle = ontype && cur[ ontype ]; 15070 if ( handle && handle.apply && acceptData( cur ) ) { 15071 event.result = handle.apply( cur, data ); 15072 if ( event.result === false ) { 15073 event.preventDefault(); 15074 } 15075 } 15076 } 15077 event.type = type; 15078 15079 // If nobody prevented the default action, do it now 15080 if ( !onlyHandlers && !event.isDefaultPrevented() ) { 15081 15082 if ( ( !special._default || 15083 special._default.apply( eventPath.pop(), data ) === false ) && 15084 acceptData( elem ) ) { 15085 15086 // Call a native DOM method on the target with the same name as the event. 15087 // Don't do default actions on window, that's where global variables be (#6170) 15088 if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { 15089 15090 // Don't re-trigger an onFOO event when we call its FOO() method 15091 tmp = elem[ ontype ]; 15092 15093 if ( tmp ) { 15094 elem[ ontype ] = null; 15095 } 15096 15097 // Prevent re-triggering of the same event, since we already bubbled it above 15098 jQuery.event.triggered = type; 15099 15100 if ( event.isPropagationStopped() ) { 15101 lastElement.addEventListener( type, stopPropagationCallback ); 15102 } 15103 15104 elem[ type ](); 15105 15106 if ( event.isPropagationStopped() ) { 15107 lastElement.removeEventListener( type, stopPropagationCallback ); 15108 } 15109 15110 jQuery.event.triggered = undefined; 15111 15112 if ( tmp ) { 15113 elem[ ontype ] = tmp; 15114 } 15115 } 15116 } 15117 } 15118 15119 return event.result; 15120 }, 15121 15122 // Piggyback on a donor event to simulate a different one 15123 // Used only for `focus(in | out)` events 15124 simulate: function( type, elem, event ) { 15125 var e = jQuery.extend( 15126 new jQuery.Event(), 15127 event, 15128 { 15129 type: type, 15130 isSimulated: true 15131 } 15132 ); 15133 15134 jQuery.event.trigger( e, null, elem ); 15135 } 15136 15137} ); 15138 15139jQuery.fn.extend( { 15140 15141 trigger: function( type, data ) { 15142 return this.each( function() { 15143 jQuery.event.trigger( type, data, this ); 15144 } ); 15145 }, 15146 triggerHandler: function( type, data ) { 15147 var elem = this[ 0 ]; 15148 if ( elem ) { 15149 return jQuery.event.trigger( type, data, elem, true ); 15150 } 15151 } 15152} ); 15153 15154 15155// Support: Firefox <=44 15156// Firefox doesn't have focus(in | out) events 15157// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 15158// 15159// Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 15160// focus(in | out) events fire after focus & blur events, 15161// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order 15162// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 15163if ( !support.focusin ) { 15164 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { 15165 15166 // Attach a single capturing handler on the document while someone wants focusin/focusout 15167 var handler = function( event ) { 15168 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); 15169 }; 15170 15171 jQuery.event.special[ fix ] = { 15172 setup: function() { 15173 15174 // Handle: regular nodes (via `this.ownerDocument`), window 15175 // (via `this.document`) & document (via `this`). 15176 var doc = this.ownerDocument || this.document || this, 15177 attaches = dataPriv.access( doc, fix ); 15178 15179 if ( !attaches ) { 15180 doc.addEventListener( orig, handler, true ); 15181 } 15182 dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); 15183 }, 15184 teardown: function() { 15185 var doc = this.ownerDocument || this.document || this, 15186 attaches = dataPriv.access( doc, fix ) - 1; 15187 15188 if ( !attaches ) { 15189 doc.removeEventListener( orig, handler, true ); 15190 dataPriv.remove( doc, fix ); 15191 15192 } else { 15193 dataPriv.access( doc, fix, attaches ); 15194 } 15195 } 15196 }; 15197 } ); 15198} 15199var location = window.location; 15200 15201var nonce = { guid: Date.now() }; 15202 15203var rquery = ( /\?/ ); 15204 15205 15206 15207// Cross-browser xml parsing 15208jQuery.parseXML = function( data ) { 15209 var xml; 15210 if ( !data || typeof data !== "string" ) { 15211 return null; 15212 } 15213 15214 // Support: IE 9 - 11 only 15215 // IE throws on parseFromString with invalid input. 15216 try { 15217 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); 15218 } catch ( e ) { 15219 xml = undefined; 15220 } 15221 15222 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { 15223 jQuery.error( "Invalid XML: " + data ); 15224 } 15225 return xml; 15226}; 15227 15228 15229var 15230 rbracket = /\[\]$/, 15231 rCRLF = /\r?\n/g, 15232 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, 15233 rsubmittable = /^(?:input|select|textarea|keygen)/i; 15234 15235function buildParams( prefix, obj, traditional, add ) { 15236 var name; 15237 15238 if ( Array.isArray( obj ) ) { 15239 15240 // Serialize array item. 15241 jQuery.each( obj, function( i, v ) { 15242 if ( traditional || rbracket.test( prefix ) ) { 15243 15244 // Treat each array item as a scalar. 15245 add( prefix, v ); 15246 15247 } else { 15248 15249 // Item is non-scalar (array or object), encode its numeric index. 15250 buildParams( 15251 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", 15252 v, 15253 traditional, 15254 add 15255 ); 15256 } 15257 } ); 15258 15259 } else if ( !traditional && toType( obj ) === "object" ) { 15260 15261 // Serialize object item. 15262 for ( name in obj ) { 15263 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); 15264 } 15265 15266 } else { 15267 15268 // Serialize scalar item. 15269 add( prefix, obj ); 15270 } 15271} 15272 15273// Serialize an array of form elements or a set of 15274// key/values into a query string 15275jQuery.param = function( a, traditional ) { 15276 var prefix, 15277 s = [], 15278 add = function( key, valueOrFunction ) { 15279 15280 // If value is a function, invoke it and use its return value 15281 var value = isFunction( valueOrFunction ) ? 15282 valueOrFunction() : 15283 valueOrFunction; 15284 15285 s[ s.length ] = encodeURIComponent( key ) + "=" + 15286 encodeURIComponent( value == null ? "" : value ); 15287 }; 15288 15289 if ( a == null ) { 15290 return ""; 15291 } 15292 15293 // If an array was passed in, assume that it is an array of form elements. 15294 if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { 15295 15296 // Serialize the form elements 15297 jQuery.each( a, function() { 15298 add( this.name, this.value ); 15299 } ); 15300 15301 } else { 15302 15303 // If traditional, encode the "old" way (the way 1.3.2 or older 15304 // did it), otherwise encode params recursively. 15305 for ( prefix in a ) { 15306 buildParams( prefix, a[ prefix ], traditional, add ); 15307 } 15308 } 15309 15310 // Return the resulting serialization 15311 return s.join( "&" ); 15312}; 15313 15314jQuery.fn.extend( { 15315 serialize: function() { 15316 return jQuery.param( this.serializeArray() ); 15317 }, 15318 serializeArray: function() { 15319 return this.map( function() { 15320 15321 // Can add propHook for "elements" to filter or add form elements 15322 var elements = jQuery.prop( this, "elements" ); 15323 return elements ? jQuery.makeArray( elements ) : this; 15324 } ) 15325 .filter( function() { 15326 var type = this.type; 15327 15328 // Use .is( ":disabled" ) so that fieldset[disabled] works 15329 return this.name && !jQuery( this ).is( ":disabled" ) && 15330 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && 15331 ( this.checked || !rcheckableType.test( type ) ); 15332 } ) 15333 .map( function( _i, elem ) { 15334 var val = jQuery( this ).val(); 15335 15336 if ( val == null ) { 15337 return null; 15338 } 15339 15340 if ( Array.isArray( val ) ) { 15341 return jQuery.map( val, function( val ) { 15342 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 15343 } ); 15344 } 15345 15346 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 15347 } ).get(); 15348 } 15349} ); 15350 15351 15352var 15353 r20 = /%20/g, 15354 rhash = /#.*$/, 15355 rantiCache = /([?&])_=[^&]*/, 15356 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, 15357 15358 // #7653, #8125, #8152: local protocol detection 15359 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, 15360 rnoContent = /^(?:GET|HEAD)$/, 15361 rprotocol = /^\/\//, 15362 15363 /* Prefilters 15364 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) 15365 * 2) These are called: 15366 * - BEFORE asking for a transport 15367 * - AFTER param serialization (s.data is a string if s.processData is true) 15368 * 3) key is the dataType 15369 * 4) the catchall symbol "*" can be used 15370 * 5) execution will start with transport dataType and THEN continue down to "*" if needed 15371 */ 15372 prefilters = {}, 15373 15374 /* Transports bindings 15375 * 1) key is the dataType 15376 * 2) the catchall symbol "*" can be used 15377 * 3) selection will start with transport dataType and THEN go to "*" if needed 15378 */ 15379 transports = {}, 15380 15381 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression 15382 allTypes = "*/".concat( "*" ), 15383 15384 // Anchor tag for parsing the document origin 15385 originAnchor = document.createElement( "a" ); 15386 originAnchor.href = location.href; 15387 15388// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport 15389function addToPrefiltersOrTransports( structure ) { 15390 15391 // dataTypeExpression is optional and defaults to "*" 15392 return function( dataTypeExpression, func ) { 15393 15394 if ( typeof dataTypeExpression !== "string" ) { 15395 func = dataTypeExpression; 15396 dataTypeExpression = "*"; 15397 } 15398 15399 var dataType, 15400 i = 0, 15401 dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || []; 15402 15403 if ( isFunction( func ) ) { 15404 15405 // For each dataType in the dataTypeExpression 15406 while ( ( dataType = dataTypes[ i++ ] ) ) { 15407 15408 // Prepend if requested 15409 if ( dataType[ 0 ] === "+" ) { 15410 dataType = dataType.slice( 1 ) || "*"; 15411 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); 15412 15413 // Otherwise append 15414 } else { 15415 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); 15416 } 15417 } 15418 } 15419 }; 15420} 15421 15422// Base inspection function for prefilters and transports 15423function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { 15424 15425 var inspected = {}, 15426 seekingTransport = ( structure === transports ); 15427 15428 function inspect( dataType ) { 15429 var selected; 15430 inspected[ dataType ] = true; 15431 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { 15432 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); 15433 if ( typeof dataTypeOrTransport === "string" && 15434 !seekingTransport && !inspected[ dataTypeOrTransport ] ) { 15435 15436 options.dataTypes.unshift( dataTypeOrTransport ); 15437 inspect( dataTypeOrTransport ); 15438 return false; 15439 } else if ( seekingTransport ) { 15440 return !( selected = dataTypeOrTransport ); 15441 } 15442 } ); 15443 return selected; 15444 } 15445 15446 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); 15447} 15448 15449// A special extend for ajax options 15450// that takes "flat" options (not to be deep extended) 15451// Fixes #9887 15452function ajaxExtend( target, src ) { 15453 var key, deep, 15454 flatOptions = jQuery.ajaxSettings.flatOptions || {}; 15455 15456 for ( key in src ) { 15457 if ( src[ key ] !== undefined ) { 15458 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; 15459 } 15460 } 15461 if ( deep ) { 15462 jQuery.extend( true, target, deep ); 15463 } 15464 15465 return target; 15466} 15467 15468/* Handles responses to an ajax request: 15469 * - finds the right dataType (mediates between content-type and expected dataType) 15470 * - returns the corresponding response 15471 */ 15472function ajaxHandleResponses( s, jqXHR, responses ) { 15473 15474 var ct, type, finalDataType, firstDataType, 15475 contents = s.contents, 15476 dataTypes = s.dataTypes; 15477 15478 // Remove auto dataType and get content-type in the process 15479 while ( dataTypes[ 0 ] === "*" ) { 15480 dataTypes.shift(); 15481 if ( ct === undefined ) { 15482 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); 15483 } 15484 } 15485 15486 // Check if we're dealing with a known content-type 15487 if ( ct ) { 15488 for ( type in contents ) { 15489 if ( contents[ type ] && contents[ type ].test( ct ) ) { 15490 dataTypes.unshift( type ); 15491 break; 15492 } 15493 } 15494 } 15495 15496 // Check to see if we have a response for the expected dataType 15497 if ( dataTypes[ 0 ] in responses ) { 15498 finalDataType = dataTypes[ 0 ]; 15499 } else { 15500 15501 // Try convertible dataTypes 15502 for ( type in responses ) { 15503 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { 15504 finalDataType = type; 15505 break; 15506 } 15507 if ( !firstDataType ) { 15508 firstDataType = type; 15509 } 15510 } 15511 15512 // Or just use first one 15513 finalDataType = finalDataType || firstDataType; 15514 } 15515 15516 // If we found a dataType 15517 // We add the dataType to the list if needed 15518 // and return the corresponding response 15519 if ( finalDataType ) { 15520 if ( finalDataType !== dataTypes[ 0 ] ) { 15521 dataTypes.unshift( finalDataType ); 15522 } 15523 return responses[ finalDataType ]; 15524 } 15525} 15526 15527/* Chain conversions given the request and the original response 15528 * Also sets the responseXXX fields on the jqXHR instance 15529 */ 15530function ajaxConvert( s, response, jqXHR, isSuccess ) { 15531 var conv2, current, conv, tmp, prev, 15532 converters = {}, 15533 15534 // Work with a copy of dataTypes in case we need to modify it for conversion 15535 dataTypes = s.dataTypes.slice(); 15536 15537 // Create converters map with lowercased keys 15538 if ( dataTypes[ 1 ] ) { 15539 for ( conv in s.converters ) { 15540 converters[ conv.toLowerCase() ] = s.converters[ conv ]; 15541 } 15542 } 15543 15544 current = dataTypes.shift(); 15545 15546 // Convert to each sequential dataType 15547 while ( current ) { 15548 15549 if ( s.responseFields[ current ] ) { 15550 jqXHR[ s.responseFields[ current ] ] = response; 15551 } 15552 15553 // Apply the dataFilter if provided 15554 if ( !prev && isSuccess && s.dataFilter ) { 15555 response = s.dataFilter( response, s.dataType ); 15556 } 15557 15558 prev = current; 15559 current = dataTypes.shift(); 15560 15561 if ( current ) { 15562 15563 // There's only work to do if current dataType is non-auto 15564 if ( current === "*" ) { 15565 15566 current = prev; 15567 15568 // Convert response if prev dataType is non-auto and differs from current 15569 } else if ( prev !== "*" && prev !== current ) { 15570 15571 // Seek a direct converter 15572 conv = converters[ prev + " " + current ] || converters[ "* " + current ]; 15573 15574 // If none found, seek a pair 15575 if ( !conv ) { 15576 for ( conv2 in converters ) { 15577 15578 // If conv2 outputs current 15579 tmp = conv2.split( " " ); 15580 if ( tmp[ 1 ] === current ) { 15581 15582 // If prev can be converted to accepted input 15583 conv = converters[ prev + " " + tmp[ 0 ] ] || 15584 converters[ "* " + tmp[ 0 ] ]; 15585 if ( conv ) { 15586 15587 // Condense equivalence converters 15588 if ( conv === true ) { 15589 conv = converters[ conv2 ]; 15590 15591 // Otherwise, insert the intermediate dataType 15592 } else if ( converters[ conv2 ] !== true ) { 15593 current = tmp[ 0 ]; 15594 dataTypes.unshift( tmp[ 1 ] ); 15595 } 15596 break; 15597 } 15598 } 15599 } 15600 } 15601 15602 // Apply converter (if not an equivalence) 15603 if ( conv !== true ) { 15604 15605 // Unless errors are allowed to bubble, catch and return them 15606 if ( conv && s.throws ) { 15607 response = conv( response ); 15608 } else { 15609 try { 15610 response = conv( response ); 15611 } catch ( e ) { 15612 return { 15613 state: "parsererror", 15614 error: conv ? e : "No conversion from " + prev + " to " + current 15615 }; 15616 } 15617 } 15618 } 15619 } 15620 } 15621 } 15622 15623 return { state: "success", data: response }; 15624} 15625 15626jQuery.extend( { 15627 15628 // Counter for holding the number of active queries 15629 active: 0, 15630 15631 // Last-Modified header cache for next request 15632 lastModified: {}, 15633 etag: {}, 15634 15635 ajaxSettings: { 15636 url: location.href, 15637 type: "GET", 15638 isLocal: rlocalProtocol.test( location.protocol ), 15639 global: true, 15640 processData: true, 15641 async: true, 15642 contentType: "application/x-www-form-urlencoded; charset=UTF-8", 15643 15644 /* 15645 timeout: 0, 15646 data: null, 15647 dataType: null, 15648 username: null, 15649 password: null, 15650 cache: null, 15651 throws: false, 15652 traditional: false, 15653 headers: {}, 15654 */ 15655 15656 accepts: { 15657 "*": allTypes, 15658 text: "text/plain", 15659 html: "text/html", 15660 xml: "application/xml, text/xml", 15661 json: "application/json, text/javascript" 15662 }, 15663 15664 contents: { 15665 xml: /\bxml\b/, 15666 html: /\bhtml/, 15667 json: /\bjson\b/ 15668 }, 15669 15670 responseFields: { 15671 xml: "responseXML", 15672 text: "responseText", 15673 json: "responseJSON" 15674 }, 15675 15676 // Data converters 15677 // Keys separate source (or catchall "*") and destination types with a single space 15678 converters: { 15679 15680 // Convert anything to text 15681 "* text": String, 15682 15683 // Text to html (true = no transformation) 15684 "text html": true, 15685 15686 // Evaluate text as a json expression 15687 "text json": JSON.parse, 15688 15689 // Parse text as xml 15690 "text xml": jQuery.parseXML 15691 }, 15692 15693 // For options that shouldn't be deep extended: 15694 // you can add your own custom options here if 15695 // and when you create one that shouldn't be 15696 // deep extended (see ajaxExtend) 15697 flatOptions: { 15698 url: true, 15699 context: true 15700 } 15701 }, 15702 15703 // Creates a full fledged settings object into target 15704 // with both ajaxSettings and settings fields. 15705 // If target is omitted, writes into ajaxSettings. 15706 ajaxSetup: function( target, settings ) { 15707 return settings ? 15708 15709 // Building a settings object 15710 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : 15711 15712 // Extending ajaxSettings 15713 ajaxExtend( jQuery.ajaxSettings, target ); 15714 }, 15715 15716 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), 15717 ajaxTransport: addToPrefiltersOrTransports( transports ), 15718 15719 // Main method 15720 ajax: function( url, options ) { 15721 15722 // If url is an object, simulate pre-1.5 signature 15723 if ( typeof url === "object" ) { 15724 options = url; 15725 url = undefined; 15726 } 15727 15728 // Force options to be an object 15729 options = options || {}; 15730 15731 var transport, 15732 15733 // URL without anti-cache param 15734 cacheURL, 15735 15736 // Response headers 15737 responseHeadersString, 15738 responseHeaders, 15739 15740 // timeout handle 15741 timeoutTimer, 15742 15743 // Url cleanup var 15744 urlAnchor, 15745 15746 // Request state (becomes false upon send and true upon completion) 15747 completed, 15748 15749 // To know if global events are to be dispatched 15750 fireGlobals, 15751 15752 // Loop variable 15753 i, 15754 15755 // uncached part of the url 15756 uncached, 15757 15758 // Create the final options object 15759 s = jQuery.ajaxSetup( {}, options ), 15760 15761 // Callbacks context 15762 callbackContext = s.context || s, 15763 15764 // Context for global events is callbackContext if it is a DOM node or jQuery collection 15765 globalEventContext = s.context && 15766 ( callbackContext.nodeType || callbackContext.jquery ) ? 15767 jQuery( callbackContext ) : 15768 jQuery.event, 15769 15770 // Deferreds 15771 deferred = jQuery.Deferred(), 15772 completeDeferred = jQuery.Callbacks( "once memory" ), 15773 15774 // Status-dependent callbacks 15775 statusCode = s.statusCode || {}, 15776 15777 // Headers (they are sent all at once) 15778 requestHeaders = {}, 15779 requestHeadersNames = {}, 15780 15781 // Default abort message 15782 strAbort = "canceled", 15783 15784 // Fake xhr 15785 jqXHR = { 15786 readyState: 0, 15787 15788 // Builds headers hashtable if needed 15789 getResponseHeader: function( key ) { 15790 var match; 15791 if ( completed ) { 15792 if ( !responseHeaders ) { 15793 responseHeaders = {}; 15794 while ( ( match = rheaders.exec( responseHeadersString ) ) ) { 15795 responseHeaders[ match[ 1 ].toLowerCase() + " " ] = 15796 ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) 15797 .concat( match[ 2 ] ); 15798 } 15799 } 15800 match = responseHeaders[ key.toLowerCase() + " " ]; 15801 } 15802 return match == null ? null : match.join( ", " ); 15803 }, 15804 15805 // Raw string 15806 getAllResponseHeaders: function() { 15807 return completed ? responseHeadersString : null; 15808 }, 15809 15810 // Caches the header 15811 setRequestHeader: function( name, value ) { 15812 if ( completed == null ) { 15813 name = requestHeadersNames[ name.toLowerCase() ] = 15814 requestHeadersNames[ name.toLowerCase() ] || name; 15815 requestHeaders[ name ] = value; 15816 } 15817 return this; 15818 }, 15819 15820 // Overrides response content-type header 15821 overrideMimeType: function( type ) { 15822 if ( completed == null ) { 15823 s.mimeType = type; 15824 } 15825 return this; 15826 }, 15827 15828 // Status-dependent callbacks 15829 statusCode: function( map ) { 15830 var code; 15831 if ( map ) { 15832 if ( completed ) { 15833 15834 // Execute the appropriate callbacks 15835 jqXHR.always( map[ jqXHR.status ] ); 15836 } else { 15837 15838 // Lazy-add the new callbacks in a way that preserves old ones 15839 for ( code in map ) { 15840 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; 15841 } 15842 } 15843 } 15844 return this; 15845 }, 15846 15847 // Cancel the request 15848 abort: function( statusText ) { 15849 var finalText = statusText || strAbort; 15850 if ( transport ) { 15851 transport.abort( finalText ); 15852 } 15853 done( 0, finalText ); 15854 return this; 15855 } 15856 }; 15857 15858 // Attach deferreds 15859 deferred.promise( jqXHR ); 15860 15861 // Add protocol if not provided (prefilters might expect it) 15862 // Handle falsy url in the settings object (#10093: consistency with old signature) 15863 // We also use the url parameter if available 15864 s.url = ( ( url || s.url || location.href ) + "" ) 15865 .replace( rprotocol, location.protocol + "//" ); 15866 15867 // Alias method option to type as per ticket #12004 15868 s.type = options.method || options.type || s.method || s.type; 15869 15870 // Extract dataTypes list 15871 s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ]; 15872 15873 // A cross-domain request is in order when the origin doesn't match the current origin. 15874 if ( s.crossDomain == null ) { 15875 urlAnchor = document.createElement( "a" ); 15876 15877 // Support: IE <=8 - 11, Edge 12 - 15 15878 // IE throws exception on accessing the href property if url is malformed, 15879 // e.g. http://example.com:80x/ 15880 try { 15881 urlAnchor.href = s.url; 15882 15883 // Support: IE <=8 - 11 only 15884 // Anchor's host property isn't correctly set when s.url is relative 15885 urlAnchor.href = urlAnchor.href; 15886 s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== 15887 urlAnchor.protocol + "//" + urlAnchor.host; 15888 } catch ( e ) { 15889 15890 // If there is an error parsing the URL, assume it is crossDomain, 15891 // it can be rejected by the transport if it is invalid 15892 s.crossDomain = true; 15893 } 15894 } 15895 15896 // Convert data if not already a string 15897 if ( s.data && s.processData && typeof s.data !== "string" ) { 15898 s.data = jQuery.param( s.data, s.traditional ); 15899 } 15900 15901 // Apply prefilters 15902 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); 15903 15904 // If request was aborted inside a prefilter, stop there 15905 if ( completed ) { 15906 return jqXHR; 15907 } 15908 15909 // We can fire global events as of now if asked to 15910 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) 15911 fireGlobals = jQuery.event && s.global; 15912 15913 // Watch for a new set of requests 15914 if ( fireGlobals && jQuery.active++ === 0 ) { 15915 jQuery.event.trigger( "ajaxStart" ); 15916 } 15917 15918 // Uppercase the type 15919 s.type = s.type.toUpperCase(); 15920 15921 // Determine if request has content 15922 s.hasContent = !rnoContent.test( s.type ); 15923 15924 // Save the URL in case we're toying with the If-Modified-Since 15925 // and/or If-None-Match header later on 15926 // Remove hash to simplify url manipulation 15927 cacheURL = s.url.replace( rhash, "" ); 15928 15929 // More options handling for requests with no content 15930 if ( !s.hasContent ) { 15931 15932 // Remember the hash so we can put it back 15933 uncached = s.url.slice( cacheURL.length ); 15934 15935 // If data is available and should be processed, append data to url 15936 if ( s.data && ( s.processData || typeof s.data === "string" ) ) { 15937 cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; 15938 15939 // #9682: remove data so that it's not used in an eventual retry 15940 delete s.data; 15941 } 15942 15943 // Add or update anti-cache param if needed 15944 if ( s.cache === false ) { 15945 cacheURL = cacheURL.replace( rantiCache, "$1" ); 15946 uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) + 15947 uncached; 15948 } 15949 15950 // Put hash and anti-cache on the URL that will be requested (gh-1732) 15951 s.url = cacheURL + uncached; 15952 15953 // Change '%20' to '+' if this is encoded form body content (gh-2658) 15954 } else if ( s.data && s.processData && 15955 ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) { 15956 s.data = s.data.replace( r20, "+" ); 15957 } 15958 15959 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 15960 if ( s.ifModified ) { 15961 if ( jQuery.lastModified[ cacheURL ] ) { 15962 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); 15963 } 15964 if ( jQuery.etag[ cacheURL ] ) { 15965 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); 15966 } 15967 } 15968 15969 // Set the correct header, if data is being sent 15970 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { 15971 jqXHR.setRequestHeader( "Content-Type", s.contentType ); 15972 } 15973 15974 // Set the Accepts header for the server, depending on the dataType 15975 jqXHR.setRequestHeader( 15976 "Accept", 15977 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? 15978 s.accepts[ s.dataTypes[ 0 ] ] + 15979 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : 15980 s.accepts[ "*" ] 15981 ); 15982 15983 // Check for headers option 15984 for ( i in s.headers ) { 15985 jqXHR.setRequestHeader( i, s.headers[ i ] ); 15986 } 15987 15988 // Allow custom headers/mimetypes and early abort 15989 if ( s.beforeSend && 15990 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) { 15991 15992 // Abort if not done already and return 15993 return jqXHR.abort(); 15994 } 15995 15996 // Aborting is no longer a cancellation 15997 strAbort = "abort"; 15998 15999 // Install callbacks on deferreds 16000 completeDeferred.add( s.complete ); 16001 jqXHR.done( s.success ); 16002 jqXHR.fail( s.error ); 16003 16004 // Get transport 16005 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); 16006 16007 // If no transport, we auto-abort 16008 if ( !transport ) { 16009 done( -1, "No Transport" ); 16010 } else { 16011 jqXHR.readyState = 1; 16012 16013 // Send global event 16014 if ( fireGlobals ) { 16015 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); 16016 } 16017 16018 // If request was aborted inside ajaxSend, stop there 16019 if ( completed ) { 16020 return jqXHR; 16021 } 16022 16023 // Timeout 16024 if ( s.async && s.timeout > 0 ) { 16025 timeoutTimer = window.setTimeout( function() { 16026 jqXHR.abort( "timeout" ); 16027 }, s.timeout ); 16028 } 16029 16030 try { 16031 completed = false; 16032 transport.send( requestHeaders, done ); 16033 } catch ( e ) { 16034 16035 // Rethrow post-completion exceptions 16036 if ( completed ) { 16037 throw e; 16038 } 16039 16040 // Propagate others as results 16041 done( -1, e ); 16042 } 16043 } 16044 16045 // Callback for when everything is done 16046 function done( status, nativeStatusText, responses, headers ) { 16047 var isSuccess, success, error, response, modified, 16048 statusText = nativeStatusText; 16049 16050 // Ignore repeat invocations 16051 if ( completed ) { 16052 return; 16053 } 16054 16055 completed = true; 16056 16057 // Clear timeout if it exists 16058 if ( timeoutTimer ) { 16059 window.clearTimeout( timeoutTimer ); 16060 } 16061 16062 // Dereference transport for early garbage collection 16063 // (no matter how long the jqXHR object will be used) 16064 transport = undefined; 16065 16066 // Cache response headers 16067 responseHeadersString = headers || ""; 16068 16069 // Set readyState 16070 jqXHR.readyState = status > 0 ? 4 : 0; 16071 16072 // Determine if successful 16073 isSuccess = status >= 200 && status < 300 || status === 304; 16074 16075 // Get response data 16076 if ( responses ) { 16077 response = ajaxHandleResponses( s, jqXHR, responses ); 16078 } 16079 16080 // Use a noop converter for missing script 16081 if ( !isSuccess && jQuery.inArray( "script", s.dataTypes ) > -1 ) { 16082 s.converters[ "text script" ] = function() {}; 16083 } 16084 16085 // Convert no matter what (that way responseXXX fields are always set) 16086 response = ajaxConvert( s, response, jqXHR, isSuccess ); 16087 16088 // If successful, handle type chaining 16089 if ( isSuccess ) { 16090 16091 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 16092 if ( s.ifModified ) { 16093 modified = jqXHR.getResponseHeader( "Last-Modified" ); 16094 if ( modified ) { 16095 jQuery.lastModified[ cacheURL ] = modified; 16096 } 16097 modified = jqXHR.getResponseHeader( "etag" ); 16098 if ( modified ) { 16099 jQuery.etag[ cacheURL ] = modified; 16100 } 16101 } 16102 16103 // if no content 16104 if ( status === 204 || s.type === "HEAD" ) { 16105 statusText = "nocontent"; 16106 16107 // if not modified 16108 } else if ( status === 304 ) { 16109 statusText = "notmodified"; 16110 16111 // If we have data, let's convert it 16112 } else { 16113 statusText = response.state; 16114 success = response.data; 16115 error = response.error; 16116 isSuccess = !error; 16117 } 16118 } else { 16119 16120 // Extract error from statusText and normalize for non-aborts 16121 error = statusText; 16122 if ( status || !statusText ) { 16123 statusText = "error"; 16124 if ( status < 0 ) { 16125 status = 0; 16126 } 16127 } 16128 } 16129 16130 // Set data for the fake xhr object 16131 jqXHR.status = status; 16132 jqXHR.statusText = ( nativeStatusText || statusText ) + ""; 16133 16134 // Success/Error 16135 if ( isSuccess ) { 16136 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); 16137 } else { 16138 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); 16139 } 16140 16141 // Status-dependent callbacks 16142 jqXHR.statusCode( statusCode ); 16143 statusCode = undefined; 16144 16145 if ( fireGlobals ) { 16146 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", 16147 [ jqXHR, s, isSuccess ? success : error ] ); 16148 } 16149 16150 // Complete 16151 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); 16152 16153 if ( fireGlobals ) { 16154 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); 16155 16156 // Handle the global AJAX counter 16157 if ( !( --jQuery.active ) ) { 16158 jQuery.event.trigger( "ajaxStop" ); 16159 } 16160 } 16161 } 16162 16163 return jqXHR; 16164 }, 16165 16166 getJSON: function( url, data, callback ) { 16167 return jQuery.get( url, data, callback, "json" ); 16168 }, 16169 16170 getScript: function( url, callback ) { 16171 return jQuery.get( url, undefined, callback, "script" ); 16172 } 16173} ); 16174 16175jQuery.each( [ "get", "post" ], function( _i, method ) { 16176 jQuery[ method ] = function( url, data, callback, type ) { 16177 16178 // Shift arguments if data argument was omitted 16179 if ( isFunction( data ) ) { 16180 type = type || callback; 16181 callback = data; 16182 data = undefined; 16183 } 16184 16185 // The url can be an options object (which then must have .url) 16186 return jQuery.ajax( jQuery.extend( { 16187 url: url, 16188 type: method, 16189 dataType: type, 16190 data: data, 16191 success: callback 16192 }, jQuery.isPlainObject( url ) && url ) ); 16193 }; 16194} ); 16195 16196jQuery.ajaxPrefilter( function( s ) { 16197 var i; 16198 for ( i in s.headers ) { 16199 if ( i.toLowerCase() === "content-type" ) { 16200 s.contentType = s.headers[ i ] || ""; 16201 } 16202 } 16203} ); 16204 16205 16206jQuery._evalUrl = function( url, options, doc ) { 16207 return jQuery.ajax( { 16208 url: url, 16209 16210 // Make this explicit, since user can override this through ajaxSetup (#11264) 16211 type: "GET", 16212 dataType: "script", 16213 cache: true, 16214 async: false, 16215 global: false, 16216 16217 // Only evaluate the response if it is successful (gh-4126) 16218 // dataFilter is not invoked for failure responses, so using it instead 16219 // of the default converter is kludgy but it works. 16220 converters: { 16221 "text script": function() {} 16222 }, 16223 dataFilter: function( response ) { 16224 jQuery.globalEval( response, options, doc ); 16225 } 16226 } ); 16227}; 16228 16229 16230jQuery.fn.extend( { 16231 wrapAll: function( html ) { 16232 var wrap; 16233 16234 if ( this[ 0 ] ) { 16235 if ( isFunction( html ) ) { 16236 html = html.call( this[ 0 ] ); 16237 } 16238 16239 // The elements to wrap the target around 16240 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); 16241 16242 if ( this[ 0 ].parentNode ) { 16243 wrap.insertBefore( this[ 0 ] ); 16244 } 16245 16246 wrap.map( function() { 16247 var elem = this; 16248 16249 while ( elem.firstElementChild ) { 16250 elem = elem.firstElementChild; 16251 } 16252 16253 return elem; 16254 } ).append( this ); 16255 } 16256 16257 return this; 16258 }, 16259 16260 wrapInner: function( html ) { 16261 if ( isFunction( html ) ) { 16262 return this.each( function( i ) { 16263 jQuery( this ).wrapInner( html.call( this, i ) ); 16264 } ); 16265 } 16266 16267 return this.each( function() { 16268 var self = jQuery( this ), 16269 contents = self.contents(); 16270 16271 if ( contents.length ) { 16272 contents.wrapAll( html ); 16273 16274 } else { 16275 self.append( html ); 16276 } 16277 } ); 16278 }, 16279 16280 wrap: function( html ) { 16281 var htmlIsFunction = isFunction( html ); 16282 16283 return this.each( function( i ) { 16284 jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html ); 16285 } ); 16286 }, 16287 16288 unwrap: function( selector ) { 16289 this.parent( selector ).not( "body" ).each( function() { 16290 jQuery( this ).replaceWith( this.childNodes ); 16291 } ); 16292 return this; 16293 } 16294} ); 16295 16296 16297jQuery.expr.pseudos.hidden = function( elem ) { 16298 return !jQuery.expr.pseudos.visible( elem ); 16299}; 16300jQuery.expr.pseudos.visible = function( elem ) { 16301 return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); 16302}; 16303 16304 16305 16306 16307jQuery.ajaxSettings.xhr = function() { 16308 try { 16309 return new window.XMLHttpRequest(); 16310 } catch ( e ) {} 16311}; 16312 16313var xhrSuccessStatus = { 16314 16315 // File protocol always yields status code 0, assume 200 16316 0: 200, 16317 16318 // Support: IE <=9 only 16319 // #1450: sometimes IE returns 1223 when it should be 204 16320 1223: 204 16321 }, 16322 xhrSupported = jQuery.ajaxSettings.xhr(); 16323 16324support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); 16325support.ajax = xhrSupported = !!xhrSupported; 16326 16327jQuery.ajaxTransport( function( options ) { 16328 var callback, errorCallback; 16329 16330 // Cross domain only allowed if supported through XMLHttpRequest 16331 if ( support.cors || xhrSupported && !options.crossDomain ) { 16332 return { 16333 send: function( headers, complete ) { 16334 var i, 16335 xhr = options.xhr(); 16336 16337 xhr.open( 16338 options.type, 16339 options.url, 16340 options.async, 16341 options.username, 16342 options.password 16343 ); 16344 16345 // Apply custom fields if provided 16346 if ( options.xhrFields ) { 16347 for ( i in options.xhrFields ) { 16348 xhr[ i ] = options.xhrFields[ i ]; 16349 } 16350 } 16351 16352 // Override mime type if needed 16353 if ( options.mimeType && xhr.overrideMimeType ) { 16354 xhr.overrideMimeType( options.mimeType ); 16355 } 16356 16357 // X-Requested-With header 16358 // For cross-domain requests, seeing as conditions for a preflight are 16359 // akin to a jigsaw puzzle, we simply never set it to be sure. 16360 // (it can always be set on a per-request basis or even using ajaxSetup) 16361 // For same-domain requests, won't change header if already provided. 16362 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { 16363 headers[ "X-Requested-With" ] = "XMLHttpRequest"; 16364 } 16365 16366 // Set headers 16367 for ( i in headers ) { 16368 xhr.setRequestHeader( i, headers[ i ] ); 16369 } 16370 16371 // Callback 16372 callback = function( type ) { 16373 return function() { 16374 if ( callback ) { 16375 callback = errorCallback = xhr.onload = 16376 xhr.onerror = xhr.onabort = xhr.ontimeout = 16377 xhr.onreadystatechange = null; 16378 16379 if ( type === "abort" ) { 16380 xhr.abort(); 16381 } else if ( type === "error" ) { 16382 16383 // Support: IE <=9 only 16384 // On a manual native abort, IE9 throws 16385 // errors on any property access that is not readyState 16386 if ( typeof xhr.status !== "number" ) { 16387 complete( 0, "error" ); 16388 } else { 16389 complete( 16390 16391 // File: protocol always yields status 0; see #8605, #14207 16392 xhr.status, 16393 xhr.statusText 16394 ); 16395 } 16396 } else { 16397 complete( 16398 xhrSuccessStatus[ xhr.status ] || xhr.status, 16399 xhr.statusText, 16400 16401 // Support: IE <=9 only 16402 // IE9 has no XHR2 but throws on binary (trac-11426) 16403 // For XHR2 non-text, let the caller handle it (gh-2498) 16404 ( xhr.responseType || "text" ) !== "text" || 16405 typeof xhr.responseText !== "string" ? 16406 { binary: xhr.response } : 16407 { text: xhr.responseText }, 16408 xhr.getAllResponseHeaders() 16409 ); 16410 } 16411 } 16412 }; 16413 }; 16414 16415 // Listen to events 16416 xhr.onload = callback(); 16417 errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" ); 16418 16419 // Support: IE 9 only 16420 // Use onreadystatechange to replace onabort 16421 // to handle uncaught aborts 16422 if ( xhr.onabort !== undefined ) { 16423 xhr.onabort = errorCallback; 16424 } else { 16425 xhr.onreadystatechange = function() { 16426 16427 // Check readyState before timeout as it changes 16428 if ( xhr.readyState === 4 ) { 16429 16430 // Allow onerror to be called first, 16431 // but that will not handle a native abort 16432 // Also, save errorCallback to a variable 16433 // as xhr.onerror cannot be accessed 16434 window.setTimeout( function() { 16435 if ( callback ) { 16436 errorCallback(); 16437 } 16438 } ); 16439 } 16440 }; 16441 } 16442 16443 // Create the abort callback 16444 callback = callback( "abort" ); 16445 16446 try { 16447 16448 // Do send the request (this may raise an exception) 16449 xhr.send( options.hasContent && options.data || null ); 16450 } catch ( e ) { 16451 16452 // #14683: Only rethrow if this hasn't been notified as an error yet 16453 if ( callback ) { 16454 throw e; 16455 } 16456 } 16457 }, 16458 16459 abort: function() { 16460 if ( callback ) { 16461 callback(); 16462 } 16463 } 16464 }; 16465 } 16466} ); 16467 16468 16469 16470 16471// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) 16472jQuery.ajaxPrefilter( function( s ) { 16473 if ( s.crossDomain ) { 16474 s.contents.script = false; 16475 } 16476} ); 16477 16478// Install script dataType 16479jQuery.ajaxSetup( { 16480 accepts: { 16481 script: "text/javascript, application/javascript, " + 16482 "application/ecmascript, application/x-ecmascript" 16483 }, 16484 contents: { 16485 script: /\b(?:java|ecma)script\b/ 16486 }, 16487 converters: { 16488 "text script": function( text ) { 16489 jQuery.globalEval( text ); 16490 return text; 16491 } 16492 } 16493} ); 16494 16495// Handle cache's special case and crossDomain 16496jQuery.ajaxPrefilter( "script", function( s ) { 16497 if ( s.cache === undefined ) { 16498 s.cache = false; 16499 } 16500 if ( s.crossDomain ) { 16501 s.type = "GET"; 16502 } 16503} ); 16504 16505// Bind script tag hack transport 16506jQuery.ajaxTransport( "script", function( s ) { 16507 16508 // This transport only deals with cross domain or forced-by-attrs requests 16509 if ( s.crossDomain || s.scriptAttrs ) { 16510 var script, callback; 16511 return { 16512 send: function( _, complete ) { 16513 script = jQuery( "<script>" ) 16514 .attr( s.scriptAttrs || {} ) 16515 .prop( { charset: s.scriptCharset, src: s.url } ) 16516 .on( "load error", callback = function( evt ) { 16517 script.remove(); 16518 callback = null; 16519 if ( evt ) { 16520 complete( evt.type === "error" ? 404 : 200, evt.type ); 16521 } 16522 } ); 16523 16524 // Use native DOM manipulation to avoid our domManip AJAX trickery 16525 document.head.appendChild( script[ 0 ] ); 16526 }, 16527 abort: function() { 16528 if ( callback ) { 16529 callback(); 16530 } 16531 } 16532 }; 16533 } 16534} ); 16535 16536 16537 16538 16539var oldCallbacks = [], 16540 rjsonp = /(=)\?(?=&|$)|\?\?/; 16541 16542// Default jsonp settings 16543jQuery.ajaxSetup( { 16544 jsonp: "callback", 16545 jsonpCallback: function() { 16546 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) ); 16547 this[ callback ] = true; 16548 return callback; 16549 } 16550} ); 16551 16552// Detect, normalize options and install callbacks for jsonp requests 16553jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 16554 16555 var callbackName, overwritten, responseContainer, 16556 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? 16557 "url" : 16558 typeof s.data === "string" && 16559 ( s.contentType || "" ) 16560 .indexOf( "application/x-www-form-urlencoded" ) === 0 && 16561 rjsonp.test( s.data ) && "data" 16562 ); 16563 16564 // Handle iff the expected data type is "jsonp" or we have a parameter to set 16565 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { 16566 16567 // Get callback name, remembering preexisting value associated with it 16568 callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ? 16569 s.jsonpCallback() : 16570 s.jsonpCallback; 16571 16572 // Insert callback into url or form data 16573 if ( jsonProp ) { 16574 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); 16575 } else if ( s.jsonp !== false ) { 16576 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; 16577 } 16578 16579 // Use data converter to retrieve json after script execution 16580 s.converters[ "script json" ] = function() { 16581 if ( !responseContainer ) { 16582 jQuery.error( callbackName + " was not called" ); 16583 } 16584 return responseContainer[ 0 ]; 16585 }; 16586 16587 // Force json dataType 16588 s.dataTypes[ 0 ] = "json"; 16589 16590 // Install callback 16591 overwritten = window[ callbackName ]; 16592 window[ callbackName ] = function() { 16593 responseContainer = arguments; 16594 }; 16595 16596 // Clean-up function (fires after converters) 16597 jqXHR.always( function() { 16598 16599 // If previous value didn't exist - remove it 16600 if ( overwritten === undefined ) { 16601 jQuery( window ).removeProp( callbackName ); 16602 16603 // Otherwise restore preexisting value 16604 } else { 16605 window[ callbackName ] = overwritten; 16606 } 16607 16608 // Save back as free 16609 if ( s[ callbackName ] ) { 16610 16611 // Make sure that re-using the options doesn't screw things around 16612 s.jsonpCallback = originalSettings.jsonpCallback; 16613 16614 // Save the callback name for future use 16615 oldCallbacks.push( callbackName ); 16616 } 16617 16618 // Call if it was a function and we have a response 16619 if ( responseContainer && isFunction( overwritten ) ) { 16620 overwritten( responseContainer[ 0 ] ); 16621 } 16622 16623 responseContainer = overwritten = undefined; 16624 } ); 16625 16626 // Delegate to script 16627 return "script"; 16628 } 16629} ); 16630 16631 16632 16633 16634// Support: Safari 8 only 16635// In Safari 8 documents created via document.implementation.createHTMLDocument 16636// collapse sibling forms: the second one becomes a child of the first one. 16637// Because of that, this security measure has to be disabled in Safari 8. 16638// https://bugs.webkit.org/show_bug.cgi?id=137337 16639support.createHTMLDocument = ( function() { 16640 var body = document.implementation.createHTMLDocument( "" ).body; 16641 body.innerHTML = "<form></form><form></form>"; 16642 return body.childNodes.length === 2; 16643} )(); 16644 16645 16646// Argument "data" should be string of html 16647// context (optional): If specified, the fragment will be created in this context, 16648// defaults to document 16649// keepScripts (optional): If true, will include scripts passed in the html string 16650jQuery.parseHTML = function( data, context, keepScripts ) { 16651 if ( typeof data !== "string" ) { 16652 return []; 16653 } 16654 if ( typeof context === "boolean" ) { 16655 keepScripts = context; 16656 context = false; 16657 } 16658 16659 var base, parsed, scripts; 16660 16661 if ( !context ) { 16662 16663 // Stop scripts or inline event handlers from being executed immediately 16664 // by using document.implementation 16665 if ( support.createHTMLDocument ) { 16666 context = document.implementation.createHTMLDocument( "" ); 16667 16668 // Set the base href for the created document 16669 // so any parsed elements with URLs 16670 // are based on the document's URL (gh-2965) 16671 base = context.createElement( "base" ); 16672 base.href = document.location.href; 16673 context.head.appendChild( base ); 16674 } else { 16675 context = document; 16676 } 16677 } 16678 16679 parsed = rsingleTag.exec( data ); 16680 scripts = !keepScripts && []; 16681 16682 // Single tag 16683 if ( parsed ) { 16684 return [ context.createElement( parsed[ 1 ] ) ]; 16685 } 16686 16687 parsed = buildFragment( [ data ], context, scripts ); 16688 16689 if ( scripts && scripts.length ) { 16690 jQuery( scripts ).remove(); 16691 } 16692 16693 return jQuery.merge( [], parsed.childNodes ); 16694}; 16695 16696 16697/** 16698 * Load a url into a page 16699 */ 16700jQuery.fn.load = function( url, params, callback ) { 16701 var selector, type, response, 16702 self = this, 16703 off = url.indexOf( " " ); 16704 16705 if ( off > -1 ) { 16706 selector = stripAndCollapse( url.slice( off ) ); 16707 url = url.slice( 0, off ); 16708 } 16709 16710 // If it's a function 16711 if ( isFunction( params ) ) { 16712 16713 // We assume that it's the callback 16714 callback = params; 16715 params = undefined; 16716 16717 // Otherwise, build a param string 16718 } else if ( params && typeof params === "object" ) { 16719 type = "POST"; 16720 } 16721 16722 // If we have elements to modify, make the request 16723 if ( self.length > 0 ) { 16724 jQuery.ajax( { 16725 url: url, 16726 16727 // If "type" variable is undefined, then "GET" method will be used. 16728 // Make value of this field explicit since 16729 // user can override it through ajaxSetup method 16730 type: type || "GET", 16731 dataType: "html", 16732 data: params 16733 } ).done( function( responseText ) { 16734 16735 // Save response for use in complete callback 16736 response = arguments; 16737 16738 self.html( selector ? 16739 16740 // If a selector was specified, locate the right elements in a dummy div 16741 // Exclude scripts to avoid IE 'Permission Denied' errors 16742 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : 16743 16744 // Otherwise use the full result 16745 responseText ); 16746 16747 // If the request succeeds, this function gets "data", "status", "jqXHR" 16748 // but they are ignored because response was set above. 16749 // If it fails, this function gets "jqXHR", "status", "error" 16750 } ).always( callback && function( jqXHR, status ) { 16751 self.each( function() { 16752 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] ); 16753 } ); 16754 } ); 16755 } 16756 16757 return this; 16758}; 16759 16760 16761 16762 16763jQuery.expr.pseudos.animated = function( elem ) { 16764 return jQuery.grep( jQuery.timers, function( fn ) { 16765 return elem === fn.elem; 16766 } ).length; 16767}; 16768 16769 16770 16771 16772jQuery.offset = { 16773 setOffset: function( elem, options, i ) { 16774 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, 16775 position = jQuery.css( elem, "position" ), 16776 curElem = jQuery( elem ), 16777 props = {}; 16778 16779 // Set position first, in-case top/left are set even on static elem 16780 if ( position === "static" ) { 16781 elem.style.position = "relative"; 16782 } 16783 16784 curOffset = curElem.offset(); 16785 curCSSTop = jQuery.css( elem, "top" ); 16786 curCSSLeft = jQuery.css( elem, "left" ); 16787 calculatePosition = ( position === "absolute" || position === "fixed" ) && 16788 ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1; 16789 16790 // Need to be able to calculate position if either 16791 // top or left is auto and position is either absolute or fixed 16792 if ( calculatePosition ) { 16793 curPosition = curElem.position(); 16794 curTop = curPosition.top; 16795 curLeft = curPosition.left; 16796 16797 } else { 16798 curTop = parseFloat( curCSSTop ) || 0; 16799 curLeft = parseFloat( curCSSLeft ) || 0; 16800 } 16801 16802 if ( isFunction( options ) ) { 16803 16804 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) 16805 options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); 16806 } 16807 16808 if ( options.top != null ) { 16809 props.top = ( options.top - curOffset.top ) + curTop; 16810 } 16811 if ( options.left != null ) { 16812 props.left = ( options.left - curOffset.left ) + curLeft; 16813 } 16814 16815 if ( "using" in options ) { 16816 options.using.call( elem, props ); 16817 16818 } else { 16819 if ( typeof props.top === "number" ) { 16820 props.top += "px"; 16821 } 16822 if ( typeof props.left === "number" ) { 16823 props.left += "px"; 16824 } 16825 curElem.css( props ); 16826 } 16827 } 16828}; 16829 16830jQuery.fn.extend( { 16831 16832 // offset() relates an element's border box to the document origin 16833 offset: function( options ) { 16834 16835 // Preserve chaining for setter 16836 if ( arguments.length ) { 16837 return options === undefined ? 16838 this : 16839 this.each( function( i ) { 16840 jQuery.offset.setOffset( this, options, i ); 16841 } ); 16842 } 16843 16844 var rect, win, 16845 elem = this[ 0 ]; 16846 16847 if ( !elem ) { 16848 return; 16849 } 16850 16851 // Return zeros for disconnected and hidden (display: none) elements (gh-2310) 16852 // Support: IE <=11 only 16853 // Running getBoundingClientRect on a 16854 // disconnected node in IE throws an error 16855 if ( !elem.getClientRects().length ) { 16856 return { top: 0, left: 0 }; 16857 } 16858 16859 // Get document-relative position by adding viewport scroll to viewport-relative gBCR 16860 rect = elem.getBoundingClientRect(); 16861 win = elem.ownerDocument.defaultView; 16862 return { 16863 top: rect.top + win.pageYOffset, 16864 left: rect.left + win.pageXOffset 16865 }; 16866 }, 16867 16868 // position() relates an element's margin box to its offset parent's padding box 16869 // This corresponds to the behavior of CSS absolute positioning 16870 position: function() { 16871 if ( !this[ 0 ] ) { 16872 return; 16873 } 16874 16875 var offsetParent, offset, doc, 16876 elem = this[ 0 ], 16877 parentOffset = { top: 0, left: 0 }; 16878 16879 // position:fixed elements are offset from the viewport, which itself always has zero offset 16880 if ( jQuery.css( elem, "position" ) === "fixed" ) { 16881 16882 // Assume position:fixed implies availability of getBoundingClientRect 16883 offset = elem.getBoundingClientRect(); 16884 16885 } else { 16886 offset = this.offset(); 16887 16888 // Account for the *real* offset parent, which can be the document or its root element 16889 // when a statically positioned element is identified 16890 doc = elem.ownerDocument; 16891 offsetParent = elem.offsetParent || doc.documentElement; 16892 while ( offsetParent && 16893 ( offsetParent === doc.body || offsetParent === doc.documentElement ) && 16894 jQuery.css( offsetParent, "position" ) === "static" ) { 16895 16896 offsetParent = offsetParent.parentNode; 16897 } 16898 if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) { 16899 16900 // Incorporate borders into its offset, since they are outside its content origin 16901 parentOffset = jQuery( offsetParent ).offset(); 16902 parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true ); 16903 parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true ); 16904 } 16905 } 16906 16907 // Subtract parent offsets and element margins 16908 return { 16909 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), 16910 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) 16911 }; 16912 }, 16913 16914 // This method will return documentElement in the following cases: 16915 // 1) For the element inside the iframe without offsetParent, this method will return 16916 // documentElement of the parent window 16917 // 2) For the hidden or detached element 16918 // 3) For body or html element, i.e. in case of the html node - it will return itself 16919 // 16920 // but those exceptions were never presented as a real life use-cases 16921 // and might be considered as more preferable results. 16922 // 16923 // This logic, however, is not guaranteed and can change at any point in the future 16924 offsetParent: function() { 16925 return this.map( function() { 16926 var offsetParent = this.offsetParent; 16927 16928 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { 16929 offsetParent = offsetParent.offsetParent; 16930 } 16931 16932 return offsetParent || documentElement; 16933 } ); 16934 } 16935} ); 16936 16937// Create scrollLeft and scrollTop methods 16938jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { 16939 var top = "pageYOffset" === prop; 16940 16941 jQuery.fn[ method ] = function( val ) { 16942 return access( this, function( elem, method, val ) { 16943 16944 // Coalesce documents and windows 16945 var win; 16946 if ( isWindow( elem ) ) { 16947 win = elem; 16948 } else if ( elem.nodeType === 9 ) { 16949 win = elem.defaultView; 16950 } 16951 16952 if ( val === undefined ) { 16953 return win ? win[ prop ] : elem[ method ]; 16954 } 16955 16956 if ( win ) { 16957 win.scrollTo( 16958 !top ? val : win.pageXOffset, 16959 top ? val : win.pageYOffset 16960 ); 16961 16962 } else { 16963 elem[ method ] = val; 16964 } 16965 }, method, val, arguments.length ); 16966 }; 16967} ); 16968 16969// Support: Safari <=7 - 9.1, Chrome <=37 - 49 16970// Add the top/left cssHooks using jQuery.fn.position 16971// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 16972// Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347 16973// getComputedStyle returns percent when specified for top/left/bottom/right; 16974// rather than make the css module depend on the offset module, just check for it here 16975jQuery.each( [ "top", "left" ], function( _i, prop ) { 16976 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, 16977 function( elem, computed ) { 16978 if ( computed ) { 16979 computed = curCSS( elem, prop ); 16980 16981 // If curCSS returns percentage, fallback to offset 16982 return rnumnonpx.test( computed ) ? 16983 jQuery( elem ).position()[ prop ] + "px" : 16984 computed; 16985 } 16986 } 16987 ); 16988} ); 16989 16990 16991// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods 16992jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { 16993 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, 16994 function( defaultExtra, funcName ) { 16995 16996 // Margin is only for outerHeight, outerWidth 16997 jQuery.fn[ funcName ] = function( margin, value ) { 16998 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), 16999 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); 17000 17001 return access( this, function( elem, type, value ) { 17002 var doc; 17003 17004 if ( isWindow( elem ) ) { 17005 17006 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729) 17007 return funcName.indexOf( "outer" ) === 0 ? 17008 elem[ "inner" + name ] : 17009 elem.document.documentElement[ "client" + name ]; 17010 } 17011 17012 // Get document width or height 17013 if ( elem.nodeType === 9 ) { 17014 doc = elem.documentElement; 17015 17016 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], 17017 // whichever is greatest 17018 return Math.max( 17019 elem.body[ "scroll" + name ], doc[ "scroll" + name ], 17020 elem.body[ "offset" + name ], doc[ "offset" + name ], 17021 doc[ "client" + name ] 17022 ); 17023 } 17024 17025 return value === undefined ? 17026 17027 // Get width or height on the element, requesting but not forcing parseFloat 17028 jQuery.css( elem, type, extra ) : 17029 17030 // Set width or height on the element 17031 jQuery.style( elem, type, value, extra ); 17032 }, type, chainable ? margin : undefined, chainable ); 17033 }; 17034 } ); 17035} ); 17036 17037 17038jQuery.each( [ 17039 "ajaxStart", 17040 "ajaxStop", 17041 "ajaxComplete", 17042 "ajaxError", 17043 "ajaxSuccess", 17044 "ajaxSend" 17045], function( _i, type ) { 17046 jQuery.fn[ type ] = function( fn ) { 17047 return this.on( type, fn ); 17048 }; 17049} ); 17050 17051 17052 17053 17054jQuery.fn.extend( { 17055 17056 bind: function( types, data, fn ) { 17057 return this.on( types, null, data, fn ); 17058 }, 17059 unbind: function( types, fn ) { 17060 return this.off( types, null, fn ); 17061 }, 17062 17063 delegate: function( selector, types, data, fn ) { 17064 return this.on( types, selector, data, fn ); 17065 }, 17066 undelegate: function( selector, types, fn ) { 17067 17068 // ( namespace ) or ( selector, types [, fn] ) 17069 return arguments.length === 1 ? 17070 this.off( selector, "**" ) : 17071 this.off( types, selector || "**", fn ); 17072 }, 17073 17074 hover: function( fnOver, fnOut ) { 17075 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); 17076 } 17077} ); 17078 17079jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + 17080 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + 17081 "change select submit keydown keypress keyup contextmenu" ).split( " " ), 17082 function( _i, name ) { 17083 17084 // Handle event binding 17085 jQuery.fn[ name ] = function( data, fn ) { 17086 return arguments.length > 0 ? 17087 this.on( name, null, data, fn ) : 17088 this.trigger( name ); 17089 }; 17090 } ); 17091 17092 17093 17094 17095// Support: Android <=4.0 only 17096// Make sure we trim BOM and NBSP 17097var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; 17098 17099// Bind a function to a context, optionally partially applying any 17100// arguments. 17101// jQuery.proxy is deprecated to promote standards (specifically Function#bind) 17102// However, it is not slated for removal any time soon 17103jQuery.proxy = function( fn, context ) { 17104 var tmp, args, proxy; 17105 17106 if ( typeof context === "string" ) { 17107 tmp = fn[ context ]; 17108 context = fn; 17109 fn = tmp; 17110 } 17111 17112 // Quick check to determine if target is callable, in the spec 17113 // this throws a TypeError, but we will just return undefined. 17114 if ( !isFunction( fn ) ) { 17115 return undefined; 17116 } 17117 17118 // Simulated bind 17119 args = slice.call( arguments, 2 ); 17120 proxy = function() { 17121 return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); 17122 }; 17123 17124 // Set the guid of unique handler to the same of original handler, so it can be removed 17125 proxy.guid = fn.guid = fn.guid || jQuery.guid++; 17126 17127 return proxy; 17128}; 17129 17130jQuery.holdReady = function( hold ) { 17131 if ( hold ) { 17132 jQuery.readyWait++; 17133 } else { 17134 jQuery.ready( true ); 17135 } 17136}; 17137jQuery.isArray = Array.isArray; 17138jQuery.parseJSON = JSON.parse; 17139jQuery.nodeName = nodeName; 17140jQuery.isFunction = isFunction; 17141jQuery.isWindow = isWindow; 17142jQuery.camelCase = camelCase; 17143jQuery.type = toType; 17144 17145jQuery.now = Date.now; 17146 17147jQuery.isNumeric = function( obj ) { 17148 17149 // As of jQuery 3.0, isNumeric is limited to 17150 // strings and numbers (primitives or objects) 17151 // that can be coerced to finite numbers (gh-2662) 17152 var type = jQuery.type( obj ); 17153 return ( type === "number" || type === "string" ) && 17154 17155 // parseFloat NaNs numeric-cast false positives ("") 17156 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") 17157 // subtraction forces infinities to NaN 17158 !isNaN( obj - parseFloat( obj ) ); 17159}; 17160 17161jQuery.trim = function( text ) { 17162 return text == null ? 17163 "" : 17164 ( text + "" ).replace( rtrim, "" ); 17165}; 17166 17167 17168 17169// Register as a named AMD module, since jQuery can be concatenated with other 17170// files that may use define, but not via a proper concatenation script that 17171// understands anonymous AMD modules. A named AMD is safest and most robust 17172// way to register. Lowercase jquery is used because AMD module names are 17173// derived from file names, and jQuery is normally delivered in a lowercase 17174// file name. Do this after creating the global so that if an AMD module wants 17175// to call noConflict to hide this version of jQuery, it will work. 17176 17177// Note that for maximum portability, libraries that are not jQuery should 17178// declare themselves as anonymous modules, and avoid setting a global if an 17179// AMD loader is present. jQuery is a special case. For more information, see 17180// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon 17181 17182if ( true ) { 17183 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() { 17184 return jQuery; 17185 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), 17186 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 17187} 17188 17189 17190 17191 17192var 17193 17194 // Map over jQuery in case of overwrite 17195 _jQuery = window.jQuery, 17196 17197 // Map over the $ in case of overwrite 17198 _$ = window.$; 17199 17200jQuery.noConflict = function( deep ) { 17201 if ( window.$ === jQuery ) { 17202 window.$ = _$; 17203 } 17204 17205 if ( deep && window.jQuery === jQuery ) { 17206 window.jQuery = _jQuery; 17207 } 17208 17209 return jQuery; 17210}; 17211 17212// Expose jQuery and $ identifiers, even in AMD 17213// (#7102#comment:10, https://github.com/jquery/jquery/pull/557) 17214// and CommonJS for browser emulators (#13566) 17215if ( typeof noGlobal === "undefined" ) { 17216 window.jQuery = window.$ = jQuery; 17217} 17218 17219 17220 17221 17222return jQuery; 17223} ); 17224 17225 17226/***/ }), 17227
vendor: 543,067 bytes, lines 17228-34392
17228/***/ "./node_modules/lodash/lodash.js": 17229/*!***************************************!*\ 17230 !*** ./node_modules/lodash/lodash.js ***! 17231 \***************************************/ 17232/*! no static exports found */ 17233/***/ (function(module, exports, __webpack_require__) { 17234 17235/* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/** 17236 * @license 17237 * Lodash <https://lodash.com/> 17238 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> 17239 * Released under MIT license <https://lodash.com/license> 17240 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> 17241 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 17242 */ 17243;(function() { 17244 17245 /** Used as a safe reference for `undefined` in pre-ES5 environments. */ 17246 var undefined; 17247 17248 /** Used as the semantic version number. */ 17249 var VERSION = '4.17.20'; 17250 17251 /** Used as the size to enable large array optimizations. */ 17252 var LARGE_ARRAY_SIZE = 200; 17253 17254 /** Error message constants. */ 17255 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', 17256 FUNC_ERROR_TEXT = 'Expected a function'; 17257 17258 /** Used to stand-in for `undefined` hash values. */ 17259 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 17260 17261 /** Used as the maximum memoize cache size. */ 17262 var MAX_MEMOIZE_SIZE = 500; 17263 17264 /** Used as the internal argument placeholder. */ 17265 var PLACEHOLDER = '__lodash_placeholder__'; 17266 17267 /** Used to compose bitmasks for cloning. */ 17268 var CLONE_DEEP_FLAG = 1, 17269 CLONE_FLAT_FLAG = 2, 17270 CLONE_SYMBOLS_FLAG = 4; 17271 17272 /** Used to compose bitmasks for value comparisons. */ 17273 var COMPARE_PARTIAL_FLAG = 1, 17274 COMPARE_UNORDERED_FLAG = 2; 17275 17276 /** Used to compose bitmasks for function metadata. */ 17277 var WRAP_BIND_FLAG = 1, 17278 WRAP_BIND_KEY_FLAG = 2, 17279 WRAP_CURRY_BOUND_FLAG = 4, 17280 WRAP_CURRY_FLAG = 8, 17281 WRAP_CURRY_RIGHT_FLAG = 16, 17282 WRAP_PARTIAL_FLAG = 32, 17283 WRAP_PARTIAL_RIGHT_FLAG = 64, 17284 WRAP_ARY_FLAG = 128, 17285 WRAP_REARG_FLAG = 256, 17286 WRAP_FLIP_FLAG = 512; 17287 17288 /** Used as default options for `_.truncate`. */ 17289 var DEFAULT_TRUNC_LENGTH = 30, 17290 DEFAULT_TRUNC_OMISSION = '...'; 17291 17292 /** Used to detect hot functions by number of calls within a span of milliseconds. */ 17293 var HOT_COUNT = 800, 17294 HOT_SPAN = 16; 17295 17296 /** Used to indicate the type of lazy iteratees. */ 17297 var LAZY_FILTER_FLAG = 1, 17298 LAZY_MAP_FLAG = 2, 17299 LAZY_WHILE_FLAG = 3; 17300 17301 /** Used as references for various `Number` constants. */ 17302 var INFINITY = 1 / 0, 17303 MAX_SAFE_INTEGER = 9007199254740991, 17304 MAX_INTEGER = 1.7976931348623157e+308, 17305 NAN = 0 / 0; 17306 17307 /** Used as references for the maximum length and index of an array. */ 17308 var MAX_ARRAY_LENGTH = 4294967295, 17309 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, 17310 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; 17311 17312 /** Used to associate wrap methods with their bit flags. */ 17313 var wrapFlags = [ 17314 ['ary', WRAP_ARY_FLAG], 17315 ['bind', WRAP_BIND_FLAG], 17316 ['bindKey', WRAP_BIND_KEY_FLAG], 17317 ['curry', WRAP_CURRY_FLAG], 17318 ['curryRight', WRAP_CURRY_RIGHT_FLAG], 17319 ['flip', WRAP_FLIP_FLAG], 17320 ['partial', WRAP_PARTIAL_FLAG], 17321 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], 17322 ['rearg', WRAP_REARG_FLAG] 17323 ]; 17324 17325 /** `Object#toString` result references. */ 17326 var argsTag = '[object Arguments]', 17327 arrayTag = '[object Array]', 17328 asyncTag = '[object AsyncFunction]', 17329 boolTag = '[object Boolean]', 17330 dateTag = '[object Date]', 17331 domExcTag = '[object DOMException]', 17332 errorTag = '[object Error]', 17333 funcTag = '[object Function]', 17334 genTag = '[object GeneratorFunction]', 17335 mapTag = '[object Map]', 17336 numberTag = '[object Number]', 17337 nullTag = '[object Null]', 17338 objectTag = '[object Object]', 17339 promiseTag = '[object Promise]', 17340 proxyTag = '[object Proxy]', 17341 regexpTag = '[object RegExp]', 17342 setTag = '[object Set]', 17343 stringTag = '[object String]', 17344 symbolTag = '[object Symbol]', 17345 undefinedTag = '[object Undefined]', 17346 weakMapTag = '[object WeakMap]', 17347 weakSetTag = '[object WeakSet]'; 17348 17349 var arrayBufferTag = '[object ArrayBuffer]', 17350 dataViewTag = '[object DataView]', 17351 float32Tag = '[object Float32Array]', 17352 float64Tag = '[object Float64Array]', 17353 int8Tag = '[object Int8Array]', 17354 int16Tag = '[object Int16Array]', 17355 int32Tag = '[object Int32Array]', 17356 uint8Tag = '[object Uint8Array]', 17357 uint8ClampedTag = '[object Uint8ClampedArray]', 17358 uint16Tag = '[object Uint16Array]', 17359 uint32Tag = '[object Uint32Array]'; 17360 17361 /** Used to match empty string literals in compiled template source. */ 17362 var reEmptyStringLeading = /\b__p \+= '';/g, 17363 reEmptyStringMiddle = /\b(__p \+=) '' \+/g, 17364 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; 17365 17366 /** Used to match HTML entities and HTML characters. */ 17367 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, 17368 reUnescapedHtml = /[&<>"']/g, 17369 reHasEscapedHtml = RegExp(reEscapedHtml.source), 17370 reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 17371 17372 /** Used to match template delimiters. */ 17373 var reEscape = /<%-([\s\S]+?)%>/g, 17374 reEvaluate = /<%([\s\S]+?)%>/g, 17375 reInterpolate = /<%=([\s\S]+?)%>/g; 17376 17377 /** Used to match property names within property paths. */ 17378 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, 17379 reIsPlainProp = /^\w*$/, 17380 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; 17381 17382 /** 17383 * Used to match `RegExp` 17384 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 17385 */ 17386 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, 17387 reHasRegExpChar = RegExp(reRegExpChar.source); 17388 17389 /** Used to match leading and trailing whitespace. */ 17390 var reTrim = /^\s+|\s+$/g, 17391 reTrimStart = /^\s+/, 17392 reTrimEnd = /\s+$/; 17393 17394 /** Used to match wrap detail comments. */ 17395 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, 17396 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, 17397 reSplitDetails = /,? & /; 17398 17399 /** Used to match words composed of alphanumeric characters. */ 17400 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 17401 17402 /** Used to match backslashes in property paths. */ 17403 var reEscapeChar = /\\(\\)?/g; 17404 17405 /** 17406 * Used to match 17407 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). 17408 */ 17409 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; 17410 17411 /** Used to match `RegExp` flags from their coerced string values. */ 17412 var reFlags = /\w*$/; 17413 17414 /** Used to detect bad signed hexadecimal string values. */ 17415 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 17416 17417 /** Used to detect binary string values. */ 17418 var reIsBinary = /^0b[01]+$/i; 17419 17420 /** Used to detect host constructors (Safari). */ 17421 var reIsHostCtor = /^\[object .+?Constructor\]$/; 17422 17423 /** Used to detect octal string values. */ 17424 var reIsOctal = /^0o[0-7]+$/i; 17425 17426 /** Used to detect unsigned integer values. */ 17427 var reIsUint = /^(?:0|[1-9]\d*)$/; 17428 17429 /** Used to match Latin Unicode letters (excluding mathematical operators). */ 17430 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 17431 17432 /** Used to ensure capturing order of template delimiters. */ 17433 var reNoMatch = /($^)/; 17434 17435 /** Used to match unescaped characters in compiled string literals. */ 17436 var reUnescapedString = /['\n\r\u2028\u2029\\]/g; 17437 17438 /** Used to compose unicode character classes. */ 17439 var rsAstralRange = '\\ud800-\\udfff', 17440 rsComboMarksRange = '\\u0300-\\u036f', 17441 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 17442 rsComboSymbolsRange = '\\u20d0-\\u20ff', 17443 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 17444 rsDingbatRange = '\\u2700-\\u27bf', 17445 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 17446 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 17447 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 17448 rsPunctuationRange = '\\u2000-\\u206f', 17449 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', 17450 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 17451 rsVarRange = '\\ufe0e\\ufe0f', 17452 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 17453 17454 /** Used to compose unicode capture groups. */ 17455 var rsApos = "['\u2019]", 17456 rsAstral = '[' + rsAstralRange + ']', 17457 rsBreak = '[' + rsBreakRange + ']', 17458 rsCombo = '[' + rsComboRange + ']', 17459 rsDigits = '\\d+', 17460 rsDingbat = '[' + rsDingbatRange + ']', 17461 rsLower = '[' + rsLowerRange + ']', 17462 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 17463 rsFitz = '\\ud83c[\\udffb-\\udfff]', 17464 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 17465 rsNonAstral = '[^' + rsAstralRange + ']', 17466 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 17467 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 17468 rsUpper = '[' + rsUpperRange + ']', 17469 rsZWJ = '\\u200d'; 17470 17471 /** Used to compose unicode regexes. */ 17472 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 17473 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 17474 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', 17475 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', 17476 reOptMod = rsModifier + '?', 17477 rsOptVar = '[' + rsVarRange + ']?', 17478 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 17479 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', 17480 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', 17481 rsSeq = rsOptVar + reOptMod + rsOptJoin, 17482 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, 17483 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; 17484 17485 /** Used to match apostrophes. */ 17486 var reApos = RegExp(rsApos, 'g'); 17487 17488 /** 17489 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 17490 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 17491 */ 17492 var reComboMark = RegExp(rsCombo, 'g'); 17493 17494 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 17495 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); 17496 17497 /** Used to match complex or compound words. */ 17498 var reUnicodeWord = RegExp([ 17499 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 17500 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 17501 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 17502 rsUpper + '+' + rsOptContrUpper, 17503 rsOrdUpper, 17504 rsOrdLower, 17505 rsDigits, 17506 rsEmoji 17507 ].join('|'), 'g'); 17508 17509 /** 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/). */ 17510 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); 17511 17512 /** Used to detect strings that need a more robust regexp to match words. */ 17513 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 ]/; 17514 17515 /** Used to assign default `context` object properties. */ 17516 var contextProps = [ 17517 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 17518 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', 17519 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 17520 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 17521 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' 17522 ]; 17523 17524 /** Used to make template sourceURLs easier to identify. */ 17525 var templateCounter = -1; 17526 17527 /** Used to identify `toStringTag` values of typed arrays. */ 17528 var typedArrayTags = {}; 17529 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 17530 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 17531 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 17532 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 17533 typedArrayTags[uint32Tag] = true; 17534 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 17535 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = 17536 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = 17537 typedArrayTags[errorTag] = typedArrayTags[funcTag] = 17538 typedArrayTags[mapTag] = typedArrayTags[numberTag] = 17539 typedArrayTags[objectTag] = typedArrayTags[regexpTag] = 17540 typedArrayTags[setTag] = typedArrayTags[stringTag] = 17541 typedArrayTags[weakMapTag] = false; 17542 17543 /** Used to identify `toStringTag` values supported by `_.clone`. */ 17544 var cloneableTags = {}; 17545 cloneableTags[argsTag] = cloneableTags[arrayTag] = 17546 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 17547 cloneableTags[boolTag] = cloneableTags[dateTag] = 17548 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 17549 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 17550 cloneableTags[int32Tag] = cloneableTags[mapTag] = 17551 cloneableTags[numberTag] = cloneableTags[objectTag] = 17552 cloneableTags[regexpTag] = cloneableTags[setTag] = 17553 cloneableTags[stringTag] = cloneableTags[symbolTag] = 17554 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 17555 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 17556 cloneableTags[errorTag] = cloneableTags[funcTag] = 17557 cloneableTags[weakMapTag] = false; 17558 17559 /** Used to map Latin Unicode letters to basic Latin letters. */ 17560 var deburredLetters = { 17561 // Latin-1 Supplement block. 17562 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 17563 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 17564 '\xc7': 'C', '\xe7': 'c', 17565 '\xd0': 'D', '\xf0': 'd', 17566 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 17567 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 17568 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 17569 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 17570 '\xd1': 'N', '\xf1': 'n', 17571 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 17572 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 17573 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 17574 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 17575 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 17576 '\xc6': 'Ae', '\xe6': 'ae', 17577 '\xde': 'Th', '\xfe': 'th', 17578 '\xdf': 'ss', 17579 // Latin Extended-A block. 17580 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 17581 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 17582 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 17583 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 17584 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 17585 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 17586 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 17587 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 17588 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 17589 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 17590 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 17591 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 17592 '\u0134': 'J', '\u0135': 'j', 17593 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 17594 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 17595 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 17596 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 17597 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 17598 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', 17599 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 17600 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 17601 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 17602 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 17603 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 17604 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 17605 '\u0163': 't', '\u0165': 't', '\u0167': 't', 17606 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 17607 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 17608 '\u0174': 'W', '\u0175': 'w', 17609 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 17610 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 17611 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 17612 '\u0132': 'IJ', '\u0133': 'ij', 17613 '\u0152': 'Oe', '\u0153': 'oe', 17614 '\u0149': "'n", '\u017f': 's' 17615 }; 17616 17617 /** Used to map characters to HTML entities. */ 17618 var htmlEscapes = { 17619 '&': '&', 17620 '<': '<', 17621 '>': '>', 17622 '"': '"', 17623 "'": ''' 17624 }; 17625 17626 /** Used to map HTML entities to characters. */ 17627 var htmlUnescapes = { 17628 '&': '&', 17629 '<': '<', 17630 '>': '>', 17631 '"': '"', 17632 ''': "'" 17633 }; 17634 17635 /** Used to escape characters for inclusion in compiled string literals. */ 17636 var stringEscapes = { 17637 '\\': '\\', 17638 "'": "'", 17639 '\n': 'n', 17640 '\r': 'r', 17641 '\u2028': 'u2028', 17642 '\u2029': 'u2029' 17643 }; 17644 17645 /** Built-in method references without a dependency on `root`. */ 17646 var freeParseFloat = parseFloat, 17647 freeParseInt = parseInt; 17648 17649 /** Detect free variable `global` from Node.js. */ 17650 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; 17651 17652 /** Detect free variable `self`. */ 17653 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 17654 17655 /** Used as a reference to the global object. */ 17656 var root = freeGlobal || freeSelf || Function('return this')(); 17657 17658 /** Detect free variable `exports`. */ 17659 var freeExports = true && exports && !exports.nodeType && exports; 17660 17661 /** Detect free variable `module`. */ 17662 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; 17663 17664 /** Detect the popular CommonJS extension `module.exports`. */ 17665 var moduleExports = freeModule && freeModule.exports === freeExports; 17666 17667 /** Detect free variable `process` from Node.js. */ 17668 var freeProcess = moduleExports && freeGlobal.process; 17669 17670 /** Used to access faster Node.js helpers. */ 17671 var nodeUtil = (function() { 17672 try { 17673 // Use `util.types` for Node.js 10+. 17674 var types = freeModule && freeModule.require && freeModule.require('util').types; 17675 17676 if (types) { 17677 return types; 17678 } 17679 17680 // Legacy `process.binding('util')` for Node.js < 10. 17681 return freeProcess && freeProcess.binding && freeProcess.binding('util'); 17682 } catch (e) {} 17683 }()); 17684 17685 /* Node.js helper references. */ 17686 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, 17687 nodeIsDate = nodeUtil && nodeUtil.isDate, 17688 nodeIsMap = nodeUtil && nodeUtil.isMap, 17689 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, 17690 nodeIsSet = nodeUtil && nodeUtil.isSet, 17691 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; 17692 17693 /*--------------------------------------------------------------------------*/ 17694 17695 /** 17696 * A faster alternative to `Function#apply`, this function invokes `func` 17697 * with the `this` binding of `thisArg` and the arguments of `args`. 17698 * 17699 * @private 17700 * @param {Function} func The function to invoke. 17701 * @param {*} thisArg The `this` binding of `func`. 17702 * @param {Array} args The arguments to invoke `func` with. 17703 * @returns {*} Returns the result of `func`. 17704 */ 17705 function apply(func, thisArg, args) { 17706 switch (args.length) { 17707 case 0: return func.call(thisArg); 17708 case 1: return func.call(thisArg, args[0]); 17709 case 2: return func.call(thisArg, args[0], args[1]); 17710 case 3: return func.call(thisArg, args[0], args[1], args[2]); 17711 } 17712 return func.apply(thisArg, args); 17713 } 17714 17715 /** 17716 * A specialized version of `baseAggregator` for arrays. 17717 * 17718 * @private 17719 * @param {Array} [array] The array to iterate over. 17720 * @param {Function} setter The function to set `accumulator` values. 17721 * @param {Function} iteratee The iteratee to transform keys. 17722 * @param {Object} accumulator The initial aggregated object. 17723 * @returns {Function} Returns `accumulator`. 17724 */ 17725 function arrayAggregator(array, setter, iteratee, accumulator) { 17726 var index = -1, 17727 length = array == null ? 0 : array.length; 17728 17729 while (++index < length) { 17730 var value = array[index]; 17731 setter(accumulator, value, iteratee(value), array); 17732 } 17733 return accumulator; 17734 } 17735 17736 /** 17737 * A specialized version of `_.forEach` for arrays without support for 17738 * iteratee shorthands. 17739 * 17740 * @private 17741 * @param {Array} [array] The array to iterate over. 17742 * @param {Function} iteratee The function invoked per iteration. 17743 * @returns {Array} Returns `array`. 17744 */ 17745 function arrayEach(array, iteratee) { 17746 var index = -1, 17747 length = array == null ? 0 : array.length; 17748 17749 while (++index < length) { 17750 if (iteratee(array[index], index, array) === false) { 17751 break; 17752 } 17753 } 17754 return array; 17755 } 17756 17757 /** 17758 * A specialized version of `_.forEachRight` for arrays without support for 17759 * iteratee shorthands. 17760 * 17761 * @private 17762 * @param {Array} [array] The array to iterate over. 17763 * @param {Function} iteratee The function invoked per iteration. 17764 * @returns {Array} Returns `array`. 17765 */ 17766 function arrayEachRight(array, iteratee) { 17767 var length = array == null ? 0 : array.length; 17768 17769 while (length--) { 17770 if (iteratee(array[length], length, array) === false) { 17771 break; 17772 } 17773 } 17774 return array; 17775 } 17776 17777 /** 17778 * A specialized version of `_.every` for arrays without support for 17779 * iteratee shorthands. 17780 * 17781 * @private 17782 * @param {Array} [array] The array to iterate over. 17783 * @param {Function} predicate The function invoked per iteration. 17784 * @returns {boolean} Returns `true` if all elements pass the predicate check, 17785 * else `false`. 17786 */ 17787 function arrayEvery(array, predicate) { 17788 var index = -1, 17789 length = array == null ? 0 : array.length; 17790 17791 while (++index < length) { 17792 if (!predicate(array[index], index, array)) { 17793 return false; 17794 } 17795 } 17796 return true; 17797 } 17798 17799 /** 17800 * A specialized version of `_.filter` for arrays without support for 17801 * iteratee shorthands. 17802 * 17803 * @private 17804 * @param {Array} [array] The array to iterate over. 17805 * @param {Function} predicate The function invoked per iteration. 17806 * @returns {Array} Returns the new filtered array. 17807 */ 17808 function arrayFilter(array, predicate) { 17809 var index = -1, 17810 length = array == null ? 0 : array.length, 17811 resIndex = 0, 17812 result = []; 17813 17814 while (++index < length) { 17815 var value = array[index]; 17816 if (predicate(value, index, array)) { 17817 result[resIndex++] = value; 17818 } 17819 } 17820 return result; 17821 } 17822 17823 /** 17824 * A specialized version of `_.includes` for arrays without support for 17825 * specifying an index to search from. 17826 * 17827 * @private 17828 * @param {Array} [array] The array to inspect. 17829 * @param {*} target The value to search for. 17830 * @returns {boolean} Returns `true` if `target` is found, else `false`. 17831 */ 17832 function arrayIncludes(array, value) { 17833 var length = array == null ? 0 : array.length; 17834 return !!length && baseIndexOf(array, value, 0) > -1; 17835 } 17836 17837 /** 17838 * This function is like `arrayIncludes` except that it accepts a comparator. 17839 * 17840 * @private 17841 * @param {Array} [array] The array to inspect. 17842 * @param {*} target The value to search for. 17843 * @param {Function} comparator The comparator invoked per element. 17844 * @returns {boolean} Returns `true` if `target` is found, else `false`. 17845 */ 17846 function arrayIncludesWith(array, value, comparator) { 17847 var index = -1, 17848 length = array == null ? 0 : array.length; 17849 17850 while (++index < length) { 17851 if (comparator(value, array[index])) { 17852 return true; 17853 } 17854 } 17855 return false; 17856 } 17857 17858 /** 17859 * A specialized version of `_.map` for arrays without support for iteratee 17860 * shorthands. 17861 * 17862 * @private 17863 * @param {Array} [array] The array to iterate over. 17864 * @param {Function} iteratee The function invoked per iteration. 17865 * @returns {Array} Returns the new mapped array. 17866 */ 17867 function arrayMap(array, iteratee) { 17868 var index = -1, 17869 length = array == null ? 0 : array.length, 17870 result = Array(length); 17871 17872 while (++index < length) { 17873 result[index] = iteratee(array[index], index, array); 17874 } 17875 return result; 17876 } 17877 17878 /** 17879 * Appends the elements of `values` to `array`. 17880 * 17881 * @private 17882 * @param {Array} array The array to modify. 17883 * @param {Array} values The values to append. 17884 * @returns {Array} Returns `array`. 17885 */ 17886 function arrayPush(array, values) { 17887 var index = -1, 17888 length = values.length, 17889 offset = array.length; 17890 17891 while (++index < length) { 17892 array[offset + index] = values[index]; 17893 } 17894 return array; 17895 } 17896 17897 /** 17898 * A specialized version of `_.reduce` for arrays without support for 17899 * iteratee shorthands. 17900 * 17901 * @private 17902 * @param {Array} [array] The array to iterate over. 17903 * @param {Function} iteratee The function invoked per iteration. 17904 * @param {*} [accumulator] The initial value. 17905 * @param {boolean} [initAccum] Specify using the first element of `array` as 17906 * the initial value. 17907 * @returns {*} Returns the accumulated value. 17908 */ 17909 function arrayReduce(array, iteratee, accumulator, initAccum) { 17910 var index = -1, 17911 length = array == null ? 0 : array.length; 17912 17913 if (initAccum && length) { 17914 accumulator = array[++index]; 17915 } 17916 while (++index < length) { 17917 accumulator = iteratee(accumulator, array[index], index, array); 17918 } 17919 return accumulator; 17920 } 17921 17922 /** 17923 * A specialized version of `_.reduceRight` for arrays without support for 17924 * iteratee shorthands. 17925 * 17926 * @private 17927 * @param {Array} [array] The array to iterate over. 17928 * @param {Function} iteratee The function invoked per iteration. 17929 * @param {*} [accumulator] The initial value. 17930 * @param {boolean} [initAccum] Specify using the last element of `array` as 17931 * the initial value. 17932 * @returns {*} Returns the accumulated value. 17933 */ 17934 function arrayReduceRight(array, iteratee, accumulator, initAccum) { 17935 var length = array == null ? 0 : array.length; 17936 if (initAccum && length) { 17937 accumulator = array[--length]; 17938 } 17939 while (length--) { 17940 accumulator = iteratee(accumulator, array[length], length, array); 17941 } 17942 return accumulator; 17943 } 17944 17945 /** 17946 * A specialized version of `_.some` for arrays without support for iteratee 17947 * shorthands. 17948 * 17949 * @private 17950 * @param {Array} [array] The array to iterate over. 17951 * @param {Function} predicate The function invoked per iteration. 17952 * @returns {boolean} Returns `true` if any element passes the predicate check, 17953 * else `false`. 17954 */ 17955 function arraySome(array, predicate) { 17956 var index = -1, 17957 length = array == null ? 0 : array.length; 17958 17959 while (++index < length) { 17960 if (predicate(array[index], index, array)) { 17961 return true; 17962 } 17963 } 17964 return false; 17965 } 17966 17967 /** 17968 * Gets the size of an ASCII `string`. 17969 * 17970 * @private 17971 * @param {string} string The string inspect. 17972 * @returns {number} Returns the string size. 17973 */ 17974 var asciiSize = baseProperty('length'); 17975 17976 /** 17977 * Converts an ASCII `string` to an array. 17978 * 17979 * @private 17980 * @param {string} string The string to convert. 17981 * @returns {Array} Returns the converted array. 17982 */ 17983 function asciiToArray(string) { 17984 return string.split(''); 17985 } 17986 17987 /** 17988 * Splits an ASCII `string` into an array of its words. 17989 * 17990 * @private 17991 * @param {string} The string to inspect. 17992 * @returns {Array} Returns the words of `string`. 17993 */ 17994 function asciiWords(string) { 17995 return string.match(reAsciiWord) || []; 17996 } 17997 17998 /** 17999 * The base implementation of methods like `_.findKey` and `_.findLastKey`, 18000 * without support for iteratee shorthands, which iterates over `collection` 18001 * using `eachFunc`. 18002 * 18003 * @private 18004 * @param {Array|Object} collection The collection to inspect. 18005 * @param {Function} predicate The function invoked per iteration. 18006 * @param {Function} eachFunc The function to iterate over `collection`. 18007 * @returns {*} Returns the found element or its key, else `undefined`. 18008 */ 18009 function baseFindKey(collection, predicate, eachFunc) { 18010 var result; 18011 eachFunc(collection, function(value, key, collection) { 18012 if (predicate(value, key, collection)) { 18013 result = key; 18014 return false; 18015 } 18016 }); 18017 return result; 18018 } 18019 18020 /** 18021 * The base implementation of `_.findIndex` and `_.findLastIndex` without 18022 * support for iteratee shorthands. 18023 * 18024 * @private 18025 * @param {Array} array The array to inspect. 18026 * @param {Function} predicate The function invoked per iteration. 18027 * @param {number} fromIndex The index to search from. 18028 * @param {boolean} [fromRight] Specify iterating from right to left. 18029 * @returns {number} Returns the index of the matched value, else `-1`. 18030 */ 18031 function baseFindIndex(array, predicate, fromIndex, fromRight) { 18032 var length = array.length, 18033 index = fromIndex + (fromRight ? 1 : -1); 18034 18035 while ((fromRight ? index-- : ++index < length)) { 18036 if (predicate(array[index], index, array)) { 18037 return index; 18038 } 18039 } 18040 return -1; 18041 } 18042 18043 /** 18044 * The base implementation of `_.indexOf` without `fromIndex` bounds checks. 18045 * 18046 * @private 18047 * @param {Array} array The array to inspect. 18048 * @param {*} value The value to search for. 18049 * @param {number} fromIndex The index to search from. 18050 * @returns {number} Returns the index of the matched value, else `-1`. 18051 */ 18052 function baseIndexOf(array, value, fromIndex) { 18053 return value === value 18054 ? strictIndexOf(array, value, fromIndex) 18055 : baseFindIndex(array, baseIsNaN, fromIndex); 18056 } 18057 18058 /** 18059 * This function is like `baseIndexOf` except that it accepts a comparator. 18060 * 18061 * @private 18062 * @param {Array} array The array to inspect. 18063 * @param {*} value The value to search for. 18064 * @param {number} fromIndex The index to search from. 18065 * @param {Function} comparator The comparator invoked per element. 18066 * @returns {number} Returns the index of the matched value, else `-1`. 18067 */ 18068 function baseIndexOfWith(array, value, fromIndex, comparator) { 18069 var index = fromIndex - 1, 18070 length = array.length; 18071 18072 while (++index < length) { 18073 if (comparator(array[index], value)) { 18074 return index; 18075 } 18076 } 18077 return -1; 18078 } 18079 18080 /** 18081 * The base implementation of `_.isNaN` without support for number objects. 18082 * 18083 * @private 18084 * @param {*} value The value to check. 18085 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 18086 */ 18087 function baseIsNaN(value) { 18088 return value !== value; 18089 } 18090 18091 /** 18092 * The base implementation of `_.mean` and `_.meanBy` without support for 18093 * iteratee shorthands. 18094 * 18095 * @private 18096 * @param {Array} array The array to iterate over. 18097 * @param {Function} iteratee The function invoked per iteration. 18098 * @returns {number} Returns the mean. 18099 */ 18100 function baseMean(array, iteratee) { 18101 var length = array == null ? 0 : array.length; 18102 return length ? (baseSum(array, iteratee) / length) : NAN; 18103 } 18104 18105 /** 18106 * The base implementation of `_.property` without support for deep paths. 18107 * 18108 * @private 18109 * @param {string} key The key of the property to get. 18110 * @returns {Function} Returns the new accessor function. 18111 */ 18112 function baseProperty(key) { 18113 return function(object) { 18114 return object == null ? undefined : object[key]; 18115 }; 18116 } 18117 18118 /** 18119 * The base implementation of `_.propertyOf` without support for deep paths. 18120 * 18121 * @private 18122 * @param {Object} object The object to query. 18123 * @returns {Function} Returns the new accessor function. 18124 */ 18125 function basePropertyOf(object) { 18126 return function(key) { 18127 return object == null ? undefined : object[key]; 18128 }; 18129 } 18130 18131 /** 18132 * The base implementation of `_.reduce` and `_.reduceRight`, without support 18133 * for iteratee shorthands, which iterates over `collection` using `eachFunc`. 18134 * 18135 * @private 18136 * @param {Array|Object} collection The collection to iterate over. 18137 * @param {Function} iteratee The function invoked per iteration. 18138 * @param {*} accumulator The initial value. 18139 * @param {boolean} initAccum Specify using the first or last element of 18140 * `collection` as the initial value. 18141 * @param {Function} eachFunc The function to iterate over `collection`. 18142 * @returns {*} Returns the accumulated value. 18143 */ 18144 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { 18145 eachFunc(collection, function(value, index, collection) { 18146 accumulator = initAccum 18147 ? (initAccum = false, value) 18148 : iteratee(accumulator, value, index, collection); 18149 }); 18150 return accumulator; 18151 } 18152 18153 /** 18154 * The base implementation of `_.sortBy` which uses `comparer` to define the 18155 * sort order of `array` and replaces criteria objects with their corresponding 18156 * values. 18157 * 18158 * @private 18159 * @param {Array} array The array to sort. 18160 * @param {Function} comparer The function to define sort order. 18161 * @returns {Array} Returns `array`. 18162 */ 18163 function baseSortBy(array, comparer) { 18164 var length = array.length; 18165 18166 array.sort(comparer); 18167 while (length--) { 18168 array[length] = array[length].value; 18169 } 18170 return array; 18171 } 18172 18173 /** 18174 * The base implementation of `_.sum` and `_.sumBy` without support for 18175 * iteratee shorthands. 18176 * 18177 * @private 18178 * @param {Array} array The array to iterate over. 18179 * @param {Function} iteratee The function invoked per iteration. 18180 * @returns {number} Returns the sum. 18181 */ 18182 function baseSum(array, iteratee) { 18183 var result, 18184 index = -1, 18185 length = array.length; 18186 18187 while (++index < length) { 18188 var current = iteratee(array[index]); 18189 if (current !== undefined) { 18190 result = result === undefined ? current : (result + current); 18191 } 18192 } 18193 return result; 18194 } 18195 18196 /** 18197 * The base implementation of `_.times` without support for iteratee shorthands 18198 * or max array length checks. 18199 * 18200 * @private 18201 * @param {number} n The number of times to invoke `iteratee`. 18202 * @param {Function} iteratee The function invoked per iteration. 18203 * @returns {Array} Returns the array of results. 18204 */ 18205 function baseTimes(n, iteratee) { 18206 var index = -1, 18207 result = Array(n); 18208 18209 while (++index < n) { 18210 result[index] = iteratee(index); 18211 } 18212 return result; 18213 } 18214 18215 /** 18216 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array 18217 * of key-value pairs for `object` corresponding to the property names of `props`. 18218 * 18219 * @private 18220 * @param {Object} object The object to query. 18221 * @param {Array} props The property names to get values for. 18222 * @returns {Object} Returns the key-value pairs. 18223 */ 18224 function baseToPairs(object, props) { 18225 return arrayMap(props, function(key) { 18226 return [key, object[key]]; 18227 }); 18228 } 18229 18230 /** 18231 * The base implementation of `_.unary` without support for storing metadata. 18232 * 18233 * @private 18234 * @param {Function} func The function to cap arguments for. 18235 * @returns {Function} Returns the new capped function. 18236 */ 18237 function baseUnary(func) { 18238 return function(value) { 18239 return func(value); 18240 }; 18241 } 18242 18243 /** 18244 * The base implementation of `_.values` and `_.valuesIn` which creates an 18245 * array of `object` property values corresponding to the property names 18246 * of `props`. 18247 * 18248 * @private 18249 * @param {Object} object The object to query. 18250 * @param {Array} props The property names to get values for. 18251 * @returns {Object} Returns the array of property values. 18252 */ 18253 function baseValues(object, props) { 18254 return arrayMap(props, function(key) { 18255 return object[key]; 18256 }); 18257 } 18258 18259 /** 18260 * Checks if a `cache` value for `key` exists. 18261 * 18262 * @private 18263 * @param {Object} cache The cache to query. 18264 * @param {string} key The key of the entry to check. 18265 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 18266 */ 18267 function cacheHas(cache, key) { 18268 return cache.has(key); 18269 } 18270 18271 /** 18272 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol 18273 * that is not found in the character symbols. 18274 * 18275 * @private 18276 * @param {Array} strSymbols The string symbols to inspect. 18277 * @param {Array} chrSymbols The character symbols to find. 18278 * @returns {number} Returns the index of the first unmatched string symbol. 18279 */ 18280 function charsStartIndex(strSymbols, chrSymbols) { 18281 var index = -1, 18282 length = strSymbols.length; 18283 18284 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 18285 return index; 18286 } 18287 18288 /** 18289 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol 18290 * that is not found in the character symbols. 18291 * 18292 * @private 18293 * @param {Array} strSymbols The string symbols to inspect. 18294 * @param {Array} chrSymbols The character symbols to find. 18295 * @returns {number} Returns the index of the last unmatched string symbol. 18296 */ 18297 function charsEndIndex(strSymbols, chrSymbols) { 18298 var index = strSymbols.length; 18299 18300 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 18301 return index; 18302 } 18303 18304 /** 18305 * Gets the number of `placeholder` occurrences in `array`. 18306 * 18307 * @private 18308 * @param {Array} array The array to inspect. 18309 * @param {*} placeholder The placeholder to search for. 18310 * @returns {number} Returns the placeholder count. 18311 */ 18312 function countHolders(array, placeholder) { 18313 var length = array.length, 18314 result = 0; 18315 18316 while (length--) { 18317 if (array[length] === placeholder) { 18318 ++result; 18319 } 18320 } 18321 return result; 18322 } 18323 18324 /** 18325 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 18326 * letters to basic Latin letters. 18327 * 18328 * @private 18329 * @param {string} letter The matched letter to deburr. 18330 * @returns {string} Returns the deburred letter. 18331 */ 18332 var deburrLetter = basePropertyOf(deburredLetters); 18333 18334 /** 18335 * Used by `_.escape` to convert characters to HTML entities. 18336 * 18337 * @private 18338 * @param {string} chr The matched character to escape. 18339 * @returns {string} Returns the escaped character. 18340 */ 18341 var escapeHtmlChar = basePropertyOf(htmlEscapes); 18342 18343 /** 18344 * Used by `_.template` to escape characters for inclusion in compiled string literals. 18345 * 18346 * @private 18347 * @param {string} chr The matched character to escape. 18348 * @returns {string} Returns the escaped character. 18349 */ 18350 function escapeStringChar(chr) { 18351 return '\\' + stringEscapes[chr]; 18352 } 18353 18354 /** 18355 * Gets the value at `key` of `object`. 18356 * 18357 * @private 18358 * @param {Object} [object] The object to query. 18359 * @param {string} key The key of the property to get. 18360 * @returns {*} Returns the property value. 18361 */ 18362 function getValue(object, key) { 18363 return object == null ? undefined : object[key]; 18364 } 18365 18366 /** 18367 * Checks if `string` contains Unicode symbols. 18368 * 18369 * @private 18370 * @param {string} string The string to inspect. 18371 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 18372 */ 18373 function hasUnicode(string) { 18374 return reHasUnicode.test(string); 18375 } 18376 18377 /** 18378 * Checks if `string` contains a word composed of Unicode symbols. 18379 * 18380 * @private 18381 * @param {string} string The string to inspect. 18382 * @returns {boolean} Returns `true` if a word is found, else `false`. 18383 */ 18384 function hasUnicodeWord(string) { 18385 return reHasUnicodeWord.test(string); 18386 } 18387 18388 /** 18389 * Converts `iterator` to an array. 18390 * 18391 * @private 18392 * @param {Object} iterator The iterator to convert. 18393 * @returns {Array} Returns the converted array. 18394 */ 18395 function iteratorToArray(iterator) { 18396 var data, 18397 result = []; 18398 18399 while (!(data = iterator.next()).done) { 18400 result.push(data.value); 18401 } 18402 return result; 18403 } 18404 18405 /** 18406 * Converts `map` to its key-value pairs. 18407 * 18408 * @private 18409 * @param {Object} map The map to convert. 18410 * @returns {Array} Returns the key-value pairs. 18411 */ 18412 function mapToArray(map) { 18413 var index = -1, 18414 result = Array(map.size); 18415 18416 map.forEach(function(value, key) { 18417 result[++index] = [key, value]; 18418 }); 18419 return result; 18420 } 18421 18422 /** 18423 * Creates a unary function that invokes `func` with its argument transformed. 18424 * 18425 * @private 18426 * @param {Function} func The function to wrap. 18427 * @param {Function} transform The argument transform. 18428 * @returns {Function} Returns the new function. 18429 */ 18430 function overArg(func, transform) { 18431 return function(arg) { 18432 return func(transform(arg)); 18433 }; 18434 } 18435 18436 /** 18437 * Replaces all `placeholder` elements in `array` with an internal placeholder 18438 * and returns an array of their indexes. 18439 * 18440 * @private 18441 * @param {Array} array The array to modify. 18442 * @param {*} placeholder The placeholder to replace. 18443 * @returns {Array} Returns the new array of placeholder indexes. 18444 */ 18445 function replaceHolders(array, placeholder) { 18446 var index = -1, 18447 length = array.length, 18448 resIndex = 0, 18449 result = []; 18450 18451 while (++index < length) { 18452 var value = array[index]; 18453 if (value === placeholder || value === PLACEHOLDER) { 18454 array[index] = PLACEHOLDER; 18455 result[resIndex++] = index; 18456 } 18457 } 18458 return result; 18459 } 18460 18461 /** 18462 * Converts `set` to an array of its values. 18463 * 18464 * @private 18465 * @param {Object} set The set to convert. 18466 * @returns {Array} Returns the values. 18467 */ 18468 function setToArray(set) { 18469 var index = -1, 18470 result = Array(set.size); 18471 18472 set.forEach(function(value) { 18473 result[++index] = value; 18474 }); 18475 return result; 18476 } 18477 18478 /** 18479 * Converts `set` to its value-value pairs. 18480 * 18481 * @private 18482 * @param {Object} set The set to convert. 18483 * @returns {Array} Returns the value-value pairs. 18484 */ 18485 function setToPairs(set) { 18486 var index = -1, 18487 result = Array(set.size); 18488 18489 set.forEach(function(value) { 18490 result[++index] = [value, value]; 18491 }); 18492 return result; 18493 } 18494 18495 /** 18496 * A specialized version of `_.indexOf` which performs strict equality 18497 * comparisons of values, i.e. `===`. 18498 * 18499 * @private 18500 * @param {Array} array The array to inspect. 18501 * @param {*} value The value to search for. 18502 * @param {number} fromIndex The index to search from. 18503 * @returns {number} Returns the index of the matched value, else `-1`. 18504 */ 18505 function strictIndexOf(array, value, fromIndex) { 18506 var index = fromIndex - 1, 18507 length = array.length; 18508 18509 while (++index < length) { 18510 if (array[index] === value) { 18511 return index; 18512 } 18513 } 18514 return -1; 18515 } 18516 18517 /** 18518 * A specialized version of `_.lastIndexOf` which performs strict equality 18519 * comparisons of values, i.e. `===`. 18520 * 18521 * @private 18522 * @param {Array} array The array to inspect. 18523 * @param {*} value The value to search for. 18524 * @param {number} fromIndex The index to search from. 18525 * @returns {number} Returns the index of the matched value, else `-1`. 18526 */ 18527 function strictLastIndexOf(array, value, fromIndex) { 18528 var index = fromIndex + 1; 18529 while (index--) { 18530 if (array[index] === value) { 18531 return index; 18532 } 18533 } 18534 return index; 18535 } 18536 18537 /** 18538 * Gets the number of symbols in `string`. 18539 * 18540 * @private 18541 * @param {string} string The string to inspect. 18542 * @returns {number} Returns the string size. 18543 */ 18544 function stringSize(string) { 18545 return hasUnicode(string) 18546 ? unicodeSize(string) 18547 : asciiSize(string); 18548 } 18549 18550 /** 18551 * Converts `string` to an array. 18552 * 18553 * @private 18554 * @param {string} string The string to convert. 18555 * @returns {Array} Returns the converted array. 18556 */ 18557 function stringToArray(string) { 18558 return hasUnicode(string) 18559 ? unicodeToArray(string) 18560 : asciiToArray(string); 18561 } 18562 18563 /** 18564 * Used by `_.unescape` to convert HTML entities to characters. 18565 * 18566 * @private 18567 * @param {string} chr The matched character to unescape. 18568 * @returns {string} Returns the unescaped character. 18569 */ 18570 var unescapeHtmlChar = basePropertyOf(htmlUnescapes); 18571 18572 /** 18573 * Gets the size of a Unicode `string`. 18574 * 18575 * @private 18576 * @param {string} string The string inspect. 18577 * @returns {number} Returns the string size. 18578 */ 18579 function unicodeSize(string) { 18580 var result = reUnicode.lastIndex = 0; 18581 while (reUnicode.test(string)) { 18582 ++result; 18583 } 18584 return result; 18585 } 18586 18587 /** 18588 * Converts a Unicode `string` to an array. 18589 * 18590 * @private 18591 * @param {string} string The string to convert. 18592 * @returns {Array} Returns the converted array. 18593 */ 18594 function unicodeToArray(string) { 18595 return string.match(reUnicode) || []; 18596 } 18597 18598 /** 18599 * Splits a Unicode `string` into an array of its words. 18600 * 18601 * @private 18602 * @param {string} The string to inspect. 18603 * @returns {Array} Returns the words of `string`. 18604 */ 18605 function unicodeWords(string) { 18606 return string.match(reUnicodeWord) || []; 18607 } 18608 18609 /*--------------------------------------------------------------------------*/ 18610 18611 /** 18612 * Create a new pristine `lodash` function using the `context` object. 18613 * 18614 * @static 18615 * @memberOf _ 18616 * @since 1.1.0 18617 * @category Util 18618 * @param {Object} [context=root] The context object. 18619 * @returns {Function} Returns a new `lodash` function. 18620 * @example 18621 * 18622 * _.mixin({ 'foo': _.constant('foo') }); 18623 * 18624 * var lodash = _.runInContext(); 18625 * lodash.mixin({ 'bar': lodash.constant('bar') }); 18626 * 18627 * _.isFunction(_.foo); 18628 * // => true 18629 * _.isFunction(_.bar); 18630 * // => false 18631 * 18632 * lodash.isFunction(lodash.foo); 18633 * // => false 18634 * lodash.isFunction(lodash.bar); 18635 * // => true 18636 * 18637 * // Create a suped-up `defer` in Node.js. 18638 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; 18639 */ 18640 var runInContext = (function runInContext(context) { 18641 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); 18642 18643 /** Built-in constructor references. */ 18644 var Array = context.Array, 18645 Date = context.Date, 18646 Error = context.Error, 18647 Function = context.Function, 18648 Math = context.Math, 18649 Object = context.Object, 18650 RegExp = context.RegExp, 18651 String = context.String, 18652 TypeError = context.TypeError; 18653 18654 /** Used for built-in method references. */ 18655 var arrayProto = Array.prototype, 18656 funcProto = Function.prototype, 18657 objectProto = Object.prototype; 18658 18659 /** Used to detect overreaching core-js shims. */ 18660 var coreJsData = context['__core-js_shared__']; 18661 18662 /** Used to resolve the decompiled source of functions. */ 18663 var funcToString = funcProto.toString; 18664 18665 /** Used to check objects for own properties. */ 18666 var hasOwnProperty = objectProto.hasOwnProperty; 18667 18668 /** Used to generate unique IDs. */ 18669 var idCounter = 0; 18670 18671 /** Used to detect methods masquerading as native. */ 18672 var maskSrcKey = (function() { 18673 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); 18674 return uid ? ('Symbol(src)_1.' + uid) : ''; 18675 }()); 18676 18677 /** 18678 * Used to resolve the 18679 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 18680 * of values. 18681 */ 18682 var nativeObjectToString = objectProto.toString; 18683 18684 /** Used to infer the `Object` constructor. */ 18685 var objectCtorString = funcToString.call(Object); 18686 18687 /** Used to restore the original `_` reference in `_.noConflict`. */ 18688 var oldDash = root._; 18689 18690 /** Used to detect if a method is native. */ 18691 var reIsNative = RegExp('^' + 18692 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') 18693 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 18694 ); 18695 18696 /** Built-in value references. */ 18697 var Buffer = moduleExports ? context.Buffer : undefined, 18698 Symbol = context.Symbol, 18699 Uint8Array = context.Uint8Array, 18700 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, 18701 getPrototype = overArg(Object.getPrototypeOf, Object), 18702 objectCreate = Object.create, 18703 propertyIsEnumerable = objectProto.propertyIsEnumerable, 18704 splice = arrayProto.splice, 18705 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, 18706 symIterator = Symbol ? Symbol.iterator : undefined, 18707 symToStringTag = Symbol ? Symbol.toStringTag : undefined; 18708 18709 var defineProperty = (function() { 18710 try { 18711 var func = getNative(Object, 'defineProperty'); 18712 func({}, '', {}); 18713 return func; 18714 } catch (e) {} 18715 }()); 18716 18717 /** Mocked built-ins. */ 18718 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, 18719 ctxNow = Date && Date.now !== root.Date.now && Date.now, 18720 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; 18721 18722 /* Built-in method references for those with the same name as other `lodash` methods. */ 18723 var nativeCeil = Math.ceil, 18724 nativeFloor = Math.floor, 18725 nativeGetSymbols = Object.getOwnPropertySymbols, 18726 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, 18727 nativeIsFinite = context.isFinite, 18728 nativeJoin = arrayProto.join, 18729 nativeKeys = overArg(Object.keys, Object), 18730 nativeMax = Math.max, 18731 nativeMin = Math.min, 18732 nativeNow = Date.now, 18733 nativeParseInt = context.parseInt, 18734 nativeRandom = Math.random, 18735 nativeReverse = arrayProto.reverse; 18736 18737 /* Built-in method references that are verified to be native. */ 18738 var DataView = getNative(context, 'DataView'), 18739 Map = getNative(context, 'Map'), 18740 Promise = getNative(context, 'Promise'), 18741 Set = getNative(context, 'Set'), 18742 WeakMap = getNative(context, 'WeakMap'), 18743 nativeCreate = getNative(Object, 'create'); 18744 18745 /** Used to store function metadata. */ 18746 var metaMap = WeakMap && new WeakMap; 18747 18748 /** Used to lookup unminified function names. */ 18749 var realNames = {}; 18750 18751 /** Used to detect maps, sets, and weakmaps. */ 18752 var dataViewCtorString = toSource(DataView), 18753 mapCtorString = toSource(Map), 18754 promiseCtorString = toSource(Promise), 18755 setCtorString = toSource(Set), 18756 weakMapCtorString = toSource(WeakMap); 18757 18758 /** Used to convert symbols to primitives and strings. */ 18759 var symbolProto = Symbol ? Symbol.prototype : undefined, 18760 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, 18761 symbolToString = symbolProto ? symbolProto.toString : undefined; 18762 18763 /*------------------------------------------------------------------------*/ 18764 18765 /** 18766 * Creates a `lodash` object which wraps `value` to enable implicit method 18767 * chain sequences. Methods that operate on and return arrays, collections, 18768 * and functions can be chained together. Methods that retrieve a single value 18769 * or may return a primitive value will automatically end the chain sequence 18770 * and return the unwrapped value. Otherwise, the value must be unwrapped 18771 * with `_#value`. 18772 * 18773 * Explicit chain sequences, which must be unwrapped with `_#value`, may be 18774 * enabled using `_.chain`. 18775 * 18776 * The execution of chained methods is lazy, that is, it's deferred until 18777 * `_#value` is implicitly or explicitly called. 18778 * 18779 * Lazy evaluation allows several methods to support shortcut fusion. 18780 * Shortcut fusion is an optimization to merge iteratee calls; this avoids 18781 * the creation of intermediate arrays and can greatly reduce the number of 18782 * iteratee executions. Sections of a chain sequence qualify for shortcut 18783 * fusion if the section is applied to an array and iteratees accept only 18784 * one argument. The heuristic for whether a section qualifies for shortcut 18785 * fusion is subject to change. 18786 * 18787 * Chaining is supported in custom builds as long as the `_#value` method is 18788 * directly or indirectly included in the build. 18789 * 18790 * In addition to lodash methods, wrappers have `Array` and `String` methods. 18791 * 18792 * The wrapper `Array` methods are: 18793 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` 18794 * 18795 * The wrapper `String` methods are: 18796 * `replace` and `split` 18797 * 18798 * The wrapper methods that support shortcut fusion are: 18799 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, 18800 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, 18801 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` 18802 * 18803 * The chainable wrapper methods are: 18804 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, 18805 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, 18806 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, 18807 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, 18808 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, 18809 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, 18810 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, 18811 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, 18812 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, 18813 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, 18814 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, 18815 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, 18816 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, 18817 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, 18818 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, 18819 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, 18820 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, 18821 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, 18822 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, 18823 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, 18824 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, 18825 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, 18826 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, 18827 * `zipObject`, `zipObjectDeep`, and `zipWith` 18828 * 18829 * The wrapper methods that are **not** chainable by default are: 18830 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, 18831 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, 18832 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, 18833 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, 18834 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, 18835 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, 18836 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, 18837 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, 18838 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, 18839 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, 18840 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, 18841 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, 18842 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, 18843 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, 18844 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, 18845 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, 18846 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, 18847 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, 18848 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, 18849 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, 18850 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, 18851 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, 18852 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, 18853 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, 18854 * `upperFirst`, `value`, and `words` 18855 * 18856 * @name _ 18857 * @constructor 18858 * @category Seq 18859 * @param {*} value The value to wrap in a `lodash` instance. 18860 * @returns {Object} Returns the new `lodash` wrapper instance. 18861 * @example 18862 * 18863 * function square(n) { 18864 * return n * n; 18865 * } 18866 * 18867 * var wrapped = _([1, 2, 3]); 18868 * 18869 * // Returns an unwrapped value. 18870 * wrapped.reduce(_.add); 18871 * // => 6 18872 * 18873 * // Returns a wrapped value. 18874 * var squares = wrapped.map(square); 18875 * 18876 * _.isArray(squares); 18877 * // => false 18878 * 18879 * _.isArray(squares.value()); 18880 * // => true 18881 */ 18882 function lodash(value) { 18883 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { 18884 if (value instanceof LodashWrapper) { 18885 return value; 18886 } 18887 if (hasOwnProperty.call(value, '__wrapped__')) { 18888 return wrapperClone(value); 18889 } 18890 } 18891 return new LodashWrapper(value); 18892 } 18893 18894 /** 18895 * The base implementation of `_.create` without support for assigning 18896 * properties to the created object. 18897 * 18898 * @private 18899 * @param {Object} proto The object to inherit from. 18900 * @returns {Object} Returns the new object. 18901 */ 18902 var baseCreate = (function() { 18903 function object() {} 18904 return function(proto) { 18905 if (!isObject(proto)) { 18906 return {}; 18907 } 18908 if (objectCreate) { 18909 return objectCreate(proto); 18910 } 18911 object.prototype = proto; 18912 var result = new object; 18913 object.prototype = undefined; 18914 return result; 18915 }; 18916 }()); 18917 18918 /** 18919 * The function whose prototype chain sequence wrappers inherit from. 18920 * 18921 * @private 18922 */ 18923 function baseLodash() { 18924 // No operation performed. 18925 } 18926 18927 /** 18928 * The base constructor for creating `lodash` wrapper objects. 18929 * 18930 * @private 18931 * @param {*} value The value to wrap. 18932 * @param {boolean} [chainAll] Enable explicit method chain sequences. 18933 */ 18934 function LodashWrapper(value, chainAll) { 18935 this.__wrapped__ = value; 18936 this.__actions__ = []; 18937 this.__chain__ = !!chainAll; 18938 this.__index__ = 0; 18939 this.__values__ = undefined; 18940 } 18941 18942 /** 18943 * By default, the template delimiters used by lodash are like those in 18944 * embedded Ruby (ERB) as well as ES2015 template strings. Change the 18945 * following template settings to use alternative delimiters. 18946 * 18947 * @static 18948 * @memberOf _ 18949 * @type {Object} 18950 */ 18951 lodash.templateSettings = { 18952 18953 /** 18954 * Used to detect `data` property values to be HTML-escaped. 18955 * 18956 * @memberOf _.templateSettings 18957 * @type {RegExp} 18958 */ 18959 'escape': reEscape, 18960 18961 /** 18962 * Used to detect code to be evaluated. 18963 * 18964 * @memberOf _.templateSettings 18965 * @type {RegExp} 18966 */ 18967 'evaluate': reEvaluate, 18968 18969 /** 18970 * Used to detect `data` property values to inject. 18971 * 18972 * @memberOf _.templateSettings 18973 * @type {RegExp} 18974 */ 18975 'interpolate': reInterpolate, 18976 18977 /** 18978 * Used to reference the data object in the template text. 18979 * 18980 * @memberOf _.templateSettings 18981 * @type {string} 18982 */ 18983 'variable': '', 18984 18985 /** 18986 * Used to import variables into the compiled template. 18987 * 18988 * @memberOf _.templateSettings 18989 * @type {Object} 18990 */ 18991 'imports': { 18992 18993 /** 18994 * A reference to the `lodash` function. 18995 * 18996 * @memberOf _.templateSettings.imports 18997 * @type {Function} 18998 */ 18999 '_': lodash 19000 } 19001 }; 19002 19003 // Ensure wrappers are instances of `baseLodash`. 19004 lodash.prototype = baseLodash.prototype; 19005 lodash.prototype.constructor = lodash; 19006 19007 LodashWrapper.prototype = baseCreate(baseLodash.prototype); 19008 LodashWrapper.prototype.constructor = LodashWrapper; 19009 19010 /*------------------------------------------------------------------------*/ 19011 19012 /** 19013 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. 19014 * 19015 * @private 19016 * @constructor 19017 * @param {*} value The value to wrap. 19018 */ 19019 function LazyWrapper(value) { 19020 this.__wrapped__ = value; 19021 this.__actions__ = []; 19022 this.__dir__ = 1; 19023 this.__filtered__ = false; 19024 this.__iteratees__ = []; 19025 this.__takeCount__ = MAX_ARRAY_LENGTH; 19026 this.__views__ = []; 19027 } 19028 19029 /** 19030 * Creates a clone of the lazy wrapper object. 19031 * 19032 * @private 19033 * @name clone 19034 * @memberOf LazyWrapper 19035 * @returns {Object} Returns the cloned `LazyWrapper` object. 19036 */ 19037 function lazyClone() { 19038 var result = new LazyWrapper(this.__wrapped__); 19039 result.__actions__ = copyArray(this.__actions__); 19040 result.__dir__ = this.__dir__; 19041 result.__filtered__ = this.__filtered__; 19042 result.__iteratees__ = copyArray(this.__iteratees__); 19043 result.__takeCount__ = this.__takeCount__; 19044 result.__views__ = copyArray(this.__views__); 19045 return result; 19046 } 19047 19048 /** 19049 * Reverses the direction of lazy iteration. 19050 * 19051 * @private 19052 * @name reverse 19053 * @memberOf LazyWrapper 19054 * @returns {Object} Returns the new reversed `LazyWrapper` object. 19055 */ 19056 function lazyReverse() { 19057 if (this.__filtered__) { 19058 var result = new LazyWrapper(this); 19059 result.__dir__ = -1; 19060 result.__filtered__ = true; 19061 } else { 19062 result = this.clone(); 19063 result.__dir__ *= -1; 19064 } 19065 return result; 19066 } 19067 19068 /** 19069 * Extracts the unwrapped value from its lazy wrapper. 19070 * 19071 * @private 19072 * @name value 19073 * @memberOf LazyWrapper 19074 * @returns {*} Returns the unwrapped value. 19075 */ 19076 function lazyValue() { 19077 var array = this.__wrapped__.value(), 19078 dir = this.__dir__, 19079 isArr = isArray(array), 19080 isRight = dir < 0, 19081 arrLength = isArr ? array.length : 0, 19082 view = getView(0, arrLength, this.__views__), 19083 start = view.start, 19084 end = view.end, 19085 length = end - start, 19086 index = isRight ? end : (start - 1), 19087 iteratees = this.__iteratees__, 19088 iterLength = iteratees.length, 19089 resIndex = 0, 19090 takeCount = nativeMin(length, this.__takeCount__); 19091 19092 if (!isArr || (!isRight && arrLength == length && takeCount == length)) { 19093 return baseWrapperValue(array, this.__actions__); 19094 } 19095 var result = []; 19096 19097 outer: 19098 while (length-- && resIndex < takeCount) { 19099 index += dir; 19100 19101 var iterIndex = -1, 19102 value = array[index]; 19103 19104 while (++iterIndex < iterLength) { 19105 var data = iteratees[iterIndex], 19106 iteratee = data.iteratee, 19107 type = data.type, 19108 computed = iteratee(value); 19109 19110 if (type == LAZY_MAP_FLAG) { 19111 value = computed; 19112 } else if (!computed) { 19113 if (type == LAZY_FILTER_FLAG) { 19114 continue outer; 19115 } else { 19116 break outer; 19117 } 19118 } 19119 } 19120 result[resIndex++] = value; 19121 } 19122 return result; 19123 } 19124 19125 // Ensure `LazyWrapper` is an instance of `baseLodash`. 19126 LazyWrapper.prototype = baseCreate(baseLodash.prototype); 19127 LazyWrapper.prototype.constructor = LazyWrapper; 19128 19129 /*------------------------------------------------------------------------*/ 19130 19131 /** 19132 * Creates a hash object. 19133 * 19134 * @private 19135 * @constructor 19136 * @param {Array} [entries] The key-value pairs to cache. 19137 */ 19138 function Hash(entries) { 19139 var index = -1, 19140 length = entries == null ? 0 : entries.length; 19141 19142 this.clear(); 19143 while (++index < length) { 19144 var entry = entries[index]; 19145 this.set(entry[0], entry[1]); 19146 } 19147 } 19148 19149 /** 19150 * Removes all key-value entries from the hash. 19151 * 19152 * @private 19153 * @name clear 19154 * @memberOf Hash 19155 */ 19156 function hashClear() { 19157 this.__data__ = nativeCreate ? nativeCreate(null) : {}; 19158 this.size = 0; 19159 } 19160 19161 /** 19162 * Removes `key` and its value from the hash. 19163 * 19164 * @private 19165 * @name delete 19166 * @memberOf Hash 19167 * @param {Object} hash The hash to modify. 19168 * @param {string} key The key of the value to remove. 19169 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 19170 */ 19171 function hashDelete(key) { 19172 var result = this.has(key) && delete this.__data__[key]; 19173 this.size -= result ? 1 : 0; 19174 return result; 19175 } 19176 19177 /** 19178 * Gets the hash value for `key`. 19179 * 19180 * @private 19181 * @name get 19182 * @memberOf Hash 19183 * @param {string} key The key of the value to get. 19184 * @returns {*} Returns the entry value. 19185 */ 19186 function hashGet(key) { 19187 var data = this.__data__; 19188 if (nativeCreate) { 19189 var result = data[key]; 19190 return result === HASH_UNDEFINED ? undefined : result; 19191 } 19192 return hasOwnProperty.call(data, key) ? data[key] : undefined; 19193 } 19194 19195 /** 19196 * Checks if a hash value for `key` exists. 19197 * 19198 * @private 19199 * @name has 19200 * @memberOf Hash 19201 * @param {string} key The key of the entry to check. 19202 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 19203 */ 19204 function hashHas(key) { 19205 var data = this.__data__; 19206 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); 19207 } 19208 19209 /** 19210 * Sets the hash `key` to `value`. 19211 * 19212 * @private 19213 * @name set 19214 * @memberOf Hash 19215 * @param {string} key The key of the value to set. 19216 * @param {*} value The value to set. 19217 * @returns {Object} Returns the hash instance. 19218 */ 19219 function hashSet(key, value) { 19220 var data = this.__data__; 19221 this.size += this.has(key) ? 0 : 1; 19222 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; 19223 return this; 19224 } 19225 19226 // Add methods to `Hash`. 19227 Hash.prototype.clear = hashClear; 19228 Hash.prototype['delete'] = hashDelete; 19229 Hash.prototype.get = hashGet; 19230 Hash.prototype.has = hashHas; 19231 Hash.prototype.set = hashSet; 19232 19233 /*------------------------------------------------------------------------*/ 19234 19235 /** 19236 * Creates an list cache object. 19237 * 19238 * @private 19239 * @constructor 19240 * @param {Array} [entries] The key-value pairs to cache. 19241 */ 19242 function ListCache(entries) { 19243 var index = -1, 19244 length = entries == null ? 0 : entries.length; 19245 19246 this.clear(); 19247 while (++index < length) { 19248 var entry = entries[index]; 19249 this.set(entry[0], entry[1]); 19250 } 19251 } 19252 19253 /** 19254 * Removes all key-value entries from the list cache. 19255 * 19256 * @private 19257 * @name clear 19258 * @memberOf ListCache 19259 */ 19260 function listCacheClear() { 19261 this.__data__ = []; 19262 this.size = 0; 19263 } 19264 19265 /** 19266 * Removes `key` and its value from the list cache. 19267 * 19268 * @private 19269 * @name delete 19270 * @memberOf ListCache 19271 * @param {string} key The key of the value to remove. 19272 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 19273 */ 19274 function listCacheDelete(key) { 19275 var data = this.__data__, 19276 index = assocIndexOf(data, key); 19277 19278 if (index < 0) { 19279 return false; 19280 } 19281 var lastIndex = data.length - 1; 19282 if (index == lastIndex) { 19283 data.pop(); 19284 } else { 19285 splice.call(data, index, 1); 19286 } 19287 --this.size; 19288 return true; 19289 } 19290 19291 /** 19292 * Gets the list cache value for `key`. 19293 * 19294 * @private 19295 * @name get 19296 * @memberOf ListCache 19297 * @param {string} key The key of the value to get. 19298 * @returns {*} Returns the entry value. 19299 */ 19300 function listCacheGet(key) { 19301 var data = this.__data__, 19302 index = assocIndexOf(data, key); 19303 19304 return index < 0 ? undefined : data[index][1]; 19305 } 19306 19307 /** 19308 * Checks if a list cache value for `key` exists. 19309 * 19310 * @private 19311 * @name has 19312 * @memberOf ListCache 19313 * @param {string} key The key of the entry to check. 19314 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 19315 */ 19316 function listCacheHas(key) { 19317 return assocIndexOf(this.__data__, key) > -1; 19318 } 19319 19320 /** 19321 * Sets the list cache `key` to `value`. 19322 * 19323 * @private 19324 * @name set 19325 * @memberOf ListCache 19326 * @param {string} key The key of the value to set. 19327 * @param {*} value The value to set. 19328 * @returns {Object} Returns the list cache instance. 19329 */ 19330 function listCacheSet(key, value) { 19331 var data = this.__data__, 19332 index = assocIndexOf(data, key); 19333 19334 if (index < 0) { 19335 ++this.size; 19336 data.push([key, value]); 19337 } else { 19338 data[index][1] = value; 19339 } 19340 return this; 19341 } 19342 19343 // Add methods to `ListCache`. 19344 ListCache.prototype.clear = listCacheClear; 19345 ListCache.prototype['delete'] = listCacheDelete; 19346 ListCache.prototype.get = listCacheGet; 19347 ListCache.prototype.has = listCacheHas; 19348 ListCache.prototype.set = listCacheSet; 19349 19350 /*------------------------------------------------------------------------*/ 19351 19352 /** 19353 * Creates a map cache object to store key-value pairs. 19354 * 19355 * @private 19356 * @constructor 19357 * @param {Array} [entries] The key-value pairs to cache. 19358 */ 19359 function MapCache(entries) { 19360 var index = -1, 19361 length = entries == null ? 0 : entries.length; 19362 19363 this.clear(); 19364 while (++index < length) { 19365 var entry = entries[index]; 19366 this.set(entry[0], entry[1]); 19367 } 19368 } 19369 19370 /** 19371 * Removes all key-value entries from the map. 19372 * 19373 * @private 19374 * @name clear 19375 * @memberOf MapCache 19376 */ 19377 function mapCacheClear() { 19378 this.size = 0; 19379 this.__data__ = { 19380 'hash': new Hash, 19381 'map': new (Map || ListCache), 19382 'string': new Hash 19383 }; 19384 } 19385 19386 /** 19387 * Removes `key` and its value from the map. 19388 * 19389 * @private 19390 * @name delete 19391 * @memberOf MapCache 19392 * @param {string} key The key of the value to remove. 19393 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 19394 */ 19395 function mapCacheDelete(key) { 19396 var result = getMapData(this, key)['delete'](key); 19397 this.size -= result ? 1 : 0; 19398 return result; 19399 } 19400 19401 /** 19402 * Gets the map value for `key`. 19403 * 19404 * @private 19405 * @name get 19406 * @memberOf MapCache 19407 * @param {string} key The key of the value to get. 19408 * @returns {*} Returns the entry value. 19409 */ 19410 function mapCacheGet(key) { 19411 return getMapData(this, key).get(key); 19412 } 19413 19414 /** 19415 * Checks if a map value for `key` exists. 19416 * 19417 * @private 19418 * @name has 19419 * @memberOf MapCache 19420 * @param {string} key The key of the entry to check. 19421 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 19422 */ 19423 function mapCacheHas(key) { 19424 return getMapData(this, key).has(key); 19425 } 19426 19427 /** 19428 * Sets the map `key` to `value`. 19429 * 19430 * @private 19431 * @name set 19432 * @memberOf MapCache 19433 * @param {string} key The key of the value to set. 19434 * @param {*} value The value to set. 19435 * @returns {Object} Returns the map cache instance. 19436 */ 19437 function mapCacheSet(key, value) { 19438 var data = getMapData(this, key), 19439 size = data.size; 19440 19441 data.set(key, value); 19442 this.size += data.size == size ? 0 : 1; 19443 return this; 19444 } 19445 19446 // Add methods to `MapCache`. 19447 MapCache.prototype.clear = mapCacheClear; 19448 MapCache.prototype['delete'] = mapCacheDelete; 19449 MapCache.prototype.get = mapCacheGet; 19450 MapCache.prototype.has = mapCacheHas; 19451 MapCache.prototype.set = mapCacheSet; 19452 19453 /*------------------------------------------------------------------------*/ 19454 19455 /** 19456 * 19457 * Creates an array cache object to store unique values. 19458 * 19459 * @private 19460 * @constructor 19461 * @param {Array} [values] The values to cache. 19462 */ 19463 function SetCache(values) { 19464 var index = -1, 19465 length = values == null ? 0 : values.length; 19466 19467 this.__data__ = new MapCache; 19468 while (++index < length) { 19469 this.add(values[index]); 19470 } 19471 } 19472 19473 /** 19474 * Adds `value` to the array cache. 19475 * 19476 * @private 19477 * @name add 19478 * @memberOf SetCache 19479 * @alias push 19480 * @param {*} value The value to cache. 19481 * @returns {Object} Returns the cache instance. 19482 */ 19483 function setCacheAdd(value) { 19484 this.__data__.set(value, HASH_UNDEFINED); 19485 return this; 19486 } 19487 19488 /** 19489 * Checks if `value` is in the array cache. 19490 * 19491 * @private 19492 * @name has 19493 * @memberOf SetCache 19494 * @param {*} value The value to search for. 19495 * @returns {number} Returns `true` if `value` is found, else `false`. 19496 */ 19497 function setCacheHas(value) { 19498 return this.__data__.has(value); 19499 } 19500 19501 // Add methods to `SetCache`. 19502 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; 19503 SetCache.prototype.has = setCacheHas; 19504 19505 /*------------------------------------------------------------------------*/ 19506 19507 /** 19508 * Creates a stack cache object to store key-value pairs. 19509 * 19510 * @private 19511 * @constructor 19512 * @param {Array} [entries] The key-value pairs to cache. 19513 */ 19514 function Stack(entries) { 19515 var data = this.__data__ = new ListCache(entries); 19516 this.size = data.size; 19517 } 19518 19519 /** 19520 * Removes all key-value entries from the stack. 19521 * 19522 * @private 19523 * @name clear 19524 * @memberOf Stack 19525 */ 19526 function stackClear() { 19527 this.__data__ = new ListCache; 19528 this.size = 0; 19529 } 19530 19531 /** 19532 * Removes `key` and its value from the stack. 19533 * 19534 * @private 19535 * @name delete 19536 * @memberOf Stack 19537 * @param {string} key The key of the value to remove. 19538 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 19539 */ 19540 function stackDelete(key) { 19541 var data = this.__data__, 19542 result = data['delete'](key); 19543 19544 this.size = data.size; 19545 return result; 19546 } 19547 19548 /** 19549 * Gets the stack value for `key`. 19550 * 19551 * @private 19552 * @name get 19553 * @memberOf Stack 19554 * @param {string} key The key of the value to get. 19555 * @returns {*} Returns the entry value. 19556 */ 19557 function stackGet(key) { 19558 return this.__data__.get(key); 19559 } 19560 19561 /** 19562 * Checks if a stack value for `key` exists. 19563 * 19564 * @private 19565 * @name has 19566 * @memberOf Stack 19567 * @param {string} key The key of the entry to check. 19568 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 19569 */ 19570 function stackHas(key) { 19571 return this.__data__.has(key); 19572 } 19573 19574 /** 19575 * Sets the stack `key` to `value`. 19576 * 19577 * @private 19578 * @name set 19579 * @memberOf Stack 19580 * @param {string} key The key of the value to set. 19581 * @param {*} value The value to set. 19582 * @returns {Object} Returns the stack cache instance. 19583 */ 19584 function stackSet(key, value) { 19585 var data = this.__data__; 19586 if (data instanceof ListCache) { 19587 var pairs = data.__data__; 19588 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 19589 pairs.push([key, value]); 19590 this.size = ++data.size; 19591 return this; 19592 } 19593 data = this.__data__ = new MapCache(pairs); 19594 } 19595 data.set(key, value); 19596 this.size = data.size; 19597 return this; 19598 } 19599 19600 // Add methods to `Stack`. 19601 Stack.prototype.clear = stackClear; 19602 Stack.prototype['delete'] = stackDelete; 19603 Stack.prototype.get = stackGet; 19604 Stack.prototype.has = stackHas; 19605 Stack.prototype.set = stackSet; 19606 19607 /*------------------------------------------------------------------------*/ 19608 19609 /** 19610 * Creates an array of the enumerable property names of the array-like `value`. 19611 * 19612 * @private 19613 * @param {*} value The value to query. 19614 * @param {boolean} inherited Specify returning inherited property names. 19615 * @returns {Array} Returns the array of property names. 19616 */ 19617 function arrayLikeKeys(value, inherited) { 19618 var isArr = isArray(value), 19619 isArg = !isArr && isArguments(value), 19620 isBuff = !isArr && !isArg && isBuffer(value), 19621 isType = !isArr && !isArg && !isBuff && isTypedArray(value), 19622 skipIndexes = isArr || isArg || isBuff || isType, 19623 result = skipIndexes ? baseTimes(value.length, String) : [], 19624 length = result.length; 19625 19626 for (var key in value) { 19627 if ((inherited || hasOwnProperty.call(value, key)) && 19628 !(skipIndexes && ( 19629 // Safari 9 has enumerable `arguments.length` in strict mode. 19630 key == 'length' || 19631 // Node.js 0.10 has enumerable non-index properties on buffers. 19632 (isBuff && (key == 'offset' || key == 'parent')) || 19633 // PhantomJS 2 has enumerable non-index properties on typed arrays. 19634 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 19635 // Skip index properties. 19636 isIndex(key, length) 19637 ))) { 19638 result.push(key); 19639 } 19640 } 19641 return result; 19642 } 19643 19644 /** 19645 * A specialized version of `_.sample` for arrays. 19646 * 19647 * @private 19648 * @param {Array} array The array to sample. 19649 * @returns {*} Returns the random element. 19650 */ 19651 function arraySample(array) { 19652 var length = array.length; 19653 return length ? array[baseRandom(0, length - 1)] : undefined; 19654 } 19655 19656 /** 19657 * A specialized version of `_.sampleSize` for arrays. 19658 * 19659 * @private 19660 * @param {Array} array The array to sample. 19661 * @param {number} n The number of elements to sample. 19662 * @returns {Array} Returns the random elements. 19663 */ 19664 function arraySampleSize(array, n) { 19665 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); 19666 } 19667 19668 /** 19669 * A specialized version of `_.shuffle` for arrays. 19670 * 19671 * @private 19672 * @param {Array} array The array to shuffle. 19673 * @returns {Array} Returns the new shuffled array. 19674 */ 19675 function arrayShuffle(array) { 19676 return shuffleSelf(copyArray(array)); 19677 } 19678 19679 /** 19680 * This function is like `assignValue` except that it doesn't assign 19681 * `undefined` values. 19682 * 19683 * @private 19684 * @param {Object} object The object to modify. 19685 * @param {string} key The key of the property to assign. 19686 * @param {*} value The value to assign. 19687 */ 19688 function assignMergeValue(object, key, value) { 19689 if ((value !== undefined && !eq(object[key], value)) || 19690 (value === undefined && !(key in object))) { 19691 baseAssignValue(object, key, value); 19692 } 19693 } 19694 19695 /** 19696 * Assigns `value` to `key` of `object` if the existing value is not equivalent 19697 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 19698 * for equality comparisons. 19699 * 19700 * @private 19701 * @param {Object} object The object to modify. 19702 * @param {string} key The key of the property to assign. 19703 * @param {*} value The value to assign. 19704 */ 19705 function assignValue(object, key, value) { 19706 var objValue = object[key]; 19707 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || 19708 (value === undefined && !(key in object))) { 19709 baseAssignValue(object, key, value); 19710 } 19711 } 19712 19713 /** 19714 * Gets the index at which the `key` is found in `array` of key-value pairs. 19715 * 19716 * @private 19717 * @param {Array} array The array to inspect. 19718 * @param {*} key The key to search for. 19719 * @returns {number} Returns the index of the matched value, else `-1`. 19720 */ 19721 function assocIndexOf(array, key) { 19722 var length = array.length; 19723 while (length--) { 19724 if (eq(array[length][0], key)) { 19725 return length; 19726 } 19727 } 19728 return -1; 19729 } 19730 19731 /** 19732 * Aggregates elements of `collection` on `accumulator` with keys transformed 19733 * by `iteratee` and values set by `setter`. 19734 * 19735 * @private 19736 * @param {Array|Object} collection The collection to iterate over. 19737 * @param {Function} setter The function to set `accumulator` values. 19738 * @param {Function} iteratee The iteratee to transform keys. 19739 * @param {Object} accumulator The initial aggregated object. 19740 * @returns {Function} Returns `accumulator`. 19741 */ 19742 function baseAggregator(collection, setter, iteratee, accumulator) { 19743 baseEach(collection, function(value, key, collection) { 19744 setter(accumulator, value, iteratee(value), collection); 19745 }); 19746 return accumulator; 19747 } 19748 19749 /** 19750 * The base implementation of `_.assign` without support for multiple sources 19751 * or `customizer` functions. 19752 * 19753 * @private 19754 * @param {Object} object The destination object. 19755 * @param {Object} source The source object. 19756 * @returns {Object} Returns `object`. 19757 */ 19758 function baseAssign(object, source) { 19759 return object && copyObject(source, keys(source), object); 19760 } 19761 19762 /** 19763 * The base implementation of `_.assignIn` without support for multiple sources 19764 * or `customizer` functions. 19765 * 19766 * @private 19767 * @param {Object} object The destination object. 19768 * @param {Object} source The source object. 19769 * @returns {Object} Returns `object`. 19770 */ 19771 function baseAssignIn(object, source) { 19772 return object && copyObject(source, keysIn(source), object); 19773 } 19774 19775 /** 19776 * The base implementation of `assignValue` and `assignMergeValue` without 19777 * value checks. 19778 * 19779 * @private 19780 * @param {Object} object The object to modify. 19781 * @param {string} key The key of the property to assign. 19782 * @param {*} value The value to assign. 19783 */ 19784 function baseAssignValue(object, key, value) { 19785 if (key == '__proto__' && defineProperty) { 19786 defineProperty(object, key, { 19787 'configurable': true, 19788 'enumerable': true, 19789 'value': value, 19790 'writable': true 19791 }); 19792 } else { 19793 object[key] = value; 19794 } 19795 } 19796 19797 /** 19798 * The base implementation of `_.at` without support for individual paths. 19799 * 19800 * @private 19801 * @param {Object} object The object to iterate over. 19802 * @param {string[]} paths The property paths to pick. 19803 * @returns {Array} Returns the picked elements. 19804 */ 19805 function baseAt(object, paths) { 19806 var index = -1, 19807 length = paths.length, 19808 result = Array(length), 19809 skip = object == null; 19810 19811 while (++index < length) { 19812 result[index] = skip ? undefined : get(object, paths[index]); 19813 } 19814 return result; 19815 } 19816 19817 /** 19818 * The base implementation of `_.clamp` which doesn't coerce arguments. 19819 * 19820 * @private 19821 * @param {number} number The number to clamp. 19822 * @param {number} [lower] The lower bound. 19823 * @param {number} upper The upper bound. 19824 * @returns {number} Returns the clamped number. 19825 */ 19826 function baseClamp(number, lower, upper) { 19827 if (number === number) { 19828 if (upper !== undefined) { 19829 number = number <= upper ? number : upper; 19830 } 19831 if (lower !== undefined) { 19832 number = number >= lower ? number : lower; 19833 } 19834 } 19835 return number; 19836 } 19837 19838 /** 19839 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 19840 * traversed objects. 19841 * 19842 * @private 19843 * @param {*} value The value to clone. 19844 * @param {boolean} bitmask The bitmask flags. 19845 * 1 - Deep clone 19846 * 2 - Flatten inherited properties 19847 * 4 - Clone symbols 19848 * @param {Function} [customizer] The function to customize cloning. 19849 * @param {string} [key] The key of `value`. 19850 * @param {Object} [object] The parent object of `value`. 19851 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 19852 * @returns {*} Returns the cloned value. 19853 */ 19854 function baseClone(value, bitmask, customizer, key, object, stack) { 19855 var result, 19856 isDeep = bitmask & CLONE_DEEP_FLAG, 19857 isFlat = bitmask & CLONE_FLAT_FLAG, 19858 isFull = bitmask & CLONE_SYMBOLS_FLAG; 19859 19860 if (customizer) { 19861 result = object ? customizer(value, key, object, stack) : customizer(value); 19862 } 19863 if (result !== undefined) { 19864 return result; 19865 } 19866 if (!isObject(value)) { 19867 return value; 19868 } 19869 var isArr = isArray(value); 19870 if (isArr) { 19871 result = initCloneArray(value); 19872 if (!isDeep) { 19873 return copyArray(value, result); 19874 } 19875 } else { 19876 var tag = getTag(value), 19877 isFunc = tag == funcTag || tag == genTag; 19878 19879 if (isBuffer(value)) { 19880 return cloneBuffer(value, isDeep); 19881 } 19882 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 19883 result = (isFlat || isFunc) ? {} : initCloneObject(value); 19884 if (!isDeep) { 19885 return isFlat 19886 ? copySymbolsIn(value, baseAssignIn(result, value)) 19887 : copySymbols(value, baseAssign(result, value)); 19888 } 19889 } else { 19890 if (!cloneableTags[tag]) { 19891 return object ? value : {}; 19892 } 19893 result = initCloneByTag(value, tag, isDeep); 19894 } 19895 } 19896 // Check for circular references and return its corresponding clone. 19897 stack || (stack = new Stack); 19898 var stacked = stack.get(value); 19899 if (stacked) { 19900 return stacked; 19901 } 19902 stack.set(value, result); 19903 19904 if (isSet(value)) { 19905 value.forEach(function(subValue) { 19906 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); 19907 }); 19908 } else if (isMap(value)) { 19909 value.forEach(function(subValue, key) { 19910 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); 19911 }); 19912 } 19913 19914 var keysFunc = isFull 19915 ? (isFlat ? getAllKeysIn : getAllKeys) 19916 : (isFlat ? keysIn : keys); 19917 19918 var props = isArr ? undefined : keysFunc(value); 19919 arrayEach(props || value, function(subValue, key) { 19920 if (props) { 19921 key = subValue; 19922 subValue = value[key]; 19923 } 19924 // Recursively populate clone (susceptible to call stack limits). 19925 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 19926 }); 19927 return result; 19928 } 19929 19930 /** 19931 * The base implementation of `_.conforms` which doesn't clone `source`. 19932 * 19933 * @private 19934 * @param {Object} source The object of property predicates to conform to. 19935 * @returns {Function} Returns the new spec function. 19936 */ 19937 function baseConforms(source) { 19938 var props = keys(source); 19939 return function(object) { 19940 return baseConformsTo(object, source, props); 19941 }; 19942 } 19943 19944 /** 19945 * The base implementation of `_.conformsTo` which accepts `props` to check. 19946 * 19947 * @private 19948 * @param {Object} object The object to inspect. 19949 * @param {Object} source The object of property predicates to conform to. 19950 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 19951 */ 19952 function baseConformsTo(object, source, props) { 19953 var length = props.length; 19954 if (object == null) { 19955 return !length; 19956 } 19957 object = Object(object); 19958 while (length--) { 19959 var key = props[length], 19960 predicate = source[key], 19961 value = object[key]; 19962 19963 if ((value === undefined && !(key in object)) || !predicate(value)) { 19964 return false; 19965 } 19966 } 19967 return true; 19968 } 19969 19970 /** 19971 * The base implementation of `_.delay` and `_.defer` which accepts `args` 19972 * to provide to `func`. 19973 * 19974 * @private 19975 * @param {Function} func The function to delay. 19976 * @param {number} wait The number of milliseconds to delay invocation. 19977 * @param {Array} args The arguments to provide to `func`. 19978 * @returns {number|Object} Returns the timer id or timeout object. 19979 */ 19980 function baseDelay(func, wait, args) { 19981 if (typeof func != 'function') { 19982 throw new TypeError(FUNC_ERROR_TEXT); 19983 } 19984 return setTimeout(function() { func.apply(undefined, args); }, wait); 19985 } 19986 19987 /** 19988 * The base implementation of methods like `_.difference` without support 19989 * for excluding multiple arrays or iteratee shorthands. 19990 * 19991 * @private 19992 * @param {Array} array The array to inspect. 19993 * @param {Array} values The values to exclude. 19994 * @param {Function} [iteratee] The iteratee invoked per element. 19995 * @param {Function} [comparator] The comparator invoked per element. 19996 * @returns {Array} Returns the new array of filtered values. 19997 */ 19998 function baseDifference(array, values, iteratee, comparator) { 19999 var index = -1, 20000 includes = arrayIncludes, 20001 isCommon = true, 20002 length = array.length, 20003 result = [], 20004 valuesLength = values.length; 20005 20006 if (!length) { 20007 return result; 20008 } 20009 if (iteratee) { 20010 values = arrayMap(values, baseUnary(iteratee)); 20011 } 20012 if (comparator) { 20013 includes = arrayIncludesWith; 20014 isCommon = false; 20015 } 20016 else if (values.length >= LARGE_ARRAY_SIZE) { 20017 includes = cacheHas; 20018 isCommon = false; 20019 values = new SetCache(values); 20020 } 20021 outer: 20022 while (++index < length) { 20023 var value = array[index], 20024 computed = iteratee == null ? value : iteratee(value); 20025 20026 value = (comparator || value !== 0) ? value : 0; 20027 if (isCommon && computed === computed) { 20028 var valuesIndex = valuesLength; 20029 while (valuesIndex--) { 20030 if (values[valuesIndex] === computed) { 20031 continue outer; 20032 } 20033 } 20034 result.push(value); 20035 } 20036 else if (!includes(values, computed, comparator)) { 20037 result.push(value); 20038 } 20039 } 20040 return result; 20041 } 20042 20043 /** 20044 * The base implementation of `_.forEach` without support for iteratee shorthands. 20045 * 20046 * @private 20047 * @param {Array|Object} collection The collection to iterate over. 20048 * @param {Function} iteratee The function invoked per iteration. 20049 * @returns {Array|Object} Returns `collection`. 20050 */ 20051 var baseEach = createBaseEach(baseForOwn); 20052 20053 /** 20054 * The base implementation of `_.forEachRight` without support for iteratee shorthands. 20055 * 20056 * @private 20057 * @param {Array|Object} collection The collection to iterate over. 20058 * @param {Function} iteratee The function invoked per iteration. 20059 * @returns {Array|Object} Returns `collection`. 20060 */ 20061 var baseEachRight = createBaseEach(baseForOwnRight, true); 20062 20063 /** 20064 * The base implementation of `_.every` without support for iteratee shorthands. 20065 * 20066 * @private 20067 * @param {Array|Object} collection The collection to iterate over. 20068 * @param {Function} predicate The function invoked per iteration. 20069 * @returns {boolean} Returns `true` if all elements pass the predicate check, 20070 * else `false` 20071 */ 20072 function baseEvery(collection, predicate) { 20073 var result = true; 20074 baseEach(collection, function(value, index, collection) { 20075 result = !!predicate(value, index, collection); 20076 return result; 20077 }); 20078 return result; 20079 } 20080 20081 /** 20082 * The base implementation of methods like `_.max` and `_.min` which accepts a 20083 * `comparator` to determine the extremum value. 20084 * 20085 * @private 20086 * @param {Array} array The array to iterate over. 20087 * @param {Function} iteratee The iteratee invoked per iteration. 20088 * @param {Function} comparator The comparator used to compare values. 20089 * @returns {*} Returns the extremum value. 20090 */ 20091 function baseExtremum(array, iteratee, comparator) { 20092 var index = -1, 20093 length = array.length; 20094 20095 while (++index < length) { 20096 var value = array[index], 20097 current = iteratee(value); 20098 20099 if (current != null && (computed === undefined 20100 ? (current === current && !isSymbol(current)) 20101 : comparator(current, computed) 20102 )) { 20103 var computed = current, 20104 result = value; 20105 } 20106 } 20107 return result; 20108 } 20109 20110 /** 20111 * The base implementation of `_.fill` without an iteratee call guard. 20112 * 20113 * @private 20114 * @param {Array} array The array to fill. 20115 * @param {*} value The value to fill `array` with. 20116 * @param {number} [start=0] The start position. 20117 * @param {number} [end=array.length] The end position. 20118 * @returns {Array} Returns `array`. 20119 */ 20120 function baseFill(array, value, start, end) { 20121 var length = array.length; 20122 20123 start = toInteger(start); 20124 if (start < 0) { 20125 start = -start > length ? 0 : (length + start); 20126 } 20127 end = (end === undefined || end > length) ? length : toInteger(end); 20128 if (end < 0) { 20129 end += length; 20130 } 20131 end = start > end ? 0 : toLength(end); 20132 while (start < end) { 20133 array[start++] = value; 20134 } 20135 return array; 20136 } 20137 20138 /** 20139 * The base implementation of `_.filter` without support for iteratee shorthands. 20140 * 20141 * @private 20142 * @param {Array|Object} collection The collection to iterate over. 20143 * @param {Function} predicate The function invoked per iteration. 20144 * @returns {Array} Returns the new filtered array. 20145 */ 20146 function baseFilter(collection, predicate) { 20147 var result = []; 20148 baseEach(collection, function(value, index, collection) { 20149 if (predicate(value, index, collection)) { 20150 result.push(value); 20151 } 20152 }); 20153 return result; 20154 } 20155 20156 /** 20157 * The base implementation of `_.flatten` with support for restricting flattening. 20158 * 20159 * @private 20160 * @param {Array} array The array to flatten. 20161 * @param {number} depth The maximum recursion depth. 20162 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. 20163 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. 20164 * @param {Array} [result=[]] The initial result value. 20165 * @returns {Array} Returns the new flattened array. 20166 */ 20167 function baseFlatten(array, depth, predicate, isStrict, result) { 20168 var index = -1, 20169 length = array.length; 20170 20171 predicate || (predicate = isFlattenable); 20172 result || (result = []); 20173 20174 while (++index < length) { 20175 var value = array[index]; 20176 if (depth > 0 && predicate(value)) { 20177 if (depth > 1) { 20178 // Recursively flatten arrays (susceptible to call stack limits). 20179 baseFlatten(value, depth - 1, predicate, isStrict, result); 20180 } else { 20181 arrayPush(result, value); 20182 } 20183 } else if (!isStrict) { 20184 result[result.length] = value; 20185 } 20186 } 20187 return result; 20188 } 20189 20190 /** 20191 * The base implementation of `baseForOwn` which iterates over `object` 20192 * properties returned by `keysFunc` and invokes `iteratee` for each property. 20193 * Iteratee functions may exit iteration early by explicitly returning `false`. 20194 * 20195 * @private 20196 * @param {Object} object The object to iterate over. 20197 * @param {Function} iteratee The function invoked per iteration. 20198 * @param {Function} keysFunc The function to get the keys of `object`. 20199 * @returns {Object} Returns `object`. 20200 */ 20201 var baseFor = createBaseFor(); 20202 20203 /** 20204 * This function is like `baseFor` except that it iterates over properties 20205 * in the opposite order. 20206 * 20207 * @private 20208 * @param {Object} object The object to iterate over. 20209 * @param {Function} iteratee The function invoked per iteration. 20210 * @param {Function} keysFunc The function to get the keys of `object`. 20211 * @returns {Object} Returns `object`. 20212 */ 20213 var baseForRight = createBaseFor(true); 20214 20215 /** 20216 * The base implementation of `_.forOwn` without support for iteratee shorthands. 20217 * 20218 * @private 20219 * @param {Object} object The object to iterate over. 20220 * @param {Function} iteratee The function invoked per iteration. 20221 * @returns {Object} Returns `object`. 20222 */ 20223 function baseForOwn(object, iteratee) { 20224 return object && baseFor(object, iteratee, keys); 20225 } 20226 20227 /** 20228 * The base implementation of `_.forOwnRight` without support for iteratee shorthands. 20229 * 20230 * @private 20231 * @param {Object} object The object to iterate over. 20232 * @param {Function} iteratee The function invoked per iteration. 20233 * @returns {Object} Returns `object`. 20234 */ 20235 function baseForOwnRight(object, iteratee) { 20236 return object && baseForRight(object, iteratee, keys); 20237 } 20238 20239 /** 20240 * The base implementation of `_.functions` which creates an array of 20241 * `object` function property names filtered from `props`. 20242 * 20243 * @private 20244 * @param {Object} object The object to inspect. 20245 * @param {Array} props The property names to filter. 20246 * @returns {Array} Returns the function names. 20247 */ 20248 function baseFunctions(object, props) { 20249 return arrayFilter(props, function(key) { 20250 return isFunction(object[key]); 20251 }); 20252 } 20253 20254 /** 20255 * The base implementation of `_.get` without support for default values. 20256 * 20257 * @private 20258 * @param {Object} object The object to query. 20259 * @param {Array|string} path The path of the property to get. 20260 * @returns {*} Returns the resolved value. 20261 */ 20262 function baseGet(object, path) { 20263 path = castPath(path, object); 20264 20265 var index = 0, 20266 length = path.length; 20267 20268 while (object != null && index < length) { 20269 object = object[toKey(path[index++])]; 20270 } 20271 return (index && index == length) ? object : undefined; 20272 } 20273 20274 /** 20275 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 20276 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 20277 * symbols of `object`. 20278 * 20279 * @private 20280 * @param {Object} object The object to query. 20281 * @param {Function} keysFunc The function to get the keys of `object`. 20282 * @param {Function} symbolsFunc The function to get the symbols of `object`. 20283 * @returns {Array} Returns the array of property names and symbols. 20284 */ 20285 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 20286 var result = keysFunc(object); 20287 return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); 20288 } 20289 20290 /** 20291 * The base implementation of `getTag` without fallbacks for buggy environments. 20292 * 20293 * @private 20294 * @param {*} value The value to query. 20295 * @returns {string} Returns the `toStringTag`. 20296 */ 20297 function baseGetTag(value) { 20298 if (value == null) { 20299 return value === undefined ? undefinedTag : nullTag; 20300 } 20301 return (symToStringTag && symToStringTag in Object(value)) 20302 ? getRawTag(value) 20303 : objectToString(value); 20304 } 20305 20306 /** 20307 * The base implementation of `_.gt` which doesn't coerce arguments. 20308 * 20309 * @private 20310 * @param {*} value The value to compare. 20311 * @param {*} other The other value to compare. 20312 * @returns {boolean} Returns `true` if `value` is greater than `other`, 20313 * else `false`. 20314 */ 20315 function baseGt(value, other) { 20316 return value > other; 20317 } 20318 20319 /** 20320 * The base implementation of `_.has` without support for deep paths. 20321 * 20322 * @private 20323 * @param {Object} [object] The object to query. 20324 * @param {Array|string} key The key to check. 20325 * @returns {boolean} Returns `true` if `key` exists, else `false`. 20326 */ 20327 function baseHas(object, key) { 20328 return object != null && hasOwnProperty.call(object, key); 20329 } 20330 20331 /** 20332 * The base implementation of `_.hasIn` without support for deep paths. 20333 * 20334 * @private 20335 * @param {Object} [object] The object to query. 20336 * @param {Array|string} key The key to check. 20337 * @returns {boolean} Returns `true` if `key` exists, else `false`. 20338 */ 20339 function baseHasIn(object, key) { 20340 return object != null && key in Object(object); 20341 } 20342 20343 /** 20344 * The base implementation of `_.inRange` which doesn't coerce arguments. 20345 * 20346 * @private 20347 * @param {number} number The number to check. 20348 * @param {number} start The start of the range. 20349 * @param {number} end The end of the range. 20350 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 20351 */ 20352 function baseInRange(number, start, end) { 20353 return number >= nativeMin(start, end) && number < nativeMax(start, end); 20354 } 20355 20356 /** 20357 * The base implementation of methods like `_.intersection`, without support 20358 * for iteratee shorthands, that accepts an array of arrays to inspect. 20359 * 20360 * @private 20361 * @param {Array} arrays The arrays to inspect. 20362 * @param {Function} [iteratee] The iteratee invoked per element. 20363 * @param {Function} [comparator] The comparator invoked per element. 20364 * @returns {Array} Returns the new array of shared values. 20365 */ 20366 function baseIntersection(arrays, iteratee, comparator) { 20367 var includes = comparator ? arrayIncludesWith : arrayIncludes, 20368 length = arrays[0].length, 20369 othLength = arrays.length, 20370 othIndex = othLength, 20371 caches = Array(othLength), 20372 maxLength = Infinity, 20373 result = []; 20374 20375 while (othIndex--) { 20376 var array = arrays[othIndex]; 20377 if (othIndex && iteratee) { 20378 array = arrayMap(array, baseUnary(iteratee)); 20379 } 20380 maxLength = nativeMin(array.length, maxLength); 20381 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) 20382 ? new SetCache(othIndex && array) 20383 : undefined; 20384 } 20385 array = arrays[0]; 20386 20387 var index = -1, 20388 seen = caches[0]; 20389 20390 outer: 20391 while (++index < length && result.length < maxLength) { 20392 var value = array[index], 20393 computed = iteratee ? iteratee(value) : value; 20394 20395 value = (comparator || value !== 0) ? value : 0; 20396 if (!(seen 20397 ? cacheHas(seen, computed) 20398 : includes(result, computed, comparator) 20399 )) { 20400 othIndex = othLength; 20401 while (--othIndex) { 20402 var cache = caches[othIndex]; 20403 if (!(cache 20404 ? cacheHas(cache, computed) 20405 : includes(arrays[othIndex], computed, comparator)) 20406 ) { 20407 continue outer; 20408 } 20409 } 20410 if (seen) { 20411 seen.push(computed); 20412 } 20413 result.push(value); 20414 } 20415 } 20416 return result; 20417 } 20418 20419 /** 20420 * The base implementation of `_.invert` and `_.invertBy` which inverts 20421 * `object` with values transformed by `iteratee` and set by `setter`. 20422 * 20423 * @private 20424 * @param {Object} object The object to iterate over. 20425 * @param {Function} setter The function to set `accumulator` values. 20426 * @param {Function} iteratee The iteratee to transform values. 20427 * @param {Object} accumulator The initial inverted object. 20428 * @returns {Function} Returns `accumulator`. 20429 */ 20430 function baseInverter(object, setter, iteratee, accumulator) { 20431 baseForOwn(object, function(value, key, object) { 20432 setter(accumulator, iteratee(value), key, object); 20433 }); 20434 return accumulator; 20435 } 20436 20437 /** 20438 * The base implementation of `_.invoke` without support for individual 20439 * method arguments. 20440 * 20441 * @private 20442 * @param {Object} object The object to query. 20443 * @param {Array|string} path The path of the method to invoke. 20444 * @param {Array} args The arguments to invoke the method with. 20445 * @returns {*} Returns the result of the invoked method. 20446 */ 20447 function baseInvoke(object, path, args) { 20448 path = castPath(path, object); 20449 object = parent(object, path); 20450 var func = object == null ? object : object[toKey(last(path))]; 20451 return func == null ? undefined : apply(func, object, args); 20452 } 20453 20454 /** 20455 * The base implementation of `_.isArguments`. 20456 * 20457 * @private 20458 * @param {*} value The value to check. 20459 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 20460 */ 20461 function baseIsArguments(value) { 20462 return isObjectLike(value) && baseGetTag(value) == argsTag; 20463 } 20464 20465 /** 20466 * The base implementation of `_.isArrayBuffer` without Node.js optimizations. 20467 * 20468 * @private 20469 * @param {*} value The value to check. 20470 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 20471 */ 20472 function baseIsArrayBuffer(value) { 20473 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; 20474 } 20475 20476 /** 20477 * The base implementation of `_.isDate` without Node.js optimizations. 20478 * 20479 * @private 20480 * @param {*} value The value to check. 20481 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 20482 */ 20483 function baseIsDate(value) { 20484 return isObjectLike(value) && baseGetTag(value) == dateTag; 20485 } 20486 20487 /** 20488 * The base implementation of `_.isEqual` which supports partial comparisons 20489 * and tracks traversed objects. 20490 * 20491 * @private 20492 * @param {*} value The value to compare. 20493 * @param {*} other The other value to compare. 20494 * @param {boolean} bitmask The bitmask flags. 20495 * 1 - Unordered comparison 20496 * 2 - Partial comparison 20497 * @param {Function} [customizer] The function to customize comparisons. 20498 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 20499 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 20500 */ 20501 function baseIsEqual(value, other, bitmask, customizer, stack) { 20502 if (value === other) { 20503 return true; 20504 } 20505 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 20506 return value !== value && other !== other; 20507 } 20508 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 20509 } 20510 20511 /** 20512 * A specialized version of `baseIsEqual` for arrays and objects which performs 20513 * deep comparisons and tracks traversed objects enabling objects with circular 20514 * references to be compared. 20515 * 20516 * @private 20517 * @param {Object} object The object to compare. 20518 * @param {Object} other The other object to compare. 20519 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 20520 * @param {Function} customizer The function to customize comparisons. 20521 * @param {Function} equalFunc The function to determine equivalents of values. 20522 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 20523 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 20524 */ 20525 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 20526 var objIsArr = isArray(object), 20527 othIsArr = isArray(other), 20528 objTag = objIsArr ? arrayTag : getTag(object), 20529 othTag = othIsArr ? arrayTag : getTag(other); 20530 20531 objTag = objTag == argsTag ? objectTag : objTag; 20532 othTag = othTag == argsTag ? objectTag : othTag; 20533 20534 var objIsObj = objTag == objectTag, 20535 othIsObj = othTag == objectTag, 20536 isSameTag = objTag == othTag; 20537 20538 if (isSameTag && isBuffer(object)) { 20539 if (!isBuffer(other)) { 20540 return false; 20541 } 20542 objIsArr = true; 20543 objIsObj = false; 20544 } 20545 if (isSameTag && !objIsObj) { 20546 stack || (stack = new Stack); 20547 return (objIsArr || isTypedArray(object)) 20548 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) 20549 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 20550 } 20551 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 20552 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 20553 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 20554 20555 if (objIsWrapped || othIsWrapped) { 20556 var objUnwrapped = objIsWrapped ? object.value() : object, 20557 othUnwrapped = othIsWrapped ? other.value() : other; 20558 20559 stack || (stack = new Stack); 20560 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 20561 } 20562 } 20563 if (!isSameTag) { 20564 return false; 20565 } 20566 stack || (stack = new Stack); 20567 return equalObjects(object, other, bitmask, customizer, equalFunc, stack); 20568 } 20569 20570 /** 20571 * The base implementation of `_.isMap` without Node.js optimizations. 20572 * 20573 * @private 20574 * @param {*} value The value to check. 20575 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 20576 */ 20577 function baseIsMap(value) { 20578 return isObjectLike(value) && getTag(value) == mapTag; 20579 } 20580 20581 /** 20582 * The base implementation of `_.isMatch` without support for iteratee shorthands. 20583 * 20584 * @private 20585 * @param {Object} object The object to inspect. 20586 * @param {Object} source The object of property values to match. 20587 * @param {Array} matchData The property names, values, and compare flags to match. 20588 * @param {Function} [customizer] The function to customize comparisons. 20589 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 20590 */ 20591 function baseIsMatch(object, source, matchData, customizer) { 20592 var index = matchData.length, 20593 length = index, 20594 noCustomizer = !customizer; 20595 20596 if (object == null) { 20597 return !length; 20598 } 20599 object = Object(object); 20600 while (index--) { 20601 var data = matchData[index]; 20602 if ((noCustomizer && data[2]) 20603 ? data[1] !== object[data[0]] 20604 : !(data[0] in object) 20605 ) { 20606 return false; 20607 } 20608 } 20609 while (++index < length) { 20610 data = matchData[index]; 20611 var key = data[0], 20612 objValue = object[key], 20613 srcValue = data[1]; 20614 20615 if (noCustomizer && data[2]) { 20616 if (objValue === undefined && !(key in object)) { 20617 return false; 20618 } 20619 } else { 20620 var stack = new Stack; 20621 if (customizer) { 20622 var result = customizer(objValue, srcValue, key, object, source, stack); 20623 } 20624 if (!(result === undefined 20625 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) 20626 : result 20627 )) { 20628 return false; 20629 } 20630 } 20631 } 20632 return true; 20633 } 20634 20635 /** 20636 * The base implementation of `_.isNative` without bad shim checks. 20637 * 20638 * @private 20639 * @param {*} value The value to check. 20640 * @returns {boolean} Returns `true` if `value` is a native function, 20641 * else `false`. 20642 */ 20643 function baseIsNative(value) { 20644 if (!isObject(value) || isMasked(value)) { 20645 return false; 20646 } 20647 var pattern = isFunction(value) ? reIsNative : reIsHostCtor; 20648 return pattern.test(toSource(value)); 20649 } 20650 20651 /** 20652 * The base implementation of `_.isRegExp` without Node.js optimizations. 20653 * 20654 * @private 20655 * @param {*} value The value to check. 20656 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 20657 */ 20658 function baseIsRegExp(value) { 20659 return isObjectLike(value) && baseGetTag(value) == regexpTag; 20660 } 20661 20662 /** 20663 * The base implementation of `_.isSet` without Node.js optimizations. 20664 * 20665 * @private 20666 * @param {*} value The value to check. 20667 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 20668 */ 20669 function baseIsSet(value) { 20670 return isObjectLike(value) && getTag(value) == setTag; 20671 } 20672 20673 /** 20674 * The base implementation of `_.isTypedArray` without Node.js optimizations. 20675 * 20676 * @private 20677 * @param {*} value The value to check. 20678 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 20679 */ 20680 function baseIsTypedArray(value) { 20681 return isObjectLike(value) && 20682 isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; 20683 } 20684 20685 /** 20686 * The base implementation of `_.iteratee`. 20687 * 20688 * @private 20689 * @param {*} [value=_.identity] The value to convert to an iteratee. 20690 * @returns {Function} Returns the iteratee. 20691 */ 20692 function baseIteratee(value) { 20693 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 20694 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 20695 if (typeof value == 'function') { 20696 return value; 20697 } 20698 if (value == null) { 20699 return identity; 20700 } 20701 if (typeof value == 'object') { 20702 return isArray(value) 20703 ? baseMatchesProperty(value[0], value[1]) 20704 : baseMatches(value); 20705 } 20706 return property(value); 20707 } 20708 20709 /** 20710 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 20711 * 20712 * @private 20713 * @param {Object} object The object to query. 20714 * @returns {Array} Returns the array of property names. 20715 */ 20716 function baseKeys(object) { 20717 if (!isPrototype(object)) { 20718 return nativeKeys(object); 20719 } 20720 var result = []; 20721 for (var key in Object(object)) { 20722 if (hasOwnProperty.call(object, key) && key != 'constructor') { 20723 result.push(key); 20724 } 20725 } 20726 return result; 20727 } 20728 20729 /** 20730 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 20731 * 20732 * @private 20733 * @param {Object} object The object to query. 20734 * @returns {Array} Returns the array of property names. 20735 */ 20736 function baseKeysIn(object) { 20737 if (!isObject(object)) { 20738 return nativeKeysIn(object); 20739 } 20740 var isProto = isPrototype(object), 20741 result = []; 20742 20743 for (var key in object) { 20744 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 20745 result.push(key); 20746 } 20747 } 20748 return result; 20749 } 20750 20751 /** 20752 * The base implementation of `_.lt` which doesn't coerce arguments. 20753 * 20754 * @private 20755 * @param {*} value The value to compare. 20756 * @param {*} other The other value to compare. 20757 * @returns {boolean} Returns `true` if `value` is less than `other`, 20758 * else `false`. 20759 */ 20760 function baseLt(value, other) { 20761 return value < other; 20762 } 20763 20764 /** 20765 * The base implementation of `_.map` without support for iteratee shorthands. 20766 * 20767 * @private 20768 * @param {Array|Object} collection The collection to iterate over. 20769 * @param {Function} iteratee The function invoked per iteration. 20770 * @returns {Array} Returns the new mapped array. 20771 */ 20772 function baseMap(collection, iteratee) { 20773 var index = -1, 20774 result = isArrayLike(collection) ? Array(collection.length) : []; 20775 20776 baseEach(collection, function(value, key, collection) { 20777 result[++index] = iteratee(value, key, collection); 20778 }); 20779 return result; 20780 } 20781 20782 /** 20783 * The base implementation of `_.matches` which doesn't clone `source`. 20784 * 20785 * @private 20786 * @param {Object} source The object of property values to match. 20787 * @returns {Function} Returns the new spec function. 20788 */ 20789 function baseMatches(source) { 20790 var matchData = getMatchData(source); 20791 if (matchData.length == 1 && matchData[0][2]) { 20792 return matchesStrictComparable(matchData[0][0], matchData[0][1]); 20793 } 20794 return function(object) { 20795 return object === source || baseIsMatch(object, source, matchData); 20796 }; 20797 } 20798 20799 /** 20800 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. 20801 * 20802 * @private 20803 * @param {string} path The path of the property to get. 20804 * @param {*} srcValue The value to match. 20805 * @returns {Function} Returns the new spec function. 20806 */ 20807 function baseMatchesProperty(path, srcValue) { 20808 if (isKey(path) && isStrictComparable(srcValue)) { 20809 return matchesStrictComparable(toKey(path), srcValue); 20810 } 20811 return function(object) { 20812 var objValue = get(object, path); 20813 return (objValue === undefined && objValue === srcValue) 20814 ? hasIn(object, path) 20815 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); 20816 }; 20817 } 20818 20819 /** 20820 * The base implementation of `_.merge` without support for multiple sources. 20821 * 20822 * @private 20823 * @param {Object} object The destination object. 20824 * @param {Object} source The source object. 20825 * @param {number} srcIndex The index of `source`. 20826 * @param {Function} [customizer] The function to customize merged values. 20827 * @param {Object} [stack] Tracks traversed source values and their merged 20828 * counterparts. 20829 */ 20830 function baseMerge(object, source, srcIndex, customizer, stack) { 20831 if (object === source) { 20832 return; 20833 } 20834 baseFor(source, function(srcValue, key) { 20835 stack || (stack = new Stack); 20836 if (isObject(srcValue)) { 20837 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 20838 } 20839 else { 20840 var newValue = customizer 20841 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) 20842 : undefined; 20843 20844 if (newValue === undefined) { 20845 newValue = srcValue; 20846 } 20847 assignMergeValue(object, key, newValue); 20848 } 20849 }, keysIn); 20850 } 20851 20852 /** 20853 * A specialized version of `baseMerge` for arrays and objects which performs 20854 * deep merges and tracks traversed objects enabling objects with circular 20855 * references to be merged. 20856 * 20857 * @private 20858 * @param {Object} object The destination object. 20859 * @param {Object} source The source object. 20860 * @param {string} key The key of the value to merge. 20861 * @param {number} srcIndex The index of `source`. 20862 * @param {Function} mergeFunc The function to merge values. 20863 * @param {Function} [customizer] The function to customize assigned values. 20864 * @param {Object} [stack] Tracks traversed source values and their merged 20865 * counterparts. 20866 */ 20867 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 20868 var objValue = safeGet(object, key), 20869 srcValue = safeGet(source, key), 20870 stacked = stack.get(srcValue); 20871 20872 if (stacked) { 20873 assignMergeValue(object, key, stacked); 20874 return; 20875 } 20876 var newValue = customizer 20877 ? customizer(objValue, srcValue, (key + ''), object, source, stack) 20878 : undefined; 20879 20880 var isCommon = newValue === undefined; 20881 20882 if (isCommon) { 20883 var isArr = isArray(srcValue), 20884 isBuff = !isArr && isBuffer(srcValue), 20885 isTyped = !isArr && !isBuff && isTypedArray(srcValue); 20886 20887 newValue = srcValue; 20888 if (isArr || isBuff || isTyped) { 20889 if (isArray(objValue)) { 20890 newValue = objValue; 20891 } 20892 else if (isArrayLikeObject(objValue)) { 20893 newValue = copyArray(objValue); 20894 } 20895 else if (isBuff) { 20896 isCommon = false; 20897 newValue = cloneBuffer(srcValue, true); 20898 } 20899 else if (isTyped) { 20900 isCommon = false; 20901 newValue = cloneTypedArray(srcValue, true); 20902 } 20903 else { 20904 newValue = []; 20905 } 20906 } 20907 else if (isPlainObject(srcValue) || isArguments(srcValue)) { 20908 newValue = objValue; 20909 if (isArguments(objValue)) { 20910 newValue = toPlainObject(objValue); 20911 } 20912 else if (!isObject(objValue) || isFunction(objValue)) { 20913 newValue = initCloneObject(srcValue); 20914 } 20915 } 20916 else { 20917 isCommon = false; 20918 } 20919 } 20920 if (isCommon) { 20921 // Recursively merge objects and arrays (susceptible to call stack limits). 20922 stack.set(srcValue, newValue); 20923 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 20924 stack['delete'](srcValue); 20925 } 20926 assignMergeValue(object, key, newValue); 20927 } 20928 20929 /** 20930 * The base implementation of `_.nth` which doesn't coerce arguments. 20931 * 20932 * @private 20933 * @param {Array} array The array to query. 20934 * @param {number} n The index of the element to return. 20935 * @returns {*} Returns the nth element of `array`. 20936 */ 20937 function baseNth(array, n) { 20938 var length = array.length; 20939 if (!length) { 20940 return; 20941 } 20942 n += n < 0 ? length : 0; 20943 return isIndex(n, length) ? array[n] : undefined; 20944 } 20945 20946 /** 20947 * The base implementation of `_.orderBy` without param guards. 20948 * 20949 * @private 20950 * @param {Array|Object} collection The collection to iterate over. 20951 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. 20952 * @param {string[]} orders The sort orders of `iteratees`. 20953 * @returns {Array} Returns the new sorted array. 20954 */ 20955 function baseOrderBy(collection, iteratees, orders) { 20956 if (iteratees.length) { 20957 iteratees = arrayMap(iteratees, function(iteratee) { 20958 if (isArray(iteratee)) { 20959 return function(value) { 20960 return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); 20961 } 20962 } 20963 return iteratee; 20964 }); 20965 } else { 20966 iteratees = [identity]; 20967 } 20968 20969 var index = -1; 20970 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 20971 20972 var result = baseMap(collection, function(value, key, collection) { 20973 var criteria = arrayMap(iteratees, function(iteratee) { 20974 return iteratee(value); 20975 }); 20976 return { 'criteria': criteria, 'index': ++index, 'value': value }; 20977 }); 20978 20979 return baseSortBy(result, function(object, other) { 20980 return compareMultiple(object, other, orders); 20981 }); 20982 } 20983 20984 /** 20985 * The base implementation of `_.pick` without support for individual 20986 * property identifiers. 20987 * 20988 * @private 20989 * @param {Object} object The source object. 20990 * @param {string[]} paths The property paths to pick. 20991 * @returns {Object} Returns the new object. 20992 */ 20993 function basePick(object, paths) { 20994 return basePickBy(object, paths, function(value, path) { 20995 return hasIn(object, path); 20996 }); 20997 } 20998 20999 /** 21000 * The base implementation of `_.pickBy` without support for iteratee shorthands. 21001 * 21002 * @private 21003 * @param {Object} object The source object. 21004 * @param {string[]} paths The property paths to pick. 21005 * @param {Function} predicate The function invoked per property. 21006 * @returns {Object} Returns the new object. 21007 */ 21008 function basePickBy(object, paths, predicate) { 21009 var index = -1, 21010 length = paths.length, 21011 result = {}; 21012 21013 while (++index < length) { 21014 var path = paths[index], 21015 value = baseGet(object, path); 21016 21017 if (predicate(value, path)) { 21018 baseSet(result, castPath(path, object), value); 21019 } 21020 } 21021 return result; 21022 } 21023 21024 /** 21025 * A specialized version of `baseProperty` which supports deep paths. 21026 * 21027 * @private 21028 * @param {Array|string} path The path of the property to get. 21029 * @returns {Function} Returns the new accessor function. 21030 */ 21031 function basePropertyDeep(path) { 21032 return function(object) { 21033 return baseGet(object, path); 21034 }; 21035 } 21036 21037 /** 21038 * The base implementation of `_.pullAllBy` without support for iteratee 21039 * shorthands. 21040 * 21041 * @private 21042 * @param {Array} array The array to modify. 21043 * @param {Array} values The values to remove. 21044 * @param {Function} [iteratee] The iteratee invoked per element. 21045 * @param {Function} [comparator] The comparator invoked per element. 21046 * @returns {Array} Returns `array`. 21047 */ 21048 function basePullAll(array, values, iteratee, comparator) { 21049 var indexOf = comparator ? baseIndexOfWith : baseIndexOf, 21050 index = -1, 21051 length = values.length, 21052 seen = array; 21053 21054 if (array === values) { 21055 values = copyArray(values); 21056 } 21057 if (iteratee) { 21058 seen = arrayMap(array, baseUnary(iteratee)); 21059 } 21060 while (++index < length) { 21061 var fromIndex = 0, 21062 value = values[index], 21063 computed = iteratee ? iteratee(value) : value; 21064 21065 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { 21066 if (seen !== array) { 21067 splice.call(seen, fromIndex, 1); 21068 } 21069 splice.call(array, fromIndex, 1); 21070 } 21071 } 21072 return array; 21073 } 21074 21075 /** 21076 * The base implementation of `_.pullAt` without support for individual 21077 * indexes or capturing the removed elements. 21078 * 21079 * @private 21080 * @param {Array} array The array to modify. 21081 * @param {number[]} indexes The indexes of elements to remove. 21082 * @returns {Array} Returns `array`. 21083 */ 21084 function basePullAt(array, indexes) { 21085 var length = array ? indexes.length : 0, 21086 lastIndex = length - 1; 21087 21088 while (length--) { 21089 var index = indexes[length]; 21090 if (length == lastIndex || index !== previous) { 21091 var previous = index; 21092 if (isIndex(index)) { 21093 splice.call(array, index, 1); 21094 } else { 21095 baseUnset(array, index); 21096 } 21097 } 21098 } 21099 return array; 21100 } 21101 21102 /** 21103 * The base implementation of `_.random` without support for returning 21104 * floating-point numbers. 21105 * 21106 * @private 21107 * @param {number} lower The lower bound. 21108 * @param {number} upper The upper bound. 21109 * @returns {number} Returns the random number. 21110 */ 21111 function baseRandom(lower, upper) { 21112 return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); 21113 } 21114 21115 /** 21116 * The base implementation of `_.range` and `_.rangeRight` which doesn't 21117 * coerce arguments. 21118 * 21119 * @private 21120 * @param {number} start The start of the range. 21121 * @param {number} end The end of the range. 21122 * @param {number} step The value to increment or decrement by. 21123 * @param {boolean} [fromRight] Specify iterating from right to left. 21124 * @returns {Array} Returns the range of numbers. 21125 */ 21126 function baseRange(start, end, step, fromRight) { 21127 var index = -1, 21128 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), 21129 result = Array(length); 21130 21131 while (length--) { 21132 result[fromRight ? length : ++index] = start; 21133 start += step; 21134 } 21135 return result; 21136 } 21137 21138 /** 21139 * The base implementation of `_.repeat` which doesn't coerce arguments. 21140 * 21141 * @private 21142 * @param {string} string The string to repeat. 21143 * @param {number} n The number of times to repeat the string. 21144 * @returns {string} Returns the repeated string. 21145 */ 21146 function baseRepeat(string, n) { 21147 var result = ''; 21148 if (!string || n < 1 || n > MAX_SAFE_INTEGER) { 21149 return result; 21150 } 21151 // Leverage the exponentiation by squaring algorithm for a faster repeat. 21152 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. 21153 do { 21154 if (n % 2) { 21155 result += string; 21156 } 21157 n = nativeFloor(n / 2); 21158 if (n) { 21159 string += string; 21160 } 21161 } while (n); 21162 21163 return result; 21164 } 21165 21166 /** 21167 * The base implementation of `_.rest` which doesn't validate or coerce arguments. 21168 * 21169 * @private 21170 * @param {Function} func The function to apply a rest parameter to. 21171 * @param {number} [start=func.length-1] The start position of the rest parameter. 21172 * @returns {Function} Returns the new function. 21173 */ 21174 function baseRest(func, start) { 21175 return setToString(overRest(func, start, identity), func + ''); 21176 } 21177 21178 /** 21179 * The base implementation of `_.sample`. 21180 * 21181 * @private 21182 * @param {Array|Object} collection The collection to sample. 21183 * @returns {*} Returns the random element. 21184 */ 21185 function baseSample(collection) { 21186 return arraySample(values(collection)); 21187 } 21188 21189 /** 21190 * The base implementation of `_.sampleSize` without param guards. 21191 * 21192 * @private 21193 * @param {Array|Object} collection The collection to sample. 21194 * @param {number} n The number of elements to sample. 21195 * @returns {Array} Returns the random elements. 21196 */ 21197 function baseSampleSize(collection, n) { 21198 var array = values(collection); 21199 return shuffleSelf(array, baseClamp(n, 0, array.length)); 21200 } 21201 21202 /** 21203 * The base implementation of `_.set`. 21204 * 21205 * @private 21206 * @param {Object} object The object to modify. 21207 * @param {Array|string} path The path of the property to set. 21208 * @param {*} value The value to set. 21209 * @param {Function} [customizer] The function to customize path creation. 21210 * @returns {Object} Returns `object`. 21211 */ 21212 function baseSet(object, path, value, customizer) { 21213 if (!isObject(object)) { 21214 return object; 21215 } 21216 path = castPath(path, object); 21217 21218 var index = -1, 21219 length = path.length, 21220 lastIndex = length - 1, 21221 nested = object; 21222 21223 while (nested != null && ++index < length) { 21224 var key = toKey(path[index]), 21225 newValue = value; 21226 21227 if (key === '__proto__' || key === 'constructor' || key === 'prototype') { 21228 return object; 21229 } 21230 21231 if (index != lastIndex) { 21232 var objValue = nested[key]; 21233 newValue = customizer ? customizer(objValue, key, nested) : undefined; 21234 if (newValue === undefined) { 21235 newValue = isObject(objValue) 21236 ? objValue 21237 : (isIndex(path[index + 1]) ? [] : {}); 21238 } 21239 } 21240 assignValue(nested, key, newValue); 21241 nested = nested[key]; 21242 } 21243 return object; 21244 } 21245 21246 /** 21247 * The base implementation of `setData` without support for hot loop shorting. 21248 * 21249 * @private 21250 * @param {Function} func The function to associate metadata with. 21251 * @param {*} data The metadata. 21252 * @returns {Function} Returns `func`. 21253 */ 21254 var baseSetData = !metaMap ? identity : function(func, data) { 21255 metaMap.set(func, data); 21256 return func; 21257 }; 21258 21259 /** 21260 * The base implementation of `setToString` without support for hot loop shorting. 21261 * 21262 * @private 21263 * @param {Function} func The function to modify. 21264 * @param {Function} string The `toString` result. 21265 * @returns {Function} Returns `func`. 21266 */ 21267 var baseSetToString = !defineProperty ? identity : function(func, string) { 21268 return defineProperty(func, 'toString', { 21269 'configurable': true, 21270 'enumerable': false, 21271 'value': constant(string), 21272 'writable': true 21273 }); 21274 }; 21275 21276 /** 21277 * The base implementation of `_.shuffle`. 21278 * 21279 * @private 21280 * @param {Array|Object} collection The collection to shuffle. 21281 * @returns {Array} Returns the new shuffled array. 21282 */ 21283 function baseShuffle(collection) { 21284 return shuffleSelf(values(collection)); 21285 } 21286 21287 /** 21288 * The base implementation of `_.slice` without an iteratee call guard. 21289 * 21290 * @private 21291 * @param {Array} array The array to slice. 21292 * @param {number} [start=0] The start position. 21293 * @param {number} [end=array.length] The end position. 21294 * @returns {Array} Returns the slice of `array`. 21295 */ 21296 function baseSlice(array, start, end) { 21297 var index = -1, 21298 length = array.length; 21299 21300 if (start < 0) { 21301 start = -start > length ? 0 : (length + start); 21302 } 21303 end = end > length ? length : end; 21304 if (end < 0) { 21305 end += length; 21306 } 21307 length = start > end ? 0 : ((end - start) >>> 0); 21308 start >>>= 0; 21309 21310 var result = Array(length); 21311 while (++index < length) { 21312 result[index] = array[index + start]; 21313 } 21314 return result; 21315 } 21316 21317 /** 21318 * The base implementation of `_.some` without support for iteratee shorthands. 21319 * 21320 * @private 21321 * @param {Array|Object} collection The collection to iterate over. 21322 * @param {Function} predicate The function invoked per iteration. 21323 * @returns {boolean} Returns `true` if any element passes the predicate check, 21324 * else `false`. 21325 */ 21326 function baseSome(collection, predicate) { 21327 var result; 21328 21329 baseEach(collection, function(value, index, collection) { 21330 result = predicate(value, index, collection); 21331 return !result; 21332 }); 21333 return !!result; 21334 } 21335 21336 /** 21337 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which 21338 * performs a binary search of `array` to determine the index at which `value` 21339 * should be inserted into `array` in order to maintain its sort order. 21340 * 21341 * @private 21342 * @param {Array} array The sorted array to inspect. 21343 * @param {*} value The value to evaluate. 21344 * @param {boolean} [retHighest] Specify returning the highest qualified index. 21345 * @returns {number} Returns the index at which `value` should be inserted 21346 * into `array`. 21347 */ 21348 function baseSortedIndex(array, value, retHighest) { 21349 var low = 0, 21350 high = array == null ? low : array.length; 21351 21352 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { 21353 while (low < high) { 21354 var mid = (low + high) >>> 1, 21355 computed = array[mid]; 21356 21357 if (computed !== null && !isSymbol(computed) && 21358 (retHighest ? (computed <= value) : (computed < value))) { 21359 low = mid + 1; 21360 } else { 21361 high = mid; 21362 } 21363 } 21364 return high; 21365 } 21366 return baseSortedIndexBy(array, value, identity, retHighest); 21367 } 21368 21369 /** 21370 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` 21371 * which invokes `iteratee` for `value` and each element of `array` to compute 21372 * their sort ranking. The iteratee is invoked with one argument; (value). 21373 * 21374 * @private 21375 * @param {Array} array The sorted array to inspect. 21376 * @param {*} value The value to evaluate. 21377 * @param {Function} iteratee The iteratee invoked per element. 21378 * @param {boolean} [retHighest] Specify returning the highest qualified index. 21379 * @returns {number} Returns the index at which `value` should be inserted 21380 * into `array`. 21381 */ 21382 function baseSortedIndexBy(array, value, iteratee, retHighest) { 21383 var low = 0, 21384 high = array == null ? 0 : array.length; 21385 if (high === 0) { 21386 return 0; 21387 } 21388 21389 value = iteratee(value); 21390 var valIsNaN = value !== value, 21391 valIsNull = value === null, 21392 valIsSymbol = isSymbol(value), 21393 valIsUndefined = value === undefined; 21394 21395 while (low < high) { 21396 var mid = nativeFloor((low + high) / 2), 21397 computed = iteratee(array[mid]), 21398 othIsDefined = computed !== undefined, 21399 othIsNull = computed === null, 21400 othIsReflexive = computed === computed, 21401 othIsSymbol = isSymbol(computed); 21402 21403 if (valIsNaN) { 21404 var setLow = retHighest || othIsReflexive; 21405 } else if (valIsUndefined) { 21406 setLow = othIsReflexive && (retHighest || othIsDefined); 21407 } else if (valIsNull) { 21408 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); 21409 } else if (valIsSymbol) { 21410 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); 21411 } else if (othIsNull || othIsSymbol) { 21412 setLow = false; 21413 } else { 21414 setLow = retHighest ? (computed <= value) : (computed < value); 21415 } 21416 if (setLow) { 21417 low = mid + 1; 21418 } else { 21419 high = mid; 21420 } 21421 } 21422 return nativeMin(high, MAX_ARRAY_INDEX); 21423 } 21424 21425 /** 21426 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without 21427 * support for iteratee shorthands. 21428 * 21429 * @private 21430 * @param {Array} array The array to inspect. 21431 * @param {Function} [iteratee] The iteratee invoked per element. 21432 * @returns {Array} Returns the new duplicate free array. 21433 */ 21434 function baseSortedUniq(array, iteratee) { 21435 var index = -1, 21436 length = array.length, 21437 resIndex = 0, 21438 result = []; 21439 21440 while (++index < length) { 21441 var value = array[index], 21442 computed = iteratee ? iteratee(value) : value; 21443 21444 if (!index || !eq(computed, seen)) { 21445 var seen = computed; 21446 result[resIndex++] = value === 0 ? 0 : value; 21447 } 21448 } 21449 return result; 21450 } 21451 21452 /** 21453 * The base implementation of `_.toNumber` which doesn't ensure correct 21454 * conversions of binary, hexadecimal, or octal string values. 21455 * 21456 * @private 21457 * @param {*} value The value to process. 21458 * @returns {number} Returns the number. 21459 */ 21460 function baseToNumber(value) { 21461 if (typeof value == 'number') { 21462 return value; 21463 } 21464 if (isSymbol(value)) { 21465 return NAN; 21466 } 21467 return +value; 21468 } 21469 21470 /** 21471 * The base implementation of `_.toString` which doesn't convert nullish 21472 * values to empty strings. 21473 * 21474 * @private 21475 * @param {*} value The value to process. 21476 * @returns {string} Returns the string. 21477 */ 21478 function baseToString(value) { 21479 // Exit early for strings to avoid a performance hit in some environments. 21480 if (typeof value == 'string') { 21481 return value; 21482 } 21483 if (isArray(value)) { 21484 // Recursively convert values (susceptible to call stack limits). 21485 return arrayMap(value, baseToString) + ''; 21486 } 21487 if (isSymbol(value)) { 21488 return symbolToString ? symbolToString.call(value) : ''; 21489 } 21490 var result = (value + ''); 21491 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 21492 } 21493 21494 /** 21495 * The base implementation of `_.uniqBy` without support for iteratee shorthands. 21496 * 21497 * @private 21498 * @param {Array} array The array to inspect. 21499 * @param {Function} [iteratee] The iteratee invoked per element. 21500 * @param {Function} [comparator] The comparator invoked per element. 21501 * @returns {Array} Returns the new duplicate free array. 21502 */ 21503 function baseUniq(array, iteratee, comparator) { 21504 var index = -1, 21505 includes = arrayIncludes, 21506 length = array.length, 21507 isCommon = true, 21508 result = [], 21509 seen = result; 21510 21511 if (comparator) { 21512 isCommon = false; 21513 includes = arrayIncludesWith; 21514 } 21515 else if (length >= LARGE_ARRAY_SIZE) { 21516 var set = iteratee ? null : createSet(array); 21517 if (set) { 21518 return setToArray(set); 21519 } 21520 isCommon = false; 21521 includes = cacheHas; 21522 seen = new SetCache; 21523 } 21524 else { 21525 seen = iteratee ? [] : result; 21526 } 21527 outer: 21528 while (++index < length) { 21529 var value = array[index], 21530 computed = iteratee ? iteratee(value) : value; 21531 21532 value = (comparator || value !== 0) ? value : 0; 21533 if (isCommon && computed === computed) { 21534 var seenIndex = seen.length; 21535 while (seenIndex--) { 21536 if (seen[seenIndex] === computed) { 21537 continue outer; 21538 } 21539 } 21540 if (iteratee) { 21541 seen.push(computed); 21542 } 21543 result.push(value); 21544 } 21545 else if (!includes(seen, computed, comparator)) { 21546 if (seen !== result) { 21547 seen.push(computed); 21548 } 21549 result.push(value); 21550 } 21551 } 21552 return result; 21553 } 21554 21555 /** 21556 * The base implementation of `_.unset`. 21557 * 21558 * @private 21559 * @param {Object} object The object to modify. 21560 * @param {Array|string} path The property path to unset. 21561 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 21562 */ 21563 function baseUnset(object, path) { 21564 path = castPath(path, object); 21565 object = parent(object, path); 21566 return object == null || delete object[toKey(last(path))]; 21567 } 21568 21569 /** 21570 * The base implementation of `_.update`. 21571 * 21572 * @private 21573 * @param {Object} object The object to modify. 21574 * @param {Array|string} path The path of the property to update. 21575 * @param {Function} updater The function to produce the updated value. 21576 * @param {Function} [customizer] The function to customize path creation. 21577 * @returns {Object} Returns `object`. 21578 */ 21579 function baseUpdate(object, path, updater, customizer) { 21580 return baseSet(object, path, updater(baseGet(object, path)), customizer); 21581 } 21582 21583 /** 21584 * The base implementation of methods like `_.dropWhile` and `_.takeWhile` 21585 * without support for iteratee shorthands. 21586 * 21587 * @private 21588 * @param {Array} array The array to query. 21589 * @param {Function} predicate The function invoked per iteration. 21590 * @param {boolean} [isDrop] Specify dropping elements instead of taking them. 21591 * @param {boolean} [fromRight] Specify iterating from right to left. 21592 * @returns {Array} Returns the slice of `array`. 21593 */ 21594 function baseWhile(array, predicate, isDrop, fromRight) { 21595 var length = array.length, 21596 index = fromRight ? length : -1; 21597 21598 while ((fromRight ? index-- : ++index < length) && 21599 predicate(array[index], index, array)) {} 21600 21601 return isDrop 21602 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 21603 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); 21604 } 21605 21606 /** 21607 * The base implementation of `wrapperValue` which returns the result of 21608 * performing a sequence of actions on the unwrapped `value`, where each 21609 * successive action is supplied the return value of the previous. 21610 * 21611 * @private 21612 * @param {*} value The unwrapped value. 21613 * @param {Array} actions Actions to perform to resolve the unwrapped value. 21614 * @returns {*} Returns the resolved value. 21615 */ 21616 function baseWrapperValue(value, actions) { 21617 var result = value; 21618 if (result instanceof LazyWrapper) { 21619 result = result.value(); 21620 } 21621 return arrayReduce(actions, function(result, action) { 21622 return action.func.apply(action.thisArg, arrayPush([result], action.args)); 21623 }, result); 21624 } 21625 21626 /** 21627 * The base implementation of methods like `_.xor`, without support for 21628 * iteratee shorthands, that accepts an array of arrays to inspect. 21629 * 21630 * @private 21631 * @param {Array} arrays The arrays to inspect. 21632 * @param {Function} [iteratee] The iteratee invoked per element. 21633 * @param {Function} [comparator] The comparator invoked per element. 21634 * @returns {Array} Returns the new array of values. 21635 */ 21636 function baseXor(arrays, iteratee, comparator) { 21637 var length = arrays.length; 21638 if (length < 2) { 21639 return length ? baseUniq(arrays[0]) : []; 21640 } 21641 var index = -1, 21642 result = Array(length); 21643 21644 while (++index < length) { 21645 var array = arrays[index], 21646 othIndex = -1; 21647 21648 while (++othIndex < length) { 21649 if (othIndex != index) { 21650 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); 21651 } 21652 } 21653 } 21654 return baseUniq(baseFlatten(result, 1), iteratee, comparator); 21655 } 21656 21657 /** 21658 * This base implementation of `_.zipObject` which assigns values using `assignFunc`. 21659 * 21660 * @private 21661 * @param {Array} props The property identifiers. 21662 * @param {Array} values The property values. 21663 * @param {Function} assignFunc The function to assign values. 21664 * @returns {Object} Returns the new object. 21665 */ 21666 function baseZipObject(props, values, assignFunc) { 21667 var index = -1, 21668 length = props.length, 21669 valsLength = values.length, 21670 result = {}; 21671 21672 while (++index < length) { 21673 var value = index < valsLength ? values[index] : undefined; 21674 assignFunc(result, props[index], value); 21675 } 21676 return result; 21677 } 21678 21679 /** 21680 * Casts `value` to an empty array if it's not an array like object. 21681 * 21682 * @private 21683 * @param {*} value The value to inspect. 21684 * @returns {Array|Object} Returns the cast array-like object. 21685 */ 21686 function castArrayLikeObject(value) { 21687 return isArrayLikeObject(value) ? value : []; 21688 } 21689 21690 /** 21691 * Casts `value` to `identity` if it's not a function. 21692 * 21693 * @private 21694 * @param {*} value The value to inspect. 21695 * @returns {Function} Returns cast function. 21696 */ 21697 function castFunction(value) { 21698 return typeof value == 'function' ? value : identity; 21699 } 21700 21701 /** 21702 * Casts `value` to a path array if it's not one. 21703 * 21704 * @private 21705 * @param {*} value The value to inspect. 21706 * @param {Object} [object] The object to query keys on. 21707 * @returns {Array} Returns the cast property path array. 21708 */ 21709 function castPath(value, object) { 21710 if (isArray(value)) { 21711 return value; 21712 } 21713 return isKey(value, object) ? [value] : stringToPath(toString(value)); 21714 } 21715 21716 /** 21717 * A `baseRest` alias which can be replaced with `identity` by module 21718 * replacement plugins. 21719 * 21720 * @private 21721 * @type {Function} 21722 * @param {Function} func The function to apply a rest parameter to. 21723 * @returns {Function} Returns the new function. 21724 */ 21725 var castRest = baseRest; 21726 21727 /** 21728 * Casts `array` to a slice if it's needed. 21729 * 21730 * @private 21731 * @param {Array} array The array to inspect. 21732 * @param {number} start The start position. 21733 * @param {number} [end=array.length] The end position. 21734 * @returns {Array} Returns the cast slice. 21735 */ 21736 function castSlice(array, start, end) { 21737 var length = array.length; 21738 end = end === undefined ? length : end; 21739 return (!start && end >= length) ? array : baseSlice(array, start, end); 21740 } 21741 21742 /** 21743 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). 21744 * 21745 * @private 21746 * @param {number|Object} id The timer id or timeout object of the timer to clear. 21747 */ 21748 var clearTimeout = ctxClearTimeout || function(id) { 21749 return root.clearTimeout(id); 21750 }; 21751 21752 /** 21753 * Creates a clone of `buffer`. 21754 * 21755 * @private 21756 * @param {Buffer} buffer The buffer to clone. 21757 * @param {boolean} [isDeep] Specify a deep clone. 21758 * @returns {Buffer} Returns the cloned buffer. 21759 */ 21760 function cloneBuffer(buffer, isDeep) { 21761 if (isDeep) { 21762 return buffer.slice(); 21763 } 21764 var length = buffer.length, 21765 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 21766 21767 buffer.copy(result); 21768 return result; 21769 } 21770 21771 /** 21772 * Creates a clone of `arrayBuffer`. 21773 * 21774 * @private 21775 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 21776 * @returns {ArrayBuffer} Returns the cloned array buffer. 21777 */ 21778 function cloneArrayBuffer(arrayBuffer) { 21779 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 21780 new Uint8Array(result).set(new Uint8Array(arrayBuffer)); 21781 return result; 21782 } 21783 21784 /** 21785 * Creates a clone of `dataView`. 21786 * 21787 * @private 21788 * @param {Object} dataView The data view to clone. 21789 * @param {boolean} [isDeep] Specify a deep clone. 21790 * @returns {Object} Returns the cloned data view. 21791 */ 21792 function cloneDataView(dataView, isDeep) { 21793 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; 21794 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 21795 } 21796 21797 /** 21798 * Creates a clone of `regexp`. 21799 * 21800 * @private 21801 * @param {Object} regexp The regexp to clone. 21802 * @returns {Object} Returns the cloned regexp. 21803 */ 21804 function cloneRegExp(regexp) { 21805 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 21806 result.lastIndex = regexp.lastIndex; 21807 return result; 21808 } 21809 21810 /** 21811 * Creates a clone of the `symbol` object. 21812 * 21813 * @private 21814 * @param {Object} symbol The symbol object to clone. 21815 * @returns {Object} Returns the cloned symbol object. 21816 */ 21817 function cloneSymbol(symbol) { 21818 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 21819 } 21820 21821 /** 21822 * Creates a clone of `typedArray`. 21823 * 21824 * @private 21825 * @param {Object} typedArray The typed array to clone. 21826 * @param {boolean} [isDeep] Specify a deep clone. 21827 * @returns {Object} Returns the cloned typed array. 21828 */ 21829 function cloneTypedArray(typedArray, isDeep) { 21830 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 21831 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 21832 } 21833 21834 /** 21835 * Compares values to sort them in ascending order. 21836 * 21837 * @private 21838 * @param {*} value The value to compare. 21839 * @param {*} other The other value to compare. 21840 * @returns {number} Returns the sort order indicator for `value`. 21841 */ 21842 function compareAscending(value, other) { 21843 if (value !== other) { 21844 var valIsDefined = value !== undefined, 21845 valIsNull = value === null, 21846 valIsReflexive = value === value, 21847 valIsSymbol = isSymbol(value); 21848 21849 var othIsDefined = other !== undefined, 21850 othIsNull = other === null, 21851 othIsReflexive = other === other, 21852 othIsSymbol = isSymbol(other); 21853 21854 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || 21855 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || 21856 (valIsNull && othIsDefined && othIsReflexive) || 21857 (!valIsDefined && othIsReflexive) || 21858 !valIsReflexive) { 21859 return 1; 21860 } 21861 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || 21862 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || 21863 (othIsNull && valIsDefined && valIsReflexive) || 21864 (!othIsDefined && valIsReflexive) || 21865 !othIsReflexive) { 21866 return -1; 21867 } 21868 } 21869 return 0; 21870 } 21871 21872 /** 21873 * Used by `_.orderBy` to compare multiple properties of a value to another 21874 * and stable sort them. 21875 * 21876 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, 21877 * specify an order of "desc" for descending or "asc" for ascending sort order 21878 * of corresponding values. 21879 * 21880 * @private 21881 * @param {Object} object The object to compare. 21882 * @param {Object} other The other object to compare. 21883 * @param {boolean[]|string[]} orders The order to sort by for each property. 21884 * @returns {number} Returns the sort order indicator for `object`. 21885 */ 21886 function compareMultiple(object, other, orders) { 21887 var index = -1, 21888 objCriteria = object.criteria, 21889 othCriteria = other.criteria, 21890 length = objCriteria.length, 21891 ordersLength = orders.length; 21892 21893 while (++index < length) { 21894 var result = compareAscending(objCriteria[index], othCriteria[index]); 21895 if (result) { 21896 if (index >= ordersLength) { 21897 return result; 21898 } 21899 var order = orders[index]; 21900 return result * (order == 'desc' ? -1 : 1); 21901 } 21902 } 21903 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications 21904 // that causes it, under certain circumstances, to provide the same value for 21905 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 21906 // for more details. 21907 // 21908 // This also ensures a stable sort in V8 and other engines. 21909 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. 21910 return object.index - other.index; 21911 } 21912 21913 /** 21914 * Creates an array that is the composition of partially applied arguments, 21915 * placeholders, and provided arguments into a single array of arguments. 21916 * 21917 * @private 21918 * @param {Array} args The provided arguments. 21919 * @param {Array} partials The arguments to prepend to those provided. 21920 * @param {Array} holders The `partials` placeholder indexes. 21921 * @params {boolean} [isCurried] Specify composing for a curried function. 21922 * @returns {Array} Returns the new array of composed arguments. 21923 */ 21924 function composeArgs(args, partials, holders, isCurried) { 21925 var argsIndex = -1, 21926 argsLength = args.length, 21927 holdersLength = holders.length, 21928 leftIndex = -1, 21929 leftLength = partials.length, 21930 rangeLength = nativeMax(argsLength - holdersLength, 0), 21931 result = Array(leftLength + rangeLength), 21932 isUncurried = !isCurried; 21933 21934 while (++leftIndex < leftLength) { 21935 result[leftIndex] = partials[leftIndex]; 21936 } 21937 while (++argsIndex < holdersLength) { 21938 if (isUncurried || argsIndex < argsLength) { 21939 result[holders[argsIndex]] = args[argsIndex]; 21940 } 21941 } 21942 while (rangeLength--) { 21943 result[leftIndex++] = args[argsIndex++]; 21944 } 21945 return result; 21946 } 21947 21948 /** 21949 * This function is like `composeArgs` except that the arguments composition 21950 * is tailored for `_.partialRight`. 21951 * 21952 * @private 21953 * @param {Array} args The provided arguments. 21954 * @param {Array} partials The arguments to append to those provided. 21955 * @param {Array} holders The `partials` placeholder indexes. 21956 * @params {boolean} [isCurried] Specify composing for a curried function. 21957 * @returns {Array} Returns the new array of composed arguments. 21958 */ 21959 function composeArgsRight(args, partials, holders, isCurried) { 21960 var argsIndex = -1, 21961 argsLength = args.length, 21962 holdersIndex = -1, 21963 holdersLength = holders.length, 21964 rightIndex = -1, 21965 rightLength = partials.length, 21966 rangeLength = nativeMax(argsLength - holdersLength, 0), 21967 result = Array(rangeLength + rightLength), 21968 isUncurried = !isCurried; 21969 21970 while (++argsIndex < rangeLength) { 21971 result[argsIndex] = args[argsIndex]; 21972 } 21973 var offset = argsIndex; 21974 while (++rightIndex < rightLength) { 21975 result[offset + rightIndex] = partials[rightIndex]; 21976 } 21977 while (++holdersIndex < holdersLength) { 21978 if (isUncurried || argsIndex < argsLength) { 21979 result[offset + holders[holdersIndex]] = args[argsIndex++]; 21980 } 21981 } 21982 return result; 21983 } 21984 21985 /** 21986 * Copies the values of `source` to `array`. 21987 * 21988 * @private 21989 * @param {Array} source The array to copy values from. 21990 * @param {Array} [array=[]] The array to copy values to. 21991 * @returns {Array} Returns `array`. 21992 */ 21993 function copyArray(source, array) { 21994 var index = -1, 21995 length = source.length; 21996 21997 array || (array = Array(length)); 21998 while (++index < length) { 21999 array[index] = source[index]; 22000 } 22001 return array; 22002 } 22003 22004 /** 22005 * Copies properties of `source` to `object`. 22006 * 22007 * @private 22008 * @param {Object} source The object to copy properties from. 22009 * @param {Array} props The property identifiers to copy. 22010 * @param {Object} [object={}] The object to copy properties to. 22011 * @param {Function} [customizer] The function to customize copied values. 22012 * @returns {Object} Returns `object`. 22013 */ 22014 function copyObject(source, props, object, customizer) { 22015 var isNew = !object; 22016 object || (object = {}); 22017 22018 var index = -1, 22019 length = props.length; 22020 22021 while (++index < length) { 22022 var key = props[index]; 22023 22024 var newValue = customizer 22025 ? customizer(object[key], source[key], key, object, source) 22026 : undefined; 22027 22028 if (newValue === undefined) { 22029 newValue = source[key]; 22030 } 22031 if (isNew) { 22032 baseAssignValue(object, key, newValue); 22033 } else { 22034 assignValue(object, key, newValue); 22035 } 22036 } 22037 return object; 22038 } 22039 22040 /** 22041 * Copies own symbols of `source` to `object`. 22042 * 22043 * @private 22044 * @param {Object} source The object to copy symbols from. 22045 * @param {Object} [object={}] The object to copy symbols to. 22046 * @returns {Object} Returns `object`. 22047 */ 22048 function copySymbols(source, object) { 22049 return copyObject(source, getSymbols(source), object); 22050 } 22051 22052 /** 22053 * Copies own and inherited symbols of `source` to `object`. 22054 * 22055 * @private 22056 * @param {Object} source The object to copy symbols from. 22057 * @param {Object} [object={}] The object to copy symbols to. 22058 * @returns {Object} Returns `object`. 22059 */ 22060 function copySymbolsIn(source, object) { 22061 return copyObject(source, getSymbolsIn(source), object); 22062 } 22063 22064 /** 22065 * Creates a function like `_.groupBy`. 22066 * 22067 * @private 22068 * @param {Function} setter The function to set accumulator values. 22069 * @param {Function} [initializer] The accumulator object initializer. 22070 * @returns {Function} Returns the new aggregator function. 22071 */ 22072 function createAggregator(setter, initializer) { 22073 return function(collection, iteratee) { 22074 var func = isArray(collection) ? arrayAggregator : baseAggregator, 22075 accumulator = initializer ? initializer() : {}; 22076 22077 return func(collection, setter, getIteratee(iteratee, 2), accumulator); 22078 }; 22079 } 22080 22081 /** 22082 * Creates a function like `_.assign`. 22083 * 22084 * @private 22085 * @param {Function} assigner The function to assign values. 22086 * @returns {Function} Returns the new assigner function. 22087 */ 22088 function createAssigner(assigner) { 22089 return baseRest(function(object, sources) { 22090 var index = -1, 22091 length = sources.length, 22092 customizer = length > 1 ? sources[length - 1] : undefined, 22093 guard = length > 2 ? sources[2] : undefined; 22094 22095 customizer = (assigner.length > 3 && typeof customizer == 'function') 22096 ? (length--, customizer) 22097 : undefined; 22098 22099 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 22100 customizer = length < 3 ? undefined : customizer; 22101 length = 1; 22102 } 22103 object = Object(object); 22104 while (++index < length) { 22105 var source = sources[index]; 22106 if (source) { 22107 assigner(object, source, index, customizer); 22108 } 22109 } 22110 return object; 22111 }); 22112 } 22113 22114 /** 22115 * Creates a `baseEach` or `baseEachRight` function. 22116 * 22117 * @private 22118 * @param {Function} eachFunc The function to iterate over a collection. 22119 * @param {boolean} [fromRight] Specify iterating from right to left. 22120 * @returns {Function} Returns the new base function. 22121 */ 22122 function createBaseEach(eachFunc, fromRight) { 22123 return function(collection, iteratee) { 22124 if (collection == null) { 22125 return collection; 22126 } 22127 if (!isArrayLike(collection)) { 22128 return eachFunc(collection, iteratee); 22129 } 22130 var length = collection.length, 22131 index = fromRight ? length : -1, 22132 iterable = Object(collection); 22133 22134 while ((fromRight ? index-- : ++index < length)) { 22135 if (iteratee(iterable[index], index, iterable) === false) { 22136 break; 22137 } 22138 } 22139 return collection; 22140 }; 22141 } 22142 22143 /** 22144 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 22145 * 22146 * @private 22147 * @param {boolean} [fromRight] Specify iterating from right to left. 22148 * @returns {Function} Returns the new base function. 22149 */ 22150 function createBaseFor(fromRight) { 22151 return function(object, iteratee, keysFunc) { 22152 var index = -1, 22153 iterable = Object(object), 22154 props = keysFunc(object), 22155 length = props.length; 22156 22157 while (length--) { 22158 var key = props[fromRight ? length : ++index]; 22159 if (iteratee(iterable[key], key, iterable) === false) { 22160 break; 22161 } 22162 } 22163 return object; 22164 }; 22165 } 22166 22167 /** 22168 * Creates a function that wraps `func` to invoke it with the optional `this` 22169 * binding of `thisArg`. 22170 * 22171 * @private 22172 * @param {Function} func The function to wrap. 22173 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 22174 * @param {*} [thisArg] The `this` binding of `func`. 22175 * @returns {Function} Returns the new wrapped function. 22176 */ 22177 function createBind(func, bitmask, thisArg) { 22178 var isBind = bitmask & WRAP_BIND_FLAG, 22179 Ctor = createCtor(func); 22180 22181 function wrapper() { 22182 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 22183 return fn.apply(isBind ? thisArg : this, arguments); 22184 } 22185 return wrapper; 22186 } 22187 22188 /** 22189 * Creates a function like `_.lowerFirst`. 22190 * 22191 * @private 22192 * @param {string} methodName The name of the `String` case method to use. 22193 * @returns {Function} Returns the new case function. 22194 */ 22195 function createCaseFirst(methodName) { 22196 return function(string) { 22197 string = toString(string); 22198 22199 var strSymbols = hasUnicode(string) 22200 ? stringToArray(string) 22201 : undefined; 22202 22203 var chr = strSymbols 22204 ? strSymbols[0] 22205 : string.charAt(0); 22206 22207 var trailing = strSymbols 22208 ? castSlice(strSymbols, 1).join('') 22209 : string.slice(1); 22210 22211 return chr[methodName]() + trailing; 22212 }; 22213 } 22214 22215 /** 22216 * Creates a function like `_.camelCase`. 22217 * 22218 * @private 22219 * @param {Function} callback The function to combine each word. 22220 * @returns {Function} Returns the new compounder function. 22221 */ 22222 function createCompounder(callback) { 22223 return function(string) { 22224 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); 22225 }; 22226 } 22227 22228 /** 22229 * Creates a function that produces an instance of `Ctor` regardless of 22230 * whether it was invoked as part of a `new` expression or by `call` or `apply`. 22231 * 22232 * @private 22233 * @param {Function} Ctor The constructor to wrap. 22234 * @returns {Function} Returns the new wrapped function. 22235 */ 22236 function createCtor(Ctor) { 22237 return function() { 22238 // Use a `switch` statement to work with class constructors. See 22239 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist 22240 // for more details. 22241 var args = arguments; 22242 switch (args.length) { 22243 case 0: return new Ctor; 22244 case 1: return new Ctor(args[0]); 22245 case 2: return new Ctor(args[0], args[1]); 22246 case 3: return new Ctor(args[0], args[1], args[2]); 22247 case 4: return new Ctor(args[0], args[1], args[2], args[3]); 22248 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); 22249 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); 22250 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); 22251 } 22252 var thisBinding = baseCreate(Ctor.prototype), 22253 result = Ctor.apply(thisBinding, args); 22254 22255 // Mimic the constructor's `return` behavior. 22256 // See https://es5.github.io/#x13.2.2 for more details. 22257 return isObject(result) ? result : thisBinding; 22258 }; 22259 } 22260 22261 /** 22262 * Creates a function that wraps `func` to enable currying. 22263 * 22264 * @private 22265 * @param {Function} func The function to wrap. 22266 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 22267 * @param {number} arity The arity of `func`. 22268 * @returns {Function} Returns the new wrapped function. 22269 */ 22270 function createCurry(func, bitmask, arity) { 22271 var Ctor = createCtor(func); 22272 22273 function wrapper() { 22274 var length = arguments.length, 22275 args = Array(length), 22276 index = length, 22277 placeholder = getHolder(wrapper); 22278 22279 while (index--) { 22280 args[index] = arguments[index]; 22281 } 22282 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) 22283 ? [] 22284 : replaceHolders(args, placeholder); 22285 22286 length -= holders.length; 22287 if (length < arity) { 22288 return createRecurry( 22289 func, bitmask, createHybrid, wrapper.placeholder, undefined, 22290 args, holders, undefined, undefined, arity - length); 22291 } 22292 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 22293 return apply(fn, this, args); 22294 } 22295 return wrapper; 22296 } 22297 22298 /** 22299 * Creates a `_.find` or `_.findLast` function. 22300 * 22301 * @private 22302 * @param {Function} findIndexFunc The function to find the collection index. 22303 * @returns {Function} Returns the new find function. 22304 */ 22305 function createFind(findIndexFunc) { 22306 return function(collection, predicate, fromIndex) { 22307 var iterable = Object(collection); 22308 if (!isArrayLike(collection)) { 22309 var iteratee = getIteratee(predicate, 3); 22310 collection = keys(collection); 22311 predicate = function(key) { return iteratee(iterable[key], key, iterable); }; 22312 } 22313 var index = findIndexFunc(collection, predicate, fromIndex); 22314 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; 22315 }; 22316 } 22317 22318 /** 22319 * Creates a `_.flow` or `_.flowRight` function. 22320 * 22321 * @private 22322 * @param {boolean} [fromRight] Specify iterating from right to left. 22323 * @returns {Function} Returns the new flow function. 22324 */ 22325 function createFlow(fromRight) { 22326 return flatRest(function(funcs) { 22327 var length = funcs.length, 22328 index = length, 22329 prereq = LodashWrapper.prototype.thru; 22330 22331 if (fromRight) { 22332 funcs.reverse(); 22333 } 22334 while (index--) { 22335 var func = funcs[index]; 22336 if (typeof func != 'function') { 22337 throw new TypeError(FUNC_ERROR_TEXT); 22338 } 22339 if (prereq && !wrapper && getFuncName(func) == 'wrapper') { 22340 var wrapper = new LodashWrapper([], true); 22341 } 22342 } 22343 index = wrapper ? index : length; 22344 while (++index < length) { 22345 func = funcs[index]; 22346 22347 var funcName = getFuncName(func), 22348 data = funcName == 'wrapper' ? getData(func) : undefined; 22349 22350 if (data && isLaziable(data[0]) && 22351 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && 22352 !data[4].length && data[9] == 1 22353 ) { 22354 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); 22355 } else { 22356 wrapper = (func.length == 1 && isLaziable(func)) 22357 ? wrapper[funcName]() 22358 : wrapper.thru(func); 22359 } 22360 } 22361 return function() { 22362 var args = arguments, 22363 value = args[0]; 22364 22365 if (wrapper && args.length == 1 && isArray(value)) { 22366 return wrapper.plant(value).value(); 22367 } 22368 var index = 0, 22369 result = length ? funcs[index].apply(this, args) : value; 22370 22371 while (++index < length) { 22372 result = funcs[index].call(this, result); 22373 } 22374 return result; 22375 }; 22376 }); 22377 } 22378 22379 /** 22380 * Creates a function that wraps `func` to invoke it with optional `this` 22381 * binding of `thisArg`, partial application, and currying. 22382 * 22383 * @private 22384 * @param {Function|string} func The function or method name to wrap. 22385 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 22386 * @param {*} [thisArg] The `this` binding of `func`. 22387 * @param {Array} [partials] The arguments to prepend to those provided to 22388 * the new function. 22389 * @param {Array} [holders] The `partials` placeholder indexes. 22390 * @param {Array} [partialsRight] The arguments to append to those provided 22391 * to the new function. 22392 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. 22393 * @param {Array} [argPos] The argument positions of the new function. 22394 * @param {number} [ary] The arity cap of `func`. 22395 * @param {number} [arity] The arity of `func`. 22396 * @returns {Function} Returns the new wrapped function. 22397 */ 22398 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { 22399 var isAry = bitmask & WRAP_ARY_FLAG, 22400 isBind = bitmask & WRAP_BIND_FLAG, 22401 isBindKey = bitmask & WRAP_BIND_KEY_FLAG, 22402 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), 22403 isFlip = bitmask & WRAP_FLIP_FLAG, 22404 Ctor = isBindKey ? undefined : createCtor(func); 22405 22406 function wrapper() { 22407 var length = arguments.length, 22408 args = Array(length), 22409 index = length; 22410 22411 while (index--) { 22412 args[index] = arguments[index]; 22413 } 22414 if (isCurried) { 22415 var placeholder = getHolder(wrapper), 22416 holdersCount = countHolders(args, placeholder); 22417 } 22418 if (partials) { 22419 args = composeArgs(args, partials, holders, isCurried); 22420 } 22421 if (partialsRight) { 22422 args = composeArgsRight(args, partialsRight, holdersRight, isCurried); 22423 } 22424 length -= holdersCount; 22425 if (isCurried && length < arity) { 22426 var newHolders = replaceHolders(args, placeholder); 22427 return createRecurry( 22428 func, bitmask, createHybrid, wrapper.placeholder, thisArg, 22429 args, newHolders, argPos, ary, arity - length 22430 ); 22431 } 22432 var thisBinding = isBind ? thisArg : this, 22433 fn = isBindKey ? thisBinding[func] : func; 22434 22435 length = args.length; 22436 if (argPos) { 22437 args = reorder(args, argPos); 22438 } else if (isFlip && length > 1) { 22439 args.reverse(); 22440 } 22441 if (isAry && ary < length) { 22442 args.length = ary; 22443 } 22444 if (this && this !== root && this instanceof wrapper) { 22445 fn = Ctor || createCtor(fn); 22446 } 22447 return fn.apply(thisBinding, args); 22448 } 22449 return wrapper; 22450 } 22451 22452 /** 22453 * Creates a function like `_.invertBy`. 22454 * 22455 * @private 22456 * @param {Function} setter The function to set accumulator values. 22457 * @param {Function} toIteratee The function to resolve iteratees. 22458 * @returns {Function} Returns the new inverter function. 22459 */ 22460 function createInverter(setter, toIteratee) { 22461 return function(object, iteratee) { 22462 return baseInverter(object, setter, toIteratee(iteratee), {}); 22463 }; 22464 } 22465 22466 /** 22467 * Creates a function that performs a mathematical operation on two values. 22468 * 22469 * @private 22470 * @param {Function} operator The function to perform the operation. 22471 * @param {number} [defaultValue] The value used for `undefined` arguments. 22472 * @returns {Function} Returns the new mathematical operation function. 22473 */ 22474 function createMathOperation(operator, defaultValue) { 22475 return function(value, other) { 22476 var result; 22477 if (value === undefined && other === undefined) { 22478 return defaultValue; 22479 } 22480 if (value !== undefined) { 22481 result = value; 22482 } 22483 if (other !== undefined) { 22484 if (result === undefined) { 22485 return other; 22486 } 22487 if (typeof value == 'string' || typeof other == 'string') { 22488 value = baseToString(value); 22489 other = baseToString(other); 22490 } else { 22491 value = baseToNumber(value); 22492 other = baseToNumber(other); 22493 } 22494 result = operator(value, other); 22495 } 22496 return result; 22497 }; 22498 } 22499 22500 /** 22501 * Creates a function like `_.over`. 22502 * 22503 * @private 22504 * @param {Function} arrayFunc The function to iterate over iteratees. 22505 * @returns {Function} Returns the new over function. 22506 */ 22507 function createOver(arrayFunc) { 22508 return flatRest(function(iteratees) { 22509 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 22510 return baseRest(function(args) { 22511 var thisArg = this; 22512 return arrayFunc(iteratees, function(iteratee) { 22513 return apply(iteratee, thisArg, args); 22514 }); 22515 }); 22516 }); 22517 } 22518 22519 /** 22520 * Creates the padding for `string` based on `length`. The `chars` string 22521 * is truncated if the number of characters exceeds `length`. 22522 * 22523 * @private 22524 * @param {number} length The padding length. 22525 * @param {string} [chars=' '] The string used as padding. 22526 * @returns {string} Returns the padding for `string`. 22527 */ 22528 function createPadding(length, chars) { 22529 chars = chars === undefined ? ' ' : baseToString(chars); 22530 22531 var charsLength = chars.length; 22532 if (charsLength < 2) { 22533 return charsLength ? baseRepeat(chars, length) : chars; 22534 } 22535 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); 22536 return hasUnicode(chars) 22537 ? castSlice(stringToArray(result), 0, length).join('') 22538 : result.slice(0, length); 22539 } 22540 22541 /** 22542 * Creates a function that wraps `func` to invoke it with the `this` binding 22543 * of `thisArg` and `partials` prepended to the arguments it receives. 22544 * 22545 * @private 22546 * @param {Function} func The function to wrap. 22547 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 22548 * @param {*} thisArg The `this` binding of `func`. 22549 * @param {Array} partials The arguments to prepend to those provided to 22550 * the new function. 22551 * @returns {Function} Returns the new wrapped function. 22552 */ 22553 function createPartial(func, bitmask, thisArg, partials) { 22554 var isBind = bitmask & WRAP_BIND_FLAG, 22555 Ctor = createCtor(func); 22556 22557 function wrapper() { 22558 var argsIndex = -1, 22559 argsLength = arguments.length, 22560 leftIndex = -1, 22561 leftLength = partials.length, 22562 args = Array(leftLength + argsLength), 22563 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 22564 22565 while (++leftIndex < leftLength) { 22566 args[leftIndex] = partials[leftIndex]; 22567 } 22568 while (argsLength--) { 22569 args[leftIndex++] = arguments[++argsIndex]; 22570 } 22571 return apply(fn, isBind ? thisArg : this, args); 22572 } 22573 return wrapper; 22574 } 22575 22576 /** 22577 * Creates a `_.range` or `_.rangeRight` function. 22578 * 22579 * @private 22580 * @param {boolean} [fromRight] Specify iterating from right to left. 22581 * @returns {Function} Returns the new range function. 22582 */ 22583 function createRange(fromRight) { 22584 return function(start, end, step) { 22585 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { 22586 end = step = undefined; 22587 } 22588 // Ensure the sign of `-0` is preserved. 22589 start = toFinite(start); 22590 if (end === undefined) { 22591 end = start; 22592 start = 0; 22593 } else { 22594 end = toFinite(end); 22595 } 22596 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); 22597 return baseRange(start, end, step, fromRight); 22598 }; 22599 } 22600 22601 /** 22602 * Creates a function that performs a relational operation on two values. 22603 * 22604 * @private 22605 * @param {Function} operator The function to perform the operation. 22606 * @returns {Function} Returns the new relational operation function. 22607 */ 22608 function createRelationalOperation(operator) { 22609 return function(value, other) { 22610 if (!(typeof value == 'string' && typeof other == 'string')) { 22611 value = toNumber(value); 22612 other = toNumber(other); 22613 } 22614 return operator(value, other); 22615 }; 22616 } 22617 22618 /** 22619 * Creates a function that wraps `func` to continue currying. 22620 * 22621 * @private 22622 * @param {Function} func The function to wrap. 22623 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 22624 * @param {Function} wrapFunc The function to create the `func` wrapper. 22625 * @param {*} placeholder The placeholder value. 22626 * @param {*} [thisArg] The `this` binding of `func`. 22627 * @param {Array} [partials] The arguments to prepend to those provided to 22628 * the new function. 22629 * @param {Array} [holders] The `partials` placeholder indexes. 22630 * @param {Array} [argPos] The argument positions of the new function. 22631 * @param {number} [ary] The arity cap of `func`. 22632 * @param {number} [arity] The arity of `func`. 22633 * @returns {Function} Returns the new wrapped function. 22634 */ 22635 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { 22636 var isCurry = bitmask & WRAP_CURRY_FLAG, 22637 newHolders = isCurry ? holders : undefined, 22638 newHoldersRight = isCurry ? undefined : holders, 22639 newPartials = isCurry ? partials : undefined, 22640 newPartialsRight = isCurry ? undefined : partials; 22641 22642 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); 22643 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); 22644 22645 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { 22646 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); 22647 } 22648 var newData = [ 22649 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, 22650 newHoldersRight, argPos, ary, arity 22651 ]; 22652 22653 var result = wrapFunc.apply(undefined, newData); 22654 if (isLaziable(func)) { 22655 setData(result, newData); 22656 } 22657 result.placeholder = placeholder; 22658 return setWrapToString(result, func, bitmask); 22659 } 22660 22661 /** 22662 * Creates a function like `_.round`. 22663 * 22664 * @private 22665 * @param {string} methodName The name of the `Math` method to use when rounding. 22666 * @returns {Function} Returns the new round function. 22667 */ 22668 function createRound(methodName) { 22669 var func = Math[methodName]; 22670 return function(number, precision) { 22671 number = toNumber(number); 22672 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); 22673 if (precision && nativeIsFinite(number)) { 22674 // Shift with exponential notation to avoid floating-point issues. 22675 // See [MDN](https://mdn.io/round#Examples) for more details. 22676 var pair = (toString(number) + 'e').split('e'), 22677 value = func(pair[0] + 'e' + (+pair[1] + precision)); 22678 22679 pair = (toString(value) + 'e').split('e'); 22680 return +(pair[0] + 'e' + (+pair[1] - precision)); 22681 } 22682 return func(number); 22683 }; 22684 } 22685 22686 /** 22687 * Creates a set object of `values`. 22688 * 22689 * @private 22690 * @param {Array} values The values to add to the set. 22691 * @returns {Object} Returns the new set. 22692 */ 22693 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { 22694 return new Set(values); 22695 }; 22696 22697 /** 22698 * Creates a `_.toPairs` or `_.toPairsIn` function. 22699 * 22700 * @private 22701 * @param {Function} keysFunc The function to get the keys of a given object. 22702 * @returns {Function} Returns the new pairs function. 22703 */ 22704 function createToPairs(keysFunc) { 22705 return function(object) { 22706 var tag = getTag(object); 22707 if (tag == mapTag) { 22708 return mapToArray(object); 22709 } 22710 if (tag == setTag) { 22711 return setToPairs(object); 22712 } 22713 return baseToPairs(object, keysFunc(object)); 22714 }; 22715 } 22716 22717 /** 22718 * Creates a function that either curries or invokes `func` with optional 22719 * `this` binding and partially applied arguments. 22720 * 22721 * @private 22722 * @param {Function|string} func The function or method name to wrap. 22723 * @param {number} bitmask The bitmask flags. 22724 * 1 - `_.bind` 22725 * 2 - `_.bindKey` 22726 * 4 - `_.curry` or `_.curryRight` of a bound function 22727 * 8 - `_.curry` 22728 * 16 - `_.curryRight` 22729 * 32 - `_.partial` 22730 * 64 - `_.partialRight` 22731 * 128 - `_.rearg` 22732 * 256 - `_.ary` 22733 * 512 - `_.flip` 22734 * @param {*} [thisArg] The `this` binding of `func`. 22735 * @param {Array} [partials] The arguments to be partially applied. 22736 * @param {Array} [holders] The `partials` placeholder indexes. 22737 * @param {Array} [argPos] The argument positions of the new function. 22738 * @param {number} [ary] The arity cap of `func`. 22739 * @param {number} [arity] The arity of `func`. 22740 * @returns {Function} Returns the new wrapped function. 22741 */ 22742 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { 22743 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; 22744 if (!isBindKey && typeof func != 'function') { 22745 throw new TypeError(FUNC_ERROR_TEXT); 22746 } 22747 var length = partials ? partials.length : 0; 22748 if (!length) { 22749 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); 22750 partials = holders = undefined; 22751 } 22752 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); 22753 arity = arity === undefined ? arity : toInteger(arity); 22754 length -= holders ? holders.length : 0; 22755 22756 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { 22757 var partialsRight = partials, 22758 holdersRight = holders; 22759 22760 partials = holders = undefined; 22761 } 22762 var data = isBindKey ? undefined : getData(func); 22763 22764 var newData = [ 22765 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, 22766 argPos, ary, arity 22767 ]; 22768 22769 if (data) { 22770 mergeData(newData, data); 22771 } 22772 func = newData[0]; 22773 bitmask = newData[1]; 22774 thisArg = newData[2]; 22775 partials = newData[3]; 22776 holders = newData[4]; 22777 arity = newData[9] = newData[9] === undefined 22778 ? (isBindKey ? 0 : func.length) 22779 : nativeMax(newData[9] - length, 0); 22780 22781 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { 22782 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); 22783 } 22784 if (!bitmask || bitmask == WRAP_BIND_FLAG) { 22785 var result = createBind(func, bitmask, thisArg); 22786 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { 22787 result = createCurry(func, bitmask, arity); 22788 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { 22789 result = createPartial(func, bitmask, thisArg, partials); 22790 } else { 22791 result = createHybrid.apply(undefined, newData); 22792 } 22793 var setter = data ? baseSetData : setData; 22794 return setWrapToString(setter(result, newData), func, bitmask); 22795 } 22796 22797 /** 22798 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties 22799 * of source objects to the destination object for all destination properties 22800 * that resolve to `undefined`. 22801 * 22802 * @private 22803 * @param {*} objValue The destination value. 22804 * @param {*} srcValue The source value. 22805 * @param {string} key The key of the property to assign. 22806 * @param {Object} object The parent object of `objValue`. 22807 * @returns {*} Returns the value to assign. 22808 */ 22809 function customDefaultsAssignIn(objValue, srcValue, key, object) { 22810 if (objValue === undefined || 22811 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { 22812 return srcValue; 22813 } 22814 return objValue; 22815 } 22816 22817 /** 22818 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source 22819 * objects into destination objects that are passed thru. 22820 * 22821 * @private 22822 * @param {*} objValue The destination value. 22823 * @param {*} srcValue The source value. 22824 * @param {string} key The key of the property to merge. 22825 * @param {Object} object The parent object of `objValue`. 22826 * @param {Object} source The parent object of `srcValue`. 22827 * @param {Object} [stack] Tracks traversed source values and their merged 22828 * counterparts. 22829 * @returns {*} Returns the value to assign. 22830 */ 22831 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { 22832 if (isObject(objValue) && isObject(srcValue)) { 22833 // Recursively merge objects and arrays (susceptible to call stack limits). 22834 stack.set(srcValue, objValue); 22835 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); 22836 stack['delete'](srcValue); 22837 } 22838 return objValue; 22839 } 22840 22841 /** 22842 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain 22843 * objects. 22844 * 22845 * @private 22846 * @param {*} value The value to inspect. 22847 * @param {string} key The key of the property to inspect. 22848 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. 22849 */ 22850 function customOmitClone(value) { 22851 return isPlainObject(value) ? undefined : value; 22852 } 22853 22854 /** 22855 * A specialized version of `baseIsEqualDeep` for arrays with support for 22856 * partial deep comparisons. 22857 * 22858 * @private 22859 * @param {Array} array The array to compare. 22860 * @param {Array} other The other array to compare. 22861 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 22862 * @param {Function} customizer The function to customize comparisons. 22863 * @param {Function} equalFunc The function to determine equivalents of values. 22864 * @param {Object} stack Tracks traversed `array` and `other` objects. 22865 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 22866 */ 22867 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 22868 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 22869 arrLength = array.length, 22870 othLength = other.length; 22871 22872 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 22873 return false; 22874 } 22875 // Check that cyclic values are equal. 22876 var arrStacked = stack.get(array); 22877 var othStacked = stack.get(other); 22878 if (arrStacked && othStacked) { 22879 return arrStacked == other && othStacked == array; 22880 } 22881 var index = -1, 22882 result = true, 22883 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; 22884 22885 stack.set(array, other); 22886 stack.set(other, array); 22887 22888 // Ignore non-index properties. 22889 while (++index < arrLength) { 22890 var arrValue = array[index], 22891 othValue = other[index]; 22892 22893 if (customizer) { 22894 var compared = isPartial 22895 ? customizer(othValue, arrValue, index, other, array, stack) 22896 : customizer(arrValue, othValue, index, array, other, stack); 22897 } 22898 if (compared !== undefined) { 22899 if (compared) { 22900 continue; 22901 } 22902 result = false; 22903 break; 22904 } 22905 // Recursively compare arrays (susceptible to call stack limits). 22906 if (seen) { 22907 if (!arraySome(other, function(othValue, othIndex) { 22908 if (!cacheHas(seen, othIndex) && 22909 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 22910 return seen.push(othIndex); 22911 } 22912 })) { 22913 result = false; 22914 break; 22915 } 22916 } else if (!( 22917 arrValue === othValue || 22918 equalFunc(arrValue, othValue, bitmask, customizer, stack) 22919 )) { 22920 result = false; 22921 break; 22922 } 22923 } 22924 stack['delete'](array); 22925 stack['delete'](other); 22926 return result; 22927 } 22928 22929 /** 22930 * A specialized version of `baseIsEqualDeep` for comparing objects of 22931 * the same `toStringTag`. 22932 * 22933 * **Note:** This function only supports comparing values with tags of 22934 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 22935 * 22936 * @private 22937 * @param {Object} object The object to compare. 22938 * @param {Object} other The other object to compare. 22939 * @param {string} tag The `toStringTag` of the objects to compare. 22940 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 22941 * @param {Function} customizer The function to customize comparisons. 22942 * @param {Function} equalFunc The function to determine equivalents of values. 22943 * @param {Object} stack Tracks traversed `object` and `other` objects. 22944 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 22945 */ 22946 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 22947 switch (tag) { 22948 case dataViewTag: 22949 if ((object.byteLength != other.byteLength) || 22950 (object.byteOffset != other.byteOffset)) { 22951 return false; 22952 } 22953 object = object.buffer; 22954 other = other.buffer; 22955 22956 case arrayBufferTag: 22957 if ((object.byteLength != other.byteLength) || 22958 !equalFunc(new Uint8Array(object), new Uint8Array(other))) { 22959 return false; 22960 } 22961 return true; 22962 22963 case boolTag: 22964 case dateTag: 22965 case numberTag: 22966 // Coerce booleans to `1` or `0` and dates to milliseconds. 22967 // Invalid dates are coerced to `NaN`. 22968 return eq(+object, +other); 22969 22970 case errorTag: 22971 return object.name == other.name && object.message == other.message; 22972 22973 case regexpTag: 22974 case stringTag: 22975 // Coerce regexes to strings and treat strings, primitives and objects, 22976 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 22977 // for more details. 22978 return object == (other + ''); 22979 22980 case mapTag: 22981 var convert = mapToArray; 22982 22983 case setTag: 22984 var isPartial = bitmask & COMPARE_PARTIAL_FLAG; 22985 convert || (convert = setToArray); 22986 22987 if (object.size != other.size && !isPartial) { 22988 return false; 22989 } 22990 // Assume cyclic values are equal. 22991 var stacked = stack.get(object); 22992 if (stacked) { 22993 return stacked == other; 22994 } 22995 bitmask |= COMPARE_UNORDERED_FLAG; 22996 22997 // Recursively compare objects (susceptible to call stack limits). 22998 stack.set(object, other); 22999 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 23000 stack['delete'](object); 23001 return result; 23002 23003 case symbolTag: 23004 if (symbolValueOf) { 23005 return symbolValueOf.call(object) == symbolValueOf.call(other); 23006 } 23007 } 23008 return false; 23009 } 23010 23011 /** 23012 * A specialized version of `baseIsEqualDeep` for objects with support for 23013 * partial deep comparisons. 23014 * 23015 * @private 23016 * @param {Object} object The object to compare. 23017 * @param {Object} other The other object to compare. 23018 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 23019 * @param {Function} customizer The function to customize comparisons. 23020 * @param {Function} equalFunc The function to determine equivalents of values. 23021 * @param {Object} stack Tracks traversed `object` and `other` objects. 23022 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 23023 */ 23024 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 23025 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 23026 objProps = getAllKeys(object), 23027 objLength = objProps.length, 23028 othProps = getAllKeys(other), 23029 othLength = othProps.length; 23030 23031 if (objLength != othLength && !isPartial) { 23032 return false; 23033 } 23034 var index = objLength; 23035 while (index--) { 23036 var key = objProps[index]; 23037 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { 23038 return false; 23039 } 23040 } 23041 // Check that cyclic values are equal. 23042 var objStacked = stack.get(object); 23043 var othStacked = stack.get(other); 23044 if (objStacked && othStacked) { 23045 return objStacked == other && othStacked == object; 23046 } 23047 var result = true; 23048 stack.set(object, other); 23049 stack.set(other, object); 23050 23051 var skipCtor = isPartial; 23052 while (++index < objLength) { 23053 key = objProps[index]; 23054 var objValue = object[key], 23055 othValue = other[key]; 23056 23057 if (customizer) { 23058 var compared = isPartial 23059 ? customizer(othValue, objValue, key, other, object, stack) 23060 : customizer(objValue, othValue, key, object, other, stack); 23061 } 23062 // Recursively compare objects (susceptible to call stack limits). 23063 if (!(compared === undefined 23064 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 23065 : compared 23066 )) { 23067 result = false; 23068 break; 23069 } 23070 skipCtor || (skipCtor = key == 'constructor'); 23071 } 23072 if (result && !skipCtor) { 23073 var objCtor = object.constructor, 23074 othCtor = other.constructor; 23075 23076 // Non `Object` object instances with different constructors are not equal. 23077 if (objCtor != othCtor && 23078 ('constructor' in object && 'constructor' in other) && 23079 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 23080 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 23081 result = false; 23082 } 23083 } 23084 stack['delete'](object); 23085 stack['delete'](other); 23086 return result; 23087 } 23088 23089 /** 23090 * A specialized version of `baseRest` which flattens the rest array. 23091 * 23092 * @private 23093 * @param {Function} func The function to apply a rest parameter to. 23094 * @returns {Function} Returns the new function. 23095 */ 23096 function flatRest(func) { 23097 return setToString(overRest(func, undefined, flatten), func + ''); 23098 } 23099 23100 /** 23101 * Creates an array of own enumerable property names and symbols of `object`. 23102 * 23103 * @private 23104 * @param {Object} object The object to query. 23105 * @returns {Array} Returns the array of property names and symbols. 23106 */ 23107 function getAllKeys(object) { 23108 return baseGetAllKeys(object, keys, getSymbols); 23109 } 23110 23111 /** 23112 * Creates an array of own and inherited enumerable property names and 23113 * symbols of `object`. 23114 * 23115 * @private 23116 * @param {Object} object The object to query. 23117 * @returns {Array} Returns the array of property names and symbols. 23118 */ 23119 function getAllKeysIn(object) { 23120 return baseGetAllKeys(object, keysIn, getSymbolsIn); 23121 } 23122 23123 /** 23124 * Gets metadata for `func`. 23125 * 23126 * @private 23127 * @param {Function} func The function to query. 23128 * @returns {*} Returns the metadata for `func`. 23129 */ 23130 var getData = !metaMap ? noop : function(func) { 23131 return metaMap.get(func); 23132 }; 23133 23134 /** 23135 * Gets the name of `func`. 23136 * 23137 * @private 23138 * @param {Function} func The function to query. 23139 * @returns {string} Returns the function name. 23140 */ 23141 function getFuncName(func) { 23142 var result = (func.name + ''), 23143 array = realNames[result], 23144 length = hasOwnProperty.call(realNames, result) ? array.length : 0; 23145 23146 while (length--) { 23147 var data = array[length], 23148 otherFunc = data.func; 23149 if (otherFunc == null || otherFunc == func) { 23150 return data.name; 23151 } 23152 } 23153 return result; 23154 } 23155 23156 /** 23157 * Gets the argument placeholder value for `func`. 23158 * 23159 * @private 23160 * @param {Function} func The function to inspect. 23161 * @returns {*} Returns the placeholder value. 23162 */ 23163 function getHolder(func) { 23164 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; 23165 return object.placeholder; 23166 } 23167 23168 /** 23169 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, 23170 * this function returns the custom method, otherwise it returns `baseIteratee`. 23171 * If arguments are provided, the chosen function is invoked with them and 23172 * its result is returned. 23173 * 23174 * @private 23175 * @param {*} [value] The value to convert to an iteratee. 23176 * @param {number} [arity] The arity of the created iteratee. 23177 * @returns {Function} Returns the chosen function or its result. 23178 */ 23179 function getIteratee() { 23180 var result = lodash.iteratee || iteratee; 23181 result = result === iteratee ? baseIteratee : result; 23182 return arguments.length ? result(arguments[0], arguments[1]) : result; 23183 } 23184 23185 /** 23186 * Gets the data for `map`. 23187 * 23188 * @private 23189 * @param {Object} map The map to query. 23190 * @param {string} key The reference key. 23191 * @returns {*} Returns the map data. 23192 */ 23193 function getMapData(map, key) { 23194 var data = map.__data__; 23195 return isKeyable(key) 23196 ? data[typeof key == 'string' ? 'string' : 'hash'] 23197 : data.map; 23198 } 23199 23200 /** 23201 * Gets the property names, values, and compare flags of `object`. 23202 * 23203 * @private 23204 * @param {Object} object The object to query. 23205 * @returns {Array} Returns the match data of `object`. 23206 */ 23207 function getMatchData(object) { 23208 var result = keys(object), 23209 length = result.length; 23210 23211 while (length--) { 23212 var key = result[length], 23213 value = object[key]; 23214 23215 result[length] = [key, value, isStrictComparable(value)]; 23216 } 23217 return result; 23218 } 23219 23220 /** 23221 * Gets the native function at `key` of `object`. 23222 * 23223 * @private 23224 * @param {Object} object The object to query. 23225 * @param {string} key The key of the method to get. 23226 * @returns {*} Returns the function if it's native, else `undefined`. 23227 */ 23228 function getNative(object, key) { 23229 var value = getValue(object, key); 23230 return baseIsNative(value) ? value : undefined; 23231 } 23232 23233 /** 23234 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 23235 * 23236 * @private 23237 * @param {*} value The value to query. 23238 * @returns {string} Returns the raw `toStringTag`. 23239 */ 23240 function getRawTag(value) { 23241 var isOwn = hasOwnProperty.call(value, symToStringTag), 23242 tag = value[symToStringTag]; 23243 23244 try { 23245 value[symToStringTag] = undefined; 23246 var unmasked = true; 23247 } catch (e) {} 23248 23249 var result = nativeObjectToString.call(value); 23250 if (unmasked) { 23251 if (isOwn) { 23252 value[symToStringTag] = tag; 23253 } else { 23254 delete value[symToStringTag]; 23255 } 23256 } 23257 return result; 23258 } 23259 23260 /** 23261 * Creates an array of the own enumerable symbols of `object`. 23262 * 23263 * @private 23264 * @param {Object} object The object to query. 23265 * @returns {Array} Returns the array of symbols. 23266 */ 23267 var getSymbols = !nativeGetSymbols ? stubArray : function(object) { 23268 if (object == null) { 23269 return []; 23270 } 23271 object = Object(object); 23272 return arrayFilter(nativeGetSymbols(object), function(symbol) { 23273 return propertyIsEnumerable.call(object, symbol); 23274 }); 23275 }; 23276 23277 /** 23278 * Creates an array of the own and inherited enumerable symbols of `object`. 23279 * 23280 * @private 23281 * @param {Object} object The object to query. 23282 * @returns {Array} Returns the array of symbols. 23283 */ 23284 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { 23285 var result = []; 23286 while (object) { 23287 arrayPush(result, getSymbols(object)); 23288 object = getPrototype(object); 23289 } 23290 return result; 23291 }; 23292 23293 /** 23294 * Gets the `toStringTag` of `value`. 23295 * 23296 * @private 23297 * @param {*} value The value to query. 23298 * @returns {string} Returns the `toStringTag`. 23299 */ 23300 var getTag = baseGetTag; 23301 23302 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 23303 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || 23304 (Map && getTag(new Map) != mapTag) || 23305 (Promise && getTag(Promise.resolve()) != promiseTag) || 23306 (Set && getTag(new Set) != setTag) || 23307 (WeakMap && getTag(new WeakMap) != weakMapTag)) { 23308 getTag = function(value) { 23309 var result = baseGetTag(value), 23310 Ctor = result == objectTag ? value.constructor : undefined, 23311 ctorString = Ctor ? toSource(Ctor) : ''; 23312 23313 if (ctorString) { 23314 switch (ctorString) { 23315 case dataViewCtorString: return dataViewTag; 23316 case mapCtorString: return mapTag; 23317 case promiseCtorString: return promiseTag; 23318 case setCtorString: return setTag; 23319 case weakMapCtorString: return weakMapTag; 23320 } 23321 } 23322 return result; 23323 }; 23324 } 23325 23326 /** 23327 * Gets the view, applying any `transforms` to the `start` and `end` positions. 23328 * 23329 * @private 23330 * @param {number} start The start of the view. 23331 * @param {number} end The end of the view. 23332 * @param {Array} transforms The transformations to apply to the view. 23333 * @returns {Object} Returns an object containing the `start` and `end` 23334 * positions of the view. 23335 */ 23336 function getView(start, end, transforms) { 23337 var index = -1, 23338 length = transforms.length; 23339 23340 while (++index < length) { 23341 var data = transforms[index], 23342 size = data.size; 23343 23344 switch (data.type) { 23345 case 'drop': start += size; break; 23346 case 'dropRight': end -= size; break; 23347 case 'take': end = nativeMin(end, start + size); break; 23348 case 'takeRight': start = nativeMax(start, end - size); break; 23349 } 23350 } 23351 return { 'start': start, 'end': end }; 23352 } 23353 23354 /** 23355 * Extracts wrapper details from the `source` body comment. 23356 * 23357 * @private 23358 * @param {string} source The source to inspect. 23359 * @returns {Array} Returns the wrapper details. 23360 */ 23361 function getWrapDetails(source) { 23362 var match = source.match(reWrapDetails); 23363 return match ? match[1].split(reSplitDetails) : []; 23364 } 23365 23366 /** 23367 * Checks if `path` exists on `object`. 23368 * 23369 * @private 23370 * @param {Object} object The object to query. 23371 * @param {Array|string} path The path to check. 23372 * @param {Function} hasFunc The function to check properties. 23373 * @returns {boolean} Returns `true` if `path` exists, else `false`. 23374 */ 23375 function hasPath(object, path, hasFunc) { 23376 path = castPath(path, object); 23377 23378 var index = -1, 23379 length = path.length, 23380 result = false; 23381 23382 while (++index < length) { 23383 var key = toKey(path[index]); 23384 if (!(result = object != null && hasFunc(object, key))) { 23385 break; 23386 } 23387 object = object[key]; 23388 } 23389 if (result || ++index != length) { 23390 return result; 23391 } 23392 length = object == null ? 0 : object.length; 23393 return !!length && isLength(length) && isIndex(key, length) && 23394 (isArray(object) || isArguments(object)); 23395 } 23396 23397 /** 23398 * Initializes an array clone. 23399 * 23400 * @private 23401 * @param {Array} array The array to clone. 23402 * @returns {Array} Returns the initialized clone. 23403 */ 23404 function initCloneArray(array) { 23405 var length = array.length, 23406 result = new array.constructor(length); 23407 23408 // Add properties assigned by `RegExp#exec`. 23409 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 23410 result.index = array.index; 23411 result.input = array.input; 23412 } 23413 return result; 23414 } 23415 23416 /** 23417 * Initializes an object clone. 23418 * 23419 * @private 23420 * @param {Object} object The object to clone. 23421 * @returns {Object} Returns the initialized clone. 23422 */ 23423 function initCloneObject(object) { 23424 return (typeof object.constructor == 'function' && !isPrototype(object)) 23425 ? baseCreate(getPrototype(object)) 23426 : {}; 23427 } 23428 23429 /** 23430 * Initializes an object clone based on its `toStringTag`. 23431 * 23432 * **Note:** This function only supports cloning values with tags of 23433 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. 23434 * 23435 * @private 23436 * @param {Object} object The object to clone. 23437 * @param {string} tag The `toStringTag` of the object to clone. 23438 * @param {boolean} [isDeep] Specify a deep clone. 23439 * @returns {Object} Returns the initialized clone. 23440 */ 23441 function initCloneByTag(object, tag, isDeep) { 23442 var Ctor = object.constructor; 23443 switch (tag) { 23444 case arrayBufferTag: 23445 return cloneArrayBuffer(object); 23446 23447 case boolTag: 23448 case dateTag: 23449 return new Ctor(+object); 23450 23451 case dataViewTag: 23452 return cloneDataView(object, isDeep); 23453 23454 case float32Tag: case float64Tag: 23455 case int8Tag: case int16Tag: case int32Tag: 23456 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: 23457 return cloneTypedArray(object, isDeep); 23458 23459 case mapTag: 23460 return new Ctor; 23461 23462 case numberTag: 23463 case stringTag: 23464 return new Ctor(object); 23465 23466 case regexpTag: 23467 return cloneRegExp(object); 23468 23469 case setTag: 23470 return new Ctor; 23471 23472 case symbolTag: 23473 return cloneSymbol(object); 23474 } 23475 } 23476 23477 /** 23478 * Inserts wrapper `details` in a comment at the top of the `source` body. 23479 * 23480 * @private 23481 * @param {string} source The source to modify. 23482 * @returns {Array} details The details to insert. 23483 * @returns {string} Returns the modified source. 23484 */ 23485 function insertWrapDetails(source, details) { 23486 var length = details.length; 23487 if (!length) { 23488 return source; 23489 } 23490 var lastIndex = length - 1; 23491 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; 23492 details = details.join(length > 2 ? ', ' : ' '); 23493 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); 23494 } 23495 23496 /** 23497 * Checks if `value` is a flattenable `arguments` object or array. 23498 * 23499 * @private 23500 * @param {*} value The value to check. 23501 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. 23502 */ 23503 function isFlattenable(value) { 23504 return isArray(value) || isArguments(value) || 23505 !!(spreadableSymbol && value && value[spreadableSymbol]); 23506 } 23507 23508 /** 23509 * Checks if `value` is a valid array-like index. 23510 * 23511 * @private 23512 * @param {*} value The value to check. 23513 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 23514 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 23515 */ 23516 function isIndex(value, length) { 23517 var type = typeof value; 23518 length = length == null ? MAX_SAFE_INTEGER : length; 23519 23520 return !!length && 23521 (type == 'number' || 23522 (type != 'symbol' && reIsUint.test(value))) && 23523 (value > -1 && value % 1 == 0 && value < length); 23524 } 23525 23526 /** 23527 * Checks if the given arguments are from an iteratee call. 23528 * 23529 * @private 23530 * @param {*} value The potential iteratee value argument. 23531 * @param {*} index The potential iteratee index or key argument. 23532 * @param {*} object The potential iteratee object argument. 23533 * @returns {boolean} Returns `true` if the arguments are from an iteratee call, 23534 * else `false`. 23535 */ 23536 function isIterateeCall(value, index, object) { 23537 if (!isObject(object)) { 23538 return false; 23539 } 23540 var type = typeof index; 23541 if (type == 'number' 23542 ? (isArrayLike(object) && isIndex(index, object.length)) 23543 : (type == 'string' && index in object) 23544 ) { 23545 return eq(object[index], value); 23546 } 23547 return false; 23548 } 23549 23550 /** 23551 * Checks if `value` is a property name and not a property path. 23552 * 23553 * @private 23554 * @param {*} value The value to check. 23555 * @param {Object} [object] The object to query keys on. 23556 * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 23557 */ 23558 function isKey(value, object) { 23559 if (isArray(value)) { 23560 return false; 23561 } 23562 var type = typeof value; 23563 if (type == 'number' || type == 'symbol' || type == 'boolean' || 23564 value == null || isSymbol(value)) { 23565 return true; 23566 } 23567 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 23568 (object != null && value in Object(object)); 23569 } 23570 23571 /** 23572 * Checks if `value` is suitable for use as unique object key. 23573 * 23574 * @private 23575 * @param {*} value The value to check. 23576 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 23577 */ 23578 function isKeyable(value) { 23579 var type = typeof value; 23580 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 23581 ? (value !== '__proto__') 23582 : (value === null); 23583 } 23584 23585 /** 23586 * Checks if `func` has a lazy counterpart. 23587 * 23588 * @private 23589 * @param {Function} func The function to check. 23590 * @returns {boolean} Returns `true` if `func` has a lazy counterpart, 23591 * else `false`. 23592 */ 23593 function isLaziable(func) { 23594 var funcName = getFuncName(func), 23595 other = lodash[funcName]; 23596 23597 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { 23598 return false; 23599 } 23600 if (func === other) { 23601 return true; 23602 } 23603 var data = getData(other); 23604 return !!data && func === data[0]; 23605 } 23606 23607 /** 23608 * Checks if `func` has its source masked. 23609 * 23610 * @private 23611 * @param {Function} func The function to check. 23612 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 23613 */ 23614 function isMasked(func) { 23615 return !!maskSrcKey && (maskSrcKey in func); 23616 } 23617 23618 /** 23619 * Checks if `func` is capable of being masked. 23620 * 23621 * @private 23622 * @param {*} value The value to check. 23623 * @returns {boolean} Returns `true` if `func` is maskable, else `false`. 23624 */ 23625 var isMaskable = coreJsData ? isFunction : stubFalse; 23626 23627 /** 23628 * Checks if `value` is likely a prototype object. 23629 * 23630 * @private 23631 * @param {*} value The value to check. 23632 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 23633 */ 23634 function isPrototype(value) { 23635 var Ctor = value && value.constructor, 23636 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; 23637 23638 return value === proto; 23639 } 23640 23641 /** 23642 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 23643 * 23644 * @private 23645 * @param {*} value The value to check. 23646 * @returns {boolean} Returns `true` if `value` if suitable for strict 23647 * equality comparisons, else `false`. 23648 */ 23649 function isStrictComparable(value) { 23650 return value === value && !isObject(value); 23651 } 23652 23653 /** 23654 * A specialized version of `matchesProperty` for source values suitable 23655 * for strict equality comparisons, i.e. `===`. 23656 * 23657 * @private 23658 * @param {string} key The key of the property to get. 23659 * @param {*} srcValue The value to match. 23660 * @returns {Function} Returns the new spec function. 23661 */ 23662 function matchesStrictComparable(key, srcValue) { 23663 return function(object) { 23664 if (object == null) { 23665 return false; 23666 } 23667 return object[key] === srcValue && 23668 (srcValue !== undefined || (key in Object(object))); 23669 }; 23670 } 23671 23672 /** 23673 * A specialized version of `_.memoize` which clears the memoized function's 23674 * cache when it exceeds `MAX_MEMOIZE_SIZE`. 23675 * 23676 * @private 23677 * @param {Function} func The function to have its output memoized. 23678 * @returns {Function} Returns the new memoized function. 23679 */ 23680 function memoizeCapped(func) { 23681 var result = memoize(func, function(key) { 23682 if (cache.size === MAX_MEMOIZE_SIZE) { 23683 cache.clear(); 23684 } 23685 return key; 23686 }); 23687 23688 var cache = result.cache; 23689 return result; 23690 } 23691 23692 /** 23693 * Merges the function metadata of `source` into `data`. 23694 * 23695 * Merging metadata reduces the number of wrappers used to invoke a function. 23696 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` 23697 * may be applied regardless of execution order. Methods like `_.ary` and 23698 * `_.rearg` modify function arguments, making the order in which they are 23699 * executed important, preventing the merging of metadata. However, we make 23700 * an exception for a safe combined case where curried functions have `_.ary` 23701 * and or `_.rearg` applied. 23702 * 23703 * @private 23704 * @param {Array} data The destination metadata. 23705 * @param {Array} source The source metadata. 23706 * @returns {Array} Returns `data`. 23707 */ 23708 function mergeData(data, source) { 23709 var bitmask = data[1], 23710 srcBitmask = source[1], 23711 newBitmask = bitmask | srcBitmask, 23712 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); 23713 23714 var isCombo = 23715 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || 23716 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || 23717 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); 23718 23719 // Exit early if metadata can't be merged. 23720 if (!(isCommon || isCombo)) { 23721 return data; 23722 } 23723 // Use source `thisArg` if available. 23724 if (srcBitmask & WRAP_BIND_FLAG) { 23725 data[2] = source[2]; 23726 // Set when currying a bound function. 23727 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; 23728 } 23729 // Compose partial arguments. 23730 var value = source[3]; 23731 if (value) { 23732 var partials = data[3]; 23733 data[3] = partials ? composeArgs(partials, value, source[4]) : value; 23734 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; 23735 } 23736 // Compose partial right arguments. 23737 value = source[5]; 23738 if (value) { 23739 partials = data[5]; 23740 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; 23741 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; 23742 } 23743 // Use source `argPos` if available. 23744 value = source[7]; 23745 if (value) { 23746 data[7] = value; 23747 } 23748 // Use source `ary` if it's smaller. 23749 if (srcBitmask & WRAP_ARY_FLAG) { 23750 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); 23751 } 23752 // Use source `arity` if one is not provided. 23753 if (data[9] == null) { 23754 data[9] = source[9]; 23755 } 23756 // Use source `func` and merge bitmasks. 23757 data[0] = source[0]; 23758 data[1] = newBitmask; 23759 23760 return data; 23761 } 23762 23763 /** 23764 * This function is like 23765 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 23766 * except that it includes inherited enumerable properties. 23767 * 23768 * @private 23769 * @param {Object} object The object to query. 23770 * @returns {Array} Returns the array of property names. 23771 */ 23772 function nativeKeysIn(object) { 23773 var result = []; 23774 if (object != null) { 23775 for (var key in Object(object)) { 23776 result.push(key); 23777 } 23778 } 23779 return result; 23780 } 23781 23782 /** 23783 * Converts `value` to a string using `Object.prototype.toString`. 23784 * 23785 * @private 23786 * @param {*} value The value to convert. 23787 * @returns {string} Returns the converted string. 23788 */ 23789 function objectToString(value) { 23790 return nativeObjectToString.call(value); 23791 } 23792 23793 /** 23794 * A specialized version of `baseRest` which transforms the rest array. 23795 * 23796 * @private 23797 * @param {Function} func The function to apply a rest parameter to. 23798 * @param {number} [start=func.length-1] The start position of the rest parameter. 23799 * @param {Function} transform The rest array transform. 23800 * @returns {Function} Returns the new function. 23801 */ 23802 function overRest(func, start, transform) { 23803 start = nativeMax(start === undefined ? (func.length - 1) : start, 0); 23804 return function() { 23805 var args = arguments, 23806 index = -1, 23807 length = nativeMax(args.length - start, 0), 23808 array = Array(length); 23809 23810 while (++index < length) { 23811 array[index] = args[start + index]; 23812 } 23813 index = -1; 23814 var otherArgs = Array(start + 1); 23815 while (++index < start) { 23816 otherArgs[index] = args[index]; 23817 } 23818 otherArgs[start] = transform(array); 23819 return apply(func, this, otherArgs); 23820 }; 23821 } 23822 23823 /** 23824 * Gets the parent value at `path` of `object`. 23825 * 23826 * @private 23827 * @param {Object} object The object to query. 23828 * @param {Array} path The path to get the parent value of. 23829 * @returns {*} Returns the parent value. 23830 */ 23831 function parent(object, path) { 23832 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); 23833 } 23834 23835 /** 23836 * Reorder `array` according to the specified indexes where the element at 23837 * the first index is assigned as the first element, the element at 23838 * the second index is assigned as the second element, and so on. 23839 * 23840 * @private 23841 * @param {Array} array The array to reorder. 23842 * @param {Array} indexes The arranged array indexes. 23843 * @returns {Array} Returns `array`. 23844 */ 23845 function reorder(array, indexes) { 23846 var arrLength = array.length, 23847 length = nativeMin(indexes.length, arrLength), 23848 oldArray = copyArray(array); 23849 23850 while (length--) { 23851 var index = indexes[length]; 23852 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; 23853 } 23854 return array; 23855 } 23856 23857 /** 23858 * Gets the value at `key`, unless `key` is "__proto__" or "constructor". 23859 * 23860 * @private 23861 * @param {Object} object The object to query. 23862 * @param {string} key The key of the property to get. 23863 * @returns {*} Returns the property value. 23864 */ 23865 function safeGet(object, key) { 23866 if (key === 'constructor' && typeof object[key] === 'function') { 23867 return; 23868 } 23869 23870 if (key == '__proto__') { 23871 return; 23872 } 23873 23874 return object[key]; 23875 } 23876 23877 /** 23878 * Sets metadata for `func`. 23879 * 23880 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short 23881 * period of time, it will trip its breaker and transition to an identity 23882 * function to avoid garbage collection pauses in V8. See 23883 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) 23884 * for more details. 23885 * 23886 * @private 23887 * @param {Function} func The function to associate metadata with. 23888 * @param {*} data The metadata. 23889 * @returns {Function} Returns `func`. 23890 */ 23891 var setData = shortOut(baseSetData); 23892 23893 /** 23894 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). 23895 * 23896 * @private 23897 * @param {Function} func The function to delay. 23898 * @param {number} wait The number of milliseconds to delay invocation. 23899 * @returns {number|Object} Returns the timer id or timeout object. 23900 */ 23901 var setTimeout = ctxSetTimeout || function(func, wait) { 23902 return root.setTimeout(func, wait); 23903 }; 23904 23905 /** 23906 * Sets the `toString` method of `func` to return `string`. 23907 * 23908 * @private 23909 * @param {Function} func The function to modify. 23910 * @param {Function} string The `toString` result. 23911 * @returns {Function} Returns `func`. 23912 */ 23913 var setToString = shortOut(baseSetToString); 23914 23915 /** 23916 * Sets the `toString` method of `wrapper` to mimic the source of `reference` 23917 * with wrapper details in a comment at the top of the source body. 23918 * 23919 * @private 23920 * @param {Function} wrapper The function to modify. 23921 * @param {Function} reference The reference function. 23922 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 23923 * @returns {Function} Returns `wrapper`. 23924 */ 23925 function setWrapToString(wrapper, reference, bitmask) { 23926 var source = (reference + ''); 23927 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); 23928 } 23929 23930 /** 23931 * Creates a function that'll short out and invoke `identity` instead 23932 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` 23933 * milliseconds. 23934 * 23935 * @private 23936 * @param {Function} func The function to restrict. 23937 * @returns {Function} Returns the new shortable function. 23938 */ 23939 function shortOut(func) { 23940 var count = 0, 23941 lastCalled = 0; 23942 23943 return function() { 23944 var stamp = nativeNow(), 23945 remaining = HOT_SPAN - (stamp - lastCalled); 23946 23947 lastCalled = stamp; 23948 if (remaining > 0) { 23949 if (++count >= HOT_COUNT) { 23950 return arguments[0]; 23951 } 23952 } else { 23953 count = 0; 23954 } 23955 return func.apply(undefined, arguments); 23956 }; 23957 } 23958 23959 /** 23960 * A specialized version of `_.shuffle` which mutates and sets the size of `array`. 23961 * 23962 * @private 23963 * @param {Array} array The array to shuffle. 23964 * @param {number} [size=array.length] The size of `array`. 23965 * @returns {Array} Returns `array`. 23966 */ 23967 function shuffleSelf(array, size) { 23968 var index = -1, 23969 length = array.length, 23970 lastIndex = length - 1; 23971 23972 size = size === undefined ? length : size; 23973 while (++index < size) { 23974 var rand = baseRandom(index, lastIndex), 23975 value = array[rand]; 23976 23977 array[rand] = array[index]; 23978 array[index] = value; 23979 } 23980 array.length = size; 23981 return array; 23982 } 23983 23984 /** 23985 * Converts `string` to a property path array. 23986 * 23987 * @private 23988 * @param {string} string The string to convert. 23989 * @returns {Array} Returns the property path array. 23990 */ 23991 var stringToPath = memoizeCapped(function(string) { 23992 var result = []; 23993 if (string.charCodeAt(0) === 46 /* . */) { 23994 result.push(''); 23995 } 23996 string.replace(rePropName, function(match, number, quote, subString) { 23997 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); 23998 }); 23999 return result; 24000 }); 24001 24002 /** 24003 * Converts `value` to a string key if it's not a string or symbol. 24004 * 24005 * @private 24006 * @param {*} value The value to inspect. 24007 * @returns {string|symbol} Returns the key. 24008 */ 24009 function toKey(value) { 24010 if (typeof value == 'string' || isSymbol(value)) { 24011 return value; 24012 } 24013 var result = (value + ''); 24014 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 24015 } 24016 24017 /** 24018 * Converts `func` to its source code. 24019 * 24020 * @private 24021 * @param {Function} func The function to convert. 24022 * @returns {string} Returns the source code. 24023 */ 24024 function toSource(func) { 24025 if (func != null) { 24026 try { 24027 return funcToString.call(func); 24028 } catch (e) {} 24029 try { 24030 return (func + ''); 24031 } catch (e) {} 24032 } 24033 return ''; 24034 } 24035 24036 /** 24037 * Updates wrapper `details` based on `bitmask` flags. 24038 * 24039 * @private 24040 * @returns {Array} details The details to modify. 24041 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 24042 * @returns {Array} Returns `details`. 24043 */ 24044 function updateWrapDetails(details, bitmask) { 24045 arrayEach(wrapFlags, function(pair) { 24046 var value = '_.' + pair[0]; 24047 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { 24048 details.push(value); 24049 } 24050 }); 24051 return details.sort(); 24052 } 24053 24054 /** 24055 * Creates a clone of `wrapper`. 24056 * 24057 * @private 24058 * @param {Object} wrapper The wrapper to clone. 24059 * @returns {Object} Returns the cloned wrapper. 24060 */ 24061 function wrapperClone(wrapper) { 24062 if (wrapper instanceof LazyWrapper) { 24063 return wrapper.clone(); 24064 } 24065 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); 24066 result.__actions__ = copyArray(wrapper.__actions__); 24067 result.__index__ = wrapper.__index__; 24068 result.__values__ = wrapper.__values__; 24069 return result; 24070 } 24071 24072 /*------------------------------------------------------------------------*/ 24073 24074 /** 24075 * Creates an array of elements split into groups the length of `size`. 24076 * If `array` can't be split evenly, the final chunk will be the remaining 24077 * elements. 24078 * 24079 * @static 24080 * @memberOf _ 24081 * @since 3.0.0 24082 * @category Array 24083 * @param {Array} array The array to process. 24084 * @param {number} [size=1] The length of each chunk 24085 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 24086 * @returns {Array} Returns the new array of chunks. 24087 * @example 24088 * 24089 * _.chunk(['a', 'b', 'c', 'd'], 2); 24090 * // => [['a', 'b'], ['c', 'd']] 24091 * 24092 * _.chunk(['a', 'b', 'c', 'd'], 3); 24093 * // => [['a', 'b', 'c'], ['d']] 24094 */ 24095 function chunk(array, size, guard) { 24096 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { 24097 size = 1; 24098 } else { 24099 size = nativeMax(toInteger(size), 0); 24100 } 24101 var length = array == null ? 0 : array.length; 24102 if (!length || size < 1) { 24103 return []; 24104 } 24105 var index = 0, 24106 resIndex = 0, 24107 result = Array(nativeCeil(length / size)); 24108 24109 while (index < length) { 24110 result[resIndex++] = baseSlice(array, index, (index += size)); 24111 } 24112 return result; 24113 } 24114 24115 /** 24116 * Creates an array with all falsey values removed. The values `false`, `null`, 24117 * `0`, `""`, `undefined`, and `NaN` are falsey. 24118 * 24119 * @static 24120 * @memberOf _ 24121 * @since 0.1.0 24122 * @category Array 24123 * @param {Array} array The array to compact. 24124 * @returns {Array} Returns the new array of filtered values. 24125 * @example 24126 * 24127 * _.compact([0, 1, false, 2, '', 3]); 24128 * // => [1, 2, 3] 24129 */ 24130 function compact(array) { 24131 var index = -1, 24132 length = array == null ? 0 : array.length, 24133 resIndex = 0, 24134 result = []; 24135 24136 while (++index < length) { 24137 var value = array[index]; 24138 if (value) { 24139 result[resIndex++] = value; 24140 } 24141 } 24142 return result; 24143 } 24144 24145 /** 24146 * Creates a new array concatenating `array` with any additional arrays 24147 * and/or values. 24148 * 24149 * @static 24150 * @memberOf _ 24151 * @since 4.0.0 24152 * @category Array 24153 * @param {Array} array The array to concatenate. 24154 * @param {...*} [values] The values to concatenate. 24155 * @returns {Array} Returns the new concatenated array. 24156 * @example 24157 * 24158 * var array = [1]; 24159 * var other = _.concat(array, 2, [3], [[4]]); 24160 * 24161 * console.log(other); 24162 * // => [1, 2, 3, [4]] 24163 * 24164 * console.log(array); 24165 * // => [1] 24166 */ 24167 function concat() { 24168 var length = arguments.length; 24169 if (!length) { 24170 return []; 24171 } 24172 var args = Array(length - 1), 24173 array = arguments[0], 24174 index = length; 24175 24176 while (index--) { 24177 args[index - 1] = arguments[index]; 24178 } 24179 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); 24180 } 24181 24182 /** 24183 * Creates an array of `array` values not included in the other given arrays 24184 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 24185 * for equality comparisons. The order and references of result values are 24186 * determined by the first array. 24187 * 24188 * **Note:** Unlike `_.pullAll`, this method returns a new array. 24189 * 24190 * @static 24191 * @memberOf _ 24192 * @since 0.1.0 24193 * @category Array 24194 * @param {Array} array The array to inspect. 24195 * @param {...Array} [values] The values to exclude. 24196 * @returns {Array} Returns the new array of filtered values. 24197 * @see _.without, _.xor 24198 * @example 24199 * 24200 * _.difference([2, 1], [2, 3]); 24201 * // => [1] 24202 */ 24203 var difference = baseRest(function(array, values) { 24204 return isArrayLikeObject(array) 24205 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) 24206 : []; 24207 }); 24208 24209 /** 24210 * This method is like `_.difference` except that it accepts `iteratee` which 24211 * is invoked for each element of `array` and `values` to generate the criterion 24212 * by which they're compared. The order and references of result values are 24213 * determined by the first array. The iteratee is invoked with one argument: 24214 * (value). 24215 * 24216 * **Note:** Unlike `_.pullAllBy`, this method returns a new array. 24217 * 24218 * @static 24219 * @memberOf _ 24220 * @since 4.0.0 24221 * @category Array 24222 * @param {Array} array The array to inspect. 24223 * @param {...Array} [values] The values to exclude. 24224 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 24225 * @returns {Array} Returns the new array of filtered values. 24226 * @example 24227 * 24228 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); 24229 * // => [1.2] 24230 * 24231 * // The `_.property` iteratee shorthand. 24232 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 24233 * // => [{ 'x': 2 }] 24234 */ 24235 var differenceBy = baseRest(function(array, values) { 24236 var iteratee = last(values); 24237 if (isArrayLikeObject(iteratee)) { 24238 iteratee = undefined; 24239 } 24240 return isArrayLikeObject(array) 24241 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) 24242 : []; 24243 }); 24244 24245 /** 24246 * This method is like `_.difference` except that it accepts `comparator` 24247 * which is invoked to compare elements of `array` to `values`. The order and 24248 * references of result values are determined by the first array. The comparator 24249 * is invoked with two arguments: (arrVal, othVal). 24250 * 24251 * **Note:** Unlike `_.pullAllWith`, this method returns a new array. 24252 * 24253 * @static 24254 * @memberOf _ 24255 * @since 4.0.0 24256 * @category Array 24257 * @param {Array} array The array to inspect. 24258 * @param {...Array} [values] The values to exclude. 24259 * @param {Function} [comparator] The comparator invoked per element. 24260 * @returns {Array} Returns the new array of filtered values. 24261 * @example 24262 * 24263 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 24264 * 24265 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); 24266 * // => [{ 'x': 2, 'y': 1 }] 24267 */ 24268 var differenceWith = baseRest(function(array, values) { 24269 var comparator = last(values); 24270 if (isArrayLikeObject(comparator)) { 24271 comparator = undefined; 24272 } 24273 return isArrayLikeObject(array) 24274 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) 24275 : []; 24276 }); 24277 24278 /** 24279 * Creates a slice of `array` with `n` elements dropped from the beginning. 24280 * 24281 * @static 24282 * @memberOf _ 24283 * @since 0.5.0 24284 * @category Array 24285 * @param {Array} array The array to query. 24286 * @param {number} [n=1] The number of elements to drop. 24287 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 24288 * @returns {Array} Returns the slice of `array`. 24289 * @example 24290 * 24291 * _.drop([1, 2, 3]); 24292 * // => [2, 3] 24293 * 24294 * _.drop([1, 2, 3], 2); 24295 * // => [3] 24296 * 24297 * _.drop([1, 2, 3], 5); 24298 * // => [] 24299 * 24300 * _.drop([1, 2, 3], 0); 24301 * // => [1, 2, 3] 24302 */ 24303 function drop(array, n, guard) { 24304 var length = array == null ? 0 : array.length; 24305 if (!length) { 24306 return []; 24307 } 24308 n = (guard || n === undefined) ? 1 : toInteger(n); 24309 return baseSlice(array, n < 0 ? 0 : n, length); 24310 } 24311 24312 /** 24313 * Creates a slice of `array` with `n` elements dropped from the end. 24314 * 24315 * @static 24316 * @memberOf _ 24317 * @since 3.0.0 24318 * @category Array 24319 * @param {Array} array The array to query. 24320 * @param {number} [n=1] The number of elements to drop. 24321 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 24322 * @returns {Array} Returns the slice of `array`. 24323 * @example 24324 * 24325 * _.dropRight([1, 2, 3]); 24326 * // => [1, 2] 24327 * 24328 * _.dropRight([1, 2, 3], 2); 24329 * // => [1] 24330 * 24331 * _.dropRight([1, 2, 3], 5); 24332 * // => [] 24333 * 24334 * _.dropRight([1, 2, 3], 0); 24335 * // => [1, 2, 3] 24336 */ 24337 function dropRight(array, n, guard) { 24338 var length = array == null ? 0 : array.length; 24339 if (!length) { 24340 return []; 24341 } 24342 n = (guard || n === undefined) ? 1 : toInteger(n); 24343 n = length - n; 24344 return baseSlice(array, 0, n < 0 ? 0 : n); 24345 } 24346 24347 /** 24348 * Creates a slice of `array` excluding elements dropped from the end. 24349 * Elements are dropped until `predicate` returns falsey. The predicate is 24350 * invoked with three arguments: (value, index, array). 24351 * 24352 * @static 24353 * @memberOf _ 24354 * @since 3.0.0 24355 * @category Array 24356 * @param {Array} array The array to query. 24357 * @param {Function} [predicate=_.identity] The function invoked per iteration. 24358 * @returns {Array} Returns the slice of `array`. 24359 * @example 24360 * 24361 * var users = [ 24362 * { 'user': 'barney', 'active': true }, 24363 * { 'user': 'fred', 'active': false }, 24364 * { 'user': 'pebbles', 'active': false } 24365 * ]; 24366 * 24367 * _.dropRightWhile(users, function(o) { return !o.active; }); 24368 * // => objects for ['barney'] 24369 * 24370 * // The `_.matches` iteratee shorthand. 24371 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); 24372 * // => objects for ['barney', 'fred'] 24373 * 24374 * // The `_.matchesProperty` iteratee shorthand. 24375 * _.dropRightWhile(users, ['active', false]); 24376 * // => objects for ['barney'] 24377 * 24378 * // The `_.property` iteratee shorthand. 24379 * _.dropRightWhile(users, 'active'); 24380 * // => objects for ['barney', 'fred', 'pebbles'] 24381 */ 24382 function dropRightWhile(array, predicate) { 24383 return (array && array.length) 24384 ? baseWhile(array, getIteratee(predicate, 3), true, true) 24385 : []; 24386 } 24387 24388 /** 24389 * Creates a slice of `array` excluding elements dropped from the beginning. 24390 * Elements are dropped until `predicate` returns falsey. The predicate is 24391 * invoked with three arguments: (value, index, array). 24392 * 24393 * @static 24394 * @memberOf _ 24395 * @since 3.0.0 24396 * @category Array 24397 * @param {Array} array The array to query. 24398 * @param {Function} [predicate=_.identity] The function invoked per iteration. 24399 * @returns {Array} Returns the slice of `array`. 24400 * @example 24401 * 24402 * var users = [ 24403 * { 'user': 'barney', 'active': false }, 24404 * { 'user': 'fred', 'active': false }, 24405 * { 'user': 'pebbles', 'active': true } 24406 * ]; 24407 * 24408 * _.dropWhile(users, function(o) { return !o.active; }); 24409 * // => objects for ['pebbles'] 24410 * 24411 * // The `_.matches` iteratee shorthand. 24412 * _.dropWhile(users, { 'user': 'barney', 'active': false }); 24413 * // => objects for ['fred', 'pebbles'] 24414 * 24415 * // The `_.matchesProperty` iteratee shorthand. 24416 * _.dropWhile(users, ['active', false]); 24417 * // => objects for ['pebbles'] 24418 * 24419 * // The `_.property` iteratee shorthand. 24420 * _.dropWhile(users, 'active'); 24421 * // => objects for ['barney', 'fred', 'pebbles'] 24422 */ 24423 function dropWhile(array, predicate) { 24424 return (array && array.length) 24425 ? baseWhile(array, getIteratee(predicate, 3), true) 24426 : []; 24427 } 24428 24429 /** 24430 * Fills elements of `array` with `value` from `start` up to, but not 24431 * including, `end`. 24432 * 24433 * **Note:** This method mutates `array`. 24434 * 24435 * @static 24436 * @memberOf _ 24437 * @since 3.2.0 24438 * @category Array 24439 * @param {Array} array The array to fill. 24440 * @param {*} value The value to fill `array` with. 24441 * @param {number} [start=0] The start position. 24442 * @param {number} [end=array.length] The end position. 24443 * @returns {Array} Returns `array`. 24444 * @example 24445 * 24446 * var array = [1, 2, 3]; 24447 * 24448 * _.fill(array, 'a'); 24449 * console.log(array); 24450 * // => ['a', 'a', 'a'] 24451 * 24452 * _.fill(Array(3), 2); 24453 * // => [2, 2, 2] 24454 * 24455 * _.fill([4, 6, 8, 10], '*', 1, 3); 24456 * // => [4, '*', '*', 10] 24457 */ 24458 function fill(array, value, start, end) { 24459 var length = array == null ? 0 : array.length; 24460 if (!length) { 24461 return []; 24462 } 24463 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { 24464 start = 0; 24465 end = length; 24466 } 24467 return baseFill(array, value, start, end); 24468 } 24469 24470 /** 24471 * This method is like `_.find` except that it returns the index of the first 24472 * element `predicate` returns truthy for instead of the element itself. 24473 * 24474 * @static 24475 * @memberOf _ 24476 * @since 1.1.0 24477 * @category Array 24478 * @param {Array} array The array to inspect. 24479 * @param {Function} [predicate=_.identity] The function invoked per iteration. 24480 * @param {number} [fromIndex=0] The index to search from. 24481 * @returns {number} Returns the index of the found element, else `-1`. 24482 * @example 24483 * 24484 * var users = [ 24485 * { 'user': 'barney', 'active': false }, 24486 * { 'user': 'fred', 'active': false }, 24487 * { 'user': 'pebbles', 'active': true } 24488 * ]; 24489 * 24490 * _.findIndex(users, function(o) { return o.user == 'barney'; }); 24491 * // => 0 24492 * 24493 * // The `_.matches` iteratee shorthand. 24494 * _.findIndex(users, { 'user': 'fred', 'active': false }); 24495 * // => 1 24496 * 24497 * // The `_.matchesProperty` iteratee shorthand. 24498 * _.findIndex(users, ['active', false]); 24499 * // => 0 24500 * 24501 * // The `_.property` iteratee shorthand. 24502 * _.findIndex(users, 'active'); 24503 * // => 2 24504 */ 24505 function findIndex(array, predicate, fromIndex) { 24506 var length = array == null ? 0 : array.length; 24507 if (!length) { 24508 return -1; 24509 } 24510 var index = fromIndex == null ? 0 : toInteger(fromIndex); 24511 if (index < 0) { 24512 index = nativeMax(length + index, 0); 24513 } 24514 return baseFindIndex(array, getIteratee(predicate, 3), index); 24515 } 24516 24517 /** 24518 * This method is like `_.findIndex` except that it iterates over elements 24519 * of `collection` from right to left. 24520 * 24521 * @static 24522 * @memberOf _ 24523 * @since 2.0.0 24524 * @category Array 24525 * @param {Array} array The array to inspect. 24526 * @param {Function} [predicate=_.identity] The function invoked per iteration. 24527 * @param {number} [fromIndex=array.length-1] The index to search from. 24528 * @returns {number} Returns the index of the found element, else `-1`. 24529 * @example 24530 * 24531 * var users = [ 24532 * { 'user': 'barney', 'active': true }, 24533 * { 'user': 'fred', 'active': false }, 24534 * { 'user': 'pebbles', 'active': false } 24535 * ]; 24536 * 24537 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); 24538 * // => 2 24539 * 24540 * // The `_.matches` iteratee shorthand. 24541 * _.findLastIndex(users, { 'user': 'barney', 'active': true }); 24542 * // => 0 24543 * 24544 * // The `_.matchesProperty` iteratee shorthand. 24545 * _.findLastIndex(users, ['active', false]); 24546 * // => 2 24547 * 24548 * // The `_.property` iteratee shorthand. 24549 * _.findLastIndex(users, 'active'); 24550 * // => 0 24551 */ 24552 function findLastIndex(array, predicate, fromIndex) { 24553 var length = array == null ? 0 : array.length; 24554 if (!length) { 24555 return -1; 24556 } 24557 var index = length - 1; 24558 if (fromIndex !== undefined) { 24559 index = toInteger(fromIndex); 24560 index = fromIndex < 0 24561 ? nativeMax(length + index, 0) 24562 : nativeMin(index, length - 1); 24563 } 24564 return baseFindIndex(array, getIteratee(predicate, 3), index, true); 24565 } 24566 24567 /** 24568 * Flattens `array` a single level deep. 24569 * 24570 * @static 24571 * @memberOf _ 24572 * @since 0.1.0 24573 * @category Array 24574 * @param {Array} array The array to flatten. 24575 * @returns {Array} Returns the new flattened array. 24576 * @example 24577 * 24578 * _.flatten([1, [2, [3, [4]], 5]]); 24579 * // => [1, 2, [3, [4]], 5] 24580 */ 24581 function flatten(array) { 24582 var length = array == null ? 0 : array.length; 24583 return length ? baseFlatten(array, 1) : []; 24584 } 24585 24586 /** 24587 * Recursively flattens `array`. 24588 * 24589 * @static 24590 * @memberOf _ 24591 * @since 3.0.0 24592 * @category Array 24593 * @param {Array} array The array to flatten. 24594 * @returns {Array} Returns the new flattened array. 24595 * @example 24596 * 24597 * _.flattenDeep([1, [2, [3, [4]], 5]]); 24598 * // => [1, 2, 3, 4, 5] 24599 */ 24600 function flattenDeep(array) { 24601 var length = array == null ? 0 : array.length; 24602 return length ? baseFlatten(array, INFINITY) : []; 24603 } 24604 24605 /** 24606 * Recursively flatten `array` up to `depth` times. 24607 * 24608 * @static 24609 * @memberOf _ 24610 * @since 4.4.0 24611 * @category Array 24612 * @param {Array} array The array to flatten. 24613 * @param {number} [depth=1] The maximum recursion depth. 24614 * @returns {Array} Returns the new flattened array. 24615 * @example 24616 * 24617 * var array = [1, [2, [3, [4]], 5]]; 24618 * 24619 * _.flattenDepth(array, 1); 24620 * // => [1, 2, [3, [4]], 5] 24621 * 24622 * _.flattenDepth(array, 2); 24623 * // => [1, 2, 3, [4], 5] 24624 */ 24625 function flattenDepth(array, depth) { 24626 var length = array == null ? 0 : array.length; 24627 if (!length) { 24628 return []; 24629 } 24630 depth = depth === undefined ? 1 : toInteger(depth); 24631 return baseFlatten(array, depth); 24632 } 24633 24634 /** 24635 * The inverse of `_.toPairs`; this method returns an object composed 24636 * from key-value `pairs`. 24637 * 24638 * @static 24639 * @memberOf _ 24640 * @since 4.0.0 24641 * @category Array 24642 * @param {Array} pairs The key-value pairs. 24643 * @returns {Object} Returns the new object. 24644 * @example 24645 * 24646 * _.fromPairs([['a', 1], ['b', 2]]); 24647 * // => { 'a': 1, 'b': 2 } 24648 */ 24649 function fromPairs(pairs) { 24650 var index = -1, 24651 length = pairs == null ? 0 : pairs.length, 24652 result = {}; 24653 24654 while (++index < length) { 24655 var pair = pairs[index]; 24656 result[pair[0]] = pair[1]; 24657 } 24658 return result; 24659 } 24660 24661 /** 24662 * Gets the first element of `array`. 24663 * 24664 * @static 24665 * @memberOf _ 24666 * @since 0.1.0 24667 * @alias first 24668 * @category Array 24669 * @param {Array} array The array to query. 24670 * @returns {*} Returns the first element of `array`. 24671 * @example 24672 * 24673 * _.head([1, 2, 3]); 24674 * // => 1 24675 * 24676 * _.head([]); 24677 * // => undefined 24678 */ 24679 function head(array) { 24680 return (array && array.length) ? array[0] : undefined; 24681 } 24682 24683 /** 24684 * Gets the index at which the first occurrence of `value` is found in `array` 24685 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 24686 * for equality comparisons. If `fromIndex` is negative, it's used as the 24687 * offset from the end of `array`. 24688 * 24689 * @static 24690 * @memberOf _ 24691 * @since 0.1.0 24692 * @category Array 24693 * @param {Array} array The array to inspect. 24694 * @param {*} value The value to search for. 24695 * @param {number} [fromIndex=0] The index to search from. 24696 * @returns {number} Returns the index of the matched value, else `-1`. 24697 * @example 24698 * 24699 * _.indexOf([1, 2, 1, 2], 2); 24700 * // => 1 24701 * 24702 * // Search from the `fromIndex`. 24703 * _.indexOf([1, 2, 1, 2], 2, 2); 24704 * // => 3 24705 */ 24706 function indexOf(array, value, fromIndex) { 24707 var length = array == null ? 0 : array.length; 24708 if (!length) { 24709 return -1; 24710 } 24711 var index = fromIndex == null ? 0 : toInteger(fromIndex); 24712 if (index < 0) { 24713 index = nativeMax(length + index, 0); 24714 } 24715 return baseIndexOf(array, value, index); 24716 } 24717 24718 /** 24719 * Gets all but the last element of `array`. 24720 * 24721 * @static 24722 * @memberOf _ 24723 * @since 0.1.0 24724 * @category Array 24725 * @param {Array} array The array to query. 24726 * @returns {Array} Returns the slice of `array`. 24727 * @example 24728 * 24729 * _.initial([1, 2, 3]); 24730 * // => [1, 2] 24731 */ 24732 function initial(array) { 24733 var length = array == null ? 0 : array.length; 24734 return length ? baseSlice(array, 0, -1) : []; 24735 } 24736 24737 /** 24738 * Creates an array of unique values that are included in all given arrays 24739 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 24740 * for equality comparisons. The order and references of result values are 24741 * determined by the first array. 24742 * 24743 * @static 24744 * @memberOf _ 24745 * @since 0.1.0 24746 * @category Array 24747 * @param {...Array} [arrays] The arrays to inspect. 24748 * @returns {Array} Returns the new array of intersecting values. 24749 * @example 24750 * 24751 * _.intersection([2, 1], [2, 3]); 24752 * // => [2] 24753 */ 24754 var intersection = baseRest(function(arrays) { 24755 var mapped = arrayMap(arrays, castArrayLikeObject); 24756 return (mapped.length && mapped[0] === arrays[0]) 24757 ? baseIntersection(mapped) 24758 : []; 24759 }); 24760 24761 /** 24762 * This method is like `_.intersection` except that it accepts `iteratee` 24763 * which is invoked for each element of each `arrays` to generate the criterion 24764 * by which they're compared. The order and references of result values are 24765 * determined by the first array. The iteratee is invoked with one argument: 24766 * (value). 24767 * 24768 * @static 24769 * @memberOf _ 24770 * @since 4.0.0 24771 * @category Array 24772 * @param {...Array} [arrays] The arrays to inspect. 24773 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 24774 * @returns {Array} Returns the new array of intersecting values. 24775 * @example 24776 * 24777 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); 24778 * // => [2.1] 24779 * 24780 * // The `_.property` iteratee shorthand. 24781 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 24782 * // => [{ 'x': 1 }] 24783 */ 24784 var intersectionBy = baseRest(function(arrays) { 24785 var iteratee = last(arrays), 24786 mapped = arrayMap(arrays, castArrayLikeObject); 24787 24788 if (iteratee === last(mapped)) { 24789 iteratee = undefined; 24790 } else { 24791 mapped.pop(); 24792 } 24793 return (mapped.length && mapped[0] === arrays[0]) 24794 ? baseIntersection(mapped, getIteratee(iteratee, 2)) 24795 : []; 24796 }); 24797 24798 /** 24799 * This method is like `_.intersection` except that it accepts `comparator` 24800 * which is invoked to compare elements of `arrays`. The order and references 24801 * of result values are determined by the first array. The comparator is 24802 * invoked with two arguments: (arrVal, othVal). 24803 * 24804 * @static 24805 * @memberOf _ 24806 * @since 4.0.0 24807 * @category Array 24808 * @param {...Array} [arrays] The arrays to inspect. 24809 * @param {Function} [comparator] The comparator invoked per element. 24810 * @returns {Array} Returns the new array of intersecting values. 24811 * @example 24812 * 24813 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 24814 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 24815 * 24816 * _.intersectionWith(objects, others, _.isEqual); 24817 * // => [{ 'x': 1, 'y': 2 }] 24818 */ 24819 var intersectionWith = baseRest(function(arrays) { 24820 var comparator = last(arrays), 24821 mapped = arrayMap(arrays, castArrayLikeObject); 24822 24823 comparator = typeof comparator == 'function' ? comparator : undefined; 24824 if (comparator) { 24825 mapped.pop(); 24826 } 24827 return (mapped.length && mapped[0] === arrays[0]) 24828 ? baseIntersection(mapped, undefined, comparator) 24829 : []; 24830 }); 24831 24832 /** 24833 * Converts all elements in `array` into a string separated by `separator`. 24834 * 24835 * @static 24836 * @memberOf _ 24837 * @since 4.0.0 24838 * @category Array 24839 * @param {Array} array The array to convert. 24840 * @param {string} [separator=','] The element separator. 24841 * @returns {string} Returns the joined string. 24842 * @example 24843 * 24844 * _.join(['a', 'b', 'c'], '~'); 24845 * // => 'a~b~c' 24846 */ 24847 function join(array, separator) { 24848 return array == null ? '' : nativeJoin.call(array, separator); 24849 } 24850 24851 /** 24852 * Gets the last element of `array`. 24853 * 24854 * @static 24855 * @memberOf _ 24856 * @since 0.1.0 24857 * @category Array 24858 * @param {Array} array The array to query. 24859 * @returns {*} Returns the last element of `array`. 24860 * @example 24861 * 24862 * _.last([1, 2, 3]); 24863 * // => 3 24864 */ 24865 function last(array) { 24866 var length = array == null ? 0 : array.length; 24867 return length ? array[length - 1] : undefined; 24868 } 24869 24870 /** 24871 * This method is like `_.indexOf` except that it iterates over elements of 24872 * `array` from right to left. 24873 * 24874 * @static 24875 * @memberOf _ 24876 * @since 0.1.0 24877 * @category Array 24878 * @param {Array} array The array to inspect. 24879 * @param {*} value The value to search for. 24880 * @param {number} [fromIndex=array.length-1] The index to search from. 24881 * @returns {number} Returns the index of the matched value, else `-1`. 24882 * @example 24883 * 24884 * _.lastIndexOf([1, 2, 1, 2], 2); 24885 * // => 3 24886 * 24887 * // Search from the `fromIndex`. 24888 * _.lastIndexOf([1, 2, 1, 2], 2, 2); 24889 * // => 1 24890 */ 24891 function lastIndexOf(array, value, fromIndex) { 24892 var length = array == null ? 0 : array.length; 24893 if (!length) { 24894 return -1; 24895 } 24896 var index = length; 24897 if (fromIndex !== undefined) { 24898 index = toInteger(fromIndex); 24899 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); 24900 } 24901 return value === value 24902 ? strictLastIndexOf(array, value, index) 24903 : baseFindIndex(array, baseIsNaN, index, true); 24904 } 24905 24906 /** 24907 * Gets the element at index `n` of `array`. If `n` is negative, the nth 24908 * element from the end is returned. 24909 * 24910 * @static 24911 * @memberOf _ 24912 * @since 4.11.0 24913 * @category Array 24914 * @param {Array} array The array to query. 24915 * @param {number} [n=0] The index of the element to return. 24916 * @returns {*} Returns the nth element of `array`. 24917 * @example 24918 * 24919 * var array = ['a', 'b', 'c', 'd']; 24920 * 24921 * _.nth(array, 1); 24922 * // => 'b' 24923 * 24924 * _.nth(array, -2); 24925 * // => 'c'; 24926 */ 24927 function nth(array, n) { 24928 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; 24929 } 24930 24931 /** 24932 * Removes all given values from `array` using 24933 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 24934 * for equality comparisons. 24935 * 24936 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` 24937 * to remove elements from an array by predicate. 24938 * 24939 * @static 24940 * @memberOf _ 24941 * @since 2.0.0 24942 * @category Array 24943 * @param {Array} array The array to modify. 24944 * @param {...*} [values] The values to remove. 24945 * @returns {Array} Returns `array`. 24946 * @example 24947 * 24948 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 24949 * 24950 * _.pull(array, 'a', 'c'); 24951 * console.log(array); 24952 * // => ['b', 'b'] 24953 */ 24954 var pull = baseRest(pullAll); 24955 24956 /** 24957 * This method is like `_.pull` except that it accepts an array of values to remove. 24958 * 24959 * **Note:** Unlike `_.difference`, this method mutates `array`. 24960 * 24961 * @static 24962 * @memberOf _ 24963 * @since 4.0.0 24964 * @category Array 24965 * @param {Array} array The array to modify. 24966 * @param {Array} values The values to remove. 24967 * @returns {Array} Returns `array`. 24968 * @example 24969 * 24970 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 24971 * 24972 * _.pullAll(array, ['a', 'c']); 24973 * console.log(array); 24974 * // => ['b', 'b'] 24975 */ 24976 function pullAll(array, values) { 24977 return (array && array.length && values && values.length) 24978 ? basePullAll(array, values) 24979 : array; 24980 } 24981 24982 /** 24983 * This method is like `_.pullAll` except that it accepts `iteratee` which is 24984 * invoked for each element of `array` and `values` to generate the criterion 24985 * by which they're compared. The iteratee is invoked with one argument: (value). 24986 * 24987 * **Note:** Unlike `_.differenceBy`, this method mutates `array`. 24988 * 24989 * @static 24990 * @memberOf _ 24991 * @since 4.0.0 24992 * @category Array 24993 * @param {Array} array The array to modify. 24994 * @param {Array} values The values to remove. 24995 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 24996 * @returns {Array} Returns `array`. 24997 * @example 24998 * 24999 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; 25000 * 25001 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); 25002 * console.log(array); 25003 * // => [{ 'x': 2 }] 25004 */ 25005 function pullAllBy(array, values, iteratee) { 25006 return (array && array.length && values && values.length) 25007 ? basePullAll(array, values, getIteratee(iteratee, 2)) 25008 : array; 25009 } 25010 25011 /** 25012 * This method is like `_.pullAll` except that it accepts `comparator` which 25013 * is invoked to compare elements of `array` to `values`. The comparator is 25014 * invoked with two arguments: (arrVal, othVal). 25015 * 25016 * **Note:** Unlike `_.differenceWith`, this method mutates `array`. 25017 * 25018 * @static 25019 * @memberOf _ 25020 * @since 4.6.0 25021 * @category Array 25022 * @param {Array} array The array to modify. 25023 * @param {Array} values The values to remove. 25024 * @param {Function} [comparator] The comparator invoked per element. 25025 * @returns {Array} Returns `array`. 25026 * @example 25027 * 25028 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; 25029 * 25030 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); 25031 * console.log(array); 25032 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] 25033 */ 25034 function pullAllWith(array, values, comparator) { 25035 return (array && array.length && values && values.length) 25036 ? basePullAll(array, values, undefined, comparator) 25037 : array; 25038 } 25039 25040 /** 25041 * Removes elements from `array` corresponding to `indexes` and returns an 25042 * array of removed elements. 25043 * 25044 * **Note:** Unlike `_.at`, this method mutates `array`. 25045 * 25046 * @static 25047 * @memberOf _ 25048 * @since 3.0.0 25049 * @category Array 25050 * @param {Array} array The array to modify. 25051 * @param {...(number|number[])} [indexes] The indexes of elements to remove. 25052 * @returns {Array} Returns the new array of removed elements. 25053 * @example 25054 * 25055 * var array = ['a', 'b', 'c', 'd']; 25056 * var pulled = _.pullAt(array, [1, 3]); 25057 * 25058 * console.log(array); 25059 * // => ['a', 'c'] 25060 * 25061 * console.log(pulled); 25062 * // => ['b', 'd'] 25063 */ 25064 var pullAt = flatRest(function(array, indexes) { 25065 var length = array == null ? 0 : array.length, 25066 result = baseAt(array, indexes); 25067 25068 basePullAt(array, arrayMap(indexes, function(index) { 25069 return isIndex(index, length) ? +index : index; 25070 }).sort(compareAscending)); 25071 25072 return result; 25073 }); 25074 25075 /** 25076 * Removes all elements from `array` that `predicate` returns truthy for 25077 * and returns an array of the removed elements. The predicate is invoked 25078 * with three arguments: (value, index, array). 25079 * 25080 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` 25081 * to pull elements from an array by value. 25082 * 25083 * @static 25084 * @memberOf _ 25085 * @since 2.0.0 25086 * @category Array 25087 * @param {Array} array The array to modify. 25088 * @param {Function} [predicate=_.identity] The function invoked per iteration. 25089 * @returns {Array} Returns the new array of removed elements. 25090 * @example 25091 * 25092 * var array = [1, 2, 3, 4]; 25093 * var evens = _.remove(array, function(n) { 25094 * return n % 2 == 0; 25095 * }); 25096 * 25097 * console.log(array); 25098 * // => [1, 3] 25099 * 25100 * console.log(evens); 25101 * // => [2, 4] 25102 */ 25103 function remove(array, predicate) { 25104 var result = []; 25105 if (!(array && array.length)) { 25106 return result; 25107 } 25108 var index = -1, 25109 indexes = [], 25110 length = array.length; 25111 25112 predicate = getIteratee(predicate, 3); 25113 while (++index < length) { 25114 var value = array[index]; 25115 if (predicate(value, index, array)) { 25116 result.push(value); 25117 indexes.push(index); 25118 } 25119 } 25120 basePullAt(array, indexes); 25121 return result; 25122 } 25123 25124 /** 25125 * Reverses `array` so that the first element becomes the last, the second 25126 * element becomes the second to last, and so on. 25127 * 25128 * **Note:** This method mutates `array` and is based on 25129 * [`Array#reverse`](https://mdn.io/Array/reverse). 25130 * 25131 * @static 25132 * @memberOf _ 25133 * @since 4.0.0 25134 * @category Array 25135 * @param {Array} array The array to modify. 25136 * @returns {Array} Returns `array`. 25137 * @example 25138 * 25139 * var array = [1, 2, 3]; 25140 * 25141 * _.reverse(array); 25142 * // => [3, 2, 1] 25143 * 25144 * console.log(array); 25145 * // => [3, 2, 1] 25146 */ 25147 function reverse(array) { 25148 return array == null ? array : nativeReverse.call(array); 25149 } 25150 25151 /** 25152 * Creates a slice of `array` from `start` up to, but not including, `end`. 25153 * 25154 * **Note:** This method is used instead of 25155 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are 25156 * returned. 25157 * 25158 * @static 25159 * @memberOf _ 25160 * @since 3.0.0 25161 * @category Array 25162 * @param {Array} array The array to slice. 25163 * @param {number} [start=0] The start position. 25164 * @param {number} [end=array.length] The end position. 25165 * @returns {Array} Returns the slice of `array`. 25166 */ 25167 function slice(array, start, end) { 25168 var length = array == null ? 0 : array.length; 25169 if (!length) { 25170 return []; 25171 } 25172 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { 25173 start = 0; 25174 end = length; 25175 } 25176 else { 25177 start = start == null ? 0 : toInteger(start); 25178 end = end === undefined ? length : toInteger(end); 25179 } 25180 return baseSlice(array, start, end); 25181 } 25182 25183 /** 25184 * Uses a binary search to determine the lowest index at which `value` 25185 * should be inserted into `array` in order to maintain its sort order. 25186 * 25187 * @static 25188 * @memberOf _ 25189 * @since 0.1.0 25190 * @category Array 25191 * @param {Array} array The sorted array to inspect. 25192 * @param {*} value The value to evaluate. 25193 * @returns {number} Returns the index at which `value` should be inserted 25194 * into `array`. 25195 * @example 25196 * 25197 * _.sortedIndex([30, 50], 40); 25198 * // => 1 25199 */ 25200 function sortedIndex(array, value) { 25201 return baseSortedIndex(array, value); 25202 } 25203 25204 /** 25205 * This method is like `_.sortedIndex` except that it accepts `iteratee` 25206 * which is invoked for `value` and each element of `array` to compute their 25207 * sort ranking. The iteratee is invoked with one argument: (value). 25208 * 25209 * @static 25210 * @memberOf _ 25211 * @since 4.0.0 25212 * @category Array 25213 * @param {Array} array The sorted array to inspect. 25214 * @param {*} value The value to evaluate. 25215 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 25216 * @returns {number} Returns the index at which `value` should be inserted 25217 * into `array`. 25218 * @example 25219 * 25220 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 25221 * 25222 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 25223 * // => 0 25224 * 25225 * // The `_.property` iteratee shorthand. 25226 * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); 25227 * // => 0 25228 */ 25229 function sortedIndexBy(array, value, iteratee) { 25230 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); 25231 } 25232 25233 /** 25234 * This method is like `_.indexOf` except that it performs a binary 25235 * search on a sorted `array`. 25236 * 25237 * @static 25238 * @memberOf _ 25239 * @since 4.0.0 25240 * @category Array 25241 * @param {Array} array The array to inspect. 25242 * @param {*} value The value to search for. 25243 * @returns {number} Returns the index of the matched value, else `-1`. 25244 * @example 25245 * 25246 * _.sortedIndexOf([4, 5, 5, 5, 6], 5); 25247 * // => 1 25248 */ 25249 function sortedIndexOf(array, value) { 25250 var length = array == null ? 0 : array.length; 25251 if (length) { 25252 var index = baseSortedIndex(array, value); 25253 if (index < length && eq(array[index], value)) { 25254 return index; 25255 } 25256 } 25257 return -1; 25258 } 25259 25260 /** 25261 * This method is like `_.sortedIndex` except that it returns the highest 25262 * index at which `value` should be inserted into `array` in order to 25263 * maintain its sort order. 25264 * 25265 * @static 25266 * @memberOf _ 25267 * @since 3.0.0 25268 * @category Array 25269 * @param {Array} array The sorted array to inspect. 25270 * @param {*} value The value to evaluate. 25271 * @returns {number} Returns the index at which `value` should be inserted 25272 * into `array`. 25273 * @example 25274 * 25275 * _.sortedLastIndex([4, 5, 5, 5, 6], 5); 25276 * // => 4 25277 */ 25278 function sortedLastIndex(array, value) { 25279 return baseSortedIndex(array, value, true); 25280 } 25281 25282 /** 25283 * This method is like `_.sortedLastIndex` except that it accepts `iteratee` 25284 * which is invoked for `value` and each element of `array` to compute their 25285 * sort ranking. The iteratee is invoked with one argument: (value). 25286 * 25287 * @static 25288 * @memberOf _ 25289 * @since 4.0.0 25290 * @category Array 25291 * @param {Array} array The sorted array to inspect. 25292 * @param {*} value The value to evaluate. 25293 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 25294 * @returns {number} Returns the index at which `value` should be inserted 25295 * into `array`. 25296 * @example 25297 * 25298 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 25299 * 25300 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 25301 * // => 1 25302 * 25303 * // The `_.property` iteratee shorthand. 25304 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); 25305 * // => 1 25306 */ 25307 function sortedLastIndexBy(array, value, iteratee) { 25308 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); 25309 } 25310 25311 /** 25312 * This method is like `_.lastIndexOf` except that it performs a binary 25313 * search on a sorted `array`. 25314 * 25315 * @static 25316 * @memberOf _ 25317 * @since 4.0.0 25318 * @category Array 25319 * @param {Array} array The array to inspect. 25320 * @param {*} value The value to search for. 25321 * @returns {number} Returns the index of the matched value, else `-1`. 25322 * @example 25323 * 25324 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); 25325 * // => 3 25326 */ 25327 function sortedLastIndexOf(array, value) { 25328 var length = array == null ? 0 : array.length; 25329 if (length) { 25330 var index = baseSortedIndex(array, value, true) - 1; 25331 if (eq(array[index], value)) { 25332 return index; 25333 } 25334 } 25335 return -1; 25336 } 25337 25338 /** 25339 * This method is like `_.uniq` except that it's designed and optimized 25340 * for sorted arrays. 25341 * 25342 * @static 25343 * @memberOf _ 25344 * @since 4.0.0 25345 * @category Array 25346 * @param {Array} array The array to inspect. 25347 * @returns {Array} Returns the new duplicate free array. 25348 * @example 25349 * 25350 * _.sortedUniq([1, 1, 2]); 25351 * // => [1, 2] 25352 */ 25353 function sortedUniq(array) { 25354 return (array && array.length) 25355 ? baseSortedUniq(array) 25356 : []; 25357 } 25358 25359 /** 25360 * This method is like `_.uniqBy` except that it's designed and optimized 25361 * for sorted arrays. 25362 * 25363 * @static 25364 * @memberOf _ 25365 * @since 4.0.0 25366 * @category Array 25367 * @param {Array} array The array to inspect. 25368 * @param {Function} [iteratee] The iteratee invoked per element. 25369 * @returns {Array} Returns the new duplicate free array. 25370 * @example 25371 * 25372 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); 25373 * // => [1.1, 2.3] 25374 */ 25375 function sortedUniqBy(array, iteratee) { 25376 return (array && array.length) 25377 ? baseSortedUniq(array, getIteratee(iteratee, 2)) 25378 : []; 25379 } 25380 25381 /** 25382 * Gets all but the first element of `array`. 25383 * 25384 * @static 25385 * @memberOf _ 25386 * @since 4.0.0 25387 * @category Array 25388 * @param {Array} array The array to query. 25389 * @returns {Array} Returns the slice of `array`. 25390 * @example 25391 * 25392 * _.tail([1, 2, 3]); 25393 * // => [2, 3] 25394 */ 25395 function tail(array) { 25396 var length = array == null ? 0 : array.length; 25397 return length ? baseSlice(array, 1, length) : []; 25398 } 25399 25400 /** 25401 * Creates a slice of `array` with `n` elements taken from the beginning. 25402 * 25403 * @static 25404 * @memberOf _ 25405 * @since 0.1.0 25406 * @category Array 25407 * @param {Array} array The array to query. 25408 * @param {number} [n=1] The number of elements to take. 25409 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 25410 * @returns {Array} Returns the slice of `array`. 25411 * @example 25412 * 25413 * _.take([1, 2, 3]); 25414 * // => [1] 25415 * 25416 * _.take([1, 2, 3], 2); 25417 * // => [1, 2] 25418 * 25419 * _.take([1, 2, 3], 5); 25420 * // => [1, 2, 3] 25421 * 25422 * _.take([1, 2, 3], 0); 25423 * // => [] 25424 */ 25425 function take(array, n, guard) { 25426 if (!(array && array.length)) { 25427 return []; 25428 } 25429 n = (guard || n === undefined) ? 1 : toInteger(n); 25430 return baseSlice(array, 0, n < 0 ? 0 : n); 25431 } 25432 25433 /** 25434 * Creates a slice of `array` with `n` elements taken from the end. 25435 * 25436 * @static 25437 * @memberOf _ 25438 * @since 3.0.0 25439 * @category Array 25440 * @param {Array} array The array to query. 25441 * @param {number} [n=1] The number of elements to take. 25442 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 25443 * @returns {Array} Returns the slice of `array`. 25444 * @example 25445 * 25446 * _.takeRight([1, 2, 3]); 25447 * // => [3] 25448 * 25449 * _.takeRight([1, 2, 3], 2); 25450 * // => [2, 3] 25451 * 25452 * _.takeRight([1, 2, 3], 5); 25453 * // => [1, 2, 3] 25454 * 25455 * _.takeRight([1, 2, 3], 0); 25456 * // => [] 25457 */ 25458 function takeRight(array, n, guard) { 25459 var length = array == null ? 0 : array.length; 25460 if (!length) { 25461 return []; 25462 } 25463 n = (guard || n === undefined) ? 1 : toInteger(n); 25464 n = length - n; 25465 return baseSlice(array, n < 0 ? 0 : n, length); 25466 } 25467 25468 /** 25469 * Creates a slice of `array` with elements taken from the end. Elements are 25470 * taken until `predicate` returns falsey. The predicate is invoked with 25471 * three arguments: (value, index, array). 25472 * 25473 * @static 25474 * @memberOf _ 25475 * @since 3.0.0 25476 * @category Array 25477 * @param {Array} array The array to query. 25478 * @param {Function} [predicate=_.identity] The function invoked per iteration. 25479 * @returns {Array} Returns the slice of `array`. 25480 * @example 25481 * 25482 * var users = [ 25483 * { 'user': 'barney', 'active': true }, 25484 * { 'user': 'fred', 'active': false }, 25485 * { 'user': 'pebbles', 'active': false } 25486 * ]; 25487 * 25488 * _.takeRightWhile(users, function(o) { return !o.active; }); 25489 * // => objects for ['fred', 'pebbles'] 25490 * 25491 * // The `_.matches` iteratee shorthand. 25492 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); 25493 * // => objects for ['pebbles'] 25494 * 25495 * // The `_.matchesProperty` iteratee shorthand. 25496 * _.takeRightWhile(users, ['active', false]); 25497 * // => objects for ['fred', 'pebbles'] 25498 * 25499 * // The `_.property` iteratee shorthand. 25500 * _.takeRightWhile(users, 'active'); 25501 * // => [] 25502 */ 25503 function takeRightWhile(array, predicate) { 25504 return (array && array.length) 25505 ? baseWhile(array, getIteratee(predicate, 3), false, true) 25506 : []; 25507 } 25508 25509 /** 25510 * Creates a slice of `array` with elements taken from the beginning. Elements 25511 * are taken until `predicate` returns falsey. The predicate is invoked with 25512 * three arguments: (value, index, array). 25513 * 25514 * @static 25515 * @memberOf _ 25516 * @since 3.0.0 25517 * @category Array 25518 * @param {Array} array The array to query. 25519 * @param {Function} [predicate=_.identity] The function invoked per iteration. 25520 * @returns {Array} Returns the slice of `array`. 25521 * @example 25522 * 25523 * var users = [ 25524 * { 'user': 'barney', 'active': false }, 25525 * { 'user': 'fred', 'active': false }, 25526 * { 'user': 'pebbles', 'active': true } 25527 * ]; 25528 * 25529 * _.takeWhile(users, function(o) { return !o.active; }); 25530 * // => objects for ['barney', 'fred'] 25531 * 25532 * // The `_.matches` iteratee shorthand. 25533 * _.takeWhile(users, { 'user': 'barney', 'active': false }); 25534 * // => objects for ['barney'] 25535 * 25536 * // The `_.matchesProperty` iteratee shorthand. 25537 * _.takeWhile(users, ['active', false]); 25538 * // => objects for ['barney', 'fred'] 25539 * 25540 * // The `_.property` iteratee shorthand. 25541 * _.takeWhile(users, 'active'); 25542 * // => [] 25543 */ 25544 function takeWhile(array, predicate) { 25545 return (array && array.length) 25546 ? baseWhile(array, getIteratee(predicate, 3)) 25547 : []; 25548 } 25549 25550 /** 25551 * Creates an array of unique values, in order, from all given arrays using 25552 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 25553 * for equality comparisons. 25554 * 25555 * @static 25556 * @memberOf _ 25557 * @since 0.1.0 25558 * @category Array 25559 * @param {...Array} [arrays] The arrays to inspect. 25560 * @returns {Array} Returns the new array of combined values. 25561 * @example 25562 * 25563 * _.union([2], [1, 2]); 25564 * // => [2, 1] 25565 */ 25566 var union = baseRest(function(arrays) { 25567 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); 25568 }); 25569 25570 /** 25571 * This method is like `_.union` except that it accepts `iteratee` which is 25572 * invoked for each element of each `arrays` to generate the criterion by 25573 * which uniqueness is computed. Result values are chosen from the first 25574 * array in which the value occurs. The iteratee is invoked with one argument: 25575 * (value). 25576 * 25577 * @static 25578 * @memberOf _ 25579 * @since 4.0.0 25580 * @category Array 25581 * @param {...Array} [arrays] The arrays to inspect. 25582 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 25583 * @returns {Array} Returns the new array of combined values. 25584 * @example 25585 * 25586 * _.unionBy([2.1], [1.2, 2.3], Math.floor); 25587 * // => [2.1, 1.2] 25588 * 25589 * // The `_.property` iteratee shorthand. 25590 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 25591 * // => [{ 'x': 1 }, { 'x': 2 }] 25592 */ 25593 var unionBy = baseRest(function(arrays) { 25594 var iteratee = last(arrays); 25595 if (isArrayLikeObject(iteratee)) { 25596 iteratee = undefined; 25597 } 25598 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); 25599 }); 25600 25601 /** 25602 * This method is like `_.union` except that it accepts `comparator` which 25603 * is invoked to compare elements of `arrays`. Result values are chosen from 25604 * the first array in which the value occurs. The comparator is invoked 25605 * with two arguments: (arrVal, othVal). 25606 * 25607 * @static 25608 * @memberOf _ 25609 * @since 4.0.0 25610 * @category Array 25611 * @param {...Array} [arrays] The arrays to inspect. 25612 * @param {Function} [comparator] The comparator invoked per element. 25613 * @returns {Array} Returns the new array of combined values. 25614 * @example 25615 * 25616 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 25617 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 25618 * 25619 * _.unionWith(objects, others, _.isEqual); 25620 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 25621 */ 25622 var unionWith = baseRest(function(arrays) { 25623 var comparator = last(arrays); 25624 comparator = typeof comparator == 'function' ? comparator : undefined; 25625 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); 25626 }); 25627 25628 /** 25629 * Creates a duplicate-free version of an array, using 25630 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 25631 * for equality comparisons, in which only the first occurrence of each element 25632 * is kept. The order of result values is determined by the order they occur 25633 * in the array. 25634 * 25635 * @static 25636 * @memberOf _ 25637 * @since 0.1.0 25638 * @category Array 25639 * @param {Array} array The array to inspect. 25640 * @returns {Array} Returns the new duplicate free array. 25641 * @example 25642 * 25643 * _.uniq([2, 1, 2]); 25644 * // => [2, 1] 25645 */ 25646 function uniq(array) { 25647 return (array && array.length) ? baseUniq(array) : []; 25648 } 25649 25650 /** 25651 * This method is like `_.uniq` except that it accepts `iteratee` which is 25652 * invoked for each element in `array` to generate the criterion by which 25653 * uniqueness is computed. The order of result values is determined by the 25654 * order they occur in the array. The iteratee is invoked with one argument: 25655 * (value). 25656 * 25657 * @static 25658 * @memberOf _ 25659 * @since 4.0.0 25660 * @category Array 25661 * @param {Array} array The array to inspect. 25662 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 25663 * @returns {Array} Returns the new duplicate free array. 25664 * @example 25665 * 25666 * _.uniqBy([2.1, 1.2, 2.3], Math.floor); 25667 * // => [2.1, 1.2] 25668 * 25669 * // The `_.property` iteratee shorthand. 25670 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); 25671 * // => [{ 'x': 1 }, { 'x': 2 }] 25672 */ 25673 function uniqBy(array, iteratee) { 25674 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; 25675 } 25676 25677 /** 25678 * This method is like `_.uniq` except that it accepts `comparator` which 25679 * is invoked to compare elements of `array`. The order of result values is 25680 * determined by the order they occur in the array.The comparator is invoked 25681 * with two arguments: (arrVal, othVal). 25682 * 25683 * @static 25684 * @memberOf _ 25685 * @since 4.0.0 25686 * @category Array 25687 * @param {Array} array The array to inspect. 25688 * @param {Function} [comparator] The comparator invoked per element. 25689 * @returns {Array} Returns the new duplicate free array. 25690 * @example 25691 * 25692 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; 25693 * 25694 * _.uniqWith(objects, _.isEqual); 25695 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] 25696 */ 25697 function uniqWith(array, comparator) { 25698 comparator = typeof comparator == 'function' ? comparator : undefined; 25699 return (array && array.length) ? baseUniq(array, undefined, comparator) : []; 25700 } 25701 25702 /** 25703 * This method is like `_.zip` except that it accepts an array of grouped 25704 * elements and creates an array regrouping the elements to their pre-zip 25705 * configuration. 25706 * 25707 * @static 25708 * @memberOf _ 25709 * @since 1.2.0 25710 * @category Array 25711 * @param {Array} array The array of grouped elements to process. 25712 * @returns {Array} Returns the new array of regrouped elements. 25713 * @example 25714 * 25715 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); 25716 * // => [['a', 1, true], ['b', 2, false]] 25717 * 25718 * _.unzip(zipped); 25719 * // => [['a', 'b'], [1, 2], [true, false]] 25720 */ 25721 function unzip(array) { 25722 if (!(array && array.length)) { 25723 return []; 25724 } 25725 var length = 0; 25726 array = arrayFilter(array, function(group) { 25727 if (isArrayLikeObject(group)) { 25728 length = nativeMax(group.length, length); 25729 return true; 25730 } 25731 }); 25732 return baseTimes(length, function(index) { 25733 return arrayMap(array, baseProperty(index)); 25734 }); 25735 } 25736 25737 /** 25738 * This method is like `_.unzip` except that it accepts `iteratee` to specify 25739 * how regrouped values should be combined. The iteratee is invoked with the 25740 * elements of each group: (...group). 25741 * 25742 * @static 25743 * @memberOf _ 25744 * @since 3.8.0 25745 * @category Array 25746 * @param {Array} array The array of grouped elements to process. 25747 * @param {Function} [iteratee=_.identity] The function to combine 25748 * regrouped values. 25749 * @returns {Array} Returns the new array of regrouped elements. 25750 * @example 25751 * 25752 * var zipped = _.zip([1, 2], [10, 20], [100, 200]); 25753 * // => [[1, 10, 100], [2, 20, 200]] 25754 * 25755 * _.unzipWith(zipped, _.add); 25756 * // => [3, 30, 300] 25757 */ 25758 function unzipWith(array, iteratee) { 25759 if (!(array && array.length)) { 25760 return []; 25761 } 25762 var result = unzip(array); 25763 if (iteratee == null) { 25764 return result; 25765 } 25766 return arrayMap(result, function(group) { 25767 return apply(iteratee, undefined, group); 25768 }); 25769 } 25770 25771 /** 25772 * Creates an array excluding all given values using 25773 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 25774 * for equality comparisons. 25775 * 25776 * **Note:** Unlike `_.pull`, this method returns a new array. 25777 * 25778 * @static 25779 * @memberOf _ 25780 * @since 0.1.0 25781 * @category Array 25782 * @param {Array} array The array to inspect. 25783 * @param {...*} [values] The values to exclude. 25784 * @returns {Array} Returns the new array of filtered values. 25785 * @see _.difference, _.xor 25786 * @example 25787 * 25788 * _.without([2, 1, 2, 3], 1, 2); 25789 * // => [3] 25790 */ 25791 var without = baseRest(function(array, values) { 25792 return isArrayLikeObject(array) 25793 ? baseDifference(array, values) 25794 : []; 25795 }); 25796 25797 /** 25798 * Creates an array of unique values that is the 25799 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) 25800 * of the given arrays. The order of result values is determined by the order 25801 * they occur in the arrays. 25802 * 25803 * @static 25804 * @memberOf _ 25805 * @since 2.4.0 25806 * @category Array 25807 * @param {...Array} [arrays] The arrays to inspect. 25808 * @returns {Array} Returns the new array of filtered values. 25809 * @see _.difference, _.without 25810 * @example 25811 * 25812 * _.xor([2, 1], [2, 3]); 25813 * // => [1, 3] 25814 */ 25815 var xor = baseRest(function(arrays) { 25816 return baseXor(arrayFilter(arrays, isArrayLikeObject)); 25817 }); 25818 25819 /** 25820 * This method is like `_.xor` except that it accepts `iteratee` which is 25821 * invoked for each element of each `arrays` to generate the criterion by 25822 * which by which they're compared. The order of result values is determined 25823 * by the order they occur in the arrays. The iteratee is invoked with one 25824 * argument: (value). 25825 * 25826 * @static 25827 * @memberOf _ 25828 * @since 4.0.0 25829 * @category Array 25830 * @param {...Array} [arrays] The arrays to inspect. 25831 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 25832 * @returns {Array} Returns the new array of filtered values. 25833 * @example 25834 * 25835 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); 25836 * // => [1.2, 3.4] 25837 * 25838 * // The `_.property` iteratee shorthand. 25839 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 25840 * // => [{ 'x': 2 }] 25841 */ 25842 var xorBy = baseRest(function(arrays) { 25843 var iteratee = last(arrays); 25844 if (isArrayLikeObject(iteratee)) { 25845 iteratee = undefined; 25846 } 25847 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); 25848 }); 25849 25850 /** 25851 * This method is like `_.xor` except that it accepts `comparator` which is 25852 * invoked to compare elements of `arrays`. The order of result values is 25853 * determined by the order they occur in the arrays. The comparator is invoked 25854 * with two arguments: (arrVal, othVal). 25855 * 25856 * @static 25857 * @memberOf _ 25858 * @since 4.0.0 25859 * @category Array 25860 * @param {...Array} [arrays] The arrays to inspect. 25861 * @param {Function} [comparator] The comparator invoked per element. 25862 * @returns {Array} Returns the new array of filtered values. 25863 * @example 25864 * 25865 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 25866 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 25867 * 25868 * _.xorWith(objects, others, _.isEqual); 25869 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 25870 */ 25871 var xorWith = baseRest(function(arrays) { 25872 var comparator = last(arrays); 25873 comparator = typeof comparator == 'function' ? comparator : undefined; 25874 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); 25875 }); 25876 25877 /** 25878 * Creates an array of grouped elements, the first of which contains the 25879 * first elements of the given arrays, the second of which contains the 25880 * second elements of the given arrays, and so on. 25881 * 25882 * @static 25883 * @memberOf _ 25884 * @since 0.1.0 25885 * @category Array 25886 * @param {...Array} [arrays] The arrays to process. 25887 * @returns {Array} Returns the new array of grouped elements. 25888 * @example 25889 * 25890 * _.zip(['a', 'b'], [1, 2], [true, false]); 25891 * // => [['a', 1, true], ['b', 2, false]] 25892 */ 25893 var zip = baseRest(unzip); 25894 25895 /** 25896 * This method is like `_.fromPairs` except that it accepts two arrays, 25897 * one of property identifiers and one of corresponding values. 25898 * 25899 * @static 25900 * @memberOf _ 25901 * @since 0.4.0 25902 * @category Array 25903 * @param {Array} [props=[]] The property identifiers. 25904 * @param {Array} [values=[]] The property values. 25905 * @returns {Object} Returns the new object. 25906 * @example 25907 * 25908 * _.zipObject(['a', 'b'], [1, 2]); 25909 * // => { 'a': 1, 'b': 2 } 25910 */ 25911 function zipObject(props, values) { 25912 return baseZipObject(props || [], values || [], assignValue); 25913 } 25914 25915 /** 25916 * This method is like `_.zipObject` except that it supports property paths. 25917 * 25918 * @static 25919 * @memberOf _ 25920 * @since 4.1.0 25921 * @category Array 25922 * @param {Array} [props=[]] The property identifiers. 25923 * @param {Array} [values=[]] The property values. 25924 * @returns {Object} Returns the new object. 25925 * @example 25926 * 25927 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); 25928 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } 25929 */ 25930 function zipObjectDeep(props, values) { 25931 return baseZipObject(props || [], values || [], baseSet); 25932 } 25933 25934 /** 25935 * This method is like `_.zip` except that it accepts `iteratee` to specify 25936 * how grouped values should be combined. The iteratee is invoked with the 25937 * elements of each group: (...group). 25938 * 25939 * @static 25940 * @memberOf _ 25941 * @since 3.8.0 25942 * @category Array 25943 * @param {...Array} [arrays] The arrays to process. 25944 * @param {Function} [iteratee=_.identity] The function to combine 25945 * grouped values. 25946 * @returns {Array} Returns the new array of grouped elements. 25947 * @example 25948 * 25949 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { 25950 * return a + b + c; 25951 * }); 25952 * // => [111, 222] 25953 */ 25954 var zipWith = baseRest(function(arrays) { 25955 var length = arrays.length, 25956 iteratee = length > 1 ? arrays[length - 1] : undefined; 25957 25958 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; 25959 return unzipWith(arrays, iteratee); 25960 }); 25961 25962 /*------------------------------------------------------------------------*/ 25963 25964 /** 25965 * Creates a `lodash` wrapper instance that wraps `value` with explicit method 25966 * chain sequences enabled. The result of such sequences must be unwrapped 25967 * with `_#value`. 25968 * 25969 * @static 25970 * @memberOf _ 25971 * @since 1.3.0 25972 * @category Seq 25973 * @param {*} value The value to wrap. 25974 * @returns {Object} Returns the new `lodash` wrapper instance. 25975 * @example 25976 * 25977 * var users = [ 25978 * { 'user': 'barney', 'age': 36 }, 25979 * { 'user': 'fred', 'age': 40 }, 25980 * { 'user': 'pebbles', 'age': 1 } 25981 * ]; 25982 * 25983 * var youngest = _ 25984 * .chain(users) 25985 * .sortBy('age') 25986 * .map(function(o) { 25987 * return o.user + ' is ' + o.age; 25988 * }) 25989 * .head() 25990 * .value(); 25991 * // => 'pebbles is 1' 25992 */ 25993 function chain(value) { 25994 var result = lodash(value); 25995 result.__chain__ = true; 25996 return result; 25997 } 25998 25999 /** 26000 * This method invokes `interceptor` and returns `value`. The interceptor 26001 * is invoked with one argument; (value). The purpose of this method is to 26002 * "tap into" a method chain sequence in order to modify intermediate results. 26003 * 26004 * @static 26005 * @memberOf _ 26006 * @since 0.1.0 26007 * @category Seq 26008 * @param {*} value The value to provide to `interceptor`. 26009 * @param {Function} interceptor The function to invoke. 26010 * @returns {*} Returns `value`. 26011 * @example 26012 * 26013 * _([1, 2, 3]) 26014 * .tap(function(array) { 26015 * // Mutate input array. 26016 * array.pop(); 26017 * }) 26018 * .reverse() 26019 * .value(); 26020 * // => [2, 1] 26021 */ 26022 function tap(value, interceptor) { 26023 interceptor(value); 26024 return value; 26025 } 26026 26027 /** 26028 * This method is like `_.tap` except that it returns the result of `interceptor`. 26029 * The purpose of this method is to "pass thru" values replacing intermediate 26030 * results in a method chain sequence. 26031 * 26032 * @static 26033 * @memberOf _ 26034 * @since 3.0.0 26035 * @category Seq 26036 * @param {*} value The value to provide to `interceptor`. 26037 * @param {Function} interceptor The function to invoke. 26038 * @returns {*} Returns the result of `interceptor`. 26039 * @example 26040 * 26041 * _(' abc ') 26042 * .chain() 26043 * .trim() 26044 * .thru(function(value) { 26045 * return [value]; 26046 * }) 26047 * .value(); 26048 * // => ['abc'] 26049 */ 26050 function thru(value, interceptor) { 26051 return interceptor(value); 26052 } 26053 26054 /** 26055 * This method is the wrapper version of `_.at`. 26056 * 26057 * @name at 26058 * @memberOf _ 26059 * @since 1.0.0 26060 * @category Seq 26061 * @param {...(string|string[])} [paths] The property paths to pick. 26062 * @returns {Object} Returns the new `lodash` wrapper instance. 26063 * @example 26064 * 26065 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 26066 * 26067 * _(object).at(['a[0].b.c', 'a[1]']).value(); 26068 * // => [3, 4] 26069 */ 26070 var wrapperAt = flatRest(function(paths) { 26071 var length = paths.length, 26072 start = length ? paths[0] : 0, 26073 value = this.__wrapped__, 26074 interceptor = function(object) { return baseAt(object, paths); }; 26075 26076 if (length > 1 || this.__actions__.length || 26077 !(value instanceof LazyWrapper) || !isIndex(start)) { 26078 return this.thru(interceptor); 26079 } 26080 value = value.slice(start, +start + (length ? 1 : 0)); 26081 value.__actions__.push({ 26082 'func': thru, 26083 'args': [interceptor], 26084 'thisArg': undefined 26085 }); 26086 return new LodashWrapper(value, this.__chain__).thru(function(array) { 26087 if (length && !array.length) { 26088 array.push(undefined); 26089 } 26090 return array; 26091 }); 26092 }); 26093 26094 /** 26095 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. 26096 * 26097 * @name chain 26098 * @memberOf _ 26099 * @since 0.1.0 26100 * @category Seq 26101 * @returns {Object} Returns the new `lodash` wrapper instance. 26102 * @example 26103 * 26104 * var users = [ 26105 * { 'user': 'barney', 'age': 36 }, 26106 * { 'user': 'fred', 'age': 40 } 26107 * ]; 26108 * 26109 * // A sequence without explicit chaining. 26110 * _(users).head(); 26111 * // => { 'user': 'barney', 'age': 36 } 26112 * 26113 * // A sequence with explicit chaining. 26114 * _(users) 26115 * .chain() 26116 * .head() 26117 * .pick('user') 26118 * .value(); 26119 * // => { 'user': 'barney' } 26120 */ 26121 function wrapperChain() { 26122 return chain(this); 26123 } 26124 26125 /** 26126 * Executes the chain sequence and returns the wrapped result. 26127 * 26128 * @name commit 26129 * @memberOf _ 26130 * @since 3.2.0 26131 * @category Seq 26132 * @returns {Object} Returns the new `lodash` wrapper instance. 26133 * @example 26134 * 26135 * var array = [1, 2]; 26136 * var wrapped = _(array).push(3); 26137 * 26138 * console.log(array); 26139 * // => [1, 2] 26140 * 26141 * wrapped = wrapped.commit(); 26142 * console.log(array); 26143 * // => [1, 2, 3] 26144 * 26145 * wrapped.last(); 26146 * // => 3 26147 * 26148 * console.log(array); 26149 * // => [1, 2, 3] 26150 */ 26151 function wrapperCommit() { 26152 return new LodashWrapper(this.value(), this.__chain__); 26153 } 26154 26155 /** 26156 * Gets the next value on a wrapped object following the 26157 * [iterator protocol](https://mdn.io/iteration_protocols#iterator). 26158 * 26159 * @name next 26160 * @memberOf _ 26161 * @since 4.0.0 26162 * @category Seq 26163 * @returns {Object} Returns the next iterator value. 26164 * @example 26165 * 26166 * var wrapped = _([1, 2]); 26167 * 26168 * wrapped.next(); 26169 * // => { 'done': false, 'value': 1 } 26170 * 26171 * wrapped.next(); 26172 * // => { 'done': false, 'value': 2 } 26173 * 26174 * wrapped.next(); 26175 * // => { 'done': true, 'value': undefined } 26176 */ 26177 function wrapperNext() { 26178 if (this.__values__ === undefined) { 26179 this.__values__ = toArray(this.value()); 26180 } 26181 var done = this.__index__ >= this.__values__.length, 26182 value = done ? undefined : this.__values__[this.__index__++]; 26183 26184 return { 'done': done, 'value': value }; 26185 } 26186 26187 /** 26188 * Enables the wrapper to be iterable. 26189 * 26190 * @name Symbol.iterator 26191 * @memberOf _ 26192 * @since 4.0.0 26193 * @category Seq 26194 * @returns {Object} Returns the wrapper object. 26195 * @example 26196 * 26197 * var wrapped = _([1, 2]); 26198 * 26199 * wrapped[Symbol.iterator]() === wrapped; 26200 * // => true 26201 * 26202 * Array.from(wrapped); 26203 * // => [1, 2] 26204 */ 26205 function wrapperToIterator() { 26206 return this; 26207 } 26208 26209 /** 26210 * Creates a clone of the chain sequence planting `value` as the wrapped value. 26211 * 26212 * @name plant 26213 * @memberOf _ 26214 * @since 3.2.0 26215 * @category Seq 26216 * @param {*} value The value to plant. 26217 * @returns {Object} Returns the new `lodash` wrapper instance. 26218 * @example 26219 * 26220 * function square(n) { 26221 * return n * n; 26222 * } 26223 * 26224 * var wrapped = _([1, 2]).map(square); 26225 * var other = wrapped.plant([3, 4]); 26226 * 26227 * other.value(); 26228 * // => [9, 16] 26229 * 26230 * wrapped.value(); 26231 * // => [1, 4] 26232 */ 26233 function wrapperPlant(value) { 26234 var result, 26235 parent = this; 26236 26237 while (parent instanceof baseLodash) { 26238 var clone = wrapperClone(parent); 26239 clone.__index__ = 0; 26240 clone.__values__ = undefined; 26241 if (result) { 26242 previous.__wrapped__ = clone; 26243 } else { 26244 result = clone; 26245 } 26246 var previous = clone; 26247 parent = parent.__wrapped__; 26248 } 26249 previous.__wrapped__ = value; 26250 return result; 26251 } 26252 26253 /** 26254 * This method is the wrapper version of `_.reverse`. 26255 * 26256 * **Note:** This method mutates the wrapped array. 26257 * 26258 * @name reverse 26259 * @memberOf _ 26260 * @since 0.1.0 26261 * @category Seq 26262 * @returns {Object} Returns the new `lodash` wrapper instance. 26263 * @example 26264 * 26265 * var array = [1, 2, 3]; 26266 * 26267 * _(array).reverse().value() 26268 * // => [3, 2, 1] 26269 * 26270 * console.log(array); 26271 * // => [3, 2, 1] 26272 */ 26273 function wrapperReverse() { 26274 var value = this.__wrapped__; 26275 if (value instanceof LazyWrapper) { 26276 var wrapped = value; 26277 if (this.__actions__.length) { 26278 wrapped = new LazyWrapper(this); 26279 } 26280 wrapped = wrapped.reverse(); 26281 wrapped.__actions__.push({ 26282 'func': thru, 26283 'args': [reverse], 26284 'thisArg': undefined 26285 }); 26286 return new LodashWrapper(wrapped, this.__chain__); 26287 } 26288 return this.thru(reverse); 26289 } 26290 26291 /** 26292 * Executes the chain sequence to resolve the unwrapped value. 26293 * 26294 * @name value 26295 * @memberOf _ 26296 * @since 0.1.0 26297 * @alias toJSON, valueOf 26298 * @category Seq 26299 * @returns {*} Returns the resolved unwrapped value. 26300 * @example 26301 * 26302 * _([1, 2, 3]).value(); 26303 * // => [1, 2, 3] 26304 */ 26305 function wrapperValue() { 26306 return baseWrapperValue(this.__wrapped__, this.__actions__); 26307 } 26308 26309 /*------------------------------------------------------------------------*/ 26310 26311 /** 26312 * Creates an object composed of keys generated from the results of running 26313 * each element of `collection` thru `iteratee`. The corresponding value of 26314 * each key is the number of times the key was returned by `iteratee`. The 26315 * iteratee is invoked with one argument: (value). 26316 * 26317 * @static 26318 * @memberOf _ 26319 * @since 0.5.0 26320 * @category Collection 26321 * @param {Array|Object} collection The collection to iterate over. 26322 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 26323 * @returns {Object} Returns the composed aggregate object. 26324 * @example 26325 * 26326 * _.countBy([6.1, 4.2, 6.3], Math.floor); 26327 * // => { '4': 1, '6': 2 } 26328 * 26329 * // The `_.property` iteratee shorthand. 26330 * _.countBy(['one', 'two', 'three'], 'length'); 26331 * // => { '3': 2, '5': 1 } 26332 */ 26333 var countBy = createAggregator(function(result, value, key) { 26334 if (hasOwnProperty.call(result, key)) { 26335 ++result[key]; 26336 } else { 26337 baseAssignValue(result, key, 1); 26338 } 26339 }); 26340 26341 /** 26342 * Checks if `predicate` returns truthy for **all** elements of `collection`. 26343 * Iteration is stopped once `predicate` returns falsey. The predicate is 26344 * invoked with three arguments: (value, index|key, collection). 26345 * 26346 * **Note:** This method returns `true` for 26347 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because 26348 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of 26349 * elements of empty collections. 26350 * 26351 * @static 26352 * @memberOf _ 26353 * @since 0.1.0 26354 * @category Collection 26355 * @param {Array|Object} collection The collection to iterate over. 26356 * @param {Function} [predicate=_.identity] The function invoked per iteration. 26357 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 26358 * @returns {boolean} Returns `true` if all elements pass the predicate check, 26359 * else `false`. 26360 * @example 26361 * 26362 * _.every([true, 1, null, 'yes'], Boolean); 26363 * // => false 26364 * 26365 * var users = [ 26366 * { 'user': 'barney', 'age': 36, 'active': false }, 26367 * { 'user': 'fred', 'age': 40, 'active': false } 26368 * ]; 26369 * 26370 * // The `_.matches` iteratee shorthand. 26371 * _.every(users, { 'user': 'barney', 'active': false }); 26372 * // => false 26373 * 26374 * // The `_.matchesProperty` iteratee shorthand. 26375 * _.every(users, ['active', false]); 26376 * // => true 26377 * 26378 * // The `_.property` iteratee shorthand. 26379 * _.every(users, 'active'); 26380 * // => false 26381 */ 26382 function every(collection, predicate, guard) { 26383 var func = isArray(collection) ? arrayEvery : baseEvery; 26384 if (guard && isIterateeCall(collection, predicate, guard)) { 26385 predicate = undefined; 26386 } 26387 return func(collection, getIteratee(predicate, 3)); 26388 } 26389 26390 /** 26391 * Iterates over elements of `collection`, returning an array of all elements 26392 * `predicate` returns truthy for. The predicate is invoked with three 26393 * arguments: (value, index|key, collection). 26394 * 26395 * **Note:** Unlike `_.remove`, this method returns a new array. 26396 * 26397 * @static 26398 * @memberOf _ 26399 * @since 0.1.0 26400 * @category Collection 26401 * @param {Array|Object} collection The collection to iterate over. 26402 * @param {Function} [predicate=_.identity] The function invoked per iteration. 26403 * @returns {Array} Returns the new filtered array. 26404 * @see _.reject 26405 * @example 26406 * 26407 * var users = [ 26408 * { 'user': 'barney', 'age': 36, 'active': true }, 26409 * { 'user': 'fred', 'age': 40, 'active': false } 26410 * ]; 26411 * 26412 * _.filter(users, function(o) { return !o.active; }); 26413 * // => objects for ['fred'] 26414 * 26415 * // The `_.matches` iteratee shorthand. 26416 * _.filter(users, { 'age': 36, 'active': true }); 26417 * // => objects for ['barney'] 26418 * 26419 * // The `_.matchesProperty` iteratee shorthand. 26420 * _.filter(users, ['active', false]); 26421 * // => objects for ['fred'] 26422 * 26423 * // The `_.property` iteratee shorthand. 26424 * _.filter(users, 'active'); 26425 * // => objects for ['barney'] 26426 * 26427 * // Combining several predicates using `_.overEvery` or `_.overSome`. 26428 * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); 26429 * // => objects for ['fred', 'barney'] 26430 */ 26431 function filter(collection, predicate) { 26432 var func = isArray(collection) ? arrayFilter : baseFilter; 26433 return func(collection, getIteratee(predicate, 3)); 26434 } 26435 26436 /** 26437 * Iterates over elements of `collection`, returning the first element 26438 * `predicate` returns truthy for. The predicate is invoked with three 26439 * arguments: (value, index|key, collection). 26440 * 26441 * @static 26442 * @memberOf _ 26443 * @since 0.1.0 26444 * @category Collection 26445 * @param {Array|Object} collection The collection to inspect. 26446 * @param {Function} [predicate=_.identity] The function invoked per iteration. 26447 * @param {number} [fromIndex=0] The index to search from. 26448 * @returns {*} Returns the matched element, else `undefined`. 26449 * @example 26450 * 26451 * var users = [ 26452 * { 'user': 'barney', 'age': 36, 'active': true }, 26453 * { 'user': 'fred', 'age': 40, 'active': false }, 26454 * { 'user': 'pebbles', 'age': 1, 'active': true } 26455 * ]; 26456 * 26457 * _.find(users, function(o) { return o.age < 40; }); 26458 * // => object for 'barney' 26459 * 26460 * // The `_.matches` iteratee shorthand. 26461 * _.find(users, { 'age': 1, 'active': true }); 26462 * // => object for 'pebbles' 26463 * 26464 * // The `_.matchesProperty` iteratee shorthand. 26465 * _.find(users, ['active', false]); 26466 * // => object for 'fred' 26467 * 26468 * // The `_.property` iteratee shorthand. 26469 * _.find(users, 'active'); 26470 * // => object for 'barney' 26471 */ 26472 var find = createFind(findIndex); 26473 26474 /** 26475 * This method is like `_.find` except that it iterates over elements of 26476 * `collection` from right to left. 26477 * 26478 * @static 26479 * @memberOf _ 26480 * @since 2.0.0 26481 * @category Collection 26482 * @param {Array|Object} collection The collection to inspect. 26483 * @param {Function} [predicate=_.identity] The function invoked per iteration. 26484 * @param {number} [fromIndex=collection.length-1] The index to search from. 26485 * @returns {*} Returns the matched element, else `undefined`. 26486 * @example 26487 * 26488 * _.findLast([1, 2, 3, 4], function(n) { 26489 * return n % 2 == 1; 26490 * }); 26491 * // => 3 26492 */ 26493 var findLast = createFind(findLastIndex); 26494 26495 /** 26496 * Creates a flattened array of values by running each element in `collection` 26497 * thru `iteratee` and flattening the mapped results. The iteratee is invoked 26498 * with three arguments: (value, index|key, collection). 26499 * 26500 * @static 26501 * @memberOf _ 26502 * @since 4.0.0 26503 * @category Collection 26504 * @param {Array|Object} collection The collection to iterate over. 26505 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 26506 * @returns {Array} Returns the new flattened array. 26507 * @example 26508 * 26509 * function duplicate(n) { 26510 * return [n, n]; 26511 * } 26512 * 26513 * _.flatMap([1, 2], duplicate); 26514 * // => [1, 1, 2, 2] 26515 */ 26516 function flatMap(collection, iteratee) { 26517 return baseFlatten(map(collection, iteratee), 1); 26518 } 26519 26520 /** 26521 * This method is like `_.flatMap` except that it recursively flattens the 26522 * mapped results. 26523 * 26524 * @static 26525 * @memberOf _ 26526 * @since 4.7.0 26527 * @category Collection 26528 * @param {Array|Object} collection The collection to iterate over. 26529 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 26530 * @returns {Array} Returns the new flattened array. 26531 * @example 26532 * 26533 * function duplicate(n) { 26534 * return [[[n, n]]]; 26535 * } 26536 * 26537 * _.flatMapDeep([1, 2], duplicate); 26538 * // => [1, 1, 2, 2] 26539 */ 26540 function flatMapDeep(collection, iteratee) { 26541 return baseFlatten(map(collection, iteratee), INFINITY); 26542 } 26543 26544 /** 26545 * This method is like `_.flatMap` except that it recursively flattens the 26546 * mapped results up to `depth` times. 26547 * 26548 * @static 26549 * @memberOf _ 26550 * @since 4.7.0 26551 * @category Collection 26552 * @param {Array|Object} collection The collection to iterate over. 26553 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 26554 * @param {number} [depth=1] The maximum recursion depth. 26555 * @returns {Array} Returns the new flattened array. 26556 * @example 26557 * 26558 * function duplicate(n) { 26559 * return [[[n, n]]]; 26560 * } 26561 * 26562 * _.flatMapDepth([1, 2], duplicate, 2); 26563 * // => [[1, 1], [2, 2]] 26564 */ 26565 function flatMapDepth(collection, iteratee, depth) { 26566 depth = depth === undefined ? 1 : toInteger(depth); 26567 return baseFlatten(map(collection, iteratee), depth); 26568 } 26569 26570 /** 26571 * Iterates over elements of `collection` and invokes `iteratee` for each element. 26572 * The iteratee is invoked with three arguments: (value, index|key, collection). 26573 * Iteratee functions may exit iteration early by explicitly returning `false`. 26574 * 26575 * **Note:** As with other "Collections" methods, objects with a "length" 26576 * property are iterated like arrays. To avoid this behavior use `_.forIn` 26577 * or `_.forOwn` for object iteration. 26578 * 26579 * @static 26580 * @memberOf _ 26581 * @since 0.1.0 26582 * @alias each 26583 * @category Collection 26584 * @param {Array|Object} collection The collection to iterate over. 26585 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 26586 * @returns {Array|Object} Returns `collection`. 26587 * @see _.forEachRight 26588 * @example 26589 * 26590 * _.forEach([1, 2], function(value) { 26591 * console.log(value); 26592 * }); 26593 * // => Logs `1` then `2`. 26594 * 26595 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 26596 * console.log(key); 26597 * }); 26598 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 26599 */ 26600 function forEach(collection, iteratee) { 26601 var func = isArray(collection) ? arrayEach : baseEach; 26602 return func(collection, getIteratee(iteratee, 3)); 26603 } 26604 26605 /** 26606 * This method is like `_.forEach` except that it iterates over elements of 26607 * `collection` from right to left. 26608 * 26609 * @static 26610 * @memberOf _ 26611 * @since 2.0.0 26612 * @alias eachRight 26613 * @category Collection 26614 * @param {Array|Object} collection The collection to iterate over. 26615 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 26616 * @returns {Array|Object} Returns `collection`. 26617 * @see _.forEach 26618 * @example 26619 * 26620 * _.forEachRight([1, 2], function(value) { 26621 * console.log(value); 26622 * }); 26623 * // => Logs `2` then `1`. 26624 */ 26625 function forEachRight(collection, iteratee) { 26626 var func = isArray(collection) ? arrayEachRight : baseEachRight; 26627 return func(collection, getIteratee(iteratee, 3)); 26628 } 26629 26630 /** 26631 * Creates an object composed of keys generated from the results of running 26632 * each element of `collection` thru `iteratee`. The order of grouped values 26633 * is determined by the order they occur in `collection`. The corresponding 26634 * value of each key is an array of elements responsible for generating the 26635 * key. The iteratee is invoked with one argument: (value). 26636 * 26637 * @static 26638 * @memberOf _ 26639 * @since 0.1.0 26640 * @category Collection 26641 * @param {Array|Object} collection The collection to iterate over. 26642 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 26643 * @returns {Object} Returns the composed aggregate object. 26644 * @example 26645 * 26646 * _.groupBy([6.1, 4.2, 6.3], Math.floor); 26647 * // => { '4': [4.2], '6': [6.1, 6.3] } 26648 * 26649 * // The `_.property` iteratee shorthand. 26650 * _.groupBy(['one', 'two', 'three'], 'length'); 26651 * // => { '3': ['one', 'two'], '5': ['three'] } 26652 */ 26653 var groupBy = createAggregator(function(result, value, key) { 26654 if (hasOwnProperty.call(result, key)) { 26655 result[key].push(value); 26656 } else { 26657 baseAssignValue(result, key, [value]); 26658 } 26659 }); 26660 26661 /** 26662 * Checks if `value` is in `collection`. If `collection` is a string, it's 26663 * checked for a substring of `value`, otherwise 26664 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 26665 * is used for equality comparisons. If `fromIndex` is negative, it's used as 26666 * the offset from the end of `collection`. 26667 * 26668 * @static 26669 * @memberOf _ 26670 * @since 0.1.0 26671 * @category Collection 26672 * @param {Array|Object|string} collection The collection to inspect. 26673 * @param {*} value The value to search for. 26674 * @param {number} [fromIndex=0] The index to search from. 26675 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 26676 * @returns {boolean} Returns `true` if `value` is found, else `false`. 26677 * @example 26678 * 26679 * _.includes([1, 2, 3], 1); 26680 * // => true 26681 * 26682 * _.includes([1, 2, 3], 1, 2); 26683 * // => false 26684 * 26685 * _.includes({ 'a': 1, 'b': 2 }, 1); 26686 * // => true 26687 * 26688 * _.includes('abcd', 'bc'); 26689 * // => true 26690 */ 26691 function includes(collection, value, fromIndex, guard) { 26692 collection = isArrayLike(collection) ? collection : values(collection); 26693 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; 26694 26695 var length = collection.length; 26696 if (fromIndex < 0) { 26697 fromIndex = nativeMax(length + fromIndex, 0); 26698 } 26699 return isString(collection) 26700 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) 26701 : (!!length && baseIndexOf(collection, value, fromIndex) > -1); 26702 } 26703 26704 /** 26705 * Invokes the method at `path` of each element in `collection`, returning 26706 * an array of the results of each invoked method. Any additional arguments 26707 * are provided to each invoked method. If `path` is a function, it's invoked 26708 * for, and `this` bound to, each element in `collection`. 26709 * 26710 * @static 26711 * @memberOf _ 26712 * @since 4.0.0 26713 * @category Collection 26714 * @param {Array|Object} collection The collection to iterate over. 26715 * @param {Array|Function|string} path The path of the method to invoke or 26716 * the function invoked per iteration. 26717 * @param {...*} [args] The arguments to invoke each method with. 26718 * @returns {Array} Returns the array of results. 26719 * @example 26720 * 26721 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); 26722 * // => [[1, 5, 7], [1, 2, 3]] 26723 * 26724 * _.invokeMap([123, 456], String.prototype.split, ''); 26725 * // => [['1', '2', '3'], ['4', '5', '6']] 26726 */ 26727 var invokeMap = baseRest(function(collection, path, args) { 26728 var index = -1, 26729 isFunc = typeof path == 'function', 26730 result = isArrayLike(collection) ? Array(collection.length) : []; 26731 26732 baseEach(collection, function(value) { 26733 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); 26734 }); 26735 return result; 26736 }); 26737 26738 /** 26739 * Creates an object composed of keys generated from the results of running 26740 * each element of `collection` thru `iteratee`. The corresponding value of 26741 * each key is the last element responsible for generating the key. The 26742 * iteratee is invoked with one argument: (value). 26743 * 26744 * @static 26745 * @memberOf _ 26746 * @since 4.0.0 26747 * @category Collection 26748 * @param {Array|Object} collection The collection to iterate over. 26749 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 26750 * @returns {Object} Returns the composed aggregate object. 26751 * @example 26752 * 26753 * var array = [ 26754 * { 'dir': 'left', 'code': 97 }, 26755 * { 'dir': 'right', 'code': 100 } 26756 * ]; 26757 * 26758 * _.keyBy(array, function(o) { 26759 * return String.fromCharCode(o.code); 26760 * }); 26761 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } 26762 * 26763 * _.keyBy(array, 'dir'); 26764 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } 26765 */ 26766 var keyBy = createAggregator(function(result, value, key) { 26767 baseAssignValue(result, key, value); 26768 }); 26769 26770 /** 26771 * Creates an array of values by running each element in `collection` thru 26772 * `iteratee`. The iteratee is invoked with three arguments: 26773 * (value, index|key, collection). 26774 * 26775 * Many lodash methods are guarded to work as iteratees for methods like 26776 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. 26777 * 26778 * The guarded methods are: 26779 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, 26780 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, 26781 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, 26782 * `template`, `trim`, `trimEnd`, `trimStart`, and `words` 26783 * 26784 * @static 26785 * @memberOf _ 26786 * @since 0.1.0 26787 * @category Collection 26788 * @param {Array|Object} collection The collection to iterate over. 26789 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 26790 * @returns {Array} Returns the new mapped array. 26791 * @example 26792 * 26793 * function square(n) { 26794 * return n * n; 26795 * } 26796 * 26797 * _.map([4, 8], square); 26798 * // => [16, 64] 26799 * 26800 * _.map({ 'a': 4, 'b': 8 }, square); 26801 * // => [16, 64] (iteration order is not guaranteed) 26802 * 26803 * var users = [ 26804 * { 'user': 'barney' }, 26805 * { 'user': 'fred' } 26806 * ]; 26807 * 26808 * // The `_.property` iteratee shorthand. 26809 * _.map(users, 'user'); 26810 * // => ['barney', 'fred'] 26811 */ 26812 function map(collection, iteratee) { 26813 var func = isArray(collection) ? arrayMap : baseMap; 26814 return func(collection, getIteratee(iteratee, 3)); 26815 } 26816 26817 /** 26818 * This method is like `_.sortBy` except that it allows specifying the sort 26819 * orders of the iteratees to sort by. If `orders` is unspecified, all values 26820 * are sorted in ascending order. Otherwise, specify an order of "desc" for 26821 * descending or "asc" for ascending sort order of corresponding values. 26822 * 26823 * @static 26824 * @memberOf _ 26825 * @since 4.0.0 26826 * @category Collection 26827 * @param {Array|Object} collection The collection to iterate over. 26828 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] 26829 * The iteratees to sort by. 26830 * @param {string[]} [orders] The sort orders of `iteratees`. 26831 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 26832 * @returns {Array} Returns the new sorted array. 26833 * @example 26834 * 26835 * var users = [ 26836 * { 'user': 'fred', 'age': 48 }, 26837 * { 'user': 'barney', 'age': 34 }, 26838 * { 'user': 'fred', 'age': 40 }, 26839 * { 'user': 'barney', 'age': 36 } 26840 * ]; 26841 * 26842 * // Sort by `user` in ascending order and by `age` in descending order. 26843 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); 26844 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 26845 */ 26846 function orderBy(collection, iteratees, orders, guard) { 26847 if (collection == null) { 26848 return []; 26849 } 26850 if (!isArray(iteratees)) { 26851 iteratees = iteratees == null ? [] : [iteratees]; 26852 } 26853 orders = guard ? undefined : orders; 26854 if (!isArray(orders)) { 26855 orders = orders == null ? [] : [orders]; 26856 } 26857 return baseOrderBy(collection, iteratees, orders); 26858 } 26859 26860 /** 26861 * Creates an array of elements split into two groups, the first of which 26862 * contains elements `predicate` returns truthy for, the second of which 26863 * contains elements `predicate` returns falsey for. The predicate is 26864 * invoked with one argument: (value). 26865 * 26866 * @static 26867 * @memberOf _ 26868 * @since 3.0.0 26869 * @category Collection 26870 * @param {Array|Object} collection The collection to iterate over. 26871 * @param {Function} [predicate=_.identity] The function invoked per iteration. 26872 * @returns {Array} Returns the array of grouped elements. 26873 * @example 26874 * 26875 * var users = [ 26876 * { 'user': 'barney', 'age': 36, 'active': false }, 26877 * { 'user': 'fred', 'age': 40, 'active': true }, 26878 * { 'user': 'pebbles', 'age': 1, 'active': false } 26879 * ]; 26880 * 26881 * _.partition(users, function(o) { return o.active; }); 26882 * // => objects for [['fred'], ['barney', 'pebbles']] 26883 * 26884 * // The `_.matches` iteratee shorthand. 26885 * _.partition(users, { 'age': 1, 'active': false }); 26886 * // => objects for [['pebbles'], ['barney', 'fred']] 26887 * 26888 * // The `_.matchesProperty` iteratee shorthand. 26889 * _.partition(users, ['active', false]); 26890 * // => objects for [['barney', 'pebbles'], ['fred']] 26891 * 26892 * // The `_.property` iteratee shorthand. 26893 * _.partition(users, 'active'); 26894 * // => objects for [['fred'], ['barney', 'pebbles']] 26895 */ 26896 var partition = createAggregator(function(result, value, key) { 26897 result[key ? 0 : 1].push(value); 26898 }, function() { return [[], []]; }); 26899 26900 /** 26901 * Reduces `collection` to a value which is the accumulated result of running 26902 * each element in `collection` thru `iteratee`, where each successive 26903 * invocation is supplied the return value of the previous. If `accumulator` 26904 * is not given, the first element of `collection` is used as the initial 26905 * value. The iteratee is invoked with four arguments: 26906 * (accumulator, value, index|key, collection). 26907 * 26908 * Many lodash methods are guarded to work as iteratees for methods like 26909 * `_.reduce`, `_.reduceRight`, and `_.transform`. 26910 * 26911 * The guarded methods are: 26912 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, 26913 * and `sortBy` 26914 * 26915 * @static 26916 * @memberOf _ 26917 * @since 0.1.0 26918 * @category Collection 26919 * @param {Array|Object} collection The collection to iterate over. 26920 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 26921 * @param {*} [accumulator] The initial value. 26922 * @returns {*} Returns the accumulated value. 26923 * @see _.reduceRight 26924 * @example 26925 * 26926 * _.reduce([1, 2], function(sum, n) { 26927 * return sum + n; 26928 * }, 0); 26929 * // => 3 26930 * 26931 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 26932 * (result[value] || (result[value] = [])).push(key); 26933 * return result; 26934 * }, {}); 26935 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) 26936 */ 26937 function reduce(collection, iteratee, accumulator) { 26938 var func = isArray(collection) ? arrayReduce : baseReduce, 26939 initAccum = arguments.length < 3; 26940 26941 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); 26942 } 26943 26944 /** 26945 * This method is like `_.reduce` except that it iterates over elements of 26946 * `collection` from right to left. 26947 * 26948 * @static 26949 * @memberOf _ 26950 * @since 0.1.0 26951 * @category Collection 26952 * @param {Array|Object} collection The collection to iterate over. 26953 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 26954 * @param {*} [accumulator] The initial value. 26955 * @returns {*} Returns the accumulated value. 26956 * @see _.reduce 26957 * @example 26958 * 26959 * var array = [[0, 1], [2, 3], [4, 5]]; 26960 * 26961 * _.reduceRight(array, function(flattened, other) { 26962 * return flattened.concat(other); 26963 * }, []); 26964 * // => [4, 5, 2, 3, 0, 1] 26965 */ 26966 function reduceRight(collection, iteratee, accumulator) { 26967 var func = isArray(collection) ? arrayReduceRight : baseReduce, 26968 initAccum = arguments.length < 3; 26969 26970 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); 26971 } 26972 26973 /** 26974 * The opposite of `_.filter`; this method returns the elements of `collection` 26975 * that `predicate` does **not** return truthy for. 26976 * 26977 * @static 26978 * @memberOf _ 26979 * @since 0.1.0 26980 * @category Collection 26981 * @param {Array|Object} collection The collection to iterate over. 26982 * @param {Function} [predicate=_.identity] The function invoked per iteration. 26983 * @returns {Array} Returns the new filtered array. 26984 * @see _.filter 26985 * @example 26986 * 26987 * var users = [ 26988 * { 'user': 'barney', 'age': 36, 'active': false }, 26989 * { 'user': 'fred', 'age': 40, 'active': true } 26990 * ]; 26991 * 26992 * _.reject(users, function(o) { return !o.active; }); 26993 * // => objects for ['fred'] 26994 * 26995 * // The `_.matches` iteratee shorthand. 26996 * _.reject(users, { 'age': 40, 'active': true }); 26997 * // => objects for ['barney'] 26998 * 26999 * // The `_.matchesProperty` iteratee shorthand. 27000 * _.reject(users, ['active', false]); 27001 * // => objects for ['fred'] 27002 * 27003 * // The `_.property` iteratee shorthand. 27004 * _.reject(users, 'active'); 27005 * // => objects for ['barney'] 27006 */ 27007 function reject(collection, predicate) { 27008 var func = isArray(collection) ? arrayFilter : baseFilter; 27009 return func(collection, negate(getIteratee(predicate, 3))); 27010 } 27011 27012 /** 27013 * Gets a random element from `collection`. 27014 * 27015 * @static 27016 * @memberOf _ 27017 * @since 2.0.0 27018 * @category Collection 27019 * @param {Array|Object} collection The collection to sample. 27020 * @returns {*} Returns the random element. 27021 * @example 27022 * 27023 * _.sample([1, 2, 3, 4]); 27024 * // => 2 27025 */ 27026 function sample(collection) { 27027 var func = isArray(collection) ? arraySample : baseSample; 27028 return func(collection); 27029 } 27030 27031 /** 27032 * Gets `n` random elements at unique keys from `collection` up to the 27033 * size of `collection`. 27034 * 27035 * @static 27036 * @memberOf _ 27037 * @since 4.0.0 27038 * @category Collection 27039 * @param {Array|Object} collection The collection to sample. 27040 * @param {number} [n=1] The number of elements to sample. 27041 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 27042 * @returns {Array} Returns the random elements. 27043 * @example 27044 * 27045 * _.sampleSize([1, 2, 3], 2); 27046 * // => [3, 1] 27047 * 27048 * _.sampleSize([1, 2, 3], 4); 27049 * // => [2, 3, 1] 27050 */ 27051 function sampleSize(collection, n, guard) { 27052 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { 27053 n = 1; 27054 } else { 27055 n = toInteger(n); 27056 } 27057 var func = isArray(collection) ? arraySampleSize : baseSampleSize; 27058 return func(collection, n); 27059 } 27060 27061 /** 27062 * Creates an array of shuffled values, using a version of the 27063 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). 27064 * 27065 * @static 27066 * @memberOf _ 27067 * @since 0.1.0 27068 * @category Collection 27069 * @param {Array|Object} collection The collection to shuffle. 27070 * @returns {Array} Returns the new shuffled array. 27071 * @example 27072 * 27073 * _.shuffle([1, 2, 3, 4]); 27074 * // => [4, 1, 3, 2] 27075 */ 27076 function shuffle(collection) { 27077 var func = isArray(collection) ? arrayShuffle : baseShuffle; 27078 return func(collection); 27079 } 27080 27081 /** 27082 * Gets the size of `collection` by returning its length for array-like 27083 * values or the number of own enumerable string keyed properties for objects. 27084 * 27085 * @static 27086 * @memberOf _ 27087 * @since 0.1.0 27088 * @category Collection 27089 * @param {Array|Object|string} collection The collection to inspect. 27090 * @returns {number} Returns the collection size. 27091 * @example 27092 * 27093 * _.size([1, 2, 3]); 27094 * // => 3 27095 * 27096 * _.size({ 'a': 1, 'b': 2 }); 27097 * // => 2 27098 * 27099 * _.size('pebbles'); 27100 * // => 7 27101 */ 27102 function size(collection) { 27103 if (collection == null) { 27104 return 0; 27105 } 27106 if (isArrayLike(collection)) { 27107 return isString(collection) ? stringSize(collection) : collection.length; 27108 } 27109 var tag = getTag(collection); 27110 if (tag == mapTag || tag == setTag) { 27111 return collection.size; 27112 } 27113 return baseKeys(collection).length; 27114 } 27115 27116 /** 27117 * Checks if `predicate` returns truthy for **any** element of `collection`. 27118 * Iteration is stopped once `predicate` returns truthy. The predicate is 27119 * invoked with three arguments: (value, index|key, collection). 27120 * 27121 * @static 27122 * @memberOf _ 27123 * @since 0.1.0 27124 * @category Collection 27125 * @param {Array|Object} collection The collection to iterate over. 27126 * @param {Function} [predicate=_.identity] The function invoked per iteration. 27127 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 27128 * @returns {boolean} Returns `true` if any element passes the predicate check, 27129 * else `false`. 27130 * @example 27131 * 27132 * _.some([null, 0, 'yes', false], Boolean); 27133 * // => true 27134 * 27135 * var users = [ 27136 * { 'user': 'barney', 'active': true }, 27137 * { 'user': 'fred', 'active': false } 27138 * ]; 27139 * 27140 * // The `_.matches` iteratee shorthand. 27141 * _.some(users, { 'user': 'barney', 'active': false }); 27142 * // => false 27143 * 27144 * // The `_.matchesProperty` iteratee shorthand. 27145 * _.some(users, ['active', false]); 27146 * // => true 27147 * 27148 * // The `_.property` iteratee shorthand. 27149 * _.some(users, 'active'); 27150 * // => true 27151 */ 27152 function some(collection, predicate, guard) { 27153 var func = isArray(collection) ? arraySome : baseSome; 27154 if (guard && isIterateeCall(collection, predicate, guard)) { 27155 predicate = undefined; 27156 } 27157 return func(collection, getIteratee(predicate, 3)); 27158 } 27159 27160 /** 27161 * Creates an array of elements, sorted in ascending order by the results of 27162 * running each element in a collection thru each iteratee. This method 27163 * performs a stable sort, that is, it preserves the original sort order of 27164 * equal elements. The iteratees are invoked with one argument: (value). 27165 * 27166 * @static 27167 * @memberOf _ 27168 * @since 0.1.0 27169 * @category Collection 27170 * @param {Array|Object} collection The collection to iterate over. 27171 * @param {...(Function|Function[])} [iteratees=[_.identity]] 27172 * The iteratees to sort by. 27173 * @returns {Array} Returns the new sorted array. 27174 * @example 27175 * 27176 * var users = [ 27177 * { 'user': 'fred', 'age': 48 }, 27178 * { 'user': 'barney', 'age': 36 }, 27179 * { 'user': 'fred', 'age': 30 }, 27180 * { 'user': 'barney', 'age': 34 } 27181 * ]; 27182 * 27183 * _.sortBy(users, [function(o) { return o.user; }]); 27184 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] 27185 * 27186 * _.sortBy(users, ['user', 'age']); 27187 * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] 27188 */ 27189 var sortBy = baseRest(function(collection, iteratees) { 27190 if (collection == null) { 27191 return []; 27192 } 27193 var length = iteratees.length; 27194 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { 27195 iteratees = []; 27196 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { 27197 iteratees = [iteratees[0]]; 27198 } 27199 return baseOrderBy(collection, baseFlatten(iteratees, 1), []); 27200 }); 27201 27202 /*------------------------------------------------------------------------*/ 27203 27204 /** 27205 * Gets the timestamp of the number of milliseconds that have elapsed since 27206 * the Unix epoch (1 January 1970 00:00:00 UTC). 27207 * 27208 * @static 27209 * @memberOf _ 27210 * @since 2.4.0 27211 * @category Date 27212 * @returns {number} Returns the timestamp. 27213 * @example 27214 * 27215 * _.defer(function(stamp) { 27216 * console.log(_.now() - stamp); 27217 * }, _.now()); 27218 * // => Logs the number of milliseconds it took for the deferred invocation. 27219 */ 27220 var now = ctxNow || function() { 27221 return root.Date.now(); 27222 }; 27223 27224 /*------------------------------------------------------------------------*/ 27225 27226 /** 27227 * The opposite of `_.before`; this method creates a function that invokes 27228 * `func` once it's called `n` or more times. 27229 * 27230 * @static 27231 * @memberOf _ 27232 * @since 0.1.0 27233 * @category Function 27234 * @param {number} n The number of calls before `func` is invoked. 27235 * @param {Function} func The function to restrict. 27236 * @returns {Function} Returns the new restricted function. 27237 * @example 27238 * 27239 * var saves = ['profile', 'settings']; 27240 * 27241 * var done = _.after(saves.length, function() { 27242 * console.log('done saving!'); 27243 * }); 27244 * 27245 * _.forEach(saves, function(type) { 27246 * asyncSave({ 'type': type, 'complete': done }); 27247 * }); 27248 * // => Logs 'done saving!' after the two async saves have completed. 27249 */ 27250 function after(n, func) { 27251 if (typeof func != 'function') { 27252 throw new TypeError(FUNC_ERROR_TEXT); 27253 } 27254 n = toInteger(n); 27255 return function() { 27256 if (--n < 1) { 27257 return func.apply(this, arguments); 27258 } 27259 }; 27260 } 27261 27262 /** 27263 * Creates a function that invokes `func`, with up to `n` arguments, 27264 * ignoring any additional arguments. 27265 * 27266 * @static 27267 * @memberOf _ 27268 * @since 3.0.0 27269 * @category Function 27270 * @param {Function} func The function to cap arguments for. 27271 * @param {number} [n=func.length] The arity cap. 27272 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 27273 * @returns {Function} Returns the new capped function. 27274 * @example 27275 * 27276 * _.map(['6', '8', '10'], _.ary(parseInt, 1)); 27277 * // => [6, 8, 10] 27278 */ 27279 function ary(func, n, guard) { 27280 n = guard ? undefined : n; 27281 n = (func && n == null) ? func.length : n; 27282 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); 27283 } 27284 27285 /** 27286 * Creates a function that invokes `func`, with the `this` binding and arguments 27287 * of the created function, while it's called less than `n` times. Subsequent 27288 * calls to the created function return the result of the last `func` invocation. 27289 * 27290 * @static 27291 * @memberOf _ 27292 * @since 3.0.0 27293 * @category Function 27294 * @param {number} n The number of calls at which `func` is no longer invoked. 27295 * @param {Function} func The function to restrict. 27296 * @returns {Function} Returns the new restricted function. 27297 * @example 27298 * 27299 * jQuery(element).on('click', _.before(5, addContactToList)); 27300 * // => Allows adding up to 4 contacts to the list. 27301 */ 27302 function before(n, func) { 27303 var result; 27304 if (typeof func != 'function') { 27305 throw new TypeError(FUNC_ERROR_TEXT); 27306 } 27307 n = toInteger(n); 27308 return function() { 27309 if (--n > 0) { 27310 result = func.apply(this, arguments); 27311 } 27312 if (n <= 1) { 27313 func = undefined; 27314 } 27315 return result; 27316 }; 27317 } 27318 27319 /** 27320 * Creates a function that invokes `func` with the `this` binding of `thisArg` 27321 * and `partials` prepended to the arguments it receives. 27322 * 27323 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, 27324 * may be used as a placeholder for partially applied arguments. 27325 * 27326 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" 27327 * property of bound functions. 27328 * 27329 * @static 27330 * @memberOf _ 27331 * @since 0.1.0 27332 * @category Function 27333 * @param {Function} func The function to bind. 27334 * @param {*} thisArg The `this` binding of `func`. 27335 * @param {...*} [partials] The arguments to be partially applied. 27336 * @returns {Function} Returns the new bound function. 27337 * @example 27338 * 27339 * function greet(greeting, punctuation) { 27340 * return greeting + ' ' + this.user + punctuation; 27341 * } 27342 * 27343 * var object = { 'user': 'fred' }; 27344 * 27345 * var bound = _.bind(greet, object, 'hi'); 27346 * bound('!'); 27347 * // => 'hi fred!' 27348 * 27349 * // Bound with placeholders. 27350 * var bound = _.bind(greet, object, _, '!'); 27351 * bound('hi'); 27352 * // => 'hi fred!' 27353 */ 27354 var bind = baseRest(function(func, thisArg, partials) { 27355 var bitmask = WRAP_BIND_FLAG; 27356 if (partials.length) { 27357 var holders = replaceHolders(partials, getHolder(bind)); 27358 bitmask |= WRAP_PARTIAL_FLAG; 27359 } 27360 return createWrap(func, bitmask, thisArg, partials, holders); 27361 }); 27362 27363 /** 27364 * Creates a function that invokes the method at `object[key]` with `partials` 27365 * prepended to the arguments it receives. 27366 * 27367 * This method differs from `_.bind` by allowing bound functions to reference 27368 * methods that may be redefined or don't yet exist. See 27369 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) 27370 * for more details. 27371 * 27372 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic 27373 * builds, may be used as a placeholder for partially applied arguments. 27374 * 27375 * @static 27376 * @memberOf _ 27377 * @since 0.10.0 27378 * @category Function 27379 * @param {Object} object The object to invoke the method on. 27380 * @param {string} key The key of the method. 27381 * @param {...*} [partials] The arguments to be partially applied. 27382 * @returns {Function} Returns the new bound function. 27383 * @example 27384 * 27385 * var object = { 27386 * 'user': 'fred', 27387 * 'greet': function(greeting, punctuation) { 27388 * return greeting + ' ' + this.user + punctuation; 27389 * } 27390 * }; 27391 * 27392 * var bound = _.bindKey(object, 'greet', 'hi'); 27393 * bound('!'); 27394 * // => 'hi fred!' 27395 * 27396 * object.greet = function(greeting, punctuation) { 27397 * return greeting + 'ya ' + this.user + punctuation; 27398 * }; 27399 * 27400 * bound('!'); 27401 * // => 'hiya fred!' 27402 * 27403 * // Bound with placeholders. 27404 * var bound = _.bindKey(object, 'greet', _, '!'); 27405 * bound('hi'); 27406 * // => 'hiya fred!' 27407 */ 27408 var bindKey = baseRest(function(object, key, partials) { 27409 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; 27410 if (partials.length) { 27411 var holders = replaceHolders(partials, getHolder(bindKey)); 27412 bitmask |= WRAP_PARTIAL_FLAG; 27413 } 27414 return createWrap(key, bitmask, object, partials, holders); 27415 }); 27416 27417 /** 27418 * Creates a function that accepts arguments of `func` and either invokes 27419 * `func` returning its result, if at least `arity` number of arguments have 27420 * been provided, or returns a function that accepts the remaining `func` 27421 * arguments, and so on. The arity of `func` may be specified if `func.length` 27422 * is not sufficient. 27423 * 27424 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, 27425 * may be used as a placeholder for provided arguments. 27426 * 27427 * **Note:** This method doesn't set the "length" property of curried functions. 27428 * 27429 * @static 27430 * @memberOf _ 27431 * @since 2.0.0 27432 * @category Function 27433 * @param {Function} func The function to curry. 27434 * @param {number} [arity=func.length] The arity of `func`. 27435 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 27436 * @returns {Function} Returns the new curried function. 27437 * @example 27438 * 27439 * var abc = function(a, b, c) { 27440 * return [a, b, c]; 27441 * }; 27442 * 27443 * var curried = _.curry(abc); 27444 * 27445 * curried(1)(2)(3); 27446 * // => [1, 2, 3] 27447 * 27448 * curried(1, 2)(3); 27449 * // => [1, 2, 3] 27450 * 27451 * curried(1, 2, 3); 27452 * // => [1, 2, 3] 27453 * 27454 * // Curried with placeholders. 27455 * curried(1)(_, 3)(2); 27456 * // => [1, 2, 3] 27457 */ 27458 function curry(func, arity, guard) { 27459 arity = guard ? undefined : arity; 27460 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 27461 result.placeholder = curry.placeholder; 27462 return result; 27463 } 27464 27465 /** 27466 * This method is like `_.curry` except that arguments are applied to `func` 27467 * in the manner of `_.partialRight` instead of `_.partial`. 27468 * 27469 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic 27470 * builds, may be used as a placeholder for provided arguments. 27471 * 27472 * **Note:** This method doesn't set the "length" property of curried functions. 27473 * 27474 * @static 27475 * @memberOf _ 27476 * @since 3.0.0 27477 * @category Function 27478 * @param {Function} func The function to curry. 27479 * @param {number} [arity=func.length] The arity of `func`. 27480 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 27481 * @returns {Function} Returns the new curried function. 27482 * @example 27483 * 27484 * var abc = function(a, b, c) { 27485 * return [a, b, c]; 27486 * }; 27487 * 27488 * var curried = _.curryRight(abc); 27489 * 27490 * curried(3)(2)(1); 27491 * // => [1, 2, 3] 27492 * 27493 * curried(2, 3)(1); 27494 * // => [1, 2, 3] 27495 * 27496 * curried(1, 2, 3); 27497 * // => [1, 2, 3] 27498 * 27499 * // Curried with placeholders. 27500 * curried(3)(1, _)(2); 27501 * // => [1, 2, 3] 27502 */ 27503 function curryRight(func, arity, guard) { 27504 arity = guard ? undefined : arity; 27505 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 27506 result.placeholder = curryRight.placeholder; 27507 return result; 27508 } 27509 27510 /** 27511 * Creates a debounced function that delays invoking `func` until after `wait` 27512 * milliseconds have elapsed since the last time the debounced function was 27513 * invoked. The debounced function comes with a `cancel` method to cancel 27514 * delayed `func` invocations and a `flush` method to immediately invoke them. 27515 * Provide `options` to indicate whether `func` should be invoked on the 27516 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 27517 * with the last arguments provided to the debounced function. Subsequent 27518 * calls to the debounced function return the result of the last `func` 27519 * invocation. 27520 * 27521 * **Note:** If `leading` and `trailing` options are `true`, `func` is 27522 * invoked on the trailing edge of the timeout only if the debounced function 27523 * is invoked more than once during the `wait` timeout. 27524 * 27525 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 27526 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 27527 * 27528 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 27529 * for details over the differences between `_.debounce` and `_.throttle`. 27530 * 27531 * @static 27532 * @memberOf _ 27533 * @since 0.1.0 27534 * @category Function 27535 * @param {Function} func The function to debounce. 27536 * @param {number} [wait=0] The number of milliseconds to delay. 27537 * @param {Object} [options={}] The options object. 27538 * @param {boolean} [options.leading=false] 27539 * Specify invoking on the leading edge of the timeout. 27540 * @param {number} [options.maxWait] 27541 * The maximum time `func` is allowed to be delayed before it's invoked. 27542 * @param {boolean} [options.trailing=true] 27543 * Specify invoking on the trailing edge of the timeout. 27544 * @returns {Function} Returns the new debounced function. 27545 * @example 27546 * 27547 * // Avoid costly calculations while the window size is in flux. 27548 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 27549 * 27550 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 27551 * jQuery(element).on('click', _.debounce(sendMail, 300, { 27552 * 'leading': true, 27553 * 'trailing': false 27554 * })); 27555 * 27556 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 27557 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 27558 * var source = new EventSource('/stream'); 27559 * jQuery(source).on('message', debounced); 27560 * 27561 * // Cancel the trailing debounced invocation. 27562 * jQuery(window).on('popstate', debounced.cancel); 27563 */ 27564 function debounce(func, wait, options) { 27565 var lastArgs, 27566 lastThis, 27567 maxWait, 27568 result, 27569 timerId, 27570 lastCallTime, 27571 lastInvokeTime = 0, 27572 leading = false, 27573 maxing = false, 27574 trailing = true; 27575 27576 if (typeof func != 'function') { 27577 throw new TypeError(FUNC_ERROR_TEXT); 27578 } 27579 wait = toNumber(wait) || 0; 27580 if (isObject(options)) { 27581 leading = !!options.leading; 27582 maxing = 'maxWait' in options; 27583 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 27584 trailing = 'trailing' in options ? !!options.trailing : trailing; 27585 } 27586 27587 function invokeFunc(time) { 27588 var args = lastArgs, 27589 thisArg = lastThis; 27590 27591 lastArgs = lastThis = undefined; 27592 lastInvokeTime = time; 27593 result = func.apply(thisArg, args); 27594 return result; 27595 } 27596 27597 function leadingEdge(time) { 27598 // Reset any `maxWait` timer. 27599 lastInvokeTime = time; 27600 // Start the timer for the trailing edge. 27601 timerId = setTimeout(timerExpired, wait); 27602 // Invoke the leading edge. 27603 return leading ? invokeFunc(time) : result; 27604 } 27605 27606 function remainingWait(time) { 27607 var timeSinceLastCall = time - lastCallTime, 27608 timeSinceLastInvoke = time - lastInvokeTime, 27609 timeWaiting = wait - timeSinceLastCall; 27610 27611 return maxing 27612 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 27613 : timeWaiting; 27614 } 27615 27616 function shouldInvoke(time) { 27617 var timeSinceLastCall = time - lastCallTime, 27618 timeSinceLastInvoke = time - lastInvokeTime; 27619 27620 // Either this is the first call, activity has stopped and we're at the 27621 // trailing edge, the system time has gone backwards and we're treating 27622 // it as the trailing edge, or we've hit the `maxWait` limit. 27623 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 27624 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 27625 } 27626 27627 function timerExpired() { 27628 var time = now(); 27629 if (shouldInvoke(time)) { 27630 return trailingEdge(time); 27631 } 27632 // Restart the timer. 27633 timerId = setTimeout(timerExpired, remainingWait(time)); 27634 } 27635 27636 function trailingEdge(time) { 27637 timerId = undefined; 27638 27639 // Only invoke if we have `lastArgs` which means `func` has been 27640 // debounced at least once. 27641 if (trailing && lastArgs) { 27642 return invokeFunc(time); 27643 } 27644 lastArgs = lastThis = undefined; 27645 return result; 27646 } 27647 27648 function cancel() { 27649 if (timerId !== undefined) { 27650 clearTimeout(timerId); 27651 } 27652 lastInvokeTime = 0; 27653 lastArgs = lastCallTime = lastThis = timerId = undefined; 27654 } 27655 27656 function flush() { 27657 return timerId === undefined ? result : trailingEdge(now()); 27658 } 27659 27660 function debounced() { 27661 var time = now(), 27662 isInvoking = shouldInvoke(time); 27663 27664 lastArgs = arguments; 27665 lastThis = this; 27666 lastCallTime = time; 27667 27668 if (isInvoking) { 27669 if (timerId === undefined) { 27670 return leadingEdge(lastCallTime); 27671 } 27672 if (maxing) { 27673 // Handle invocations in a tight loop. 27674 clearTimeout(timerId); 27675 timerId = setTimeout(timerExpired, wait); 27676 return invokeFunc(lastCallTime); 27677 } 27678 } 27679 if (timerId === undefined) { 27680 timerId = setTimeout(timerExpired, wait); 27681 } 27682 return result; 27683 } 27684 debounced.cancel = cancel; 27685 debounced.flush = flush; 27686 return debounced; 27687 } 27688 27689 /** 27690 * Defers invoking the `func` until the current call stack has cleared. Any 27691 * additional arguments are provided to `func` when it's invoked. 27692 * 27693 * @static 27694 * @memberOf _ 27695 * @since 0.1.0 27696 * @category Function 27697 * @param {Function} func The function to defer. 27698 * @param {...*} [args] The arguments to invoke `func` with. 27699 * @returns {number} Returns the timer id. 27700 * @example 27701 * 27702 * _.defer(function(text) { 27703 * console.log(text); 27704 * }, 'deferred'); 27705 * // => Logs 'deferred' after one millisecond. 27706 */ 27707 var defer = baseRest(function(func, args) { 27708 return baseDelay(func, 1, args); 27709 }); 27710 27711 /** 27712 * Invokes `func` after `wait` milliseconds. Any additional arguments are 27713 * provided to `func` when it's invoked. 27714 * 27715 * @static 27716 * @memberOf _ 27717 * @since 0.1.0 27718 * @category Function 27719 * @param {Function} func The function to delay. 27720 * @param {number} wait The number of milliseconds to delay invocation. 27721 * @param {...*} [args] The arguments to invoke `func` with. 27722 * @returns {number} Returns the timer id. 27723 * @example 27724 * 27725 * _.delay(function(text) { 27726 * console.log(text); 27727 * }, 1000, 'later'); 27728 * // => Logs 'later' after one second. 27729 */ 27730 var delay = baseRest(function(func, wait, args) { 27731 return baseDelay(func, toNumber(wait) || 0, args); 27732 }); 27733 27734 /** 27735 * Creates a function that invokes `func` with arguments reversed. 27736 * 27737 * @static 27738 * @memberOf _ 27739 * @since 4.0.0 27740 * @category Function 27741 * @param {Function} func The function to flip arguments for. 27742 * @returns {Function} Returns the new flipped function. 27743 * @example 27744 * 27745 * var flipped = _.flip(function() { 27746 * return _.toArray(arguments); 27747 * }); 27748 * 27749 * flipped('a', 'b', 'c', 'd'); 27750 * // => ['d', 'c', 'b', 'a'] 27751 */ 27752 function flip(func) { 27753 return createWrap(func, WRAP_FLIP_FLAG); 27754 } 27755 27756 /** 27757 * Creates a function that memoizes the result of `func`. If `resolver` is 27758 * provided, it determines the cache key for storing the result based on the 27759 * arguments provided to the memoized function. By default, the first argument 27760 * provided to the memoized function is used as the map cache key. The `func` 27761 * is invoked with the `this` binding of the memoized function. 27762 * 27763 * **Note:** The cache is exposed as the `cache` property on the memoized 27764 * function. Its creation may be customized by replacing the `_.memoize.Cache` 27765 * constructor with one whose instances implement the 27766 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) 27767 * method interface of `clear`, `delete`, `get`, `has`, and `set`. 27768 * 27769 * @static 27770 * @memberOf _ 27771 * @since 0.1.0 27772 * @category Function 27773 * @param {Function} func The function to have its output memoized. 27774 * @param {Function} [resolver] The function to resolve the cache key. 27775 * @returns {Function} Returns the new memoized function. 27776 * @example 27777 * 27778 * var object = { 'a': 1, 'b': 2 }; 27779 * var other = { 'c': 3, 'd': 4 }; 27780 * 27781 * var values = _.memoize(_.values); 27782 * values(object); 27783 * // => [1, 2] 27784 * 27785 * values(other); 27786 * // => [3, 4] 27787 * 27788 * object.a = 2; 27789 * values(object); 27790 * // => [1, 2] 27791 * 27792 * // Modify the result cache. 27793 * values.cache.set(object, ['a', 'b']); 27794 * values(object); 27795 * // => ['a', 'b'] 27796 * 27797 * // Replace `_.memoize.Cache`. 27798 * _.memoize.Cache = WeakMap; 27799 */ 27800 function memoize(func, resolver) { 27801 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 27802 throw new TypeError(FUNC_ERROR_TEXT); 27803 } 27804 var memoized = function() { 27805 var args = arguments, 27806 key = resolver ? resolver.apply(this, args) : args[0], 27807 cache = memoized.cache; 27808 27809 if (cache.has(key)) { 27810 return cache.get(key); 27811 } 27812 var result = func.apply(this, args); 27813 memoized.cache = cache.set(key, result) || cache; 27814 return result; 27815 }; 27816 memoized.cache = new (memoize.Cache || MapCache); 27817 return memoized; 27818 } 27819 27820 // Expose `MapCache`. 27821 memoize.Cache = MapCache; 27822 27823 /** 27824 * Creates a function that negates the result of the predicate `func`. The 27825 * `func` predicate is invoked with the `this` binding and arguments of the 27826 * created function. 27827 * 27828 * @static 27829 * @memberOf _ 27830 * @since 3.0.0 27831 * @category Function 27832 * @param {Function} predicate The predicate to negate. 27833 * @returns {Function} Returns the new negated function. 27834 * @example 27835 * 27836 * function isEven(n) { 27837 * return n % 2 == 0; 27838 * } 27839 * 27840 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); 27841 * // => [1, 3, 5] 27842 */ 27843 function negate(predicate) { 27844 if (typeof predicate != 'function') { 27845 throw new TypeError(FUNC_ERROR_TEXT); 27846 } 27847 return function() { 27848 var args = arguments; 27849 switch (args.length) { 27850 case 0: return !predicate.call(this); 27851 case 1: return !predicate.call(this, args[0]); 27852 case 2: return !predicate.call(this, args[0], args[1]); 27853 case 3: return !predicate.call(this, args[0], args[1], args[2]); 27854 } 27855 return !predicate.apply(this, args); 27856 }; 27857 } 27858 27859 /** 27860 * Creates a function that is restricted to invoking `func` once. Repeat calls 27861 * to the function return the value of the first invocation. The `func` is 27862 * invoked with the `this` binding and arguments of the created function. 27863 * 27864 * @static 27865 * @memberOf _ 27866 * @since 0.1.0 27867 * @category Function 27868 * @param {Function} func The function to restrict. 27869 * @returns {Function} Returns the new restricted function. 27870 * @example 27871 * 27872 * var initialize = _.once(createApplication); 27873 * initialize(); 27874 * initialize(); 27875 * // => `createApplication` is invoked once 27876 */ 27877 function once(func) { 27878 return before(2, func); 27879 } 27880 27881 /** 27882 * Creates a function that invokes `func` with its arguments transformed. 27883 * 27884 * @static 27885 * @since 4.0.0 27886 * @memberOf _ 27887 * @category Function 27888 * @param {Function} func The function to wrap. 27889 * @param {...(Function|Function[])} [transforms=[_.identity]] 27890 * The argument transforms. 27891 * @returns {Function} Returns the new function. 27892 * @example 27893 * 27894 * function doubled(n) { 27895 * return n * 2; 27896 * } 27897 * 27898 * function square(n) { 27899 * return n * n; 27900 * } 27901 * 27902 * var func = _.overArgs(function(x, y) { 27903 * return [x, y]; 27904 * }, [square, doubled]); 27905 * 27906 * func(9, 3); 27907 * // => [81, 6] 27908 * 27909 * func(10, 5); 27910 * // => [100, 10] 27911 */ 27912 var overArgs = castRest(function(func, transforms) { 27913 transforms = (transforms.length == 1 && isArray(transforms[0])) 27914 ? arrayMap(transforms[0], baseUnary(getIteratee())) 27915 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); 27916 27917 var funcsLength = transforms.length; 27918 return baseRest(function(args) { 27919 var index = -1, 27920 length = nativeMin(args.length, funcsLength); 27921 27922 while (++index < length) { 27923 args[index] = transforms[index].call(this, args[index]); 27924 } 27925 return apply(func, this, args); 27926 }); 27927 }); 27928 27929 /** 27930 * Creates a function that invokes `func` with `partials` prepended to the 27931 * arguments it receives. This method is like `_.bind` except it does **not** 27932 * alter the `this` binding. 27933 * 27934 * The `_.partial.placeholder` value, which defaults to `_` in monolithic 27935 * builds, may be used as a placeholder for partially applied arguments. 27936 * 27937 * **Note:** This method doesn't set the "length" property of partially 27938 * applied functions. 27939 * 27940 * @static 27941 * @memberOf _ 27942 * @since 0.2.0 27943 * @category Function 27944 * @param {Function} func The function to partially apply arguments to. 27945 * @param {...*} [partials] The arguments to be partially applied. 27946 * @returns {Function} Returns the new partially applied function. 27947 * @example 27948 * 27949 * function greet(greeting, name) { 27950 * return greeting + ' ' + name; 27951 * } 27952 * 27953 * var sayHelloTo = _.partial(greet, 'hello'); 27954 * sayHelloTo('fred'); 27955 * // => 'hello fred' 27956 * 27957 * // Partially applied with placeholders. 27958 * var greetFred = _.partial(greet, _, 'fred'); 27959 * greetFred('hi'); 27960 * // => 'hi fred' 27961 */ 27962 var partial = baseRest(function(func, partials) { 27963 var holders = replaceHolders(partials, getHolder(partial)); 27964 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); 27965 }); 27966 27967 /** 27968 * This method is like `_.partial` except that partially applied arguments 27969 * are appended to the arguments it receives. 27970 * 27971 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic 27972 * builds, may be used as a placeholder for partially applied arguments. 27973 * 27974 * **Note:** This method doesn't set the "length" property of partially 27975 * applied functions. 27976 * 27977 * @static 27978 * @memberOf _ 27979 * @since 1.0.0 27980 * @category Function 27981 * @param {Function} func The function to partially apply arguments to. 27982 * @param {...*} [partials] The arguments to be partially applied. 27983 * @returns {Function} Returns the new partially applied function. 27984 * @example 27985 * 27986 * function greet(greeting, name) { 27987 * return greeting + ' ' + name; 27988 * } 27989 * 27990 * var greetFred = _.partialRight(greet, 'fred'); 27991 * greetFred('hi'); 27992 * // => 'hi fred' 27993 * 27994 * // Partially applied with placeholders. 27995 * var sayHelloTo = _.partialRight(greet, 'hello', _); 27996 * sayHelloTo('fred'); 27997 * // => 'hello fred' 27998 */ 27999 var partialRight = baseRest(function(func, partials) { 28000 var holders = replaceHolders(partials, getHolder(partialRight)); 28001 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); 28002 }); 28003 28004 /** 28005 * Creates a function that invokes `func` with arguments arranged according 28006 * to the specified `indexes` where the argument value at the first index is 28007 * provided as the first argument, the argument value at the second index is 28008 * provided as the second argument, and so on. 28009 * 28010 * @static 28011 * @memberOf _ 28012 * @since 3.0.0 28013 * @category Function 28014 * @param {Function} func The function to rearrange arguments for. 28015 * @param {...(number|number[])} indexes The arranged argument indexes. 28016 * @returns {Function} Returns the new function. 28017 * @example 28018 * 28019 * var rearged = _.rearg(function(a, b, c) { 28020 * return [a, b, c]; 28021 * }, [2, 0, 1]); 28022 * 28023 * rearged('b', 'c', 'a') 28024 * // => ['a', 'b', 'c'] 28025 */ 28026 var rearg = flatRest(function(func, indexes) { 28027 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); 28028 }); 28029 28030 /** 28031 * Creates a function that invokes `func` with the `this` binding of the 28032 * created function and arguments from `start` and beyond provided as 28033 * an array. 28034 * 28035 * **Note:** This method is based on the 28036 * [rest parameter](https://mdn.io/rest_parameters). 28037 * 28038 * @static 28039 * @memberOf _ 28040 * @since 4.0.0 28041 * @category Function 28042 * @param {Function} func The function to apply a rest parameter to. 28043 * @param {number} [start=func.length-1] The start position of the rest parameter. 28044 * @returns {Function} Returns the new function. 28045 * @example 28046 * 28047 * var say = _.rest(function(what, names) { 28048 * return what + ' ' + _.initial(names).join(', ') + 28049 * (_.size(names) > 1 ? ', & ' : '') + _.last(names); 28050 * }); 28051 * 28052 * say('hello', 'fred', 'barney', 'pebbles'); 28053 * // => 'hello fred, barney, & pebbles' 28054 */ 28055 function rest(func, start) { 28056 if (typeof func != 'function') { 28057 throw new TypeError(FUNC_ERROR_TEXT); 28058 } 28059 start = start === undefined ? start : toInteger(start); 28060 return baseRest(func, start); 28061 } 28062 28063 /** 28064 * Creates a function that invokes `func` with the `this` binding of the 28065 * create function and an array of arguments much like 28066 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). 28067 * 28068 * **Note:** This method is based on the 28069 * [spread operator](https://mdn.io/spread_operator). 28070 * 28071 * @static 28072 * @memberOf _ 28073 * @since 3.2.0 28074 * @category Function 28075 * @param {Function} func The function to spread arguments over. 28076 * @param {number} [start=0] The start position of the spread. 28077 * @returns {Function} Returns the new function. 28078 * @example 28079 * 28080 * var say = _.spread(function(who, what) { 28081 * return who + ' says ' + what; 28082 * }); 28083 * 28084 * say(['fred', 'hello']); 28085 * // => 'fred says hello' 28086 * 28087 * var numbers = Promise.all([ 28088 * Promise.resolve(40), 28089 * Promise.resolve(36) 28090 * ]); 28091 * 28092 * numbers.then(_.spread(function(x, y) { 28093 * return x + y; 28094 * })); 28095 * // => a Promise of 76 28096 */ 28097 function spread(func, start) { 28098 if (typeof func != 'function') { 28099 throw new TypeError(FUNC_ERROR_TEXT); 28100 } 28101 start = start == null ? 0 : nativeMax(toInteger(start), 0); 28102 return baseRest(function(args) { 28103 var array = args[start], 28104 otherArgs = castSlice(args, 0, start); 28105 28106 if (array) { 28107 arrayPush(otherArgs, array); 28108 } 28109 return apply(func, this, otherArgs); 28110 }); 28111 } 28112 28113 /** 28114 * Creates a throttled function that only invokes `func` at most once per 28115 * every `wait` milliseconds. The throttled function comes with a `cancel` 28116 * method to cancel delayed `func` invocations and a `flush` method to 28117 * immediately invoke them. Provide `options` to indicate whether `func` 28118 * should be invoked on the leading and/or trailing edge of the `wait` 28119 * timeout. The `func` is invoked with the last arguments provided to the 28120 * throttled function. Subsequent calls to the throttled function return the 28121 * result of the last `func` invocation. 28122 * 28123 * **Note:** If `leading` and `trailing` options are `true`, `func` is 28124 * invoked on the trailing edge of the timeout only if the throttled function 28125 * is invoked more than once during the `wait` timeout. 28126 * 28127 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 28128 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 28129 * 28130 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 28131 * for details over the differences between `_.throttle` and `_.debounce`. 28132 * 28133 * @static 28134 * @memberOf _ 28135 * @since 0.1.0 28136 * @category Function 28137 * @param {Function} func The function to throttle. 28138 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 28139 * @param {Object} [options={}] The options object. 28140 * @param {boolean} [options.leading=true] 28141 * Specify invoking on the leading edge of the timeout. 28142 * @param {boolean} [options.trailing=true] 28143 * Specify invoking on the trailing edge of the timeout. 28144 * @returns {Function} Returns the new throttled function. 28145 * @example 28146 * 28147 * // Avoid excessively updating the position while scrolling. 28148 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 28149 * 28150 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 28151 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 28152 * jQuery(element).on('click', throttled); 28153 * 28154 * // Cancel the trailing throttled invocation. 28155 * jQuery(window).on('popstate', throttled.cancel); 28156 */ 28157 function throttle(func, wait, options) { 28158 var leading = true, 28159 trailing = true; 28160 28161 if (typeof func != 'function') { 28162 throw new TypeError(FUNC_ERROR_TEXT); 28163 } 28164 if (isObject(options)) { 28165 leading = 'leading' in options ? !!options.leading : leading; 28166 trailing = 'trailing' in options ? !!options.trailing : trailing; 28167 } 28168 return debounce(func, wait, { 28169 'leading': leading, 28170 'maxWait': wait, 28171 'trailing': trailing 28172 }); 28173 } 28174 28175 /** 28176 * Creates a function that accepts up to one argument, ignoring any 28177 * additional arguments. 28178 * 28179 * @static 28180 * @memberOf _ 28181 * @since 4.0.0 28182 * @category Function 28183 * @param {Function} func The function to cap arguments for. 28184 * @returns {Function} Returns the new capped function. 28185 * @example 28186 * 28187 * _.map(['6', '8', '10'], _.unary(parseInt)); 28188 * // => [6, 8, 10] 28189 */ 28190 function unary(func) { 28191 return ary(func, 1); 28192 } 28193 28194 /** 28195 * Creates a function that provides `value` to `wrapper` as its first 28196 * argument. Any additional arguments provided to the function are appended 28197 * to those provided to the `wrapper`. The wrapper is invoked with the `this` 28198 * binding of the created function. 28199 * 28200 * @static 28201 * @memberOf _ 28202 * @since 0.1.0 28203 * @category Function 28204 * @param {*} value The value to wrap. 28205 * @param {Function} [wrapper=identity] The wrapper function. 28206 * @returns {Function} Returns the new function. 28207 * @example 28208 * 28209 * var p = _.wrap(_.escape, function(func, text) { 28210 * return '<p>' + func(text) + '</p>'; 28211 * }); 28212 * 28213 * p('fred, barney, & pebbles'); 28214 * // => '<p>fred, barney, & pebbles</p>' 28215 */ 28216 function wrap(value, wrapper) { 28217 return partial(castFunction(wrapper), value); 28218 } 28219 28220 /*------------------------------------------------------------------------*/ 28221 28222 /** 28223 * Casts `value` as an array if it's not one. 28224 * 28225 * @static 28226 * @memberOf _ 28227 * @since 4.4.0 28228 * @category Lang 28229 * @param {*} value The value to inspect. 28230 * @returns {Array} Returns the cast array. 28231 * @example 28232 * 28233 * _.castArray(1); 28234 * // => [1] 28235 * 28236 * _.castArray({ 'a': 1 }); 28237 * // => [{ 'a': 1 }] 28238 * 28239 * _.castArray('abc'); 28240 * // => ['abc'] 28241 * 28242 * _.castArray(null); 28243 * // => [null] 28244 * 28245 * _.castArray(undefined); 28246 * // => [undefined] 28247 * 28248 * _.castArray(); 28249 * // => [] 28250 * 28251 * var array = [1, 2, 3]; 28252 * console.log(_.castArray(array) === array); 28253 * // => true 28254 */ 28255 function castArray() { 28256 if (!arguments.length) { 28257 return []; 28258 } 28259 var value = arguments[0]; 28260 return isArray(value) ? value : [value]; 28261 } 28262 28263 /** 28264 * Creates a shallow clone of `value`. 28265 * 28266 * **Note:** This method is loosely based on the 28267 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) 28268 * and supports cloning arrays, array buffers, booleans, date objects, maps, 28269 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed 28270 * arrays. The own enumerable properties of `arguments` objects are cloned 28271 * as plain objects. An empty object is returned for uncloneable values such 28272 * as error objects, functions, DOM nodes, and WeakMaps. 28273 * 28274 * @static 28275 * @memberOf _ 28276 * @since 0.1.0 28277 * @category Lang 28278 * @param {*} value The value to clone. 28279 * @returns {*} Returns the cloned value. 28280 * @see _.cloneDeep 28281 * @example 28282 * 28283 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 28284 * 28285 * var shallow = _.clone(objects); 28286 * console.log(shallow[0] === objects[0]); 28287 * // => true 28288 */ 28289 function clone(value) { 28290 return baseClone(value, CLONE_SYMBOLS_FLAG); 28291 } 28292 28293 /** 28294 * This method is like `_.clone` except that it accepts `customizer` which 28295 * is invoked to produce the cloned value. If `customizer` returns `undefined`, 28296 * cloning is handled by the method instead. The `customizer` is invoked with 28297 * up to four arguments; (value [, index|key, object, stack]). 28298 * 28299 * @static 28300 * @memberOf _ 28301 * @since 4.0.0 28302 * @category Lang 28303 * @param {*} value The value to clone. 28304 * @param {Function} [customizer] The function to customize cloning. 28305 * @returns {*} Returns the cloned value. 28306 * @see _.cloneDeepWith 28307 * @example 28308 * 28309 * function customizer(value) { 28310 * if (_.isElement(value)) { 28311 * return value.cloneNode(false); 28312 * } 28313 * } 28314 * 28315 * var el = _.cloneWith(document.body, customizer); 28316 * 28317 * console.log(el === document.body); 28318 * // => false 28319 * console.log(el.nodeName); 28320 * // => 'BODY' 28321 * console.log(el.childNodes.length); 28322 * // => 0 28323 */ 28324 function cloneWith(value, customizer) { 28325 customizer = typeof customizer == 'function' ? customizer : undefined; 28326 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); 28327 } 28328 28329 /** 28330 * This method is like `_.clone` except that it recursively clones `value`. 28331 * 28332 * @static 28333 * @memberOf _ 28334 * @since 1.0.0 28335 * @category Lang 28336 * @param {*} value The value to recursively clone. 28337 * @returns {*} Returns the deep cloned value. 28338 * @see _.clone 28339 * @example 28340 * 28341 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 28342 * 28343 * var deep = _.cloneDeep(objects); 28344 * console.log(deep[0] === objects[0]); 28345 * // => false 28346 */ 28347 function cloneDeep(value) { 28348 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 28349 } 28350 28351 /** 28352 * This method is like `_.cloneWith` except that it recursively clones `value`. 28353 * 28354 * @static 28355 * @memberOf _ 28356 * @since 4.0.0 28357 * @category Lang 28358 * @param {*} value The value to recursively clone. 28359 * @param {Function} [customizer] The function to customize cloning. 28360 * @returns {*} Returns the deep cloned value. 28361 * @see _.cloneWith 28362 * @example 28363 * 28364 * function customizer(value) { 28365 * if (_.isElement(value)) { 28366 * return value.cloneNode(true); 28367 * } 28368 * } 28369 * 28370 * var el = _.cloneDeepWith(document.body, customizer); 28371 * 28372 * console.log(el === document.body); 28373 * // => false 28374 * console.log(el.nodeName); 28375 * // => 'BODY' 28376 * console.log(el.childNodes.length); 28377 * // => 20 28378 */ 28379 function cloneDeepWith(value, customizer) { 28380 customizer = typeof customizer == 'function' ? customizer : undefined; 28381 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); 28382 } 28383 28384 /** 28385 * Checks if `object` conforms to `source` by invoking the predicate 28386 * properties of `source` with the corresponding property values of `object`. 28387 * 28388 * **Note:** This method is equivalent to `_.conforms` when `source` is 28389 * partially applied. 28390 * 28391 * @static 28392 * @memberOf _ 28393 * @since 4.14.0 28394 * @category Lang 28395 * @param {Object} object The object to inspect. 28396 * @param {Object} source The object of property predicates to conform to. 28397 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 28398 * @example 28399 * 28400 * var object = { 'a': 1, 'b': 2 }; 28401 * 28402 * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); 28403 * // => true 28404 * 28405 * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); 28406 * // => false 28407 */ 28408 function conformsTo(object, source) { 28409 return source == null || baseConformsTo(object, source, keys(source)); 28410 } 28411 28412 /** 28413 * Performs a 28414 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 28415 * comparison between two values to determine if they are equivalent. 28416 * 28417 * @static 28418 * @memberOf _ 28419 * @since 4.0.0 28420 * @category Lang 28421 * @param {*} value The value to compare. 28422 * @param {*} other The other value to compare. 28423 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 28424 * @example 28425 * 28426 * var object = { 'a': 1 }; 28427 * var other = { 'a': 1 }; 28428 * 28429 * _.eq(object, object); 28430 * // => true 28431 * 28432 * _.eq(object, other); 28433 * // => false 28434 * 28435 * _.eq('a', 'a'); 28436 * // => true 28437 * 28438 * _.eq('a', Object('a')); 28439 * // => false 28440 * 28441 * _.eq(NaN, NaN); 28442 * // => true 28443 */ 28444 function eq(value, other) { 28445 return value === other || (value !== value && other !== other); 28446 } 28447 28448 /** 28449 * Checks if `value` is greater than `other`. 28450 * 28451 * @static 28452 * @memberOf _ 28453 * @since 3.9.0 28454 * @category Lang 28455 * @param {*} value The value to compare. 28456 * @param {*} other The other value to compare. 28457 * @returns {boolean} Returns `true` if `value` is greater than `other`, 28458 * else `false`. 28459 * @see _.lt 28460 * @example 28461 * 28462 * _.gt(3, 1); 28463 * // => true 28464 * 28465 * _.gt(3, 3); 28466 * // => false 28467 * 28468 * _.gt(1, 3); 28469 * // => false 28470 */ 28471 var gt = createRelationalOperation(baseGt); 28472 28473 /** 28474 * Checks if `value` is greater than or equal to `other`. 28475 * 28476 * @static 28477 * @memberOf _ 28478 * @since 3.9.0 28479 * @category Lang 28480 * @param {*} value The value to compare. 28481 * @param {*} other The other value to compare. 28482 * @returns {boolean} Returns `true` if `value` is greater than or equal to 28483 * `other`, else `false`. 28484 * @see _.lte 28485 * @example 28486 * 28487 * _.gte(3, 1); 28488 * // => true 28489 * 28490 * _.gte(3, 3); 28491 * // => true 28492 * 28493 * _.gte(1, 3); 28494 * // => false 28495 */ 28496 var gte = createRelationalOperation(function(value, other) { 28497 return value >= other; 28498 }); 28499 28500 /** 28501 * Checks if `value` is likely an `arguments` object. 28502 * 28503 * @static 28504 * @memberOf _ 28505 * @since 0.1.0 28506 * @category Lang 28507 * @param {*} value The value to check. 28508 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 28509 * else `false`. 28510 * @example 28511 * 28512 * _.isArguments(function() { return arguments; }()); 28513 * // => true 28514 * 28515 * _.isArguments([1, 2, 3]); 28516 * // => false 28517 */ 28518 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { 28519 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && 28520 !propertyIsEnumerable.call(value, 'callee'); 28521 }; 28522 28523 /** 28524 * Checks if `value` is classified as an `Array` object. 28525 * 28526 * @static 28527 * @memberOf _ 28528 * @since 0.1.0 28529 * @category Lang 28530 * @param {*} value The value to check. 28531 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 28532 * @example 28533 * 28534 * _.isArray([1, 2, 3]); 28535 * // => true 28536 * 28537 * _.isArray(document.body.children); 28538 * // => false 28539 * 28540 * _.isArray('abc'); 28541 * // => false 28542 * 28543 * _.isArray(_.noop); 28544 * // => false 28545 */ 28546 var isArray = Array.isArray; 28547 28548 /** 28549 * Checks if `value` is classified as an `ArrayBuffer` object. 28550 * 28551 * @static 28552 * @memberOf _ 28553 * @since 4.3.0 28554 * @category Lang 28555 * @param {*} value The value to check. 28556 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 28557 * @example 28558 * 28559 * _.isArrayBuffer(new ArrayBuffer(2)); 28560 * // => true 28561 * 28562 * _.isArrayBuffer(new Array(2)); 28563 * // => false 28564 */ 28565 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; 28566 28567 /** 28568 * Checks if `value` is array-like. A value is considered array-like if it's 28569 * not a function and has a `value.length` that's an integer greater than or 28570 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 28571 * 28572 * @static 28573 * @memberOf _ 28574 * @since 4.0.0 28575 * @category Lang 28576 * @param {*} value The value to check. 28577 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 28578 * @example 28579 * 28580 * _.isArrayLike([1, 2, 3]); 28581 * // => true 28582 * 28583 * _.isArrayLike(document.body.children); 28584 * // => true 28585 * 28586 * _.isArrayLike('abc'); 28587 * // => true 28588 * 28589 * _.isArrayLike(_.noop); 28590 * // => false 28591 */ 28592 function isArrayLike(value) { 28593 return value != null && isLength(value.length) && !isFunction(value); 28594 } 28595 28596 /** 28597 * This method is like `_.isArrayLike` except that it also checks if `value` 28598 * is an object. 28599 * 28600 * @static 28601 * @memberOf _ 28602 * @since 4.0.0 28603 * @category Lang 28604 * @param {*} value The value to check. 28605 * @returns {boolean} Returns `true` if `value` is an array-like object, 28606 * else `false`. 28607 * @example 28608 * 28609 * _.isArrayLikeObject([1, 2, 3]); 28610 * // => true 28611 * 28612 * _.isArrayLikeObject(document.body.children); 28613 * // => true 28614 * 28615 * _.isArrayLikeObject('abc'); 28616 * // => false 28617 * 28618 * _.isArrayLikeObject(_.noop); 28619 * // => false 28620 */ 28621 function isArrayLikeObject(value) { 28622 return isObjectLike(value) && isArrayLike(value); 28623 } 28624 28625 /** 28626 * Checks if `value` is classified as a boolean primitive or object. 28627 * 28628 * @static 28629 * @memberOf _ 28630 * @since 0.1.0 28631 * @category Lang 28632 * @param {*} value The value to check. 28633 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. 28634 * @example 28635 * 28636 * _.isBoolean(false); 28637 * // => true 28638 * 28639 * _.isBoolean(null); 28640 * // => false 28641 */ 28642 function isBoolean(value) { 28643 return value === true || value === false || 28644 (isObjectLike(value) && baseGetTag(value) == boolTag); 28645 } 28646 28647 /** 28648 * Checks if `value` is a buffer. 28649 * 28650 * @static 28651 * @memberOf _ 28652 * @since 4.3.0 28653 * @category Lang 28654 * @param {*} value The value to check. 28655 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 28656 * @example 28657 * 28658 * _.isBuffer(new Buffer(2)); 28659 * // => true 28660 * 28661 * _.isBuffer(new Uint8Array(2)); 28662 * // => false 28663 */ 28664 var isBuffer = nativeIsBuffer || stubFalse; 28665 28666 /** 28667 * Checks if `value` is classified as a `Date` object. 28668 * 28669 * @static 28670 * @memberOf _ 28671 * @since 0.1.0 28672 * @category Lang 28673 * @param {*} value The value to check. 28674 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 28675 * @example 28676 * 28677 * _.isDate(new Date); 28678 * // => true 28679 * 28680 * _.isDate('Mon April 23 2012'); 28681 * // => false 28682 */ 28683 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; 28684 28685 /** 28686 * Checks if `value` is likely a DOM element. 28687 * 28688 * @static 28689 * @memberOf _ 28690 * @since 0.1.0 28691 * @category Lang 28692 * @param {*} value The value to check. 28693 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. 28694 * @example 28695 * 28696 * _.isElement(document.body); 28697 * // => true 28698 * 28699 * _.isElement('<body>'); 28700 * // => false 28701 */ 28702 function isElement(value) { 28703 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); 28704 } 28705 28706 /** 28707 * Checks if `value` is an empty object, collection, map, or set. 28708 * 28709 * Objects are considered empty if they have no own enumerable string keyed 28710 * properties. 28711 * 28712 * Array-like values such as `arguments` objects, arrays, buffers, strings, or 28713 * jQuery-like collections are considered empty if they have a `length` of `0`. 28714 * Similarly, maps and sets are considered empty if they have a `size` of `0`. 28715 * 28716 * @static 28717 * @memberOf _ 28718 * @since 0.1.0 28719 * @category Lang 28720 * @param {*} value The value to check. 28721 * @returns {boolean} Returns `true` if `value` is empty, else `false`. 28722 * @example 28723 * 28724 * _.isEmpty(null); 28725 * // => true 28726 * 28727 * _.isEmpty(true); 28728 * // => true 28729 * 28730 * _.isEmpty(1); 28731 * // => true 28732 * 28733 * _.isEmpty([1, 2, 3]); 28734 * // => false 28735 * 28736 * _.isEmpty({ 'a': 1 }); 28737 * // => false 28738 */ 28739 function isEmpty(value) { 28740 if (value == null) { 28741 return true; 28742 } 28743 if (isArrayLike(value) && 28744 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || 28745 isBuffer(value) || isTypedArray(value) || isArguments(value))) { 28746 return !value.length; 28747 } 28748 var tag = getTag(value); 28749 if (tag == mapTag || tag == setTag) { 28750 return !value.size; 28751 } 28752 if (isPrototype(value)) { 28753 return !baseKeys(value).length; 28754 } 28755 for (var key in value) { 28756 if (hasOwnProperty.call(value, key)) { 28757 return false; 28758 } 28759 } 28760 return true; 28761 } 28762 28763 /** 28764 * Performs a deep comparison between two values to determine if they are 28765 * equivalent. 28766 * 28767 * **Note:** This method supports comparing arrays, array buffers, booleans, 28768 * date objects, error objects, maps, numbers, `Object` objects, regexes, 28769 * sets, strings, symbols, and typed arrays. `Object` objects are compared 28770 * by their own, not inherited, enumerable properties. Functions and DOM 28771 * nodes are compared by strict equality, i.e. `===`. 28772 * 28773 * @static 28774 * @memberOf _ 28775 * @since 0.1.0 28776 * @category Lang 28777 * @param {*} value The value to compare. 28778 * @param {*} other The other value to compare. 28779 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 28780 * @example 28781 * 28782 * var object = { 'a': 1 }; 28783 * var other = { 'a': 1 }; 28784 * 28785 * _.isEqual(object, other); 28786 * // => true 28787 * 28788 * object === other; 28789 * // => false 28790 */ 28791 function isEqual(value, other) { 28792 return baseIsEqual(value, other); 28793 } 28794 28795 /** 28796 * This method is like `_.isEqual` except that it accepts `customizer` which 28797 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 28798 * are handled by the method instead. The `customizer` is invoked with up to 28799 * six arguments: (objValue, othValue [, index|key, object, other, stack]). 28800 * 28801 * @static 28802 * @memberOf _ 28803 * @since 4.0.0 28804 * @category Lang 28805 * @param {*} value The value to compare. 28806 * @param {*} other The other value to compare. 28807 * @param {Function} [customizer] The function to customize comparisons. 28808 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 28809 * @example 28810 * 28811 * function isGreeting(value) { 28812 * return /^h(?:i|ello)$/.test(value); 28813 * } 28814 * 28815 * function customizer(objValue, othValue) { 28816 * if (isGreeting(objValue) && isGreeting(othValue)) { 28817 * return true; 28818 * } 28819 * } 28820 * 28821 * var array = ['hello', 'goodbye']; 28822 * var other = ['hi', 'goodbye']; 28823 * 28824 * _.isEqualWith(array, other, customizer); 28825 * // => true 28826 */ 28827 function isEqualWith(value, other, customizer) { 28828 customizer = typeof customizer == 'function' ? customizer : undefined; 28829 var result = customizer ? customizer(value, other) : undefined; 28830 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; 28831 } 28832 28833 /** 28834 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, 28835 * `SyntaxError`, `TypeError`, or `URIError` object. 28836 * 28837 * @static 28838 * @memberOf _ 28839 * @since 3.0.0 28840 * @category Lang 28841 * @param {*} value The value to check. 28842 * @returns {boolean} Returns `true` if `value` is an error object, else `false`. 28843 * @example 28844 * 28845 * _.isError(new Error); 28846 * // => true 28847 * 28848 * _.isError(Error); 28849 * // => false 28850 */ 28851 function isError(value) { 28852 if (!isObjectLike(value)) { 28853 return false; 28854 } 28855 var tag = baseGetTag(value); 28856 return tag == errorTag || tag == domExcTag || 28857 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); 28858 } 28859 28860 /** 28861 * Checks if `value` is a finite primitive number. 28862 * 28863 * **Note:** This method is based on 28864 * [`Number.isFinite`](https://mdn.io/Number/isFinite). 28865 * 28866 * @static 28867 * @memberOf _ 28868 * @since 0.1.0 28869 * @category Lang 28870 * @param {*} value The value to check. 28871 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. 28872 * @example 28873 * 28874 * _.isFinite(3); 28875 * // => true 28876 * 28877 * _.isFinite(Number.MIN_VALUE); 28878 * // => true 28879 * 28880 * _.isFinite(Infinity); 28881 * // => false 28882 * 28883 * _.isFinite('3'); 28884 * // => false 28885 */ 28886 function isFinite(value) { 28887 return typeof value == 'number' && nativeIsFinite(value); 28888 } 28889 28890 /** 28891 * Checks if `value` is classified as a `Function` object. 28892 * 28893 * @static 28894 * @memberOf _ 28895 * @since 0.1.0 28896 * @category Lang 28897 * @param {*} value The value to check. 28898 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 28899 * @example 28900 * 28901 * _.isFunction(_); 28902 * // => true 28903 * 28904 * _.isFunction(/abc/); 28905 * // => false 28906 */ 28907 function isFunction(value) { 28908 if (!isObject(value)) { 28909 return false; 28910 } 28911 // The use of `Object#toString` avoids issues with the `typeof` operator 28912 // in Safari 9 which returns 'object' for typed arrays and other constructors. 28913 var tag = baseGetTag(value); 28914 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; 28915 } 28916 28917 /** 28918 * Checks if `value` is an integer. 28919 * 28920 * **Note:** This method is based on 28921 * [`Number.isInteger`](https://mdn.io/Number/isInteger). 28922 * 28923 * @static 28924 * @memberOf _ 28925 * @since 4.0.0 28926 * @category Lang 28927 * @param {*} value The value to check. 28928 * @returns {boolean} Returns `true` if `value` is an integer, else `false`. 28929 * @example 28930 * 28931 * _.isInteger(3); 28932 * // => true 28933 * 28934 * _.isInteger(Number.MIN_VALUE); 28935 * // => false 28936 * 28937 * _.isInteger(Infinity); 28938 * // => false 28939 * 28940 * _.isInteger('3'); 28941 * // => false 28942 */ 28943 function isInteger(value) { 28944 return typeof value == 'number' && value == toInteger(value); 28945 } 28946 28947 /** 28948 * Checks if `value` is a valid array-like length. 28949 * 28950 * **Note:** This method is loosely based on 28951 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 28952 * 28953 * @static 28954 * @memberOf _ 28955 * @since 4.0.0 28956 * @category Lang 28957 * @param {*} value The value to check. 28958 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 28959 * @example 28960 * 28961 * _.isLength(3); 28962 * // => true 28963 * 28964 * _.isLength(Number.MIN_VALUE); 28965 * // => false 28966 * 28967 * _.isLength(Infinity); 28968 * // => false 28969 * 28970 * _.isLength('3'); 28971 * // => false 28972 */ 28973 function isLength(value) { 28974 return typeof value == 'number' && 28975 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 28976 } 28977 28978 /** 28979 * Checks if `value` is the 28980 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 28981 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 28982 * 28983 * @static 28984 * @memberOf _ 28985 * @since 0.1.0 28986 * @category Lang 28987 * @param {*} value The value to check. 28988 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 28989 * @example 28990 * 28991 * _.isObject({}); 28992 * // => true 28993 * 28994 * _.isObject([1, 2, 3]); 28995 * // => true 28996 * 28997 * _.isObject(_.noop); 28998 * // => true 28999 * 29000 * _.isObject(null); 29001 * // => false 29002 */ 29003 function isObject(value) { 29004 var type = typeof value; 29005 return value != null && (type == 'object' || type == 'function'); 29006 } 29007 29008 /** 29009 * Checks if `value` is object-like. A value is object-like if it's not `null` 29010 * and has a `typeof` result of "object". 29011 * 29012 * @static 29013 * @memberOf _ 29014 * @since 4.0.0 29015 * @category Lang 29016 * @param {*} value The value to check. 29017 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 29018 * @example 29019 * 29020 * _.isObjectLike({}); 29021 * // => true 29022 * 29023 * _.isObjectLike([1, 2, 3]); 29024 * // => true 29025 * 29026 * _.isObjectLike(_.noop); 29027 * // => false 29028 * 29029 * _.isObjectLike(null); 29030 * // => false 29031 */ 29032 function isObjectLike(value) { 29033 return value != null && typeof value == 'object'; 29034 } 29035 29036 /** 29037 * Checks if `value` is classified as a `Map` object. 29038 * 29039 * @static 29040 * @memberOf _ 29041 * @since 4.3.0 29042 * @category Lang 29043 * @param {*} value The value to check. 29044 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 29045 * @example 29046 * 29047 * _.isMap(new Map); 29048 * // => true 29049 * 29050 * _.isMap(new WeakMap); 29051 * // => false 29052 */ 29053 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; 29054 29055 /** 29056 * Performs a partial deep comparison between `object` and `source` to 29057 * determine if `object` contains equivalent property values. 29058 * 29059 * **Note:** This method is equivalent to `_.matches` when `source` is 29060 * partially applied. 29061 * 29062 * Partial comparisons will match empty array and empty object `source` 29063 * values against any array or object value, respectively. See `_.isEqual` 29064 * for a list of supported value comparisons. 29065 * 29066 * @static 29067 * @memberOf _ 29068 * @since 3.0.0 29069 * @category Lang 29070 * @param {Object} object The object to inspect. 29071 * @param {Object} source The object of property values to match. 29072 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 29073 * @example 29074 * 29075 * var object = { 'a': 1, 'b': 2 }; 29076 * 29077 * _.isMatch(object, { 'b': 2 }); 29078 * // => true 29079 * 29080 * _.isMatch(object, { 'b': 1 }); 29081 * // => false 29082 */ 29083 function isMatch(object, source) { 29084 return object === source || baseIsMatch(object, source, getMatchData(source)); 29085 } 29086 29087 /** 29088 * This method is like `_.isMatch` except that it accepts `customizer` which 29089 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 29090 * are handled by the method instead. The `customizer` is invoked with five 29091 * arguments: (objValue, srcValue, index|key, object, source). 29092 * 29093 * @static 29094 * @memberOf _ 29095 * @since 4.0.0 29096 * @category Lang 29097 * @param {Object} object The object to inspect. 29098 * @param {Object} source The object of property values to match. 29099 * @param {Function} [customizer] The function to customize comparisons. 29100 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 29101 * @example 29102 * 29103 * function isGreeting(value) { 29104 * return /^h(?:i|ello)$/.test(value); 29105 * } 29106 * 29107 * function customizer(objValue, srcValue) { 29108 * if (isGreeting(objValue) && isGreeting(srcValue)) { 29109 * return true; 29110 * } 29111 * } 29112 * 29113 * var object = { 'greeting': 'hello' }; 29114 * var source = { 'greeting': 'hi' }; 29115 * 29116 * _.isMatchWith(object, source, customizer); 29117 * // => true 29118 */ 29119 function isMatchWith(object, source, customizer) { 29120 customizer = typeof customizer == 'function' ? customizer : undefined; 29121 return baseIsMatch(object, source, getMatchData(source), customizer); 29122 } 29123 29124 /** 29125 * Checks if `value` is `NaN`. 29126 * 29127 * **Note:** This method is based on 29128 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as 29129 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for 29130 * `undefined` and other non-number values. 29131 * 29132 * @static 29133 * @memberOf _ 29134 * @since 0.1.0 29135 * @category Lang 29136 * @param {*} value The value to check. 29137 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 29138 * @example 29139 * 29140 * _.isNaN(NaN); 29141 * // => true 29142 * 29143 * _.isNaN(new Number(NaN)); 29144 * // => true 29145 * 29146 * isNaN(undefined); 29147 * // => true 29148 * 29149 * _.isNaN(undefined); 29150 * // => false 29151 */ 29152 function isNaN(value) { 29153 // An `NaN` primitive is the only value that is not equal to itself. 29154 // Perform the `toStringTag` check first to avoid errors with some 29155 // ActiveX objects in IE. 29156 return isNumber(value) && value != +value; 29157 } 29158 29159 /** 29160 * Checks if `value` is a pristine native function. 29161 * 29162 * **Note:** This method can't reliably detect native functions in the presence 29163 * of the core-js package because core-js circumvents this kind of detection. 29164 * Despite multiple requests, the core-js maintainer has made it clear: any 29165 * attempt to fix the detection will be obstructed. As a result, we're left 29166 * with little choice but to throw an error. Unfortunately, this also affects 29167 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), 29168 * which rely on core-js. 29169 * 29170 * @static 29171 * @memberOf _ 29172 * @since 3.0.0 29173 * @category Lang 29174 * @param {*} value The value to check. 29175 * @returns {boolean} Returns `true` if `value` is a native function, 29176 * else `false`. 29177 * @example 29178 * 29179 * _.isNative(Array.prototype.push); 29180 * // => true 29181 * 29182 * _.isNative(_); 29183 * // => false 29184 */ 29185 function isNative(value) { 29186 if (isMaskable(value)) { 29187 throw new Error(CORE_ERROR_TEXT); 29188 } 29189 return baseIsNative(value); 29190 } 29191 29192 /** 29193 * Checks if `value` is `null`. 29194 * 29195 * @static 29196 * @memberOf _ 29197 * @since 0.1.0 29198 * @category Lang 29199 * @param {*} value The value to check. 29200 * @returns {boolean} Returns `true` if `value` is `null`, else `false`. 29201 * @example 29202 * 29203 * _.isNull(null); 29204 * // => true 29205 * 29206 * _.isNull(void 0); 29207 * // => false 29208 */ 29209 function isNull(value) { 29210 return value === null; 29211 } 29212 29213 /** 29214 * Checks if `value` is `null` or `undefined`. 29215 * 29216 * @static 29217 * @memberOf _ 29218 * @since 4.0.0 29219 * @category Lang 29220 * @param {*} value The value to check. 29221 * @returns {boolean} Returns `true` if `value` is nullish, else `false`. 29222 * @example 29223 * 29224 * _.isNil(null); 29225 * // => true 29226 * 29227 * _.isNil(void 0); 29228 * // => true 29229 * 29230 * _.isNil(NaN); 29231 * // => false 29232 */ 29233 function isNil(value) { 29234 return value == null; 29235 } 29236 29237 /** 29238 * Checks if `value` is classified as a `Number` primitive or object. 29239 * 29240 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are 29241 * classified as numbers, use the `_.isFinite` method. 29242 * 29243 * @static 29244 * @memberOf _ 29245 * @since 0.1.0 29246 * @category Lang 29247 * @param {*} value The value to check. 29248 * @returns {boolean} Returns `true` if `value` is a number, else `false`. 29249 * @example 29250 * 29251 * _.isNumber(3); 29252 * // => true 29253 * 29254 * _.isNumber(Number.MIN_VALUE); 29255 * // => true 29256 * 29257 * _.isNumber(Infinity); 29258 * // => true 29259 * 29260 * _.isNumber('3'); 29261 * // => false 29262 */ 29263 function isNumber(value) { 29264 return typeof value == 'number' || 29265 (isObjectLike(value) && baseGetTag(value) == numberTag); 29266 } 29267 29268 /** 29269 * Checks if `value` is a plain object, that is, an object created by the 29270 * `Object` constructor or one with a `[[Prototype]]` of `null`. 29271 * 29272 * @static 29273 * @memberOf _ 29274 * @since 0.8.0 29275 * @category Lang 29276 * @param {*} value The value to check. 29277 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 29278 * @example 29279 * 29280 * function Foo() { 29281 * this.a = 1; 29282 * } 29283 * 29284 * _.isPlainObject(new Foo); 29285 * // => false 29286 * 29287 * _.isPlainObject([1, 2, 3]); 29288 * // => false 29289 * 29290 * _.isPlainObject({ 'x': 0, 'y': 0 }); 29291 * // => true 29292 * 29293 * _.isPlainObject(Object.create(null)); 29294 * // => true 29295 */ 29296 function isPlainObject(value) { 29297 if (!isObjectLike(value) || baseGetTag(value) != objectTag) { 29298 return false; 29299 } 29300 var proto = getPrototype(value); 29301 if (proto === null) { 29302 return true; 29303 } 29304 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 29305 return typeof Ctor == 'function' && Ctor instanceof Ctor && 29306 funcToString.call(Ctor) == objectCtorString; 29307 } 29308 29309 /** 29310 * Checks if `value` is classified as a `RegExp` object. 29311 * 29312 * @static 29313 * @memberOf _ 29314 * @since 0.1.0 29315 * @category Lang 29316 * @param {*} value The value to check. 29317 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 29318 * @example 29319 * 29320 * _.isRegExp(/abc/); 29321 * // => true 29322 * 29323 * _.isRegExp('/abc/'); 29324 * // => false 29325 */ 29326 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; 29327 29328 /** 29329 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 29330 * double precision number which isn't the result of a rounded unsafe integer. 29331 * 29332 * **Note:** This method is based on 29333 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). 29334 * 29335 * @static 29336 * @memberOf _ 29337 * @since 4.0.0 29338 * @category Lang 29339 * @param {*} value The value to check. 29340 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. 29341 * @example 29342 * 29343 * _.isSafeInteger(3); 29344 * // => true 29345 * 29346 * _.isSafeInteger(Number.MIN_VALUE); 29347 * // => false 29348 * 29349 * _.isSafeInteger(Infinity); 29350 * // => false 29351 * 29352 * _.isSafeInteger('3'); 29353 * // => false 29354 */ 29355 function isSafeInteger(value) { 29356 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; 29357 } 29358 29359 /** 29360 * Checks if `value` is classified as a `Set` object. 29361 * 29362 * @static 29363 * @memberOf _ 29364 * @since 4.3.0 29365 * @category Lang 29366 * @param {*} value The value to check. 29367 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 29368 * @example 29369 * 29370 * _.isSet(new Set); 29371 * // => true 29372 * 29373 * _.isSet(new WeakSet); 29374 * // => false 29375 */ 29376 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; 29377 29378 /** 29379 * Checks if `value` is classified as a `String` primitive or object. 29380 * 29381 * @static 29382 * @since 0.1.0 29383 * @memberOf _ 29384 * @category Lang 29385 * @param {*} value The value to check. 29386 * @returns {boolean} Returns `true` if `value` is a string, else `false`. 29387 * @example 29388 * 29389 * _.isString('abc'); 29390 * // => true 29391 * 29392 * _.isString(1); 29393 * // => false 29394 */ 29395 function isString(value) { 29396 return typeof value == 'string' || 29397 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); 29398 } 29399 29400 /** 29401 * Checks if `value` is classified as a `Symbol` primitive or object. 29402 * 29403 * @static 29404 * @memberOf _ 29405 * @since 4.0.0 29406 * @category Lang 29407 * @param {*} value The value to check. 29408 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 29409 * @example 29410 * 29411 * _.isSymbol(Symbol.iterator); 29412 * // => true 29413 * 29414 * _.isSymbol('abc'); 29415 * // => false 29416 */ 29417 function isSymbol(value) { 29418 return typeof value == 'symbol' || 29419 (isObjectLike(value) && baseGetTag(value) == symbolTag); 29420 } 29421 29422 /** 29423 * Checks if `value` is classified as a typed array. 29424 * 29425 * @static 29426 * @memberOf _ 29427 * @since 3.0.0 29428 * @category Lang 29429 * @param {*} value The value to check. 29430 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 29431 * @example 29432 * 29433 * _.isTypedArray(new Uint8Array); 29434 * // => true 29435 * 29436 * _.isTypedArray([]); 29437 * // => false 29438 */ 29439 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; 29440 29441 /** 29442 * Checks if `value` is `undefined`. 29443 * 29444 * @static 29445 * @since 0.1.0 29446 * @memberOf _ 29447 * @category Lang 29448 * @param {*} value The value to check. 29449 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 29450 * @example 29451 * 29452 * _.isUndefined(void 0); 29453 * // => true 29454 * 29455 * _.isUndefined(null); 29456 * // => false 29457 */ 29458 function isUndefined(value) { 29459 return value === undefined; 29460 } 29461 29462 /** 29463 * Checks if `value` is classified as a `WeakMap` object. 29464 * 29465 * @static 29466 * @memberOf _ 29467 * @since 4.3.0 29468 * @category Lang 29469 * @param {*} value The value to check. 29470 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. 29471 * @example 29472 * 29473 * _.isWeakMap(new WeakMap); 29474 * // => true 29475 * 29476 * _.isWeakMap(new Map); 29477 * // => false 29478 */ 29479 function isWeakMap(value) { 29480 return isObjectLike(value) && getTag(value) == weakMapTag; 29481 } 29482 29483 /** 29484 * Checks if `value` is classified as a `WeakSet` object. 29485 * 29486 * @static 29487 * @memberOf _ 29488 * @since 4.3.0 29489 * @category Lang 29490 * @param {*} value The value to check. 29491 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. 29492 * @example 29493 * 29494 * _.isWeakSet(new WeakSet); 29495 * // => true 29496 * 29497 * _.isWeakSet(new Set); 29498 * // => false 29499 */ 29500 function isWeakSet(value) { 29501 return isObjectLike(value) && baseGetTag(value) == weakSetTag; 29502 } 29503 29504 /** 29505 * Checks if `value` is less than `other`. 29506 * 29507 * @static 29508 * @memberOf _ 29509 * @since 3.9.0 29510 * @category Lang 29511 * @param {*} value The value to compare. 29512 * @param {*} other The other value to compare. 29513 * @returns {boolean} Returns `true` if `value` is less than `other`, 29514 * else `false`. 29515 * @see _.gt 29516 * @example 29517 * 29518 * _.lt(1, 3); 29519 * // => true 29520 * 29521 * _.lt(3, 3); 29522 * // => false 29523 * 29524 * _.lt(3, 1); 29525 * // => false 29526 */ 29527 var lt = createRelationalOperation(baseLt); 29528 29529 /** 29530 * Checks if `value` is less than or equal to `other`. 29531 * 29532 * @static 29533 * @memberOf _ 29534 * @since 3.9.0 29535 * @category Lang 29536 * @param {*} value The value to compare. 29537 * @param {*} other The other value to compare. 29538 * @returns {boolean} Returns `true` if `value` is less than or equal to 29539 * `other`, else `false`. 29540 * @see _.gte 29541 * @example 29542 * 29543 * _.lte(1, 3); 29544 * // => true 29545 * 29546 * _.lte(3, 3); 29547 * // => true 29548 * 29549 * _.lte(3, 1); 29550 * // => false 29551 */ 29552 var lte = createRelationalOperation(function(value, other) { 29553 return value <= other; 29554 }); 29555 29556 /** 29557 * Converts `value` to an array. 29558 * 29559 * @static 29560 * @since 0.1.0 29561 * @memberOf _ 29562 * @category Lang 29563 * @param {*} value The value to convert. 29564 * @returns {Array} Returns the converted array. 29565 * @example 29566 * 29567 * _.toArray({ 'a': 1, 'b': 2 }); 29568 * // => [1, 2] 29569 * 29570 * _.toArray('abc'); 29571 * // => ['a', 'b', 'c'] 29572 * 29573 * _.toArray(1); 29574 * // => [] 29575 * 29576 * _.toArray(null); 29577 * // => [] 29578 */ 29579 function toArray(value) { 29580 if (!value) { 29581 return []; 29582 } 29583 if (isArrayLike(value)) { 29584 return isString(value) ? stringToArray(value) : copyArray(value); 29585 } 29586 if (symIterator && value[symIterator]) { 29587 return iteratorToArray(value[symIterator]()); 29588 } 29589 var tag = getTag(value), 29590 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); 29591 29592 return func(value); 29593 } 29594 29595 /** 29596 * Converts `value` to a finite number. 29597 * 29598 * @static 29599 * @memberOf _ 29600 * @since 4.12.0 29601 * @category Lang 29602 * @param {*} value The value to convert. 29603 * @returns {number} Returns the converted number. 29604 * @example 29605 * 29606 * _.toFinite(3.2); 29607 * // => 3.2 29608 * 29609 * _.toFinite(Number.MIN_VALUE); 29610 * // => 5e-324 29611 * 29612 * _.toFinite(Infinity); 29613 * // => 1.7976931348623157e+308 29614 * 29615 * _.toFinite('3.2'); 29616 * // => 3.2 29617 */ 29618 function toFinite(value) { 29619 if (!value) { 29620 return value === 0 ? value : 0; 29621 } 29622 value = toNumber(value); 29623 if (value === INFINITY || value === -INFINITY) { 29624 var sign = (value < 0 ? -1 : 1); 29625 return sign * MAX_INTEGER; 29626 } 29627 return value === value ? value : 0; 29628 } 29629 29630 /** 29631 * Converts `value` to an integer. 29632 * 29633 * **Note:** This method is loosely based on 29634 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). 29635 * 29636 * @static 29637 * @memberOf _ 29638 * @since 4.0.0 29639 * @category Lang 29640 * @param {*} value The value to convert. 29641 * @returns {number} Returns the converted integer. 29642 * @example 29643 * 29644 * _.toInteger(3.2); 29645 * // => 3 29646 * 29647 * _.toInteger(Number.MIN_VALUE); 29648 * // => 0 29649 * 29650 * _.toInteger(Infinity); 29651 * // => 1.7976931348623157e+308 29652 * 29653 * _.toInteger('3.2'); 29654 * // => 3 29655 */ 29656 function toInteger(value) { 29657 var result = toFinite(value), 29658 remainder = result % 1; 29659 29660 return result === result ? (remainder ? result - remainder : result) : 0; 29661 } 29662 29663 /** 29664 * Converts `value` to an integer suitable for use as the length of an 29665 * array-like object. 29666 * 29667 * **Note:** This method is based on 29668 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 29669 * 29670 * @static 29671 * @memberOf _ 29672 * @since 4.0.0 29673 * @category Lang 29674 * @param {*} value The value to convert. 29675 * @returns {number} Returns the converted integer. 29676 * @example 29677 * 29678 * _.toLength(3.2); 29679 * // => 3 29680 * 29681 * _.toLength(Number.MIN_VALUE); 29682 * // => 0 29683 * 29684 * _.toLength(Infinity); 29685 * // => 4294967295 29686 * 29687 * _.toLength('3.2'); 29688 * // => 3 29689 */ 29690 function toLength(value) { 29691 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; 29692 } 29693 29694 /** 29695 * Converts `value` to a number. 29696 * 29697 * @static 29698 * @memberOf _ 29699 * @since 4.0.0 29700 * @category Lang 29701 * @param {*} value The value to process. 29702 * @returns {number} Returns the number. 29703 * @example 29704 * 29705 * _.toNumber(3.2); 29706 * // => 3.2 29707 * 29708 * _.toNumber(Number.MIN_VALUE); 29709 * // => 5e-324 29710 * 29711 * _.toNumber(Infinity); 29712 * // => Infinity 29713 * 29714 * _.toNumber('3.2'); 29715 * // => 3.2 29716 */ 29717 function toNumber(value) { 29718 if (typeof value == 'number') { 29719 return value; 29720 } 29721 if (isSymbol(value)) { 29722 return NAN; 29723 } 29724 if (isObject(value)) { 29725 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 29726 value = isObject(other) ? (other + '') : other; 29727 } 29728 if (typeof value != 'string') { 29729 return value === 0 ? value : +value; 29730 } 29731 value = value.replace(reTrim, ''); 29732 var isBinary = reIsBinary.test(value); 29733 return (isBinary || reIsOctal.test(value)) 29734 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 29735 : (reIsBadHex.test(value) ? NAN : +value); 29736 } 29737 29738 /** 29739 * Converts `value` to a plain object flattening inherited enumerable string 29740 * keyed properties of `value` to own properties of the plain object. 29741 * 29742 * @static 29743 * @memberOf _ 29744 * @since 3.0.0 29745 * @category Lang 29746 * @param {*} value The value to convert. 29747 * @returns {Object} Returns the converted plain object. 29748 * @example 29749 * 29750 * function Foo() { 29751 * this.b = 2; 29752 * } 29753 * 29754 * Foo.prototype.c = 3; 29755 * 29756 * _.assign({ 'a': 1 }, new Foo); 29757 * // => { 'a': 1, 'b': 2 } 29758 * 29759 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 29760 * // => { 'a': 1, 'b': 2, 'c': 3 } 29761 */ 29762 function toPlainObject(value) { 29763 return copyObject(value, keysIn(value)); 29764 } 29765 29766 /** 29767 * Converts `value` to a safe integer. A safe integer can be compared and 29768 * represented correctly. 29769 * 29770 * @static 29771 * @memberOf _ 29772 * @since 4.0.0 29773 * @category Lang 29774 * @param {*} value The value to convert. 29775 * @returns {number} Returns the converted integer. 29776 * @example 29777 * 29778 * _.toSafeInteger(3.2); 29779 * // => 3 29780 * 29781 * _.toSafeInteger(Number.MIN_VALUE); 29782 * // => 0 29783 * 29784 * _.toSafeInteger(Infinity); 29785 * // => 9007199254740991 29786 * 29787 * _.toSafeInteger('3.2'); 29788 * // => 3 29789 */ 29790 function toSafeInteger(value) { 29791 return value 29792 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) 29793 : (value === 0 ? value : 0); 29794 } 29795 29796 /** 29797 * Converts `value` to a string. An empty string is returned for `null` 29798 * and `undefined` values. The sign of `-0` is preserved. 29799 * 29800 * @static 29801 * @memberOf _ 29802 * @since 4.0.0 29803 * @category Lang 29804 * @param {*} value The value to convert. 29805 * @returns {string} Returns the converted string. 29806 * @example 29807 * 29808 * _.toString(null); 29809 * // => '' 29810 * 29811 * _.toString(-0); 29812 * // => '-0' 29813 * 29814 * _.toString([1, 2, 3]); 29815 * // => '1,2,3' 29816 */ 29817 function toString(value) { 29818 return value == null ? '' : baseToString(value); 29819 } 29820 29821 /*------------------------------------------------------------------------*/ 29822 29823 /** 29824 * Assigns own enumerable string keyed properties of source objects to the 29825 * destination object. Source objects are applied from left to right. 29826 * Subsequent sources overwrite property assignments of previous sources. 29827 * 29828 * **Note:** This method mutates `object` and is loosely based on 29829 * [`Object.assign`](https://mdn.io/Object/assign). 29830 * 29831 * @static 29832 * @memberOf _ 29833 * @since 0.10.0 29834 * @category Object 29835 * @param {Object} object The destination object. 29836 * @param {...Object} [sources] The source objects. 29837 * @returns {Object} Returns `object`. 29838 * @see _.assignIn 29839 * @example 29840 * 29841 * function Foo() { 29842 * this.a = 1; 29843 * } 29844 * 29845 * function Bar() { 29846 * this.c = 3; 29847 * } 29848 * 29849 * Foo.prototype.b = 2; 29850 * Bar.prototype.d = 4; 29851 * 29852 * _.assign({ 'a': 0 }, new Foo, new Bar); 29853 * // => { 'a': 1, 'c': 3 } 29854 */ 29855 var assign = createAssigner(function(object, source) { 29856 if (isPrototype(source) || isArrayLike(source)) { 29857 copyObject(source, keys(source), object); 29858 return; 29859 } 29860 for (var key in source) { 29861 if (hasOwnProperty.call(source, key)) { 29862 assignValue(object, key, source[key]); 29863 } 29864 } 29865 }); 29866 29867 /** 29868 * This method is like `_.assign` except that it iterates over own and 29869 * inherited source properties. 29870 * 29871 * **Note:** This method mutates `object`. 29872 * 29873 * @static 29874 * @memberOf _ 29875 * @since 4.0.0 29876 * @alias extend 29877 * @category Object 29878 * @param {Object} object The destination object. 29879 * @param {...Object} [sources] The source objects. 29880 * @returns {Object} Returns `object`. 29881 * @see _.assign 29882 * @example 29883 * 29884 * function Foo() { 29885 * this.a = 1; 29886 * } 29887 * 29888 * function Bar() { 29889 * this.c = 3; 29890 * } 29891 * 29892 * Foo.prototype.b = 2; 29893 * Bar.prototype.d = 4; 29894 * 29895 * _.assignIn({ 'a': 0 }, new Foo, new Bar); 29896 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } 29897 */ 29898 var assignIn = createAssigner(function(object, source) { 29899 copyObject(source, keysIn(source), object); 29900 }); 29901 29902 /** 29903 * This method is like `_.assignIn` except that it accepts `customizer` 29904 * which is invoked to produce the assigned values. If `customizer` returns 29905 * `undefined`, assignment is handled by the method instead. The `customizer` 29906 * is invoked with five arguments: (objValue, srcValue, key, object, source). 29907 * 29908 * **Note:** This method mutates `object`. 29909 * 29910 * @static 29911 * @memberOf _ 29912 * @since 4.0.0 29913 * @alias extendWith 29914 * @category Object 29915 * @param {Object} object The destination object. 29916 * @param {...Object} sources The source objects. 29917 * @param {Function} [customizer] The function to customize assigned values. 29918 * @returns {Object} Returns `object`. 29919 * @see _.assignWith 29920 * @example 29921 * 29922 * function customizer(objValue, srcValue) { 29923 * return _.isUndefined(objValue) ? srcValue : objValue; 29924 * } 29925 * 29926 * var defaults = _.partialRight(_.assignInWith, customizer); 29927 * 29928 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 29929 * // => { 'a': 1, 'b': 2 } 29930 */ 29931 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { 29932 copyObject(source, keysIn(source), object, customizer); 29933 }); 29934 29935 /** 29936 * This method is like `_.assign` except that it accepts `customizer` 29937 * which is invoked to produce the assigned values. If `customizer` returns 29938 * `undefined`, assignment is handled by the method instead. The `customizer` 29939 * is invoked with five arguments: (objValue, srcValue, key, object, source). 29940 * 29941 * **Note:** This method mutates `object`. 29942 * 29943 * @static 29944 * @memberOf _ 29945 * @since 4.0.0 29946 * @category Object 29947 * @param {Object} object The destination object. 29948 * @param {...Object} sources The source objects. 29949 * @param {Function} [customizer] The function to customize assigned values. 29950 * @returns {Object} Returns `object`. 29951 * @see _.assignInWith 29952 * @example 29953 * 29954 * function customizer(objValue, srcValue) { 29955 * return _.isUndefined(objValue) ? srcValue : objValue; 29956 * } 29957 * 29958 * var defaults = _.partialRight(_.assignWith, customizer); 29959 * 29960 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 29961 * // => { 'a': 1, 'b': 2 } 29962 */ 29963 var assignWith = createAssigner(function(object, source, srcIndex, customizer) { 29964 copyObject(source, keys(source), object, customizer); 29965 }); 29966 29967 /** 29968 * Creates an array of values corresponding to `paths` of `object`. 29969 * 29970 * @static 29971 * @memberOf _ 29972 * @since 1.0.0 29973 * @category Object 29974 * @param {Object} object The object to iterate over. 29975 * @param {...(string|string[])} [paths] The property paths to pick. 29976 * @returns {Array} Returns the picked values. 29977 * @example 29978 * 29979 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 29980 * 29981 * _.at(object, ['a[0].b.c', 'a[1]']); 29982 * // => [3, 4] 29983 */ 29984 var at = flatRest(baseAt); 29985 29986 /** 29987 * Creates an object that inherits from the `prototype` object. If a 29988 * `properties` object is given, its own enumerable string keyed properties 29989 * are assigned to the created object. 29990 * 29991 * @static 29992 * @memberOf _ 29993 * @since 2.3.0 29994 * @category Object 29995 * @param {Object} prototype The object to inherit from. 29996 * @param {Object} [properties] The properties to assign to the object. 29997 * @returns {Object} Returns the new object. 29998 * @example 29999 * 30000 * function Shape() { 30001 * this.x = 0; 30002 * this.y = 0; 30003 * } 30004 * 30005 * function Circle() { 30006 * Shape.call(this); 30007 * } 30008 * 30009 * Circle.prototype = _.create(Shape.prototype, { 30010 * 'constructor': Circle 30011 * }); 30012 * 30013 * var circle = new Circle; 30014 * circle instanceof Circle; 30015 * // => true 30016 * 30017 * circle instanceof Shape; 30018 * // => true 30019 */ 30020 function create(prototype, properties) { 30021 var result = baseCreate(prototype); 30022 return properties == null ? result : baseAssign(result, properties); 30023 } 30024 30025 /** 30026 * Assigns own and inherited enumerable string keyed properties of source 30027 * objects to the destination object for all destination properties that 30028 * resolve to `undefined`. Source objects are applied from left to right. 30029 * Once a property is set, additional values of the same property are ignored. 30030 * 30031 * **Note:** This method mutates `object`. 30032 * 30033 * @static 30034 * @since 0.1.0 30035 * @memberOf _ 30036 * @category Object 30037 * @param {Object} object The destination object. 30038 * @param {...Object} [sources] The source objects. 30039 * @returns {Object} Returns `object`. 30040 * @see _.defaultsDeep 30041 * @example 30042 * 30043 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 30044 * // => { 'a': 1, 'b': 2 } 30045 */ 30046 var defaults = baseRest(function(object, sources) { 30047 object = Object(object); 30048 30049 var index = -1; 30050 var length = sources.length; 30051 var guard = length > 2 ? sources[2] : undefined; 30052 30053 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 30054 length = 1; 30055 } 30056 30057 while (++index < length) { 30058 var source = sources[index]; 30059 var props = keysIn(source); 30060 var propsIndex = -1; 30061 var propsLength = props.length; 30062 30063 while (++propsIndex < propsLength) { 30064 var key = props[propsIndex]; 30065 var value = object[key]; 30066 30067 if (value === undefined || 30068 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { 30069 object[key] = source[key]; 30070 } 30071 } 30072 } 30073 30074 return object; 30075 }); 30076 30077 /** 30078 * This method is like `_.defaults` except that it recursively assigns 30079 * default properties. 30080 * 30081 * **Note:** This method mutates `object`. 30082 * 30083 * @static 30084 * @memberOf _ 30085 * @since 3.10.0 30086 * @category Object 30087 * @param {Object} object The destination object. 30088 * @param {...Object} [sources] The source objects. 30089 * @returns {Object} Returns `object`. 30090 * @see _.defaults 30091 * @example 30092 * 30093 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); 30094 * // => { 'a': { 'b': 2, 'c': 3 } } 30095 */ 30096 var defaultsDeep = baseRest(function(args) { 30097 args.push(undefined, customDefaultsMerge); 30098 return apply(mergeWith, undefined, args); 30099 }); 30100 30101 /** 30102 * This method is like `_.find` except that it returns the key of the first 30103 * element `predicate` returns truthy for instead of the element itself. 30104 * 30105 * @static 30106 * @memberOf _ 30107 * @since 1.1.0 30108 * @category Object 30109 * @param {Object} object The object to inspect. 30110 * @param {Function} [predicate=_.identity] The function invoked per iteration. 30111 * @returns {string|undefined} Returns the key of the matched element, 30112 * else `undefined`. 30113 * @example 30114 * 30115 * var users = { 30116 * 'barney': { 'age': 36, 'active': true }, 30117 * 'fred': { 'age': 40, 'active': false }, 30118 * 'pebbles': { 'age': 1, 'active': true } 30119 * }; 30120 * 30121 * _.findKey(users, function(o) { return o.age < 40; }); 30122 * // => 'barney' (iteration order is not guaranteed) 30123 * 30124 * // The `_.matches` iteratee shorthand. 30125 * _.findKey(users, { 'age': 1, 'active': true }); 30126 * // => 'pebbles' 30127 * 30128 * // The `_.matchesProperty` iteratee shorthand. 30129 * _.findKey(users, ['active', false]); 30130 * // => 'fred' 30131 * 30132 * // The `_.property` iteratee shorthand. 30133 * _.findKey(users, 'active'); 30134 * // => 'barney' 30135 */ 30136 function findKey(object, predicate) { 30137 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); 30138 } 30139 30140 /** 30141 * This method is like `_.findKey` except that it iterates over elements of 30142 * a collection in the opposite order. 30143 * 30144 * @static 30145 * @memberOf _ 30146 * @since 2.0.0 30147 * @category Object 30148 * @param {Object} object The object to inspect. 30149 * @param {Function} [predicate=_.identity] The function invoked per iteration. 30150 * @returns {string|undefined} Returns the key of the matched element, 30151 * else `undefined`. 30152 * @example 30153 * 30154 * var users = { 30155 * 'barney': { 'age': 36, 'active': true }, 30156 * 'fred': { 'age': 40, 'active': false }, 30157 * 'pebbles': { 'age': 1, 'active': true } 30158 * }; 30159 * 30160 * _.findLastKey(users, function(o) { return o.age < 40; }); 30161 * // => returns 'pebbles' assuming `_.findKey` returns 'barney' 30162 * 30163 * // The `_.matches` iteratee shorthand. 30164 * _.findLastKey(users, { 'age': 36, 'active': true }); 30165 * // => 'barney' 30166 * 30167 * // The `_.matchesProperty` iteratee shorthand. 30168 * _.findLastKey(users, ['active', false]); 30169 * // => 'fred' 30170 * 30171 * // The `_.property` iteratee shorthand. 30172 * _.findLastKey(users, 'active'); 30173 * // => 'pebbles' 30174 */ 30175 function findLastKey(object, predicate) { 30176 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); 30177 } 30178 30179 /** 30180 * Iterates over own and inherited enumerable string keyed properties of an 30181 * object and invokes `iteratee` for each property. The iteratee is invoked 30182 * with three arguments: (value, key, object). Iteratee functions may exit 30183 * iteration early by explicitly returning `false`. 30184 * 30185 * @static 30186 * @memberOf _ 30187 * @since 0.3.0 30188 * @category Object 30189 * @param {Object} object The object to iterate over. 30190 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 30191 * @returns {Object} Returns `object`. 30192 * @see _.forInRight 30193 * @example 30194 * 30195 * function Foo() { 30196 * this.a = 1; 30197 * this.b = 2; 30198 * } 30199 * 30200 * Foo.prototype.c = 3; 30201 * 30202 * _.forIn(new Foo, function(value, key) { 30203 * console.log(key); 30204 * }); 30205 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). 30206 */ 30207 function forIn(object, iteratee) { 30208 return object == null 30209 ? object 30210 : baseFor(object, getIteratee(iteratee, 3), keysIn); 30211 } 30212 30213 /** 30214 * This method is like `_.forIn` except that it iterates over properties of 30215 * `object` in the opposite order. 30216 * 30217 * @static 30218 * @memberOf _ 30219 * @since 2.0.0 30220 * @category Object 30221 * @param {Object} object The object to iterate over. 30222 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 30223 * @returns {Object} Returns `object`. 30224 * @see _.forIn 30225 * @example 30226 * 30227 * function Foo() { 30228 * this.a = 1; 30229 * this.b = 2; 30230 * } 30231 * 30232 * Foo.prototype.c = 3; 30233 * 30234 * _.forInRight(new Foo, function(value, key) { 30235 * console.log(key); 30236 * }); 30237 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. 30238 */ 30239 function forInRight(object, iteratee) { 30240 return object == null 30241 ? object 30242 : baseForRight(object, getIteratee(iteratee, 3), keysIn); 30243 } 30244 30245 /** 30246 * Iterates over own enumerable string keyed properties of an object and 30247 * invokes `iteratee` for each property. The iteratee is invoked with three 30248 * arguments: (value, key, object). Iteratee functions may exit iteration 30249 * early by explicitly returning `false`. 30250 * 30251 * @static 30252 * @memberOf _ 30253 * @since 0.3.0 30254 * @category Object 30255 * @param {Object} object The object to iterate over. 30256 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 30257 * @returns {Object} Returns `object`. 30258 * @see _.forOwnRight 30259 * @example 30260 * 30261 * function Foo() { 30262 * this.a = 1; 30263 * this.b = 2; 30264 * } 30265 * 30266 * Foo.prototype.c = 3; 30267 * 30268 * _.forOwn(new Foo, function(value, key) { 30269 * console.log(key); 30270 * }); 30271 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 30272 */ 30273 function forOwn(object, iteratee) { 30274 return object && baseForOwn(object, getIteratee(iteratee, 3)); 30275 } 30276 30277 /** 30278 * This method is like `_.forOwn` except that it iterates over properties of 30279 * `object` in the opposite order. 30280 * 30281 * @static 30282 * @memberOf _ 30283 * @since 2.0.0 30284 * @category Object 30285 * @param {Object} object The object to iterate over. 30286 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 30287 * @returns {Object} Returns `object`. 30288 * @see _.forOwn 30289 * @example 30290 * 30291 * function Foo() { 30292 * this.a = 1; 30293 * this.b = 2; 30294 * } 30295 * 30296 * Foo.prototype.c = 3; 30297 * 30298 * _.forOwnRight(new Foo, function(value, key) { 30299 * console.log(key); 30300 * }); 30301 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. 30302 */ 30303 function forOwnRight(object, iteratee) { 30304 return object && baseForOwnRight(object, getIteratee(iteratee, 3)); 30305 } 30306 30307 /** 30308 * Creates an array of function property names from own enumerable properties 30309 * of `object`. 30310 * 30311 * @static 30312 * @since 0.1.0 30313 * @memberOf _ 30314 * @category Object 30315 * @param {Object} object The object to inspect. 30316 * @returns {Array} Returns the function names. 30317 * @see _.functionsIn 30318 * @example 30319 * 30320 * function Foo() { 30321 * this.a = _.constant('a'); 30322 * this.b = _.constant('b'); 30323 * } 30324 * 30325 * Foo.prototype.c = _.constant('c'); 30326 * 30327 * _.functions(new Foo); 30328 * // => ['a', 'b'] 30329 */ 30330 function functions(object) { 30331 return object == null ? [] : baseFunctions(object, keys(object)); 30332 } 30333 30334 /** 30335 * Creates an array of function property names from own and inherited 30336 * enumerable properties of `object`. 30337 * 30338 * @static 30339 * @memberOf _ 30340 * @since 4.0.0 30341 * @category Object 30342 * @param {Object} object The object to inspect. 30343 * @returns {Array} Returns the function names. 30344 * @see _.functions 30345 * @example 30346 * 30347 * function Foo() { 30348 * this.a = _.constant('a'); 30349 * this.b = _.constant('b'); 30350 * } 30351 * 30352 * Foo.prototype.c = _.constant('c'); 30353 * 30354 * _.functionsIn(new Foo); 30355 * // => ['a', 'b', 'c'] 30356 */ 30357 function functionsIn(object) { 30358 return object == null ? [] : baseFunctions(object, keysIn(object)); 30359 } 30360 30361 /** 30362 * Gets the value at `path` of `object`. If the resolved value is 30363 * `undefined`, the `defaultValue` is returned in its place. 30364 * 30365 * @static 30366 * @memberOf _ 30367 * @since 3.7.0 30368 * @category Object 30369 * @param {Object} object The object to query. 30370 * @param {Array|string} path The path of the property to get. 30371 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 30372 * @returns {*} Returns the resolved value. 30373 * @example 30374 * 30375 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 30376 * 30377 * _.get(object, 'a[0].b.c'); 30378 * // => 3 30379 * 30380 * _.get(object, ['a', '0', 'b', 'c']); 30381 * // => 3 30382 * 30383 * _.get(object, 'a.b.c', 'default'); 30384 * // => 'default' 30385 */ 30386 function get(object, path, defaultValue) { 30387 var result = object == null ? undefined : baseGet(object, path); 30388 return result === undefined ? defaultValue : result; 30389 } 30390 30391 /** 30392 * Checks if `path` is a direct property of `object`. 30393 * 30394 * @static 30395 * @since 0.1.0 30396 * @memberOf _ 30397 * @category Object 30398 * @param {Object} object The object to query. 30399 * @param {Array|string} path The path to check. 30400 * @returns {boolean} Returns `true` if `path` exists, else `false`. 30401 * @example 30402 * 30403 * var object = { 'a': { 'b': 2 } }; 30404 * var other = _.create({ 'a': _.create({ 'b': 2 }) }); 30405 * 30406 * _.has(object, 'a'); 30407 * // => true 30408 * 30409 * _.has(object, 'a.b'); 30410 * // => true 30411 * 30412 * _.has(object, ['a', 'b']); 30413 * // => true 30414 * 30415 * _.has(other, 'a'); 30416 * // => false 30417 */ 30418 function has(object, path) { 30419 return object != null && hasPath(object, path, baseHas); 30420 } 30421 30422 /** 30423 * Checks if `path` is a direct or inherited property of `object`. 30424 * 30425 * @static 30426 * @memberOf _ 30427 * @since 4.0.0 30428 * @category Object 30429 * @param {Object} object The object to query. 30430 * @param {Array|string} path The path to check. 30431 * @returns {boolean} Returns `true` if `path` exists, else `false`. 30432 * @example 30433 * 30434 * var object = _.create({ 'a': _.create({ 'b': 2 }) }); 30435 * 30436 * _.hasIn(object, 'a'); 30437 * // => true 30438 * 30439 * _.hasIn(object, 'a.b'); 30440 * // => true 30441 * 30442 * _.hasIn(object, ['a', 'b']); 30443 * // => true 30444 * 30445 * _.hasIn(object, 'b'); 30446 * // => false 30447 */ 30448 function hasIn(object, path) { 30449 return object != null && hasPath(object, path, baseHasIn); 30450 } 30451 30452 /** 30453 * Creates an object composed of the inverted keys and values of `object`. 30454 * If `object` contains duplicate values, subsequent values overwrite 30455 * property assignments of previous values. 30456 * 30457 * @static 30458 * @memberOf _ 30459 * @since 0.7.0 30460 * @category Object 30461 * @param {Object} object The object to invert. 30462 * @returns {Object} Returns the new inverted object. 30463 * @example 30464 * 30465 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 30466 * 30467 * _.invert(object); 30468 * // => { '1': 'c', '2': 'b' } 30469 */ 30470 var invert = createInverter(function(result, value, key) { 30471 if (value != null && 30472 typeof value.toString != 'function') { 30473 value = nativeObjectToString.call(value); 30474 } 30475 30476 result[value] = key; 30477 }, constant(identity)); 30478 30479 /** 30480 * This method is like `_.invert` except that the inverted object is generated 30481 * from the results of running each element of `object` thru `iteratee`. The 30482 * corresponding inverted value of each inverted key is an array of keys 30483 * responsible for generating the inverted value. The iteratee is invoked 30484 * with one argument: (value). 30485 * 30486 * @static 30487 * @memberOf _ 30488 * @since 4.1.0 30489 * @category Object 30490 * @param {Object} object The object to invert. 30491 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 30492 * @returns {Object} Returns the new inverted object. 30493 * @example 30494 * 30495 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 30496 * 30497 * _.invertBy(object); 30498 * // => { '1': ['a', 'c'], '2': ['b'] } 30499 * 30500 * _.invertBy(object, function(value) { 30501 * return 'group' + value; 30502 * }); 30503 * // => { 'group1': ['a', 'c'], 'group2': ['b'] } 30504 */ 30505 var invertBy = createInverter(function(result, value, key) { 30506 if (value != null && 30507 typeof value.toString != 'function') { 30508 value = nativeObjectToString.call(value); 30509 } 30510 30511 if (hasOwnProperty.call(result, value)) { 30512 result[value].push(key); 30513 } else { 30514 result[value] = [key]; 30515 } 30516 }, getIteratee); 30517 30518 /** 30519 * Invokes the method at `path` of `object`. 30520 * 30521 * @static 30522 * @memberOf _ 30523 * @since 4.0.0 30524 * @category Object 30525 * @param {Object} object The object to query. 30526 * @param {Array|string} path The path of the method to invoke. 30527 * @param {...*} [args] The arguments to invoke the method with. 30528 * @returns {*} Returns the result of the invoked method. 30529 * @example 30530 * 30531 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 30532 * 30533 * _.invoke(object, 'a[0].b.c.slice', 1, 3); 30534 * // => [2, 3] 30535 */ 30536 var invoke = baseRest(baseInvoke); 30537 30538 /** 30539 * Creates an array of the own enumerable property names of `object`. 30540 * 30541 * **Note:** Non-object values are coerced to objects. See the 30542 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 30543 * for more details. 30544 * 30545 * @static 30546 * @since 0.1.0 30547 * @memberOf _ 30548 * @category Object 30549 * @param {Object} object The object to query. 30550 * @returns {Array} Returns the array of property names. 30551 * @example 30552 * 30553 * function Foo() { 30554 * this.a = 1; 30555 * this.b = 2; 30556 * } 30557 * 30558 * Foo.prototype.c = 3; 30559 * 30560 * _.keys(new Foo); 30561 * // => ['a', 'b'] (iteration order is not guaranteed) 30562 * 30563 * _.keys('hi'); 30564 * // => ['0', '1'] 30565 */ 30566 function keys(object) { 30567 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); 30568 } 30569 30570 /** 30571 * Creates an array of the own and inherited enumerable property names of `object`. 30572 * 30573 * **Note:** Non-object values are coerced to objects. 30574 * 30575 * @static 30576 * @memberOf _ 30577 * @since 3.0.0 30578 * @category Object 30579 * @param {Object} object The object to query. 30580 * @returns {Array} Returns the array of property names. 30581 * @example 30582 * 30583 * function Foo() { 30584 * this.a = 1; 30585 * this.b = 2; 30586 * } 30587 * 30588 * Foo.prototype.c = 3; 30589 * 30590 * _.keysIn(new Foo); 30591 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 30592 */ 30593 function keysIn(object) { 30594 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); 30595 } 30596 30597 /** 30598 * The opposite of `_.mapValues`; this method creates an object with the 30599 * same values as `object` and keys generated by running each own enumerable 30600 * string keyed property of `object` thru `iteratee`. The iteratee is invoked 30601 * with three arguments: (value, key, object). 30602 * 30603 * @static 30604 * @memberOf _ 30605 * @since 3.8.0 30606 * @category Object 30607 * @param {Object} object The object to iterate over. 30608 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 30609 * @returns {Object} Returns the new mapped object. 30610 * @see _.mapValues 30611 * @example 30612 * 30613 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 30614 * return key + value; 30615 * }); 30616 * // => { 'a1': 1, 'b2': 2 } 30617 */ 30618 function mapKeys(object, iteratee) { 30619 var result = {}; 30620 iteratee = getIteratee(iteratee, 3); 30621 30622 baseForOwn(object, function(value, key, object) { 30623 baseAssignValue(result, iteratee(value, key, object), value); 30624 }); 30625 return result; 30626 } 30627 30628 /** 30629 * Creates an object with the same keys as `object` and values generated 30630 * by running each own enumerable string keyed property of `object` thru 30631 * `iteratee`. The iteratee is invoked with three arguments: 30632 * (value, key, object). 30633 * 30634 * @static 30635 * @memberOf _ 30636 * @since 2.4.0 30637 * @category Object 30638 * @param {Object} object The object to iterate over. 30639 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 30640 * @returns {Object} Returns the new mapped object. 30641 * @see _.mapKeys 30642 * @example 30643 * 30644 * var users = { 30645 * 'fred': { 'user': 'fred', 'age': 40 }, 30646 * 'pebbles': { 'user': 'pebbles', 'age': 1 } 30647 * }; 30648 * 30649 * _.mapValues(users, function(o) { return o.age; }); 30650 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 30651 * 30652 * // The `_.property` iteratee shorthand. 30653 * _.mapValues(users, 'age'); 30654 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 30655 */ 30656 function mapValues(object, iteratee) { 30657 var result = {}; 30658 iteratee = getIteratee(iteratee, 3); 30659 30660 baseForOwn(object, function(value, key, object) { 30661 baseAssignValue(result, key, iteratee(value, key, object)); 30662 }); 30663 return result; 30664 } 30665 30666 /** 30667 * This method is like `_.assign` except that it recursively merges own and 30668 * inherited enumerable string keyed properties of source objects into the 30669 * destination object. Source properties that resolve to `undefined` are 30670 * skipped if a destination value exists. Array and plain object properties 30671 * are merged recursively. Other objects and value types are overridden by 30672 * assignment. Source objects are applied from left to right. Subsequent 30673 * sources overwrite property assignments of previous sources. 30674 * 30675 * **Note:** This method mutates `object`. 30676 * 30677 * @static 30678 * @memberOf _ 30679 * @since 0.5.0 30680 * @category Object 30681 * @param {Object} object The destination object. 30682 * @param {...Object} [sources] The source objects. 30683 * @returns {Object} Returns `object`. 30684 * @example 30685 * 30686 * var object = { 30687 * 'a': [{ 'b': 2 }, { 'd': 4 }] 30688 * }; 30689 * 30690 * var other = { 30691 * 'a': [{ 'c': 3 }, { 'e': 5 }] 30692 * }; 30693 * 30694 * _.merge(object, other); 30695 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } 30696 */ 30697 var merge = createAssigner(function(object, source, srcIndex) { 30698 baseMerge(object, source, srcIndex); 30699 }); 30700 30701 /** 30702 * This method is like `_.merge` except that it accepts `customizer` which 30703 * is invoked to produce the merged values of the destination and source 30704 * properties. If `customizer` returns `undefined`, merging is handled by the 30705 * method instead. The `customizer` is invoked with six arguments: 30706 * (objValue, srcValue, key, object, source, stack). 30707 * 30708 * **Note:** This method mutates `object`. 30709 * 30710 * @static 30711 * @memberOf _ 30712 * @since 4.0.0 30713 * @category Object 30714 * @param {Object} object The destination object. 30715 * @param {...Object} sources The source objects. 30716 * @param {Function} customizer The function to customize assigned values. 30717 * @returns {Object} Returns `object`. 30718 * @example 30719 * 30720 * function customizer(objValue, srcValue) { 30721 * if (_.isArray(objValue)) { 30722 * return objValue.concat(srcValue); 30723 * } 30724 * } 30725 * 30726 * var object = { 'a': [1], 'b': [2] }; 30727 * var other = { 'a': [3], 'b': [4] }; 30728 * 30729 * _.mergeWith(object, other, customizer); 30730 * // => { 'a': [1, 3], 'b': [2, 4] } 30731 */ 30732 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { 30733 baseMerge(object, source, srcIndex, customizer); 30734 }); 30735 30736 /** 30737 * The opposite of `_.pick`; this method creates an object composed of the 30738 * own and inherited enumerable property paths of `object` that are not omitted. 30739 * 30740 * **Note:** This method is considerably slower than `_.pick`. 30741 * 30742 * @static 30743 * @since 0.1.0 30744 * @memberOf _ 30745 * @category Object 30746 * @param {Object} object The source object. 30747 * @param {...(string|string[])} [paths] The property paths to omit. 30748 * @returns {Object} Returns the new object. 30749 * @example 30750 * 30751 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 30752 * 30753 * _.omit(object, ['a', 'c']); 30754 * // => { 'b': '2' } 30755 */ 30756 var omit = flatRest(function(object, paths) { 30757 var result = {}; 30758 if (object == null) { 30759 return result; 30760 } 30761 var isDeep = false; 30762 paths = arrayMap(paths, function(path) { 30763 path = castPath(path, object); 30764 isDeep || (isDeep = path.length > 1); 30765 return path; 30766 }); 30767 copyObject(object, getAllKeysIn(object), result); 30768 if (isDeep) { 30769 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); 30770 } 30771 var length = paths.length; 30772 while (length--) { 30773 baseUnset(result, paths[length]); 30774 } 30775 return result; 30776 }); 30777 30778 /** 30779 * The opposite of `_.pickBy`; this method creates an object composed of 30780 * the own and inherited enumerable string keyed properties of `object` that 30781 * `predicate` doesn't return truthy for. The predicate is invoked with two 30782 * arguments: (value, key). 30783 * 30784 * @static 30785 * @memberOf _ 30786 * @since 4.0.0 30787 * @category Object 30788 * @param {Object} object The source object. 30789 * @param {Function} [predicate=_.identity] The function invoked per property. 30790 * @returns {Object} Returns the new object. 30791 * @example 30792 * 30793 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 30794 * 30795 * _.omitBy(object, _.isNumber); 30796 * // => { 'b': '2' } 30797 */ 30798 function omitBy(object, predicate) { 30799 return pickBy(object, negate(getIteratee(predicate))); 30800 } 30801 30802 /** 30803 * Creates an object composed of the picked `object` properties. 30804 * 30805 * @static 30806 * @since 0.1.0 30807 * @memberOf _ 30808 * @category Object 30809 * @param {Object} object The source object. 30810 * @param {...(string|string[])} [paths] The property paths to pick. 30811 * @returns {Object} Returns the new object. 30812 * @example 30813 * 30814 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 30815 * 30816 * _.pick(object, ['a', 'c']); 30817 * // => { 'a': 1, 'c': 3 } 30818 */ 30819 var pick = flatRest(function(object, paths) { 30820 return object == null ? {} : basePick(object, paths); 30821 }); 30822 30823 /** 30824 * Creates an object composed of the `object` properties `predicate` returns 30825 * truthy for. The predicate is invoked with two arguments: (value, key). 30826 * 30827 * @static 30828 * @memberOf _ 30829 * @since 4.0.0 30830 * @category Object 30831 * @param {Object} object The source object. 30832 * @param {Function} [predicate=_.identity] The function invoked per property. 30833 * @returns {Object} Returns the new object. 30834 * @example 30835 * 30836 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 30837 * 30838 * _.pickBy(object, _.isNumber); 30839 * // => { 'a': 1, 'c': 3 } 30840 */ 30841 function pickBy(object, predicate) { 30842 if (object == null) { 30843 return {}; 30844 } 30845 var props = arrayMap(getAllKeysIn(object), function(prop) { 30846 return [prop]; 30847 }); 30848 predicate = getIteratee(predicate); 30849 return basePickBy(object, props, function(value, path) { 30850 return predicate(value, path[0]); 30851 }); 30852 } 30853 30854 /** 30855 * This method is like `_.get` except that if the resolved value is a 30856 * function it's invoked with the `this` binding of its parent object and 30857 * its result is returned. 30858 * 30859 * @static 30860 * @since 0.1.0 30861 * @memberOf _ 30862 * @category Object 30863 * @param {Object} object The object to query. 30864 * @param {Array|string} path The path of the property to resolve. 30865 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 30866 * @returns {*} Returns the resolved value. 30867 * @example 30868 * 30869 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 30870 * 30871 * _.result(object, 'a[0].b.c1'); 30872 * // => 3 30873 * 30874 * _.result(object, 'a[0].b.c2'); 30875 * // => 4 30876 * 30877 * _.result(object, 'a[0].b.c3', 'default'); 30878 * // => 'default' 30879 * 30880 * _.result(object, 'a[0].b.c3', _.constant('default')); 30881 * // => 'default' 30882 */ 30883 function result(object, path, defaultValue) { 30884 path = castPath(path, object); 30885 30886 var index = -1, 30887 length = path.length; 30888 30889 // Ensure the loop is entered when path is empty. 30890 if (!length) { 30891 length = 1; 30892 object = undefined; 30893 } 30894 while (++index < length) { 30895 var value = object == null ? undefined : object[toKey(path[index])]; 30896 if (value === undefined) { 30897 index = length; 30898 value = defaultValue; 30899 } 30900 object = isFunction(value) ? value.call(object) : value; 30901 } 30902 return object; 30903 } 30904 30905 /** 30906 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, 30907 * it's created. Arrays are created for missing index properties while objects 30908 * are created for all other missing properties. Use `_.setWith` to customize 30909 * `path` creation. 30910 * 30911 * **Note:** This method mutates `object`. 30912 * 30913 * @static 30914 * @memberOf _ 30915 * @since 3.7.0 30916 * @category Object 30917 * @param {Object} object The object to modify. 30918 * @param {Array|string} path The path of the property to set. 30919 * @param {*} value The value to set. 30920 * @returns {Object} Returns `object`. 30921 * @example 30922 * 30923 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 30924 * 30925 * _.set(object, 'a[0].b.c', 4); 30926 * console.log(object.a[0].b.c); 30927 * // => 4 30928 * 30929 * _.set(object, ['x', '0', 'y', 'z'], 5); 30930 * console.log(object.x[0].y.z); 30931 * // => 5 30932 */ 30933 function set(object, path, value) { 30934 return object == null ? object : baseSet(object, path, value); 30935 } 30936 30937 /** 30938 * This method is like `_.set` except that it accepts `customizer` which is 30939 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 30940 * path creation is handled by the method instead. The `customizer` is invoked 30941 * with three arguments: (nsValue, key, nsObject). 30942 * 30943 * **Note:** This method mutates `object`. 30944 * 30945 * @static 30946 * @memberOf _ 30947 * @since 4.0.0 30948 * @category Object 30949 * @param {Object} object The object to modify. 30950 * @param {Array|string} path The path of the property to set. 30951 * @param {*} value The value to set. 30952 * @param {Function} [customizer] The function to customize assigned values. 30953 * @returns {Object} Returns `object`. 30954 * @example 30955 * 30956 * var object = {}; 30957 * 30958 * _.setWith(object, '[0][1]', 'a', Object); 30959 * // => { '0': { '1': 'a' } } 30960 */ 30961 function setWith(object, path, value, customizer) { 30962 customizer = typeof customizer == 'function' ? customizer : undefined; 30963 return object == null ? object : baseSet(object, path, value, customizer); 30964 } 30965 30966 /** 30967 * Creates an array of own enumerable string keyed-value pairs for `object` 30968 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its 30969 * entries are returned. 30970 * 30971 * @static 30972 * @memberOf _ 30973 * @since 4.0.0 30974 * @alias entries 30975 * @category Object 30976 * @param {Object} object The object to query. 30977 * @returns {Array} Returns the key-value pairs. 30978 * @example 30979 * 30980 * function Foo() { 30981 * this.a = 1; 30982 * this.b = 2; 30983 * } 30984 * 30985 * Foo.prototype.c = 3; 30986 * 30987 * _.toPairs(new Foo); 30988 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) 30989 */ 30990 var toPairs = createToPairs(keys); 30991 30992 /** 30993 * Creates an array of own and inherited enumerable string keyed-value pairs 30994 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map 30995 * or set, its entries are returned. 30996 * 30997 * @static 30998 * @memberOf _ 30999 * @since 4.0.0 31000 * @alias entriesIn 31001 * @category Object 31002 * @param {Object} object The object to query. 31003 * @returns {Array} Returns the key-value pairs. 31004 * @example 31005 * 31006 * function Foo() { 31007 * this.a = 1; 31008 * this.b = 2; 31009 * } 31010 * 31011 * Foo.prototype.c = 3; 31012 * 31013 * _.toPairsIn(new Foo); 31014 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) 31015 */ 31016 var toPairsIn = createToPairs(keysIn); 31017 31018 /** 31019 * An alternative to `_.reduce`; this method transforms `object` to a new 31020 * `accumulator` object which is the result of running each of its own 31021 * enumerable string keyed properties thru `iteratee`, with each invocation 31022 * potentially mutating the `accumulator` object. If `accumulator` is not 31023 * provided, a new object with the same `[[Prototype]]` will be used. The 31024 * iteratee is invoked with four arguments: (accumulator, value, key, object). 31025 * Iteratee functions may exit iteration early by explicitly returning `false`. 31026 * 31027 * @static 31028 * @memberOf _ 31029 * @since 1.3.0 31030 * @category Object 31031 * @param {Object} object The object to iterate over. 31032 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 31033 * @param {*} [accumulator] The custom accumulator value. 31034 * @returns {*} Returns the accumulated value. 31035 * @example 31036 * 31037 * _.transform([2, 3, 4], function(result, n) { 31038 * result.push(n *= n); 31039 * return n % 2 == 0; 31040 * }, []); 31041 * // => [4, 9] 31042 * 31043 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 31044 * (result[value] || (result[value] = [])).push(key); 31045 * }, {}); 31046 * // => { '1': ['a', 'c'], '2': ['b'] } 31047 */ 31048 function transform(object, iteratee, accumulator) { 31049 var isArr = isArray(object), 31050 isArrLike = isArr || isBuffer(object) || isTypedArray(object); 31051 31052 iteratee = getIteratee(iteratee, 4); 31053 if (accumulator == null) { 31054 var Ctor = object && object.constructor; 31055 if (isArrLike) { 31056 accumulator = isArr ? new Ctor : []; 31057 } 31058 else if (isObject(object)) { 31059 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; 31060 } 31061 else { 31062 accumulator = {}; 31063 } 31064 } 31065 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { 31066 return iteratee(accumulator, value, index, object); 31067 }); 31068 return accumulator; 31069 } 31070 31071 /** 31072 * Removes the property at `path` of `object`. 31073 * 31074 * **Note:** This method mutates `object`. 31075 * 31076 * @static 31077 * @memberOf _ 31078 * @since 4.0.0 31079 * @category Object 31080 * @param {Object} object The object to modify. 31081 * @param {Array|string} path The path of the property to unset. 31082 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 31083 * @example 31084 * 31085 * var object = { 'a': [{ 'b': { 'c': 7 } }] }; 31086 * _.unset(object, 'a[0].b.c'); 31087 * // => true 31088 * 31089 * console.log(object); 31090 * // => { 'a': [{ 'b': {} }] }; 31091 * 31092 * _.unset(object, ['a', '0', 'b', 'c']); 31093 * // => true 31094 * 31095 * console.log(object); 31096 * // => { 'a': [{ 'b': {} }] }; 31097 */ 31098 function unset(object, path) { 31099 return object == null ? true : baseUnset(object, path); 31100 } 31101 31102 /** 31103 * This method is like `_.set` except that accepts `updater` to produce the 31104 * value to set. Use `_.updateWith` to customize `path` creation. The `updater` 31105 * is invoked with one argument: (value). 31106 * 31107 * **Note:** This method mutates `object`. 31108 * 31109 * @static 31110 * @memberOf _ 31111 * @since 4.6.0 31112 * @category Object 31113 * @param {Object} object The object to modify. 31114 * @param {Array|string} path The path of the property to set. 31115 * @param {Function} updater The function to produce the updated value. 31116 * @returns {Object} Returns `object`. 31117 * @example 31118 * 31119 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 31120 * 31121 * _.update(object, 'a[0].b.c', function(n) { return n * n; }); 31122 * console.log(object.a[0].b.c); 31123 * // => 9 31124 * 31125 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 31126 * console.log(object.x[0].y.z); 31127 * // => 0 31128 */ 31129 function update(object, path, updater) { 31130 return object == null ? object : baseUpdate(object, path, castFunction(updater)); 31131 } 31132 31133 /** 31134 * This method is like `_.update` except that it accepts `customizer` which is 31135 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 31136 * path creation is handled by the method instead. The `customizer` is invoked 31137 * with three arguments: (nsValue, key, nsObject). 31138 * 31139 * **Note:** This method mutates `object`. 31140 * 31141 * @static 31142 * @memberOf _ 31143 * @since 4.6.0 31144 * @category Object 31145 * @param {Object} object The object to modify. 31146 * @param {Array|string} path The path of the property to set. 31147 * @param {Function} updater The function to produce the updated value. 31148 * @param {Function} [customizer] The function to customize assigned values. 31149 * @returns {Object} Returns `object`. 31150 * @example 31151 * 31152 * var object = {}; 31153 * 31154 * _.updateWith(object, '[0][1]', _.constant('a'), Object); 31155 * // => { '0': { '1': 'a' } } 31156 */ 31157 function updateWith(object, path, updater, customizer) { 31158 customizer = typeof customizer == 'function' ? customizer : undefined; 31159 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); 31160 } 31161 31162 /** 31163 * Creates an array of the own enumerable string keyed property values of `object`. 31164 * 31165 * **Note:** Non-object values are coerced to objects. 31166 * 31167 * @static 31168 * @since 0.1.0 31169 * @memberOf _ 31170 * @category Object 31171 * @param {Object} object The object to query. 31172 * @returns {Array} Returns the array of property values. 31173 * @example 31174 * 31175 * function Foo() { 31176 * this.a = 1; 31177 * this.b = 2; 31178 * } 31179 * 31180 * Foo.prototype.c = 3; 31181 * 31182 * _.values(new Foo); 31183 * // => [1, 2] (iteration order is not guaranteed) 31184 * 31185 * _.values('hi'); 31186 * // => ['h', 'i'] 31187 */ 31188 function values(object) { 31189 return object == null ? [] : baseValues(object, keys(object)); 31190 } 31191 31192 /** 31193 * Creates an array of the own and inherited enumerable string keyed property 31194 * values of `object`. 31195 * 31196 * **Note:** Non-object values are coerced to objects. 31197 * 31198 * @static 31199 * @memberOf _ 31200 * @since 3.0.0 31201 * @category Object 31202 * @param {Object} object The object to query. 31203 * @returns {Array} Returns the array of property values. 31204 * @example 31205 * 31206 * function Foo() { 31207 * this.a = 1; 31208 * this.b = 2; 31209 * } 31210 * 31211 * Foo.prototype.c = 3; 31212 * 31213 * _.valuesIn(new Foo); 31214 * // => [1, 2, 3] (iteration order is not guaranteed) 31215 */ 31216 function valuesIn(object) { 31217 return object == null ? [] : baseValues(object, keysIn(object)); 31218 } 31219 31220 /*------------------------------------------------------------------------*/ 31221 31222 /** 31223 * Clamps `number` within the inclusive `lower` and `upper` bounds. 31224 * 31225 * @static 31226 * @memberOf _ 31227 * @since 4.0.0 31228 * @category Number 31229 * @param {number} number The number to clamp. 31230 * @param {number} [lower] The lower bound. 31231 * @param {number} upper The upper bound. 31232 * @returns {number} Returns the clamped number. 31233 * @example 31234 * 31235 * _.clamp(-10, -5, 5); 31236 * // => -5 31237 * 31238 * _.clamp(10, -5, 5); 31239 * // => 5 31240 */ 31241 function clamp(number, lower, upper) { 31242 if (upper === undefined) { 31243 upper = lower; 31244 lower = undefined; 31245 } 31246 if (upper !== undefined) { 31247 upper = toNumber(upper); 31248 upper = upper === upper ? upper : 0; 31249 } 31250 if (lower !== undefined) { 31251 lower = toNumber(lower); 31252 lower = lower === lower ? lower : 0; 31253 } 31254 return baseClamp(toNumber(number), lower, upper); 31255 } 31256 31257 /** 31258 * Checks if `n` is between `start` and up to, but not including, `end`. If 31259 * `end` is not specified, it's set to `start` with `start` then set to `0`. 31260 * If `start` is greater than `end` the params are swapped to support 31261 * negative ranges. 31262 * 31263 * @static 31264 * @memberOf _ 31265 * @since 3.3.0 31266 * @category Number 31267 * @param {number} number The number to check. 31268 * @param {number} [start=0] The start of the range. 31269 * @param {number} end The end of the range. 31270 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 31271 * @see _.range, _.rangeRight 31272 * @example 31273 * 31274 * _.inRange(3, 2, 4); 31275 * // => true 31276 * 31277 * _.inRange(4, 8); 31278 * // => true 31279 * 31280 * _.inRange(4, 2); 31281 * // => false 31282 * 31283 * _.inRange(2, 2); 31284 * // => false 31285 * 31286 * _.inRange(1.2, 2); 31287 * // => true 31288 * 31289 * _.inRange(5.2, 4); 31290 * // => false 31291 * 31292 * _.inRange(-3, -2, -6); 31293 * // => true 31294 */ 31295 function inRange(number, start, end) { 31296 start = toFinite(start); 31297 if (end === undefined) { 31298 end = start; 31299 start = 0; 31300 } else { 31301 end = toFinite(end); 31302 } 31303 number = toNumber(number); 31304 return baseInRange(number, start, end); 31305 } 31306 31307 /** 31308 * Produces a random number between the inclusive `lower` and `upper` bounds. 31309 * If only one argument is provided a number between `0` and the given number 31310 * is returned. If `floating` is `true`, or either `lower` or `upper` are 31311 * floats, a floating-point number is returned instead of an integer. 31312 * 31313 * **Note:** JavaScript follows the IEEE-754 standard for resolving 31314 * floating-point values which can produce unexpected results. 31315 * 31316 * @static 31317 * @memberOf _ 31318 * @since 0.7.0 31319 * @category Number 31320 * @param {number} [lower=0] The lower bound. 31321 * @param {number} [upper=1] The upper bound. 31322 * @param {boolean} [floating] Specify returning a floating-point number. 31323 * @returns {number} Returns the random number. 31324 * @example 31325 * 31326 * _.random(0, 5); 31327 * // => an integer between 0 and 5 31328 * 31329 * _.random(5); 31330 * // => also an integer between 0 and 5 31331 * 31332 * _.random(5, true); 31333 * // => a floating-point number between 0 and 5 31334 * 31335 * _.random(1.2, 5.2); 31336 * // => a floating-point number between 1.2 and 5.2 31337 */ 31338 function random(lower, upper, floating) { 31339 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { 31340 upper = floating = undefined; 31341 } 31342 if (floating === undefined) { 31343 if (typeof upper == 'boolean') { 31344 floating = upper; 31345 upper = undefined; 31346 } 31347 else if (typeof lower == 'boolean') { 31348 floating = lower; 31349 lower = undefined; 31350 } 31351 } 31352 if (lower === undefined && upper === undefined) { 31353 lower = 0; 31354 upper = 1; 31355 } 31356 else { 31357 lower = toFinite(lower); 31358 if (upper === undefined) { 31359 upper = lower; 31360 lower = 0; 31361 } else { 31362 upper = toFinite(upper); 31363 } 31364 } 31365 if (lower > upper) { 31366 var temp = lower; 31367 lower = upper; 31368 upper = temp; 31369 } 31370 if (floating || lower % 1 || upper % 1) { 31371 var rand = nativeRandom(); 31372 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); 31373 } 31374 return baseRandom(lower, upper); 31375 } 31376 31377 /*------------------------------------------------------------------------*/ 31378 31379 /** 31380 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 31381 * 31382 * @static 31383 * @memberOf _ 31384 * @since 3.0.0 31385 * @category String 31386 * @param {string} [string=''] The string to convert. 31387 * @returns {string} Returns the camel cased string. 31388 * @example 31389 * 31390 * _.camelCase('Foo Bar'); 31391 * // => 'fooBar' 31392 * 31393 * _.camelCase('--foo-bar--'); 31394 * // => 'fooBar' 31395 * 31396 * _.camelCase('__FOO_BAR__'); 31397 * // => 'fooBar' 31398 */ 31399 var camelCase = createCompounder(function(result, word, index) { 31400 word = word.toLowerCase(); 31401 return result + (index ? capitalize(word) : word); 31402 }); 31403 31404 /** 31405 * Converts the first character of `string` to upper case and the remaining 31406 * to lower case. 31407 * 31408 * @static 31409 * @memberOf _ 31410 * @since 3.0.0 31411 * @category String 31412 * @param {string} [string=''] The string to capitalize. 31413 * @returns {string} Returns the capitalized string. 31414 * @example 31415 * 31416 * _.capitalize('FRED'); 31417 * // => 'Fred' 31418 */ 31419 function capitalize(string) { 31420 return upperFirst(toString(string).toLowerCase()); 31421 } 31422 31423 /** 31424 * Deburrs `string` by converting 31425 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 31426 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 31427 * letters to basic Latin letters and removing 31428 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 31429 * 31430 * @static 31431 * @memberOf _ 31432 * @since 3.0.0 31433 * @category String 31434 * @param {string} [string=''] The string to deburr. 31435 * @returns {string} Returns the deburred string. 31436 * @example 31437 * 31438 * _.deburr('déjàvu'); 31439 * // => 'deja vu' 31440 */ 31441 function deburr(string) { 31442 string = toString(string); 31443 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); 31444 } 31445 31446 /** 31447 * Checks if `string` ends with the given target string. 31448 * 31449 * @static 31450 * @memberOf _ 31451 * @since 3.0.0 31452 * @category String 31453 * @param {string} [string=''] The string to inspect. 31454 * @param {string} [target] The string to search for. 31455 * @param {number} [position=string.length] The position to search up to. 31456 * @returns {boolean} Returns `true` if `string` ends with `target`, 31457 * else `false`. 31458 * @example 31459 * 31460 * _.endsWith('abc', 'c'); 31461 * // => true 31462 * 31463 * _.endsWith('abc', 'b'); 31464 * // => false 31465 * 31466 * _.endsWith('abc', 'b', 2); 31467 * // => true 31468 */ 31469 function endsWith(string, target, position) { 31470 string = toString(string); 31471 target = baseToString(target); 31472 31473 var length = string.length; 31474 position = position === undefined 31475 ? length 31476 : baseClamp(toInteger(position), 0, length); 31477 31478 var end = position; 31479 position -= target.length; 31480 return position >= 0 && string.slice(position, end) == target; 31481 } 31482 31483 /** 31484 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their 31485 * corresponding HTML entities. 31486 * 31487 * **Note:** No other characters are escaped. To escape additional 31488 * characters use a third-party library like [_he_](https://mths.be/he). 31489 * 31490 * Though the ">" character is escaped for symmetry, characters like 31491 * ">" and "/" don't need escaping in HTML and have no special meaning 31492 * unless they're part of a tag or unquoted attribute value. See 31493 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) 31494 * (under "semi-related fun fact") for more details. 31495 * 31496 * When working with HTML you should always 31497 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce 31498 * XSS vectors. 31499 * 31500 * @static 31501 * @since 0.1.0 31502 * @memberOf _ 31503 * @category String 31504 * @param {string} [string=''] The string to escape. 31505 * @returns {string} Returns the escaped string. 31506 * @example 31507 * 31508 * _.escape('fred, barney, & pebbles'); 31509 * // => 'fred, barney, & pebbles' 31510 */ 31511 function escape(string) { 31512 string = toString(string); 31513 return (string && reHasUnescapedHtml.test(string)) 31514 ? string.replace(reUnescapedHtml, escapeHtmlChar) 31515 : string; 31516 } 31517 31518 /** 31519 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", 31520 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. 31521 * 31522 * @static 31523 * @memberOf _ 31524 * @since 3.0.0 31525 * @category String 31526 * @param {string} [string=''] The string to escape. 31527 * @returns {string} Returns the escaped string. 31528 * @example 31529 * 31530 * _.escapeRegExp('[lodash](https://lodash.com/)'); 31531 * // => '\[lodash\]\(https://lodash\.com/\)' 31532 */ 31533 function escapeRegExp(string) { 31534 string = toString(string); 31535 return (string && reHasRegExpChar.test(string)) 31536 ? string.replace(reRegExpChar, '\\$&') 31537 : string; 31538 } 31539 31540 /** 31541 * Converts `string` to 31542 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 31543 * 31544 * @static 31545 * @memberOf _ 31546 * @since 3.0.0 31547 * @category String 31548 * @param {string} [string=''] The string to convert. 31549 * @returns {string} Returns the kebab cased string. 31550 * @example 31551 * 31552 * _.kebabCase('Foo Bar'); 31553 * // => 'foo-bar' 31554 * 31555 * _.kebabCase('fooBar'); 31556 * // => 'foo-bar' 31557 * 31558 * _.kebabCase('__FOO_BAR__'); 31559 * // => 'foo-bar' 31560 */ 31561 var kebabCase = createCompounder(function(result, word, index) { 31562 return result + (index ? '-' : '') + word.toLowerCase(); 31563 }); 31564 31565 /** 31566 * Converts `string`, as space separated words, to lower case. 31567 * 31568 * @static 31569 * @memberOf _ 31570 * @since 4.0.0 31571 * @category String 31572 * @param {string} [string=''] The string to convert. 31573 * @returns {string} Returns the lower cased string. 31574 * @example 31575 * 31576 * _.lowerCase('--Foo-Bar--'); 31577 * // => 'foo bar' 31578 * 31579 * _.lowerCase('fooBar'); 31580 * // => 'foo bar' 31581 * 31582 * _.lowerCase('__FOO_BAR__'); 31583 * // => 'foo bar' 31584 */ 31585 var lowerCase = createCompounder(function(result, word, index) { 31586 return result + (index ? ' ' : '') + word.toLowerCase(); 31587 }); 31588 31589 /** 31590 * Converts the first character of `string` to lower case. 31591 * 31592 * @static 31593 * @memberOf _ 31594 * @since 4.0.0 31595 * @category String 31596 * @param {string} [string=''] The string to convert. 31597 * @returns {string} Returns the converted string. 31598 * @example 31599 * 31600 * _.lowerFirst('Fred'); 31601 * // => 'fred' 31602 * 31603 * _.lowerFirst('FRED'); 31604 * // => 'fRED' 31605 */ 31606 var lowerFirst = createCaseFirst('toLowerCase'); 31607 31608 /** 31609 * Pads `string` on the left and right sides if it's shorter than `length`. 31610 * Padding characters are truncated if they can't be evenly divided by `length`. 31611 * 31612 * @static 31613 * @memberOf _ 31614 * @since 3.0.0 31615 * @category String 31616 * @param {string} [string=''] The string to pad. 31617 * @param {number} [length=0] The padding length. 31618 * @param {string} [chars=' '] The string used as padding. 31619 * @returns {string} Returns the padded string. 31620 * @example 31621 * 31622 * _.pad('abc', 8); 31623 * // => ' abc ' 31624 * 31625 * _.pad('abc', 8, '_-'); 31626 * // => '_-abc_-_' 31627 * 31628 * _.pad('abc', 3); 31629 * // => 'abc' 31630 */ 31631 function pad(string, length, chars) { 31632 string = toString(string); 31633 length = toInteger(length); 31634 31635 var strLength = length ? stringSize(string) : 0; 31636 if (!length || strLength >= length) { 31637 return string; 31638 } 31639 var mid = (length - strLength) / 2; 31640 return ( 31641 createPadding(nativeFloor(mid), chars) + 31642 string + 31643 createPadding(nativeCeil(mid), chars) 31644 ); 31645 } 31646 31647 /** 31648 * Pads `string` on the right side if it's shorter than `length`. Padding 31649 * characters are truncated if they exceed `length`. 31650 * 31651 * @static 31652 * @memberOf _ 31653 * @since 4.0.0 31654 * @category String 31655 * @param {string} [string=''] The string to pad. 31656 * @param {number} [length=0] The padding length. 31657 * @param {string} [chars=' '] The string used as padding. 31658 * @returns {string} Returns the padded string. 31659 * @example 31660 * 31661 * _.padEnd('abc', 6); 31662 * // => 'abc ' 31663 * 31664 * _.padEnd('abc', 6, '_-'); 31665 * // => 'abc_-_' 31666 * 31667 * _.padEnd('abc', 3); 31668 * // => 'abc' 31669 */ 31670 function padEnd(string, length, chars) { 31671 string = toString(string); 31672 length = toInteger(length); 31673 31674 var strLength = length ? stringSize(string) : 0; 31675 return (length && strLength < length) 31676 ? (string + createPadding(length - strLength, chars)) 31677 : string; 31678 } 31679 31680 /** 31681 * Pads `string` on the left side if it's shorter than `length`. Padding 31682 * characters are truncated if they exceed `length`. 31683 * 31684 * @static 31685 * @memberOf _ 31686 * @since 4.0.0 31687 * @category String 31688 * @param {string} [string=''] The string to pad. 31689 * @param {number} [length=0] The padding length. 31690 * @param {string} [chars=' '] The string used as padding. 31691 * @returns {string} Returns the padded string. 31692 * @example 31693 * 31694 * _.padStart('abc', 6); 31695 * // => ' abc' 31696 * 31697 * _.padStart('abc', 6, '_-'); 31698 * // => '_-_abc' 31699 * 31700 * _.padStart('abc', 3); 31701 * // => 'abc' 31702 */ 31703 function padStart(string, length, chars) { 31704 string = toString(string); 31705 length = toInteger(length); 31706 31707 var strLength = length ? stringSize(string) : 0; 31708 return (length && strLength < length) 31709 ? (createPadding(length - strLength, chars) + string) 31710 : string; 31711 } 31712 31713 /** 31714 * Converts `string` to an integer of the specified radix. If `radix` is 31715 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a 31716 * hexadecimal, in which case a `radix` of `16` is used. 31717 * 31718 * **Note:** This method aligns with the 31719 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. 31720 * 31721 * @static 31722 * @memberOf _ 31723 * @since 1.1.0 31724 * @category String 31725 * @param {string} string The string to convert. 31726 * @param {number} [radix=10] The radix to interpret `value` by. 31727 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 31728 * @returns {number} Returns the converted integer. 31729 * @example 31730 * 31731 * _.parseInt('08'); 31732 * // => 8 31733 * 31734 * _.map(['6', '08', '10'], _.parseInt); 31735 * // => [6, 8, 10] 31736 */ 31737 function parseInt(string, radix, guard) { 31738 if (guard || radix == null) { 31739 radix = 0; 31740 } else if (radix) { 31741 radix = +radix; 31742 } 31743 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); 31744 } 31745 31746 /** 31747 * Repeats the given string `n` times. 31748 * 31749 * @static 31750 * @memberOf _ 31751 * @since 3.0.0 31752 * @category String 31753 * @param {string} [string=''] The string to repeat. 31754 * @param {number} [n=1] The number of times to repeat the string. 31755 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 31756 * @returns {string} Returns the repeated string. 31757 * @example 31758 * 31759 * _.repeat('*', 3); 31760 * // => '***' 31761 * 31762 * _.repeat('abc', 2); 31763 * // => 'abcabc' 31764 * 31765 * _.repeat('abc', 0); 31766 * // => '' 31767 */ 31768 function repeat(string, n, guard) { 31769 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { 31770 n = 1; 31771 } else { 31772 n = toInteger(n); 31773 } 31774 return baseRepeat(toString(string), n); 31775 } 31776 31777 /** 31778 * Replaces matches for `pattern` in `string` with `replacement`. 31779 * 31780 * **Note:** This method is based on 31781 * [`String#replace`](https://mdn.io/String/replace). 31782 * 31783 * @static 31784 * @memberOf _ 31785 * @since 4.0.0 31786 * @category String 31787 * @param {string} [string=''] The string to modify. 31788 * @param {RegExp|string} pattern The pattern to replace. 31789 * @param {Function|string} replacement The match replacement. 31790 * @returns {string} Returns the modified string. 31791 * @example 31792 * 31793 * _.replace('Hi Fred', 'Fred', 'Barney'); 31794 * // => 'Hi Barney' 31795 */ 31796 function replace() { 31797 var args = arguments, 31798 string = toString(args[0]); 31799 31800 return args.length < 3 ? string : string.replace(args[1], args[2]); 31801 } 31802 31803 /** 31804 * Converts `string` to 31805 * [snake case](https://en.wikipedia.org/wiki/Snake_case). 31806 * 31807 * @static 31808 * @memberOf _ 31809 * @since 3.0.0 31810 * @category String 31811 * @param {string} [string=''] The string to convert. 31812 * @returns {string} Returns the snake cased string. 31813 * @example 31814 * 31815 * _.snakeCase('Foo Bar'); 31816 * // => 'foo_bar' 31817 * 31818 * _.snakeCase('fooBar'); 31819 * // => 'foo_bar' 31820 * 31821 * _.snakeCase('--FOO-BAR--'); 31822 * // => 'foo_bar' 31823 */ 31824 var snakeCase = createCompounder(function(result, word, index) { 31825 return result + (index ? '_' : '') + word.toLowerCase(); 31826 }); 31827 31828 /** 31829 * Splits `string` by `separator`. 31830 * 31831 * **Note:** This method is based on 31832 * [`String#split`](https://mdn.io/String/split). 31833 * 31834 * @static 31835 * @memberOf _ 31836 * @since 4.0.0 31837 * @category String 31838 * @param {string} [string=''] The string to split. 31839 * @param {RegExp|string} separator The separator pattern to split by. 31840 * @param {number} [limit] The length to truncate results to. 31841 * @returns {Array} Returns the string segments. 31842 * @example 31843 * 31844 * _.split('a-b-c', '-', 2); 31845 * // => ['a', 'b'] 31846 */ 31847 function split(string, separator, limit) { 31848 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { 31849 separator = limit = undefined; 31850 } 31851 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; 31852 if (!limit) { 31853 return []; 31854 } 31855 string = toString(string); 31856 if (string && ( 31857 typeof separator == 'string' || 31858 (separator != null && !isRegExp(separator)) 31859 )) { 31860 separator = baseToString(separator); 31861 if (!separator && hasUnicode(string)) { 31862 return castSlice(stringToArray(string), 0, limit); 31863 } 31864 } 31865 return string.split(separator, limit); 31866 } 31867 31868 /** 31869 * Converts `string` to 31870 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). 31871 * 31872 * @static 31873 * @memberOf _ 31874 * @since 3.1.0 31875 * @category String 31876 * @param {string} [string=''] The string to convert. 31877 * @returns {string} Returns the start cased string. 31878 * @example 31879 * 31880 * _.startCase('--foo-bar--'); 31881 * // => 'Foo Bar' 31882 * 31883 * _.startCase('fooBar'); 31884 * // => 'Foo Bar' 31885 * 31886 * _.startCase('__FOO_BAR__'); 31887 * // => 'FOO BAR' 31888 */ 31889 var startCase = createCompounder(function(result, word, index) { 31890 return result + (index ? ' ' : '') + upperFirst(word); 31891 }); 31892 31893 /** 31894 * Checks if `string` starts with the given target string. 31895 * 31896 * @static 31897 * @memberOf _ 31898 * @since 3.0.0 31899 * @category String 31900 * @param {string} [string=''] The string to inspect. 31901 * @param {string} [target] The string to search for. 31902 * @param {number} [position=0] The position to search from. 31903 * @returns {boolean} Returns `true` if `string` starts with `target`, 31904 * else `false`. 31905 * @example 31906 * 31907 * _.startsWith('abc', 'a'); 31908 * // => true 31909 * 31910 * _.startsWith('abc', 'b'); 31911 * // => false 31912 * 31913 * _.startsWith('abc', 'b', 1); 31914 * // => true 31915 */ 31916 function startsWith(string, target, position) { 31917 string = toString(string); 31918 position = position == null 31919 ? 0 31920 : baseClamp(toInteger(position), 0, string.length); 31921 31922 target = baseToString(target); 31923 return string.slice(position, position + target.length) == target; 31924 } 31925 31926 /** 31927 * Creates a compiled template function that can interpolate data properties 31928 * in "interpolate" delimiters, HTML-escape interpolated data properties in 31929 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data 31930 * properties may be accessed as free variables in the template. If a setting 31931 * object is given, it takes precedence over `_.templateSettings` values. 31932 * 31933 * **Note:** In the development build `_.template` utilizes 31934 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) 31935 * for easier debugging. 31936 * 31937 * For more information on precompiling templates see 31938 * [lodash's custom builds documentation](https://lodash.com/custom-builds). 31939 * 31940 * For more information on Chrome extension sandboxes see 31941 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). 31942 * 31943 * @static 31944 * @since 0.1.0 31945 * @memberOf _ 31946 * @category String 31947 * @param {string} [string=''] The template string. 31948 * @param {Object} [options={}] The options object. 31949 * @param {RegExp} [options.escape=_.templateSettings.escape] 31950 * The HTML "escape" delimiter. 31951 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] 31952 * The "evaluate" delimiter. 31953 * @param {Object} [options.imports=_.templateSettings.imports] 31954 * An object to import into the template as free variables. 31955 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] 31956 * The "interpolate" delimiter. 31957 * @param {string} [options.sourceURL='lodash.templateSources[n]'] 31958 * The sourceURL of the compiled template. 31959 * @param {string} [options.variable='obj'] 31960 * The data object variable name. 31961 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 31962 * @returns {Function} Returns the compiled template function. 31963 * @example 31964 * 31965 * // Use the "interpolate" delimiter to create a compiled template. 31966 * var compiled = _.template('hello <%= user %>!'); 31967 * compiled({ 'user': 'fred' }); 31968 * // => 'hello fred!' 31969 * 31970 * // Use the HTML "escape" delimiter to escape data property values. 31971 * var compiled = _.template('<b><%- value %></b>'); 31972 * compiled({ 'value': '<script>' }); 31973 * // => '<b><script></b>' 31974 * 31975 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. 31976 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); 31977 * compiled({ 'users': ['fred', 'barney'] }); 31978 * // => '<li>fred</li><li>barney</li>' 31979 * 31980 * // Use the internal `print` function in "evaluate" delimiters. 31981 * var compiled = _.template('<% print("hello " + user); %>!'); 31982 * compiled({ 'user': 'barney' }); 31983 * // => 'hello barney!' 31984 * 31985 * // Use the ES template literal delimiter as an "interpolate" delimiter. 31986 * // Disable support by replacing the "interpolate" delimiter. 31987 * var compiled = _.template('hello ${ user }!'); 31988 * compiled({ 'user': 'pebbles' }); 31989 * // => 'hello pebbles!' 31990 * 31991 * // Use backslashes to treat delimiters as plain text. 31992 * var compiled = _.template('<%= "\\<%- value %\\>" %>'); 31993 * compiled({ 'value': 'ignored' }); 31994 * // => '<%- value %>' 31995 * 31996 * // Use the `imports` option to import `jQuery` as `jq`. 31997 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; 31998 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); 31999 * compiled({ 'users': ['fred', 'barney'] }); 32000 * // => '<li>fred</li><li>barney</li>' 32001 * 32002 * // Use the `sourceURL` option to specify a custom sourceURL for the template. 32003 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); 32004 * compiled(data); 32005 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. 32006 * 32007 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. 32008 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); 32009 * compiled.source; 32010 * // => function(data) { 32011 * // var __t, __p = ''; 32012 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; 32013 * // return __p; 32014 * // } 32015 * 32016 * // Use custom template delimiters. 32017 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; 32018 * var compiled = _.template('hello {{ user }}!'); 32019 * compiled({ 'user': 'mustache' }); 32020 * // => 'hello mustache!' 32021 * 32022 * // Use the `source` property to inline compiled templates for meaningful 32023 * // line numbers in error messages and stack traces. 32024 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ 32025 * var JST = {\ 32026 * "main": ' + _.template(mainText).source + '\ 32027 * };\ 32028 * '); 32029 */ 32030 function template(string, options, guard) { 32031 // Based on John Resig's `tmpl` implementation 32032 // (http://ejohn.org/blog/javascript-micro-templating/) 32033 // and Laura Doktorova's doT.js (https://github.com/olado/doT). 32034 var settings = lodash.templateSettings; 32035 32036 if (guard && isIterateeCall(string, options, guard)) { 32037 options = undefined; 32038 } 32039 string = toString(string); 32040 options = assignInWith({}, options, settings, customDefaultsAssignIn); 32041 32042 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), 32043 importsKeys = keys(imports), 32044 importsValues = baseValues(imports, importsKeys); 32045 32046 var isEscaping, 32047 isEvaluating, 32048 index = 0, 32049 interpolate = options.interpolate || reNoMatch, 32050 source = "__p += '"; 32051 32052 // Compile the regexp to match each delimiter. 32053 var reDelimiters = RegExp( 32054 (options.escape || reNoMatch).source + '|' + 32055 interpolate.source + '|' + 32056 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + 32057 (options.evaluate || reNoMatch).source + '|$' 32058 , 'g'); 32059 32060 // Use a sourceURL for easier debugging. 32061 // The sourceURL gets injected into the source that's eval-ed, so be careful 32062 // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in 32063 // and escape the comment, thus injecting code that gets evaled. 32064 var sourceURL = '//# sourceURL=' + 32065 (hasOwnProperty.call(options, 'sourceURL') 32066 ? (options.sourceURL + '').replace(/\s/g, ' ') 32067 : ('lodash.templateSources[' + (++templateCounter) + ']') 32068 ) + '\n'; 32069 32070 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { 32071 interpolateValue || (interpolateValue = esTemplateValue); 32072 32073 // Escape characters that can't be included in string literals. 32074 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); 32075 32076 // Replace delimiters with snippets. 32077 if (escapeValue) { 32078 isEscaping = true; 32079 source += "' +\n__e(" + escapeValue + ") +\n'"; 32080 } 32081 if (evaluateValue) { 32082 isEvaluating = true; 32083 source += "';\n" + evaluateValue + ";\n__p += '"; 32084 } 32085 if (interpolateValue) { 32086 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; 32087 } 32088 index = offset + match.length; 32089 32090 // The JS engine embedded in Adobe products needs `match` returned in 32091 // order to produce the correct `offset` value. 32092 return match; 32093 }); 32094 32095 source += "';\n"; 32096 32097 // If `variable` is not specified wrap a with-statement around the generated 32098 // code to add the data object to the top of the scope chain. 32099 var variable = hasOwnProperty.call(options, 'variable') && options.variable; 32100 if (!variable) { 32101 source = 'with (obj) {\n' + source + '\n}\n'; 32102 } 32103 // Cleanup code by stripping empty strings. 32104 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) 32105 .replace(reEmptyStringMiddle, '$1') 32106 .replace(reEmptyStringTrailing, '$1;'); 32107 32108 // Frame code as the function body. 32109 source = 'function(' + (variable || 'obj') + ') {\n' + 32110 (variable 32111 ? '' 32112 : 'obj || (obj = {});\n' 32113 ) + 32114 "var __t, __p = ''" + 32115 (isEscaping 32116 ? ', __e = _.escape' 32117 : '' 32118 ) + 32119 (isEvaluating 32120 ? ', __j = Array.prototype.join;\n' + 32121 "function print() { __p += __j.call(arguments, '') }\n" 32122 : ';\n' 32123 ) + 32124 source + 32125 'return __p\n}'; 32126 32127 var result = attempt(function() { 32128 return Function(importsKeys, sourceURL + 'return ' + source) 32129 .apply(undefined, importsValues); 32130 }); 32131 32132 // Provide the compiled function's source by its `toString` method or 32133 // the `source` property as a convenience for inlining compiled templates. 32134 result.source = source; 32135 if (isError(result)) { 32136 throw result; 32137 } 32138 return result; 32139 } 32140 32141 /** 32142 * Converts `string`, as a whole, to lower case just like 32143 * [String#toLowerCase](https://mdn.io/toLowerCase). 32144 * 32145 * @static 32146 * @memberOf _ 32147 * @since 4.0.0 32148 * @category String 32149 * @param {string} [string=''] The string to convert. 32150 * @returns {string} Returns the lower cased string. 32151 * @example 32152 * 32153 * _.toLower('--Foo-Bar--'); 32154 * // => '--foo-bar--' 32155 * 32156 * _.toLower('fooBar'); 32157 * // => 'foobar' 32158 * 32159 * _.toLower('__FOO_BAR__'); 32160 * // => '__foo_bar__' 32161 */ 32162 function toLower(value) { 32163 return toString(value).toLowerCase(); 32164 } 32165 32166 /** 32167 * Converts `string`, as a whole, to upper case just like 32168 * [String#toUpperCase](https://mdn.io/toUpperCase). 32169 * 32170 * @static 32171 * @memberOf _ 32172 * @since 4.0.0 32173 * @category String 32174 * @param {string} [string=''] The string to convert. 32175 * @returns {string} Returns the upper cased string. 32176 * @example 32177 * 32178 * _.toUpper('--foo-bar--'); 32179 * // => '--FOO-BAR--' 32180 * 32181 * _.toUpper('fooBar'); 32182 * // => 'FOOBAR' 32183 * 32184 * _.toUpper('__foo_bar__'); 32185 * // => '__FOO_BAR__' 32186 */ 32187 function toUpper(value) { 32188 return toString(value).toUpperCase(); 32189 } 32190 32191 /** 32192 * Removes leading and trailing whitespace or specified characters from `string`. 32193 * 32194 * @static 32195 * @memberOf _ 32196 * @since 3.0.0 32197 * @category String 32198 * @param {string} [string=''] The string to trim. 32199 * @param {string} [chars=whitespace] The characters to trim. 32200 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 32201 * @returns {string} Returns the trimmed string. 32202 * @example 32203 * 32204 * _.trim(' abc '); 32205 * // => 'abc' 32206 * 32207 * _.trim('-_-abc-_-', '_-'); 32208 * // => 'abc' 32209 * 32210 * _.map([' foo ', ' bar '], _.trim); 32211 * // => ['foo', 'bar'] 32212 */ 32213 function trim(string, chars, guard) { 32214 string = toString(string); 32215 if (string && (guard || chars === undefined)) { 32216 return string.replace(reTrim, ''); 32217 } 32218 if (!string || !(chars = baseToString(chars))) { 32219 return string; 32220 } 32221 var strSymbols = stringToArray(string), 32222 chrSymbols = stringToArray(chars), 32223 start = charsStartIndex(strSymbols, chrSymbols), 32224 end = charsEndIndex(strSymbols, chrSymbols) + 1; 32225 32226 return castSlice(strSymbols, start, end).join(''); 32227 } 32228 32229 /** 32230 * Removes trailing whitespace or specified characters from `string`. 32231 * 32232 * @static 32233 * @memberOf _ 32234 * @since 4.0.0 32235 * @category String 32236 * @param {string} [string=''] The string to trim. 32237 * @param {string} [chars=whitespace] The characters to trim. 32238 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 32239 * @returns {string} Returns the trimmed string. 32240 * @example 32241 * 32242 * _.trimEnd(' abc '); 32243 * // => ' abc' 32244 * 32245 * _.trimEnd('-_-abc-_-', '_-'); 32246 * // => '-_-abc' 32247 */ 32248 function trimEnd(string, chars, guard) { 32249 string = toString(string); 32250 if (string && (guard || chars === undefined)) { 32251 return string.replace(reTrimEnd, ''); 32252 } 32253 if (!string || !(chars = baseToString(chars))) { 32254 return string; 32255 } 32256 var strSymbols = stringToArray(string), 32257 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; 32258 32259 return castSlice(strSymbols, 0, end).join(''); 32260 } 32261 32262 /** 32263 * Removes leading whitespace or specified characters from `string`. 32264 * 32265 * @static 32266 * @memberOf _ 32267 * @since 4.0.0 32268 * @category String 32269 * @param {string} [string=''] The string to trim. 32270 * @param {string} [chars=whitespace] The characters to trim. 32271 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 32272 * @returns {string} Returns the trimmed string. 32273 * @example 32274 * 32275 * _.trimStart(' abc '); 32276 * // => 'abc ' 32277 * 32278 * _.trimStart('-_-abc-_-', '_-'); 32279 * // => 'abc-_-' 32280 */ 32281 function trimStart(string, chars, guard) { 32282 string = toString(string); 32283 if (string && (guard || chars === undefined)) { 32284 return string.replace(reTrimStart, ''); 32285 } 32286 if (!string || !(chars = baseToString(chars))) { 32287 return string; 32288 } 32289 var strSymbols = stringToArray(string), 32290 start = charsStartIndex(strSymbols, stringToArray(chars)); 32291 32292 return castSlice(strSymbols, start).join(''); 32293 } 32294 32295 /** 32296 * Truncates `string` if it's longer than the given maximum string length. 32297 * The last characters of the truncated string are replaced with the omission 32298 * string which defaults to "...". 32299 * 32300 * @static 32301 * @memberOf _ 32302 * @since 4.0.0 32303 * @category String 32304 * @param {string} [string=''] The string to truncate. 32305 * @param {Object} [options={}] The options object. 32306 * @param {number} [options.length=30] The maximum string length. 32307 * @param {string} [options.omission='...'] The string to indicate text is omitted. 32308 * @param {RegExp|string} [options.separator] The separator pattern to truncate to. 32309 * @returns {string} Returns the truncated string. 32310 * @example 32311 * 32312 * _.truncate('hi-diddly-ho there, neighborino'); 32313 * // => 'hi-diddly-ho there, neighbo...' 32314 * 32315 * _.truncate('hi-diddly-ho there, neighborino', { 32316 * 'length': 24, 32317 * 'separator': ' ' 32318 * }); 32319 * // => 'hi-diddly-ho there,...' 32320 * 32321 * _.truncate('hi-diddly-ho there, neighborino', { 32322 * 'length': 24, 32323 * 'separator': /,? +/ 32324 * }); 32325 * // => 'hi-diddly-ho there...' 32326 * 32327 * _.truncate('hi-diddly-ho there, neighborino', { 32328 * 'omission': ' [...]' 32329 * }); 32330 * // => 'hi-diddly-ho there, neig [...]' 32331 */ 32332 function truncate(string, options) { 32333 var length = DEFAULT_TRUNC_LENGTH, 32334 omission = DEFAULT_TRUNC_OMISSION; 32335 32336 if (isObject(options)) { 32337 var separator = 'separator' in options ? options.separator : separator; 32338 length = 'length' in options ? toInteger(options.length) : length; 32339 omission = 'omission' in options ? baseToString(options.omission) : omission; 32340 } 32341 string = toString(string); 32342 32343 var strLength = string.length; 32344 if (hasUnicode(string)) { 32345 var strSymbols = stringToArray(string); 32346 strLength = strSymbols.length; 32347 } 32348 if (length >= strLength) { 32349 return string; 32350 } 32351 var end = length - stringSize(omission); 32352 if (end < 1) { 32353 return omission; 32354 } 32355 var result = strSymbols 32356 ? castSlice(strSymbols, 0, end).join('') 32357 : string.slice(0, end); 32358 32359 if (separator === undefined) { 32360 return result + omission; 32361 } 32362 if (strSymbols) { 32363 end += (result.length - end); 32364 } 32365 if (isRegExp(separator)) { 32366 if (string.slice(end).search(separator)) { 32367 var match, 32368 substring = result; 32369 32370 if (!separator.global) { 32371 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); 32372 } 32373 separator.lastIndex = 0; 32374 while ((match = separator.exec(substring))) { 32375 var newEnd = match.index; 32376 } 32377 result = result.slice(0, newEnd === undefined ? end : newEnd); 32378 } 32379 } else if (string.indexOf(baseToString(separator), end) != end) { 32380 var index = result.lastIndexOf(separator); 32381 if (index > -1) { 32382 result = result.slice(0, index); 32383 } 32384 } 32385 return result + omission; 32386 } 32387 32388 /** 32389 * The inverse of `_.escape`; this method converts the HTML entities 32390 * `&`, `<`, `>`, `"`, and `'` in `string` to 32391 * their corresponding characters. 32392 * 32393 * **Note:** No other HTML entities are unescaped. To unescape additional 32394 * HTML entities use a third-party library like [_he_](https://mths.be/he). 32395 * 32396 * @static 32397 * @memberOf _ 32398 * @since 0.6.0 32399 * @category String 32400 * @param {string} [string=''] The string to unescape. 32401 * @returns {string} Returns the unescaped string. 32402 * @example 32403 * 32404 * _.unescape('fred, barney, & pebbles'); 32405 * // => 'fred, barney, & pebbles' 32406 */ 32407 function unescape(string) { 32408 string = toString(string); 32409 return (string && reHasEscapedHtml.test(string)) 32410 ? string.replace(reEscapedHtml, unescapeHtmlChar) 32411 : string; 32412 } 32413 32414 /** 32415 * Converts `string`, as space separated words, to upper case. 32416 * 32417 * @static 32418 * @memberOf _ 32419 * @since 4.0.0 32420 * @category String 32421 * @param {string} [string=''] The string to convert. 32422 * @returns {string} Returns the upper cased string. 32423 * @example 32424 * 32425 * _.upperCase('--foo-bar'); 32426 * // => 'FOO BAR' 32427 * 32428 * _.upperCase('fooBar'); 32429 * // => 'FOO BAR' 32430 * 32431 * _.upperCase('__foo_bar__'); 32432 * // => 'FOO BAR' 32433 */ 32434 var upperCase = createCompounder(function(result, word, index) { 32435 return result + (index ? ' ' : '') + word.toUpperCase(); 32436 }); 32437 32438 /** 32439 * Converts the first character of `string` to upper case. 32440 * 32441 * @static 32442 * @memberOf _ 32443 * @since 4.0.0 32444 * @category String 32445 * @param {string} [string=''] The string to convert. 32446 * @returns {string} Returns the converted string. 32447 * @example 32448 * 32449 * _.upperFirst('fred'); 32450 * // => 'Fred' 32451 * 32452 * _.upperFirst('FRED'); 32453 * // => 'FRED' 32454 */ 32455 var upperFirst = createCaseFirst('toUpperCase'); 32456 32457 /** 32458 * Splits `string` into an array of its words. 32459 * 32460 * @static 32461 * @memberOf _ 32462 * @since 3.0.0 32463 * @category String 32464 * @param {string} [string=''] The string to inspect. 32465 * @param {RegExp|string} [pattern] The pattern to match words. 32466 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 32467 * @returns {Array} Returns the words of `string`. 32468 * @example 32469 * 32470 * _.words('fred, barney, & pebbles'); 32471 * // => ['fred', 'barney', 'pebbles'] 32472 * 32473 * _.words('fred, barney, & pebbles', /[^, ]+/g); 32474 * // => ['fred', 'barney', '&', 'pebbles'] 32475 */ 32476 function words(string, pattern, guard) { 32477 string = toString(string); 32478 pattern = guard ? undefined : pattern; 32479 32480 if (pattern === undefined) { 32481 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 32482 } 32483 return string.match(pattern) || []; 32484 } 32485 32486 /*------------------------------------------------------------------------*/ 32487 32488 /** 32489 * Attempts to invoke `func`, returning either the result or the caught error 32490 * object. Any additional arguments are provided to `func` when it's invoked. 32491 * 32492 * @static 32493 * @memberOf _ 32494 * @since 3.0.0 32495 * @category Util 32496 * @param {Function} func The function to attempt. 32497 * @param {...*} [args] The arguments to invoke `func` with. 32498 * @returns {*} Returns the `func` result or error object. 32499 * @example 32500 * 32501 * // Avoid throwing errors for invalid selectors. 32502 * var elements = _.attempt(function(selector) { 32503 * return document.querySelectorAll(selector); 32504 * }, '>_>'); 32505 * 32506 * if (_.isError(elements)) { 32507 * elements = []; 32508 * } 32509 */ 32510 var attempt = baseRest(function(func, args) { 32511 try { 32512 return apply(func, undefined, args); 32513 } catch (e) { 32514 return isError(e) ? e : new Error(e); 32515 } 32516 }); 32517 32518 /** 32519 * Binds methods of an object to the object itself, overwriting the existing 32520 * method. 32521 * 32522 * **Note:** This method doesn't set the "length" property of bound functions. 32523 * 32524 * @static 32525 * @since 0.1.0 32526 * @memberOf _ 32527 * @category Util 32528 * @param {Object} object The object to bind and assign the bound methods to. 32529 * @param {...(string|string[])} methodNames The object method names to bind. 32530 * @returns {Object} Returns `object`. 32531 * @example 32532 * 32533 * var view = { 32534 * 'label': 'docs', 32535 * 'click': function() { 32536 * console.log('clicked ' + this.label); 32537 * } 32538 * }; 32539 * 32540 * _.bindAll(view, ['click']); 32541 * jQuery(element).on('click', view.click); 32542 * // => Logs 'clicked docs' when clicked. 32543 */ 32544 var bindAll = flatRest(function(object, methodNames) { 32545 arrayEach(methodNames, function(key) { 32546 key = toKey(key); 32547 baseAssignValue(object, key, bind(object[key], object)); 32548 }); 32549 return object; 32550 }); 32551 32552 /** 32553 * Creates a function that iterates over `pairs` and invokes the corresponding 32554 * function of the first predicate to return truthy. The predicate-function 32555 * pairs are invoked with the `this` binding and arguments of the created 32556 * function. 32557 * 32558 * @static 32559 * @memberOf _ 32560 * @since 4.0.0 32561 * @category Util 32562 * @param {Array} pairs The predicate-function pairs. 32563 * @returns {Function} Returns the new composite function. 32564 * @example 32565 * 32566 * var func = _.cond([ 32567 * [_.matches({ 'a': 1 }), _.constant('matches A')], 32568 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 32569 * [_.stubTrue, _.constant('no match')] 32570 * ]); 32571 * 32572 * func({ 'a': 1, 'b': 2 }); 32573 * // => 'matches A' 32574 * 32575 * func({ 'a': 0, 'b': 1 }); 32576 * // => 'matches B' 32577 * 32578 * func({ 'a': '1', 'b': '2' }); 32579 * // => 'no match' 32580 */ 32581 function cond(pairs) { 32582 var length = pairs == null ? 0 : pairs.length, 32583 toIteratee = getIteratee(); 32584 32585 pairs = !length ? [] : arrayMap(pairs, function(pair) { 32586 if (typeof pair[1] != 'function') { 32587 throw new TypeError(FUNC_ERROR_TEXT); 32588 } 32589 return [toIteratee(pair[0]), pair[1]]; 32590 }); 32591 32592 return baseRest(function(args) { 32593 var index = -1; 32594 while (++index < length) { 32595 var pair = pairs[index]; 32596 if (apply(pair[0], this, args)) { 32597 return apply(pair[1], this, args); 32598 } 32599 } 32600 }); 32601 } 32602 32603 /** 32604 * Creates a function that invokes the predicate properties of `source` with 32605 * the corresponding property values of a given object, returning `true` if 32606 * all predicates return truthy, else `false`. 32607 * 32608 * **Note:** The created function is equivalent to `_.conformsTo` with 32609 * `source` partially applied. 32610 * 32611 * @static 32612 * @memberOf _ 32613 * @since 4.0.0 32614 * @category Util 32615 * @param {Object} source The object of property predicates to conform to. 32616 * @returns {Function} Returns the new spec function. 32617 * @example 32618 * 32619 * var objects = [ 32620 * { 'a': 2, 'b': 1 }, 32621 * { 'a': 1, 'b': 2 } 32622 * ]; 32623 * 32624 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); 32625 * // => [{ 'a': 1, 'b': 2 }] 32626 */ 32627 function conforms(source) { 32628 return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); 32629 } 32630 32631 /** 32632 * Creates a function that returns `value`. 32633 * 32634 * @static 32635 * @memberOf _ 32636 * @since 2.4.0 32637 * @category Util 32638 * @param {*} value The value to return from the new function. 32639 * @returns {Function} Returns the new constant function. 32640 * @example 32641 * 32642 * var objects = _.times(2, _.constant({ 'a': 1 })); 32643 * 32644 * console.log(objects); 32645 * // => [{ 'a': 1 }, { 'a': 1 }] 32646 * 32647 * console.log(objects[0] === objects[1]); 32648 * // => true 32649 */ 32650 function constant(value) { 32651 return function() { 32652 return value; 32653 }; 32654 } 32655 32656 /** 32657 * Checks `value` to determine whether a default value should be returned in 32658 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, 32659 * or `undefined`. 32660 * 32661 * @static 32662 * @memberOf _ 32663 * @since 4.14.0 32664 * @category Util 32665 * @param {*} value The value to check. 32666 * @param {*} defaultValue The default value. 32667 * @returns {*} Returns the resolved value. 32668 * @example 32669 * 32670 * _.defaultTo(1, 10); 32671 * // => 1 32672 * 32673 * _.defaultTo(undefined, 10); 32674 * // => 10 32675 */ 32676 function defaultTo(value, defaultValue) { 32677 return (value == null || value !== value) ? defaultValue : value; 32678 } 32679 32680 /** 32681 * Creates a function that returns the result of invoking the given functions 32682 * with the `this` binding of the created function, where each successive 32683 * invocation is supplied the return value of the previous. 32684 * 32685 * @static 32686 * @memberOf _ 32687 * @since 3.0.0 32688 * @category Util 32689 * @param {...(Function|Function[])} [funcs] The functions to invoke. 32690 * @returns {Function} Returns the new composite function. 32691 * @see _.flowRight 32692 * @example 32693 * 32694 * function square(n) { 32695 * return n * n; 32696 * } 32697 * 32698 * var addSquare = _.flow([_.add, square]); 32699 * addSquare(1, 2); 32700 * // => 9 32701 */ 32702 var flow = createFlow(); 32703 32704 /** 32705 * This method is like `_.flow` except that it creates a function that 32706 * invokes the given functions from right to left. 32707 * 32708 * @static 32709 * @since 3.0.0 32710 * @memberOf _ 32711 * @category Util 32712 * @param {...(Function|Function[])} [funcs] The functions to invoke. 32713 * @returns {Function} Returns the new composite function. 32714 * @see _.flow 32715 * @example 32716 * 32717 * function square(n) { 32718 * return n * n; 32719 * } 32720 * 32721 * var addSquare = _.flowRight([square, _.add]); 32722 * addSquare(1, 2); 32723 * // => 9 32724 */ 32725 var flowRight = createFlow(true); 32726 32727 /** 32728 * This method returns the first argument it receives. 32729 * 32730 * @static 32731 * @since 0.1.0 32732 * @memberOf _ 32733 * @category Util 32734 * @param {*} value Any value. 32735 * @returns {*} Returns `value`. 32736 * @example 32737 * 32738 * var object = { 'a': 1 }; 32739 * 32740 * console.log(_.identity(object) === object); 32741 * // => true 32742 */ 32743 function identity(value) { 32744 return value; 32745 } 32746 32747 /** 32748 * Creates a function that invokes `func` with the arguments of the created 32749 * function. If `func` is a property name, the created function returns the 32750 * property value for a given element. If `func` is an array or object, the 32751 * created function returns `true` for elements that contain the equivalent 32752 * source properties, otherwise it returns `false`. 32753 * 32754 * @static 32755 * @since 4.0.0 32756 * @memberOf _ 32757 * @category Util 32758 * @param {*} [func=_.identity] The value to convert to a callback. 32759 * @returns {Function} Returns the callback. 32760 * @example 32761 * 32762 * var users = [ 32763 * { 'user': 'barney', 'age': 36, 'active': true }, 32764 * { 'user': 'fred', 'age': 40, 'active': false } 32765 * ]; 32766 * 32767 * // The `_.matches` iteratee shorthand. 32768 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 32769 * // => [{ 'user': 'barney', 'age': 36, 'active': true }] 32770 * 32771 * // The `_.matchesProperty` iteratee shorthand. 32772 * _.filter(users, _.iteratee(['user', 'fred'])); 32773 * // => [{ 'user': 'fred', 'age': 40 }] 32774 * 32775 * // The `_.property` iteratee shorthand. 32776 * _.map(users, _.iteratee('user')); 32777 * // => ['barney', 'fred'] 32778 * 32779 * // Create custom iteratee shorthands. 32780 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 32781 * return !_.isRegExp(func) ? iteratee(func) : function(string) { 32782 * return func.test(string); 32783 * }; 32784 * }); 32785 * 32786 * _.filter(['abc', 'def'], /ef/); 32787 * // => ['def'] 32788 */ 32789 function iteratee(func) { 32790 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); 32791 } 32792 32793 /** 32794 * Creates a function that performs a partial deep comparison between a given 32795 * object and `source`, returning `true` if the given object has equivalent 32796 * property values, else `false`. 32797 * 32798 * **Note:** The created function is equivalent to `_.isMatch` with `source` 32799 * partially applied. 32800 * 32801 * Partial comparisons will match empty array and empty object `source` 32802 * values against any array or object value, respectively. See `_.isEqual` 32803 * for a list of supported value comparisons. 32804 * 32805 * **Note:** Multiple values can be checked by combining several matchers 32806 * using `_.overSome` 32807 * 32808 * @static 32809 * @memberOf _ 32810 * @since 3.0.0 32811 * @category Util 32812 * @param {Object} source The object of property values to match. 32813 * @returns {Function} Returns the new spec function. 32814 * @example 32815 * 32816 * var objects = [ 32817 * { 'a': 1, 'b': 2, 'c': 3 }, 32818 * { 'a': 4, 'b': 5, 'c': 6 } 32819 * ]; 32820 * 32821 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); 32822 * // => [{ 'a': 4, 'b': 5, 'c': 6 }] 32823 * 32824 * // Checking for several possible values 32825 * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); 32826 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 32827 */ 32828 function matches(source) { 32829 return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); 32830 } 32831 32832 /** 32833 * Creates a function that performs a partial deep comparison between the 32834 * value at `path` of a given object to `srcValue`, returning `true` if the 32835 * object value is equivalent, else `false`. 32836 * 32837 * **Note:** Partial comparisons will match empty array and empty object 32838 * `srcValue` values against any array or object value, respectively. See 32839 * `_.isEqual` for a list of supported value comparisons. 32840 * 32841 * **Note:** Multiple values can be checked by combining several matchers 32842 * using `_.overSome` 32843 * 32844 * @static 32845 * @memberOf _ 32846 * @since 3.2.0 32847 * @category Util 32848 * @param {Array|string} path The path of the property to get. 32849 * @param {*} srcValue The value to match. 32850 * @returns {Function} Returns the new spec function. 32851 * @example 32852 * 32853 * var objects = [ 32854 * { 'a': 1, 'b': 2, 'c': 3 }, 32855 * { 'a': 4, 'b': 5, 'c': 6 } 32856 * ]; 32857 * 32858 * _.find(objects, _.matchesProperty('a', 4)); 32859 * // => { 'a': 4, 'b': 5, 'c': 6 } 32860 * 32861 * // Checking for several possible values 32862 * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); 32863 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 32864 */ 32865 function matchesProperty(path, srcValue) { 32866 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); 32867 } 32868 32869 /** 32870 * Creates a function that invokes the method at `path` of a given object. 32871 * Any additional arguments are provided to the invoked method. 32872 * 32873 * @static 32874 * @memberOf _ 32875 * @since 3.7.0 32876 * @category Util 32877 * @param {Array|string} path The path of the method to invoke. 32878 * @param {...*} [args] The arguments to invoke the method with. 32879 * @returns {Function} Returns the new invoker function. 32880 * @example 32881 * 32882 * var objects = [ 32883 * { 'a': { 'b': _.constant(2) } }, 32884 * { 'a': { 'b': _.constant(1) } } 32885 * ]; 32886 * 32887 * _.map(objects, _.method('a.b')); 32888 * // => [2, 1] 32889 * 32890 * _.map(objects, _.method(['a', 'b'])); 32891 * // => [2, 1] 32892 */ 32893 var method = baseRest(function(path, args) { 32894 return function(object) { 32895 return baseInvoke(object, path, args); 32896 }; 32897 }); 32898 32899 /** 32900 * The opposite of `_.method`; this method creates a function that invokes 32901 * the method at a given path of `object`. Any additional arguments are 32902 * provided to the invoked method. 32903 * 32904 * @static 32905 * @memberOf _ 32906 * @since 3.7.0 32907 * @category Util 32908 * @param {Object} object The object to query. 32909 * @param {...*} [args] The arguments to invoke the method with. 32910 * @returns {Function} Returns the new invoker function. 32911 * @example 32912 * 32913 * var array = _.times(3, _.constant), 32914 * object = { 'a': array, 'b': array, 'c': array }; 32915 * 32916 * _.map(['a[2]', 'c[0]'], _.methodOf(object)); 32917 * // => [2, 0] 32918 * 32919 * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); 32920 * // => [2, 0] 32921 */ 32922 var methodOf = baseRest(function(object, args) { 32923 return function(path) { 32924 return baseInvoke(object, path, args); 32925 }; 32926 }); 32927 32928 /** 32929 * Adds all own enumerable string keyed function properties of a source 32930 * object to the destination object. If `object` is a function, then methods 32931 * are added to its prototype as well. 32932 * 32933 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to 32934 * avoid conflicts caused by modifying the original. 32935 * 32936 * @static 32937 * @since 0.1.0 32938 * @memberOf _ 32939 * @category Util 32940 * @param {Function|Object} [object=lodash] The destination object. 32941 * @param {Object} source The object of functions to add. 32942 * @param {Object} [options={}] The options object. 32943 * @param {boolean} [options.chain=true] Specify whether mixins are chainable. 32944 * @returns {Function|Object} Returns `object`. 32945 * @example 32946 * 32947 * function vowels(string) { 32948 * return _.filter(string, function(v) { 32949 * return /[aeiou]/i.test(v); 32950 * }); 32951 * } 32952 * 32953 * _.mixin({ 'vowels': vowels }); 32954 * _.vowels('fred'); 32955 * // => ['e'] 32956 * 32957 * _('fred').vowels().value(); 32958 * // => ['e'] 32959 * 32960 * _.mixin({ 'vowels': vowels }, { 'chain': false }); 32961 * _('fred').vowels(); 32962 * // => ['e'] 32963 */ 32964 function mixin(object, source, options) { 32965 var props = keys(source), 32966 methodNames = baseFunctions(source, props); 32967 32968 if (options == null && 32969 !(isObject(source) && (methodNames.length || !props.length))) { 32970 options = source; 32971 source = object; 32972 object = this; 32973 methodNames = baseFunctions(source, keys(source)); 32974 } 32975 var chain = !(isObject(options) && 'chain' in options) || !!options.chain, 32976 isFunc = isFunction(object); 32977 32978 arrayEach(methodNames, function(methodName) { 32979 var func = source[methodName]; 32980 object[methodName] = func; 32981 if (isFunc) { 32982 object.prototype[methodName] = function() { 32983 var chainAll = this.__chain__; 32984 if (chain || chainAll) { 32985 var result = object(this.__wrapped__), 32986 actions = result.__actions__ = copyArray(this.__actions__); 32987 32988 actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); 32989 result.__chain__ = chainAll; 32990 return result; 32991 } 32992 return func.apply(object, arrayPush([this.value()], arguments)); 32993 }; 32994 } 32995 }); 32996 32997 return object; 32998 } 32999 33000 /** 33001 * Reverts the `_` variable to its previous value and returns a reference to 33002 * the `lodash` function. 33003 * 33004 * @static 33005 * @since 0.1.0 33006 * @memberOf _ 33007 * @category Util 33008 * @returns {Function} Returns the `lodash` function. 33009 * @example 33010 * 33011 * var lodash = _.noConflict(); 33012 */ 33013 function noConflict() { 33014 if (root._ === this) { 33015 root._ = oldDash; 33016 } 33017 return this; 33018 } 33019 33020 /** 33021 * This method returns `undefined`. 33022 * 33023 * @static 33024 * @memberOf _ 33025 * @since 2.3.0 33026 * @category Util 33027 * @example 33028 * 33029 * _.times(2, _.noop); 33030 * // => [undefined, undefined] 33031 */ 33032 function noop() { 33033 // No operation performed. 33034 } 33035 33036 /** 33037 * Creates a function that gets the argument at index `n`. If `n` is negative, 33038 * the nth argument from the end is returned. 33039 * 33040 * @static 33041 * @memberOf _ 33042 * @since 4.0.0 33043 * @category Util 33044 * @param {number} [n=0] The index of the argument to return. 33045 * @returns {Function} Returns the new pass-thru function. 33046 * @example 33047 * 33048 * var func = _.nthArg(1); 33049 * func('a', 'b', 'c', 'd'); 33050 * // => 'b' 33051 * 33052 * var func = _.nthArg(-2); 33053 * func('a', 'b', 'c', 'd'); 33054 * // => 'c' 33055 */ 33056 function nthArg(n) { 33057 n = toInteger(n); 33058 return baseRest(function(args) { 33059 return baseNth(args, n); 33060 }); 33061 } 33062 33063 /** 33064 * Creates a function that invokes `iteratees` with the arguments it receives 33065 * and returns their results. 33066 * 33067 * @static 33068 * @memberOf _ 33069 * @since 4.0.0 33070 * @category Util 33071 * @param {...(Function|Function[])} [iteratees=[_.identity]] 33072 * The iteratees to invoke. 33073 * @returns {Function} Returns the new function. 33074 * @example 33075 * 33076 * var func = _.over([Math.max, Math.min]); 33077 * 33078 * func(1, 2, 3, 4); 33079 * // => [4, 1] 33080 */ 33081 var over = createOver(arrayMap); 33082 33083 /** 33084 * Creates a function that checks if **all** of the `predicates` return 33085 * truthy when invoked with the arguments it receives. 33086 * 33087 * Following shorthands are possible for providing predicates. 33088 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 33089 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 33090 * 33091 * @static 33092 * @memberOf _ 33093 * @since 4.0.0 33094 * @category Util 33095 * @param {...(Function|Function[])} [predicates=[_.identity]] 33096 * The predicates to check. 33097 * @returns {Function} Returns the new function. 33098 * @example 33099 * 33100 * var func = _.overEvery([Boolean, isFinite]); 33101 * 33102 * func('1'); 33103 * // => true 33104 * 33105 * func(null); 33106 * // => false 33107 * 33108 * func(NaN); 33109 * // => false 33110 */ 33111 var overEvery = createOver(arrayEvery); 33112 33113 /** 33114 * Creates a function that checks if **any** of the `predicates` return 33115 * truthy when invoked with the arguments it receives. 33116 * 33117 * Following shorthands are possible for providing predicates. 33118 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 33119 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 33120 * 33121 * @static 33122 * @memberOf _ 33123 * @since 4.0.0 33124 * @category Util 33125 * @param {...(Function|Function[])} [predicates=[_.identity]] 33126 * The predicates to check. 33127 * @returns {Function} Returns the new function. 33128 * @example 33129 * 33130 * var func = _.overSome([Boolean, isFinite]); 33131 * 33132 * func('1'); 33133 * // => true 33134 * 33135 * func(null); 33136 * // => true 33137 * 33138 * func(NaN); 33139 * // => false 33140 * 33141 * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) 33142 * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) 33143 */ 33144 var overSome = createOver(arraySome); 33145 33146 /** 33147 * Creates a function that returns the value at `path` of a given object. 33148 * 33149 * @static 33150 * @memberOf _ 33151 * @since 2.4.0 33152 * @category Util 33153 * @param {Array|string} path The path of the property to get. 33154 * @returns {Function} Returns the new accessor function. 33155 * @example 33156 * 33157 * var objects = [ 33158 * { 'a': { 'b': 2 } }, 33159 * { 'a': { 'b': 1 } } 33160 * ]; 33161 * 33162 * _.map(objects, _.property('a.b')); 33163 * // => [2, 1] 33164 * 33165 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); 33166 * // => [1, 2] 33167 */ 33168 function property(path) { 33169 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); 33170 } 33171 33172 /** 33173 * The opposite of `_.property`; this method creates a function that returns 33174 * the value at a given path of `object`. 33175 * 33176 * @static 33177 * @memberOf _ 33178 * @since 3.0.0 33179 * @category Util 33180 * @param {Object} object The object to query. 33181 * @returns {Function} Returns the new accessor function. 33182 * @example 33183 * 33184 * var array = [0, 1, 2], 33185 * object = { 'a': array, 'b': array, 'c': array }; 33186 * 33187 * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); 33188 * // => [2, 0] 33189 * 33190 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); 33191 * // => [2, 0] 33192 */ 33193 function propertyOf(object) { 33194 return function(path) { 33195 return object == null ? undefined : baseGet(object, path); 33196 }; 33197 } 33198 33199 /** 33200 * Creates an array of numbers (positive and/or negative) progressing from 33201 * `start` up to, but not including, `end`. A step of `-1` is used if a negative 33202 * `start` is specified without an `end` or `step`. If `end` is not specified, 33203 * it's set to `start` with `start` then set to `0`. 33204 * 33205 * **Note:** JavaScript follows the IEEE-754 standard for resolving 33206 * floating-point values which can produce unexpected results. 33207 * 33208 * @static 33209 * @since 0.1.0 33210 * @memberOf _ 33211 * @category Util 33212 * @param {number} [start=0] The start of the range. 33213 * @param {number} end The end of the range. 33214 * @param {number} [step=1] The value to increment or decrement by. 33215 * @returns {Array} Returns the range of numbers. 33216 * @see _.inRange, _.rangeRight 33217 * @example 33218 * 33219 * _.range(4); 33220 * // => [0, 1, 2, 3] 33221 * 33222 * _.range(-4); 33223 * // => [0, -1, -2, -3] 33224 * 33225 * _.range(1, 5); 33226 * // => [1, 2, 3, 4] 33227 * 33228 * _.range(0, 20, 5); 33229 * // => [0, 5, 10, 15] 33230 * 33231 * _.range(0, -4, -1); 33232 * // => [0, -1, -2, -3] 33233 * 33234 * _.range(1, 4, 0); 33235 * // => [1, 1, 1] 33236 * 33237 * _.range(0); 33238 * // => [] 33239 */ 33240 var range = createRange(); 33241 33242 /** 33243 * This method is like `_.range` except that it populates values in 33244 * descending order. 33245 * 33246 * @static 33247 * @memberOf _ 33248 * @since 4.0.0 33249 * @category Util 33250 * @param {number} [start=0] The start of the range. 33251 * @param {number} end The end of the range. 33252 * @param {number} [step=1] The value to increment or decrement by. 33253 * @returns {Array} Returns the range of numbers. 33254 * @see _.inRange, _.range 33255 * @example 33256 * 33257 * _.rangeRight(4); 33258 * // => [3, 2, 1, 0] 33259 * 33260 * _.rangeRight(-4); 33261 * // => [-3, -2, -1, 0] 33262 * 33263 * _.rangeRight(1, 5); 33264 * // => [4, 3, 2, 1] 33265 * 33266 * _.rangeRight(0, 20, 5); 33267 * // => [15, 10, 5, 0] 33268 * 33269 * _.rangeRight(0, -4, -1); 33270 * // => [-3, -2, -1, 0] 33271 * 33272 * _.rangeRight(1, 4, 0); 33273 * // => [1, 1, 1] 33274 * 33275 * _.rangeRight(0); 33276 * // => [] 33277 */ 33278 var rangeRight = createRange(true); 33279 33280 /** 33281 * This method returns a new empty array. 33282 * 33283 * @static 33284 * @memberOf _ 33285 * @since 4.13.0 33286 * @category Util 33287 * @returns {Array} Returns the new empty array. 33288 * @example 33289 * 33290 * var arrays = _.times(2, _.stubArray); 33291 * 33292 * console.log(arrays); 33293 * // => [[], []] 33294 * 33295 * console.log(arrays[0] === arrays[1]); 33296 * // => false 33297 */ 33298 function stubArray() { 33299 return []; 33300 } 33301 33302 /** 33303 * This method returns `false`. 33304 * 33305 * @static 33306 * @memberOf _ 33307 * @since 4.13.0 33308 * @category Util 33309 * @returns {boolean} Returns `false`. 33310 * @example 33311 * 33312 * _.times(2, _.stubFalse); 33313 * // => [false, false] 33314 */ 33315 function stubFalse() { 33316 return false; 33317 } 33318 33319 /** 33320 * This method returns a new empty object. 33321 * 33322 * @static 33323 * @memberOf _ 33324 * @since 4.13.0 33325 * @category Util 33326 * @returns {Object} Returns the new empty object. 33327 * @example 33328 * 33329 * var objects = _.times(2, _.stubObject); 33330 * 33331 * console.log(objects); 33332 * // => [{}, {}] 33333 * 33334 * console.log(objects[0] === objects[1]); 33335 * // => false 33336 */ 33337 function stubObject() { 33338 return {}; 33339 } 33340 33341 /** 33342 * This method returns an empty string. 33343 * 33344 * @static 33345 * @memberOf _ 33346 * @since 4.13.0 33347 * @category Util 33348 * @returns {string} Returns the empty string. 33349 * @example 33350 * 33351 * _.times(2, _.stubString); 33352 * // => ['', ''] 33353 */ 33354 function stubString() { 33355 return ''; 33356 } 33357 33358 /** 33359 * This method returns `true`. 33360 * 33361 * @static 33362 * @memberOf _ 33363 * @since 4.13.0 33364 * @category Util 33365 * @returns {boolean} Returns `true`. 33366 * @example 33367 * 33368 * _.times(2, _.stubTrue); 33369 * // => [true, true] 33370 */ 33371 function stubTrue() { 33372 return true; 33373 } 33374 33375 /** 33376 * Invokes the iteratee `n` times, returning an array of the results of 33377 * each invocation. The iteratee is invoked with one argument; (index). 33378 * 33379 * @static 33380 * @since 0.1.0 33381 * @memberOf _ 33382 * @category Util 33383 * @param {number} n The number of times to invoke `iteratee`. 33384 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 33385 * @returns {Array} Returns the array of results. 33386 * @example 33387 * 33388 * _.times(3, String); 33389 * // => ['0', '1', '2'] 33390 * 33391 * _.times(4, _.constant(0)); 33392 * // => [0, 0, 0, 0] 33393 */ 33394 function times(n, iteratee) { 33395 n = toInteger(n); 33396 if (n < 1 || n > MAX_SAFE_INTEGER) { 33397 return []; 33398 } 33399 var index = MAX_ARRAY_LENGTH, 33400 length = nativeMin(n, MAX_ARRAY_LENGTH); 33401 33402 iteratee = getIteratee(iteratee); 33403 n -= MAX_ARRAY_LENGTH; 33404 33405 var result = baseTimes(length, iteratee); 33406 while (++index < n) { 33407 iteratee(index); 33408 } 33409 return result; 33410 } 33411 33412 /** 33413 * Converts `value` to a property path array. 33414 * 33415 * @static 33416 * @memberOf _ 33417 * @since 4.0.0 33418 * @category Util 33419 * @param {*} value The value to convert. 33420 * @returns {Array} Returns the new property path array. 33421 * @example 33422 * 33423 * _.toPath('a.b.c'); 33424 * // => ['a', 'b', 'c'] 33425 * 33426 * _.toPath('a[0].b.c'); 33427 * // => ['a', '0', 'b', 'c'] 33428 */ 33429 function toPath(value) { 33430 if (isArray(value)) { 33431 return arrayMap(value, toKey); 33432 } 33433 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); 33434 } 33435 33436 /** 33437 * Generates a unique ID. If `prefix` is given, the ID is appended to it. 33438 * 33439 * @static 33440 * @since 0.1.0 33441 * @memberOf _ 33442 * @category Util 33443 * @param {string} [prefix=''] The value to prefix the ID with. 33444 * @returns {string} Returns the unique ID. 33445 * @example 33446 * 33447 * _.uniqueId('contact_'); 33448 * // => 'contact_104' 33449 * 33450 * _.uniqueId(); 33451 * // => '105' 33452 */ 33453 function uniqueId(prefix) { 33454 var id = ++idCounter; 33455 return toString(prefix) + id; 33456 } 33457 33458 /*------------------------------------------------------------------------*/ 33459 33460 /** 33461 * Adds two numbers. 33462 * 33463 * @static 33464 * @memberOf _ 33465 * @since 3.4.0 33466 * @category Math 33467 * @param {number} augend The first number in an addition. 33468 * @param {number} addend The second number in an addition. 33469 * @returns {number} Returns the total. 33470 * @example 33471 * 33472 * _.add(6, 4); 33473 * // => 10 33474 */ 33475 var add = createMathOperation(function(augend, addend) { 33476 return augend + addend; 33477 }, 0); 33478 33479 /** 33480 * Computes `number` rounded up to `precision`. 33481 * 33482 * @static 33483 * @memberOf _ 33484 * @since 3.10.0 33485 * @category Math 33486 * @param {number} number The number to round up. 33487 * @param {number} [precision=0] The precision to round up to. 33488 * @returns {number} Returns the rounded up number. 33489 * @example 33490 * 33491 * _.ceil(4.006); 33492 * // => 5 33493 * 33494 * _.ceil(6.004, 2); 33495 * // => 6.01 33496 * 33497 * _.ceil(6040, -2); 33498 * // => 6100 33499 */ 33500 var ceil = createRound('ceil'); 33501 33502 /** 33503 * Divide two numbers. 33504 * 33505 * @static 33506 * @memberOf _ 33507 * @since 4.7.0 33508 * @category Math 33509 * @param {number} dividend The first number in a division. 33510 * @param {number} divisor The second number in a division. 33511 * @returns {number} Returns the quotient. 33512 * @example 33513 * 33514 * _.divide(6, 4); 33515 * // => 1.5 33516 */ 33517 var divide = createMathOperation(function(dividend, divisor) { 33518 return dividend / divisor; 33519 }, 1); 33520 33521 /** 33522 * Computes `number` rounded down to `precision`. 33523 * 33524 * @static 33525 * @memberOf _ 33526 * @since 3.10.0 33527 * @category Math 33528 * @param {number} number The number to round down. 33529 * @param {number} [precision=0] The precision to round down to. 33530 * @returns {number} Returns the rounded down number. 33531 * @example 33532 * 33533 * _.floor(4.006); 33534 * // => 4 33535 * 33536 * _.floor(0.046, 2); 33537 * // => 0.04 33538 * 33539 * _.floor(4060, -2); 33540 * // => 4000 33541 */ 33542 var floor = createRound('floor'); 33543 33544 /** 33545 * Computes the maximum value of `array`. If `array` is empty or falsey, 33546 * `undefined` is returned. 33547 * 33548 * @static 33549 * @since 0.1.0 33550 * @memberOf _ 33551 * @category Math 33552 * @param {Array} array The array to iterate over. 33553 * @returns {*} Returns the maximum value. 33554 * @example 33555 * 33556 * _.max([4, 2, 8, 6]); 33557 * // => 8 33558 * 33559 * _.max([]); 33560 * // => undefined 33561 */ 33562 function max(array) { 33563 return (array && array.length) 33564 ? baseExtremum(array, identity, baseGt) 33565 : undefined; 33566 } 33567 33568 /** 33569 * This method is like `_.max` except that it accepts `iteratee` which is 33570 * invoked for each element in `array` to generate the criterion by which 33571 * the value is ranked. The iteratee is invoked with one argument: (value). 33572 * 33573 * @static 33574 * @memberOf _ 33575 * @since 4.0.0 33576 * @category Math 33577 * @param {Array} array The array to iterate over. 33578 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 33579 * @returns {*} Returns the maximum value. 33580 * @example 33581 * 33582 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 33583 * 33584 * _.maxBy(objects, function(o) { return o.n; }); 33585 * // => { 'n': 2 } 33586 * 33587 * // The `_.property` iteratee shorthand. 33588 * _.maxBy(objects, 'n'); 33589 * // => { 'n': 2 } 33590 */ 33591 function maxBy(array, iteratee) { 33592 return (array && array.length) 33593 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) 33594 : undefined; 33595 } 33596 33597 /** 33598 * Computes the mean of the values in `array`. 33599 * 33600 * @static 33601 * @memberOf _ 33602 * @since 4.0.0 33603 * @category Math 33604 * @param {Array} array The array to iterate over. 33605 * @returns {number} Returns the mean. 33606 * @example 33607 * 33608 * _.mean([4, 2, 8, 6]); 33609 * // => 5 33610 */ 33611 function mean(array) { 33612 return baseMean(array, identity); 33613 } 33614 33615 /** 33616 * This method is like `_.mean` except that it accepts `iteratee` which is 33617 * invoked for each element in `array` to generate the value to be averaged. 33618 * The iteratee is invoked with one argument: (value). 33619 * 33620 * @static 33621 * @memberOf _ 33622 * @since 4.7.0 33623 * @category Math 33624 * @param {Array} array The array to iterate over. 33625 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 33626 * @returns {number} Returns the mean. 33627 * @example 33628 * 33629 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 33630 * 33631 * _.meanBy(objects, function(o) { return o.n; }); 33632 * // => 5 33633 * 33634 * // The `_.property` iteratee shorthand. 33635 * _.meanBy(objects, 'n'); 33636 * // => 5 33637 */ 33638 function meanBy(array, iteratee) { 33639 return baseMean(array, getIteratee(iteratee, 2)); 33640 } 33641 33642 /** 33643 * Computes the minimum value of `array`. If `array` is empty or falsey, 33644 * `undefined` is returned. 33645 * 33646 * @static 33647 * @since 0.1.0 33648 * @memberOf _ 33649 * @category Math 33650 * @param {Array} array The array to iterate over. 33651 * @returns {*} Returns the minimum value. 33652 * @example 33653 * 33654 * _.min([4, 2, 8, 6]); 33655 * // => 2 33656 * 33657 * _.min([]); 33658 * // => undefined 33659 */ 33660 function min(array) { 33661 return (array && array.length) 33662 ? baseExtremum(array, identity, baseLt) 33663 : undefined; 33664 } 33665 33666 /** 33667 * This method is like `_.min` except that it accepts `iteratee` which is 33668 * invoked for each element in `array` to generate the criterion by which 33669 * the value is ranked. The iteratee is invoked with one argument: (value). 33670 * 33671 * @static 33672 * @memberOf _ 33673 * @since 4.0.0 33674 * @category Math 33675 * @param {Array} array The array to iterate over. 33676 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 33677 * @returns {*} Returns the minimum value. 33678 * @example 33679 * 33680 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 33681 * 33682 * _.minBy(objects, function(o) { return o.n; }); 33683 * // => { 'n': 1 } 33684 * 33685 * // The `_.property` iteratee shorthand. 33686 * _.minBy(objects, 'n'); 33687 * // => { 'n': 1 } 33688 */ 33689 function minBy(array, iteratee) { 33690 return (array && array.length) 33691 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) 33692 : undefined; 33693 } 33694 33695 /** 33696 * Multiply two numbers. 33697 * 33698 * @static 33699 * @memberOf _ 33700 * @since 4.7.0 33701 * @category Math 33702 * @param {number} multiplier The first number in a multiplication. 33703 * @param {number} multiplicand The second number in a multiplication. 33704 * @returns {number} Returns the product. 33705 * @example 33706 * 33707 * _.multiply(6, 4); 33708 * // => 24 33709 */ 33710 var multiply = createMathOperation(function(multiplier, multiplicand) { 33711 return multiplier * multiplicand; 33712 }, 1); 33713 33714 /** 33715 * Computes `number` rounded to `precision`. 33716 * 33717 * @static 33718 * @memberOf _ 33719 * @since 3.10.0 33720 * @category Math 33721 * @param {number} number The number to round. 33722 * @param {number} [precision=0] The precision to round to. 33723 * @returns {number} Returns the rounded number. 33724 * @example 33725 * 33726 * _.round(4.006); 33727 * // => 4 33728 * 33729 * _.round(4.006, 2); 33730 * // => 4.01 33731 * 33732 * _.round(4060, -2); 33733 * // => 4100 33734 */ 33735 var round = createRound('round'); 33736 33737 /** 33738 * Subtract two numbers. 33739 * 33740 * @static 33741 * @memberOf _ 33742 * @since 4.0.0 33743 * @category Math 33744 * @param {number} minuend The first number in a subtraction. 33745 * @param {number} subtrahend The second number in a subtraction. 33746 * @returns {number} Returns the difference. 33747 * @example 33748 * 33749 * _.subtract(6, 4); 33750 * // => 2 33751 */ 33752 var subtract = createMathOperation(function(minuend, subtrahend) { 33753 return minuend - subtrahend; 33754 }, 0); 33755 33756 /** 33757 * Computes the sum of the values in `array`. 33758 * 33759 * @static 33760 * @memberOf _ 33761 * @since 3.4.0 33762 * @category Math 33763 * @param {Array} array The array to iterate over. 33764 * @returns {number} Returns the sum. 33765 * @example 33766 * 33767 * _.sum([4, 2, 8, 6]); 33768 * // => 20 33769 */ 33770 function sum(array) { 33771 return (array && array.length) 33772 ? baseSum(array, identity) 33773 : 0; 33774 } 33775 33776 /** 33777 * This method is like `_.sum` except that it accepts `iteratee` which is 33778 * invoked for each element in `array` to generate the value to be summed. 33779 * The iteratee is invoked with one argument: (value). 33780 * 33781 * @static 33782 * @memberOf _ 33783 * @since 4.0.0 33784 * @category Math 33785 * @param {Array} array The array to iterate over. 33786 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 33787 * @returns {number} Returns the sum. 33788 * @example 33789 * 33790 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 33791 * 33792 * _.sumBy(objects, function(o) { return o.n; }); 33793 * // => 20 33794 * 33795 * // The `_.property` iteratee shorthand. 33796 * _.sumBy(objects, 'n'); 33797 * // => 20 33798 */ 33799 function sumBy(array, iteratee) { 33800 return (array && array.length) 33801 ? baseSum(array, getIteratee(iteratee, 2)) 33802 : 0; 33803 } 33804 33805 /*------------------------------------------------------------------------*/ 33806 33807 // Add methods that return wrapped values in chain sequences. 33808 lodash.after = after; 33809 lodash.ary = ary; 33810 lodash.assign = assign; 33811 lodash.assignIn = assignIn; 33812 lodash.assignInWith = assignInWith; 33813 lodash.assignWith = assignWith; 33814 lodash.at = at; 33815 lodash.before = before; 33816 lodash.bind = bind; 33817 lodash.bindAll = bindAll; 33818 lodash.bindKey = bindKey; 33819 lodash.castArray = castArray; 33820 lodash.chain = chain; 33821 lodash.chunk = chunk; 33822 lodash.compact = compact; 33823 lodash.concat = concat; 33824 lodash.cond = cond; 33825 lodash.conforms = conforms; 33826 lodash.constant = constant; 33827 lodash.countBy = countBy; 33828 lodash.create = create; 33829 lodash.curry = curry; 33830 lodash.curryRight = curryRight; 33831 lodash.debounce = debounce; 33832 lodash.defaults = defaults; 33833 lodash.defaultsDeep = defaultsDeep; 33834 lodash.defer = defer; 33835 lodash.delay = delay; 33836 lodash.difference = difference; 33837 lodash.differenceBy = differenceBy; 33838 lodash.differenceWith = differenceWith; 33839 lodash.drop = drop; 33840 lodash.dropRight = dropRight; 33841 lodash.dropRightWhile = dropRightWhile; 33842 lodash.dropWhile = dropWhile; 33843 lodash.fill = fill; 33844 lodash.filter = filter; 33845 lodash.flatMap = flatMap; 33846 lodash.flatMapDeep = flatMapDeep; 33847 lodash.flatMapDepth = flatMapDepth; 33848 lodash.flatten = flatten; 33849 lodash.flattenDeep = flattenDeep; 33850 lodash.flattenDepth = flattenDepth; 33851 lodash.flip = flip; 33852 lodash.flow = flow; 33853 lodash.flowRight = flowRight; 33854 lodash.fromPairs = fromPairs; 33855 lodash.functions = functions; 33856 lodash.functionsIn = functionsIn; 33857 lodash.groupBy = groupBy; 33858 lodash.initial = initial; 33859 lodash.intersection = intersection; 33860 lodash.intersectionBy = intersectionBy; 33861 lodash.intersectionWith = intersectionWith; 33862 lodash.invert = invert; 33863 lodash.invertBy = invertBy; 33864 lodash.invokeMap = invokeMap; 33865 lodash.iteratee = iteratee; 33866 lodash.keyBy = keyBy; 33867 lodash.keys = keys; 33868 lodash.keysIn = keysIn; 33869 lodash.map = map; 33870 lodash.mapKeys = mapKeys; 33871 lodash.mapValues = mapValues; 33872 lodash.matches = matches; 33873 lodash.matchesProperty = matchesProperty; 33874 lodash.memoize = memoize; 33875 lodash.merge = merge; 33876 lodash.mergeWith = mergeWith; 33877 lodash.method = method; 33878 lodash.methodOf = methodOf; 33879 lodash.mixin = mixin; 33880 lodash.negate = negate; 33881 lodash.nthArg = nthArg; 33882 lodash.omit = omit; 33883 lodash.omitBy = omitBy; 33884 lodash.once = once; 33885 lodash.orderBy = orderBy; 33886 lodash.over = over; 33887 lodash.overArgs = overArgs; 33888 lodash.overEvery = overEvery; 33889 lodash.overSome = overSome; 33890 lodash.partial = partial; 33891 lodash.partialRight = partialRight; 33892 lodash.partition = partition; 33893 lodash.pick = pick; 33894 lodash.pickBy = pickBy; 33895 lodash.property = property; 33896 lodash.propertyOf = propertyOf; 33897 lodash.pull = pull; 33898 lodash.pullAll = pullAll; 33899 lodash.pullAllBy = pullAllBy; 33900 lodash.pullAllWith = pullAllWith; 33901 lodash.pullAt = pullAt; 33902 lodash.range = range; 33903 lodash.rangeRight = rangeRight; 33904 lodash.rearg = rearg; 33905 lodash.reject = reject; 33906 lodash.remove = remove; 33907 lodash.rest = rest; 33908 lodash.reverse = reverse; 33909 lodash.sampleSize = sampleSize; 33910 lodash.set = set; 33911 lodash.setWith = setWith; 33912 lodash.shuffle = shuffle; 33913 lodash.slice = slice; 33914 lodash.sortBy = sortBy; 33915 lodash.sortedUniq = sortedUniq; 33916 lodash.sortedUniqBy = sortedUniqBy; 33917 lodash.split = split; 33918 lodash.spread = spread; 33919 lodash.tail = tail; 33920 lodash.take = take; 33921 lodash.takeRight = takeRight; 33922 lodash.takeRightWhile = takeRightWhile; 33923 lodash.takeWhile = takeWhile; 33924 lodash.tap = tap; 33925 lodash.throttle = throttle; 33926 lodash.thru = thru; 33927 lodash.toArray = toArray; 33928 lodash.toPairs = toPairs; 33929 lodash.toPairsIn = toPairsIn; 33930 lodash.toPath = toPath; 33931 lodash.toPlainObject = toPlainObject; 33932 lodash.transform = transform; 33933 lodash.unary = unary; 33934 lodash.union = union; 33935 lodash.unionBy = unionBy; 33936 lodash.unionWith = unionWith; 33937 lodash.uniq = uniq; 33938 lodash.uniqBy = uniqBy; 33939 lodash.uniqWith = uniqWith; 33940 lodash.unset = unset; 33941 lodash.unzip = unzip; 33942 lodash.unzipWith = unzipWith; 33943 lodash.update = update; 33944 lodash.updateWith = updateWith; 33945 lodash.values = values; 33946 lodash.valuesIn = valuesIn; 33947 lodash.without = without; 33948 lodash.words = words; 33949 lodash.wrap = wrap; 33950 lodash.xor = xor; 33951 lodash.xorBy = xorBy; 33952 lodash.xorWith = xorWith; 33953 lodash.zip = zip; 33954 lodash.zipObject = zipObject; 33955 lodash.zipObjectDeep = zipObjectDeep; 33956 lodash.zipWith = zipWith; 33957 33958 // Add aliases. 33959 lodash.entries = toPairs; 33960 lodash.entriesIn = toPairsIn; 33961 lodash.extend = assignIn; 33962 lodash.extendWith = assignInWith; 33963 33964 // Add methods to `lodash.prototype`. 33965 mixin(lodash, lodash); 33966 33967 /*------------------------------------------------------------------------*/ 33968 33969 // Add methods that return unwrapped values in chain sequences. 33970 lodash.add = add; 33971 lodash.attempt = attempt; 33972 lodash.camelCase = camelCase; 33973 lodash.capitalize = capitalize; 33974 lodash.ceil = ceil; 33975 lodash.clamp = clamp; 33976 lodash.clone = clone; 33977 lodash.cloneDeep = cloneDeep; 33978 lodash.cloneDeepWith = cloneDeepWith; 33979 lodash.cloneWith = cloneWith; 33980 lodash.conformsTo = conformsTo; 33981 lodash.deburr = deburr; 33982 lodash.defaultTo = defaultTo; 33983 lodash.divide = divide; 33984 lodash.endsWith = endsWith; 33985 lodash.eq = eq; 33986 lodash.escape = escape; 33987 lodash.escapeRegExp = escapeRegExp; 33988 lodash.every = every; 33989 lodash.find = find; 33990 lodash.findIndex = findIndex; 33991 lodash.findKey = findKey; 33992 lodash.findLast = findLast; 33993 lodash.findLastIndex = findLastIndex; 33994 lodash.findLastKey = findLastKey; 33995 lodash.floor = floor; 33996 lodash.forEach = forEach; 33997 lodash.forEachRight = forEachRight; 33998 lodash.forIn = forIn; 33999 lodash.forInRight = forInRight; 34000 lodash.forOwn = forOwn; 34001 lodash.forOwnRight = forOwnRight; 34002 lodash.get = get; 34003 lodash.gt = gt; 34004 lodash.gte = gte; 34005 lodash.has = has; 34006 lodash.hasIn = hasIn; 34007 lodash.head = head; 34008 lodash.identity = identity; 34009 lodash.includes = includes; 34010 lodash.indexOf = indexOf; 34011 lodash.inRange = inRange; 34012 lodash.invoke = invoke; 34013 lodash.isArguments = isArguments; 34014 lodash.isArray = isArray; 34015 lodash.isArrayBuffer = isArrayBuffer; 34016 lodash.isArrayLike = isArrayLike; 34017 lodash.isArrayLikeObject = isArrayLikeObject; 34018 lodash.isBoolean = isBoolean; 34019 lodash.isBuffer = isBuffer; 34020 lodash.isDate = isDate; 34021 lodash.isElement = isElement; 34022 lodash.isEmpty = isEmpty; 34023 lodash.isEqual = isEqual; 34024 lodash.isEqualWith = isEqualWith; 34025 lodash.isError = isError; 34026 lodash.isFinite = isFinite; 34027 lodash.isFunction = isFunction; 34028 lodash.isInteger = isInteger; 34029 lodash.isLength = isLength; 34030 lodash.isMap = isMap; 34031 lodash.isMatch = isMatch; 34032 lodash.isMatchWith = isMatchWith; 34033 lodash.isNaN = isNaN; 34034 lodash.isNative = isNative; 34035 lodash.isNil = isNil; 34036 lodash.isNull = isNull; 34037 lodash.isNumber = isNumber; 34038 lodash.isObject = isObject; 34039 lodash.isObjectLike = isObjectLike; 34040 lodash.isPlainObject = isPlainObject; 34041 lodash.isRegExp = isRegExp; 34042 lodash.isSafeInteger = isSafeInteger; 34043 lodash.isSet = isSet; 34044 lodash.isString = isString; 34045 lodash.isSymbol = isSymbol; 34046 lodash.isTypedArray = isTypedArray; 34047 lodash.isUndefined = isUndefined; 34048 lodash.isWeakMap = isWeakMap; 34049 lodash.isWeakSet = isWeakSet; 34050 lodash.join = join; 34051 lodash.kebabCase = kebabCase; 34052 lodash.last = last; 34053 lodash.lastIndexOf = lastIndexOf; 34054 lodash.lowerCase = lowerCase; 34055 lodash.lowerFirst = lowerFirst; 34056 lodash.lt = lt; 34057 lodash.lte = lte; 34058 lodash.max = max; 34059 lodash.maxBy = maxBy; 34060 lodash.mean = mean; 34061 lodash.meanBy = meanBy; 34062 lodash.min = min; 34063 lodash.minBy = minBy; 34064 lodash.stubArray = stubArray; 34065 lodash.stubFalse = stubFalse; 34066 lodash.stubObject = stubObject; 34067 lodash.stubString = stubString; 34068 lodash.stubTrue = stubTrue; 34069 lodash.multiply = multiply; 34070 lodash.nth = nth; 34071 lodash.noConflict = noConflict; 34072 lodash.noop = noop; 34073 lodash.now = now; 34074 lodash.pad = pad; 34075 lodash.padEnd = padEnd; 34076 lodash.padStart = padStart; 34077 lodash.parseInt = parseInt; 34078 lodash.random = random; 34079 lodash.reduce = reduce; 34080 lodash.reduceRight = reduceRight; 34081 lodash.repeat = repeat; 34082 lodash.replace = replace; 34083 lodash.result = result; 34084 lodash.round = round; 34085 lodash.runInContext = runInContext; 34086 lodash.sample = sample; 34087 lodash.size = size; 34088 lodash.snakeCase = snakeCase; 34089 lodash.some = some; 34090 lodash.sortedIndex = sortedIndex; 34091 lodash.sortedIndexBy = sortedIndexBy; 34092 lodash.sortedIndexOf = sortedIndexOf; 34093 lodash.sortedLastIndex = sortedLastIndex; 34094 lodash.sortedLastIndexBy = sortedLastIndexBy; 34095 lodash.sortedLastIndexOf = sortedLastIndexOf; 34096 lodash.startCase = startCase; 34097 lodash.startsWith = startsWith; 34098 lodash.subtract = subtract; 34099 lodash.sum = sum; 34100 lodash.sumBy = sumBy; 34101 lodash.template = template; 34102 lodash.times = times; 34103 lodash.toFinite = toFinite; 34104 lodash.toInteger = toInteger; 34105 lodash.toLength = toLength; 34106 lodash.toLower = toLower; 34107 lodash.toNumber = toNumber; 34108 lodash.toSafeInteger = toSafeInteger; 34109 lodash.toString = toString; 34110 lodash.toUpper = toUpper; 34111 lodash.trim = trim; 34112 lodash.trimEnd = trimEnd; 34113 lodash.trimStart = trimStart; 34114 lodash.truncate = truncate; 34115 lodash.unescape = unescape; 34116 lodash.uniqueId = uniqueId; 34117 lodash.upperCase = upperCase; 34118 lodash.upperFirst = upperFirst; 34119 34120 // Add aliases. 34121 lodash.each = forEach; 34122 lodash.eachRight = forEachRight; 34123 lodash.first = head; 34124 34125 mixin(lodash, (function() { 34126 var source = {}; 34127 baseForOwn(lodash, function(func, methodName) { 34128 if (!hasOwnProperty.call(lodash.prototype, methodName)) { 34129 source[methodName] = func; 34130 } 34131 }); 34132 return source; 34133 }()), { 'chain': false }); 34134 34135 /*------------------------------------------------------------------------*/ 34136 34137 /** 34138 * The semantic version number. 34139 * 34140 * @static 34141 * @memberOf _ 34142 * @type {string} 34143 */ 34144 lodash.VERSION = VERSION; 34145 34146 // Assign default placeholders. 34147 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { 34148 lodash[methodName].placeholder = lodash; 34149 }); 34150 34151 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. 34152 arrayEach(['drop', 'take'], function(methodName, index) { 34153 LazyWrapper.prototype[methodName] = function(n) { 34154 n = n === undefined ? 1 : nativeMax(toInteger(n), 0); 34155 34156 var result = (this.__filtered__ && !index) 34157 ? new LazyWrapper(this) 34158 : this.clone(); 34159 34160 if (result.__filtered__) { 34161 result.__takeCount__ = nativeMin(n, result.__takeCount__); 34162 } else { 34163 result.__views__.push({ 34164 'size': nativeMin(n, MAX_ARRAY_LENGTH), 34165 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') 34166 }); 34167 } 34168 return result; 34169 }; 34170 34171 LazyWrapper.prototype[methodName + 'Right'] = function(n) { 34172 return this.reverse()[methodName](n).reverse(); 34173 }; 34174 }); 34175 34176 // Add `LazyWrapper` methods that accept an `iteratee` value. 34177 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { 34178 var type = index + 1, 34179 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; 34180 34181 LazyWrapper.prototype[methodName] = function(iteratee) { 34182 var result = this.clone(); 34183 result.__iteratees__.push({ 34184 'iteratee': getIteratee(iteratee, 3), 34185 'type': type 34186 }); 34187 result.__filtered__ = result.__filtered__ || isFilter; 34188 return result; 34189 }; 34190 }); 34191 34192 // Add `LazyWrapper` methods for `_.head` and `_.last`. 34193 arrayEach(['head', 'last'], function(methodName, index) { 34194 var takeName = 'take' + (index ? 'Right' : ''); 34195 34196 LazyWrapper.prototype[methodName] = function() { 34197 return this[takeName](1).value()[0]; 34198 }; 34199 }); 34200 34201 // Add `LazyWrapper` methods for `_.initial` and `_.tail`. 34202 arrayEach(['initial', 'tail'], function(methodName, index) { 34203 var dropName = 'drop' + (index ? '' : 'Right'); 34204 34205 LazyWrapper.prototype[methodName] = function() { 34206 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); 34207 }; 34208 }); 34209 34210 LazyWrapper.prototype.compact = function() { 34211 return this.filter(identity); 34212 }; 34213 34214 LazyWrapper.prototype.find = function(predicate) { 34215 return this.filter(predicate).head(); 34216 }; 34217 34218 LazyWrapper.prototype.findLast = function(predicate) { 34219 return this.reverse().find(predicate); 34220 }; 34221 34222 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { 34223 if (typeof path == 'function') { 34224 return new LazyWrapper(this); 34225 } 34226 return this.map(function(value) { 34227 return baseInvoke(value, path, args); 34228 }); 34229 }); 34230 34231 LazyWrapper.prototype.reject = function(predicate) { 34232 return this.filter(negate(getIteratee(predicate))); 34233 }; 34234 34235 LazyWrapper.prototype.slice = function(start, end) { 34236 start = toInteger(start); 34237 34238 var result = this; 34239 if (result.__filtered__ && (start > 0 || end < 0)) { 34240 return new LazyWrapper(result); 34241 } 34242 if (start < 0) { 34243 result = result.takeRight(-start); 34244 } else if (start) { 34245 result = result.drop(start); 34246 } 34247 if (end !== undefined) { 34248 end = toInteger(end); 34249 result = end < 0 ? result.dropRight(-end) : result.take(end - start); 34250 } 34251 return result; 34252 }; 34253 34254 LazyWrapper.prototype.takeRightWhile = function(predicate) { 34255 return this.reverse().takeWhile(predicate).reverse(); 34256 }; 34257 34258 LazyWrapper.prototype.toArray = function() { 34259 return this.take(MAX_ARRAY_LENGTH); 34260 }; 34261 34262 // Add `LazyWrapper` methods to `lodash.prototype`. 34263 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 34264 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), 34265 isTaker = /^(?:head|last)$/.test(methodName), 34266 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], 34267 retUnwrapped = isTaker || /^find/.test(methodName); 34268 34269 if (!lodashFunc) { 34270 return; 34271 } 34272 lodash.prototype[methodName] = function() { 34273 var value = this.__wrapped__, 34274 args = isTaker ? [1] : arguments, 34275 isLazy = value instanceof LazyWrapper, 34276 iteratee = args[0], 34277 useLazy = isLazy || isArray(value); 34278 34279 var interceptor = function(value) { 34280 var result = lodashFunc.apply(lodash, arrayPush([value], args)); 34281 return (isTaker && chainAll) ? result[0] : result; 34282 }; 34283 34284 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { 34285 // Avoid lazy use if the iteratee has a "length" value other than `1`. 34286 isLazy = useLazy = false; 34287 } 34288 var chainAll = this.__chain__, 34289 isHybrid = !!this.__actions__.length, 34290 isUnwrapped = retUnwrapped && !chainAll, 34291 onlyLazy = isLazy && !isHybrid; 34292 34293 if (!retUnwrapped && useLazy) { 34294 value = onlyLazy ? value : new LazyWrapper(this); 34295 var result = func.apply(value, args); 34296 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); 34297 return new LodashWrapper(result, chainAll); 34298 } 34299 if (isUnwrapped && onlyLazy) { 34300 return func.apply(this, args); 34301 } 34302 result = this.thru(interceptor); 34303 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; 34304 }; 34305 }); 34306 34307 // Add `Array` methods to `lodash.prototype`. 34308 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { 34309 var func = arrayProto[methodName], 34310 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', 34311 retUnwrapped = /^(?:pop|shift)$/.test(methodName); 34312 34313 lodash.prototype[methodName] = function() { 34314 var args = arguments; 34315 if (retUnwrapped && !this.__chain__) { 34316 var value = this.value(); 34317 return func.apply(isArray(value) ? value : [], args); 34318 } 34319 return this[chainName](function(value) { 34320 return func.apply(isArray(value) ? value : [], args); 34321 }); 34322 }; 34323 }); 34324 34325 // Map minified method names to their real names. 34326 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 34327 var lodashFunc = lodash[methodName]; 34328 if (lodashFunc) { 34329 var key = lodashFunc.name + ''; 34330 if (!hasOwnProperty.call(realNames, key)) { 34331 realNames[key] = []; 34332 } 34333 realNames[key].push({ 'name': methodName, 'func': lodashFunc }); 34334 } 34335 }); 34336 34337 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ 34338 'name': 'wrapper', 34339 'func': undefined 34340 }]; 34341 34342 // Add methods to `LazyWrapper`. 34343 LazyWrapper.prototype.clone = lazyClone; 34344 LazyWrapper.prototype.reverse = lazyReverse; 34345 LazyWrapper.prototype.value = lazyValue; 34346 34347 // Add chain sequence methods to the `lodash` wrapper. 34348 lodash.prototype.at = wrapperAt; 34349 lodash.prototype.chain = wrapperChain; 34350 lodash.prototype.commit = wrapperCommit; 34351 lodash.prototype.next = wrapperNext; 34352 lodash.prototype.plant = wrapperPlant; 34353 lodash.prototype.reverse = wrapperReverse; 34354 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; 34355 34356 // Add lazy aliases. 34357 lodash.prototype.first = lodash.prototype.head; 34358 34359 if (symIterator) { 34360 lodash.prototype[symIterator] = wrapperToIterator; 34361 } 34362 return lodash; 34363 }); 34364 34365 /*--------------------------------------------------------------------------*/ 34366 34367 // Export lodash. 34368 var _ = runInContext(); 34369 34370 // Some AMD build optimizers, like r.js, check for condition patterns like: 34371 if (true) { 34372 // Expose Lodash on the global object to prevent errors when Lodash is 34373 // loaded by a script tag in the presence of an AMD loader. 34374 // See http://requirejs.org/docs/errors.html#mismatch for more details. 34375 // Use `_.noConflict` to remove Lodash from the global object. 34376 root._ = _; 34377 34378 // Define as an anonymous module so, through path mapping, it can be 34379 // referenced as the "underscore" module. 34380 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 34381 return _; 34382 }).call(exports, __webpack_require__, exports, module), 34383 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 34384 } 34385 // Check for `exports` after `define` in case a build optimizer adds it. 34386 else {} 34387}.call(this)); 34388 34389/* 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))) 34390 34391/***/ }), 34392
vendor: 2,409 bytes, lines 34393-34494
34393/***/ "./node_modules/object-assign/index.js": 34394/*!*********************************************!*\ 34395 !*** ./node_modules/object-assign/index.js ***! 34396 \*********************************************/ 34397/*! no static exports found */ 34398/***/ (function(module, exports, __webpack_require__) { 34399 34400"use strict"; 34401/* 34402object-assign 34403(c) Sindre Sorhus 34404@license MIT 34405*/ 34406 34407 34408/* eslint-disable no-unused-vars */ 34409var getOwnPropertySymbols = Object.getOwnPropertySymbols; 34410var hasOwnProperty = Object.prototype.hasOwnProperty; 34411var propIsEnumerable = Object.prototype.propertyIsEnumerable; 34412 34413function toObject(val) { 34414 if (val === null || val === undefined) { 34415 throw new TypeError('Object.assign cannot be called with null or undefined'); 34416 } 34417 34418 return Object(val); 34419} 34420 34421function shouldUseNative() { 34422 try { 34423 if (!Object.assign) { 34424 return false; 34425 } 34426 34427 // Detect buggy property enumeration order in older V8 versions. 34428 34429 // https://bugs.chromium.org/p/v8/issues/detail?id=4118 34430 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers 34431 test1[5] = 'de'; 34432 if (Object.getOwnPropertyNames(test1)[0] === '5') { 34433 return false; 34434 } 34435 34436 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 34437 var test2 = {}; 34438 for (var i = 0; i < 10; i++) { 34439 test2['_' + String.fromCharCode(i)] = i; 34440 } 34441 var order2 = Object.getOwnPropertyNames(test2).map(function (n) { 34442 return test2[n]; 34443 }); 34444 if (order2.join('') !== '0123456789') { 34445 return false; 34446 } 34447 34448 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 34449 var test3 = {}; 34450 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { 34451 test3[letter] = letter; 34452 }); 34453 if (Object.keys(Object.assign({}, test3)).join('') !== 34454 'abcdefghijklmnopqrst') { 34455 return false; 34456 } 34457 34458 return true; 34459 } catch (err) { 34460 // We don't expect any of the above to throw, but better to be safe. 34461 return false; 34462 } 34463} 34464 34465module.exports = shouldUseNative() ? Object.assign : function (target, source) { 34466 var from; 34467 var to = toObject(target); 34468 var symbols; 34469 34470 for (var s = 1; s < arguments.length; s++) { 34471 from = Object(arguments[s]); 34472 34473 for (var key in from) { 34474 if (hasOwnProperty.call(from, key)) { 34475 to[key] = from[key]; 34476 } 34477 } 34478 34479 if (getOwnPropertySymbols) { 34480 symbols = getOwnPropertySymbols(from); 34481 for (var i = 0; i < symbols.length; i++) { 34482 if (propIsEnumerable.call(from, symbols[i])) { 34483 to[symbols[i]] = from[symbols[i]]; 34484 } 34485 } 34486 } 34487 } 34488 34489 return to; 34490}; 34491 34492 34493/***/ }), 34494
vendor: 89,123 bytes, lines 34495-37124
34495/***/ "./node_modules/popper.js/dist/esm/popper.js": 34496/*!***************************************************!*\ 34497 !*** ./node_modules/popper.js/dist/esm/popper.js ***! 34498 \***************************************************/ 34499/*! exports provided: default */ 34500/***/ (function(module, __webpack_exports__, __webpack_require__) { 34501 34502"use strict"; 34503__webpack_require__.r(__webpack_exports__); 34504/* WEBPACK VAR INJECTION */(function(global) {/**! 34505 * @fileOverview Kickass library to create and place poppers near their reference elements. 34506 * @version 1.16.1 34507 * @license 34508 * Copyright (c) 2016 Federico Zivolo and contributors 34509 * 34510 * Permission is hereby granted, free of charge, to any person obtaining a copy 34511 * of this software and associated documentation files (the "Software"), to deal 34512 * in the Software without restriction, including without limitation the rights 34513 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 34514 * copies of the Software, and to permit persons to whom the Software is 34515 * furnished to do so, subject to the following conditions: 34516 * 34517 * The above copyright notice and this permission notice shall be included in all 34518 * copies or substantial portions of the Software. 34519 * 34520 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 34521 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34522 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34523 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34524 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34525 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 34526 * SOFTWARE. 34527 */ 34528var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined'; 34529 34530var timeoutDuration = function () { 34531 var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox']; 34532 for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) { 34533 if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) { 34534 return 1; 34535 } 34536 } 34537 return 0; 34538}(); 34539 34540function microtaskDebounce(fn) { 34541 var called = false; 34542 return function () { 34543 if (called) { 34544 return; 34545 } 34546 called = true; 34547 window.Promise.resolve().then(function () { 34548 called = false; 34549 fn(); 34550 }); 34551 }; 34552} 34553 34554function taskDebounce(fn) { 34555 var scheduled = false; 34556 return function () { 34557 if (!scheduled) { 34558 scheduled = true; 34559 setTimeout(function () { 34560 scheduled = false; 34561 fn(); 34562 }, timeoutDuration); 34563 } 34564 }; 34565} 34566 34567var supportsMicroTasks = isBrowser && window.Promise; 34568 34569/** 34570* Create a debounced version of a method, that's asynchronously deferred 34571* but called in the minimum time possible. 34572* 34573* @method 34574* @memberof Popper.Utils 34575* @argument {Function} fn 34576* @returns {Function} 34577*/ 34578var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce; 34579 34580/** 34581 * Check if the given variable is a function 34582 * @method 34583 * @memberof Popper.Utils 34584 * @argument {Any} functionToCheck - variable to check 34585 * @returns {Boolean} answer to: is a function? 34586 */ 34587function isFunction(functionToCheck) { 34588 var getType = {}; 34589 return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; 34590} 34591 34592/** 34593 * Get CSS computed property of the given element 34594 * @method 34595 * @memberof Popper.Utils 34596 * @argument {Eement} element 34597 * @argument {String} property 34598 */ 34599function getStyleComputedProperty(element, property) { 34600 if (element.nodeType !== 1) { 34601 return []; 34602 } 34603 // NOTE: 1 DOM access here 34604 var window = element.ownerDocument.defaultView; 34605 var css = window.getComputedStyle(element, null); 34606 return property ? css[property] : css; 34607} 34608 34609/** 34610 * Returns the parentNode or the host of the element 34611 * @method 34612 * @memberof Popper.Utils 34613 * @argument {Element} element 34614 * @returns {Element} parent 34615 */ 34616function getParentNode(element) { 34617 if (element.nodeName === 'HTML') { 34618 return element; 34619 } 34620 return element.parentNode || element.host; 34621} 34622 34623/** 34624 * Returns the scrolling parent of the given element 34625 * @method 34626 * @memberof Popper.Utils 34627 * @argument {Element} element 34628 * @returns {Element} scroll parent 34629 */ 34630function getScrollParent(element) { 34631 // Return body, `getScroll` will take care to get the correct `scrollTop` from it 34632 if (!element) { 34633 return document.body; 34634 } 34635 34636 switch (element.nodeName) { 34637 case 'HTML': 34638 case 'BODY': 34639 return element.ownerDocument.body; 34640 case '#document': 34641 return element.body; 34642 } 34643 34644 // Firefox want us to check `-x` and `-y` variations as well 34645 34646 var _getStyleComputedProp = getStyleComputedProperty(element), 34647 overflow = _getStyleComputedProp.overflow, 34648 overflowX = _getStyleComputedProp.overflowX, 34649 overflowY = _getStyleComputedProp.overflowY; 34650 34651 if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) { 34652 return element; 34653 } 34654 34655 return getScrollParent(getParentNode(element)); 34656} 34657 34658/** 34659 * Returns the reference node of the reference object, or the reference object itself. 34660 * @method 34661 * @memberof Popper.Utils 34662 * @param {Element|Object} reference - the reference element (the popper will be relative to this) 34663 * @returns {Element} parent 34664 */ 34665function getReferenceNode(reference) { 34666 return reference && reference.referenceNode ? reference.referenceNode : reference; 34667} 34668 34669var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode); 34670var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent); 34671 34672/** 34673 * Determines if the browser is Internet Explorer 34674 * @method 34675 * @memberof Popper.Utils 34676 * @param {Number} version to check 34677 * @returns {Boolean} isIE 34678 */ 34679function isIE(version) { 34680 if (version === 11) { 34681 return isIE11; 34682 } 34683 if (version === 10) { 34684 return isIE10; 34685 } 34686 return isIE11 || isIE10; 34687} 34688 34689/** 34690 * Returns the offset parent of the given element 34691 * @method 34692 * @memberof Popper.Utils 34693 * @argument {Element} element 34694 * @returns {Element} offset parent 34695 */ 34696function getOffsetParent(element) { 34697 if (!element) { 34698 return document.documentElement; 34699 } 34700 34701 var noOffsetParent = isIE(10) ? document.body : null; 34702 34703 // NOTE: 1 DOM access here 34704 var offsetParent = element.offsetParent || null; 34705 // Skip hidden elements which don't have an offsetParent 34706 while (offsetParent === noOffsetParent && element.nextElementSibling) { 34707 offsetParent = (element = element.nextElementSibling).offsetParent; 34708 } 34709 34710 var nodeName = offsetParent && offsetParent.nodeName; 34711 34712 if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') { 34713 return element ? element.ownerDocument.documentElement : document.documentElement; 34714 } 34715 34716 // .offsetParent will return the closest TH, TD or TABLE in case 34717 // no offsetParent is present, I hate this job... 34718 if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') { 34719 return getOffsetParent(offsetParent); 34720 } 34721 34722 return offsetParent; 34723} 34724 34725function isOffsetContainer(element) { 34726 var nodeName = element.nodeName; 34727 34728 if (nodeName === 'BODY') { 34729 return false; 34730 } 34731 return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element; 34732} 34733 34734/** 34735 * Finds the root node (document, shadowDOM root) of the given element 34736 * @method 34737 * @memberof Popper.Utils 34738 * @argument {Element} node 34739 * @returns {Element} root node 34740 */ 34741function getRoot(node) { 34742 if (node.parentNode !== null) { 34743 return getRoot(node.parentNode); 34744 } 34745 34746 return node; 34747} 34748 34749/** 34750 * Finds the offset parent common to the two provided nodes 34751 * @method 34752 * @memberof Popper.Utils 34753 * @argument {Element} element1 34754 * @argument {Element} element2 34755 * @returns {Element} common offset parent 34756 */ 34757function findCommonOffsetParent(element1, element2) { 34758 // This check is needed to avoid errors in case one of the elements isn't defined for any reason 34759 if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) { 34760 return document.documentElement; 34761 } 34762 34763 // Here we make sure to give as "start" the element that comes first in the DOM 34764 var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING; 34765 var start = order ? element1 : element2; 34766 var end = order ? element2 : element1; 34767 34768 // Get common ancestor container 34769 var range = document.createRange(); 34770 range.setStart(start, 0); 34771 range.setEnd(end, 0); 34772 var commonAncestorContainer = range.commonAncestorContainer; 34773 34774 // Both nodes are inside #document 34775 34776 if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) { 34777 if (isOffsetContainer(commonAncestorContainer)) { 34778 return commonAncestorContainer; 34779 } 34780 34781 return getOffsetParent(commonAncestorContainer); 34782 } 34783 34784 // one of the nodes is inside shadowDOM, find which one 34785 var element1root = getRoot(element1); 34786 if (element1root.host) { 34787 return findCommonOffsetParent(element1root.host, element2); 34788 } else { 34789 return findCommonOffsetParent(element1, getRoot(element2).host); 34790 } 34791} 34792 34793/** 34794 * Gets the scroll value of the given element in the given side (top and left) 34795 * @method 34796 * @memberof Popper.Utils 34797 * @argument {Element} element 34798 * @argument {String} side `top` or `left` 34799 * @returns {number} amount of scrolled pixels 34800 */ 34801function getScroll(element) { 34802 var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top'; 34803 34804 var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft'; 34805 var nodeName = element.nodeName; 34806 34807 if (nodeName === 'BODY' || nodeName === 'HTML') { 34808 var html = element.ownerDocument.documentElement; 34809 var scrollingElement = element.ownerDocument.scrollingElement || html; 34810 return scrollingElement[upperSide]; 34811 } 34812 34813 return element[upperSide]; 34814} 34815 34816/* 34817 * Sum or subtract the element scroll values (left and top) from a given rect object 34818 * @method 34819 * @memberof Popper.Utils 34820 * @param {Object} rect - Rect object you want to change 34821 * @param {HTMLElement} element - The element from the function reads the scroll values 34822 * @param {Boolean} subtract - set to true if you want to subtract the scroll values 34823 * @return {Object} rect - The modifier rect object 34824 */ 34825function includeScroll(rect, element) { 34826 var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 34827 34828 var scrollTop = getScroll(element, 'top'); 34829 var scrollLeft = getScroll(element, 'left'); 34830 var modifier = subtract ? -1 : 1; 34831 rect.top += scrollTop * modifier; 34832 rect.bottom += scrollTop * modifier; 34833 rect.left += scrollLeft * modifier; 34834 rect.right += scrollLeft * modifier; 34835 return rect; 34836} 34837 34838/* 34839 * Helper to detect borders of a given element 34840 * @method 34841 * @memberof Popper.Utils 34842 * @param {CSSStyleDeclaration} styles 34843 * Result of `getStyleComputedProperty` on the given element 34844 * @param {String} axis - `x` or `y` 34845 * @return {number} borders - The borders size of the given axis 34846 */ 34847 34848function getBordersSize(styles, axis) { 34849 var sideA = axis === 'x' ? 'Left' : 'Top'; 34850 var sideB = sideA === 'Left' ? 'Right' : 'Bottom'; 34851 34852 return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']); 34853} 34854 34855function getSize(axis, body, html, computedStyle) { 34856 return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0); 34857} 34858 34859function getWindowSizes(document) { 34860 var body = document.body; 34861 var html = document.documentElement; 34862 var computedStyle = isIE(10) && getComputedStyle(html); 34863 34864 return { 34865 height: getSize('Height', body, html, computedStyle), 34866 width: getSize('Width', body, html, computedStyle) 34867 }; 34868} 34869 34870var classCallCheck = function (instance, Constructor) { 34871 if (!(instance instanceof Constructor)) { 34872 throw new TypeError("Cannot call a class as a function"); 34873 } 34874}; 34875 34876var createClass = function () { 34877 function defineProperties(target, props) { 34878 for (var i = 0; i < props.length; i++) { 34879 var descriptor = props[i]; 34880 descriptor.enumerable = descriptor.enumerable || false; 34881 descriptor.configurable = true; 34882 if ("value" in descriptor) descriptor.writable = true; 34883 Object.defineProperty(target, descriptor.key, descriptor); 34884 } 34885 } 34886 34887 return function (Constructor, protoProps, staticProps) { 34888 if (protoProps) defineProperties(Constructor.prototype, protoProps); 34889 if (staticProps) defineProperties(Constructor, staticProps); 34890 return Constructor; 34891 }; 34892}(); 34893 34894 34895 34896 34897 34898var defineProperty = function (obj, key, value) { 34899 if (key in obj) { 34900 Object.defineProperty(obj, key, { 34901 value: value, 34902 enumerable: true, 34903 configurable: true, 34904 writable: true 34905 }); 34906 } else { 34907 obj[key] = value; 34908 } 34909 34910 return obj; 34911}; 34912 34913var _extends = Object.assign || function (target) { 34914 for (var i = 1; i < arguments.length; i++) { 34915 var source = arguments[i]; 34916 34917 for (var key in source) { 34918 if (Object.prototype.hasOwnProperty.call(source, key)) { 34919 target[key] = source[key]; 34920 } 34921 } 34922 } 34923 34924 return target; 34925}; 34926 34927/** 34928 * Given element offsets, generate an output similar to getBoundingClientRect 34929 * @method 34930 * @memberof Popper.Utils 34931 * @argument {Object} offsets 34932 * @returns {Object} ClientRect like output 34933 */ 34934function getClientRect(offsets) { 34935 return _extends({}, offsets, { 34936 right: offsets.left + offsets.width, 34937 bottom: offsets.top + offsets.height 34938 }); 34939} 34940 34941/** 34942 * Get bounding client rect of given element 34943 * @method 34944 * @memberof Popper.Utils 34945 * @param {HTMLElement} element 34946 * @return {Object} client rect 34947 */ 34948function getBoundingClientRect(element) { 34949 var rect = {}; 34950 34951 // IE10 10 FIX: Please, don't ask, the element isn't 34952 // considered in DOM in some circumstances... 34953 // This isn't reproducible in IE10 compatibility mode of IE11 34954 try { 34955 if (isIE(10)) { 34956 rect = element.getBoundingClientRect(); 34957 var scrollTop = getScroll(element, 'top'); 34958 var scrollLeft = getScroll(element, 'left'); 34959 rect.top += scrollTop; 34960 rect.left += scrollLeft; 34961 rect.bottom += scrollTop; 34962 rect.right += scrollLeft; 34963 } else { 34964 rect = element.getBoundingClientRect(); 34965 } 34966 } catch (e) {} 34967 34968 var result = { 34969 left: rect.left, 34970 top: rect.top, 34971 width: rect.right - rect.left, 34972 height: rect.bottom - rect.top 34973 }; 34974 34975 // subtract scrollbar size from sizes 34976 var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {}; 34977 var width = sizes.width || element.clientWidth || result.width; 34978 var height = sizes.height || element.clientHeight || result.height; 34979 34980 var horizScrollbar = element.offsetWidth - width; 34981 var vertScrollbar = element.offsetHeight - height; 34982 34983 // if an hypothetical scrollbar is detected, we must be sure it's not a `border` 34984 // we make this check conditional for performance reasons 34985 if (horizScrollbar || vertScrollbar) { 34986 var styles = getStyleComputedProperty(element); 34987 horizScrollbar -= getBordersSize(styles, 'x'); 34988 vertScrollbar -= getBordersSize(styles, 'y'); 34989 34990 result.width -= horizScrollbar; 34991 result.height -= vertScrollbar; 34992 } 34993 34994 return getClientRect(result); 34995} 34996 34997function getOffsetRectRelativeToArbitraryNode(children, parent) { 34998 var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 34999 35000 var isIE10 = isIE(10); 35001 var isHTML = parent.nodeName === 'HTML'; 35002 var childrenRect = getBoundingClientRect(children); 35003 var parentRect = getBoundingClientRect(parent); 35004 var scrollParent = getScrollParent(children); 35005 35006 var styles = getStyleComputedProperty(parent); 35007 var borderTopWidth = parseFloat(styles.borderTopWidth); 35008 var borderLeftWidth = parseFloat(styles.borderLeftWidth); 35009 35010 // In cases where the parent is fixed, we must ignore negative scroll in offset calc 35011 if (fixedPosition && isHTML) { 35012 parentRect.top = Math.max(parentRect.top, 0); 35013 parentRect.left = Math.max(parentRect.left, 0); 35014 } 35015 var offsets = getClientRect({ 35016 top: childrenRect.top - parentRect.top - borderTopWidth, 35017 left: childrenRect.left - parentRect.left - borderLeftWidth, 35018 width: childrenRect.width, 35019 height: childrenRect.height 35020 }); 35021 offsets.marginTop = 0; 35022 offsets.marginLeft = 0; 35023 35024 // Subtract margins of documentElement in case it's being used as parent 35025 // we do this only on HTML because it's the only element that behaves 35026 // differently when margins are applied to it. The margins are included in 35027 // the box of the documentElement, in the other cases not. 35028 if (!isIE10 && isHTML) { 35029 var marginTop = parseFloat(styles.marginTop); 35030 var marginLeft = parseFloat(styles.marginLeft); 35031 35032 offsets.top -= borderTopWidth - marginTop; 35033 offsets.bottom -= borderTopWidth - marginTop; 35034 offsets.left -= borderLeftWidth - marginLeft; 35035 offsets.right -= borderLeftWidth - marginLeft; 35036 35037 // Attach marginTop and marginLeft because in some circumstances we may need them 35038 offsets.marginTop = marginTop; 35039 offsets.marginLeft = marginLeft; 35040 } 35041 35042 if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') { 35043 offsets = includeScroll(offsets, parent); 35044 } 35045 35046 return offsets; 35047} 35048 35049function getViewportOffsetRectRelativeToArtbitraryNode(element) { 35050 var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 35051 35052 var html = element.ownerDocument.documentElement; 35053 var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html); 35054 var width = Math.max(html.clientWidth, window.innerWidth || 0); 35055 var height = Math.max(html.clientHeight, window.innerHeight || 0); 35056 35057 var scrollTop = !excludeScroll ? getScroll(html) : 0; 35058 var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0; 35059 35060 var offset = { 35061 top: scrollTop - relativeOffset.top + relativeOffset.marginTop, 35062 left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft, 35063 width: width, 35064 height: height 35065 }; 35066 35067 return getClientRect(offset); 35068} 35069 35070/** 35071 * Check if the given element is fixed or is inside a fixed parent 35072 * @method 35073 * @memberof Popper.Utils 35074 * @argument {Element} element 35075 * @argument {Element} customContainer 35076 * @returns {Boolean} answer to "isFixed?" 35077 */ 35078function isFixed(element) { 35079 var nodeName = element.nodeName; 35080 if (nodeName === 'BODY' || nodeName === 'HTML') { 35081 return false; 35082 } 35083 if (getStyleComputedProperty(element, 'position') === 'fixed') { 35084 return true; 35085 } 35086 var parentNode = getParentNode(element); 35087 if (!parentNode) { 35088 return false; 35089 } 35090 return isFixed(parentNode); 35091} 35092 35093/** 35094 * Finds the first parent of an element that has a transformed property defined 35095 * @method 35096 * @memberof Popper.Utils 35097 * @argument {Element} element 35098 * @returns {Element} first transformed parent or documentElement 35099 */ 35100 35101function getFixedPositionOffsetParent(element) { 35102 // This check is needed to avoid errors in case one of the elements isn't defined for any reason 35103 if (!element || !element.parentElement || isIE()) { 35104 return document.documentElement; 35105 } 35106 var el = element.parentElement; 35107 while (el && getStyleComputedProperty(el, 'transform') === 'none') { 35108 el = el.parentElement; 35109 } 35110 return el || document.documentElement; 35111} 35112 35113/** 35114 * Computed the boundaries limits and return them 35115 * @method 35116 * @memberof Popper.Utils 35117 * @param {HTMLElement} popper 35118 * @param {HTMLElement} reference 35119 * @param {number} padding 35120 * @param {HTMLElement} boundariesElement - Element used to define the boundaries 35121 * @param {Boolean} fixedPosition - Is in fixed position mode 35122 * @returns {Object} Coordinates of the boundaries 35123 */ 35124function getBoundaries(popper, reference, padding, boundariesElement) { 35125 var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; 35126 35127 // NOTE: 1 DOM access here 35128 35129 var boundaries = { top: 0, left: 0 }; 35130 var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference)); 35131 35132 // Handle viewport case 35133 if (boundariesElement === 'viewport') { 35134 boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition); 35135 } else { 35136 // Handle other cases based on DOM element used as boundaries 35137 var boundariesNode = void 0; 35138 if (boundariesElement === 'scrollParent') { 35139 boundariesNode = getScrollParent(getParentNode(reference)); 35140 if (boundariesNode.nodeName === 'BODY') { 35141 boundariesNode = popper.ownerDocument.documentElement; 35142 } 35143 } else if (boundariesElement === 'window') { 35144 boundariesNode = popper.ownerDocument.documentElement; 35145 } else { 35146 boundariesNode = boundariesElement; 35147 } 35148 35149 var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition); 35150 35151 // In case of HTML, we need a different computation 35152 if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) { 35153 var _getWindowSizes = getWindowSizes(popper.ownerDocument), 35154 height = _getWindowSizes.height, 35155 width = _getWindowSizes.width; 35156 35157 boundaries.top += offsets.top - offsets.marginTop; 35158 boundaries.bottom = height + offsets.top; 35159 boundaries.left += offsets.left - offsets.marginLeft; 35160 boundaries.right = width + offsets.left; 35161 } else { 35162 // for all the other DOM elements, this one is good 35163 boundaries = offsets; 35164 } 35165 } 35166 35167 // Add paddings 35168 padding = padding || 0; 35169 var isPaddingNumber = typeof padding === 'number'; 35170 boundaries.left += isPaddingNumber ? padding : padding.left || 0; 35171 boundaries.top += isPaddingNumber ? padding : padding.top || 0; 35172 boundaries.right -= isPaddingNumber ? padding : padding.right || 0; 35173 boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0; 35174 35175 return boundaries; 35176} 35177 35178function getArea(_ref) { 35179 var width = _ref.width, 35180 height = _ref.height; 35181 35182 return width * height; 35183} 35184 35185/** 35186 * Utility used to transform the `auto` placement to the placement with more 35187 * available space. 35188 * @method 35189 * @memberof Popper.Utils 35190 * @argument {Object} data - The data object generated by update method 35191 * @argument {Object} options - Modifiers configuration and options 35192 * @returns {Object} The data object, properly modified 35193 */ 35194function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) { 35195 var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0; 35196 35197 if (placement.indexOf('auto') === -1) { 35198 return placement; 35199 } 35200 35201 var boundaries = getBoundaries(popper, reference, padding, boundariesElement); 35202 35203 var rects = { 35204 top: { 35205 width: boundaries.width, 35206 height: refRect.top - boundaries.top 35207 }, 35208 right: { 35209 width: boundaries.right - refRect.right, 35210 height: boundaries.height 35211 }, 35212 bottom: { 35213 width: boundaries.width, 35214 height: boundaries.bottom - refRect.bottom 35215 }, 35216 left: { 35217 width: refRect.left - boundaries.left, 35218 height: boundaries.height 35219 } 35220 }; 35221 35222 var sortedAreas = Object.keys(rects).map(function (key) { 35223 return _extends({ 35224 key: key 35225 }, rects[key], { 35226 area: getArea(rects[key]) 35227 }); 35228 }).sort(function (a, b) { 35229 return b.area - a.area; 35230 }); 35231 35232 var filteredAreas = sortedAreas.filter(function (_ref2) { 35233 var width = _ref2.width, 35234 height = _ref2.height; 35235 return width >= popper.clientWidth && height >= popper.clientHeight; 35236 }); 35237 35238 var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key; 35239 35240 var variation = placement.split('-')[1]; 35241 35242 return computedPlacement + (variation ? '-' + variation : ''); 35243} 35244 35245/** 35246 * Get offsets to the reference element 35247 * @method 35248 * @memberof Popper.Utils 35249 * @param {Object} state 35250 * @param {Element} popper - the popper element 35251 * @param {Element} reference - the reference element (the popper will be relative to this) 35252 * @param {Element} fixedPosition - is in fixed position mode 35253 * @returns {Object} An object containing the offsets which will be applied to the popper 35254 */ 35255function getReferenceOffsets(state, popper, reference) { 35256 var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; 35257 35258 var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference)); 35259 return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition); 35260} 35261 35262/** 35263 * Get the outer sizes of the given element (offset size + margins) 35264 * @method 35265 * @memberof Popper.Utils 35266 * @argument {Element} element 35267 * @returns {Object} object containing width and height properties 35268 */ 35269function getOuterSizes(element) { 35270 var window = element.ownerDocument.defaultView; 35271 var styles = window.getComputedStyle(element); 35272 var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0); 35273 var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0); 35274 var result = { 35275 width: element.offsetWidth + y, 35276 height: element.offsetHeight + x 35277 }; 35278 return result; 35279} 35280 35281/** 35282 * Get the opposite placement of the given one 35283 * @method 35284 * @memberof Popper.Utils 35285 * @argument {String} placement 35286 * @returns {String} flipped placement 35287 */ 35288function getOppositePlacement(placement) { 35289 var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' }; 35290 return placement.replace(/left|right|bottom|top/g, function (matched) { 35291 return hash[matched]; 35292 }); 35293} 35294 35295/** 35296 * Get offsets to the popper 35297 * @method 35298 * @memberof Popper.Utils 35299 * @param {Object} position - CSS position the Popper will get applied 35300 * @param {HTMLElement} popper - the popper element 35301 * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this) 35302 * @param {String} placement - one of the valid placement options 35303 * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper 35304 */ 35305function getPopperOffsets(popper, referenceOffsets, placement) { 35306 placement = placement.split('-')[0]; 35307 35308 // Get popper node sizes 35309 var popperRect = getOuterSizes(popper); 35310 35311 // Add position, width and height to our offsets object 35312 var popperOffsets = { 35313 width: popperRect.width, 35314 height: popperRect.height 35315 }; 35316 35317 // depending by the popper placement we have to compute its offsets slightly differently 35318 var isHoriz = ['right', 'left'].indexOf(placement) !== -1; 35319 var mainSide = isHoriz ? 'top' : 'left'; 35320 var secondarySide = isHoriz ? 'left' : 'top'; 35321 var measurement = isHoriz ? 'height' : 'width'; 35322 var secondaryMeasurement = !isHoriz ? 'height' : 'width'; 35323 35324 popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2; 35325 if (placement === secondarySide) { 35326 popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement]; 35327 } else { 35328 popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)]; 35329 } 35330 35331 return popperOffsets; 35332} 35333 35334/** 35335 * Mimics the `find` method of Array 35336 * @method 35337 * @memberof Popper.Utils 35338 * @argument {Array} arr 35339 * @argument prop 35340 * @argument value 35341 * @returns index or -1 35342 */ 35343function find(arr, check) { 35344 // use native find if supported 35345 if (Array.prototype.find) { 35346 return arr.find(check); 35347 } 35348 35349 // use `filter` to obtain the same behavior of `find` 35350 return arr.filter(check)[0]; 35351} 35352 35353/** 35354 * Return the index of the matching object 35355 * @method 35356 * @memberof Popper.Utils 35357 * @argument {Array} arr 35358 * @argument prop 35359 * @argument value 35360 * @returns index or -1 35361 */ 35362function findIndex(arr, prop, value) { 35363 // use native findIndex if supported 35364 if (Array.prototype.findIndex) { 35365 return arr.findIndex(function (cur) { 35366 return cur[prop] === value; 35367 }); 35368 } 35369 35370 // use `find` + `indexOf` if `findIndex` isn't supported 35371 var match = find(arr, function (obj) { 35372 return obj[prop] === value; 35373 }); 35374 return arr.indexOf(match); 35375} 35376 35377/** 35378 * Loop trough the list of modifiers and run them in order, 35379 * each of them will then edit the data object. 35380 * @method 35381 * @memberof Popper.Utils 35382 * @param {dataObject} data 35383 * @param {Array} modifiers 35384 * @param {String} ends - Optional modifier name used as stopper 35385 * @returns {dataObject} 35386 */ 35387function runModifiers(modifiers, data, ends) { 35388 var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends)); 35389 35390 modifiersToRun.forEach(function (modifier) { 35391 if (modifier['function']) { 35392 // eslint-disable-line dot-notation 35393 console.warn('`modifier.function` is deprecated, use `modifier.fn`!'); 35394 } 35395 var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation 35396 if (modifier.enabled && isFunction(fn)) { 35397 // Add properties to offsets to make them a complete clientRect object 35398 // we do this before each modifier to make sure the previous one doesn't 35399 // mess with these values 35400 data.offsets.popper = getClientRect(data.offsets.popper); 35401 data.offsets.reference = getClientRect(data.offsets.reference); 35402 35403 data = fn(data, modifier); 35404 } 35405 }); 35406 35407 return data; 35408} 35409 35410/** 35411 * Updates the position of the popper, computing the new offsets and applying 35412 * the new style.<br /> 35413 * Prefer `scheduleUpdate` over `update` because of performance reasons. 35414 * @method 35415 * @memberof Popper 35416 */ 35417function update() { 35418 // if popper is destroyed, don't perform any further update 35419 if (this.state.isDestroyed) { 35420 return; 35421 } 35422 35423 var data = { 35424 instance: this, 35425 styles: {}, 35426 arrowStyles: {}, 35427 attributes: {}, 35428 flipped: false, 35429 offsets: {} 35430 }; 35431 35432 // compute reference element offsets 35433 data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed); 35434 35435 // compute auto placement, store placement inside the data object, 35436 // modifiers will be able to edit `placement` if needed 35437 // and refer to originalPlacement to know the original value 35438 data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding); 35439 35440 // store the computed placement inside `originalPlacement` 35441 data.originalPlacement = data.placement; 35442 35443 data.positionFixed = this.options.positionFixed; 35444 35445 // compute the popper offsets 35446 data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement); 35447 35448 data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute'; 35449 35450 // run the modifiers 35451 data = runModifiers(this.modifiers, data); 35452 35453 // the first `update` will call `onCreate` callback 35454 // the other ones will call `onUpdate` callback 35455 if (!this.state.isCreated) { 35456 this.state.isCreated = true; 35457 this.options.onCreate(data); 35458 } else { 35459 this.options.onUpdate(data); 35460 } 35461} 35462 35463/** 35464 * Helper used to know if the given modifier is enabled. 35465 * @method 35466 * @memberof Popper.Utils 35467 * @returns {Boolean} 35468 */ 35469function isModifierEnabled(modifiers, modifierName) { 35470 return modifiers.some(function (_ref) { 35471 var name = _ref.name, 35472 enabled = _ref.enabled; 35473 return enabled && name === modifierName; 35474 }); 35475} 35476 35477/** 35478 * Get the prefixed supported property name 35479 * @method 35480 * @memberof Popper.Utils 35481 * @argument {String} property (camelCase) 35482 * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix) 35483 */ 35484function getSupportedPropertyName(property) { 35485 var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O']; 35486 var upperProp = property.charAt(0).toUpperCase() + property.slice(1); 35487 35488 for (var i = 0; i < prefixes.length; i++) { 35489 var prefix = prefixes[i]; 35490 var toCheck = prefix ? '' + prefix + upperProp : property; 35491 if (typeof document.body.style[toCheck] !== 'undefined') { 35492 return toCheck; 35493 } 35494 } 35495 return null; 35496} 35497 35498/** 35499 * Destroys the popper. 35500 * @method 35501 * @memberof Popper 35502 */ 35503function destroy() { 35504 this.state.isDestroyed = true; 35505 35506 // touch DOM only if `applyStyle` modifier is enabled 35507 if (isModifierEnabled(this.modifiers, 'applyStyle')) { 35508 this.popper.removeAttribute('x-placement'); 35509 this.popper.style.position = ''; 35510 this.popper.style.top = ''; 35511 this.popper.style.left = ''; 35512 this.popper.style.right = ''; 35513 this.popper.style.bottom = ''; 35514 this.popper.style.willChange = ''; 35515 this.popper.style[getSupportedPropertyName('transform')] = ''; 35516 } 35517 35518 this.disableEventListeners(); 35519 35520 // remove the popper if user explicitly asked for the deletion on destroy 35521 // do not use `remove` because IE11 doesn't support it 35522 if (this.options.removeOnDestroy) { 35523 this.popper.parentNode.removeChild(this.popper); 35524 } 35525 return this; 35526} 35527 35528/** 35529 * Get the window associated with the element 35530 * @argument {Element} element 35531 * @returns {Window} 35532 */ 35533function getWindow(element) { 35534 var ownerDocument = element.ownerDocument; 35535 return ownerDocument ? ownerDocument.defaultView : window; 35536} 35537 35538function attachToScrollParents(scrollParent, event, callback, scrollParents) { 35539 var isBody = scrollParent.nodeName === 'BODY'; 35540 var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent; 35541 target.addEventListener(event, callback, { passive: true }); 35542 35543 if (!isBody) { 35544 attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents); 35545 } 35546 scrollParents.push(target); 35547} 35548 35549/** 35550 * Setup needed event listeners used to update the popper position 35551 * @method 35552 * @memberof Popper.Utils 35553 * @private 35554 */ 35555function setupEventListeners(reference, options, state, updateBound) { 35556 // Resize event listener on window 35557 state.updateBound = updateBound; 35558 getWindow(reference).addEventListener('resize', state.updateBound, { passive: true }); 35559 35560 // Scroll event listener on scroll parents 35561 var scrollElement = getScrollParent(reference); 35562 attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents); 35563 state.scrollElement = scrollElement; 35564 state.eventsEnabled = true; 35565 35566 return state; 35567} 35568 35569/** 35570 * It will add resize/scroll events and start recalculating 35571 * position of the popper element when they are triggered. 35572 * @method 35573 * @memberof Popper 35574 */ 35575function enableEventListeners() { 35576 if (!this.state.eventsEnabled) { 35577 this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate); 35578 } 35579} 35580 35581/** 35582 * Remove event listeners used to update the popper position 35583 * @method 35584 * @memberof Popper.Utils 35585 * @private 35586 */ 35587function removeEventListeners(reference, state) { 35588 // Remove resize event listener on window 35589 getWindow(reference).removeEventListener('resize', state.updateBound); 35590 35591 // Remove scroll event listener on scroll parents 35592 state.scrollParents.forEach(function (target) { 35593 target.removeEventListener('scroll', state.updateBound); 35594 }); 35595 35596 // Reset state 35597 state.updateBound = null; 35598 state.scrollParents = []; 35599 state.scrollElement = null; 35600 state.eventsEnabled = false; 35601 return state; 35602} 35603 35604/** 35605 * It will remove resize/scroll events and won't recalculate popper position 35606 * when they are triggered. It also won't trigger `onUpdate` callback anymore, 35607 * unless you call `update` method manually. 35608 * @method 35609 * @memberof Popper 35610 */ 35611function disableEventListeners() { 35612 if (this.state.eventsEnabled) { 35613 cancelAnimationFrame(this.scheduleUpdate); 35614 this.state = removeEventListeners(this.reference, this.state); 35615 } 35616} 35617 35618/** 35619 * Tells if a given input is a number 35620 * @method 35621 * @memberof Popper.Utils 35622 * @param {*} input to check 35623 * @return {Boolean} 35624 */ 35625function isNumeric(n) { 35626 return n !== '' && !isNaN(parseFloat(n)) && isFinite(n); 35627} 35628 35629/** 35630 * Set the style to the given popper 35631 * @method 35632 * @memberof Popper.Utils 35633 * @argument {Element} element - Element to apply the style to 35634 * @argument {Object} styles 35635 * Object with a list of properties and values which will be applied to the element 35636 */ 35637function setStyles(element, styles) { 35638 Object.keys(styles).forEach(function (prop) { 35639 var unit = ''; 35640 // add unit if the value is numeric and is one of the following 35641 if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) { 35642 unit = 'px'; 35643 } 35644 element.style[prop] = styles[prop] + unit; 35645 }); 35646} 35647 35648/** 35649 * Set the attributes to the given popper 35650 * @method 35651 * @memberof Popper.Utils 35652 * @argument {Element} element - Element to apply the attributes to 35653 * @argument {Object} styles 35654 * Object with a list of properties and values which will be applied to the element 35655 */ 35656function setAttributes(element, attributes) { 35657 Object.keys(attributes).forEach(function (prop) { 35658 var value = attributes[prop]; 35659 if (value !== false) { 35660 element.setAttribute(prop, attributes[prop]); 35661 } else { 35662 element.removeAttribute(prop); 35663 } 35664 }); 35665} 35666 35667/** 35668 * @function 35669 * @memberof Modifiers 35670 * @argument {Object} data - The data object generated by `update` method 35671 * @argument {Object} data.styles - List of style properties - values to apply to popper element 35672 * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element 35673 * @argument {Object} options - Modifiers configuration and options 35674 * @returns {Object} The same data object 35675 */ 35676function applyStyle(data) { 35677 // any property present in `data.styles` will be applied to the popper, 35678 // in this way we can make the 3rd party modifiers add custom styles to it 35679 // Be aware, modifiers could override the properties defined in the previous 35680 // lines of this modifier! 35681 setStyles(data.instance.popper, data.styles); 35682 35683 // any property present in `data.attributes` will be applied to the popper, 35684 // they will be set as HTML attributes of the element 35685 setAttributes(data.instance.popper, data.attributes); 35686 35687 // if arrowElement is defined and arrowStyles has some properties 35688 if (data.arrowElement && Object.keys(data.arrowStyles).length) { 35689 setStyles(data.arrowElement, data.arrowStyles); 35690 } 35691 35692 return data; 35693} 35694 35695/** 35696 * Set the x-placement attribute before everything else because it could be used 35697 * to add margins to the popper margins needs to be calculated to get the 35698 * correct popper offsets. 35699 * @method 35700 * @memberof Popper.modifiers 35701 * @param {HTMLElement} reference - The reference element used to position the popper 35702 * @param {HTMLElement} popper - The HTML element used as popper 35703 * @param {Object} options - Popper.js options 35704 */ 35705function applyStyleOnLoad(reference, popper, options, modifierOptions, state) { 35706 // compute reference element offsets 35707 var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed); 35708 35709 // compute auto placement, store placement inside the data object, 35710 // modifiers will be able to edit `placement` if needed 35711 // and refer to originalPlacement to know the original value 35712 var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding); 35713 35714 popper.setAttribute('x-placement', placement); 35715 35716 // Apply `position` to popper before anything else because 35717 // without the position applied we can't guarantee correct computations 35718 setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' }); 35719 35720 return options; 35721} 35722 35723/** 35724 * @function 35725 * @memberof Popper.Utils 35726 * @argument {Object} data - The data object generated by `update` method 35727 * @argument {Boolean} shouldRound - If the offsets should be rounded at all 35728 * @returns {Object} The popper's position offsets rounded 35729 * 35730 * The tale of pixel-perfect positioning. It's still not 100% perfect, but as 35731 * good as it can be within reason. 35732 * Discussion here: https://github.com/FezVrasta/popper.js/pull/715 35733 * 35734 * Low DPI screens cause a popper to be blurry if not using full pixels (Safari 35735 * as well on High DPI screens). 35736 * 35737 * Firefox prefers no rounding for positioning and does not have blurriness on 35738 * high DPI screens. 35739 * 35740 * Only horizontal placement and left/right values need to be considered. 35741 */ 35742function getRoundedOffsets(data, shouldRound) { 35743 var _data$offsets = data.offsets, 35744 popper = _data$offsets.popper, 35745 reference = _data$offsets.reference; 35746 var round = Math.round, 35747 floor = Math.floor; 35748 35749 var noRound = function noRound(v) { 35750 return v; 35751 }; 35752 35753 var referenceWidth = round(reference.width); 35754 var popperWidth = round(popper.width); 35755 35756 var isVertical = ['left', 'right'].indexOf(data.placement) !== -1; 35757 var isVariation = data.placement.indexOf('-') !== -1; 35758 var sameWidthParity = referenceWidth % 2 === popperWidth % 2; 35759 var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1; 35760 35761 var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor; 35762 var verticalToInteger = !shouldRound ? noRound : round; 35763 35764 return { 35765 left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left), 35766 top: verticalToInteger(popper.top), 35767 bottom: verticalToInteger(popper.bottom), 35768 right: horizontalToInteger(popper.right) 35769 }; 35770} 35771 35772var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent); 35773 35774/** 35775 * @function 35776 * @memberof Modifiers 35777 * @argument {Object} data - The data object generated by `update` method 35778 * @argument {Object} options - Modifiers configuration and options 35779 * @returns {Object} The data object, properly modified 35780 */ 35781function computeStyle(data, options) { 35782 var x = options.x, 35783 y = options.y; 35784 var popper = data.offsets.popper; 35785 35786 // Remove this legacy support in Popper.js v2 35787 35788 var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) { 35789 return modifier.name === 'applyStyle'; 35790 }).gpuAcceleration; 35791 if (legacyGpuAccelerationOption !== undefined) { 35792 console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!'); 35793 } 35794 var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration; 35795 35796 var offsetParent = getOffsetParent(data.instance.popper); 35797 var offsetParentRect = getBoundingClientRect(offsetParent); 35798 35799 // Styles 35800 var styles = { 35801 position: popper.position 35802 }; 35803 35804 var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox); 35805 35806 var sideA = x === 'bottom' ? 'top' : 'bottom'; 35807 var sideB = y === 'right' ? 'left' : 'right'; 35808 35809 // if gpuAcceleration is set to `true` and transform is supported, 35810 // we use `translate3d` to apply the position to the popper we 35811 // automatically use the supported prefixed version if needed 35812 var prefixedProperty = getSupportedPropertyName('transform'); 35813 35814 // now, let's make a step back and look at this code closely (wtf?) 35815 // If the content of the popper grows once it's been positioned, it 35816 // may happen that the popper gets misplaced because of the new content 35817 // overflowing its reference element 35818 // To avoid this problem, we provide two options (x and y), which allow 35819 // the consumer to define the offset origin. 35820 // If we position a popper on top of a reference element, we can set 35821 // `x` to `top` to make the popper grow towards its top instead of 35822 // its bottom. 35823 var left = void 0, 35824 top = void 0; 35825 if (sideA === 'bottom') { 35826 // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar) 35827 // and not the bottom of the html element 35828 if (offsetParent.nodeName === 'HTML') { 35829 top = -offsetParent.clientHeight + offsets.bottom; 35830 } else { 35831 top = -offsetParentRect.height + offsets.bottom; 35832 } 35833 } else { 35834 top = offsets.top; 35835 } 35836 if (sideB === 'right') { 35837 if (offsetParent.nodeName === 'HTML') { 35838 left = -offsetParent.clientWidth + offsets.right; 35839 } else { 35840 left = -offsetParentRect.width + offsets.right; 35841 } 35842 } else { 35843 left = offsets.left; 35844 } 35845 if (gpuAcceleration && prefixedProperty) { 35846 styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)'; 35847 styles[sideA] = 0; 35848 styles[sideB] = 0; 35849 styles.willChange = 'transform'; 35850 } else { 35851 // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties 35852 var invertTop = sideA === 'bottom' ? -1 : 1; 35853 var invertLeft = sideB === 'right' ? -1 : 1; 35854 styles[sideA] = top * invertTop; 35855 styles[sideB] = left * invertLeft; 35856 styles.willChange = sideA + ', ' + sideB; 35857 } 35858 35859 // Attributes 35860 var attributes = { 35861 'x-placement': data.placement 35862 }; 35863 35864 // Update `data` attributes, styles and arrowStyles 35865 data.attributes = _extends({}, attributes, data.attributes); 35866 data.styles = _extends({}, styles, data.styles); 35867 data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles); 35868 35869 return data; 35870} 35871 35872/** 35873 * Helper used to know if the given modifier depends from another one.<br /> 35874 * It checks if the needed modifier is listed and enabled. 35875 * @method 35876 * @memberof Popper.Utils 35877 * @param {Array} modifiers - list of modifiers 35878 * @param {String} requestingName - name of requesting modifier 35879 * @param {String} requestedName - name of requested modifier 35880 * @returns {Boolean} 35881 */ 35882function isModifierRequired(modifiers, requestingName, requestedName) { 35883 var requesting = find(modifiers, function (_ref) { 35884 var name = _ref.name; 35885 return name === requestingName; 35886 }); 35887 35888 var isRequired = !!requesting && modifiers.some(function (modifier) { 35889 return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order; 35890 }); 35891 35892 if (!isRequired) { 35893 var _requesting = '`' + requestingName + '`'; 35894 var requested = '`' + requestedName + '`'; 35895 console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!'); 35896 } 35897 return isRequired; 35898} 35899 35900/** 35901 * @function 35902 * @memberof Modifiers 35903 * @argument {Object} data - The data object generated by update method 35904 * @argument {Object} options - Modifiers configuration and options 35905 * @returns {Object} The data object, properly modified 35906 */ 35907function arrow(data, options) { 35908 var _data$offsets$arrow; 35909 35910 // arrow depends on keepTogether in order to work 35911 if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) { 35912 return data; 35913 } 35914 35915 var arrowElement = options.element; 35916 35917 // if arrowElement is a string, suppose it's a CSS selector 35918 if (typeof arrowElement === 'string') { 35919 arrowElement = data.instance.popper.querySelector(arrowElement); 35920 35921 // if arrowElement is not found, don't run the modifier 35922 if (!arrowElement) { 35923 return data; 35924 } 35925 } else { 35926 // if the arrowElement isn't a query selector we must check that the 35927 // provided DOM node is child of its popper node 35928 if (!data.instance.popper.contains(arrowElement)) { 35929 console.warn('WARNING: `arrow.element` must be child of its popper element!'); 35930 return data; 35931 } 35932 } 35933 35934 var placement = data.placement.split('-')[0]; 35935 var _data$offsets = data.offsets, 35936 popper = _data$offsets.popper, 35937 reference = _data$offsets.reference; 35938 35939 var isVertical = ['left', 'right'].indexOf(placement) !== -1; 35940 35941 var len = isVertical ? 'height' : 'width'; 35942 var sideCapitalized = isVertical ? 'Top' : 'Left'; 35943 var side = sideCapitalized.toLowerCase(); 35944 var altSide = isVertical ? 'left' : 'top'; 35945 var opSide = isVertical ? 'bottom' : 'right'; 35946 var arrowElementSize = getOuterSizes(arrowElement)[len]; 35947 35948 // 35949 // extends keepTogether behavior making sure the popper and its 35950 // reference have enough pixels in conjunction 35951 // 35952 35953 // top/left side 35954 if (reference[opSide] - arrowElementSize < popper[side]) { 35955 data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize); 35956 } 35957 // bottom/right side 35958 if (reference[side] + arrowElementSize > popper[opSide]) { 35959 data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide]; 35960 } 35961 data.offsets.popper = getClientRect(data.offsets.popper); 35962 35963 // compute center of the popper 35964 var center = reference[side] + reference[len] / 2 - arrowElementSize / 2; 35965 35966 // Compute the sideValue using the updated popper offsets 35967 // take popper margin in account because we don't have this info available 35968 var css = getStyleComputedProperty(data.instance.popper); 35969 var popperMarginSide = parseFloat(css['margin' + sideCapitalized]); 35970 var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']); 35971 var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide; 35972 35973 // prevent arrowElement from being placed not contiguously to its popper 35974 sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0); 35975 35976 data.arrowElement = arrowElement; 35977 data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow); 35978 35979 return data; 35980} 35981 35982/** 35983 * Get the opposite placement variation of the given one 35984 * @method 35985 * @memberof Popper.Utils 35986 * @argument {String} placement variation 35987 * @returns {String} flipped placement variation 35988 */ 35989function getOppositeVariation(variation) { 35990 if (variation === 'end') { 35991 return 'start'; 35992 } else if (variation === 'start') { 35993 return 'end'; 35994 } 35995 return variation; 35996} 35997 35998/** 35999 * List of accepted placements to use as values of the `placement` option.<br /> 36000 * Valid placements are: 36001 * - `auto` 36002 * - `top` 36003 * - `right` 36004 * - `bottom` 36005 * - `left` 36006 * 36007 * Each placement can have a variation from this list: 36008 * - `-start` 36009 * - `-end` 36010 * 36011 * Variations are interpreted easily if you think of them as the left to right 36012 * written languages. Horizontally (`top` and `bottom`), `start` is left and `end` 36013 * is right.<br /> 36014 * Vertically (`left` and `right`), `start` is top and `end` is bottom. 36015 * 36016 * Some valid examples are: 36017 * - `top-end` (on top of reference, right aligned) 36018 * - `right-start` (on right of reference, top aligned) 36019 * - `bottom` (on bottom, centered) 36020 * - `auto-end` (on the side with more space available, alignment depends by placement) 36021 * 36022 * @static 36023 * @type {Array} 36024 * @enum {String} 36025 * @readonly 36026 * @method placements 36027 * @memberof Popper 36028 */ 36029var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start']; 36030 36031// Get rid of `auto` `auto-start` and `auto-end` 36032var validPlacements = placements.slice(3); 36033 36034/** 36035 * Given an initial placement, returns all the subsequent placements 36036 * clockwise (or counter-clockwise). 36037 * 36038 * @method 36039 * @memberof Popper.Utils 36040 * @argument {String} placement - A valid placement (it accepts variations) 36041 * @argument {Boolean} counter - Set to true to walk the placements counterclockwise 36042 * @returns {Array} placements including their variations 36043 */ 36044function clockwise(placement) { 36045 var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 36046 36047 var index = validPlacements.indexOf(placement); 36048 var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index)); 36049 return counter ? arr.reverse() : arr; 36050} 36051 36052var BEHAVIORS = { 36053 FLIP: 'flip', 36054 CLOCKWISE: 'clockwise', 36055 COUNTERCLOCKWISE: 'counterclockwise' 36056}; 36057 36058/** 36059 * @function 36060 * @memberof Modifiers 36061 * @argument {Object} data - The data object generated by update method 36062 * @argument {Object} options - Modifiers configuration and options 36063 * @returns {Object} The data object, properly modified 36064 */ 36065function flip(data, options) { 36066 // if `inner` modifier is enabled, we can't use the `flip` modifier 36067 if (isModifierEnabled(data.instance.modifiers, 'inner')) { 36068 return data; 36069 } 36070 36071 if (data.flipped && data.placement === data.originalPlacement) { 36072 // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides 36073 return data; 36074 } 36075 36076 var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed); 36077 36078 var placement = data.placement.split('-')[0]; 36079 var placementOpposite = getOppositePlacement(placement); 36080 var variation = data.placement.split('-')[1] || ''; 36081 36082 var flipOrder = []; 36083 36084 switch (options.behavior) { 36085 case BEHAVIORS.FLIP: 36086 flipOrder = [placement, placementOpposite]; 36087 break; 36088 case BEHAVIORS.CLOCKWISE: 36089 flipOrder = clockwise(placement); 36090 break; 36091 case BEHAVIORS.COUNTERCLOCKWISE: 36092 flipOrder = clockwise(placement, true); 36093 break; 36094 default: 36095 flipOrder = options.behavior; 36096 } 36097 36098 flipOrder.forEach(function (step, index) { 36099 if (placement !== step || flipOrder.length === index + 1) { 36100 return data; 36101 } 36102 36103 placement = data.placement.split('-')[0]; 36104 placementOpposite = getOppositePlacement(placement); 36105 36106 var popperOffsets = data.offsets.popper; 36107 var refOffsets = data.offsets.reference; 36108 36109 // using floor because the reference offsets may contain decimals we are not going to consider here 36110 var floor = Math.floor; 36111 var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom); 36112 36113 var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left); 36114 var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right); 36115 var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top); 36116 var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom); 36117 36118 var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom; 36119 36120 // flip the variation if required 36121 var isVertical = ['top', 'bottom'].indexOf(placement) !== -1; 36122 36123 // flips variation if reference element overflows boundaries 36124 var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom); 36125 36126 // flips variation if popper content overflows boundaries 36127 var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop); 36128 36129 var flippedVariation = flippedVariationByRef || flippedVariationByContent; 36130 36131 if (overlapsRef || overflowsBoundaries || flippedVariation) { 36132 // this boolean to detect any flip loop 36133 data.flipped = true; 36134 36135 if (overlapsRef || overflowsBoundaries) { 36136 placement = flipOrder[index + 1]; 36137 } 36138 36139 if (flippedVariation) { 36140 variation = getOppositeVariation(variation); 36141 } 36142 36143 data.placement = placement + (variation ? '-' + variation : ''); 36144 36145 // this object contains `position`, we want to preserve it along with 36146 // any additional property we may add in the future 36147 data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement)); 36148 36149 data = runModifiers(data.instance.modifiers, data, 'flip'); 36150 } 36151 }); 36152 return data; 36153} 36154 36155/** 36156 * @function 36157 * @memberof Modifiers 36158 * @argument {Object} data - The data object generated by update method 36159 * @argument {Object} options - Modifiers configuration and options 36160 * @returns {Object} The data object, properly modified 36161 */ 36162function keepTogether(data) { 36163 var _data$offsets = data.offsets, 36164 popper = _data$offsets.popper, 36165 reference = _data$offsets.reference; 36166 36167 var placement = data.placement.split('-')[0]; 36168 var floor = Math.floor; 36169 var isVertical = ['top', 'bottom'].indexOf(placement) !== -1; 36170 var side = isVertical ? 'right' : 'bottom'; 36171 var opSide = isVertical ? 'left' : 'top'; 36172 var measurement = isVertical ? 'width' : 'height'; 36173 36174 if (popper[side] < floor(reference[opSide])) { 36175 data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement]; 36176 } 36177 if (popper[opSide] > floor(reference[side])) { 36178 data.offsets.popper[opSide] = floor(reference[side]); 36179 } 36180 36181 return data; 36182} 36183 36184/** 36185 * Converts a string containing value + unit into a px value number 36186 * @function 36187 * @memberof {modifiers~offset} 36188 * @private 36189 * @argument {String} str - Value + unit string 36190 * @argument {String} measurement - `height` or `width` 36191 * @argument {Object} popperOffsets 36192 * @argument {Object} referenceOffsets 36193 * @returns {Number|String} 36194 * Value in pixels, or original string if no values were extracted 36195 */ 36196function toValue(str, measurement, popperOffsets, referenceOffsets) { 36197 // separate value from unit 36198 var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/); 36199 var value = +split[1]; 36200 var unit = split[2]; 36201 36202 // If it's not a number it's an operator, I guess 36203 if (!value) { 36204 return str; 36205 } 36206 36207 if (unit.indexOf('%') === 0) { 36208 var element = void 0; 36209 switch (unit) { 36210 case '%p': 36211 element = popperOffsets; 36212 break; 36213 case '%': 36214 case '%r': 36215 default: 36216 element = referenceOffsets; 36217 } 36218 36219 var rect = getClientRect(element); 36220 return rect[measurement] / 100 * value; 36221 } else if (unit === 'vh' || unit === 'vw') { 36222 // if is a vh or vw, we calculate the size based on the viewport 36223 var size = void 0; 36224 if (unit === 'vh') { 36225 size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); 36226 } else { 36227 size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 36228 } 36229 return size / 100 * value; 36230 } else { 36231 // if is an explicit pixel unit, we get rid of the unit and keep the value 36232 // if is an implicit unit, it's px, and we return just the value 36233 return value; 36234 } 36235} 36236 36237/** 36238 * Parse an `offset` string to extrapolate `x` and `y` numeric offsets. 36239 * @function 36240 * @memberof {modifiers~offset} 36241 * @private 36242 * @argument {String} offset 36243 * @argument {Object} popperOffsets 36244 * @argument {Object} referenceOffsets 36245 * @argument {String} basePlacement 36246 * @returns {Array} a two cells array with x and y offsets in numbers 36247 */ 36248function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) { 36249 var offsets = [0, 0]; 36250 36251 // Use height if placement is left or right and index is 0 otherwise use width 36252 // in this way the first offset will use an axis and the second one 36253 // will use the other one 36254 var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1; 36255 36256 // Split the offset string to obtain a list of values and operands 36257 // The regex addresses values with the plus or minus sign in front (+10, -20, etc) 36258 var fragments = offset.split(/(\+|\-)/).map(function (frag) { 36259 return frag.trim(); 36260 }); 36261 36262 // Detect if the offset string contains a pair of values or a single one 36263 // they could be separated by comma or space 36264 var divider = fragments.indexOf(find(fragments, function (frag) { 36265 return frag.search(/,|\s/) !== -1; 36266 })); 36267 36268 if (fragments[divider] && fragments[divider].indexOf(',') === -1) { 36269 console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.'); 36270 } 36271 36272 // If divider is found, we divide the list of values and operands to divide 36273 // them by ofset X and Y. 36274 var splitRegex = /\s*,\s*|\s+/; 36275 var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments]; 36276 36277 // Convert the values with units to absolute pixels to allow our computations 36278 ops = ops.map(function (op, index) { 36279 // Most of the units rely on the orientation of the popper 36280 var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width'; 36281 var mergeWithPrevious = false; 36282 return op 36283 // This aggregates any `+` or `-` sign that aren't considered operators 36284 // e.g.: 10 + +5 => [10, +, +5] 36285 .reduce(function (a, b) { 36286 if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) { 36287 a[a.length - 1] = b; 36288 mergeWithPrevious = true; 36289 return a; 36290 } else if (mergeWithPrevious) { 36291 a[a.length - 1] += b; 36292 mergeWithPrevious = false; 36293 return a; 36294 } else { 36295 return a.concat(b); 36296 } 36297 }, []) 36298 // Here we convert the string values into number values (in px) 36299 .map(function (str) { 36300 return toValue(str, measurement, popperOffsets, referenceOffsets); 36301 }); 36302 }); 36303 36304 // Loop trough the offsets arrays and execute the operations 36305 ops.forEach(function (op, index) { 36306 op.forEach(function (frag, index2) { 36307 if (isNumeric(frag)) { 36308 offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1); 36309 } 36310 }); 36311 }); 36312 return offsets; 36313} 36314 36315/** 36316 * @function 36317 * @memberof Modifiers 36318 * @argument {Object} data - The data object generated by update method 36319 * @argument {Object} options - Modifiers configuration and options 36320 * @argument {Number|String} options.offset=0 36321 * The offset value as described in the modifier description 36322 * @returns {Object} The data object, properly modified 36323 */ 36324function offset(data, _ref) { 36325 var offset = _ref.offset; 36326 var placement = data.placement, 36327 _data$offsets = data.offsets, 36328 popper = _data$offsets.popper, 36329 reference = _data$offsets.reference; 36330 36331 var basePlacement = placement.split('-')[0]; 36332 36333 var offsets = void 0; 36334 if (isNumeric(+offset)) { 36335 offsets = [+offset, 0]; 36336 } else { 36337 offsets = parseOffset(offset, popper, reference, basePlacement); 36338 } 36339 36340 if (basePlacement === 'left') { 36341 popper.top += offsets[0]; 36342 popper.left -= offsets[1]; 36343 } else if (basePlacement === 'right') { 36344 popper.top += offsets[0]; 36345 popper.left += offsets[1]; 36346 } else if (basePlacement === 'top') { 36347 popper.left += offsets[0]; 36348 popper.top -= offsets[1]; 36349 } else if (basePlacement === 'bottom') { 36350 popper.left += offsets[0]; 36351 popper.top += offsets[1]; 36352 } 36353 36354 data.popper = popper; 36355 return data; 36356} 36357 36358/** 36359 * @function 36360 * @memberof Modifiers 36361 * @argument {Object} data - The data object generated by `update` method 36362 * @argument {Object} options - Modifiers configuration and options 36363 * @returns {Object} The data object, properly modified 36364 */ 36365function preventOverflow(data, options) { 36366 var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper); 36367 36368 // If offsetParent is the reference element, we really want to 36369 // go one step up and use the next offsetParent as reference to 36370 // avoid to make this modifier completely useless and look like broken 36371 if (data.instance.reference === boundariesElement) { 36372 boundariesElement = getOffsetParent(boundariesElement); 36373 } 36374 36375 // NOTE: DOM access here 36376 // resets the popper's position so that the document size can be calculated excluding 36377 // the size of the popper element itself 36378 var transformProp = getSupportedPropertyName('transform'); 36379 var popperStyles = data.instance.popper.style; // assignment to help minification 36380 var top = popperStyles.top, 36381 left = popperStyles.left, 36382 transform = popperStyles[transformProp]; 36383 36384 popperStyles.top = ''; 36385 popperStyles.left = ''; 36386 popperStyles[transformProp] = ''; 36387 36388 var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed); 36389 36390 // NOTE: DOM access here 36391 // restores the original style properties after the offsets have been computed 36392 popperStyles.top = top; 36393 popperStyles.left = left; 36394 popperStyles[transformProp] = transform; 36395 36396 options.boundaries = boundaries; 36397 36398 var order = options.priority; 36399 var popper = data.offsets.popper; 36400 36401 var check = { 36402 primary: function primary(placement) { 36403 var value = popper[placement]; 36404 if (popper[placement] < boundaries[placement] && !options.escapeWithReference) { 36405 value = Math.max(popper[placement], boundaries[placement]); 36406 } 36407 return defineProperty({}, placement, value); 36408 }, 36409 secondary: function secondary(placement) { 36410 var mainSide = placement === 'right' ? 'left' : 'top'; 36411 var value = popper[mainSide]; 36412 if (popper[placement] > boundaries[placement] && !options.escapeWithReference) { 36413 value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height)); 36414 } 36415 return defineProperty({}, mainSide, value); 36416 } 36417 }; 36418 36419 order.forEach(function (placement) { 36420 var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary'; 36421 popper = _extends({}, popper, check[side](placement)); 36422 }); 36423 36424 data.offsets.popper = popper; 36425 36426 return data; 36427} 36428 36429/** 36430 * @function 36431 * @memberof Modifiers 36432 * @argument {Object} data - The data object generated by `update` method 36433 * @argument {Object} options - Modifiers configuration and options 36434 * @returns {Object} The data object, properly modified 36435 */ 36436function shift(data) { 36437 var placement = data.placement; 36438 var basePlacement = placement.split('-')[0]; 36439 var shiftvariation = placement.split('-')[1]; 36440 36441 // if shift shiftvariation is specified, run the modifier 36442 if (shiftvariation) { 36443 var _data$offsets = data.offsets, 36444 reference = _data$offsets.reference, 36445 popper = _data$offsets.popper; 36446 36447 var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1; 36448 var side = isVertical ? 'left' : 'top'; 36449 var measurement = isVertical ? 'width' : 'height'; 36450 36451 var shiftOffsets = { 36452 start: defineProperty({}, side, reference[side]), 36453 end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement]) 36454 }; 36455 36456 data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]); 36457 } 36458 36459 return data; 36460} 36461 36462/** 36463 * @function 36464 * @memberof Modifiers 36465 * @argument {Object} data - The data object generated by update method 36466 * @argument {Object} options - Modifiers configuration and options 36467 * @returns {Object} The data object, properly modified 36468 */ 36469function hide(data) { 36470 if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) { 36471 return data; 36472 } 36473 36474 var refRect = data.offsets.reference; 36475 var bound = find(data.instance.modifiers, function (modifier) { 36476 return modifier.name === 'preventOverflow'; 36477 }).boundaries; 36478 36479 if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) { 36480 // Avoid unnecessary DOM access if visibility hasn't changed 36481 if (data.hide === true) { 36482 return data; 36483 } 36484 36485 data.hide = true; 36486 data.attributes['x-out-of-boundaries'] = ''; 36487 } else { 36488 // Avoid unnecessary DOM access if visibility hasn't changed 36489 if (data.hide === false) { 36490 return data; 36491 } 36492 36493 data.hide = false; 36494 data.attributes['x-out-of-boundaries'] = false; 36495 } 36496 36497 return data; 36498} 36499 36500/** 36501 * @function 36502 * @memberof Modifiers 36503 * @argument {Object} data - The data object generated by `update` method 36504 * @argument {Object} options - Modifiers configuration and options 36505 * @returns {Object} The data object, properly modified 36506 */ 36507function inner(data) { 36508 var placement = data.placement; 36509 var basePlacement = placement.split('-')[0]; 36510 var _data$offsets = data.offsets, 36511 popper = _data$offsets.popper, 36512 reference = _data$offsets.reference; 36513 36514 var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1; 36515 36516 var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1; 36517 36518 popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0); 36519 36520 data.placement = getOppositePlacement(placement); 36521 data.offsets.popper = getClientRect(popper); 36522 36523 return data; 36524} 36525 36526/** 36527 * Modifier function, each modifier can have a function of this type assigned 36528 * to its `fn` property.<br /> 36529 * These functions will be called on each update, this means that you must 36530 * make sure they are performant enough to avoid performance bottlenecks. 36531 * 36532 * @function ModifierFn 36533 * @argument {dataObject} data - The data object generated by `update` method 36534 * @argument {Object} options - Modifiers configuration and options 36535 * @returns {dataObject} The data object, properly modified 36536 */ 36537 36538/** 36539 * Modifiers are plugins used to alter the behavior of your poppers.<br /> 36540 * Popper.js uses a set of 9 modifiers to provide all the basic functionalities 36541 * needed by the library. 36542 * 36543 * Usually you don't want to override the `order`, `fn` and `onLoad` props. 36544 * All the other properties are configurations that could be tweaked. 36545 * @namespace modifiers 36546 */ 36547var modifiers = { 36548 /** 36549 * Modifier used to shift the popper on the start or end of its reference 36550 * element.<br /> 36551 * It will read the variation of the `placement` property.<br /> 36552 * It can be one either `-end` or `-start`. 36553 * @memberof modifiers 36554 * @inner 36555 */ 36556 shift: { 36557 /** @prop {number} order=100 - Index used to define the order of execution */ 36558 order: 100, 36559 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 36560 enabled: true, 36561 /** @prop {ModifierFn} */ 36562 fn: shift 36563 }, 36564 36565 /** 36566 * The `offset` modifier can shift your popper on both its axis. 36567 * 36568 * It accepts the following units: 36569 * - `px` or unit-less, interpreted as pixels 36570 * - `%` or `%r`, percentage relative to the length of the reference element 36571 * - `%p`, percentage relative to the length of the popper element 36572 * - `vw`, CSS viewport width unit 36573 * - `vh`, CSS viewport height unit 36574 * 36575 * For length is intended the main axis relative to the placement of the popper.<br /> 36576 * This means that if the placement is `top` or `bottom`, the length will be the 36577 * `width`. In case of `left` or `right`, it will be the `height`. 36578 * 36579 * You can provide a single value (as `Number` or `String`), or a pair of values 36580 * as `String` divided by a comma or one (or more) white spaces.<br /> 36581 * The latter is a deprecated method because it leads to confusion and will be 36582 * removed in v2.<br /> 36583 * Additionally, it accepts additions and subtractions between different units. 36584 * Note that multiplications and divisions aren't supported. 36585 * 36586 * Valid examples are: 36587 * ``` 36588 * 10 36589 * '10%' 36590 * '10, 10' 36591 * '10%, 10' 36592 * '10 + 10%' 36593 * '10 - 5vh + 3%' 36594 * '-10px + 5vh, 5px - 6%' 36595 * ``` 36596 * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap 36597 * > with their reference element, unfortunately, you will have to disable the `flip` modifier. 36598 * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373). 36599 * 36600 * @memberof modifiers 36601 * @inner 36602 */ 36603 offset: { 36604 /** @prop {number} order=200 - Index used to define the order of execution */ 36605 order: 200, 36606 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 36607 enabled: true, 36608 /** @prop {ModifierFn} */ 36609 fn: offset, 36610 /** @prop {Number|String} offset=0 36611 * The offset value as described in the modifier description 36612 */ 36613 offset: 0 36614 }, 36615 36616 /** 36617 * Modifier used to prevent the popper from being positioned outside the boundary. 36618 * 36619 * A scenario exists where the reference itself is not within the boundaries.<br /> 36620 * We can say it has "escaped the boundaries" — or just "escaped".<br /> 36621 * In this case we need to decide whether the popper should either: 36622 * 36623 * - detach from the reference and remain "trapped" in the boundaries, or 36624 * - if it should ignore the boundary and "escape with its reference" 36625 * 36626 * When `escapeWithReference` is set to`true` and reference is completely 36627 * outside its boundaries, the popper will overflow (or completely leave) 36628 * the boundaries in order to remain attached to the edge of the reference. 36629 * 36630 * @memberof modifiers 36631 * @inner 36632 */ 36633 preventOverflow: { 36634 /** @prop {number} order=300 - Index used to define the order of execution */ 36635 order: 300, 36636 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 36637 enabled: true, 36638 /** @prop {ModifierFn} */ 36639 fn: preventOverflow, 36640 /** 36641 * @prop {Array} [priority=['left','right','top','bottom']] 36642 * Popper will try to prevent overflow following these priorities by default, 36643 * then, it could overflow on the left and on top of the `boundariesElement` 36644 */ 36645 priority: ['left', 'right', 'top', 'bottom'], 36646 /** 36647 * @prop {number} padding=5 36648 * Amount of pixel used to define a minimum distance between the boundaries 36649 * and the popper. This makes sure the popper always has a little padding 36650 * between the edges of its container 36651 */ 36652 padding: 5, 36653 /** 36654 * @prop {String|HTMLElement} boundariesElement='scrollParent' 36655 * Boundaries used by the modifier. Can be `scrollParent`, `window`, 36656 * `viewport` or any DOM element. 36657 */ 36658 boundariesElement: 'scrollParent' 36659 }, 36660 36661 /** 36662 * Modifier used to make sure the reference and its popper stay near each other 36663 * without leaving any gap between the two. Especially useful when the arrow is 36664 * enabled and you want to ensure that it points to its reference element. 36665 * It cares only about the first axis. You can still have poppers with margin 36666 * between the popper and its reference element. 36667 * @memberof modifiers 36668 * @inner 36669 */ 36670 keepTogether: { 36671 /** @prop {number} order=400 - Index used to define the order of execution */ 36672 order: 400, 36673 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 36674 enabled: true, 36675 /** @prop {ModifierFn} */ 36676 fn: keepTogether 36677 }, 36678 36679 /** 36680 * This modifier is used to move the `arrowElement` of the popper to make 36681 * sure it is positioned between the reference element and its popper element. 36682 * It will read the outer size of the `arrowElement` node to detect how many 36683 * pixels of conjunction are needed. 36684 * 36685 * It has no effect if no `arrowElement` is provided. 36686 * @memberof modifiers 36687 * @inner 36688 */ 36689 arrow: { 36690 /** @prop {number} order=500 - Index used to define the order of execution */ 36691 order: 500, 36692 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 36693 enabled: true, 36694 /** @prop {ModifierFn} */ 36695 fn: arrow, 36696 /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */ 36697 element: '[x-arrow]' 36698 }, 36699 36700 /** 36701 * Modifier used to flip the popper's placement when it starts to overlap its 36702 * reference element. 36703 * 36704 * Requires the `preventOverflow` modifier before it in order to work. 36705 * 36706 * **NOTE:** this modifier will interrupt the current update cycle and will 36707 * restart it if it detects the need to flip the placement. 36708 * @memberof modifiers 36709 * @inner 36710 */ 36711 flip: { 36712 /** @prop {number} order=600 - Index used to define the order of execution */ 36713 order: 600, 36714 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 36715 enabled: true, 36716 /** @prop {ModifierFn} */ 36717 fn: flip, 36718 /** 36719 * @prop {String|Array} behavior='flip' 36720 * The behavior used to change the popper's placement. It can be one of 36721 * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid 36722 * placements (with optional variations) 36723 */ 36724 behavior: 'flip', 36725 /** 36726 * @prop {number} padding=5 36727 * The popper will flip if it hits the edges of the `boundariesElement` 36728 */ 36729 padding: 5, 36730 /** 36731 * @prop {String|HTMLElement} boundariesElement='viewport' 36732 * The element which will define the boundaries of the popper position. 36733 * The popper will never be placed outside of the defined boundaries 36734 * (except if `keepTogether` is enabled) 36735 */ 36736 boundariesElement: 'viewport', 36737 /** 36738 * @prop {Boolean} flipVariations=false 36739 * The popper will switch placement variation between `-start` and `-end` when 36740 * the reference element overlaps its boundaries. 36741 * 36742 * The original placement should have a set variation. 36743 */ 36744 flipVariations: false, 36745 /** 36746 * @prop {Boolean} flipVariationsByContent=false 36747 * The popper will switch placement variation between `-start` and `-end` when 36748 * the popper element overlaps its reference boundaries. 36749 * 36750 * The original placement should have a set variation. 36751 */ 36752 flipVariationsByContent: false 36753 }, 36754 36755 /** 36756 * Modifier used to make the popper flow toward the inner of the reference element. 36757 * By default, when this modifier is disabled, the popper will be placed outside 36758 * the reference element. 36759 * @memberof modifiers 36760 * @inner 36761 */ 36762 inner: { 36763 /** @prop {number} order=700 - Index used to define the order of execution */ 36764 order: 700, 36765 /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */ 36766 enabled: false, 36767 /** @prop {ModifierFn} */ 36768 fn: inner 36769 }, 36770 36771 /** 36772 * Modifier used to hide the popper when its reference element is outside of the 36773 * popper boundaries. It will set a `x-out-of-boundaries` attribute which can 36774 * be used to hide with a CSS selector the popper when its reference is 36775 * out of boundaries. 36776 * 36777 * Requires the `preventOverflow` modifier before it in order to work. 36778 * @memberof modifiers 36779 * @inner 36780 */ 36781 hide: { 36782 /** @prop {number} order=800 - Index used to define the order of execution */ 36783 order: 800, 36784 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 36785 enabled: true, 36786 /** @prop {ModifierFn} */ 36787 fn: hide 36788 }, 36789 36790 /** 36791 * Computes the style that will be applied to the popper element to gets 36792 * properly positioned. 36793 * 36794 * Note that this modifier will not touch the DOM, it just prepares the styles 36795 * so that `applyStyle` modifier can apply it. This separation is useful 36796 * in case you need to replace `applyStyle` with a custom implementation. 36797 * 36798 * This modifier has `850` as `order` value to maintain backward compatibility 36799 * with previous versions of Popper.js. Expect the modifiers ordering method 36800 * to change in future major versions of the library. 36801 * 36802 * @memberof modifiers 36803 * @inner 36804 */ 36805 computeStyle: { 36806 /** @prop {number} order=850 - Index used to define the order of execution */ 36807 order: 850, 36808 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 36809 enabled: true, 36810 /** @prop {ModifierFn} */ 36811 fn: computeStyle, 36812 /** 36813 * @prop {Boolean} gpuAcceleration=true 36814 * If true, it uses the CSS 3D transformation to position the popper. 36815 * Otherwise, it will use the `top` and `left` properties 36816 */ 36817 gpuAcceleration: true, 36818 /** 36819 * @prop {string} [x='bottom'] 36820 * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin. 36821 * Change this if your popper should grow in a direction different from `bottom` 36822 */ 36823 x: 'bottom', 36824 /** 36825 * @prop {string} [x='left'] 36826 * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin. 36827 * Change this if your popper should grow in a direction different from `right` 36828 */ 36829 y: 'right' 36830 }, 36831 36832 /** 36833 * Applies the computed styles to the popper element. 36834 * 36835 * All the DOM manipulations are limited to this modifier. This is useful in case 36836 * you want to integrate Popper.js inside a framework or view library and you 36837 * want to delegate all the DOM manipulations to it. 36838 * 36839 * Note that if you disable this modifier, you must make sure the popper element 36840 * has its position set to `absolute` before Popper.js can do its work! 36841 * 36842 * Just disable this modifier and define your own to achieve the desired effect. 36843 * 36844 * @memberof modifiers 36845 * @inner 36846 */ 36847 applyStyle: { 36848 /** @prop {number} order=900 - Index used to define the order of execution */ 36849 order: 900, 36850 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ 36851 enabled: true, 36852 /** @prop {ModifierFn} */ 36853 fn: applyStyle, 36854 /** @prop {Function} */ 36855 onLoad: applyStyleOnLoad, 36856 /** 36857 * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier 36858 * @prop {Boolean} gpuAcceleration=true 36859 * If true, it uses the CSS 3D transformation to position the popper. 36860 * Otherwise, it will use the `top` and `left` properties 36861 */ 36862 gpuAcceleration: undefined 36863 } 36864}; 36865 36866/** 36867 * The `dataObject` is an object containing all the information used by Popper.js. 36868 * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks. 36869 * @name dataObject 36870 * @property {Object} data.instance The Popper.js instance 36871 * @property {String} data.placement Placement applied to popper 36872 * @property {String} data.originalPlacement Placement originally defined on init 36873 * @property {Boolean} data.flipped True if popper has been flipped by flip modifier 36874 * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper 36875 * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier 36876 * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`) 36877 * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`) 36878 * @property {Object} data.boundaries Offsets of the popper boundaries 36879 * @property {Object} data.offsets The measurements of popper, reference and arrow elements 36880 * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values 36881 * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values 36882 * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0 36883 */ 36884 36885/** 36886 * Default options provided to Popper.js constructor.<br /> 36887 * These can be overridden using the `options` argument of Popper.js.<br /> 36888 * To override an option, simply pass an object with the same 36889 * structure of the `options` object, as the 3rd argument. For example: 36890 * ``` 36891 * new Popper(ref, pop, { 36892 * modifiers: { 36893 * preventOverflow: { enabled: false } 36894 * } 36895 * }) 36896 * ``` 36897 * @type {Object} 36898 * @static 36899 * @memberof Popper 36900 */ 36901var Defaults = { 36902 /** 36903 * Popper's placement. 36904 * @prop {Popper.placements} placement='bottom' 36905 */ 36906 placement: 'bottom', 36907 36908 /** 36909 * Set this to true if you want popper to position it self in 'fixed' mode 36910 * @prop {Boolean} positionFixed=false 36911 */ 36912 positionFixed: false, 36913 36914 /** 36915 * Whether events (resize, scroll) are initially enabled. 36916 * @prop {Boolean} eventsEnabled=true 36917 */ 36918 eventsEnabled: true, 36919 36920 /** 36921 * Set to true if you want to automatically remove the popper when 36922 * you call the `destroy` method. 36923 * @prop {Boolean} removeOnDestroy=false 36924 */ 36925 removeOnDestroy: false, 36926 36927 /** 36928 * Callback called when the popper is created.<br /> 36929 * By default, it is set to no-op.<br /> 36930 * Access Popper.js instance with `data.instance`. 36931 * @prop {onCreate} 36932 */ 36933 onCreate: function onCreate() {}, 36934 36935 /** 36936 * Callback called when the popper is updated. This callback is not called 36937 * on the initialization/creation of the popper, but only on subsequent 36938 * updates.<br /> 36939 * By default, it is set to no-op.<br /> 36940 * Access Popper.js instance with `data.instance`. 36941 * @prop {onUpdate} 36942 */ 36943 onUpdate: function onUpdate() {}, 36944 36945 /** 36946 * List of modifiers used to modify the offsets before they are applied to the popper. 36947 * They provide most of the functionalities of Popper.js. 36948 * @prop {modifiers} 36949 */ 36950 modifiers: modifiers 36951}; 36952 36953/** 36954 * @callback onCreate 36955 * @param {dataObject} data 36956 */ 36957 36958/** 36959 * @callback onUpdate 36960 * @param {dataObject} data 36961 */ 36962 36963// Utils 36964// Methods 36965var Popper = function () { 36966 /** 36967 * Creates a new Popper.js instance. 36968 * @class Popper 36969 * @param {Element|referenceObject} reference - The reference element used to position the popper 36970 * @param {Element} popper - The HTML / XML element used as the popper 36971 * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults) 36972 * @return {Object} instance - The generated Popper.js instance 36973 */ 36974 function Popper(reference, popper) { 36975 var _this = this; 36976 36977 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 36978 classCallCheck(this, Popper); 36979 36980 this.scheduleUpdate = function () { 36981 return requestAnimationFrame(_this.update); 36982 }; 36983 36984 // make update() debounced, so that it only runs at most once-per-tick 36985 this.update = debounce(this.update.bind(this)); 36986 36987 // with {} we create a new object with the options inside it 36988 this.options = _extends({}, Popper.Defaults, options); 36989 36990 // init state 36991 this.state = { 36992 isDestroyed: false, 36993 isCreated: false, 36994 scrollParents: [] 36995 }; 36996 36997 // get reference and popper elements (allow jQuery wrappers) 36998 this.reference = reference && reference.jquery ? reference[0] : reference; 36999 this.popper = popper && popper.jquery ? popper[0] : popper; 37000 37001 // Deep merge modifiers options 37002 this.options.modifiers = {}; 37003 Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) { 37004 _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {}); 37005 }); 37006 37007 // Refactoring modifiers' list (Object => Array) 37008 this.modifiers = Object.keys(this.options.modifiers).map(function (name) { 37009 return _extends({ 37010 name: name 37011 }, _this.options.modifiers[name]); 37012 }) 37013 // sort the modifiers by order 37014 .sort(function (a, b) { 37015 return a.order - b.order; 37016 }); 37017 37018 // modifiers have the ability to execute arbitrary code when Popper.js get inited 37019 // such code is executed in the same order of its modifier 37020 // they could add new properties to their options configuration 37021 // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`! 37022 this.modifiers.forEach(function (modifierOptions) { 37023 if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) { 37024 modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state); 37025 } 37026 }); 37027 37028 // fire the first update to position the popper in the right place 37029 this.update(); 37030 37031 var eventsEnabled = this.options.eventsEnabled; 37032 if (eventsEnabled) { 37033 // setup event listeners, they will take care of update the position in specific situations 37034 this.enableEventListeners(); 37035 } 37036 37037 this.state.eventsEnabled = eventsEnabled; 37038 } 37039 37040 // We can't use class properties because they don't get listed in the 37041 // class prototype and break stuff like Sinon stubs 37042 37043 37044 createClass(Popper, [{ 37045 key: 'update', 37046 value: function update$$1() { 37047 return update.call(this); 37048 } 37049 }, { 37050 key: 'destroy', 37051 value: function destroy$$1() { 37052 return destroy.call(this); 37053 } 37054 }, { 37055 key: 'enableEventListeners', 37056 value: function enableEventListeners$$1() { 37057 return enableEventListeners.call(this); 37058 } 37059 }, { 37060 key: 'disableEventListeners', 37061 value: function disableEventListeners$$1() { 37062 return disableEventListeners.call(this); 37063 } 37064 37065 /** 37066 * Schedules an update. It will run on the next UI update available. 37067 * @method scheduleUpdate 37068 * @memberof Popper 37069 */ 37070 37071 37072 /** 37073 * Collection of utilities useful when writing custom modifiers. 37074 * Starting from version 1.7, this method is available only if you 37075 * include `popper-utils.js` before `popper.js`. 37076 * 37077 * **DEPRECATION**: This way to access PopperUtils is deprecated 37078 * and will be removed in v2! Use the PopperUtils module directly instead. 37079 * Due to the high instability of the methods contained in Utils, we can't 37080 * guarantee them to follow semver. Use them at your own risk! 37081 * @static 37082 * @private 37083 * @type {Object} 37084 * @deprecated since version 1.8 37085 * @member Utils 37086 * @memberof Popper 37087 */ 37088 37089 }]); 37090 return Popper; 37091}(); 37092 37093/** 37094 * The `referenceObject` is an object that provides an interface compatible with Popper.js 37095 * and lets you use it as replacement of a real DOM node.<br /> 37096 * You can use this method to position a popper relatively to a set of coordinates 37097 * in case you don't have a DOM node to use as reference. 37098 * 37099 * ``` 37100 * new Popper(referenceObject, popperNode); 37101 * ``` 37102 * 37103 * NB: This feature isn't supported in Internet Explorer 10. 37104 * @name referenceObject 37105 * @property {Function} data.getBoundingClientRect 37106 * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method. 37107 * @property {number} data.clientWidth 37108 * An ES6 getter that will return the width of the virtual reference element. 37109 * @property {number} data.clientHeight 37110 * An ES6 getter that will return the height of the virtual reference element. 37111 */ 37112 37113 37114Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils; 37115Popper.placements = placements; 37116Popper.Defaults = Defaults; 37117 37118/* harmony default export */ __webpack_exports__["default"] = (Popper); 37119//# sourceMappingURL=popper.js.map 37120 37121/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))) 37122 37123/***/ }), 37124
vendor: 5,681 bytes, lines 37125-37319
37125/***/ "./node_modules/process/browser.js": 37126/*!*****************************************!*\ 37127 !*** ./node_modules/process/browser.js ***! 37128 \*****************************************/ 37129/*! no static exports found */ 37130/***/ (function(module, exports) { 37131 37132// shim for using process in browser 37133var process = module.exports = {}; 37134 37135// cached from whatever global is present so that test runners that stub it 37136// don't break things. But we need to wrap it in a try catch in case it is 37137// wrapped in strict mode code which doesn't define any globals. It's inside a 37138// function because try/catches deoptimize in certain engines. 37139 37140var cachedSetTimeout; 37141var cachedClearTimeout; 37142 37143function defaultSetTimout() { 37144 throw new Error('setTimeout has not been defined'); 37145} 37146function defaultClearTimeout () { 37147 throw new Error('clearTimeout has not been defined'); 37148} 37149(function () { 37150 try { 37151 if (typeof setTimeout === 'function') { 37152 cachedSetTimeout = setTimeout; 37153 } else { 37154 cachedSetTimeout = defaultSetTimout; 37155 } 37156 } catch (e) { 37157 cachedSetTimeout = defaultSetTimout; 37158 } 37159 try { 37160 if (typeof clearTimeout === 'function') { 37161 cachedClearTimeout = clearTimeout; 37162 } else { 37163 cachedClearTimeout = defaultClearTimeout; 37164 } 37165 } catch (e) { 37166 cachedClearTimeout = defaultClearTimeout; 37167 } 37168} ()) 37169function runTimeout(fun) { 37170 if (cachedSetTimeout === setTimeout) { 37171 //normal enviroments in sane situations 37172 return setTimeout(fun, 0); 37173 } 37174 // if setTimeout wasn't available but was latter defined 37175 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { 37176 cachedSetTimeout = setTimeout; 37177 return setTimeout(fun, 0); 37178 } 37179 try { 37180 // when when somebody has screwed with setTimeout but no I.E. maddness 37181 return cachedSetTimeout(fun, 0); 37182 } catch(e){ 37183 try { 37184 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 37185 return cachedSetTimeout.call(null, fun, 0); 37186 } catch(e){ 37187 // 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 37188 return cachedSetTimeout.call(this, fun, 0); 37189 } 37190 } 37191 37192 37193} 37194function runClearTimeout(marker) { 37195 if (cachedClearTimeout === clearTimeout) { 37196 //normal enviroments in sane situations 37197 return clearTimeout(marker); 37198 } 37199 // if clearTimeout wasn't available but was latter defined 37200 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { 37201 cachedClearTimeout = clearTimeout; 37202 return clearTimeout(marker); 37203 } 37204 try { 37205 // when when somebody has screwed with setTimeout but no I.E. maddness 37206 return cachedClearTimeout(marker); 37207 } catch (e){ 37208 try { 37209 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 37210 return cachedClearTimeout.call(null, marker); 37211 } catch (e){ 37212 // 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. 37213 // Some versions of I.E. have different rules for clearTimeout vs setTimeout 37214 return cachedClearTimeout.call(this, marker); 37215 } 37216 } 37217 37218 37219 37220} 37221var queue = []; 37222var draining = false; 37223var currentQueue; 37224var queueIndex = -1; 37225 37226function cleanUpNextTick() { 37227 if (!draining || !currentQueue) { 37228 return; 37229 } 37230 draining = false; 37231 if (currentQueue.length) { 37232 queue = currentQueue.concat(queue); 37233 } else { 37234 queueIndex = -1; 37235 } 37236 if (queue.length) { 37237 drainQueue(); 37238 } 37239} 37240 37241function drainQueue() { 37242 if (draining) { 37243 return; 37244 } 37245 var timeout = runTimeout(cleanUpNextTick); 37246 draining = true; 37247 37248 var len = queue.length; 37249 while(len) { 37250 currentQueue = queue; 37251 queue = []; 37252 while (++queueIndex < len) { 37253 if (currentQueue) { 37254 currentQueue[queueIndex].run(); 37255 } 37256 } 37257 queueIndex = -1; 37258 len = queue.length; 37259 } 37260 currentQueue = null; 37261 draining = false; 37262 runClearTimeout(timeout); 37263} 37264 37265process.nextTick = function (fun) { 37266 var args = new Array(arguments.length - 1); 37267 if (arguments.length > 1) { 37268 for (var i = 1; i < arguments.length; i++) { 37269 args[i - 1] = arguments[i]; 37270 } 37271 } 37272 queue.push(new Item(fun, args)); 37273 if (queue.length === 1 && !draining) { 37274 runTimeout(drainQueue); 37275 } 37276}; 37277 37278// v8 likes predictible objects 37279function Item(fun, array) { 37280 this.fun = fun; 37281 this.array = array; 37282} 37283Item.prototype.run = function () { 37284 this.fun.apply(null, this.array); 37285}; 37286process.title = 'browser'; 37287process.browser = true; 37288process.env = {}; 37289process.argv = []; 37290process.version = ''; // empty string to avoid regexp issues 37291process.versions = {}; 37292 37293function noop() {} 37294 37295process.on = noop; 37296process.addListener = noop; 37297process.once = noop; 37298process.off = noop; 37299process.removeListener = noop; 37300process.removeAllListeners = noop; 37301process.emit = noop; 37302process.prependListener = noop; 37303process.prependOnceListener = noop; 37304 37305process.listeners = function (name) { return [] } 37306 37307process.binding = function (name) { 37308 throw new Error('process.binding is not supported'); 37309}; 37310 37311process.cwd = function () { return '/' }; 37312process.chdir = function (dir) { 37313 throw new Error('process.chdir is not supported'); 37314}; 37315process.umask = function() { return 0; }; 37316 37317 37318/***/ }), 37319
vendor: 4,080 bytes, lines 37320-37433
37320/***/ "./node_modules/prop-types/checkPropTypes.js": 37321/*!***************************************************!*\ 37322 !*** ./node_modules/prop-types/checkPropTypes.js ***! 37323 \***************************************************/ 37324/*! no static exports found */ 37325/***/ (function(module, exports, __webpack_require__) { 37326 37327"use strict"; 37328/** 37329 * Copyright (c) 2013-present, Facebook, Inc. 37330 * 37331 * This source code is licensed under the MIT license found in the 37332 * LICENSE file in the root directory of this source tree. 37333 */ 37334 37335 37336 37337var printWarning = function() {}; 37338 37339if (true) { 37340 var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "./node_modules/prop-types/lib/ReactPropTypesSecret.js"); 37341 var loggedTypeFailures = {}; 37342 var has = Function.call.bind(Object.prototype.hasOwnProperty); 37343 37344 printWarning = function(text) { 37345 var message = 'Warning: ' + text; 37346 if (typeof console !== 'undefined') { 37347 console.error(message); 37348 } 37349 try { 37350 // --- Welcome to debugging React --- 37351 // This error was thrown as a convenience so that you can use this stack 37352 // to find the callsite that caused this warning to fire. 37353 throw new Error(message); 37354 } catch (x) {} 37355 }; 37356} 37357 37358/** 37359 * Assert that the values match with the type specs. 37360 * Error messages are memorized and will only be shown once. 37361 * 37362 * @param {object} typeSpecs Map of name to a ReactPropType 37363 * @param {object} values Runtime values that need to be type-checked 37364 * @param {string} location e.g. "prop", "context", "child context" 37365 * @param {string} componentName Name of the component for error messages. 37366 * @param {?Function} getStack Returns the component stack. 37367 * @private 37368 */ 37369function checkPropTypes(typeSpecs, values, location, componentName, getStack) { 37370 if (true) { 37371 for (var typeSpecName in typeSpecs) { 37372 if (has(typeSpecs, typeSpecName)) { 37373 var error; 37374 // Prop type validation may throw. In case they do, we don't want to 37375 // fail the render phase where it didn't fail before. So we log it. 37376 // After these have been cleaned up, we'll let them throw. 37377 try { 37378 // This is intentionally an invariant that gets caught. It's the same 37379 // behavior as without this statement except with a better message. 37380 if (typeof typeSpecs[typeSpecName] !== 'function') { 37381 var err = Error( 37382 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 37383 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' 37384 ); 37385 err.name = 'Invariant Violation'; 37386 throw err; 37387 } 37388 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); 37389 } catch (ex) { 37390 error = ex; 37391 } 37392 if (error && !(error instanceof Error)) { 37393 printWarning( 37394 (componentName || 'React class') + ': type specification of ' + 37395 location + ' `' + typeSpecName + '` is invalid; the type checker ' + 37396 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + 37397 'You may have forgotten to pass an argument to the type checker ' + 37398 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 37399 'shape all require an argument).' 37400 ); 37401 } 37402 if (error instanceof Error && !(error.message in loggedTypeFailures)) { 37403 // Only monitor this failure once because there tends to be a lot of the 37404 // same error. 37405 loggedTypeFailures[error.message] = true; 37406 37407 var stack = getStack ? getStack() : ''; 37408 37409 printWarning( 37410 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') 37411 ); 37412 } 37413 } 37414 } 37415 } 37416} 37417 37418/** 37419 * Resets warning cache when testing. 37420 * 37421 * @private 37422 */ 37423checkPropTypes.resetWarningCache = function() { 37424 if (true) { 37425 loggedTypeFailures = {}; 37426 } 37427} 37428 37429module.exports = checkPropTypes; 37430 37431 37432/***/ }), 37433
vendor: 679 bytes, lines 37434-37457
37434/***/ "./node_modules/prop-types/lib/ReactPropTypesSecret.js": 37435/*!*************************************************************!*\ 37436 !*** ./node_modules/prop-types/lib/ReactPropTypesSecret.js ***! 37437 \*************************************************************/ 37438/*! no static exports found */ 37439/***/ (function(module, exports, __webpack_require__) { 37440 37441"use strict"; 37442/** 37443 * Copyright (c) 2013-present, Facebook, Inc. 37444 * 37445 * This source code is licensed under the MIT license found in the 37446 * LICENSE file in the root directory of this source tree. 37447 */ 37448 37449 37450 37451var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; 37452 37453module.exports = ReactPropTypesSecret; 37454 37455 37456/***/ }), 37457
vendor: 859,423 bytes, lines 37458-62481
37458/***/ "./node_modules/react-dom/cjs/react-dom.development.js": 37459/*!*************************************************************!*\ 37460 !*** ./node_modules/react-dom/cjs/react-dom.development.js ***! 37461 \*************************************************************/ 37462/*! no static exports found */ 37463/***/ (function(module, exports, __webpack_require__) { 37464 37465"use strict"; 37466/** @license React v16.14.0 37467 * react-dom.development.js 37468 * 37469 * Copyright (c) Facebook, Inc. and its affiliates. 37470 * 37471 * This source code is licensed under the MIT license found in the 37472 * LICENSE file in the root directory of this source tree. 37473 */ 37474 37475 37476 37477 37478 37479if (true) { 37480 (function() { 37481'use strict'; 37482 37483var React = __webpack_require__(/*! react */ "./node_modules/react/index.js"); 37484var _assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js"); 37485var Scheduler = __webpack_require__(/*! scheduler */ "./node_modules/scheduler/index.js"); 37486var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "./node_modules/prop-types/checkPropTypes.js"); 37487var tracing = __webpack_require__(/*! scheduler/tracing */ "./node_modules/scheduler/tracing.js"); 37488 37489var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. 37490// Current owner and dispatcher used to share the same ref, 37491// but PR #14548 split them out to better support the react-debug-tools package. 37492 37493if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) { 37494 ReactSharedInternals.ReactCurrentDispatcher = { 37495 current: null 37496 }; 37497} 37498 37499if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) { 37500 ReactSharedInternals.ReactCurrentBatchConfig = { 37501 suspense: null 37502 }; 37503} 37504 37505// by calls to these methods by a Babel plugin. 37506// 37507// In PROD (or in packages without access to React internals), 37508// they are left as they are instead. 37509 37510function warn(format) { 37511 { 37512 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 37513 args[_key - 1] = arguments[_key]; 37514 } 37515 37516 printWarning('warn', format, args); 37517 } 37518} 37519function error(format) { 37520 { 37521 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 37522 args[_key2 - 1] = arguments[_key2]; 37523 } 37524 37525 printWarning('error', format, args); 37526 } 37527} 37528 37529function printWarning(level, format, args) { 37530 // When changing this logic, you might want to also 37531 // update consoleWithStackDev.www.js as well. 37532 { 37533 var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0; 37534 37535 if (!hasExistingStack) { 37536 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 37537 var stack = ReactDebugCurrentFrame.getStackAddendum(); 37538 37539 if (stack !== '') { 37540 format += '%s'; 37541 args = args.concat([stack]); 37542 } 37543 } 37544 37545 var argsWithFormat = args.map(function (item) { 37546 return '' + item; 37547 }); // Careful: RN currently depends on this prefix 37548 37549 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it 37550 // breaks IE9: https://github.com/facebook/react/issues/13610 37551 // eslint-disable-next-line react-internal/no-production-logging 37552 37553 Function.prototype.apply.call(console[level], console, argsWithFormat); 37554 37555 try { 37556 // --- Welcome to debugging React --- 37557 // This error was thrown as a convenience so that you can use this stack 37558 // to find the callsite that caused this warning to fire. 37559 var argIndex = 0; 37560 var message = 'Warning: ' + format.replace(/%s/g, function () { 37561 return args[argIndex++]; 37562 }); 37563 throw new Error(message); 37564 } catch (x) {} 37565 } 37566} 37567 37568if (!React) { 37569 { 37570 throw Error( "ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM." ); 37571 } 37572} 37573 37574var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) { 37575 var funcArgs = Array.prototype.slice.call(arguments, 3); 37576 37577 try { 37578 func.apply(context, funcArgs); 37579 } catch (error) { 37580 this.onError(error); 37581 } 37582}; 37583 37584{ 37585 // In DEV mode, we swap out invokeGuardedCallback for a special version 37586 // that plays more nicely with the browser's DevTools. The idea is to preserve 37587 // "Pause on exceptions" behavior. Because React wraps all user-provided 37588 // functions in invokeGuardedCallback, and the production version of 37589 // invokeGuardedCallback uses a try-catch, all user exceptions are treated 37590 // like caught exceptions, and the DevTools won't pause unless the developer 37591 // takes the extra step of enabling pause on caught exceptions. This is 37592 // unintuitive, though, because even though React has caught the error, from 37593 // the developer's perspective, the error is uncaught. 37594 // 37595 // To preserve the expected "Pause on exceptions" behavior, we don't use a 37596 // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake 37597 // DOM node, and call the user-provided callback from inside an event handler 37598 // for that fake event. If the callback throws, the error is "captured" using 37599 // a global event handler. But because the error happens in a different 37600 // event loop context, it does not interrupt the normal program flow. 37601 // Effectively, this gives us try-catch behavior without actually using 37602 // try-catch. Neat! 37603 // Check that the browser supports the APIs we need to implement our special 37604 // DEV version of invokeGuardedCallback 37605 if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { 37606 var fakeNode = document.createElement('react'); 37607 37608 var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) { 37609 // If document doesn't exist we know for sure we will crash in this method 37610 // when we call document.createEvent(). However this can cause confusing 37611 // errors: https://github.com/facebookincubator/create-react-app/issues/3482 37612 // So we preemptively throw with a better message instead. 37613 if (!(typeof document !== 'undefined')) { 37614 { 37615 throw Error( "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." ); 37616 } 37617 } 37618 37619 var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We 37620 // set this to true at the beginning, then set it to false right after 37621 // calling the function. If the function errors, `didError` will never be 37622 // set to false. This strategy works even if the browser is flaky and 37623 // fails to call our global error handler, because it doesn't rely on 37624 // the error event at all. 37625 37626 var didError = true; // Keeps track of the value of window.event so that we can reset it 37627 // during the callback to let user code access window.event in the 37628 // browsers that support it. 37629 37630 var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event 37631 // dispatching: https://github.com/facebook/react/issues/13688 37632 37633 var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); // Create an event handler for our fake event. We will synchronously 37634 // dispatch our fake event using `dispatchEvent`. Inside the handler, we 37635 // call the user-provided callback. 37636 37637 var funcArgs = Array.prototype.slice.call(arguments, 3); 37638 37639 function callCallback() { 37640 // We immediately remove the callback from event listeners so that 37641 // nested `invokeGuardedCallback` calls do not clash. Otherwise, a 37642 // nested call would trigger the fake event handlers of any call higher 37643 // in the stack. 37644 fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the 37645 // window.event assignment in both IE <= 10 as they throw an error 37646 // "Member not found" in strict mode, and in Firefox which does not 37647 // support window.event. 37648 37649 if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) { 37650 window.event = windowEvent; 37651 } 37652 37653 func.apply(context, funcArgs); 37654 didError = false; 37655 } // Create a global error event handler. We use this to capture the value 37656 // that was thrown. It's possible that this error handler will fire more 37657 // than once; for example, if non-React code also calls `dispatchEvent` 37658 // and a handler for that event throws. We should be resilient to most of 37659 // those cases. Even if our error event handler fires more than once, the 37660 // last error event is always used. If the callback actually does error, 37661 // we know that the last error event is the correct one, because it's not 37662 // possible for anything else to have happened in between our callback 37663 // erroring and the code that follows the `dispatchEvent` call below. If 37664 // the callback doesn't error, but the error event was fired, we know to 37665 // ignore it because `didError` will be false, as described above. 37666 37667 37668 var error; // Use this to track whether the error event is ever called. 37669 37670 var didSetError = false; 37671 var isCrossOriginError = false; 37672 37673 function handleWindowError(event) { 37674 error = event.error; 37675 didSetError = true; 37676 37677 if (error === null && event.colno === 0 && event.lineno === 0) { 37678 isCrossOriginError = true; 37679 } 37680 37681 if (event.defaultPrevented) { 37682 // Some other error handler has prevented default. 37683 // Browsers silence the error report if this happens. 37684 // We'll remember this to later decide whether to log it or not. 37685 if (error != null && typeof error === 'object') { 37686 try { 37687 error._suppressLogging = true; 37688 } catch (inner) {// Ignore. 37689 } 37690 } 37691 } 37692 } // Create a fake event type. 37693 37694 37695 var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers 37696 37697 window.addEventListener('error', handleWindowError); 37698 fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function 37699 // errors, it will trigger our global error handler. 37700 37701 evt.initEvent(evtType, false, false); 37702 fakeNode.dispatchEvent(evt); 37703 37704 if (windowEventDescriptor) { 37705 Object.defineProperty(window, 'event', windowEventDescriptor); 37706 } 37707 37708 if (didError) { 37709 if (!didSetError) { 37710 // The callback errored, but the error event never fired. 37711 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.'); 37712 } else if (isCrossOriginError) { 37713 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.'); 37714 } 37715 37716 this.onError(error); 37717 } // Remove our event listeners 37718 37719 37720 window.removeEventListener('error', handleWindowError); 37721 }; 37722 37723 invokeGuardedCallbackImpl = invokeGuardedCallbackDev; 37724 } 37725} 37726 37727var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; 37728 37729var hasError = false; 37730var caughtError = null; // Used by event system to capture/rethrow the first error. 37731 37732var hasRethrowError = false; 37733var rethrowError = null; 37734var reporter = { 37735 onError: function (error) { 37736 hasError = true; 37737 caughtError = error; 37738 } 37739}; 37740/** 37741 * Call a function while guarding against errors that happens within it. 37742 * Returns an error if it throws, otherwise null. 37743 * 37744 * In production, this is implemented using a try-catch. The reason we don't 37745 * use a try-catch directly is so that we can swap out a different 37746 * implementation in DEV mode. 37747 * 37748 * @param {String} name of the guard to use for logging or debugging 37749 * @param {Function} func The function to invoke 37750 * @param {*} context The context to use when calling the function 37751 * @param {...*} args Arguments for function 37752 */ 37753 37754function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { 37755 hasError = false; 37756 caughtError = null; 37757 invokeGuardedCallbackImpl$1.apply(reporter, arguments); 37758} 37759/** 37760 * Same as invokeGuardedCallback, but instead of returning an error, it stores 37761 * it in a global so it can be rethrown by `rethrowCaughtError` later. 37762 * TODO: See if caughtError and rethrowError can be unified. 37763 * 37764 * @param {String} name of the guard to use for logging or debugging 37765 * @param {Function} func The function to invoke 37766 * @param {*} context The context to use when calling the function 37767 * @param {...*} args Arguments for function 37768 */ 37769 37770function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) { 37771 invokeGuardedCallback.apply(this, arguments); 37772 37773 if (hasError) { 37774 var error = clearCaughtError(); 37775 37776 if (!hasRethrowError) { 37777 hasRethrowError = true; 37778 rethrowError = error; 37779 } 37780 } 37781} 37782/** 37783 * During execution of guarded functions we will capture the first error which 37784 * we will rethrow to be handled by the top level error handler. 37785 */ 37786 37787function rethrowCaughtError() { 37788 if (hasRethrowError) { 37789 var error = rethrowError; 37790 hasRethrowError = false; 37791 rethrowError = null; 37792 throw error; 37793 } 37794} 37795function hasCaughtError() { 37796 return hasError; 37797} 37798function clearCaughtError() { 37799 if (hasError) { 37800 var error = caughtError; 37801 hasError = false; 37802 caughtError = null; 37803 return error; 37804 } else { 37805 { 37806 { 37807 throw Error( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." ); 37808 } 37809 } 37810 } 37811} 37812 37813var getFiberCurrentPropsFromNode = null; 37814var getInstanceFromNode = null; 37815var getNodeFromInstance = null; 37816function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) { 37817 getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl; 37818 getInstanceFromNode = getInstanceFromNodeImpl; 37819 getNodeFromInstance = getNodeFromInstanceImpl; 37820 37821 { 37822 if (!getNodeFromInstance || !getInstanceFromNode) { 37823 error('EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.'); 37824 } 37825 } 37826} 37827var validateEventDispatches; 37828 37829{ 37830 validateEventDispatches = function (event) { 37831 var dispatchListeners = event._dispatchListeners; 37832 var dispatchInstances = event._dispatchInstances; 37833 var listenersIsArr = Array.isArray(dispatchListeners); 37834 var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0; 37835 var instancesIsArr = Array.isArray(dispatchInstances); 37836 var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0; 37837 37838 if (instancesIsArr !== listenersIsArr || instancesLen !== listenersLen) { 37839 error('EventPluginUtils: Invalid `event`.'); 37840 } 37841 }; 37842} 37843/** 37844 * Dispatch the event to the listener. 37845 * @param {SyntheticEvent} event SyntheticEvent to handle 37846 * @param {function} listener Application-level callback 37847 * @param {*} inst Internal component instance 37848 */ 37849 37850 37851function executeDispatch(event, listener, inst) { 37852 var type = event.type || 'unknown-event'; 37853 event.currentTarget = getNodeFromInstance(inst); 37854 invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); 37855 event.currentTarget = null; 37856} 37857/** 37858 * Standard/simple iteration through an event's collected dispatches. 37859 */ 37860 37861function executeDispatchesInOrder(event) { 37862 var dispatchListeners = event._dispatchListeners; 37863 var dispatchInstances = event._dispatchInstances; 37864 37865 { 37866 validateEventDispatches(event); 37867 } 37868 37869 if (Array.isArray(dispatchListeners)) { 37870 for (var i = 0; i < dispatchListeners.length; i++) { 37871 if (event.isPropagationStopped()) { 37872 break; 37873 } // Listeners and Instances are two parallel arrays that are always in sync. 37874 37875 37876 executeDispatch(event, dispatchListeners[i], dispatchInstances[i]); 37877 } 37878 } else if (dispatchListeners) { 37879 executeDispatch(event, dispatchListeners, dispatchInstances); 37880 } 37881 37882 event._dispatchListeners = null; 37883 event._dispatchInstances = null; 37884} 37885 37886var FunctionComponent = 0; 37887var ClassComponent = 1; 37888var IndeterminateComponent = 2; // Before we know whether it is function or class 37889 37890var HostRoot = 3; // Root of a host tree. Could be nested inside another node. 37891 37892var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. 37893 37894var HostComponent = 5; 37895var HostText = 6; 37896var Fragment = 7; 37897var Mode = 8; 37898var ContextConsumer = 9; 37899var ContextProvider = 10; 37900var ForwardRef = 11; 37901var Profiler = 12; 37902var SuspenseComponent = 13; 37903var MemoComponent = 14; 37904var SimpleMemoComponent = 15; 37905var LazyComponent = 16; 37906var IncompleteClassComponent = 17; 37907var DehydratedFragment = 18; 37908var SuspenseListComponent = 19; 37909var FundamentalComponent = 20; 37910var ScopeComponent = 21; 37911var Block = 22; 37912 37913/** 37914 * Injectable ordering of event plugins. 37915 */ 37916var eventPluginOrder = null; 37917/** 37918 * Injectable mapping from names to event plugin modules. 37919 */ 37920 37921var namesToPlugins = {}; 37922/** 37923 * Recomputes the plugin list using the injected plugins and plugin ordering. 37924 * 37925 * @private 37926 */ 37927 37928function recomputePluginOrdering() { 37929 if (!eventPluginOrder) { 37930 // Wait until an `eventPluginOrder` is injected. 37931 return; 37932 } 37933 37934 for (var pluginName in namesToPlugins) { 37935 var pluginModule = namesToPlugins[pluginName]; 37936 var pluginIndex = eventPluginOrder.indexOf(pluginName); 37937 37938 if (!(pluginIndex > -1)) { 37939 { 37940 throw Error( "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + pluginName + "`." ); 37941 } 37942 } 37943 37944 if (plugins[pluginIndex]) { 37945 continue; 37946 } 37947 37948 if (!pluginModule.extractEvents) { 37949 { 37950 throw Error( "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + pluginName + "` does not." ); 37951 } 37952 } 37953 37954 plugins[pluginIndex] = pluginModule; 37955 var publishedEvents = pluginModule.eventTypes; 37956 37957 for (var eventName in publishedEvents) { 37958 if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) { 37959 { 37960 throw Error( "EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + pluginName + "`." ); 37961 } 37962 } 37963 } 37964 } 37965} 37966/** 37967 * Publishes an event so that it can be dispatched by the supplied plugin. 37968 * 37969 * @param {object} dispatchConfig Dispatch configuration for the event. 37970 * @param {object} PluginModule Plugin publishing the event. 37971 * @return {boolean} True if the event was successfully published. 37972 * @private 37973 */ 37974 37975 37976function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { 37977 if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { 37978 { 37979 throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + eventName + "`." ); 37980 } 37981 } 37982 37983 eventNameDispatchConfigs[eventName] = dispatchConfig; 37984 var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; 37985 37986 if (phasedRegistrationNames) { 37987 for (var phaseName in phasedRegistrationNames) { 37988 if (phasedRegistrationNames.hasOwnProperty(phaseName)) { 37989 var phasedRegistrationName = phasedRegistrationNames[phaseName]; 37990 publishRegistrationName(phasedRegistrationName, pluginModule, eventName); 37991 } 37992 } 37993 37994 return true; 37995 } else if (dispatchConfig.registrationName) { 37996 publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName); 37997 return true; 37998 } 37999 38000 return false; 38001} 38002/** 38003 * Publishes a registration name that is used to identify dispatched events. 38004 * 38005 * @param {string} registrationName Registration name to add. 38006 * @param {object} PluginModule Plugin publishing the event. 38007 * @private 38008 */ 38009 38010 38011function publishRegistrationName(registrationName, pluginModule, eventName) { 38012 if (!!registrationNameModules[registrationName]) { 38013 { 38014 throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + registrationName + "`." ); 38015 } 38016 } 38017 38018 registrationNameModules[registrationName] = pluginModule; 38019 registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies; 38020 38021 { 38022 var lowerCasedName = registrationName.toLowerCase(); 38023 possibleRegistrationNames[lowerCasedName] = registrationName; 38024 38025 if (registrationName === 'onDoubleClick') { 38026 possibleRegistrationNames.ondblclick = registrationName; 38027 } 38028 } 38029} 38030/** 38031 * Registers plugins so that they can extract and dispatch events. 38032 */ 38033 38034/** 38035 * Ordered list of injected plugins. 38036 */ 38037 38038 38039var plugins = []; 38040/** 38041 * Mapping from event name to dispatch config 38042 */ 38043 38044var eventNameDispatchConfigs = {}; 38045/** 38046 * Mapping from registration name to plugin module 38047 */ 38048 38049var registrationNameModules = {}; 38050/** 38051 * Mapping from registration name to event name 38052 */ 38053 38054var registrationNameDependencies = {}; 38055/** 38056 * Mapping from lowercase registration names to the properly cased version, 38057 * used to warn in the case of missing event handlers. Available 38058 * only in true. 38059 * @type {Object} 38060 */ 38061 38062var possibleRegistrationNames = {} ; // Trust the developer to only use possibleRegistrationNames in true 38063 38064/** 38065 * Injects an ordering of plugins (by plugin name). This allows the ordering 38066 * to be decoupled from injection of the actual plugins so that ordering is 38067 * always deterministic regardless of packaging, on-the-fly injection, etc. 38068 * 38069 * @param {array} InjectedEventPluginOrder 38070 * @internal 38071 */ 38072 38073function injectEventPluginOrder(injectedEventPluginOrder) { 38074 if (!!eventPluginOrder) { 38075 { 38076 throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." ); 38077 } 38078 } // Clone the ordering so it cannot be dynamically mutated. 38079 38080 38081 eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); 38082 recomputePluginOrdering(); 38083} 38084/** 38085 * Injects plugins to be used by plugin event system. The plugin names must be 38086 * in the ordering injected by `injectEventPluginOrder`. 38087 * 38088 * Plugins can be injected as part of page initialization or on-the-fly. 38089 * 38090 * @param {object} injectedNamesToPlugins Map from names to plugin modules. 38091 * @internal 38092 */ 38093 38094function injectEventPluginsByName(injectedNamesToPlugins) { 38095 var isOrderingDirty = false; 38096 38097 for (var pluginName in injectedNamesToPlugins) { 38098 if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { 38099 continue; 38100 } 38101 38102 var pluginModule = injectedNamesToPlugins[pluginName]; 38103 38104 if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) { 38105 if (!!namesToPlugins[pluginName]) { 38106 { 38107 throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + pluginName + "`." ); 38108 } 38109 } 38110 38111 namesToPlugins[pluginName] = pluginModule; 38112 isOrderingDirty = true; 38113 } 38114 } 38115 38116 if (isOrderingDirty) { 38117 recomputePluginOrdering(); 38118 } 38119} 38120 38121var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); 38122 38123var PLUGIN_EVENT_SYSTEM = 1; 38124var IS_REPLAYED = 1 << 5; 38125var IS_FIRST_ANCESTOR = 1 << 6; 38126 38127var restoreImpl = null; 38128var restoreTarget = null; 38129var restoreQueue = null; 38130 38131function restoreStateOfTarget(target) { 38132 // We perform this translation at the end of the event loop so that we 38133 // always receive the correct fiber here 38134 var internalInstance = getInstanceFromNode(target); 38135 38136 if (!internalInstance) { 38137 // Unmounted 38138 return; 38139 } 38140 38141 if (!(typeof restoreImpl === 'function')) { 38142 { 38143 throw Error( "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); 38144 } 38145 } 38146 38147 var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted. 38148 38149 if (stateNode) { 38150 var _props = getFiberCurrentPropsFromNode(stateNode); 38151 38152 restoreImpl(internalInstance.stateNode, internalInstance.type, _props); 38153 } 38154} 38155 38156function setRestoreImplementation(impl) { 38157 restoreImpl = impl; 38158} 38159function enqueueStateRestore(target) { 38160 if (restoreTarget) { 38161 if (restoreQueue) { 38162 restoreQueue.push(target); 38163 } else { 38164 restoreQueue = [target]; 38165 } 38166 } else { 38167 restoreTarget = target; 38168 } 38169} 38170function needsStateRestore() { 38171 return restoreTarget !== null || restoreQueue !== null; 38172} 38173function restoreStateIfNeeded() { 38174 if (!restoreTarget) { 38175 return; 38176 } 38177 38178 var target = restoreTarget; 38179 var queuedTargets = restoreQueue; 38180 restoreTarget = null; 38181 restoreQueue = null; 38182 restoreStateOfTarget(target); 38183 38184 if (queuedTargets) { 38185 for (var i = 0; i < queuedTargets.length; i++) { 38186 restoreStateOfTarget(queuedTargets[i]); 38187 } 38188 } 38189} 38190 38191var enableProfilerTimer = true; // Trace which interactions trigger each commit. 38192 38193var enableDeprecatedFlareAPI = false; // Experimental Host Component support. 38194 38195var enableFundamentalAPI = false; // Experimental Scope support. 38196var warnAboutStringRefs = false; 38197 38198// the renderer. Such as when we're dispatching events or if third party 38199// libraries need to call batchedUpdates. Eventually, this API will go away when 38200// everything is batched by default. We'll then have a similar API to opt-out of 38201// scheduled work and instead do synchronous work. 38202// Defaults 38203 38204var batchedUpdatesImpl = function (fn, bookkeeping) { 38205 return fn(bookkeeping); 38206}; 38207 38208var discreteUpdatesImpl = function (fn, a, b, c, d) { 38209 return fn(a, b, c, d); 38210}; 38211 38212var flushDiscreteUpdatesImpl = function () {}; 38213 38214var batchedEventUpdatesImpl = batchedUpdatesImpl; 38215var isInsideEventHandler = false; 38216var isBatchingEventUpdates = false; 38217 38218function finishEventHandler() { 38219 // Here we wait until all updates have propagated, which is important 38220 // when using controlled components within layers: 38221 // https://github.com/facebook/react/issues/1698 38222 // Then we restore state of any controlled component. 38223 var controlledComponentsHavePendingUpdates = needsStateRestore(); 38224 38225 if (controlledComponentsHavePendingUpdates) { 38226 // If a controlled event was fired, we may need to restore the state of 38227 // the DOM node back to the controlled value. This is necessary when React 38228 // bails out of the update without touching the DOM. 38229 flushDiscreteUpdatesImpl(); 38230 restoreStateIfNeeded(); 38231 } 38232} 38233 38234function batchedUpdates(fn, bookkeeping) { 38235 if (isInsideEventHandler) { 38236 // If we are currently inside another batch, we need to wait until it 38237 // fully completes before restoring state. 38238 return fn(bookkeeping); 38239 } 38240 38241 isInsideEventHandler = true; 38242 38243 try { 38244 return batchedUpdatesImpl(fn, bookkeeping); 38245 } finally { 38246 isInsideEventHandler = false; 38247 finishEventHandler(); 38248 } 38249} 38250function batchedEventUpdates(fn, a, b) { 38251 if (isBatchingEventUpdates) { 38252 // If we are currently inside another batch, we need to wait until it 38253 // fully completes before restoring state. 38254 return fn(a, b); 38255 } 38256 38257 isBatchingEventUpdates = true; 38258 38259 try { 38260 return batchedEventUpdatesImpl(fn, a, b); 38261 } finally { 38262 isBatchingEventUpdates = false; 38263 finishEventHandler(); 38264 } 38265} // This is for the React Flare event system 38266function discreteUpdates(fn, a, b, c, d) { 38267 var prevIsInsideEventHandler = isInsideEventHandler; 38268 isInsideEventHandler = true; 38269 38270 try { 38271 return discreteUpdatesImpl(fn, a, b, c, d); 38272 } finally { 38273 isInsideEventHandler = prevIsInsideEventHandler; 38274 38275 if (!isInsideEventHandler) { 38276 finishEventHandler(); 38277 } 38278 } 38279} 38280function flushDiscreteUpdatesIfNeeded(timeStamp) { 38281 // event.timeStamp isn't overly reliable due to inconsistencies in 38282 // how different browsers have historically provided the time stamp. 38283 // Some browsers provide high-resolution time stamps for all events, 38284 // some provide low-resolution time stamps for all events. FF < 52 38285 // even mixes both time stamps together. Some browsers even report 38286 // negative time stamps or time stamps that are 0 (iOS9) in some cases. 38287 // Given we are only comparing two time stamps with equality (!==), 38288 // we are safe from the resolution differences. If the time stamp is 0 38289 // we bail-out of preventing the flush, which can affect semantics, 38290 // such as if an earlier flush removes or adds event listeners that 38291 // are fired in the subsequent flush. However, this is the same 38292 // behaviour as we had before this change, so the risks are low. 38293 if (!isInsideEventHandler && (!enableDeprecatedFlareAPI )) { 38294 flushDiscreteUpdatesImpl(); 38295 } 38296} 38297function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) { 38298 batchedUpdatesImpl = _batchedUpdatesImpl; 38299 discreteUpdatesImpl = _discreteUpdatesImpl; 38300 flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl; 38301 batchedEventUpdatesImpl = _batchedEventUpdatesImpl; 38302} 38303 38304var DiscreteEvent = 0; 38305var UserBlockingEvent = 1; 38306var ContinuousEvent = 2; 38307 38308// A reserved attribute. 38309// It is handled by React separately and shouldn't be written to the DOM. 38310var RESERVED = 0; // A simple string attribute. 38311// Attributes that aren't in the whitelist are presumed to have this type. 38312 38313var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called 38314// "enumerated" attributes with "true" and "false" as possible values. 38315// When true, it should be set to a "true" string. 38316// When false, it should be set to a "false" string. 38317 38318var BOOLEANISH_STRING = 2; // A real boolean attribute. 38319// When true, it should be present (set either to an empty string or its name). 38320// When false, it should be omitted. 38321 38322var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value. 38323// When true, it should be present (set either to an empty string or its name). 38324// When false, it should be omitted. 38325// For any other value, should be present with that value. 38326 38327var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric. 38328// When falsy, it should be removed. 38329 38330var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric. 38331// When falsy, it should be removed. 38332 38333var POSITIVE_NUMERIC = 6; 38334 38335/* eslint-disable max-len */ 38336var 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"; 38337/* eslint-enable max-len */ 38338 38339var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; 38340var ROOT_ATTRIBUTE_NAME = 'data-reactroot'; 38341var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$'); 38342var hasOwnProperty = Object.prototype.hasOwnProperty; 38343var illegalAttributeNameCache = {}; 38344var validatedAttributeNameCache = {}; 38345function isAttributeNameSafe(attributeName) { 38346 if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) { 38347 return true; 38348 } 38349 38350 if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) { 38351 return false; 38352 } 38353 38354 if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { 38355 validatedAttributeNameCache[attributeName] = true; 38356 return true; 38357 } 38358 38359 illegalAttributeNameCache[attributeName] = true; 38360 38361 { 38362 error('Invalid attribute name: `%s`', attributeName); 38363 } 38364 38365 return false; 38366} 38367function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) { 38368 if (propertyInfo !== null) { 38369 return propertyInfo.type === RESERVED; 38370 } 38371 38372 if (isCustomComponentTag) { 38373 return false; 38374 } 38375 38376 if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) { 38377 return true; 38378 } 38379 38380 return false; 38381} 38382function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) { 38383 if (propertyInfo !== null && propertyInfo.type === RESERVED) { 38384 return false; 38385 } 38386 38387 switch (typeof value) { 38388 case 'function': // $FlowIssue symbol is perfectly valid here 38389 38390 case 'symbol': 38391 // eslint-disable-line 38392 return true; 38393 38394 case 'boolean': 38395 { 38396 if (isCustomComponentTag) { 38397 return false; 38398 } 38399 38400 if (propertyInfo !== null) { 38401 return !propertyInfo.acceptsBooleans; 38402 } else { 38403 var prefix = name.toLowerCase().slice(0, 5); 38404 return prefix !== 'data-' && prefix !== 'aria-'; 38405 } 38406 } 38407 38408 default: 38409 return false; 38410 } 38411} 38412function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) { 38413 if (value === null || typeof value === 'undefined') { 38414 return true; 38415 } 38416 38417 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) { 38418 return true; 38419 } 38420 38421 if (isCustomComponentTag) { 38422 return false; 38423 } 38424 38425 if (propertyInfo !== null) { 38426 switch (propertyInfo.type) { 38427 case BOOLEAN: 38428 return !value; 38429 38430 case OVERLOADED_BOOLEAN: 38431 return value === false; 38432 38433 case NUMERIC: 38434 return isNaN(value); 38435 38436 case POSITIVE_NUMERIC: 38437 return isNaN(value) || value < 1; 38438 } 38439 } 38440 38441 return false; 38442} 38443function getPropertyInfo(name) { 38444 return properties.hasOwnProperty(name) ? properties[name] : null; 38445} 38446 38447function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL) { 38448 this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN; 38449 this.attributeName = attributeName; 38450 this.attributeNamespace = attributeNamespace; 38451 this.mustUseProperty = mustUseProperty; 38452 this.propertyName = name; 38453 this.type = type; 38454 this.sanitizeURL = sanitizeURL; 38455} // When adding attributes to this list, be sure to also add them to 38456// the `possibleStandardNames` module to ensure casing and incorrect 38457// name warnings. 38458 38459 38460var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM. 38461 38462var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular 38463// elements (not just inputs). Now that ReactDOMInput assigns to the 38464// defaultValue property -- do we need this? 38465'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style']; 38466 38467reservedProps.forEach(function (name) { 38468 properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty 38469 name, // attributeName 38470 null, // attributeNamespace 38471 false); 38472}); // A few React string attributes have a different name. 38473// This is a mapping from React prop names to the attribute names. 38474 38475[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) { 38476 var name = _ref[0], 38477 attributeName = _ref[1]; 38478 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 38479 attributeName, // attributeName 38480 null, // attributeNamespace 38481 false); 38482}); // These are "enumerated" HTML attributes that accept "true" and "false". 38483// In React, we let users pass `true` and `false` even though technically 38484// these aren't boolean attributes (they are coerced to strings). 38485 38486['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) { 38487 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty 38488 name.toLowerCase(), // attributeName 38489 null, // attributeNamespace 38490 false); 38491}); // These are "enumerated" SVG attributes that accept "true" and "false". 38492// In React, we let users pass `true` and `false` even though technically 38493// these aren't boolean attributes (they are coerced to strings). 38494// Since these are SVG attributes, their attribute names are case-sensitive. 38495 38496['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) { 38497 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty 38498 name, // attributeName 38499 null, // attributeNamespace 38500 false); 38501}); // These are HTML boolean attributes. 38502 38503['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM 38504// on the client side because the browsers are inconsistent. Instead we call focus(). 38505'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata 38506'itemScope'].forEach(function (name) { 38507 properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty 38508 name.toLowerCase(), // attributeName 38509 null, // attributeNamespace 38510 false); 38511}); // These are the few React props that we set as DOM properties 38512// rather than attributes. These are all booleans. 38513 38514['checked', // Note: `option.selected` is not updated if `select.multiple` is 38515// disabled with `removeAttribute`. We have special logic for handling this. 38516'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list, 38517// you'll need to set attributeName to name.toLowerCase() 38518// instead in the assignment below. 38519].forEach(function (name) { 38520 properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty 38521 name, // attributeName 38522 null, // attributeNamespace 38523 false); 38524}); // These are HTML attributes that are "overloaded booleans": they behave like 38525// booleans, but can also accept a string value. 38526 38527['capture', 'download' // NOTE: if you add a camelCased prop to this list, 38528// you'll need to set attributeName to name.toLowerCase() 38529// instead in the assignment below. 38530].forEach(function (name) { 38531 properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty 38532 name, // attributeName 38533 null, // attributeNamespace 38534 false); 38535}); // These are HTML attributes that must be positive numbers. 38536 38537['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list, 38538// you'll need to set attributeName to name.toLowerCase() 38539// instead in the assignment below. 38540].forEach(function (name) { 38541 properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty 38542 name, // attributeName 38543 null, // attributeNamespace 38544 false); 38545}); // These are HTML attributes that must be numbers. 38546 38547['rowSpan', 'start'].forEach(function (name) { 38548 properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty 38549 name.toLowerCase(), // attributeName 38550 null, // attributeNamespace 38551 false); 38552}); 38553var CAMELIZE = /[\-\:]([a-z])/g; 38554 38555var capitalize = function (token) { 38556 return token[1].toUpperCase(); 38557}; // This is a list of all SVG attributes that need special casing, namespacing, 38558// or boolean value assignment. Regular attributes that just accept strings 38559// and have the same names are omitted, just like in the HTML whitelist. 38560// Some of these attributes can be hard to find. This list was created by 38561// scraping the MDN documentation. 38562 38563 38564['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' // NOTE: if you add a camelCased prop to this list, 38565// you'll need to set attributeName to name.toLowerCase() 38566// instead in the assignment below. 38567].forEach(function (attributeName) { 38568 var name = attributeName.replace(CAMELIZE, capitalize); 38569 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 38570 attributeName, null, // attributeNamespace 38571 false); 38572}); // String SVG attributes with the xlink namespace. 38573 38574['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list, 38575// you'll need to set attributeName to name.toLowerCase() 38576// instead in the assignment below. 38577].forEach(function (attributeName) { 38578 var name = attributeName.replace(CAMELIZE, capitalize); 38579 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 38580 attributeName, 'http://www.w3.org/1999/xlink', false); 38581}); // String SVG attributes with the xml namespace. 38582 38583['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list, 38584// you'll need to set attributeName to name.toLowerCase() 38585// instead in the assignment below. 38586].forEach(function (attributeName) { 38587 var name = attributeName.replace(CAMELIZE, capitalize); 38588 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 38589 attributeName, 'http://www.w3.org/XML/1998/namespace', false); 38590}); // These attribute exists both in HTML and SVG. 38591// The attribute name is case-sensitive in SVG so we can't just use 38592// the React name like we do for attributes that exist only in HTML. 38593 38594['tabIndex', 'crossOrigin'].forEach(function (attributeName) { 38595 properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty 38596 attributeName.toLowerCase(), // attributeName 38597 null, // attributeNamespace 38598 false); 38599}); // These attributes accept URLs. These must not allow javascript: URLS. 38600// These will also need to accept Trusted Types object in the future. 38601 38602var xlinkHref = 'xlinkHref'; 38603properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty 38604'xlink:href', 'http://www.w3.org/1999/xlink', true); 38605['src', 'href', 'action', 'formAction'].forEach(function (attributeName) { 38606 properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty 38607 attributeName.toLowerCase(), // attributeName 38608 null, // attributeNamespace 38609 true); 38610}); 38611 38612var ReactDebugCurrentFrame = null; 38613 38614{ 38615 ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 38616} // A javascript: URL can contain leading C0 control or \u0020 SPACE, 38617// and any newline or tab are filtered out as if they're not part of the URL. 38618// https://url.spec.whatwg.org/#url-parsing 38619// Tab or newline are defined as \r\n\t: 38620// https://infra.spec.whatwg.org/#ascii-tab-or-newline 38621// A C0 control is a code point in the range \u0000 NULL to \u001F 38622// INFORMATION SEPARATOR ONE, inclusive: 38623// https://infra.spec.whatwg.org/#c0-control-or-space 38624 38625/* eslint-disable max-len */ 38626 38627 38628var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i; 38629var didWarn = false; 38630 38631function sanitizeURL(url) { 38632 { 38633 if (!didWarn && isJavaScriptProtocol.test(url)) { 38634 didWarn = true; 38635 38636 error('A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url)); 38637 } 38638 } 38639} 38640 38641/** 38642 * Get the value for a property on a node. Only used in DEV for SSR validation. 38643 * The "expected" argument is used as a hint of what the expected value is. 38644 * Some properties have multiple equivalent values. 38645 */ 38646function getValueForProperty(node, name, expected, propertyInfo) { 38647 { 38648 if (propertyInfo.mustUseProperty) { 38649 var propertyName = propertyInfo.propertyName; 38650 return node[propertyName]; 38651 } else { 38652 if ( propertyInfo.sanitizeURL) { 38653 // If we haven't fully disabled javascript: URLs, and if 38654 // the hydration is successful of a javascript: URL, we 38655 // still want to warn on the client. 38656 sanitizeURL('' + expected); 38657 } 38658 38659 var attributeName = propertyInfo.attributeName; 38660 var stringValue = null; 38661 38662 if (propertyInfo.type === OVERLOADED_BOOLEAN) { 38663 if (node.hasAttribute(attributeName)) { 38664 var value = node.getAttribute(attributeName); 38665 38666 if (value === '') { 38667 return true; 38668 } 38669 38670 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 38671 return value; 38672 } 38673 38674 if (value === '' + expected) { 38675 return expected; 38676 } 38677 38678 return value; 38679 } 38680 } else if (node.hasAttribute(attributeName)) { 38681 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 38682 // We had an attribute but shouldn't have had one, so read it 38683 // for the error message. 38684 return node.getAttribute(attributeName); 38685 } 38686 38687 if (propertyInfo.type === BOOLEAN) { 38688 // If this was a boolean, it doesn't matter what the value is 38689 // the fact that we have it is the same as the expected. 38690 return expected; 38691 } // Even if this property uses a namespace we use getAttribute 38692 // because we assume its namespaced name is the same as our config. 38693 // To use getAttributeNS we need the local name which we don't have 38694 // in our config atm. 38695 38696 38697 stringValue = node.getAttribute(attributeName); 38698 } 38699 38700 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 38701 return stringValue === null ? expected : stringValue; 38702 } else if (stringValue === '' + expected) { 38703 return expected; 38704 } else { 38705 return stringValue; 38706 } 38707 } 38708 } 38709} 38710/** 38711 * Get the value for a attribute on a node. Only used in DEV for SSR validation. 38712 * The third argument is used as a hint of what the expected value is. Some 38713 * attributes have multiple equivalent values. 38714 */ 38715 38716function getValueForAttribute(node, name, expected) { 38717 { 38718 if (!isAttributeNameSafe(name)) { 38719 return; 38720 } 38721 38722 if (!node.hasAttribute(name)) { 38723 return expected === undefined ? undefined : null; 38724 } 38725 38726 var value = node.getAttribute(name); 38727 38728 if (value === '' + expected) { 38729 return expected; 38730 } 38731 38732 return value; 38733 } 38734} 38735/** 38736 * Sets the value for a property on a node. 38737 * 38738 * @param {DOMElement} node 38739 * @param {string} name 38740 * @param {*} value 38741 */ 38742 38743function setValueForProperty(node, name, value, isCustomComponentTag) { 38744 var propertyInfo = getPropertyInfo(name); 38745 38746 if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) { 38747 return; 38748 } 38749 38750 if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) { 38751 value = null; 38752 } // If the prop isn't in the special list, treat it as a simple attribute. 38753 38754 38755 if (isCustomComponentTag || propertyInfo === null) { 38756 if (isAttributeNameSafe(name)) { 38757 var _attributeName = name; 38758 38759 if (value === null) { 38760 node.removeAttribute(_attributeName); 38761 } else { 38762 node.setAttribute(_attributeName, '' + value); 38763 } 38764 } 38765 38766 return; 38767 } 38768 38769 var mustUseProperty = propertyInfo.mustUseProperty; 38770 38771 if (mustUseProperty) { 38772 var propertyName = propertyInfo.propertyName; 38773 38774 if (value === null) { 38775 var type = propertyInfo.type; 38776 node[propertyName] = type === BOOLEAN ? false : ''; 38777 } else { 38778 // Contrary to `setAttribute`, object properties are properly 38779 // `toString`ed by IE8/9. 38780 node[propertyName] = value; 38781 } 38782 38783 return; 38784 } // The rest are treated as attributes with special cases. 38785 38786 38787 var attributeName = propertyInfo.attributeName, 38788 attributeNamespace = propertyInfo.attributeNamespace; 38789 38790 if (value === null) { 38791 node.removeAttribute(attributeName); 38792 } else { 38793 var _type = propertyInfo.type; 38794 var attributeValue; 38795 38796 if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) { 38797 // If attribute type is boolean, we know for sure it won't be an execution sink 38798 // and we won't require Trusted Type here. 38799 attributeValue = ''; 38800 } else { 38801 // `setAttribute` with objects becomes only `[object]` in IE8/9, 38802 // ('' + value) makes it output the correct toString()-value. 38803 { 38804 attributeValue = '' + value; 38805 } 38806 38807 if (propertyInfo.sanitizeURL) { 38808 sanitizeURL(attributeValue.toString()); 38809 } 38810 } 38811 38812 if (attributeNamespace) { 38813 node.setAttributeNS(attributeNamespace, attributeName, attributeValue); 38814 } else { 38815 node.setAttribute(attributeName, attributeValue); 38816 } 38817 } 38818} 38819 38820var BEFORE_SLASH_RE = /^(.*)[\\\/]/; 38821function describeComponentFrame (name, source, ownerName) { 38822 var sourceInfo = ''; 38823 38824 if (source) { 38825 var path = source.fileName; 38826 var fileName = path.replace(BEFORE_SLASH_RE, ''); 38827 38828 { 38829 // In DEV, include code for a common special case: 38830 // prefer "folder/index.js" instead of just "index.js". 38831 if (/^index\./.test(fileName)) { 38832 var match = path.match(BEFORE_SLASH_RE); 38833 38834 if (match) { 38835 var pathBeforeSlash = match[1]; 38836 38837 if (pathBeforeSlash) { 38838 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ''); 38839 fileName = folderName + '/' + fileName; 38840 } 38841 } 38842 } 38843 } 38844 38845 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')'; 38846 } else if (ownerName) { 38847 sourceInfo = ' (created by ' + ownerName + ')'; 38848 } 38849 38850 return '\n in ' + (name || 'Unknown') + sourceInfo; 38851} 38852 38853// The Symbol used to tag the ReactElement-like types. If there is no native Symbol 38854// nor polyfill, then a plain number is used for performance. 38855var hasSymbol = typeof Symbol === 'function' && Symbol.for; 38856var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; 38857var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; 38858var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; 38859var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; 38860var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; 38861var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; 38862var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary 38863var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; 38864var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; 38865var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; 38866var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; 38867var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; 38868var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; 38869var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; 38870var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 38871var FAUX_ITERATOR_SYMBOL = '@@iterator'; 38872function getIteratorFn(maybeIterable) { 38873 if (maybeIterable === null || typeof maybeIterable !== 'object') { 38874 return null; 38875 } 38876 38877 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 38878 38879 if (typeof maybeIterator === 'function') { 38880 return maybeIterator; 38881 } 38882 38883 return null; 38884} 38885 38886var Uninitialized = -1; 38887var Pending = 0; 38888var Resolved = 1; 38889var Rejected = 2; 38890function refineResolvedLazyComponent(lazyComponent) { 38891 return lazyComponent._status === Resolved ? lazyComponent._result : null; 38892} 38893function initializeLazyComponentType(lazyComponent) { 38894 if (lazyComponent._status === Uninitialized) { 38895 lazyComponent._status = Pending; 38896 var ctor = lazyComponent._ctor; 38897 var thenable = ctor(); 38898 lazyComponent._result = thenable; 38899 thenable.then(function (moduleObject) { 38900 if (lazyComponent._status === Pending) { 38901 var defaultExport = moduleObject.default; 38902 38903 { 38904 if (defaultExport === undefined) { 38905 error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject); 38906 } 38907 } 38908 38909 lazyComponent._status = Resolved; 38910 lazyComponent._result = defaultExport; 38911 } 38912 }, function (error) { 38913 if (lazyComponent._status === Pending) { 38914 lazyComponent._status = Rejected; 38915 lazyComponent._result = error; 38916 } 38917 }); 38918 } 38919} 38920 38921function getWrappedName(outerType, innerType, wrapperName) { 38922 var functionName = innerType.displayName || innerType.name || ''; 38923 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); 38924} 38925 38926function getComponentName(type) { 38927 if (type == null) { 38928 // Host root, text node or just invalid type. 38929 return null; 38930 } 38931 38932 { 38933 if (typeof type.tag === 'number') { 38934 error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); 38935 } 38936 } 38937 38938 if (typeof type === 'function') { 38939 return type.displayName || type.name || null; 38940 } 38941 38942 if (typeof type === 'string') { 38943 return type; 38944 } 38945 38946 switch (type) { 38947 case REACT_FRAGMENT_TYPE: 38948 return 'Fragment'; 38949 38950 case REACT_PORTAL_TYPE: 38951 return 'Portal'; 38952 38953 case REACT_PROFILER_TYPE: 38954 return "Profiler"; 38955 38956 case REACT_STRICT_MODE_TYPE: 38957 return 'StrictMode'; 38958 38959 case REACT_SUSPENSE_TYPE: 38960 return 'Suspense'; 38961 38962 case REACT_SUSPENSE_LIST_TYPE: 38963 return 'SuspenseList'; 38964 } 38965 38966 if (typeof type === 'object') { 38967 switch (type.$$typeof) { 38968 case REACT_CONTEXT_TYPE: 38969 return 'Context.Consumer'; 38970 38971 case REACT_PROVIDER_TYPE: 38972 return 'Context.Provider'; 38973 38974 case REACT_FORWARD_REF_TYPE: 38975 return getWrappedName(type, type.render, 'ForwardRef'); 38976 38977 case REACT_MEMO_TYPE: 38978 return getComponentName(type.type); 38979 38980 case REACT_BLOCK_TYPE: 38981 return getComponentName(type.render); 38982 38983 case REACT_LAZY_TYPE: 38984 { 38985 var thenable = type; 38986 var resolvedThenable = refineResolvedLazyComponent(thenable); 38987 38988 if (resolvedThenable) { 38989 return getComponentName(resolvedThenable); 38990 } 38991 38992 break; 38993 } 38994 } 38995 } 38996 38997 return null; 38998} 38999 39000var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; 39001 39002function describeFiber(fiber) { 39003 switch (fiber.tag) { 39004 case HostRoot: 39005 case HostPortal: 39006 case HostText: 39007 case Fragment: 39008 case ContextProvider: 39009 case ContextConsumer: 39010 return ''; 39011 39012 default: 39013 var owner = fiber._debugOwner; 39014 var source = fiber._debugSource; 39015 var name = getComponentName(fiber.type); 39016 var ownerName = null; 39017 39018 if (owner) { 39019 ownerName = getComponentName(owner.type); 39020 } 39021 39022 return describeComponentFrame(name, source, ownerName); 39023 } 39024} 39025 39026function getStackByFiberInDevAndProd(workInProgress) { 39027 var info = ''; 39028 var node = workInProgress; 39029 39030 do { 39031 info += describeFiber(node); 39032 node = node.return; 39033 } while (node); 39034 39035 return info; 39036} 39037var current = null; 39038var isRendering = false; 39039function getCurrentFiberOwnerNameInDevOrNull() { 39040 { 39041 if (current === null) { 39042 return null; 39043 } 39044 39045 var owner = current._debugOwner; 39046 39047 if (owner !== null && typeof owner !== 'undefined') { 39048 return getComponentName(owner.type); 39049 } 39050 } 39051 39052 return null; 39053} 39054function getCurrentFiberStackInDev() { 39055 { 39056 if (current === null) { 39057 return ''; 39058 } // Safe because if current fiber exists, we are reconciling, 39059 // and it is guaranteed to be the work-in-progress version. 39060 39061 39062 return getStackByFiberInDevAndProd(current); 39063 } 39064} 39065function resetCurrentFiber() { 39066 { 39067 ReactDebugCurrentFrame$1.getCurrentStack = null; 39068 current = null; 39069 isRendering = false; 39070 } 39071} 39072function setCurrentFiber(fiber) { 39073 { 39074 ReactDebugCurrentFrame$1.getCurrentStack = getCurrentFiberStackInDev; 39075 current = fiber; 39076 isRendering = false; 39077 } 39078} 39079function setIsRendering(rendering) { 39080 { 39081 isRendering = rendering; 39082 } 39083} 39084 39085// Flow does not allow string concatenation of most non-string types. To work 39086// around this limitation, we use an opaque type that can only be obtained by 39087// passing the value through getToStringValue first. 39088function toString(value) { 39089 return '' + value; 39090} 39091function getToStringValue(value) { 39092 switch (typeof value) { 39093 case 'boolean': 39094 case 'number': 39095 case 'object': 39096 case 'string': 39097 case 'undefined': 39098 return value; 39099 39100 default: 39101 // function, symbol are assigned as empty strings 39102 return ''; 39103 } 39104} 39105 39106var ReactDebugCurrentFrame$2 = null; 39107var ReactControlledValuePropTypes = { 39108 checkPropTypes: null 39109}; 39110 39111{ 39112 ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame; 39113 var hasReadOnlyValue = { 39114 button: true, 39115 checkbox: true, 39116 image: true, 39117 hidden: true, 39118 radio: true, 39119 reset: true, 39120 submit: true 39121 }; 39122 var propTypes = { 39123 value: function (props, propName, componentName) { 39124 if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null || enableDeprecatedFlareAPI ) { 39125 return null; 39126 } 39127 39128 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`.'); 39129 }, 39130 checked: function (props, propName, componentName) { 39131 if (props.onChange || props.readOnly || props.disabled || props[propName] == null || enableDeprecatedFlareAPI ) { 39132 return null; 39133 } 39134 39135 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`.'); 39136 } 39137 }; 39138 /** 39139 * Provide a linked `value` attribute for controlled forms. You should not use 39140 * this outside of the ReactDOM controlled form components. 39141 */ 39142 39143 ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) { 39144 checkPropTypes(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$2.getStackAddendum); 39145 }; 39146} 39147 39148function isCheckable(elem) { 39149 var type = elem.type; 39150 var nodeName = elem.nodeName; 39151 return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); 39152} 39153 39154function getTracker(node) { 39155 return node._valueTracker; 39156} 39157 39158function detachTracker(node) { 39159 node._valueTracker = null; 39160} 39161 39162function getValueFromNode(node) { 39163 var value = ''; 39164 39165 if (!node) { 39166 return value; 39167 } 39168 39169 if (isCheckable(node)) { 39170 value = node.checked ? 'true' : 'false'; 39171 } else { 39172 value = node.value; 39173 } 39174 39175 return value; 39176} 39177 39178function trackValueOnNode(node) { 39179 var valueField = isCheckable(node) ? 'checked' : 'value'; 39180 var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); 39181 var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail 39182 // and don't track value will cause over reporting of changes, 39183 // but it's better then a hard failure 39184 // (needed for certain tests that spyOn input values and Safari) 39185 39186 if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { 39187 return; 39188 } 39189 39190 var get = descriptor.get, 39191 set = descriptor.set; 39192 Object.defineProperty(node, valueField, { 39193 configurable: true, 39194 get: function () { 39195 return get.call(this); 39196 }, 39197 set: function (value) { 39198 currentValue = '' + value; 39199 set.call(this, value); 39200 } 39201 }); // We could've passed this the first time 39202 // but it triggers a bug in IE11 and Edge 14/15. 39203 // Calling defineProperty() again should be equivalent. 39204 // https://github.com/facebook/react/issues/11768 39205 39206 Object.defineProperty(node, valueField, { 39207 enumerable: descriptor.enumerable 39208 }); 39209 var tracker = { 39210 getValue: function () { 39211 return currentValue; 39212 }, 39213 setValue: function (value) { 39214 currentValue = '' + value; 39215 }, 39216 stopTracking: function () { 39217 detachTracker(node); 39218 delete node[valueField]; 39219 } 39220 }; 39221 return tracker; 39222} 39223 39224function track(node) { 39225 if (getTracker(node)) { 39226 return; 39227 } // TODO: Once it's just Fiber we can move this to node._wrapperState 39228 39229 39230 node._valueTracker = trackValueOnNode(node); 39231} 39232function updateValueIfChanged(node) { 39233 if (!node) { 39234 return false; 39235 } 39236 39237 var tracker = getTracker(node); // if there is no tracker at this point it's unlikely 39238 // that trying again will succeed 39239 39240 if (!tracker) { 39241 return true; 39242 } 39243 39244 var lastValue = tracker.getValue(); 39245 var nextValue = getValueFromNode(node); 39246 39247 if (nextValue !== lastValue) { 39248 tracker.setValue(nextValue); 39249 return true; 39250 } 39251 39252 return false; 39253} 39254 39255var didWarnValueDefaultValue = false; 39256var didWarnCheckedDefaultChecked = false; 39257var didWarnControlledToUncontrolled = false; 39258var didWarnUncontrolledToControlled = false; 39259 39260function isControlled(props) { 39261 var usesChecked = props.type === 'checkbox' || props.type === 'radio'; 39262 return usesChecked ? props.checked != null : props.value != null; 39263} 39264/** 39265 * Implements an <input> host component that allows setting these optional 39266 * props: `checked`, `value`, `defaultChecked`, and `defaultValue`. 39267 * 39268 * If `checked` or `value` are not supplied (or null/undefined), user actions 39269 * that affect the checked state or value will trigger updates to the element. 39270 * 39271 * If they are supplied (and not null/undefined), the rendered element will not 39272 * trigger updates to the element. Instead, the props must change in order for 39273 * the rendered element to be updated. 39274 * 39275 * The rendered element will be initialized as unchecked (or `defaultChecked`) 39276 * with an empty value (or `defaultValue`). 39277 * 39278 * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html 39279 */ 39280 39281 39282function getHostProps(element, props) { 39283 var node = element; 39284 var checked = props.checked; 39285 39286 var hostProps = _assign({}, props, { 39287 defaultChecked: undefined, 39288 defaultValue: undefined, 39289 value: undefined, 39290 checked: checked != null ? checked : node._wrapperState.initialChecked 39291 }); 39292 39293 return hostProps; 39294} 39295function initWrapperState(element, props) { 39296 { 39297 ReactControlledValuePropTypes.checkPropTypes('input', props); 39298 39299 if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { 39300 error('%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', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); 39301 39302 didWarnCheckedDefaultChecked = true; 39303 } 39304 39305 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { 39306 error('%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', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); 39307 39308 didWarnValueDefaultValue = true; 39309 } 39310 } 39311 39312 var node = element; 39313 var defaultValue = props.defaultValue == null ? '' : props.defaultValue; 39314 node._wrapperState = { 39315 initialChecked: props.checked != null ? props.checked : props.defaultChecked, 39316 initialValue: getToStringValue(props.value != null ? props.value : defaultValue), 39317 controlled: isControlled(props) 39318 }; 39319} 39320function updateChecked(element, props) { 39321 var node = element; 39322 var checked = props.checked; 39323 39324 if (checked != null) { 39325 setValueForProperty(node, 'checked', checked, false); 39326 } 39327} 39328function updateWrapper(element, props) { 39329 var node = element; 39330 39331 { 39332 var controlled = isControlled(props); 39333 39334 if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) { 39335 error('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', props.type); 39336 39337 didWarnUncontrolledToControlled = true; 39338 } 39339 39340 if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) { 39341 error('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', props.type); 39342 39343 didWarnControlledToUncontrolled = true; 39344 } 39345 } 39346 39347 updateChecked(element, props); 39348 var value = getToStringValue(props.value); 39349 var type = props.type; 39350 39351 if (value != null) { 39352 if (type === 'number') { 39353 if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible. 39354 // eslint-disable-next-line 39355 node.value != value) { 39356 node.value = toString(value); 39357 } 39358 } else if (node.value !== toString(value)) { 39359 node.value = toString(value); 39360 } 39361 } else if (type === 'submit' || type === 'reset') { 39362 // Submit/reset inputs need the attribute removed completely to avoid 39363 // blank-text buttons. 39364 node.removeAttribute('value'); 39365 return; 39366 } 39367 39368 { 39369 // When syncing the value attribute, the value comes from a cascade of 39370 // properties: 39371 // 1. The value React property 39372 // 2. The defaultValue React property 39373 // 3. Otherwise there should be no change 39374 if (props.hasOwnProperty('value')) { 39375 setDefaultValue(node, props.type, value); 39376 } else if (props.hasOwnProperty('defaultValue')) { 39377 setDefaultValue(node, props.type, getToStringValue(props.defaultValue)); 39378 } 39379 } 39380 39381 { 39382 // When syncing the checked attribute, it only changes when it needs 39383 // to be removed, such as transitioning from a checkbox into a text input 39384 if (props.checked == null && props.defaultChecked != null) { 39385 node.defaultChecked = !!props.defaultChecked; 39386 } 39387 } 39388} 39389function postMountWrapper(element, props, isHydrating) { 39390 var node = element; // Do not assign value if it is already set. This prevents user text input 39391 // from being lost during SSR hydration. 39392 39393 if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) { 39394 var type = props.type; 39395 var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the 39396 // default value provided by the browser. See: #12872 39397 39398 if (isButton && (props.value === undefined || props.value === null)) { 39399 return; 39400 } 39401 39402 var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input 39403 // from being lost during SSR hydration. 39404 39405 if (!isHydrating) { 39406 { 39407 // When syncing the value attribute, the value property should use 39408 // the wrapperState._initialValue property. This uses: 39409 // 39410 // 1. The value React property when present 39411 // 2. The defaultValue React property when present 39412 // 3. An empty string 39413 if (initialValue !== node.value) { 39414 node.value = initialValue; 39415 } 39416 } 39417 } 39418 39419 { 39420 // Otherwise, the value attribute is synchronized to the property, 39421 // so we assign defaultValue to the same thing as the value property 39422 // assignment step above. 39423 node.defaultValue = initialValue; 39424 } 39425 } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug 39426 // this is needed to work around a chrome bug where setting defaultChecked 39427 // will sometimes influence the value of checked (even after detachment). 39428 // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 39429 // We need to temporarily unset name to avoid disrupting radio button groups. 39430 39431 39432 var name = node.name; 39433 39434 if (name !== '') { 39435 node.name = ''; 39436 } 39437 39438 { 39439 // When syncing the checked attribute, both the checked property and 39440 // attribute are assigned at the same time using defaultChecked. This uses: 39441 // 39442 // 1. The checked React property when present 39443 // 2. The defaultChecked React property when present 39444 // 3. Otherwise, false 39445 node.defaultChecked = !node.defaultChecked; 39446 node.defaultChecked = !!node._wrapperState.initialChecked; 39447 } 39448 39449 if (name !== '') { 39450 node.name = name; 39451 } 39452} 39453function restoreControlledState(element, props) { 39454 var node = element; 39455 updateWrapper(node, props); 39456 updateNamedCousins(node, props); 39457} 39458 39459function updateNamedCousins(rootNode, props) { 39460 var name = props.name; 39461 39462 if (props.type === 'radio' && name != null) { 39463 var queryRoot = rootNode; 39464 39465 while (queryRoot.parentNode) { 39466 queryRoot = queryRoot.parentNode; 39467 } // If `rootNode.form` was non-null, then we could try `form.elements`, 39468 // but that sometimes behaves strangely in IE8. We could also try using 39469 // `form.getElementsByName`, but that will only return direct children 39470 // and won't include inputs that use the HTML5 `form=` attribute. Since 39471 // the input might not even be in a form. It might not even be in the 39472 // document. Let's just use the local `querySelectorAll` to ensure we don't 39473 // miss anything. 39474 39475 39476 var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); 39477 39478 for (var i = 0; i < group.length; i++) { 39479 var otherNode = group[i]; 39480 39481 if (otherNode === rootNode || otherNode.form !== rootNode.form) { 39482 continue; 39483 } // This will throw if radio buttons rendered by different copies of React 39484 // and the same name are rendered into the same form (same as #1939). 39485 // That's probably okay; we don't support it just as we don't support 39486 // mixing React radio buttons with non-React ones. 39487 39488 39489 var otherProps = getFiberCurrentPropsFromNode$1(otherNode); 39490 39491 if (!otherProps) { 39492 { 39493 throw Error( "ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported." ); 39494 } 39495 } // We need update the tracked value on the named cousin since the value 39496 // was changed but the input saw no event or value set 39497 39498 39499 updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that 39500 // was previously checked to update will cause it to be come re-checked 39501 // as appropriate. 39502 39503 updateWrapper(otherNode, otherProps); 39504 } 39505 } 39506} // In Chrome, assigning defaultValue to certain input types triggers input validation. 39507// For number inputs, the display value loses trailing decimal points. For email inputs, 39508// Chrome raises "The specified value <x> is not a valid email address". 39509// 39510// Here we check to see if the defaultValue has actually changed, avoiding these problems 39511// when the user is inputting text 39512// 39513// https://github.com/facebook/react/issues/7253 39514 39515 39516function setDefaultValue(node, type, value) { 39517 if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js 39518 type !== 'number' || node.ownerDocument.activeElement !== node) { 39519 if (value == null) { 39520 node.defaultValue = toString(node._wrapperState.initialValue); 39521 } else if (node.defaultValue !== toString(value)) { 39522 node.defaultValue = toString(value); 39523 } 39524 } 39525} 39526 39527var didWarnSelectedSetOnOption = false; 39528var didWarnInvalidChild = false; 39529 39530function flattenChildren(children) { 39531 var content = ''; // Flatten children. We'll warn if they are invalid 39532 // during validateProps() which runs for hydration too. 39533 // Note that this would throw on non-element objects. 39534 // Elements are stringified (which is normally irrelevant 39535 // but matters for <fbt>). 39536 39537 React.Children.forEach(children, function (child) { 39538 if (child == null) { 39539 return; 39540 } 39541 39542 content += child; // Note: we don't warn about invalid children here. 39543 // Instead, this is done separately below so that 39544 // it happens during the hydration codepath too. 39545 }); 39546 return content; 39547} 39548/** 39549 * Implements an <option> host component that warns when `selected` is set. 39550 */ 39551 39552 39553function validateProps(element, props) { 39554 { 39555 // This mirrors the codepath above, but runs for hydration too. 39556 // Warn about invalid children here so that client and hydration are consistent. 39557 // TODO: this seems like it could cause a DEV-only throw for hydration 39558 // if children contains a non-element object. We should try to avoid that. 39559 if (typeof props.children === 'object' && props.children !== null) { 39560 React.Children.forEach(props.children, function (child) { 39561 if (child == null) { 39562 return; 39563 } 39564 39565 if (typeof child === 'string' || typeof child === 'number') { 39566 return; 39567 } 39568 39569 if (typeof child.type !== 'string') { 39570 return; 39571 } 39572 39573 if (!didWarnInvalidChild) { 39574 didWarnInvalidChild = true; 39575 39576 error('Only strings and numbers are supported as <option> children.'); 39577 } 39578 }); 39579 } // TODO: Remove support for `selected` in <option>. 39580 39581 39582 if (props.selected != null && !didWarnSelectedSetOnOption) { 39583 error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.'); 39584 39585 didWarnSelectedSetOnOption = true; 39586 } 39587 } 39588} 39589function postMountWrapper$1(element, props) { 39590 // value="" should make a value attribute (#6219) 39591 if (props.value != null) { 39592 element.setAttribute('value', toString(getToStringValue(props.value))); 39593 } 39594} 39595function getHostProps$1(element, props) { 39596 var hostProps = _assign({ 39597 children: undefined 39598 }, props); 39599 39600 var content = flattenChildren(props.children); 39601 39602 if (content) { 39603 hostProps.children = content; 39604 } 39605 39606 return hostProps; 39607} 39608 39609var didWarnValueDefaultValue$1; 39610 39611{ 39612 didWarnValueDefaultValue$1 = false; 39613} 39614 39615function getDeclarationErrorAddendum() { 39616 var ownerName = getCurrentFiberOwnerNameInDevOrNull(); 39617 39618 if (ownerName) { 39619 return '\n\nCheck the render method of `' + ownerName + '`.'; 39620 } 39621 39622 return ''; 39623} 39624 39625var valuePropNames = ['value', 'defaultValue']; 39626/** 39627 * Validation function for `value` and `defaultValue`. 39628 */ 39629 39630function checkSelectPropTypes(props) { 39631 { 39632 ReactControlledValuePropTypes.checkPropTypes('select', props); 39633 39634 for (var i = 0; i < valuePropNames.length; i++) { 39635 var propName = valuePropNames[i]; 39636 39637 if (props[propName] == null) { 39638 continue; 39639 } 39640 39641 var isArray = Array.isArray(props[propName]); 39642 39643 if (props.multiple && !isArray) { 39644 error('The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum()); 39645 } else if (!props.multiple && isArray) { 39646 error('The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum()); 39647 } 39648 } 39649 } 39650} 39651 39652function updateOptions(node, multiple, propValue, setDefaultSelected) { 39653 var options = node.options; 39654 39655 if (multiple) { 39656 var selectedValues = propValue; 39657 var selectedValue = {}; 39658 39659 for (var i = 0; i < selectedValues.length; i++) { 39660 // Prefix to avoid chaos with special keys. 39661 selectedValue['$' + selectedValues[i]] = true; 39662 } 39663 39664 for (var _i = 0; _i < options.length; _i++) { 39665 var selected = selectedValue.hasOwnProperty('$' + options[_i].value); 39666 39667 if (options[_i].selected !== selected) { 39668 options[_i].selected = selected; 39669 } 39670 39671 if (selected && setDefaultSelected) { 39672 options[_i].defaultSelected = true; 39673 } 39674 } 39675 } else { 39676 // Do not set `select.value` as exact behavior isn't consistent across all 39677 // browsers for all cases. 39678 var _selectedValue = toString(getToStringValue(propValue)); 39679 39680 var defaultSelected = null; 39681 39682 for (var _i2 = 0; _i2 < options.length; _i2++) { 39683 if (options[_i2].value === _selectedValue) { 39684 options[_i2].selected = true; 39685 39686 if (setDefaultSelected) { 39687 options[_i2].defaultSelected = true; 39688 } 39689 39690 return; 39691 } 39692 39693 if (defaultSelected === null && !options[_i2].disabled) { 39694 defaultSelected = options[_i2]; 39695 } 39696 } 39697 39698 if (defaultSelected !== null) { 39699 defaultSelected.selected = true; 39700 } 39701 } 39702} 39703/** 39704 * Implements a <select> host component that allows optionally setting the 39705 * props `value` and `defaultValue`. If `multiple` is false, the prop must be a 39706 * stringable. If `multiple` is true, the prop must be an array of stringables. 39707 * 39708 * If `value` is not supplied (or null/undefined), user actions that change the 39709 * selected option will trigger updates to the rendered options. 39710 * 39711 * If it is supplied (and not null/undefined), the rendered options will not 39712 * update in response to user actions. Instead, the `value` prop must change in 39713 * order for the rendered options to update. 39714 * 39715 * If `defaultValue` is provided, any options with the supplied values will be 39716 * selected. 39717 */ 39718 39719 39720function getHostProps$2(element, props) { 39721 return _assign({}, props, { 39722 value: undefined 39723 }); 39724} 39725function initWrapperState$1(element, props) { 39726 var node = element; 39727 39728 { 39729 checkSelectPropTypes(props); 39730 } 39731 39732 node._wrapperState = { 39733 wasMultiple: !!props.multiple 39734 }; 39735 39736 { 39737 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) { 39738 error('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'); 39739 39740 didWarnValueDefaultValue$1 = true; 39741 } 39742 } 39743} 39744function postMountWrapper$2(element, props) { 39745 var node = element; 39746 node.multiple = !!props.multiple; 39747 var value = props.value; 39748 39749 if (value != null) { 39750 updateOptions(node, !!props.multiple, value, false); 39751 } else if (props.defaultValue != null) { 39752 updateOptions(node, !!props.multiple, props.defaultValue, true); 39753 } 39754} 39755function postUpdateWrapper(element, props) { 39756 var node = element; 39757 var wasMultiple = node._wrapperState.wasMultiple; 39758 node._wrapperState.wasMultiple = !!props.multiple; 39759 var value = props.value; 39760 39761 if (value != null) { 39762 updateOptions(node, !!props.multiple, value, false); 39763 } else if (wasMultiple !== !!props.multiple) { 39764 // For simplicity, reapply `defaultValue` if `multiple` is toggled. 39765 if (props.defaultValue != null) { 39766 updateOptions(node, !!props.multiple, props.defaultValue, true); 39767 } else { 39768 // Revert the select back to its default unselected state. 39769 updateOptions(node, !!props.multiple, props.multiple ? [] : '', false); 39770 } 39771 } 39772} 39773function restoreControlledState$1(element, props) { 39774 var node = element; 39775 var value = props.value; 39776 39777 if (value != null) { 39778 updateOptions(node, !!props.multiple, value, false); 39779 } 39780} 39781 39782var didWarnValDefaultVal = false; 39783 39784/** 39785 * Implements a <textarea> host component that allows setting `value`, and 39786 * `defaultValue`. This differs from the traditional DOM API because value is 39787 * usually set as PCDATA children. 39788 * 39789 * If `value` is not supplied (or null/undefined), user actions that affect the 39790 * value will trigger updates to the element. 39791 * 39792 * If `value` is supplied (and not null/undefined), the rendered element will 39793 * not trigger updates to the element. Instead, the `value` prop must change in 39794 * order for the rendered element to be updated. 39795 * 39796 * The rendered element will be initialized with an empty value, the prop 39797 * `defaultValue` if specified, or the children content (deprecated). 39798 */ 39799function getHostProps$3(element, props) { 39800 var node = element; 39801 39802 if (!(props.dangerouslySetInnerHTML == null)) { 39803 { 39804 throw Error( "`dangerouslySetInnerHTML` does not make sense on <textarea>." ); 39805 } 39806 } // Always set children to the same thing. In IE9, the selection range will 39807 // get reset if `textContent` is mutated. We could add a check in setTextContent 39808 // to only set the value if/when the value differs from the node value (which would 39809 // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this 39810 // solution. The value can be a boolean or object so that's why it's forced 39811 // to be a string. 39812 39813 39814 var hostProps = _assign({}, props, { 39815 value: undefined, 39816 defaultValue: undefined, 39817 children: toString(node._wrapperState.initialValue) 39818 }); 39819 39820 return hostProps; 39821} 39822function initWrapperState$2(element, props) { 39823 var node = element; 39824 39825 { 39826 ReactControlledValuePropTypes.checkPropTypes('textarea', props); 39827 39828 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) { 39829 error('%s contains a textarea with both value and defaultValue props. ' + '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', getCurrentFiberOwnerNameInDevOrNull() || 'A component'); 39830 39831 didWarnValDefaultVal = true; 39832 } 39833 } 39834 39835 var initialValue = props.value; // Only bother fetching default value if we're going to use it 39836 39837 if (initialValue == null) { 39838 var children = props.children, 39839 defaultValue = props.defaultValue; 39840 39841 if (children != null) { 39842 { 39843 error('Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.'); 39844 } 39845 39846 { 39847 if (!(defaultValue == null)) { 39848 { 39849 throw Error( "If you supply `defaultValue` on a <textarea>, do not pass children." ); 39850 } 39851 } 39852 39853 if (Array.isArray(children)) { 39854 if (!(children.length <= 1)) { 39855 { 39856 throw Error( "<textarea> can only have at most one child." ); 39857 } 39858 } 39859 39860 children = children[0]; 39861 } 39862 39863 defaultValue = children; 39864 } 39865 } 39866 39867 if (defaultValue == null) { 39868 defaultValue = ''; 39869 } 39870 39871 initialValue = defaultValue; 39872 } 39873 39874 node._wrapperState = { 39875 initialValue: getToStringValue(initialValue) 39876 }; 39877} 39878function updateWrapper$1(element, props) { 39879 var node = element; 39880 var value = getToStringValue(props.value); 39881 var defaultValue = getToStringValue(props.defaultValue); 39882 39883 if (value != null) { 39884 // Cast `value` to a string to ensure the value is set correctly. While 39885 // browsers typically do this as necessary, jsdom doesn't. 39886 var newValue = toString(value); // To avoid side effects (such as losing text selection), only set value if changed 39887 39888 if (newValue !== node.value) { 39889 node.value = newValue; 39890 } 39891 39892 if (props.defaultValue == null && node.defaultValue !== newValue) { 39893 node.defaultValue = newValue; 39894 } 39895 } 39896 39897 if (defaultValue != null) { 39898 node.defaultValue = toString(defaultValue); 39899 } 39900} 39901function postMountWrapper$3(element, props) { 39902 var node = element; // This is in postMount because we need access to the DOM node, which is not 39903 // available until after the component has mounted. 39904 39905 var textContent = node.textContent; // Only set node.value if textContent is equal to the expected 39906 // initial value. In IE10/IE11 there is a bug where the placeholder attribute 39907 // will populate textContent as well. 39908 // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/ 39909 39910 if (textContent === node._wrapperState.initialValue) { 39911 if (textContent !== '' && textContent !== null) { 39912 node.value = textContent; 39913 } 39914 } 39915} 39916function restoreControlledState$2(element, props) { 39917 // DOM component is still mounted; update 39918 updateWrapper$1(element, props); 39919} 39920 39921var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; 39922var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; 39923var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; 39924var Namespaces = { 39925 html: HTML_NAMESPACE, 39926 mathml: MATH_NAMESPACE, 39927 svg: SVG_NAMESPACE 39928}; // Assumes there is no parent namespace. 39929 39930function getIntrinsicNamespace(type) { 39931 switch (type) { 39932 case 'svg': 39933 return SVG_NAMESPACE; 39934 39935 case 'math': 39936 return MATH_NAMESPACE; 39937 39938 default: 39939 return HTML_NAMESPACE; 39940 } 39941} 39942function getChildNamespace(parentNamespace, type) { 39943 if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) { 39944 // No (or default) parent namespace: potential entry point. 39945 return getIntrinsicNamespace(type); 39946 } 39947 39948 if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') { 39949 // We're leaving SVG. 39950 return HTML_NAMESPACE; 39951 } // By default, pass namespace below. 39952 39953 39954 return parentNamespace; 39955} 39956 39957/* globals MSApp */ 39958 39959/** 39960 * Create a function which has 'unsafe' privileges (required by windows8 apps) 39961 */ 39962var createMicrosoftUnsafeLocalFunction = function (func) { 39963 if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) { 39964 return function (arg0, arg1, arg2, arg3) { 39965 MSApp.execUnsafeLocalFunction(function () { 39966 return func(arg0, arg1, arg2, arg3); 39967 }); 39968 }; 39969 } else { 39970 return func; 39971 } 39972}; 39973 39974var reusableSVGContainer; 39975/** 39976 * Set the innerHTML property of a node 39977 * 39978 * @param {DOMElement} node 39979 * @param {string} html 39980 * @internal 39981 */ 39982 39983var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) { 39984 if (node.namespaceURI === Namespaces.svg) { 39985 39986 if (!('innerHTML' in node)) { 39987 // IE does not have innerHTML for SVG nodes, so instead we inject the 39988 // new markup in a temp node and then move the child nodes across into 39989 // the target node 39990 reusableSVGContainer = reusableSVGContainer || document.createElement('div'); 39991 reusableSVGContainer.innerHTML = '<svg>' + html.valueOf().toString() + '</svg>'; 39992 var svgNode = reusableSVGContainer.firstChild; 39993 39994 while (node.firstChild) { 39995 node.removeChild(node.firstChild); 39996 } 39997 39998 while (svgNode.firstChild) { 39999 node.appendChild(svgNode.firstChild); 40000 } 40001 40002 return; 40003 } 40004 } 40005 40006 node.innerHTML = html; 40007}); 40008 40009/** 40010 * HTML nodeType values that represent the type of the node 40011 */ 40012var ELEMENT_NODE = 1; 40013var TEXT_NODE = 3; 40014var COMMENT_NODE = 8; 40015var DOCUMENT_NODE = 9; 40016var DOCUMENT_FRAGMENT_NODE = 11; 40017 40018/** 40019 * Set the textContent property of a node. For text updates, it's faster 40020 * to set the `nodeValue` of the Text node directly instead of using 40021 * `.textContent` which will remove the existing node and create a new one. 40022 * 40023 * @param {DOMElement} node 40024 * @param {string} text 40025 * @internal 40026 */ 40027 40028var setTextContent = function (node, text) { 40029 if (text) { 40030 var firstChild = node.firstChild; 40031 40032 if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) { 40033 firstChild.nodeValue = text; 40034 return; 40035 } 40036 } 40037 40038 node.textContent = text; 40039}; 40040 40041// Do not use the below two methods directly! 40042// Instead use constants exported from DOMTopLevelEventTypes in ReactDOM. 40043// (It is the only module that is allowed to access these methods.) 40044function unsafeCastStringToDOMTopLevelType(topLevelType) { 40045 return topLevelType; 40046} 40047function unsafeCastDOMTopLevelTypeToString(topLevelType) { 40048 return topLevelType; 40049} 40050 40051/** 40052 * Generate a mapping of standard vendor prefixes using the defined style property and event name. 40053 * 40054 * @param {string} styleProp 40055 * @param {string} eventName 40056 * @returns {object} 40057 */ 40058 40059function makePrefixMap(styleProp, eventName) { 40060 var prefixes = {}; 40061 prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); 40062 prefixes['Webkit' + styleProp] = 'webkit' + eventName; 40063 prefixes['Moz' + styleProp] = 'moz' + eventName; 40064 return prefixes; 40065} 40066/** 40067 * A list of event names to a configurable list of vendor prefixes. 40068 */ 40069 40070 40071var vendorPrefixes = { 40072 animationend: makePrefixMap('Animation', 'AnimationEnd'), 40073 animationiteration: makePrefixMap('Animation', 'AnimationIteration'), 40074 animationstart: makePrefixMap('Animation', 'AnimationStart'), 40075 transitionend: makePrefixMap('Transition', 'TransitionEnd') 40076}; 40077/** 40078 * Event names that have already been detected and prefixed (if applicable). 40079 */ 40080 40081var prefixedEventNames = {}; 40082/** 40083 * Element to check for prefixes on. 40084 */ 40085 40086var style = {}; 40087/** 40088 * Bootstrap if a DOM exists. 40089 */ 40090 40091if (canUseDOM) { 40092 style = document.createElement('div').style; // On some platforms, in particular some releases of Android 4.x, 40093 // the un-prefixed "animation" and "transition" properties are defined on the 40094 // style object but the events that fire will still be prefixed, so we need 40095 // to check if the un-prefixed events are usable, and if not remove them from the map. 40096 40097 if (!('AnimationEvent' in window)) { 40098 delete vendorPrefixes.animationend.animation; 40099 delete vendorPrefixes.animationiteration.animation; 40100 delete vendorPrefixes.animationstart.animation; 40101 } // Same as above 40102 40103 40104 if (!('TransitionEvent' in window)) { 40105 delete vendorPrefixes.transitionend.transition; 40106 } 40107} 40108/** 40109 * Attempts to determine the correct vendor prefixed event name. 40110 * 40111 * @param {string} eventName 40112 * @returns {string} 40113 */ 40114 40115 40116function getVendorPrefixedEventName(eventName) { 40117 if (prefixedEventNames[eventName]) { 40118 return prefixedEventNames[eventName]; 40119 } else if (!vendorPrefixes[eventName]) { 40120 return eventName; 40121 } 40122 40123 var prefixMap = vendorPrefixes[eventName]; 40124 40125 for (var styleProp in prefixMap) { 40126 if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { 40127 return prefixedEventNames[eventName] = prefixMap[styleProp]; 40128 } 40129 } 40130 40131 return eventName; 40132} 40133 40134/** 40135 * To identify top level events in ReactDOM, we use constants defined by this 40136 * module. This is the only module that uses the unsafe* methods to express 40137 * that the constants actually correspond to the browser event names. This lets 40138 * us save some bundle size by avoiding a top level type -> event name map. 40139 * The rest of ReactDOM code should import top level types from this file. 40140 */ 40141 40142var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort'); 40143var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend')); 40144var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration')); 40145var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart')); 40146var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur'); 40147var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay'); 40148var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough'); 40149var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel'); 40150var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change'); 40151var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click'); 40152var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close'); 40153var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend'); 40154var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart'); 40155var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate'); 40156var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu'); 40157var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy'); 40158var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut'); 40159var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick'); 40160var TOP_AUX_CLICK = unsafeCastStringToDOMTopLevelType('auxclick'); 40161var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag'); 40162var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend'); 40163var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter'); 40164var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit'); 40165var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave'); 40166var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover'); 40167var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart'); 40168var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop'); 40169var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange'); 40170var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied'); 40171var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted'); 40172var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended'); 40173var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error'); 40174var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus'); 40175var TOP_GOT_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('gotpointercapture'); 40176var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input'); 40177var TOP_INVALID = unsafeCastStringToDOMTopLevelType('invalid'); 40178var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown'); 40179var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress'); 40180var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup'); 40181var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load'); 40182var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart'); 40183var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata'); 40184var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata'); 40185var TOP_LOST_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('lostpointercapture'); 40186var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown'); 40187var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove'); 40188var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout'); 40189var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover'); 40190var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup'); 40191var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste'); 40192var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause'); 40193var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play'); 40194var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing'); 40195var TOP_POINTER_CANCEL = unsafeCastStringToDOMTopLevelType('pointercancel'); 40196var TOP_POINTER_DOWN = unsafeCastStringToDOMTopLevelType('pointerdown'); 40197var TOP_POINTER_MOVE = unsafeCastStringToDOMTopLevelType('pointermove'); 40198var TOP_POINTER_OUT = unsafeCastStringToDOMTopLevelType('pointerout'); 40199var TOP_POINTER_OVER = unsafeCastStringToDOMTopLevelType('pointerover'); 40200var TOP_POINTER_UP = unsafeCastStringToDOMTopLevelType('pointerup'); 40201var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress'); 40202var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange'); 40203var TOP_RESET = unsafeCastStringToDOMTopLevelType('reset'); 40204var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll'); 40205var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked'); 40206var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking'); 40207var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange'); 40208var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled'); 40209var TOP_SUBMIT = unsafeCastStringToDOMTopLevelType('submit'); 40210var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend'); 40211var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput'); 40212var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate'); 40213var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle'); 40214var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel'); 40215var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend'); 40216var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove'); 40217var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart'); 40218var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend')); 40219var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange'); 40220var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting'); 40221var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel'); // List of events that need to be individually attached to media elements. 40222// Note that events in this list will *not* be listened to at the top level 40223// unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`. 40224 40225var 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]; 40226function getRawEventName(topLevelType) { 40227 return unsafeCastDOMTopLevelTypeToString(topLevelType); 40228} 40229 40230var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; // prettier-ignore 40231 40232var elementListenerMap = new PossiblyWeakMap(); 40233function getListenerMapForElement(element) { 40234 var listenerMap = elementListenerMap.get(element); 40235 40236 if (listenerMap === undefined) { 40237 listenerMap = new Map(); 40238 elementListenerMap.set(element, listenerMap); 40239 } 40240 40241 return listenerMap; 40242} 40243 40244/** 40245 * `ReactInstanceMap` maintains a mapping from a public facing stateful 40246 * instance (key) and the internal representation (value). This allows public 40247 * methods to accept the user facing instance as an argument and map them back 40248 * to internal methods. 40249 * 40250 * Note that this module is currently shared and assumed to be stateless. 40251 * If this becomes an actual Map, that will break. 40252 */ 40253function get(key) { 40254 return key._reactInternalFiber; 40255} 40256function has(key) { 40257 return key._reactInternalFiber !== undefined; 40258} 40259function set(key, value) { 40260 key._reactInternalFiber = value; 40261} 40262 40263// Don't change these two values. They're used by React Dev Tools. 40264var NoEffect = 40265/* */ 402660; 40267var PerformedWork = 40268/* */ 402691; // You can change the rest (and add more). 40270 40271var Placement = 40272/* */ 402732; 40274var Update = 40275/* */ 402764; 40277var PlacementAndUpdate = 40278/* */ 402796; 40280var Deletion = 40281/* */ 402828; 40283var ContentReset = 40284/* */ 4028516; 40286var Callback = 40287/* */ 4028832; 40289var DidCapture = 40290/* */ 4029164; 40292var Ref = 40293/* */ 40294128; 40295var Snapshot = 40296/* */ 40297256; 40298var Passive = 40299/* */ 40300512; 40301var Hydrating = 40302/* */ 403031024; 40304var HydratingAndUpdate = 40305/* */ 403061028; // Passive & Update & Callback & Ref & Snapshot 40307 40308var LifecycleEffectMask = 40309/* */ 40310932; // Union of all host effects 40311 40312var HostEffectMask = 40313/* */ 403142047; 40315var Incomplete = 40316/* */ 403172048; 40318var ShouldCapture = 40319/* */ 403204096; 40321 40322var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; 40323function getNearestMountedFiber(fiber) { 40324 var node = fiber; 40325 var nearestMounted = fiber; 40326 40327 if (!fiber.alternate) { 40328 // If there is no alternate, this might be a new tree that isn't inserted 40329 // yet. If it is, then it will have a pending insertion effect on it. 40330 var nextNode = node; 40331 40332 do { 40333 node = nextNode; 40334 40335 if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) { 40336 // This is an insertion or in-progress hydration. The nearest possible 40337 // mounted fiber is the parent but we need to continue to figure out 40338 // if that one is still mounted. 40339 nearestMounted = node.return; 40340 } 40341 40342 nextNode = node.return; 40343 } while (nextNode); 40344 } else { 40345 while (node.return) { 40346 node = node.return; 40347 } 40348 } 40349 40350 if (node.tag === HostRoot) { 40351 // TODO: Check if this was a nested HostRoot when used with 40352 // renderContainerIntoSubtree. 40353 return nearestMounted; 40354 } // If we didn't hit the root, that means that we're in an disconnected tree 40355 // that has been unmounted. 40356 40357 40358 return null; 40359} 40360function getSuspenseInstanceFromFiber(fiber) { 40361 if (fiber.tag === SuspenseComponent) { 40362 var suspenseState = fiber.memoizedState; 40363 40364 if (suspenseState === null) { 40365 var current = fiber.alternate; 40366 40367 if (current !== null) { 40368 suspenseState = current.memoizedState; 40369 } 40370 } 40371 40372 if (suspenseState !== null) { 40373 return suspenseState.dehydrated; 40374 } 40375 } 40376 40377 return null; 40378} 40379function getContainerFromFiber(fiber) { 40380 return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null; 40381} 40382function isFiberMounted(fiber) { 40383 return getNearestMountedFiber(fiber) === fiber; 40384} 40385function isMounted(component) { 40386 { 40387 var owner = ReactCurrentOwner.current; 40388 40389 if (owner !== null && owner.tag === ClassComponent) { 40390 var ownerFiber = owner; 40391 var instance = ownerFiber.stateNode; 40392 40393 if (!instance._warnedAboutRefsInRender) { 40394 error('%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.type) || 'A component'); 40395 } 40396 40397 instance._warnedAboutRefsInRender = true; 40398 } 40399 } 40400 40401 var fiber = get(component); 40402 40403 if (!fiber) { 40404 return false; 40405 } 40406 40407 return getNearestMountedFiber(fiber) === fiber; 40408} 40409 40410function assertIsMounted(fiber) { 40411 if (!(getNearestMountedFiber(fiber) === fiber)) { 40412 { 40413 throw Error( "Unable to find node on an unmounted component." ); 40414 } 40415 } 40416} 40417 40418function findCurrentFiberUsingSlowPath(fiber) { 40419 var alternate = fiber.alternate; 40420 40421 if (!alternate) { 40422 // If there is no alternate, then we only need to check if it is mounted. 40423 var nearestMounted = getNearestMountedFiber(fiber); 40424 40425 if (!(nearestMounted !== null)) { 40426 { 40427 throw Error( "Unable to find node on an unmounted component." ); 40428 } 40429 } 40430 40431 if (nearestMounted !== fiber) { 40432 return null; 40433 } 40434 40435 return fiber; 40436 } // If we have two possible branches, we'll walk backwards up to the root 40437 // to see what path the root points to. On the way we may hit one of the 40438 // special cases and we'll deal with them. 40439 40440 40441 var a = fiber; 40442 var b = alternate; 40443 40444 while (true) { 40445 var parentA = a.return; 40446 40447 if (parentA === null) { 40448 // We're at the root. 40449 break; 40450 } 40451 40452 var parentB = parentA.alternate; 40453 40454 if (parentB === null) { 40455 // There is no alternate. This is an unusual case. Currently, it only 40456 // happens when a Suspense component is hidden. An extra fragment fiber 40457 // is inserted in between the Suspense fiber and its children. Skip 40458 // over this extra fragment fiber and proceed to the next parent. 40459 var nextParent = parentA.return; 40460 40461 if (nextParent !== null) { 40462 a = b = nextParent; 40463 continue; 40464 } // If there's no parent, we're at the root. 40465 40466 40467 break; 40468 } // If both copies of the parent fiber point to the same child, we can 40469 // assume that the child is current. This happens when we bailout on low 40470 // priority: the bailed out fiber's child reuses the current child. 40471 40472 40473 if (parentA.child === parentB.child) { 40474 var child = parentA.child; 40475 40476 while (child) { 40477 if (child === a) { 40478 // We've determined that A is the current branch. 40479 assertIsMounted(parentA); 40480 return fiber; 40481 } 40482 40483 if (child === b) { 40484 // We've determined that B is the current branch. 40485 assertIsMounted(parentA); 40486 return alternate; 40487 } 40488 40489 child = child.sibling; 40490 } // We should never have an alternate for any mounting node. So the only 40491 // way this could possibly happen is if this was unmounted, if at all. 40492 40493 40494 { 40495 { 40496 throw Error( "Unable to find node on an unmounted component." ); 40497 } 40498 } 40499 } 40500 40501 if (a.return !== b.return) { 40502 // The return pointer of A and the return pointer of B point to different 40503 // fibers. We assume that return pointers never criss-cross, so A must 40504 // belong to the child set of A.return, and B must belong to the child 40505 // set of B.return. 40506 a = parentA; 40507 b = parentB; 40508 } else { 40509 // The return pointers point to the same fiber. We'll have to use the 40510 // default, slow path: scan the child sets of each parent alternate to see 40511 // which child belongs to which set. 40512 // 40513 // Search parent A's child set 40514 var didFindChild = false; 40515 var _child = parentA.child; 40516 40517 while (_child) { 40518 if (_child === a) { 40519 didFindChild = true; 40520 a = parentA; 40521 b = parentB; 40522 break; 40523 } 40524 40525 if (_child === b) { 40526 didFindChild = true; 40527 b = parentA; 40528 a = parentB; 40529 break; 40530 } 40531 40532 _child = _child.sibling; 40533 } 40534 40535 if (!didFindChild) { 40536 // Search parent B's child set 40537 _child = parentB.child; 40538 40539 while (_child) { 40540 if (_child === a) { 40541 didFindChild = true; 40542 a = parentB; 40543 b = parentA; 40544 break; 40545 } 40546 40547 if (_child === b) { 40548 didFindChild = true; 40549 b = parentB; 40550 a = parentA; 40551 break; 40552 } 40553 40554 _child = _child.sibling; 40555 } 40556 40557 if (!didFindChild) { 40558 { 40559 throw Error( "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." ); 40560 } 40561 } 40562 } 40563 } 40564 40565 if (!(a.alternate === b)) { 40566 { 40567 throw Error( "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); 40568 } 40569 } 40570 } // If the root is not a host container, we're in a disconnected tree. I.e. 40571 // unmounted. 40572 40573 40574 if (!(a.tag === HostRoot)) { 40575 { 40576 throw Error( "Unable to find node on an unmounted component." ); 40577 } 40578 } 40579 40580 if (a.stateNode.current === a) { 40581 // We've determined that A is the current branch. 40582 return fiber; 40583 } // Otherwise B has to be current branch. 40584 40585 40586 return alternate; 40587} 40588function findCurrentHostFiber(parent) { 40589 var currentParent = findCurrentFiberUsingSlowPath(parent); 40590 40591 if (!currentParent) { 40592 return null; 40593 } // Next we'll drill down this component to find the first HostComponent/Text. 40594 40595 40596 var node = currentParent; 40597 40598 while (true) { 40599 if (node.tag === HostComponent || node.tag === HostText) { 40600 return node; 40601 } else if (node.child) { 40602 node.child.return = node; 40603 node = node.child; 40604 continue; 40605 } 40606 40607 if (node === currentParent) { 40608 return null; 40609 } 40610 40611 while (!node.sibling) { 40612 if (!node.return || node.return === currentParent) { 40613 return null; 40614 } 40615 40616 node = node.return; 40617 } 40618 40619 node.sibling.return = node.return; 40620 node = node.sibling; 40621 } // Flow needs the return null here, but ESLint complains about it. 40622 // eslint-disable-next-line no-unreachable 40623 40624 40625 return null; 40626} 40627function findCurrentHostFiberWithNoPortals(parent) { 40628 var currentParent = findCurrentFiberUsingSlowPath(parent); 40629 40630 if (!currentParent) { 40631 return null; 40632 } // Next we'll drill down this component to find the first HostComponent/Text. 40633 40634 40635 var node = currentParent; 40636 40637 while (true) { 40638 if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI ) { 40639 return node; 40640 } else if (node.child && node.tag !== HostPortal) { 40641 node.child.return = node; 40642 node = node.child; 40643 continue; 40644 } 40645 40646 if (node === currentParent) { 40647 return null; 40648 } 40649 40650 while (!node.sibling) { 40651 if (!node.return || node.return === currentParent) { 40652 return null; 40653 } 40654 40655 node = node.return; 40656 } 40657 40658 node.sibling.return = node.return; 40659 node = node.sibling; 40660 } // Flow needs the return null here, but ESLint complains about it. 40661 // eslint-disable-next-line no-unreachable 40662 40663 40664 return null; 40665} 40666 40667/** 40668 * Accumulates items that must not be null or undefined into the first one. This 40669 * is used to conserve memory by avoiding array allocations, and thus sacrifices 40670 * API cleanness. Since `current` can be null before being passed in and not 40671 * null after this function, make sure to assign it back to `current`: 40672 * 40673 * `a = accumulateInto(a, b);` 40674 * 40675 * This API should be sparingly used. Try `accumulate` for something cleaner. 40676 * 40677 * @return {*|array<*>} An accumulation of items. 40678 */ 40679 40680function accumulateInto(current, next) { 40681 if (!(next != null)) { 40682 { 40683 throw Error( "accumulateInto(...): Accumulated items must not be null or undefined." ); 40684 } 40685 } 40686 40687 if (current == null) { 40688 return next; 40689 } // Both are not empty. Warning: Never call x.concat(y) when you are not 40690 // certain that x is an Array (x could be a string with concat method). 40691 40692 40693 if (Array.isArray(current)) { 40694 if (Array.isArray(next)) { 40695 current.push.apply(current, next); 40696 return current; 40697 } 40698 40699 current.push(next); 40700 return current; 40701 } 40702 40703 if (Array.isArray(next)) { 40704 // A bit too dangerous to mutate `next`. 40705 return [current].concat(next); 40706 } 40707 40708 return [current, next]; 40709} 40710 40711/** 40712 * @param {array} arr an "accumulation" of items which is either an Array or 40713 * a single item. Useful when paired with the `accumulate` module. This is a 40714 * simple utility that allows us to reason about a collection of items, but 40715 * handling the case when there is exactly one item (and we do not need to 40716 * allocate an array). 40717 * @param {function} cb Callback invoked with each element or a collection. 40718 * @param {?} [scope] Scope used as `this` in a callback. 40719 */ 40720function forEachAccumulated(arr, cb, scope) { 40721 if (Array.isArray(arr)) { 40722 arr.forEach(cb, scope); 40723 } else if (arr) { 40724 cb.call(scope, arr); 40725 } 40726} 40727 40728/** 40729 * Internal queue of events that have accumulated their dispatches and are 40730 * waiting to have their dispatches executed. 40731 */ 40732 40733var eventQueue = null; 40734/** 40735 * Dispatches an event and releases it back into the pool, unless persistent. 40736 * 40737 * @param {?object} event Synthetic event to be dispatched. 40738 * @private 40739 */ 40740 40741var executeDispatchesAndRelease = function (event) { 40742 if (event) { 40743 executeDispatchesInOrder(event); 40744 40745 if (!event.isPersistent()) { 40746 event.constructor.release(event); 40747 } 40748 } 40749}; 40750 40751var executeDispatchesAndReleaseTopLevel = function (e) { 40752 return executeDispatchesAndRelease(e); 40753}; 40754 40755function runEventsInBatch(events) { 40756 if (events !== null) { 40757 eventQueue = accumulateInto(eventQueue, events); 40758 } // Set `eventQueue` to null before processing it so that we can tell if more 40759 // events get enqueued while processing. 40760 40761 40762 var processingEventQueue = eventQueue; 40763 eventQueue = null; 40764 40765 if (!processingEventQueue) { 40766 return; 40767 } 40768 40769 forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); 40770 40771 if (!!eventQueue) { 40772 { 40773 throw Error( "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ); 40774 } 40775 } // This would be a good time to rethrow if any of the event handlers threw. 40776 40777 40778 rethrowCaughtError(); 40779} 40780 40781/** 40782 * Gets the target node from a native browser event by accounting for 40783 * inconsistencies in browser DOM APIs. 40784 * 40785 * @param {object} nativeEvent Native browser event. 40786 * @return {DOMEventTarget} Target node. 40787 */ 40788 40789function getEventTarget(nativeEvent) { 40790 // Fallback to nativeEvent.srcElement for IE9 40791 // https://github.com/facebook/react/issues/12506 40792 var target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963 40793 40794 if (target.correspondingUseElement) { 40795 target = target.correspondingUseElement; 40796 } // Safari may fire events on text nodes (Node.TEXT_NODE is 3). 40797 // @see http://www.quirksmode.org/js/events_properties.html 40798 40799 40800 return target.nodeType === TEXT_NODE ? target.parentNode : target; 40801} 40802 40803/** 40804 * Checks if an event is supported in the current execution environment. 40805 * 40806 * NOTE: This will not work correctly for non-generic events such as `change`, 40807 * `reset`, `load`, `error`, and `select`. 40808 * 40809 * Borrows from Modernizr. 40810 * 40811 * @param {string} eventNameSuffix Event name, e.g. "click". 40812 * @return {boolean} True if the event is supported. 40813 * @internal 40814 * @license Modernizr 3.0.0pre (Custom Build) | MIT 40815 */ 40816 40817function isEventSupported(eventNameSuffix) { 40818 if (!canUseDOM) { 40819 return false; 40820 } 40821 40822 var eventName = 'on' + eventNameSuffix; 40823 var isSupported = eventName in document; 40824 40825 if (!isSupported) { 40826 var element = document.createElement('div'); 40827 element.setAttribute(eventName, 'return;'); 40828 isSupported = typeof element[eventName] === 'function'; 40829 } 40830 40831 return isSupported; 40832} 40833 40834/** 40835 * Summary of `DOMEventPluginSystem` event handling: 40836 * 40837 * - Top-level delegation is used to trap most native browser events. This 40838 * may only occur in the main thread and is the responsibility of 40839 * ReactDOMEventListener, which is injected and can therefore support 40840 * pluggable event sources. This is the only work that occurs in the main 40841 * thread. 40842 * 40843 * - We normalize and de-duplicate events to account for browser quirks. This 40844 * may be done in the worker thread. 40845 * 40846 * - Forward these native events (with the associated top-level type used to 40847 * trap it) to `EventPluginRegistry`, which in turn will ask plugins if they want 40848 * to extract any synthetic events. 40849 * 40850 * - The `EventPluginRegistry` will then process each event by annotating them with 40851 * "dispatches", a sequence of listeners and IDs that care about that event. 40852 * 40853 * - The `EventPluginRegistry` then dispatches the events. 40854 * 40855 * Overview of React and the event system: 40856 * 40857 * +------------+ . 40858 * | DOM | . 40859 * +------------+ . 40860 * | . 40861 * v . 40862 * +------------+ . 40863 * | ReactEvent | . 40864 * | Listener | . 40865 * +------------+ . +-----------+ 40866 * | . +--------+|SimpleEvent| 40867 * | . | |Plugin | 40868 * +-----|------+ . v +-----------+ 40869 * | | | . +--------------+ +------------+ 40870 * | +-----------.--->|PluginRegistry| | Event | 40871 * | | . | | +-----------+ | Propagators| 40872 * | ReactEvent | . | | |TapEvent | |------------| 40873 * | Emitter | . | |<---+|Plugin | |other plugin| 40874 * | | . | | +-----------+ | utilities | 40875 * | +-----------.--->| | +------------+ 40876 * | | | . +--------------+ 40877 * +-----|------+ . ^ +-----------+ 40878 * | . | |Enter/Leave| 40879 * + . +-------+|Plugin | 40880 * +-------------+ . +-----------+ 40881 * | application | . 40882 * |-------------| . 40883 * | | . 40884 * | | . 40885 * +-------------+ . 40886 * . 40887 * React Core . General Purpose Event Plugin System 40888 */ 40889 40890var CALLBACK_BOOKKEEPING_POOL_SIZE = 10; 40891var callbackBookkeepingPool = []; 40892 40893function releaseTopLevelCallbackBookKeeping(instance) { 40894 instance.topLevelType = null; 40895 instance.nativeEvent = null; 40896 instance.targetInst = null; 40897 instance.ancestors.length = 0; 40898 40899 if (callbackBookkeepingPool.length < CALLBACK_BOOKKEEPING_POOL_SIZE) { 40900 callbackBookkeepingPool.push(instance); 40901 } 40902} // Used to store ancestor hierarchy in top level callback 40903 40904 40905function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags) { 40906 if (callbackBookkeepingPool.length) { 40907 var instance = callbackBookkeepingPool.pop(); 40908 instance.topLevelType = topLevelType; 40909 instance.eventSystemFlags = eventSystemFlags; 40910 instance.nativeEvent = nativeEvent; 40911 instance.targetInst = targetInst; 40912 return instance; 40913 } 40914 40915 return { 40916 topLevelType: topLevelType, 40917 eventSystemFlags: eventSystemFlags, 40918 nativeEvent: nativeEvent, 40919 targetInst: targetInst, 40920 ancestors: [] 40921 }; 40922} 40923/** 40924 * Find the deepest React component completely containing the root of the 40925 * passed-in instance (for use when entire React trees are nested within each 40926 * other). If React trees are not nested, returns null. 40927 */ 40928 40929 40930function findRootContainerNode(inst) { 40931 if (inst.tag === HostRoot) { 40932 return inst.stateNode.containerInfo; 40933 } // TODO: It may be a good idea to cache this to prevent unnecessary DOM 40934 // traversal, but caching is difficult to do correctly without using a 40935 // mutation observer to listen for all DOM changes. 40936 40937 40938 while (inst.return) { 40939 inst = inst.return; 40940 } 40941 40942 if (inst.tag !== HostRoot) { 40943 // This can happen if we're in a detached tree. 40944 return null; 40945 } 40946 40947 return inst.stateNode.containerInfo; 40948} 40949/** 40950 * Allows registered plugins an opportunity to extract events from top-level 40951 * native browser events. 40952 * 40953 * @return {*} An accumulation of synthetic events. 40954 * @internal 40955 */ 40956 40957 40958function extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { 40959 var events = null; 40960 40961 for (var i = 0; i < plugins.length; i++) { 40962 // Not every plugin in the ordering may be loaded at runtime. 40963 var possiblePlugin = plugins[i]; 40964 40965 if (possiblePlugin) { 40966 var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); 40967 40968 if (extractedEvents) { 40969 events = accumulateInto(events, extractedEvents); 40970 } 40971 } 40972 } 40973 40974 return events; 40975} 40976 40977function runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { 40978 var events = extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); 40979 runEventsInBatch(events); 40980} 40981 40982function handleTopLevel(bookKeeping) { 40983 var targetInst = bookKeeping.targetInst; // Loop through the hierarchy, in case there's any nested components. 40984 // It's important that we build the array of ancestors before calling any 40985 // event handlers, because event handlers can modify the DOM, leading to 40986 // inconsistencies with ReactMount's node cache. See #1105. 40987 40988 var ancestor = targetInst; 40989 40990 do { 40991 if (!ancestor) { 40992 var ancestors = bookKeeping.ancestors; 40993 ancestors.push(ancestor); 40994 break; 40995 } 40996 40997 var root = findRootContainerNode(ancestor); 40998 40999 if (!root) { 41000 break; 41001 } 41002 41003 var tag = ancestor.tag; 41004 41005 if (tag === HostComponent || tag === HostText) { 41006 bookKeeping.ancestors.push(ancestor); 41007 } 41008 41009 ancestor = getClosestInstanceFromNode(root); 41010 } while (ancestor); 41011 41012 for (var i = 0; i < bookKeeping.ancestors.length; i++) { 41013 targetInst = bookKeeping.ancestors[i]; 41014 var eventTarget = getEventTarget(bookKeeping.nativeEvent); 41015 var topLevelType = bookKeeping.topLevelType; 41016 var nativeEvent = bookKeeping.nativeEvent; 41017 var eventSystemFlags = bookKeeping.eventSystemFlags; // If this is the first ancestor, we mark it on the system flags 41018 41019 if (i === 0) { 41020 eventSystemFlags |= IS_FIRST_ANCESTOR; 41021 } 41022 41023 runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, eventTarget, eventSystemFlags); 41024 } 41025} 41026 41027function dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst) { 41028 var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags); 41029 41030 try { 41031 // Event queue being processed in the same cycle allows 41032 // `preventDefault`. 41033 batchedEventUpdates(handleTopLevel, bookKeeping); 41034 } finally { 41035 releaseTopLevelCallbackBookKeeping(bookKeeping); 41036 } 41037} 41038/** 41039 * We listen for bubbled touch events on the document object. 41040 * 41041 * Firefox v8.01 (and possibly others) exhibited strange behavior when 41042 * mounting `onmousemove` events at some node that was not the document 41043 * element. The symptoms were that if your mouse is not moving over something 41044 * contained within that mount point (for example on the background) the 41045 * top-level listeners for `onmousemove` won't be called. However, if you 41046 * register the `mousemove` on the document object, then it will of course 41047 * catch all `mousemove`s. This along with iOS quirks, justifies restricting 41048 * top-level listeners to the document object only, at least for these 41049 * movement types of events and possibly all events. 41050 * 41051 * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html 41052 * 41053 * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but 41054 * they bubble to document. 41055 * 41056 * @param {string} registrationName Name of listener (e.g. `onClick`). 41057 * @param {object} mountAt Container where to mount the listener 41058 */ 41059 41060function legacyListenToEvent(registrationName, mountAt) { 41061 var listenerMap = getListenerMapForElement(mountAt); 41062 var dependencies = registrationNameDependencies[registrationName]; 41063 41064 for (var i = 0; i < dependencies.length; i++) { 41065 var dependency = dependencies[i]; 41066 legacyListenToTopLevelEvent(dependency, mountAt, listenerMap); 41067 } 41068} 41069function legacyListenToTopLevelEvent(topLevelType, mountAt, listenerMap) { 41070 if (!listenerMap.has(topLevelType)) { 41071 switch (topLevelType) { 41072 case TOP_SCROLL: 41073 trapCapturedEvent(TOP_SCROLL, mountAt); 41074 break; 41075 41076 case TOP_FOCUS: 41077 case TOP_BLUR: 41078 trapCapturedEvent(TOP_FOCUS, mountAt); 41079 trapCapturedEvent(TOP_BLUR, mountAt); // We set the flag for a single dependency later in this function, 41080 // but this ensures we mark both as attached rather than just one. 41081 41082 listenerMap.set(TOP_BLUR, null); 41083 listenerMap.set(TOP_FOCUS, null); 41084 break; 41085 41086 case TOP_CANCEL: 41087 case TOP_CLOSE: 41088 if (isEventSupported(getRawEventName(topLevelType))) { 41089 trapCapturedEvent(topLevelType, mountAt); 41090 } 41091 41092 break; 41093 41094 case TOP_INVALID: 41095 case TOP_SUBMIT: 41096 case TOP_RESET: 41097 // We listen to them on the target DOM elements. 41098 // Some of them bubble so we don't want them to fire twice. 41099 break; 41100 41101 default: 41102 // By default, listen on the top level to all non-media events. 41103 // Media events don't bubble so adding the listener wouldn't do anything. 41104 var isMediaEvent = mediaEventTypes.indexOf(topLevelType) !== -1; 41105 41106 if (!isMediaEvent) { 41107 trapBubbledEvent(topLevelType, mountAt); 41108 } 41109 41110 break; 41111 } 41112 41113 listenerMap.set(topLevelType, null); 41114 } 41115} 41116function isListeningToAllDependencies(registrationName, mountAt) { 41117 var listenerMap = getListenerMapForElement(mountAt); 41118 var dependencies = registrationNameDependencies[registrationName]; 41119 41120 for (var i = 0; i < dependencies.length; i++) { 41121 var dependency = dependencies[i]; 41122 41123 if (!listenerMap.has(dependency)) { 41124 return false; 41125 } 41126 } 41127 41128 return true; 41129} 41130 41131var attemptUserBlockingHydration; 41132function setAttemptUserBlockingHydration(fn) { 41133 attemptUserBlockingHydration = fn; 41134} 41135var attemptContinuousHydration; 41136function setAttemptContinuousHydration(fn) { 41137 attemptContinuousHydration = fn; 41138} 41139var attemptHydrationAtCurrentPriority; 41140function setAttemptHydrationAtCurrentPriority(fn) { 41141 attemptHydrationAtCurrentPriority = fn; 41142} // TODO: Upgrade this definition once we're on a newer version of Flow that 41143var hasScheduledReplayAttempt = false; // The queue of discrete events to be replayed. 41144 41145var queuedDiscreteEvents = []; // Indicates if any continuous event targets are non-null for early bailout. 41146// if the last target was dehydrated. 41147 41148var queuedFocus = null; 41149var queuedDrag = null; 41150var queuedMouse = null; // For pointer events there can be one latest event per pointerId. 41151 41152var queuedPointers = new Map(); 41153var queuedPointerCaptures = new Map(); // We could consider replaying selectionchange and touchmoves too. 41154 41155var queuedExplicitHydrationTargets = []; 41156function hasQueuedDiscreteEvents() { 41157 return queuedDiscreteEvents.length > 0; 41158} 41159var discreteReplayableEvents = [TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_TOUCH_START, TOP_AUX_CLICK, TOP_DOUBLE_CLICK, TOP_POINTER_CANCEL, TOP_POINTER_DOWN, TOP_POINTER_UP, TOP_DRAG_END, TOP_DRAG_START, TOP_DROP, TOP_COMPOSITION_END, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_INPUT, TOP_TEXT_INPUT, TOP_CLOSE, TOP_CANCEL, TOP_COPY, TOP_CUT, TOP_PASTE, TOP_CLICK, TOP_CHANGE, TOP_CONTEXT_MENU, TOP_RESET, TOP_SUBMIT]; 41160var continuousReplayableEvents = [TOP_FOCUS, TOP_BLUR, TOP_DRAG_ENTER, TOP_DRAG_LEAVE, TOP_MOUSE_OVER, TOP_MOUSE_OUT, TOP_POINTER_OVER, TOP_POINTER_OUT, TOP_GOT_POINTER_CAPTURE, TOP_LOST_POINTER_CAPTURE]; 41161function isReplayableDiscreteEvent(eventType) { 41162 return discreteReplayableEvents.indexOf(eventType) > -1; 41163} 41164 41165function trapReplayableEventForDocument(topLevelType, document, listenerMap) { 41166 legacyListenToTopLevelEvent(topLevelType, document, listenerMap); 41167} 41168 41169function eagerlyTrapReplayableEvents(container, document) { 41170 var listenerMapForDoc = getListenerMapForElement(document); // Discrete 41171 41172 discreteReplayableEvents.forEach(function (topLevelType) { 41173 trapReplayableEventForDocument(topLevelType, document, listenerMapForDoc); 41174 }); // Continuous 41175 41176 continuousReplayableEvents.forEach(function (topLevelType) { 41177 trapReplayableEventForDocument(topLevelType, document, listenerMapForDoc); 41178 }); 41179} 41180 41181function createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) { 41182 return { 41183 blockedOn: blockedOn, 41184 topLevelType: topLevelType, 41185 eventSystemFlags: eventSystemFlags | IS_REPLAYED, 41186 nativeEvent: nativeEvent, 41187 container: container 41188 }; 41189} 41190 41191function queueDiscreteEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) { 41192 var queuedEvent = createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent); 41193 queuedDiscreteEvents.push(queuedEvent); 41194} // Resets the replaying for this type of continuous event to no event. 41195 41196function clearIfContinuousEvent(topLevelType, nativeEvent) { 41197 switch (topLevelType) { 41198 case TOP_FOCUS: 41199 case TOP_BLUR: 41200 queuedFocus = null; 41201 break; 41202 41203 case TOP_DRAG_ENTER: 41204 case TOP_DRAG_LEAVE: 41205 queuedDrag = null; 41206 break; 41207 41208 case TOP_MOUSE_OVER: 41209 case TOP_MOUSE_OUT: 41210 queuedMouse = null; 41211 break; 41212 41213 case TOP_POINTER_OVER: 41214 case TOP_POINTER_OUT: 41215 { 41216 var pointerId = nativeEvent.pointerId; 41217 queuedPointers.delete(pointerId); 41218 break; 41219 } 41220 41221 case TOP_GOT_POINTER_CAPTURE: 41222 case TOP_LOST_POINTER_CAPTURE: 41223 { 41224 var _pointerId = nativeEvent.pointerId; 41225 queuedPointerCaptures.delete(_pointerId); 41226 break; 41227 } 41228 } 41229} 41230 41231function accumulateOrCreateContinuousQueuedReplayableEvent(existingQueuedEvent, blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) { 41232 if (existingQueuedEvent === null || existingQueuedEvent.nativeEvent !== nativeEvent) { 41233 var queuedEvent = createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent); 41234 41235 if (blockedOn !== null) { 41236 var _fiber2 = getInstanceFromNode$1(blockedOn); 41237 41238 if (_fiber2 !== null) { 41239 // Attempt to increase the priority of this target. 41240 attemptContinuousHydration(_fiber2); 41241 } 41242 } 41243 41244 return queuedEvent; 41245 } // If we have already queued this exact event, then it's because 41246 // the different event systems have different DOM event listeners. 41247 // We can accumulate the flags and store a single event to be 41248 // replayed. 41249 41250 41251 existingQueuedEvent.eventSystemFlags |= eventSystemFlags; 41252 return existingQueuedEvent; 41253} 41254 41255function queueIfContinuousEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) { 41256 // These set relatedTarget to null because the replayed event will be treated as if we 41257 // moved from outside the window (no target) onto the target once it hydrates. 41258 // Instead of mutating we could clone the event. 41259 switch (topLevelType) { 41260 case TOP_FOCUS: 41261 { 41262 var focusEvent = nativeEvent; 41263 queuedFocus = accumulateOrCreateContinuousQueuedReplayableEvent(queuedFocus, blockedOn, topLevelType, eventSystemFlags, container, focusEvent); 41264 return true; 41265 } 41266 41267 case TOP_DRAG_ENTER: 41268 { 41269 var dragEvent = nativeEvent; 41270 queuedDrag = accumulateOrCreateContinuousQueuedReplayableEvent(queuedDrag, blockedOn, topLevelType, eventSystemFlags, container, dragEvent); 41271 return true; 41272 } 41273 41274 case TOP_MOUSE_OVER: 41275 { 41276 var mouseEvent = nativeEvent; 41277 queuedMouse = accumulateOrCreateContinuousQueuedReplayableEvent(queuedMouse, blockedOn, topLevelType, eventSystemFlags, container, mouseEvent); 41278 return true; 41279 } 41280 41281 case TOP_POINTER_OVER: 41282 { 41283 var pointerEvent = nativeEvent; 41284 var pointerId = pointerEvent.pointerId; 41285 queuedPointers.set(pointerId, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointers.get(pointerId) || null, blockedOn, topLevelType, eventSystemFlags, container, pointerEvent)); 41286 return true; 41287 } 41288 41289 case TOP_GOT_POINTER_CAPTURE: 41290 { 41291 var _pointerEvent = nativeEvent; 41292 var _pointerId2 = _pointerEvent.pointerId; 41293 queuedPointerCaptures.set(_pointerId2, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointerCaptures.get(_pointerId2) || null, blockedOn, topLevelType, eventSystemFlags, container, _pointerEvent)); 41294 return true; 41295 } 41296 } 41297 41298 return false; 41299} // Check if this target is unblocked. Returns true if it's unblocked. 41300 41301function attemptExplicitHydrationTarget(queuedTarget) { 41302 // TODO: This function shares a lot of logic with attemptToDispatchEvent. 41303 // Try to unify them. It's a bit tricky since it would require two return 41304 // values. 41305 var targetInst = getClosestInstanceFromNode(queuedTarget.target); 41306 41307 if (targetInst !== null) { 41308 var nearestMounted = getNearestMountedFiber(targetInst); 41309 41310 if (nearestMounted !== null) { 41311 var tag = nearestMounted.tag; 41312 41313 if (tag === SuspenseComponent) { 41314 var instance = getSuspenseInstanceFromFiber(nearestMounted); 41315 41316 if (instance !== null) { 41317 // We're blocked on hydrating this boundary. 41318 // Increase its priority. 41319 queuedTarget.blockedOn = instance; 41320 Scheduler.unstable_runWithPriority(queuedTarget.priority, function () { 41321 attemptHydrationAtCurrentPriority(nearestMounted); 41322 }); 41323 return; 41324 } 41325 } else if (tag === HostRoot) { 41326 var root = nearestMounted.stateNode; 41327 41328 if (root.hydrate) { 41329 queuedTarget.blockedOn = getContainerFromFiber(nearestMounted); // We don't currently have a way to increase the priority of 41330 // a root other than sync. 41331 41332 return; 41333 } 41334 } 41335 } 41336 } 41337 41338 queuedTarget.blockedOn = null; 41339} 41340 41341function attemptReplayContinuousQueuedEvent(queuedEvent) { 41342 if (queuedEvent.blockedOn !== null) { 41343 return false; 41344 } 41345 41346 var nextBlockedOn = attemptToDispatchEvent(queuedEvent.topLevelType, queuedEvent.eventSystemFlags, queuedEvent.container, queuedEvent.nativeEvent); 41347 41348 if (nextBlockedOn !== null) { 41349 // We're still blocked. Try again later. 41350 var _fiber3 = getInstanceFromNode$1(nextBlockedOn); 41351 41352 if (_fiber3 !== null) { 41353 attemptContinuousHydration(_fiber3); 41354 } 41355 41356 queuedEvent.blockedOn = nextBlockedOn; 41357 return false; 41358 } 41359 41360 return true; 41361} 41362 41363function attemptReplayContinuousQueuedEventInMap(queuedEvent, key, map) { 41364 if (attemptReplayContinuousQueuedEvent(queuedEvent)) { 41365 map.delete(key); 41366 } 41367} 41368 41369function replayUnblockedEvents() { 41370 hasScheduledReplayAttempt = false; // First replay discrete events. 41371 41372 while (queuedDiscreteEvents.length > 0) { 41373 var nextDiscreteEvent = queuedDiscreteEvents[0]; 41374 41375 if (nextDiscreteEvent.blockedOn !== null) { 41376 // We're still blocked. 41377 // Increase the priority of this boundary to unblock 41378 // the next discrete event. 41379 var _fiber4 = getInstanceFromNode$1(nextDiscreteEvent.blockedOn); 41380 41381 if (_fiber4 !== null) { 41382 attemptUserBlockingHydration(_fiber4); 41383 } 41384 41385 break; 41386 } 41387 41388 var nextBlockedOn = attemptToDispatchEvent(nextDiscreteEvent.topLevelType, nextDiscreteEvent.eventSystemFlags, nextDiscreteEvent.container, nextDiscreteEvent.nativeEvent); 41389 41390 if (nextBlockedOn !== null) { 41391 // We're still blocked. Try again later. 41392 nextDiscreteEvent.blockedOn = nextBlockedOn; 41393 } else { 41394 // We've successfully replayed the first event. Let's try the next one. 41395 queuedDiscreteEvents.shift(); 41396 } 41397 } // Next replay any continuous events. 41398 41399 41400 if (queuedFocus !== null && attemptReplayContinuousQueuedEvent(queuedFocus)) { 41401 queuedFocus = null; 41402 } 41403 41404 if (queuedDrag !== null && attemptReplayContinuousQueuedEvent(queuedDrag)) { 41405 queuedDrag = null; 41406 } 41407 41408 if (queuedMouse !== null && attemptReplayContinuousQueuedEvent(queuedMouse)) { 41409 queuedMouse = null; 41410 } 41411 41412 queuedPointers.forEach(attemptReplayContinuousQueuedEventInMap); 41413 queuedPointerCaptures.forEach(attemptReplayContinuousQueuedEventInMap); 41414} 41415 41416function scheduleCallbackIfUnblocked(queuedEvent, unblocked) { 41417 if (queuedEvent.blockedOn === unblocked) { 41418 queuedEvent.blockedOn = null; 41419 41420 if (!hasScheduledReplayAttempt) { 41421 hasScheduledReplayAttempt = true; // Schedule a callback to attempt replaying as many events as are 41422 // now unblocked. This first might not actually be unblocked yet. 41423 // We could check it early to avoid scheduling an unnecessary callback. 41424 41425 Scheduler.unstable_scheduleCallback(Scheduler.unstable_NormalPriority, replayUnblockedEvents); 41426 } 41427 } 41428} 41429 41430function retryIfBlockedOn(unblocked) { 41431 // Mark anything that was blocked on this as no longer blocked 41432 // and eligible for a replay. 41433 if (queuedDiscreteEvents.length > 0) { 41434 scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked); // This is a exponential search for each boundary that commits. I think it's 41435 // worth it because we expect very few discrete events to queue up and once 41436 // we are actually fully unblocked it will be fast to replay them. 41437 41438 for (var i = 1; i < queuedDiscreteEvents.length; i++) { 41439 var queuedEvent = queuedDiscreteEvents[i]; 41440 41441 if (queuedEvent.blockedOn === unblocked) { 41442 queuedEvent.blockedOn = null; 41443 } 41444 } 41445 } 41446 41447 if (queuedFocus !== null) { 41448 scheduleCallbackIfUnblocked(queuedFocus, unblocked); 41449 } 41450 41451 if (queuedDrag !== null) { 41452 scheduleCallbackIfUnblocked(queuedDrag, unblocked); 41453 } 41454 41455 if (queuedMouse !== null) { 41456 scheduleCallbackIfUnblocked(queuedMouse, unblocked); 41457 } 41458 41459 var unblock = function (queuedEvent) { 41460 return scheduleCallbackIfUnblocked(queuedEvent, unblocked); 41461 }; 41462 41463 queuedPointers.forEach(unblock); 41464 queuedPointerCaptures.forEach(unblock); 41465 41466 for (var _i = 0; _i < queuedExplicitHydrationTargets.length; _i++) { 41467 var queuedTarget = queuedExplicitHydrationTargets[_i]; 41468 41469 if (queuedTarget.blockedOn === unblocked) { 41470 queuedTarget.blockedOn = null; 41471 } 41472 } 41473 41474 while (queuedExplicitHydrationTargets.length > 0) { 41475 var nextExplicitTarget = queuedExplicitHydrationTargets[0]; 41476 41477 if (nextExplicitTarget.blockedOn !== null) { 41478 // We're still blocked. 41479 break; 41480 } else { 41481 attemptExplicitHydrationTarget(nextExplicitTarget); 41482 41483 if (nextExplicitTarget.blockedOn === null) { 41484 // We're unblocked. 41485 queuedExplicitHydrationTargets.shift(); 41486 } 41487 } 41488 } 41489} 41490 41491function addEventBubbleListener(element, eventType, listener) { 41492 element.addEventListener(eventType, listener, false); 41493} 41494function addEventCaptureListener(element, eventType, listener) { 41495 element.addEventListener(eventType, listener, true); 41496} 41497 41498// do it in two places, which duplicates logic 41499// and increases the bundle size, we do it all 41500// here once. If we remove or refactor the 41501// SimpleEventPlugin, we should also remove or 41502// update the below line. 41503 41504var simpleEventPluginEventTypes = {}; 41505var topLevelEventsToDispatchConfig = new Map(); 41506var eventPriorities = new Map(); // We store most of the events in this module in pairs of two strings so we can re-use 41507// the code required to apply the same logic for event prioritization and that of the 41508// SimpleEventPlugin. This complicates things slightly, but the aim is to reduce code 41509// duplication (for which there would be quite a bit). For the events that are not needed 41510// for the SimpleEventPlugin (otherDiscreteEvents) we process them separately as an 41511// array of top level events. 41512// Lastly, we ignore prettier so we can keep the formatting sane. 41513// prettier-ignore 41514 41515var discreteEventPairsForSimpleEventPlugin = [TOP_BLUR, 'blur', TOP_CANCEL, 'cancel', TOP_CLICK, 'click', TOP_CLOSE, 'close', TOP_CONTEXT_MENU, 'contextMenu', TOP_COPY, 'copy', TOP_CUT, 'cut', TOP_AUX_CLICK, 'auxClick', 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']; 41516var otherDiscreteEvents = [TOP_CHANGE, TOP_SELECTION_CHANGE, TOP_TEXT_INPUT, TOP_COMPOSITION_START, TOP_COMPOSITION_END, TOP_COMPOSITION_UPDATE]; // prettier-ignore 41517 41518var userBlockingPairsForSimpleEventPlugin = [TOP_DRAG, 'drag', TOP_DRAG_ENTER, 'dragEnter', TOP_DRAG_EXIT, 'dragExit', TOP_DRAG_LEAVE, 'dragLeave', TOP_DRAG_OVER, 'dragOver', TOP_MOUSE_MOVE, 'mouseMove', TOP_MOUSE_OUT, 'mouseOut', TOP_MOUSE_OVER, 'mouseOver', TOP_POINTER_MOVE, 'pointerMove', TOP_POINTER_OUT, 'pointerOut', TOP_POINTER_OVER, 'pointerOver', TOP_SCROLL, 'scroll', TOP_TOGGLE, 'toggle', TOP_TOUCH_MOVE, 'touchMove', TOP_WHEEL, 'wheel']; // prettier-ignore 41519 41520var continuousPairsForSimpleEventPlugin = [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_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_PLAYING, 'playing', TOP_PROGRESS, 'progress', TOP_SEEKING, 'seeking', TOP_STALLED, 'stalled', TOP_SUSPEND, 'suspend', TOP_TIME_UPDATE, 'timeUpdate', TOP_TRANSITION_END, 'transitionEnd', TOP_WAITING, 'waiting']; 41521/** 41522 * Turns 41523 * ['abort', ...] 41524 * into 41525 * eventTypes = { 41526 * 'abort': { 41527 * phasedRegistrationNames: { 41528 * bubbled: 'onAbort', 41529 * captured: 'onAbortCapture', 41530 * }, 41531 * dependencies: [TOP_ABORT], 41532 * }, 41533 * ... 41534 * }; 41535 * topLevelEventsToDispatchConfig = new Map([ 41536 * [TOP_ABORT, { sameConfig }], 41537 * ]); 41538 */ 41539 41540function processSimpleEventPluginPairsByPriority(eventTypes, priority) { 41541 // As the event types are in pairs of two, we need to iterate 41542 // through in twos. The events are in pairs of two to save code 41543 // and improve init perf of processing this array, as it will 41544 // result in far fewer object allocations and property accesses 41545 // if we only use three arrays to process all the categories of 41546 // instead of tuples. 41547 for (var i = 0; i < eventTypes.length; i += 2) { 41548 var topEvent = eventTypes[i]; 41549 var event = eventTypes[i + 1]; 41550 var capitalizedEvent = event[0].toUpperCase() + event.slice(1); 41551 var onEvent = 'on' + capitalizedEvent; 41552 var config = { 41553 phasedRegistrationNames: { 41554 bubbled: onEvent, 41555 captured: onEvent + 'Capture' 41556 }, 41557 dependencies: [topEvent], 41558 eventPriority: priority 41559 }; 41560 eventPriorities.set(topEvent, priority); 41561 topLevelEventsToDispatchConfig.set(topEvent, config); 41562 simpleEventPluginEventTypes[event] = config; 41563 } 41564} 41565 41566function processTopEventPairsByPriority(eventTypes, priority) { 41567 for (var i = 0; i < eventTypes.length; i++) { 41568 eventPriorities.set(eventTypes[i], priority); 41569 } 41570} // SimpleEventPlugin 41571 41572 41573processSimpleEventPluginPairsByPriority(discreteEventPairsForSimpleEventPlugin, DiscreteEvent); 41574processSimpleEventPluginPairsByPriority(userBlockingPairsForSimpleEventPlugin, UserBlockingEvent); 41575processSimpleEventPluginPairsByPriority(continuousPairsForSimpleEventPlugin, ContinuousEvent); // Not used by SimpleEventPlugin 41576 41577processTopEventPairsByPriority(otherDiscreteEvents, DiscreteEvent); 41578function getEventPriorityForPluginSystem(topLevelType) { 41579 var priority = eventPriorities.get(topLevelType); // Default to a ContinuousEvent. Note: we might 41580 // want to warn if we can't detect the priority 41581 // for the event. 41582 41583 return priority === undefined ? ContinuousEvent : priority; 41584} 41585 41586// Intentionally not named imports because Rollup would use dynamic dispatch for 41587var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, 41588 runWithPriority = Scheduler.unstable_runWithPriority; // TODO: can we stop exporting these? 41589 41590var _enabled = true; 41591function setEnabled(enabled) { 41592 _enabled = !!enabled; 41593} 41594function isEnabled() { 41595 return _enabled; 41596} 41597function trapBubbledEvent(topLevelType, element) { 41598 trapEventForPluginEventSystem(element, topLevelType, false); 41599} 41600function trapCapturedEvent(topLevelType, element) { 41601 trapEventForPluginEventSystem(element, topLevelType, true); 41602} 41603 41604function trapEventForPluginEventSystem(container, topLevelType, capture) { 41605 var listener; 41606 41607 switch (getEventPriorityForPluginSystem(topLevelType)) { 41608 case DiscreteEvent: 41609 listener = dispatchDiscreteEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM, container); 41610 break; 41611 41612 case UserBlockingEvent: 41613 listener = dispatchUserBlockingUpdate.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM, container); 41614 break; 41615 41616 case ContinuousEvent: 41617 default: 41618 listener = dispatchEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM, container); 41619 break; 41620 } 41621 41622 var rawEventName = getRawEventName(topLevelType); 41623 41624 if (capture) { 41625 addEventCaptureListener(container, rawEventName, listener); 41626 } else { 41627 addEventBubbleListener(container, rawEventName, listener); 41628 } 41629} 41630 41631function dispatchDiscreteEvent(topLevelType, eventSystemFlags, container, nativeEvent) { 41632 flushDiscreteUpdatesIfNeeded(nativeEvent.timeStamp); 41633 discreteUpdates(dispatchEvent, topLevelType, eventSystemFlags, container, nativeEvent); 41634} 41635 41636function dispatchUserBlockingUpdate(topLevelType, eventSystemFlags, container, nativeEvent) { 41637 runWithPriority(UserBlockingPriority, dispatchEvent.bind(null, topLevelType, eventSystemFlags, container, nativeEvent)); 41638} 41639 41640function dispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent) { 41641 if (!_enabled) { 41642 return; 41643 } 41644 41645 if (hasQueuedDiscreteEvents() && isReplayableDiscreteEvent(topLevelType)) { 41646 // If we already have a queue of discrete events, and this is another discrete 41647 // event, then we can't dispatch it regardless of its target, since they 41648 // need to dispatch in order. 41649 queueDiscreteEvent(null, // Flags that we're not actually blocked on anything as far as we know. 41650 topLevelType, eventSystemFlags, container, nativeEvent); 41651 return; 41652 } 41653 41654 var blockedOn = attemptToDispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent); 41655 41656 if (blockedOn === null) { 41657 // We successfully dispatched this event. 41658 clearIfContinuousEvent(topLevelType, nativeEvent); 41659 return; 41660 } 41661 41662 if (isReplayableDiscreteEvent(topLevelType)) { 41663 // This this to be replayed later once the target is available. 41664 queueDiscreteEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent); 41665 return; 41666 } 41667 41668 if (queueIfContinuousEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent)) { 41669 return; 41670 } // We need to clear only if we didn't queue because 41671 // queueing is accummulative. 41672 41673 41674 clearIfContinuousEvent(topLevelType, nativeEvent); // This is not replayable so we'll invoke it but without a target, 41675 // in case the event system needs to trace it. 41676 41677 { 41678 dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, null); 41679 } 41680} // Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked. 41681 41682function attemptToDispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent) { 41683 // TODO: Warn if _enabled is false. 41684 var nativeEventTarget = getEventTarget(nativeEvent); 41685 var targetInst = getClosestInstanceFromNode(nativeEventTarget); 41686 41687 if (targetInst !== null) { 41688 var nearestMounted = getNearestMountedFiber(targetInst); 41689 41690 if (nearestMounted === null) { 41691 // This tree has been unmounted already. Dispatch without a target. 41692 targetInst = null; 41693 } else { 41694 var tag = nearestMounted.tag; 41695 41696 if (tag === SuspenseComponent) { 41697 var instance = getSuspenseInstanceFromFiber(nearestMounted); 41698 41699 if (instance !== null) { 41700 // Queue the event to be replayed later. Abort dispatching since we 41701 // don't want this event dispatched twice through the event system. 41702 // TODO: If this is the first discrete event in the queue. Schedule an increased 41703 // priority for this boundary. 41704 return instance; 41705 } // This shouldn't happen, something went wrong but to avoid blocking 41706 // the whole system, dispatch the event without a target. 41707 // TODO: Warn. 41708 41709 41710 targetInst = null; 41711 } else if (tag === HostRoot) { 41712 var root = nearestMounted.stateNode; 41713 41714 if (root.hydrate) { 41715 // If this happens during a replay something went wrong and it might block 41716 // the whole system. 41717 return getContainerFromFiber(nearestMounted); 41718 } 41719 41720 targetInst = null; 41721 } else if (nearestMounted !== targetInst) { 41722 // If we get an event (ex: img onload) before committing that 41723 // component's mount, ignore it for now (that is, treat it as if it was an 41724 // event on a non-React tree). We might also consider queueing events and 41725 // dispatching them after the mount. 41726 targetInst = null; 41727 } 41728 } 41729 } 41730 41731 { 41732 dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst); 41733 } // We're not blocked on anything. 41734 41735 41736 return null; 41737} 41738 41739// List derived from Gecko source code: 41740// https://github.com/mozilla/gecko-dev/blob/4e638efc71/layout/style/test/property_database.js 41741var shorthandToLonghand = { 41742 animation: ['animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction'], 41743 background: ['backgroundAttachment', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundSize'], 41744 backgroundPosition: ['backgroundPositionX', 'backgroundPositionY'], 41745 border: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderTopColor', 'borderTopStyle', 'borderTopWidth'], 41746 borderBlockEnd: ['borderBlockEndColor', 'borderBlockEndStyle', 'borderBlockEndWidth'], 41747 borderBlockStart: ['borderBlockStartColor', 'borderBlockStartStyle', 'borderBlockStartWidth'], 41748 borderBottom: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth'], 41749 borderColor: ['borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor'], 41750 borderImage: ['borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth'], 41751 borderInlineEnd: ['borderInlineEndColor', 'borderInlineEndStyle', 'borderInlineEndWidth'], 41752 borderInlineStart: ['borderInlineStartColor', 'borderInlineStartStyle', 'borderInlineStartWidth'], 41753 borderLeft: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth'], 41754 borderRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius'], 41755 borderRight: ['borderRightColor', 'borderRightStyle', 'borderRightWidth'], 41756 borderStyle: ['borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopStyle'], 41757 borderTop: ['borderTopColor', 'borderTopStyle', 'borderTopWidth'], 41758 borderWidth: ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth'], 41759 columnRule: ['columnRuleColor', 'columnRuleStyle', 'columnRuleWidth'], 41760 columns: ['columnCount', 'columnWidth'], 41761 flex: ['flexBasis', 'flexGrow', 'flexShrink'], 41762 flexFlow: ['flexDirection', 'flexWrap'], 41763 font: ['fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontLanguageOverride', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition', 'fontWeight', 'lineHeight'], 41764 fontVariant: ['fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition'], 41765 gap: ['columnGap', 'rowGap'], 41766 grid: ['gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'], 41767 gridArea: ['gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart'], 41768 gridColumn: ['gridColumnEnd', 'gridColumnStart'], 41769 gridColumnGap: ['columnGap'], 41770 gridGap: ['columnGap', 'rowGap'], 41771 gridRow: ['gridRowEnd', 'gridRowStart'], 41772 gridRowGap: ['rowGap'], 41773 gridTemplate: ['gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'], 41774 listStyle: ['listStyleImage', 'listStylePosition', 'listStyleType'], 41775 margin: ['marginBottom', 'marginLeft', 'marginRight', 'marginTop'], 41776 marker: ['markerEnd', 'markerMid', 'markerStart'], 41777 mask: ['maskClip', 'maskComposite', 'maskImage', 'maskMode', 'maskOrigin', 'maskPositionX', 'maskPositionY', 'maskRepeat', 'maskSize'], 41778 maskPosition: ['maskPositionX', 'maskPositionY'], 41779 outline: ['outlineColor', 'outlineStyle', 'outlineWidth'], 41780 overflow: ['overflowX', 'overflowY'], 41781 padding: ['paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop'], 41782 placeContent: ['alignContent', 'justifyContent'], 41783 placeItems: ['alignItems', 'justifyItems'], 41784 placeSelf: ['alignSelf', 'justifySelf'], 41785 textDecoration: ['textDecorationColor', 'textDecorationLine', 'textDecorationStyle'], 41786 textEmphasis: ['textEmphasisColor', 'textEmphasisStyle'], 41787 transition: ['transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction'], 41788 wordWrap: ['overflowWrap'] 41789}; 41790 41791/** 41792 * CSS properties which accept numbers but are not in units of "px". 41793 */ 41794var isUnitlessNumber = { 41795 animationIterationCount: true, 41796 borderImageOutset: true, 41797 borderImageSlice: true, 41798 borderImageWidth: true, 41799 boxFlex: true, 41800 boxFlexGroup: true, 41801 boxOrdinalGroup: true, 41802 columnCount: true, 41803 columns: true, 41804 flex: true, 41805 flexGrow: true, 41806 flexPositive: true, 41807 flexShrink: true, 41808 flexNegative: true, 41809 flexOrder: true, 41810 gridArea: true, 41811 gridRow: true, 41812 gridRowEnd: true, 41813 gridRowSpan: true, 41814 gridRowStart: true, 41815 gridColumn: true, 41816 gridColumnEnd: true, 41817 gridColumnSpan: true, 41818 gridColumnStart: true, 41819 fontWeight: true, 41820 lineClamp: true, 41821 lineHeight: true, 41822 opacity: true, 41823 order: true, 41824 orphans: true, 41825 tabSize: true, 41826 widows: true, 41827 zIndex: true, 41828 zoom: true, 41829 // SVG-related properties 41830 fillOpacity: true, 41831 floodOpacity: true, 41832 stopOpacity: true, 41833 strokeDasharray: true, 41834 strokeDashoffset: true, 41835 strokeMiterlimit: true, 41836 strokeOpacity: true, 41837 strokeWidth: true 41838}; 41839/** 41840 * @param {string} prefix vendor-specific prefix, eg: Webkit 41841 * @param {string} key style name, eg: transitionDuration 41842 * @return {string} style name prefixed with `prefix`, properly camelCased, eg: 41843 * WebkitTransitionDuration 41844 */ 41845 41846function prefixKey(prefix, key) { 41847 return prefix + key.charAt(0).toUpperCase() + key.substring(1); 41848} 41849/** 41850 * Support style names that may come passed in prefixed by adding permutations 41851 * of vendor prefixes. 41852 */ 41853 41854 41855var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an 41856// infinite loop, because it iterates over the newly added props too. 41857 41858Object.keys(isUnitlessNumber).forEach(function (prop) { 41859 prefixes.forEach(function (prefix) { 41860 isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; 41861 }); 41862}); 41863 41864/** 41865 * Convert a value into the proper css writable value. The style name `name` 41866 * should be logical (no hyphens), as specified 41867 * in `CSSProperty.isUnitlessNumber`. 41868 * 41869 * @param {string} name CSS property name such as `topMargin`. 41870 * @param {*} value CSS property value such as `10px`. 41871 * @return {string} Normalized style value with dimensions applied. 41872 */ 41873 41874function dangerousStyleValue(name, value, isCustomProperty) { 41875 // Note that we've removed escapeTextForBrowser() calls here since the 41876 // whole string will be escaped when the attribute is injected into 41877 // the markup. If you provide unsafe user data here they can inject 41878 // arbitrary CSS which may be problematic (I couldn't repro this): 41879 // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet 41880 // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/ 41881 // This is not an XSS hole but instead a potential CSS injection issue 41882 // which has lead to a greater discussion about how we're going to 41883 // trust URLs moving forward. See #2115901 41884 var isEmpty = value == null || typeof value === 'boolean' || value === ''; 41885 41886 if (isEmpty) { 41887 return ''; 41888 } 41889 41890 if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) { 41891 return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers 41892 } 41893 41894 return ('' + value).trim(); 41895} 41896 41897var uppercasePattern = /([A-Z])/g; 41898var msPattern = /^ms-/; 41899/** 41900 * Hyphenates a camelcased CSS property name, for example: 41901 * 41902 * > hyphenateStyleName('backgroundColor') 41903 * < "background-color" 41904 * > hyphenateStyleName('MozTransition') 41905 * < "-moz-transition" 41906 * > hyphenateStyleName('msTransition') 41907 * < "-ms-transition" 41908 * 41909 * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix 41910 * is converted to `-ms-`. 41911 */ 41912 41913function hyphenateStyleName(name) { 41914 return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-'); 41915} 41916 41917var warnValidStyle = function () {}; 41918 41919{ 41920 // 'msTransform' is correct, but the other prefixes should be capitalized 41921 var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; 41922 var msPattern$1 = /^-ms-/; 41923 var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon 41924 41925 var badStyleValueWithSemicolonPattern = /;\s*$/; 41926 var warnedStyleNames = {}; 41927 var warnedStyleValues = {}; 41928 var warnedForNaNValue = false; 41929 var warnedForInfinityValue = false; 41930 41931 var camelize = function (string) { 41932 return string.replace(hyphenPattern, function (_, character) { 41933 return character.toUpperCase(); 41934 }); 41935 }; 41936 41937 var warnHyphenatedStyleName = function (name) { 41938 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { 41939 return; 41940 } 41941 41942 warnedStyleNames[name] = true; 41943 41944 error('Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests 41945 // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix 41946 // is converted to lowercase `ms`. 41947 camelize(name.replace(msPattern$1, 'ms-'))); 41948 }; 41949 41950 var warnBadVendoredStyleName = function (name) { 41951 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { 41952 return; 41953 } 41954 41955 warnedStyleNames[name] = true; 41956 41957 error('Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1)); 41958 }; 41959 41960 var warnStyleValueWithSemicolon = function (name, value) { 41961 if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { 41962 return; 41963 } 41964 41965 warnedStyleValues[value] = true; 41966 41967 error("Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, '')); 41968 }; 41969 41970 var warnStyleValueIsNaN = function (name, value) { 41971 if (warnedForNaNValue) { 41972 return; 41973 } 41974 41975 warnedForNaNValue = true; 41976 41977 error('`NaN` is an invalid value for the `%s` css style property.', name); 41978 }; 41979 41980 var warnStyleValueIsInfinity = function (name, value) { 41981 if (warnedForInfinityValue) { 41982 return; 41983 } 41984 41985 warnedForInfinityValue = true; 41986 41987 error('`Infinity` is an invalid value for the `%s` css style property.', name); 41988 }; 41989 41990 warnValidStyle = function (name, value) { 41991 if (name.indexOf('-') > -1) { 41992 warnHyphenatedStyleName(name); 41993 } else if (badVendoredStyleNamePattern.test(name)) { 41994 warnBadVendoredStyleName(name); 41995 } else if (badStyleValueWithSemicolonPattern.test(value)) { 41996 warnStyleValueWithSemicolon(name, value); 41997 } 41998 41999 if (typeof value === 'number') { 42000 if (isNaN(value)) { 42001 warnStyleValueIsNaN(name, value); 42002 } else if (!isFinite(value)) { 42003 warnStyleValueIsInfinity(name, value); 42004 } 42005 } 42006 }; 42007} 42008 42009var warnValidStyle$1 = warnValidStyle; 42010 42011/** 42012 * Operations for dealing with CSS properties. 42013 */ 42014 42015/** 42016 * This creates a string that is expected to be equivalent to the style 42017 * attribute generated by server-side rendering. It by-passes warnings and 42018 * security checks so it's not safe to use this value for anything other than 42019 * comparison. It is only used in DEV for SSR validation. 42020 */ 42021 42022function createDangerousStringForStyles(styles) { 42023 { 42024 var serialized = ''; 42025 var delimiter = ''; 42026 42027 for (var styleName in styles) { 42028 if (!styles.hasOwnProperty(styleName)) { 42029 continue; 42030 } 42031 42032 var styleValue = styles[styleName]; 42033 42034 if (styleValue != null) { 42035 var isCustomProperty = styleName.indexOf('--') === 0; 42036 serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':'; 42037 serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty); 42038 delimiter = ';'; 42039 } 42040 } 42041 42042 return serialized || null; 42043 } 42044} 42045/** 42046 * Sets the value for multiple styles on a node. If a value is specified as 42047 * '' (empty string), the corresponding style property will be unset. 42048 * 42049 * @param {DOMElement} node 42050 * @param {object} styles 42051 */ 42052 42053function setValueForStyles(node, styles) { 42054 var style = node.style; 42055 42056 for (var styleName in styles) { 42057 if (!styles.hasOwnProperty(styleName)) { 42058 continue; 42059 } 42060 42061 var isCustomProperty = styleName.indexOf('--') === 0; 42062 42063 { 42064 if (!isCustomProperty) { 42065 warnValidStyle$1(styleName, styles[styleName]); 42066 } 42067 } 42068 42069 var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty); 42070 42071 if (styleName === 'float') { 42072 styleName = 'cssFloat'; 42073 } 42074 42075 if (isCustomProperty) { 42076 style.setProperty(styleName, styleValue); 42077 } else { 42078 style[styleName] = styleValue; 42079 } 42080 } 42081} 42082 42083function isValueEmpty(value) { 42084 return value == null || typeof value === 'boolean' || value === ''; 42085} 42086/** 42087 * Given {color: 'red', overflow: 'hidden'} returns { 42088 * color: 'color', 42089 * overflowX: 'overflow', 42090 * overflowY: 'overflow', 42091 * }. This can be read as "the overflowY property was set by the overflow 42092 * shorthand". That is, the values are the property that each was derived from. 42093 */ 42094 42095 42096function expandShorthandMap(styles) { 42097 var expanded = {}; 42098 42099 for (var key in styles) { 42100 var longhands = shorthandToLonghand[key] || [key]; 42101 42102 for (var i = 0; i < longhands.length; i++) { 42103 expanded[longhands[i]] = key; 42104 } 42105 } 42106 42107 return expanded; 42108} 42109/** 42110 * When mixing shorthand and longhand property names, we warn during updates if 42111 * we expect an incorrect result to occur. In particular, we warn for: 42112 * 42113 * Updating a shorthand property (longhand gets overwritten): 42114 * {font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'} 42115 * becomes .style.font = 'baz' 42116 * Removing a shorthand property (longhand gets lost too): 42117 * {font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'} 42118 * becomes .style.font = '' 42119 * Removing a longhand property (should revert to shorthand; doesn't): 42120 * {font: 'foo', fontVariant: 'bar'} -> {font: 'foo'} 42121 * becomes .style.fontVariant = '' 42122 */ 42123 42124 42125function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) { 42126 { 42127 42128 if (!nextStyles) { 42129 return; 42130 } 42131 42132 var expandedUpdates = expandShorthandMap(styleUpdates); 42133 var expandedStyles = expandShorthandMap(nextStyles); 42134 var warnedAbout = {}; 42135 42136 for (var key in expandedUpdates) { 42137 var originalKey = expandedUpdates[key]; 42138 var correctOriginalKey = expandedStyles[key]; 42139 42140 if (correctOriginalKey && originalKey !== correctOriginalKey) { 42141 var warningKey = originalKey + ',' + correctOriginalKey; 42142 42143 if (warnedAbout[warningKey]) { 42144 continue; 42145 } 42146 42147 warnedAbout[warningKey] = true; 42148 42149 error('%s a style property during rerender (%s) when a ' + 'conflicting property is set (%s) can lead to styling bugs. To ' + "avoid this, don't mix shorthand and non-shorthand properties " + 'for the same value; instead, replace the shorthand with ' + 'separate values.', isValueEmpty(styleUpdates[originalKey]) ? 'Removing' : 'Updating', originalKey, correctOriginalKey); 42150 } 42151 } 42152 } 42153} 42154 42155// For HTML, certain tags should omit their close tag. We keep a whitelist for 42156// those special-case tags. 42157var omittedCloseTags = { 42158 area: true, 42159 base: true, 42160 br: true, 42161 col: true, 42162 embed: true, 42163 hr: true, 42164 img: true, 42165 input: true, 42166 keygen: true, 42167 link: true, 42168 meta: true, 42169 param: true, 42170 source: true, 42171 track: true, 42172 wbr: true // NOTE: menuitem's close tag should be omitted, but that causes problems. 42173 42174}; 42175 42176// `omittedCloseTags` except that `menuitem` should still have its closing tag. 42177 42178var voidElementTags = _assign({ 42179 menuitem: true 42180}, omittedCloseTags); 42181 42182var HTML = '__html'; 42183var ReactDebugCurrentFrame$3 = null; 42184 42185{ 42186 ReactDebugCurrentFrame$3 = ReactSharedInternals.ReactDebugCurrentFrame; 42187} 42188 42189function assertValidProps(tag, props) { 42190 if (!props) { 42191 return; 42192 } // Note the use of `==` which checks for null or undefined. 42193 42194 42195 if (voidElementTags[tag]) { 42196 if (!(props.children == null && props.dangerouslySetInnerHTML == null)) { 42197 { 42198 throw Error( tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`." + ( ReactDebugCurrentFrame$3.getStackAddendum() ) ); 42199 } 42200 } 42201 } 42202 42203 if (props.dangerouslySetInnerHTML != null) { 42204 if (!(props.children == null)) { 42205 { 42206 throw Error( "Can only set one of `children` or `props.dangerouslySetInnerHTML`." ); 42207 } 42208 } 42209 42210 if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML)) { 42211 { 42212 throw Error( "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information." ); 42213 } 42214 } 42215 } 42216 42217 { 42218 if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) { 42219 error('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.'); 42220 } 42221 } 42222 42223 if (!(props.style == null || typeof props.style === 'object')) { 42224 { 42225 throw Error( "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX." + ( ReactDebugCurrentFrame$3.getStackAddendum() ) ); 42226 } 42227 } 42228} 42229 42230function isCustomComponent(tagName, props) { 42231 if (tagName.indexOf('-') === -1) { 42232 return typeof props.is === 'string'; 42233 } 42234 42235 switch (tagName) { 42236 // These are reserved SVG and MathML elements. 42237 // We don't mind this whitelist too much because we expect it to never grow. 42238 // The alternative is to track the namespace in a few places which is convoluted. 42239 // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts 42240 case 'annotation-xml': 42241 case 'color-profile': 42242 case 'font-face': 42243 case 'font-face-src': 42244 case 'font-face-uri': 42245 case 'font-face-format': 42246 case 'font-face-name': 42247 case 'missing-glyph': 42248 return false; 42249 42250 default: 42251 return true; 42252 } 42253} 42254 42255// When adding attributes to the HTML or SVG whitelist, be sure to 42256// also add them to this module to ensure casing and incorrect name 42257// warnings. 42258var possibleStandardNames = { 42259 // HTML 42260 accept: 'accept', 42261 acceptcharset: 'acceptCharset', 42262 'accept-charset': 'acceptCharset', 42263 accesskey: 'accessKey', 42264 action: 'action', 42265 allowfullscreen: 'allowFullScreen', 42266 alt: 'alt', 42267 as: 'as', 42268 async: 'async', 42269 autocapitalize: 'autoCapitalize', 42270 autocomplete: 'autoComplete', 42271 autocorrect: 'autoCorrect', 42272 autofocus: 'autoFocus', 42273 autoplay: 'autoPlay', 42274 autosave: 'autoSave', 42275 capture: 'capture', 42276 cellpadding: 'cellPadding', 42277 cellspacing: 'cellSpacing', 42278 challenge: 'challenge', 42279 charset: 'charSet', 42280 checked: 'checked', 42281 children: 'children', 42282 cite: 'cite', 42283 class: 'className', 42284 classid: 'classID', 42285 classname: 'className', 42286 cols: 'cols', 42287 colspan: 'colSpan', 42288 content: 'content', 42289 contenteditable: 'contentEditable', 42290 contextmenu: 'contextMenu', 42291 controls: 'controls', 42292 controlslist: 'controlsList', 42293 coords: 'coords', 42294 crossorigin: 'crossOrigin', 42295 dangerouslysetinnerhtml: 'dangerouslySetInnerHTML', 42296 data: 'data', 42297 datetime: 'dateTime', 42298 default: 'default', 42299 defaultchecked: 'defaultChecked', 42300 defaultvalue: 'defaultValue', 42301 defer: 'defer', 42302 dir: 'dir', 42303 disabled: 'disabled', 42304 disablepictureinpicture: 'disablePictureInPicture', 42305 download: 'download', 42306 draggable: 'draggable', 42307 enctype: 'encType', 42308 for: 'htmlFor', 42309 form: 'form', 42310 formmethod: 'formMethod', 42311 formaction: 'formAction', 42312 formenctype: 'formEncType', 42313 formnovalidate: 'formNoValidate', 42314 formtarget: 'formTarget', 42315 frameborder: 'frameBorder', 42316 headers: 'headers', 42317 height: 'height', 42318 hidden: 'hidden', 42319 high: 'high', 42320 href: 'href', 42321 hreflang: 'hrefLang', 42322 htmlfor: 'htmlFor', 42323 httpequiv: 'httpEquiv', 42324 'http-equiv': 'httpEquiv', 42325 icon: 'icon', 42326 id: 'id', 42327 innerhtml: 'innerHTML', 42328 inputmode: 'inputMode', 42329 integrity: 'integrity', 42330 is: 'is', 42331 itemid: 'itemID', 42332 itemprop: 'itemProp', 42333 itemref: 'itemRef', 42334 itemscope: 'itemScope', 42335 itemtype: 'itemType', 42336 keyparams: 'keyParams', 42337 keytype: 'keyType', 42338 kind: 'kind', 42339 label: 'label', 42340 lang: 'lang', 42341 list: 'list', 42342 loop: 'loop', 42343 low: 'low', 42344 manifest: 'manifest', 42345 marginwidth: 'marginWidth', 42346 marginheight: 'marginHeight', 42347 max: 'max', 42348 maxlength: 'maxLength', 42349 media: 'media', 42350 mediagroup: 'mediaGroup', 42351 method: 'method', 42352 min: 'min', 42353 minlength: 'minLength', 42354 multiple: 'multiple', 42355 muted: 'muted', 42356 name: 'name', 42357 nomodule: 'noModule', 42358 nonce: 'nonce', 42359 novalidate: 'noValidate', 42360 open: 'open', 42361 optimum: 'optimum', 42362 pattern: 'pattern', 42363 placeholder: 'placeholder', 42364 playsinline: 'playsInline', 42365 poster: 'poster', 42366 preload: 'preload', 42367 profile: 'profile', 42368 radiogroup: 'radioGroup', 42369 readonly: 'readOnly', 42370 referrerpolicy: 'referrerPolicy', 42371 rel: 'rel', 42372 required: 'required', 42373 reversed: 'reversed', 42374 role: 'role', 42375 rows: 'rows', 42376 rowspan: 'rowSpan', 42377 sandbox: 'sandbox', 42378 scope: 'scope', 42379 scoped: 'scoped', 42380 scrolling: 'scrolling', 42381 seamless: 'seamless', 42382 selected: 'selected', 42383 shape: 'shape', 42384 size: 'size', 42385 sizes: 'sizes', 42386 span: 'span', 42387 spellcheck: 'spellCheck', 42388 src: 'src', 42389 srcdoc: 'srcDoc', 42390 srclang: 'srcLang', 42391 srcset: 'srcSet', 42392 start: 'start', 42393 step: 'step', 42394 style: 'style', 42395 summary: 'summary', 42396 tabindex: 'tabIndex', 42397 target: 'target', 42398 title: 'title', 42399 type: 'type', 42400 usemap: 'useMap', 42401 value: 'value', 42402 width: 'width', 42403 wmode: 'wmode', 42404 wrap: 'wrap', 42405 // SVG 42406 about: 'about', 42407 accentheight: 'accentHeight', 42408 'accent-height': 'accentHeight', 42409 accumulate: 'accumulate', 42410 additive: 'additive', 42411 alignmentbaseline: 'alignmentBaseline', 42412 'alignment-baseline': 'alignmentBaseline', 42413 allowreorder: 'allowReorder', 42414 alphabetic: 'alphabetic', 42415 amplitude: 'amplitude', 42416 arabicform: 'arabicForm', 42417 'arabic-form': 'arabicForm', 42418 ascent: 'ascent', 42419 attributename: 'attributeName', 42420 attributetype: 'attributeType', 42421 autoreverse: 'autoReverse', 42422 azimuth: 'azimuth', 42423 basefrequency: 'baseFrequency', 42424 baselineshift: 'baselineShift', 42425 'baseline-shift': 'baselineShift', 42426 baseprofile: 'baseProfile', 42427 bbox: 'bbox', 42428 begin: 'begin', 42429 bias: 'bias', 42430 by: 'by', 42431 calcmode: 'calcMode', 42432 capheight: 'capHeight', 42433 'cap-height': 'capHeight', 42434 clip: 'clip', 42435 clippath: 'clipPath', 42436 'clip-path': 'clipPath', 42437 clippathunits: 'clipPathUnits', 42438 cliprule: 'clipRule', 42439 'clip-rule': 'clipRule', 42440 color: 'color', 42441 colorinterpolation: 'colorInterpolation', 42442 'color-interpolation': 'colorInterpolation', 42443 colorinterpolationfilters: 'colorInterpolationFilters', 42444 'color-interpolation-filters': 'colorInterpolationFilters', 42445 colorprofile: 'colorProfile', 42446 'color-profile': 'colorProfile', 42447 colorrendering: 'colorRendering', 42448 'color-rendering': 'colorRendering', 42449 contentscripttype: 'contentScriptType', 42450 contentstyletype: 'contentStyleType', 42451 cursor: 'cursor', 42452 cx: 'cx', 42453 cy: 'cy', 42454 d: 'd', 42455 datatype: 'datatype', 42456 decelerate: 'decelerate', 42457 descent: 'descent', 42458 diffuseconstant: 'diffuseConstant', 42459 direction: 'direction', 42460 display: 'display', 42461 divisor: 'divisor', 42462 dominantbaseline: 'dominantBaseline', 42463 'dominant-baseline': 'dominantBaseline', 42464 dur: 'dur', 42465 dx: 'dx', 42466 dy: 'dy', 42467 edgemode: 'edgeMode', 42468 elevation: 'elevation', 42469 enablebackground: 'enableBackground', 42470 'enable-background': 'enableBackground', 42471 end: 'end', 42472 exponent: 'exponent', 42473 externalresourcesrequired: 'externalResourcesRequired', 42474 fill: 'fill', 42475 fillopacity: 'fillOpacity', 42476 'fill-opacity': 'fillOpacity', 42477 fillrule: 'fillRule', 42478 'fill-rule': 'fillRule', 42479 filter: 'filter', 42480 filterres: 'filterRes', 42481 filterunits: 'filterUnits', 42482 floodopacity: 'floodOpacity', 42483 'flood-opacity': 'floodOpacity', 42484 floodcolor: 'floodColor', 42485 'flood-color': 'floodColor', 42486 focusable: 'focusable', 42487 fontfamily: 'fontFamily', 42488 'font-family': 'fontFamily', 42489 fontsize: 'fontSize', 42490 'font-size': 'fontSize', 42491 fontsizeadjust: 'fontSizeAdjust', 42492 'font-size-adjust': 'fontSizeAdjust', 42493 fontstretch: 'fontStretch', 42494 'font-stretch': 'fontStretch', 42495 fontstyle: 'fontStyle', 42496 'font-style': 'fontStyle', 42497 fontvariant: 'fontVariant', 42498 'font-variant': 'fontVariant', 42499 fontweight: 'fontWeight', 42500 'font-weight': 'fontWeight', 42501 format: 'format', 42502 from: 'from', 42503 fx: 'fx', 42504 fy: 'fy', 42505 g1: 'g1', 42506 g2: 'g2', 42507 glyphname: 'glyphName', 42508 'glyph-name': 'glyphName', 42509 glyphorientationhorizontal: 'glyphOrientationHorizontal', 42510 'glyph-orientation-horizontal': 'glyphOrientationHorizontal', 42511 glyphorientationvertical: 'glyphOrientationVertical', 42512 'glyph-orientation-vertical': 'glyphOrientationVertical', 42513 glyphref: 'glyphRef', 42514 gradienttransform: 'gradientTransform', 42515 gradientunits: 'gradientUnits', 42516 hanging: 'hanging', 42517 horizadvx: 'horizAdvX', 42518 'horiz-adv-x': 'horizAdvX', 42519 horizoriginx: 'horizOriginX', 42520 'horiz-origin-x': 'horizOriginX', 42521 ideographic: 'ideographic', 42522 imagerendering: 'imageRendering', 42523 'image-rendering': 'imageRendering', 42524 in2: 'in2', 42525 in: 'in', 42526 inlist: 'inlist', 42527 intercept: 'intercept', 42528 k1: 'k1', 42529 k2: 'k2', 42530 k3: 'k3', 42531 k4: 'k4', 42532 k: 'k', 42533 kernelmatrix: 'kernelMatrix', 42534 kernelunitlength: 'kernelUnitLength', 42535 kerning: 'kerning', 42536 keypoints: 'keyPoints', 42537 keysplines: 'keySplines', 42538 keytimes: 'keyTimes', 42539 lengthadjust: 'lengthAdjust', 42540 letterspacing: 'letterSpacing', 42541 'letter-spacing': 'letterSpacing', 42542 lightingcolor: 'lightingColor', 42543 'lighting-color': 'lightingColor', 42544 limitingconeangle: 'limitingConeAngle', 42545 local: 'local', 42546 markerend: 'markerEnd', 42547 'marker-end': 'markerEnd', 42548 markerheight: 'markerHeight', 42549 markermid: 'markerMid', 42550 'marker-mid': 'markerMid', 42551 markerstart: 'markerStart', 42552 'marker-start': 'markerStart', 42553 markerunits: 'markerUnits', 42554 markerwidth: 'markerWidth', 42555 mask: 'mask', 42556 maskcontentunits: 'maskContentUnits', 42557 maskunits: 'maskUnits', 42558 mathematical: 'mathematical', 42559 mode: 'mode', 42560 numoctaves: 'numOctaves', 42561 offset: 'offset', 42562 opacity: 'opacity', 42563 operator: 'operator', 42564 order: 'order', 42565 orient: 'orient', 42566 orientation: 'orientation', 42567 origin: 'origin', 42568 overflow: 'overflow', 42569 overlineposition: 'overlinePosition', 42570 'overline-position': 'overlinePosition', 42571 overlinethickness: 'overlineThickness', 42572 'overline-thickness': 'overlineThickness', 42573 paintorder: 'paintOrder', 42574 'paint-order': 'paintOrder', 42575 panose1: 'panose1', 42576 'panose-1': 'panose1', 42577 pathlength: 'pathLength', 42578 patterncontentunits: 'patternContentUnits', 42579 patterntransform: 'patternTransform', 42580 patternunits: 'patternUnits', 42581 pointerevents: 'pointerEvents', 42582 'pointer-events': 'pointerEvents', 42583 points: 'points', 42584 pointsatx: 'pointsAtX', 42585 pointsaty: 'pointsAtY', 42586 pointsatz: 'pointsAtZ', 42587 prefix: 'prefix', 42588 preservealpha: 'preserveAlpha', 42589 preserveaspectratio: 'preserveAspectRatio', 42590 primitiveunits: 'primitiveUnits', 42591 property: 'property', 42592 r: 'r', 42593 radius: 'radius', 42594 refx: 'refX', 42595 refy: 'refY', 42596 renderingintent: 'renderingIntent', 42597 'rendering-intent': 'renderingIntent', 42598 repeatcount: 'repeatCount', 42599 repeatdur: 'repeatDur', 42600 requiredextensions: 'requiredExtensions', 42601 requiredfeatures: 'requiredFeatures', 42602 resource: 'resource', 42603 restart: 'restart', 42604 result: 'result', 42605 results: 'results', 42606 rotate: 'rotate', 42607 rx: 'rx', 42608 ry: 'ry', 42609 scale: 'scale', 42610 security: 'security', 42611 seed: 'seed', 42612 shaperendering: 'shapeRendering', 42613 'shape-rendering': 'shapeRendering', 42614 slope: 'slope', 42615 spacing: 'spacing', 42616 specularconstant: 'specularConstant', 42617 specularexponent: 'specularExponent', 42618 speed: 'speed', 42619 spreadmethod: 'spreadMethod', 42620 startoffset: 'startOffset', 42621 stddeviation: 'stdDeviation', 42622 stemh: 'stemh', 42623 stemv: 'stemv', 42624 stitchtiles: 'stitchTiles', 42625 stopcolor: 'stopColor', 42626 'stop-color': 'stopColor', 42627 stopopacity: 'stopOpacity', 42628 'stop-opacity': 'stopOpacity', 42629 strikethroughposition: 'strikethroughPosition', 42630 'strikethrough-position': 'strikethroughPosition', 42631 strikethroughthickness: 'strikethroughThickness', 42632 'strikethrough-thickness': 'strikethroughThickness', 42633 string: 'string', 42634 stroke: 'stroke', 42635 strokedasharray: 'strokeDasharray', 42636 'stroke-dasharray': 'strokeDasharray', 42637 strokedashoffset: 'strokeDashoffset', 42638 'stroke-dashoffset': 'strokeDashoffset', 42639 strokelinecap: 'strokeLinecap', 42640 'stroke-linecap': 'strokeLinecap', 42641 strokelinejoin: 'strokeLinejoin', 42642 'stroke-linejoin': 'strokeLinejoin', 42643 strokemiterlimit: 'strokeMiterlimit', 42644 'stroke-miterlimit': 'strokeMiterlimit', 42645 strokewidth: 'strokeWidth', 42646 'stroke-width': 'strokeWidth', 42647 strokeopacity: 'strokeOpacity', 42648 'stroke-opacity': 'strokeOpacity', 42649 suppresscontenteditablewarning: 'suppressContentEditableWarning', 42650 suppresshydrationwarning: 'suppressHydrationWarning', 42651 surfacescale: 'surfaceScale', 42652 systemlanguage: 'systemLanguage', 42653 tablevalues: 'tableValues', 42654 targetx: 'targetX', 42655 targety: 'targetY', 42656 textanchor: 'textAnchor', 42657 'text-anchor': 'textAnchor', 42658 textdecoration: 'textDecoration', 42659 'text-decoration': 'textDecoration', 42660 textlength: 'textLength', 42661 textrendering: 'textRendering', 42662 'text-rendering': 'textRendering', 42663 to: 'to', 42664 transform: 'transform', 42665 typeof: 'typeof', 42666 u1: 'u1', 42667 u2: 'u2', 42668 underlineposition: 'underlinePosition', 42669 'underline-position': 'underlinePosition', 42670 underlinethickness: 'underlineThickness', 42671 'underline-thickness': 'underlineThickness', 42672 unicode: 'unicode', 42673 unicodebidi: 'unicodeBidi', 42674 'unicode-bidi': 'unicodeBidi', 42675 unicoderange: 'unicodeRange', 42676 'unicode-range': 'unicodeRange', 42677 unitsperem: 'unitsPerEm', 42678 'units-per-em': 'unitsPerEm', 42679 unselectable: 'unselectable', 42680 valphabetic: 'vAlphabetic', 42681 'v-alphabetic': 'vAlphabetic', 42682 values: 'values', 42683 vectoreffect: 'vectorEffect', 42684 'vector-effect': 'vectorEffect', 42685 version: 'version', 42686 vertadvy: 'vertAdvY', 42687 'vert-adv-y': 'vertAdvY', 42688 vertoriginx: 'vertOriginX', 42689 'vert-origin-x': 'vertOriginX', 42690 vertoriginy: 'vertOriginY', 42691 'vert-origin-y': 'vertOriginY', 42692 vhanging: 'vHanging', 42693 'v-hanging': 'vHanging', 42694 videographic: 'vIdeographic', 42695 'v-ideographic': 'vIdeographic', 42696 viewbox: 'viewBox', 42697 viewtarget: 'viewTarget', 42698 visibility: 'visibility', 42699 vmathematical: 'vMathematical', 42700 'v-mathematical': 'vMathematical', 42701 vocab: 'vocab', 42702 widths: 'widths', 42703 wordspacing: 'wordSpacing', 42704 'word-spacing': 'wordSpacing', 42705 writingmode: 'writingMode', 42706 'writing-mode': 'writingMode', 42707 x1: 'x1', 42708 x2: 'x2', 42709 x: 'x', 42710 xchannelselector: 'xChannelSelector', 42711 xheight: 'xHeight', 42712 'x-height': 'xHeight', 42713 xlinkactuate: 'xlinkActuate', 42714 'xlink:actuate': 'xlinkActuate', 42715 xlinkarcrole: 'xlinkArcrole', 42716 'xlink:arcrole': 'xlinkArcrole', 42717 xlinkhref: 'xlinkHref', 42718 'xlink:href': 'xlinkHref', 42719 xlinkrole: 'xlinkRole', 42720 'xlink:role': 'xlinkRole', 42721 xlinkshow: 'xlinkShow', 42722 'xlink:show': 'xlinkShow', 42723 xlinktitle: 'xlinkTitle', 42724 'xlink:title': 'xlinkTitle', 42725 xlinktype: 'xlinkType', 42726 'xlink:type': 'xlinkType', 42727 xmlbase: 'xmlBase', 42728 'xml:base': 'xmlBase', 42729 xmllang: 'xmlLang', 42730 'xml:lang': 'xmlLang', 42731 xmlns: 'xmlns', 42732 'xml:space': 'xmlSpace', 42733 xmlnsxlink: 'xmlnsXlink', 42734 'xmlns:xlink': 'xmlnsXlink', 42735 xmlspace: 'xmlSpace', 42736 y1: 'y1', 42737 y2: 'y2', 42738 y: 'y', 42739 ychannelselector: 'yChannelSelector', 42740 z: 'z', 42741 zoomandpan: 'zoomAndPan' 42742}; 42743 42744var ariaProperties = { 42745 'aria-current': 0, 42746 // state 42747 'aria-details': 0, 42748 'aria-disabled': 0, 42749 // state 42750 'aria-hidden': 0, 42751 // state 42752 'aria-invalid': 0, 42753 // state 42754 'aria-keyshortcuts': 0, 42755 'aria-label': 0, 42756 'aria-roledescription': 0, 42757 // Widget Attributes 42758 'aria-autocomplete': 0, 42759 'aria-checked': 0, 42760 'aria-expanded': 0, 42761 'aria-haspopup': 0, 42762 'aria-level': 0, 42763 'aria-modal': 0, 42764 'aria-multiline': 0, 42765 'aria-multiselectable': 0, 42766 'aria-orientation': 0, 42767 'aria-placeholder': 0, 42768 'aria-pressed': 0, 42769 'aria-readonly': 0, 42770 'aria-required': 0, 42771 'aria-selected': 0, 42772 'aria-sort': 0, 42773 'aria-valuemax': 0, 42774 'aria-valuemin': 0, 42775 'aria-valuenow': 0, 42776 'aria-valuetext': 0, 42777 // Live Region Attributes 42778 'aria-atomic': 0, 42779 'aria-busy': 0, 42780 'aria-live': 0, 42781 'aria-relevant': 0, 42782 // Drag-and-Drop Attributes 42783 'aria-dropeffect': 0, 42784 'aria-grabbed': 0, 42785 // Relationship Attributes 42786 'aria-activedescendant': 0, 42787 'aria-colcount': 0, 42788 'aria-colindex': 0, 42789 'aria-colspan': 0, 42790 'aria-controls': 0, 42791 'aria-describedby': 0, 42792 'aria-errormessage': 0, 42793 'aria-flowto': 0, 42794 'aria-labelledby': 0, 42795 'aria-owns': 0, 42796 'aria-posinset': 0, 42797 'aria-rowcount': 0, 42798 'aria-rowindex': 0, 42799 'aria-rowspan': 0, 42800 'aria-setsize': 0 42801}; 42802 42803var warnedProperties = {}; 42804var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); 42805var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); 42806var hasOwnProperty$1 = Object.prototype.hasOwnProperty; 42807 42808function validateProperty(tagName, name) { 42809 { 42810 if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) { 42811 return true; 42812 } 42813 42814 if (rARIACamel.test(name)) { 42815 var ariaName = 'aria-' + name.slice(4).toLowerCase(); 42816 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM 42817 // DOM properties, then it is an invalid aria-* attribute. 42818 42819 if (correctName == null) { 42820 error('Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name); 42821 42822 warnedProperties[name] = true; 42823 return true; 42824 } // aria-* attributes should be lowercase; suggest the lowercase version. 42825 42826 42827 if (name !== correctName) { 42828 error('Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName); 42829 42830 warnedProperties[name] = true; 42831 return true; 42832 } 42833 } 42834 42835 if (rARIA.test(name)) { 42836 var lowerCasedName = name.toLowerCase(); 42837 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM 42838 // DOM properties, then it is an invalid aria-* attribute. 42839 42840 if (standardName == null) { 42841 warnedProperties[name] = true; 42842 return false; 42843 } // aria-* attributes should be lowercase; suggest the lowercase version. 42844 42845 42846 if (name !== standardName) { 42847 error('Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName); 42848 42849 warnedProperties[name] = true; 42850 return true; 42851 } 42852 } 42853 } 42854 42855 return true; 42856} 42857 42858function warnInvalidARIAProps(type, props) { 42859 { 42860 var invalidProps = []; 42861 42862 for (var key in props) { 42863 var isValid = validateProperty(type, key); 42864 42865 if (!isValid) { 42866 invalidProps.push(key); 42867 } 42868 } 42869 42870 var unknownPropString = invalidProps.map(function (prop) { 42871 return '`' + prop + '`'; 42872 }).join(', '); 42873 42874 if (invalidProps.length === 1) { 42875 error('Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type); 42876 } else if (invalidProps.length > 1) { 42877 error('Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type); 42878 } 42879 } 42880} 42881 42882function validateProperties(type, props) { 42883 if (isCustomComponent(type, props)) { 42884 return; 42885 } 42886 42887 warnInvalidARIAProps(type, props); 42888} 42889 42890var didWarnValueNull = false; 42891function validateProperties$1(type, props) { 42892 { 42893 if (type !== 'input' && type !== 'textarea' && type !== 'select') { 42894 return; 42895 } 42896 42897 if (props != null && props.value === null && !didWarnValueNull) { 42898 didWarnValueNull = true; 42899 42900 if (type === 'select' && props.multiple) { 42901 error('`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.', type); 42902 } else { 42903 error('`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type); 42904 } 42905 } 42906 } 42907} 42908 42909var validateProperty$1 = function () {}; 42910 42911{ 42912 var warnedProperties$1 = {}; 42913 var _hasOwnProperty = Object.prototype.hasOwnProperty; 42914 var EVENT_NAME_REGEX = /^on./; 42915 var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/; 42916 var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); 42917 var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); 42918 42919 validateProperty$1 = function (tagName, name, value, canUseEventSystem) { 42920 if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) { 42921 return true; 42922 } 42923 42924 var lowerCasedName = name.toLowerCase(); 42925 42926 if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') { 42927 error('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.'); 42928 42929 warnedProperties$1[name] = true; 42930 return true; 42931 } // We can't rely on the event system being injected on the server. 42932 42933 42934 if (canUseEventSystem) { 42935 if (registrationNameModules.hasOwnProperty(name)) { 42936 return true; 42937 } 42938 42939 var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null; 42940 42941 if (registrationName != null) { 42942 error('Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName); 42943 42944 warnedProperties$1[name] = true; 42945 return true; 42946 } 42947 42948 if (EVENT_NAME_REGEX.test(name)) { 42949 error('Unknown event handler property `%s`. It will be ignored.', name); 42950 42951 warnedProperties$1[name] = true; 42952 return true; 42953 } 42954 } else if (EVENT_NAME_REGEX.test(name)) { 42955 // If no event plugins have been injected, we are in a server environment. 42956 // So we can't tell if the event name is correct for sure, but we can filter 42957 // out known bad ones like `onclick`. We can't suggest a specific replacement though. 42958 if (INVALID_EVENT_NAME_REGEX.test(name)) { 42959 error('Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name); 42960 } 42961 42962 warnedProperties$1[name] = true; 42963 return true; 42964 } // Let the ARIA attribute hook validate ARIA attributes 42965 42966 42967 if (rARIA$1.test(name) || rARIACamel$1.test(name)) { 42968 return true; 42969 } 42970 42971 if (lowerCasedName === 'innerhtml') { 42972 error('Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.'); 42973 42974 warnedProperties$1[name] = true; 42975 return true; 42976 } 42977 42978 if (lowerCasedName === 'aria') { 42979 error('The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.'); 42980 42981 warnedProperties$1[name] = true; 42982 return true; 42983 } 42984 42985 if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') { 42986 error('Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value); 42987 42988 warnedProperties$1[name] = true; 42989 return true; 42990 } 42991 42992 if (typeof value === 'number' && isNaN(value)) { 42993 error('Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name); 42994 42995 warnedProperties$1[name] = true; 42996 return true; 42997 } 42998 42999 var propertyInfo = getPropertyInfo(name); 43000 var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config. 43001 43002 if (possibleStandardNames.hasOwnProperty(lowerCasedName)) { 43003 var standardName = possibleStandardNames[lowerCasedName]; 43004 43005 if (standardName !== name) { 43006 error('Invalid DOM property `%s`. Did you mean `%s`?', name, standardName); 43007 43008 warnedProperties$1[name] = true; 43009 return true; 43010 } 43011 } else if (!isReserved && name !== lowerCasedName) { 43012 // Unknown attributes should have lowercase casing since that's how they 43013 // will be cased anyway with server rendering. 43014 error('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.', name, lowerCasedName); 43015 43016 warnedProperties$1[name] = true; 43017 return true; 43018 } 43019 43020 if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { 43021 if (value) { 43022 error('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()}.', value, name, name, value, name); 43023 } else { 43024 error('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.', value, name, name, value, name, name, name); 43025 } 43026 43027 warnedProperties$1[name] = true; 43028 return true; 43029 } // Now that we've validated casing, do not validate 43030 // data types for reserved props 43031 43032 43033 if (isReserved) { 43034 return true; 43035 } // Warn when a known attribute is a bad type 43036 43037 43038 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { 43039 warnedProperties$1[name] = true; 43040 return false; 43041 } // Warn when passing the strings 'false' or 'true' into a boolean prop 43042 43043 43044 if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) { 43045 error('Received the string `%s` for the boolean attribute `%s`. ' + '%s ' + 'Did you mean %s={%s}?', value, name, value === 'false' ? 'The browser will interpret it as a truthy value.' : 'Although this works, it will not work as expected if you pass the string "false".', name, value); 43046 43047 warnedProperties$1[name] = true; 43048 return true; 43049 } 43050 43051 return true; 43052 }; 43053} 43054 43055var warnUnknownProperties = function (type, props, canUseEventSystem) { 43056 { 43057 var unknownProps = []; 43058 43059 for (var key in props) { 43060 var isValid = validateProperty$1(type, key, props[key], canUseEventSystem); 43061 43062 if (!isValid) { 43063 unknownProps.push(key); 43064 } 43065 } 43066 43067 var unknownPropString = unknownProps.map(function (prop) { 43068 return '`' + prop + '`'; 43069 }).join(', '); 43070 43071 if (unknownProps.length === 1) { 43072 error('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', unknownPropString, type); 43073 } else if (unknownProps.length > 1) { 43074 error('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', unknownPropString, type); 43075 } 43076 } 43077}; 43078 43079function validateProperties$2(type, props, canUseEventSystem) { 43080 if (isCustomComponent(type, props)) { 43081 return; 43082 } 43083 43084 warnUnknownProperties(type, props, canUseEventSystem); 43085} 43086 43087var didWarnInvalidHydration = false; 43088var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML'; 43089var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning'; 43090var SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning'; 43091var AUTOFOCUS = 'autoFocus'; 43092var CHILDREN = 'children'; 43093var STYLE = 'style'; 43094var HTML$1 = '__html'; 43095var HTML_NAMESPACE$1 = Namespaces.html; 43096var warnedUnknownTags; 43097var suppressHydrationWarning; 43098var validatePropertiesInDevelopment; 43099var warnForTextDifference; 43100var warnForPropDifference; 43101var warnForExtraAttributes; 43102var warnForInvalidEventListener; 43103var canDiffStyleForHydrationWarning; 43104var normalizeMarkupForTextOrAttribute; 43105var normalizeHTML; 43106 43107{ 43108 warnedUnknownTags = { 43109 // Chrome is the only major browser not shipping <time>. But as of July 43110 // 2017 it intends to ship it due to widespread usage. We intentionally 43111 // *don't* warn for <time> even if it's unrecognized by Chrome because 43112 // it soon will be, and many apps have been using it anyway. 43113 time: true, 43114 // There are working polyfills for <dialog>. Let people use it. 43115 dialog: true, 43116 // Electron ships a custom <webview> tag to display external web content in 43117 // an isolated frame and process. 43118 // This tag is not present in non Electron environments such as JSDom which 43119 // is often used for testing purposes. 43120 // @see https://electronjs.org/docs/api/webview-tag 43121 webview: true 43122 }; 43123 43124 validatePropertiesInDevelopment = function (type, props) { 43125 validateProperties(type, props); 43126 validateProperties$1(type, props); 43127 validateProperties$2(type, props, 43128 /* canUseEventSystem */ 43129 true); 43130 }; // IE 11 parses & normalizes the style attribute as opposed to other 43131 // browsers. It adds spaces and sorts the properties in some 43132 // non-alphabetical order. Handling that would require sorting CSS 43133 // properties in the client & server versions or applying 43134 // `expectedStyle` to a temporary DOM node to read its `style` attribute 43135 // normalized. Since it only affects IE, we're skipping style warnings 43136 // in that browser completely in favor of doing all that work. 43137 // See https://github.com/facebook/react/issues/11807 43138 43139 43140 canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode; // HTML parsing normalizes CR and CRLF to LF. 43141 // It also can turn \u0000 into \uFFFD inside attributes. 43142 // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream 43143 // If we have a mismatch, it might be caused by that. 43144 // We will still patch up in this case but not fire the warning. 43145 43146 var NORMALIZE_NEWLINES_REGEX = /\r\n?/g; 43147 var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g; 43148 43149 normalizeMarkupForTextOrAttribute = function (markup) { 43150 var markupString = typeof markup === 'string' ? markup : '' + markup; 43151 return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, ''); 43152 }; 43153 43154 warnForTextDifference = function (serverText, clientText) { 43155 if (didWarnInvalidHydration) { 43156 return; 43157 } 43158 43159 var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText); 43160 var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText); 43161 43162 if (normalizedServerText === normalizedClientText) { 43163 return; 43164 } 43165 43166 didWarnInvalidHydration = true; 43167 43168 error('Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText); 43169 }; 43170 43171 warnForPropDifference = function (propName, serverValue, clientValue) { 43172 if (didWarnInvalidHydration) { 43173 return; 43174 } 43175 43176 var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue); 43177 var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue); 43178 43179 if (normalizedServerValue === normalizedClientValue) { 43180 return; 43181 } 43182 43183 didWarnInvalidHydration = true; 43184 43185 error('Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue)); 43186 }; 43187 43188 warnForExtraAttributes = function (attributeNames) { 43189 if (didWarnInvalidHydration) { 43190 return; 43191 } 43192 43193 didWarnInvalidHydration = true; 43194 var names = []; 43195 attributeNames.forEach(function (name) { 43196 names.push(name); 43197 }); 43198 43199 error('Extra attributes from the server: %s', names); 43200 }; 43201 43202 warnForInvalidEventListener = function (registrationName, listener) { 43203 if (listener === false) { 43204 error('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.', registrationName, registrationName, registrationName); 43205 } else { 43206 error('Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener); 43207 } 43208 }; // Parse the HTML and read it back to normalize the HTML string so that it 43209 // can be used for comparison. 43210 43211 43212 normalizeHTML = function (parent, html) { 43213 // We could have created a separate document here to avoid 43214 // re-initializing custom elements if they exist. But this breaks 43215 // how <noscript> is being handled. So we use the same document. 43216 // See the discussion in https://github.com/facebook/react/pull/11157. 43217 var testElement = parent.namespaceURI === HTML_NAMESPACE$1 ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName); 43218 testElement.innerHTML = html; 43219 return testElement.innerHTML; 43220 }; 43221} 43222 43223function ensureListeningTo(rootContainerElement, registrationName) { 43224 var isDocumentOrFragment = rootContainerElement.nodeType === DOCUMENT_NODE || rootContainerElement.nodeType === DOCUMENT_FRAGMENT_NODE; 43225 var doc = isDocumentOrFragment ? rootContainerElement : rootContainerElement.ownerDocument; 43226 legacyListenToEvent(registrationName, doc); 43227} 43228 43229function getOwnerDocumentFromRootContainer(rootContainerElement) { 43230 return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument; 43231} 43232 43233function noop() {} 43234 43235function trapClickOnNonInteractiveElement(node) { 43236 // Mobile Safari does not fire properly bubble click events on 43237 // non-interactive elements, which means delegated click listeners do not 43238 // fire. The workaround for this bug involves attaching an empty click 43239 // listener on the target node. 43240 // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html 43241 // Just set it using the onclick property so that we don't have to manage any 43242 // bookkeeping for it. Not sure if we need to clear it when the listener is 43243 // removed. 43244 // TODO: Only do this for the relevant Safaris maybe? 43245 node.onclick = noop; 43246} 43247 43248function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) { 43249 for (var propKey in nextProps) { 43250 if (!nextProps.hasOwnProperty(propKey)) { 43251 continue; 43252 } 43253 43254 var nextProp = nextProps[propKey]; 43255 43256 if (propKey === STYLE) { 43257 { 43258 if (nextProp) { 43259 // Freeze the next style object so that we can assume it won't be 43260 // mutated. We have already warned for this in the past. 43261 Object.freeze(nextProp); 43262 } 43263 } // Relies on `updateStylesByID` not mutating `styleUpdates`. 43264 43265 43266 setValueForStyles(domElement, nextProp); 43267 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 43268 var nextHtml = nextProp ? nextProp[HTML$1] : undefined; 43269 43270 if (nextHtml != null) { 43271 setInnerHTML(domElement, nextHtml); 43272 } 43273 } else if (propKey === CHILDREN) { 43274 if (typeof nextProp === 'string') { 43275 // Avoid setting initial textContent when the text is empty. In IE11 setting 43276 // textContent on a <textarea> will cause the placeholder to not 43277 // show within the <textarea> until it has been focused and blurred again. 43278 // https://github.com/facebook/react/issues/6731#issuecomment-254874553 43279 var canSetTextContent = tag !== 'textarea' || nextProp !== ''; 43280 43281 if (canSetTextContent) { 43282 setTextContent(domElement, nextProp); 43283 } 43284 } else if (typeof nextProp === 'number') { 43285 setTextContent(domElement, '' + nextProp); 43286 } 43287 } else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameModules.hasOwnProperty(propKey)) { 43288 if (nextProp != null) { 43289 if ( typeof nextProp !== 'function') { 43290 warnForInvalidEventListener(propKey, nextProp); 43291 } 43292 43293 ensureListeningTo(rootContainerElement, propKey); 43294 } 43295 } else if (nextProp != null) { 43296 setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag); 43297 } 43298 } 43299} 43300 43301function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) { 43302 // TODO: Handle wasCustomComponentTag 43303 for (var i = 0; i < updatePayload.length; i += 2) { 43304 var propKey = updatePayload[i]; 43305 var propValue = updatePayload[i + 1]; 43306 43307 if (propKey === STYLE) { 43308 setValueForStyles(domElement, propValue); 43309 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 43310 setInnerHTML(domElement, propValue); 43311 } else if (propKey === CHILDREN) { 43312 setTextContent(domElement, propValue); 43313 } else { 43314 setValueForProperty(domElement, propKey, propValue, isCustomComponentTag); 43315 } 43316 } 43317} 43318 43319function createElement(type, props, rootContainerElement, parentNamespace) { 43320 var isCustomComponentTag; // We create tags in the namespace of their parent container, except HTML 43321 // tags get no namespace. 43322 43323 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement); 43324 var domElement; 43325 var namespaceURI = parentNamespace; 43326 43327 if (namespaceURI === HTML_NAMESPACE$1) { 43328 namespaceURI = getIntrinsicNamespace(type); 43329 } 43330 43331 if (namespaceURI === HTML_NAMESPACE$1) { 43332 { 43333 isCustomComponentTag = isCustomComponent(type, props); // Should this check be gated by parent namespace? Not sure we want to 43334 // allow <SVG> or <mATH>. 43335 43336 if (!isCustomComponentTag && type !== type.toLowerCase()) { 43337 error('<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type); 43338 } 43339 } 43340 43341 if (type === 'script') { 43342 // Create the script via .innerHTML so its "parser-inserted" flag is 43343 // set to true and it does not execute 43344 var div = ownerDocument.createElement('div'); 43345 43346 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line 43347 // This is guaranteed to yield a script element. 43348 43349 var firstChild = div.firstChild; 43350 domElement = div.removeChild(firstChild); 43351 } else if (typeof props.is === 'string') { 43352 // $FlowIssue `createElement` should be updated for Web Components 43353 domElement = ownerDocument.createElement(type, { 43354 is: props.is 43355 }); 43356 } else { 43357 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug. 43358 // See discussion in https://github.com/facebook/react/pull/6896 43359 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240 43360 domElement = ownerDocument.createElement(type); // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size` 43361 // attributes on `select`s needs to be added before `option`s are inserted. 43362 // This prevents: 43363 // - a bug where the `select` does not scroll to the correct option because singular 43364 // `select` elements automatically pick the first item #13222 43365 // - a bug where the `select` set the first item as selected despite the `size` attribute #14239 43366 // See https://github.com/facebook/react/issues/13222 43367 // and https://github.com/facebook/react/issues/14239 43368 43369 if (type === 'select') { 43370 var node = domElement; 43371 43372 if (props.multiple) { 43373 node.multiple = true; 43374 } else if (props.size) { 43375 // Setting a size greater than 1 causes a select to behave like `multiple=true`, where 43376 // it is possible that no option is selected. 43377 // 43378 // This is only necessary when a select in "single selection mode". 43379 node.size = props.size; 43380 } 43381 } 43382 } 43383 } else { 43384 domElement = ownerDocument.createElementNS(namespaceURI, type); 43385 } 43386 43387 { 43388 if (namespaceURI === HTML_NAMESPACE$1) { 43389 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) { 43390 warnedUnknownTags[type] = true; 43391 43392 error('The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type); 43393 } 43394 } 43395 } 43396 43397 return domElement; 43398} 43399function createTextNode(text, rootContainerElement) { 43400 return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text); 43401} 43402function setInitialProperties(domElement, tag, rawProps, rootContainerElement) { 43403 var isCustomComponentTag = isCustomComponent(tag, rawProps); 43404 43405 { 43406 validatePropertiesInDevelopment(tag, rawProps); 43407 } // TODO: Make sure that we check isMounted before firing any of these events. 43408 43409 43410 var props; 43411 43412 switch (tag) { 43413 case 'iframe': 43414 case 'object': 43415 case 'embed': 43416 trapBubbledEvent(TOP_LOAD, domElement); 43417 props = rawProps; 43418 break; 43419 43420 case 'video': 43421 case 'audio': 43422 // Create listener for each media event 43423 for (var i = 0; i < mediaEventTypes.length; i++) { 43424 trapBubbledEvent(mediaEventTypes[i], domElement); 43425 } 43426 43427 props = rawProps; 43428 break; 43429 43430 case 'source': 43431 trapBubbledEvent(TOP_ERROR, domElement); 43432 props = rawProps; 43433 break; 43434 43435 case 'img': 43436 case 'image': 43437 case 'link': 43438 trapBubbledEvent(TOP_ERROR, domElement); 43439 trapBubbledEvent(TOP_LOAD, domElement); 43440 props = rawProps; 43441 break; 43442 43443 case 'form': 43444 trapBubbledEvent(TOP_RESET, domElement); 43445 trapBubbledEvent(TOP_SUBMIT, domElement); 43446 props = rawProps; 43447 break; 43448 43449 case 'details': 43450 trapBubbledEvent(TOP_TOGGLE, domElement); 43451 props = rawProps; 43452 break; 43453 43454 case 'input': 43455 initWrapperState(domElement, rawProps); 43456 props = getHostProps(domElement, rawProps); 43457 trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening 43458 // to onChange. Even if there is no listener. 43459 43460 ensureListeningTo(rootContainerElement, 'onChange'); 43461 break; 43462 43463 case 'option': 43464 validateProps(domElement, rawProps); 43465 props = getHostProps$1(domElement, rawProps); 43466 break; 43467 43468 case 'select': 43469 initWrapperState$1(domElement, rawProps); 43470 props = getHostProps$2(domElement, rawProps); 43471 trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening 43472 // to onChange. Even if there is no listener. 43473 43474 ensureListeningTo(rootContainerElement, 'onChange'); 43475 break; 43476 43477 case 'textarea': 43478 initWrapperState$2(domElement, rawProps); 43479 props = getHostProps$3(domElement, rawProps); 43480 trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening 43481 // to onChange. Even if there is no listener. 43482 43483 ensureListeningTo(rootContainerElement, 'onChange'); 43484 break; 43485 43486 default: 43487 props = rawProps; 43488 } 43489 43490 assertValidProps(tag, props); 43491 setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag); 43492 43493 switch (tag) { 43494 case 'input': 43495 // TODO: Make sure we check if this is still unmounted or do any clean 43496 // up necessary since we never stop tracking anymore. 43497 track(domElement); 43498 postMountWrapper(domElement, rawProps, false); 43499 break; 43500 43501 case 'textarea': 43502 // TODO: Make sure we check if this is still unmounted or do any clean 43503 // up necessary since we never stop tracking anymore. 43504 track(domElement); 43505 postMountWrapper$3(domElement); 43506 break; 43507 43508 case 'option': 43509 postMountWrapper$1(domElement, rawProps); 43510 break; 43511 43512 case 'select': 43513 postMountWrapper$2(domElement, rawProps); 43514 break; 43515 43516 default: 43517 if (typeof props.onClick === 'function') { 43518 // TODO: This cast may not be sound for SVG, MathML or custom elements. 43519 trapClickOnNonInteractiveElement(domElement); 43520 } 43521 43522 break; 43523 } 43524} // Calculate the diff between the two objects. 43525 43526function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) { 43527 { 43528 validatePropertiesInDevelopment(tag, nextRawProps); 43529 } 43530 43531 var updatePayload = null; 43532 var lastProps; 43533 var nextProps; 43534 43535 switch (tag) { 43536 case 'input': 43537 lastProps = getHostProps(domElement, lastRawProps); 43538 nextProps = getHostProps(domElement, nextRawProps); 43539 updatePayload = []; 43540 break; 43541 43542 case 'option': 43543 lastProps = getHostProps$1(domElement, lastRawProps); 43544 nextProps = getHostProps$1(domElement, nextRawProps); 43545 updatePayload = []; 43546 break; 43547 43548 case 'select': 43549 lastProps = getHostProps$2(domElement, lastRawProps); 43550 nextProps = getHostProps$2(domElement, nextRawProps); 43551 updatePayload = []; 43552 break; 43553 43554 case 'textarea': 43555 lastProps = getHostProps$3(domElement, lastRawProps); 43556 nextProps = getHostProps$3(domElement, nextRawProps); 43557 updatePayload = []; 43558 break; 43559 43560 default: 43561 lastProps = lastRawProps; 43562 nextProps = nextRawProps; 43563 43564 if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') { 43565 // TODO: This cast may not be sound for SVG, MathML or custom elements. 43566 trapClickOnNonInteractiveElement(domElement); 43567 } 43568 43569 break; 43570 } 43571 43572 assertValidProps(tag, nextProps); 43573 var propKey; 43574 var styleName; 43575 var styleUpdates = null; 43576 43577 for (propKey in lastProps) { 43578 if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) { 43579 continue; 43580 } 43581 43582 if (propKey === STYLE) { 43583 var lastStyle = lastProps[propKey]; 43584 43585 for (styleName in lastStyle) { 43586 if (lastStyle.hasOwnProperty(styleName)) { 43587 if (!styleUpdates) { 43588 styleUpdates = {}; 43589 } 43590 43591 styleUpdates[styleName] = ''; 43592 } 43593 } 43594 } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) ; else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameModules.hasOwnProperty(propKey)) { 43595 // This is a special case. If any listener updates we need to ensure 43596 // that the "current" fiber pointer gets updated so we need a commit 43597 // to update this element. 43598 if (!updatePayload) { 43599 updatePayload = []; 43600 } 43601 } else { 43602 // For all other deleted properties we add it to the queue. We use 43603 // the whitelist in the commit phase instead. 43604 (updatePayload = updatePayload || []).push(propKey, null); 43605 } 43606 } 43607 43608 for (propKey in nextProps) { 43609 var nextProp = nextProps[propKey]; 43610 var lastProp = lastProps != null ? lastProps[propKey] : undefined; 43611 43612 if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) { 43613 continue; 43614 } 43615 43616 if (propKey === STYLE) { 43617 { 43618 if (nextProp) { 43619 // Freeze the next style object so that we can assume it won't be 43620 // mutated. We have already warned for this in the past. 43621 Object.freeze(nextProp); 43622 } 43623 } 43624 43625 if (lastProp) { 43626 // Unset styles on `lastProp` but not on `nextProp`. 43627 for (styleName in lastProp) { 43628 if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) { 43629 if (!styleUpdates) { 43630 styleUpdates = {}; 43631 } 43632 43633 styleUpdates[styleName] = ''; 43634 } 43635 } // Update styles that changed since `lastProp`. 43636 43637 43638 for (styleName in nextProp) { 43639 if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) { 43640 if (!styleUpdates) { 43641 styleUpdates = {}; 43642 } 43643 43644 styleUpdates[styleName] = nextProp[styleName]; 43645 } 43646 } 43647 } else { 43648 // Relies on `updateStylesByID` not mutating `styleUpdates`. 43649 if (!styleUpdates) { 43650 if (!updatePayload) { 43651 updatePayload = []; 43652 } 43653 43654 updatePayload.push(propKey, styleUpdates); 43655 } 43656 43657 styleUpdates = nextProp; 43658 } 43659 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 43660 var nextHtml = nextProp ? nextProp[HTML$1] : undefined; 43661 var lastHtml = lastProp ? lastProp[HTML$1] : undefined; 43662 43663 if (nextHtml != null) { 43664 if (lastHtml !== nextHtml) { 43665 (updatePayload = updatePayload || []).push(propKey, nextHtml); 43666 } 43667 } 43668 } else if (propKey === CHILDREN) { 43669 if (lastProp !== nextProp && (typeof nextProp === 'string' || typeof nextProp === 'number')) { 43670 (updatePayload = updatePayload || []).push(propKey, '' + nextProp); 43671 } 43672 } else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (registrationNameModules.hasOwnProperty(propKey)) { 43673 if (nextProp != null) { 43674 // We eagerly listen to this even though we haven't committed yet. 43675 if ( typeof nextProp !== 'function') { 43676 warnForInvalidEventListener(propKey, nextProp); 43677 } 43678 43679 ensureListeningTo(rootContainerElement, propKey); 43680 } 43681 43682 if (!updatePayload && lastProp !== nextProp) { 43683 // This is a special case. If any listener updates we need to ensure 43684 // that the "current" props pointer gets updated so we need a commit 43685 // to update this element. 43686 updatePayload = []; 43687 } 43688 } else { 43689 // For any other property we always add it to the queue and then we 43690 // filter it out using the whitelist during the commit. 43691 (updatePayload = updatePayload || []).push(propKey, nextProp); 43692 } 43693 } 43694 43695 if (styleUpdates) { 43696 { 43697 validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE]); 43698 } 43699 43700 (updatePayload = updatePayload || []).push(STYLE, styleUpdates); 43701 } 43702 43703 return updatePayload; 43704} // Apply the diff. 43705 43706function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) { 43707 // Update checked *before* name. 43708 // In the middle of an update, it is possible to have multiple checked. 43709 // When a checked radio tries to change name, browser makes another radio's checked false. 43710 if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) { 43711 updateChecked(domElement, nextRawProps); 43712 } 43713 43714 var wasCustomComponentTag = isCustomComponent(tag, lastRawProps); 43715 var isCustomComponentTag = isCustomComponent(tag, nextRawProps); // Apply the diff. 43716 43717 updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); // TODO: Ensure that an update gets scheduled if any of the special props 43718 // changed. 43719 43720 switch (tag) { 43721 case 'input': 43722 // Update the wrapper around inputs *after* updating props. This has to 43723 // happen after `updateDOMProperties`. Otherwise HTML5 input validations 43724 // raise warnings and prevent the new value from being assigned. 43725 updateWrapper(domElement, nextRawProps); 43726 break; 43727 43728 case 'textarea': 43729 updateWrapper$1(domElement, nextRawProps); 43730 break; 43731 43732 case 'select': 43733 // <select> value update needs to occur after <option> children 43734 // reconciliation 43735 postUpdateWrapper(domElement, nextRawProps); 43736 break; 43737 } 43738} 43739 43740function getPossibleStandardName(propName) { 43741 { 43742 var lowerCasedName = propName.toLowerCase(); 43743 43744 if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) { 43745 return null; 43746 } 43747 43748 return possibleStandardNames[lowerCasedName] || null; 43749 } 43750} 43751 43752function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) { 43753 var isCustomComponentTag; 43754 var extraAttributeNames; 43755 43756 { 43757 suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING] === true; 43758 isCustomComponentTag = isCustomComponent(tag, rawProps); 43759 validatePropertiesInDevelopment(tag, rawProps); 43760 } // TODO: Make sure that we check isMounted before firing any of these events. 43761 43762 43763 switch (tag) { 43764 case 'iframe': 43765 case 'object': 43766 case 'embed': 43767 trapBubbledEvent(TOP_LOAD, domElement); 43768 break; 43769 43770 case 'video': 43771 case 'audio': 43772 // Create listener for each media event 43773 for (var i = 0; i < mediaEventTypes.length; i++) { 43774 trapBubbledEvent(mediaEventTypes[i], domElement); 43775 } 43776 43777 break; 43778 43779 case 'source': 43780 trapBubbledEvent(TOP_ERROR, domElement); 43781 break; 43782 43783 case 'img': 43784 case 'image': 43785 case 'link': 43786 trapBubbledEvent(TOP_ERROR, domElement); 43787 trapBubbledEvent(TOP_LOAD, domElement); 43788 break; 43789 43790 case 'form': 43791 trapBubbledEvent(TOP_RESET, domElement); 43792 trapBubbledEvent(TOP_SUBMIT, domElement); 43793 break; 43794 43795 case 'details': 43796 trapBubbledEvent(TOP_TOGGLE, domElement); 43797 break; 43798 43799 case 'input': 43800 initWrapperState(domElement, rawProps); 43801 trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening 43802 // to onChange. Even if there is no listener. 43803 43804 ensureListeningTo(rootContainerElement, 'onChange'); 43805 break; 43806 43807 case 'option': 43808 validateProps(domElement, rawProps); 43809 break; 43810 43811 case 'select': 43812 initWrapperState$1(domElement, rawProps); 43813 trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening 43814 // to onChange. Even if there is no listener. 43815 43816 ensureListeningTo(rootContainerElement, 'onChange'); 43817 break; 43818 43819 case 'textarea': 43820 initWrapperState$2(domElement, rawProps); 43821 trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening 43822 // to onChange. Even if there is no listener. 43823 43824 ensureListeningTo(rootContainerElement, 'onChange'); 43825 break; 43826 } 43827 43828 assertValidProps(tag, rawProps); 43829 43830 { 43831 extraAttributeNames = new Set(); 43832 var attributes = domElement.attributes; 43833 43834 for (var _i = 0; _i < attributes.length; _i++) { 43835 var name = attributes[_i].name.toLowerCase(); 43836 43837 switch (name) { 43838 // Built-in SSR attribute is whitelisted 43839 case 'data-reactroot': 43840 break; 43841 // Controlled attributes are not validated 43842 // TODO: Only ignore them on controlled tags. 43843 43844 case 'value': 43845 break; 43846 43847 case 'checked': 43848 break; 43849 43850 case 'selected': 43851 break; 43852 43853 default: 43854 // Intentionally use the original name. 43855 // See discussion in https://github.com/facebook/react/pull/10676. 43856 extraAttributeNames.add(attributes[_i].name); 43857 } 43858 } 43859 } 43860 43861 var updatePayload = null; 43862 43863 for (var propKey in rawProps) { 43864 if (!rawProps.hasOwnProperty(propKey)) { 43865 continue; 43866 } 43867 43868 var nextProp = rawProps[propKey]; 43869 43870 if (propKey === CHILDREN) { 43871 // For text content children we compare against textContent. This 43872 // might match additional HTML that is hidden when we read it using 43873 // textContent. E.g. "foo" will match "f<span>oo</span>" but that still 43874 // satisfies our requirement. Our requirement is not to produce perfect 43875 // HTML and attributes. Ideally we should preserve structure but it's 43876 // ok not to if the visible content is still enough to indicate what 43877 // even listeners these nodes might be wired up to. 43878 // TODO: Warn if there is more than a single textNode as a child. 43879 // TODO: Should we use domElement.firstChild.nodeValue to compare? 43880 if (typeof nextProp === 'string') { 43881 if (domElement.textContent !== nextProp) { 43882 if ( !suppressHydrationWarning) { 43883 warnForTextDifference(domElement.textContent, nextProp); 43884 } 43885 43886 updatePayload = [CHILDREN, nextProp]; 43887 } 43888 } else if (typeof nextProp === 'number') { 43889 if (domElement.textContent !== '' + nextProp) { 43890 if ( !suppressHydrationWarning) { 43891 warnForTextDifference(domElement.textContent, nextProp); 43892 } 43893 43894 updatePayload = [CHILDREN, '' + nextProp]; 43895 } 43896 } 43897 } else if (registrationNameModules.hasOwnProperty(propKey)) { 43898 if (nextProp != null) { 43899 if ( typeof nextProp !== 'function') { 43900 warnForInvalidEventListener(propKey, nextProp); 43901 } 43902 43903 ensureListeningTo(rootContainerElement, propKey); 43904 } 43905 } else if ( // Convince Flow we've calculated it (it's DEV-only in this method.) 43906 typeof isCustomComponentTag === 'boolean') { 43907 // Validate that the properties correspond to their expected values. 43908 var serverValue = void 0; 43909 var propertyInfo = getPropertyInfo(propKey); 43910 43911 if (suppressHydrationWarning) ; else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING || // Controlled attributes are not validated 43912 // TODO: Only ignore them on controlled tags. 43913 propKey === 'value' || propKey === 'checked' || propKey === 'selected') ; else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 43914 var serverHTML = domElement.innerHTML; 43915 var nextHtml = nextProp ? nextProp[HTML$1] : undefined; 43916 var expectedHTML = normalizeHTML(domElement, nextHtml != null ? nextHtml : ''); 43917 43918 if (expectedHTML !== serverHTML) { 43919 warnForPropDifference(propKey, serverHTML, expectedHTML); 43920 } 43921 } else if (propKey === STYLE) { 43922 // $FlowFixMe - Should be inferred as not undefined. 43923 extraAttributeNames.delete(propKey); 43924 43925 if (canDiffStyleForHydrationWarning) { 43926 var expectedStyle = createDangerousStringForStyles(nextProp); 43927 serverValue = domElement.getAttribute('style'); 43928 43929 if (expectedStyle !== serverValue) { 43930 warnForPropDifference(propKey, serverValue, expectedStyle); 43931 } 43932 } 43933 } else if (isCustomComponentTag) { 43934 // $FlowFixMe - Should be inferred as not undefined. 43935 extraAttributeNames.delete(propKey.toLowerCase()); 43936 serverValue = getValueForAttribute(domElement, propKey, nextProp); 43937 43938 if (nextProp !== serverValue) { 43939 warnForPropDifference(propKey, serverValue, nextProp); 43940 } 43941 } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) { 43942 var isMismatchDueToBadCasing = false; 43943 43944 if (propertyInfo !== null) { 43945 // $FlowFixMe - Should be inferred as not undefined. 43946 extraAttributeNames.delete(propertyInfo.attributeName); 43947 serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo); 43948 } else { 43949 var ownNamespace = parentNamespace; 43950 43951 if (ownNamespace === HTML_NAMESPACE$1) { 43952 ownNamespace = getIntrinsicNamespace(tag); 43953 } 43954 43955 if (ownNamespace === HTML_NAMESPACE$1) { 43956 // $FlowFixMe - Should be inferred as not undefined. 43957 extraAttributeNames.delete(propKey.toLowerCase()); 43958 } else { 43959 var standardName = getPossibleStandardName(propKey); 43960 43961 if (standardName !== null && standardName !== propKey) { 43962 // If an SVG prop is supplied with bad casing, it will 43963 // be successfully parsed from HTML, but will produce a mismatch 43964 // (and would be incorrectly rendered on the client). 43965 // However, we already warn about bad casing elsewhere. 43966 // So we'll skip the misleading extra mismatch warning in this case. 43967 isMismatchDueToBadCasing = true; // $FlowFixMe - Should be inferred as not undefined. 43968 43969 extraAttributeNames.delete(standardName); 43970 } // $FlowFixMe - Should be inferred as not undefined. 43971 43972 43973 extraAttributeNames.delete(propKey); 43974 } 43975 43976 serverValue = getValueForAttribute(domElement, propKey, nextProp); 43977 } 43978 43979 if (nextProp !== serverValue && !isMismatchDueToBadCasing) { 43980 warnForPropDifference(propKey, serverValue, nextProp); 43981 } 43982 } 43983 } 43984 } 43985 43986 { 43987 // $FlowFixMe - Should be inferred as not undefined. 43988 if (extraAttributeNames.size > 0 && !suppressHydrationWarning) { 43989 // $FlowFixMe - Should be inferred as not undefined. 43990 warnForExtraAttributes(extraAttributeNames); 43991 } 43992 } 43993 43994 switch (tag) { 43995 case 'input': 43996 // TODO: Make sure we check if this is still unmounted or do any clean 43997 // up necessary since we never stop tracking anymore. 43998 track(domElement); 43999 postMountWrapper(domElement, rawProps, true); 44000 break; 44001 44002 case 'textarea': 44003 // TODO: Make sure we check if this is still unmounted or do any clean 44004 // up necessary since we never stop tracking anymore. 44005 track(domElement); 44006 postMountWrapper$3(domElement); 44007 break; 44008 44009 case 'select': 44010 case 'option': 44011 // For input and textarea we current always set the value property at 44012 // post mount to force it to diverge from attributes. However, for 44013 // option and select we don't quite do the same thing and select 44014 // is not resilient to the DOM state changing so we don't do that here. 44015 // TODO: Consider not doing this for input and textarea. 44016 break; 44017 44018 default: 44019 if (typeof rawProps.onClick === 'function') { 44020 // TODO: This cast may not be sound for SVG, MathML or custom elements. 44021 trapClickOnNonInteractiveElement(domElement); 44022 } 44023 44024 break; 44025 } 44026 44027 return updatePayload; 44028} 44029function diffHydratedText(textNode, text) { 44030 var isDifferent = textNode.nodeValue !== text; 44031 return isDifferent; 44032} 44033function warnForUnmatchedText(textNode, text) { 44034 { 44035 warnForTextDifference(textNode.nodeValue, text); 44036 } 44037} 44038function warnForDeletedHydratableElement(parentNode, child) { 44039 { 44040 if (didWarnInvalidHydration) { 44041 return; 44042 } 44043 44044 didWarnInvalidHydration = true; 44045 44046 error('Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase()); 44047 } 44048} 44049function warnForDeletedHydratableText(parentNode, child) { 44050 { 44051 if (didWarnInvalidHydration) { 44052 return; 44053 } 44054 44055 didWarnInvalidHydration = true; 44056 44057 error('Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase()); 44058 } 44059} 44060function warnForInsertedHydratedElement(parentNode, tag, props) { 44061 { 44062 if (didWarnInvalidHydration) { 44063 return; 44064 } 44065 44066 didWarnInvalidHydration = true; 44067 44068 error('Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase()); 44069 } 44070} 44071function warnForInsertedHydratedText(parentNode, text) { 44072 { 44073 if (text === '') { 44074 // We expect to insert empty text nodes since they're not represented in 44075 // the HTML. 44076 // TODO: Remove this special case if we can just avoid inserting empty 44077 // text nodes. 44078 return; 44079 } 44080 44081 if (didWarnInvalidHydration) { 44082 return; 44083 } 44084 44085 didWarnInvalidHydration = true; 44086 44087 error('Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase()); 44088 } 44089} 44090function restoreControlledState$3(domElement, tag, props) { 44091 switch (tag) { 44092 case 'input': 44093 restoreControlledState(domElement, props); 44094 return; 44095 44096 case 'textarea': 44097 restoreControlledState$2(domElement, props); 44098 return; 44099 44100 case 'select': 44101 restoreControlledState$1(domElement, props); 44102 return; 44103 } 44104} 44105 44106function getActiveElement(doc) { 44107 doc = doc || (typeof document !== 'undefined' ? document : undefined); 44108 44109 if (typeof doc === 'undefined') { 44110 return null; 44111 } 44112 44113 try { 44114 return doc.activeElement || doc.body; 44115 } catch (e) { 44116 return doc.body; 44117 } 44118} 44119 44120/** 44121 * Given any node return the first leaf node without children. 44122 * 44123 * @param {DOMElement|DOMTextNode} node 44124 * @return {DOMElement|DOMTextNode} 44125 */ 44126 44127function getLeafNode(node) { 44128 while (node && node.firstChild) { 44129 node = node.firstChild; 44130 } 44131 44132 return node; 44133} 44134/** 44135 * Get the next sibling within a container. This will walk up the 44136 * DOM if a node's siblings have been exhausted. 44137 * 44138 * @param {DOMElement|DOMTextNode} node 44139 * @return {?DOMElement|DOMTextNode} 44140 */ 44141 44142 44143function getSiblingNode(node) { 44144 while (node) { 44145 if (node.nextSibling) { 44146 return node.nextSibling; 44147 } 44148 44149 node = node.parentNode; 44150 } 44151} 44152/** 44153 * Get object describing the nodes which contain characters at offset. 44154 * 44155 * @param {DOMElement|DOMTextNode} root 44156 * @param {number} offset 44157 * @return {?object} 44158 */ 44159 44160 44161function getNodeForCharacterOffset(root, offset) { 44162 var node = getLeafNode(root); 44163 var nodeStart = 0; 44164 var nodeEnd = 0; 44165 44166 while (node) { 44167 if (node.nodeType === TEXT_NODE) { 44168 nodeEnd = nodeStart + node.textContent.length; 44169 44170 if (nodeStart <= offset && nodeEnd >= offset) { 44171 return { 44172 node: node, 44173 offset: offset - nodeStart 44174 }; 44175 } 44176 44177 nodeStart = nodeEnd; 44178 } 44179 44180 node = getLeafNode(getSiblingNode(node)); 44181 } 44182} 44183 44184/** 44185 * @param {DOMElement} outerNode 44186 * @return {?object} 44187 */ 44188 44189function getOffsets(outerNode) { 44190 var ownerDocument = outerNode.ownerDocument; 44191 var win = ownerDocument && ownerDocument.defaultView || window; 44192 var selection = win.getSelection && win.getSelection(); 44193 44194 if (!selection || selection.rangeCount === 0) { 44195 return null; 44196 } 44197 44198 var anchorNode = selection.anchorNode, 44199 anchorOffset = selection.anchorOffset, 44200 focusNode = selection.focusNode, 44201 focusOffset = selection.focusOffset; // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the 44202 // up/down buttons on an <input type="number">. Anonymous divs do not seem to 44203 // expose properties, triggering a "Permission denied error" if any of its 44204 // properties are accessed. The only seemingly possible way to avoid erroring 44205 // is to access a property that typically works for non-anonymous divs and 44206 // catch any error that may otherwise arise. See 44207 // https://bugzilla.mozilla.org/show_bug.cgi?id=208427 44208 44209 try { 44210 /* eslint-disable no-unused-expressions */ 44211 anchorNode.nodeType; 44212 focusNode.nodeType; 44213 /* eslint-enable no-unused-expressions */ 44214 } catch (e) { 44215 return null; 44216 } 44217 44218 return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset); 44219} 44220/** 44221 * Returns {start, end} where `start` is the character/codepoint index of 44222 * (anchorNode, anchorOffset) within the textContent of `outerNode`, and 44223 * `end` is the index of (focusNode, focusOffset). 44224 * 44225 * Returns null if you pass in garbage input but we should probably just crash. 44226 * 44227 * Exported only for testing. 44228 */ 44229 44230function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) { 44231 var length = 0; 44232 var start = -1; 44233 var end = -1; 44234 var indexWithinAnchor = 0; 44235 var indexWithinFocus = 0; 44236 var node = outerNode; 44237 var parentNode = null; 44238 44239 outer: while (true) { 44240 var next = null; 44241 44242 while (true) { 44243 if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) { 44244 start = length + anchorOffset; 44245 } 44246 44247 if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) { 44248 end = length + focusOffset; 44249 } 44250 44251 if (node.nodeType === TEXT_NODE) { 44252 length += node.nodeValue.length; 44253 } 44254 44255 if ((next = node.firstChild) === null) { 44256 break; 44257 } // Moving from `node` to its first child `next`. 44258 44259 44260 parentNode = node; 44261 node = next; 44262 } 44263 44264 while (true) { 44265 if (node === outerNode) { 44266 // If `outerNode` has children, this is always the second time visiting 44267 // it. If it has no children, this is still the first loop, and the only 44268 // valid selection is anchorNode and focusNode both equal to this node 44269 // and both offsets 0, in which case we will have handled above. 44270 break outer; 44271 } 44272 44273 if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) { 44274 start = length; 44275 } 44276 44277 if (parentNode === focusNode && ++indexWithinFocus === focusOffset) { 44278 end = length; 44279 } 44280 44281 if ((next = node.nextSibling) !== null) { 44282 break; 44283 } 44284 44285 node = parentNode; 44286 parentNode = node.parentNode; 44287 } // Moving from `node` to its next sibling `next`. 44288 44289 44290 node = next; 44291 } 44292 44293 if (start === -1 || end === -1) { 44294 // This should never happen. (Would happen if the anchor/focus nodes aren't 44295 // actually inside the passed-in node.) 44296 return null; 44297 } 44298 44299 return { 44300 start: start, 44301 end: end 44302 }; 44303} 44304/** 44305 * In modern non-IE browsers, we can support both forward and backward 44306 * selections. 44307 * 44308 * Note: IE10+ supports the Selection object, but it does not support 44309 * the `extend` method, which means that even in modern IE, it's not possible 44310 * to programmatically create a backward selection. Thus, for all IE 44311 * versions, we use the old IE API to create our selections. 44312 * 44313 * @param {DOMElement|DOMTextNode} node 44314 * @param {object} offsets 44315 */ 44316 44317function setOffsets(node, offsets) { 44318 var doc = node.ownerDocument || document; 44319 var win = doc && doc.defaultView || window; // Edge fails with "Object expected" in some scenarios. 44320 // (For instance: TinyMCE editor used in a list component that supports pasting to add more, 44321 // fails when pasting 100+ items) 44322 44323 if (!win.getSelection) { 44324 return; 44325 } 44326 44327 var selection = win.getSelection(); 44328 var length = node.textContent.length; 44329 var start = Math.min(offsets.start, length); 44330 var end = offsets.end === undefined ? start : Math.min(offsets.end, length); // IE 11 uses modern selection, but doesn't support the extend method. 44331 // Flip backward selections, so we can set with a single range. 44332 44333 if (!selection.extend && start > end) { 44334 var temp = end; 44335 end = start; 44336 start = temp; 44337 } 44338 44339 var startMarker = getNodeForCharacterOffset(node, start); 44340 var endMarker = getNodeForCharacterOffset(node, end); 44341 44342 if (startMarker && endMarker) { 44343 if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) { 44344 return; 44345 } 44346 44347 var range = doc.createRange(); 44348 range.setStart(startMarker.node, startMarker.offset); 44349 selection.removeAllRanges(); 44350 44351 if (start > end) { 44352 selection.addRange(range); 44353 selection.extend(endMarker.node, endMarker.offset); 44354 } else { 44355 range.setEnd(endMarker.node, endMarker.offset); 44356 selection.addRange(range); 44357 } 44358 } 44359} 44360 44361function isTextNode(node) { 44362 return node && node.nodeType === TEXT_NODE; 44363} 44364 44365function containsNode(outerNode, innerNode) { 44366 if (!outerNode || !innerNode) { 44367 return false; 44368 } else if (outerNode === innerNode) { 44369 return true; 44370 } else if (isTextNode(outerNode)) { 44371 return false; 44372 } else if (isTextNode(innerNode)) { 44373 return containsNode(outerNode, innerNode.parentNode); 44374 } else if ('contains' in outerNode) { 44375 return outerNode.contains(innerNode); 44376 } else if (outerNode.compareDocumentPosition) { 44377 return !!(outerNode.compareDocumentPosition(innerNode) & 16); 44378 } else { 44379 return false; 44380 } 44381} 44382 44383function isInDocument(node) { 44384 return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node); 44385} 44386 44387function isSameOriginFrame(iframe) { 44388 try { 44389 // Accessing the contentDocument of a HTMLIframeElement can cause the browser 44390 // to throw, e.g. if it has a cross-origin src attribute. 44391 // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g: 44392 // iframe.contentDocument.defaultView; 44393 // A safety way is to access one of the cross origin properties: Window or Location 44394 // Which might result in "SecurityError" DOM Exception and it is compatible to Safari. 44395 // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl 44396 return typeof iframe.contentWindow.location.href === 'string'; 44397 } catch (err) { 44398 return false; 44399 } 44400} 44401 44402function getActiveElementDeep() { 44403 var win = window; 44404 var element = getActiveElement(); 44405 44406 while (element instanceof win.HTMLIFrameElement) { 44407 if (isSameOriginFrame(element)) { 44408 win = element.contentWindow; 44409 } else { 44410 return element; 44411 } 44412 44413 element = getActiveElement(win.document); 44414 } 44415 44416 return element; 44417} 44418/** 44419 * @ReactInputSelection: React input selection module. Based on Selection.js, 44420 * but modified to be suitable for react and has a couple of bug fixes (doesn't 44421 * assume buttons have range selections allowed). 44422 * Input selection module for React. 44423 */ 44424 44425/** 44426 * @hasSelectionCapabilities: we get the element types that support selection 44427 * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart` 44428 * and `selectionEnd` rows. 44429 */ 44430 44431 44432function hasSelectionCapabilities(elem) { 44433 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); 44434 return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true'); 44435} 44436function getSelectionInformation() { 44437 var focusedElem = getActiveElementDeep(); 44438 return { 44439 // Used by Flare 44440 activeElementDetached: null, 44441 focusedElem: focusedElem, 44442 selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null 44443 }; 44444} 44445/** 44446 * @restoreSelection: If any selection information was potentially lost, 44447 * restore it. This is useful when performing operations that could remove dom 44448 * nodes and place them back in, resulting in focus being lost. 44449 */ 44450 44451function restoreSelection(priorSelectionInformation) { 44452 var curFocusedElem = getActiveElementDeep(); 44453 var priorFocusedElem = priorSelectionInformation.focusedElem; 44454 var priorSelectionRange = priorSelectionInformation.selectionRange; 44455 44456 if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) { 44457 if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) { 44458 setSelection(priorFocusedElem, priorSelectionRange); 44459 } // Focusing a node can change the scroll position, which is undesirable 44460 44461 44462 var ancestors = []; 44463 var ancestor = priorFocusedElem; 44464 44465 while (ancestor = ancestor.parentNode) { 44466 if (ancestor.nodeType === ELEMENT_NODE) { 44467 ancestors.push({ 44468 element: ancestor, 44469 left: ancestor.scrollLeft, 44470 top: ancestor.scrollTop 44471 }); 44472 } 44473 } 44474 44475 if (typeof priorFocusedElem.focus === 'function') { 44476 priorFocusedElem.focus(); 44477 } 44478 44479 for (var i = 0; i < ancestors.length; i++) { 44480 var info = ancestors[i]; 44481 info.element.scrollLeft = info.left; 44482 info.element.scrollTop = info.top; 44483 } 44484 } 44485} 44486/** 44487 * @getSelection: Gets the selection bounds of a focused textarea, input or 44488 * contentEditable node. 44489 * -@input: Look up selection bounds of this input 44490 * -@return {start: selectionStart, end: selectionEnd} 44491 */ 44492 44493function getSelection(input) { 44494 var selection; 44495 44496 if ('selectionStart' in input) { 44497 // Modern browser with input or textarea. 44498 selection = { 44499 start: input.selectionStart, 44500 end: input.selectionEnd 44501 }; 44502 } else { 44503 // Content editable or old IE textarea. 44504 selection = getOffsets(input); 44505 } 44506 44507 return selection || { 44508 start: 0, 44509 end: 0 44510 }; 44511} 44512/** 44513 * @setSelection: Sets the selection bounds of a textarea or input and focuses 44514 * the input. 44515 * -@input Set selection bounds of this input or textarea 44516 * -@offsets Object of same form that is returned from get* 44517 */ 44518 44519function setSelection(input, offsets) { 44520 var start = offsets.start, 44521 end = offsets.end; 44522 44523 if (end === undefined) { 44524 end = start; 44525 } 44526 44527 if ('selectionStart' in input) { 44528 input.selectionStart = start; 44529 input.selectionEnd = Math.min(end, input.value.length); 44530 } else { 44531 setOffsets(input, offsets); 44532 } 44533} 44534 44535var validateDOMNesting = function () {}; 44536 44537var updatedAncestorInfo = function () {}; 44538 44539{ 44540 // This validation code was written based on the HTML5 parsing spec: 44541 // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope 44542 // 44543 // Note: this does not catch all invalid nesting, nor does it try to (as it's 44544 // not clear what practical benefit doing so provides); instead, we warn only 44545 // for cases where the parser will give a parse tree differing from what React 44546 // intended. For example, <b><div></div></b> is invalid but we don't warn 44547 // because it still parses correctly; we do warn for other cases like nested 44548 // <p> tags where the beginning of the second element implicitly closes the 44549 // first, causing a confusing mess. 44550 // https://html.spec.whatwg.org/multipage/syntax.html#special 44551 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']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope 44552 44553 var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point 44554 // TODO: Distinguish by namespace here -- for <title>, including it here 44555 // errs on the side of fewer warnings 44556 'foreignObject', 'desc', 'title']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope 44557 44558 var buttonScopeTags = inScopeTags.concat(['button']); // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags 44559 44560 var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt']; 44561 var emptyAncestorInfo = { 44562 current: null, 44563 formTag: null, 44564 aTagInScope: null, 44565 buttonTagInScope: null, 44566 nobrTagInScope: null, 44567 pTagInButtonScope: null, 44568 listItemTagAutoclosing: null, 44569 dlItemTagAutoclosing: null 44570 }; 44571 44572 updatedAncestorInfo = function (oldInfo, tag) { 44573 var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo); 44574 44575 var info = { 44576 tag: tag 44577 }; 44578 44579 if (inScopeTags.indexOf(tag) !== -1) { 44580 ancestorInfo.aTagInScope = null; 44581 ancestorInfo.buttonTagInScope = null; 44582 ancestorInfo.nobrTagInScope = null; 44583 } 44584 44585 if (buttonScopeTags.indexOf(tag) !== -1) { 44586 ancestorInfo.pTagInButtonScope = null; 44587 } // See rules for 'li', 'dd', 'dt' start tags in 44588 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody 44589 44590 44591 if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') { 44592 ancestorInfo.listItemTagAutoclosing = null; 44593 ancestorInfo.dlItemTagAutoclosing = null; 44594 } 44595 44596 ancestorInfo.current = info; 44597 44598 if (tag === 'form') { 44599 ancestorInfo.formTag = info; 44600 } 44601 44602 if (tag === 'a') { 44603 ancestorInfo.aTagInScope = info; 44604 } 44605 44606 if (tag === 'button') { 44607 ancestorInfo.buttonTagInScope = info; 44608 } 44609 44610 if (tag === 'nobr') { 44611 ancestorInfo.nobrTagInScope = info; 44612 } 44613 44614 if (tag === 'p') { 44615 ancestorInfo.pTagInButtonScope = info; 44616 } 44617 44618 if (tag === 'li') { 44619 ancestorInfo.listItemTagAutoclosing = info; 44620 } 44621 44622 if (tag === 'dd' || tag === 'dt') { 44623 ancestorInfo.dlItemTagAutoclosing = info; 44624 } 44625 44626 return ancestorInfo; 44627 }; 44628 /** 44629 * Returns whether 44630 */ 44631 44632 44633 var isTagValidWithParent = function (tag, parentTag) { 44634 // First, let's check if we're in an unusual parsing mode... 44635 switch (parentTag) { 44636 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect 44637 case 'select': 44638 return tag === 'option' || tag === 'optgroup' || tag === '#text'; 44639 44640 case 'optgroup': 44641 return tag === 'option' || tag === '#text'; 44642 // Strictly speaking, seeing an <option> doesn't mean we're in a <select> 44643 // but 44644 44645 case 'option': 44646 return tag === '#text'; 44647 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd 44648 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption 44649 // No special behavior since these rules fall back to "in body" mode for 44650 // all except special table nodes which cause bad parsing behavior anyway. 44651 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr 44652 44653 case 'tr': 44654 return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template'; 44655 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody 44656 44657 case 'tbody': 44658 case 'thead': 44659 case 'tfoot': 44660 return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template'; 44661 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup 44662 44663 case 'colgroup': 44664 return tag === 'col' || tag === 'template'; 44665 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable 44666 44667 case 'table': 44668 return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template'; 44669 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead 44670 44671 case 'head': 44672 return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template'; 44673 // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element 44674 44675 case 'html': 44676 return tag === 'head' || tag === 'body' || tag === 'frameset'; 44677 44678 case 'frameset': 44679 return tag === 'frame'; 44680 44681 case '#document': 44682 return tag === 'html'; 44683 } // Probably in the "in body" parsing mode, so we outlaw only tag combos 44684 // where the parsing rules cause implicit opens or closes to be added. 44685 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody 44686 44687 44688 switch (tag) { 44689 case 'h1': 44690 case 'h2': 44691 case 'h3': 44692 case 'h4': 44693 case 'h5': 44694 case 'h6': 44695 return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6'; 44696 44697 case 'rp': 44698 case 'rt': 44699 return impliedEndTags.indexOf(parentTag) === -1; 44700 44701 case 'body': 44702 case 'caption': 44703 case 'col': 44704 case 'colgroup': 44705 case 'frameset': 44706 case 'frame': 44707 case 'head': 44708 case 'html': 44709 case 'tbody': 44710 case 'td': 44711 case 'tfoot': 44712 case 'th': 44713 case 'thead': 44714 case 'tr': 44715 // These tags are only valid with a few parents that have special child 44716 // parsing rules -- if we're down here, then none of those matched and 44717 // so we allow it only if we don't know what the parent is, as all other 44718 // cases are invalid. 44719 return parentTag == null; 44720 } 44721 44722 return true; 44723 }; 44724 /** 44725 * Returns whether 44726 */ 44727 44728 44729 var findInvalidAncestorForTag = function (tag, ancestorInfo) { 44730 switch (tag) { 44731 case 'address': 44732 case 'article': 44733 case 'aside': 44734 case 'blockquote': 44735 case 'center': 44736 case 'details': 44737 case 'dialog': 44738 case 'dir': 44739 case 'div': 44740 case 'dl': 44741 case 'fieldset': 44742 case 'figcaption': 44743 case 'figure': 44744 case 'footer': 44745 case 'header': 44746 case 'hgroup': 44747 case 'main': 44748 case 'menu': 44749 case 'nav': 44750 case 'ol': 44751 case 'p': 44752 case 'section': 44753 case 'summary': 44754 case 'ul': 44755 case 'pre': 44756 case 'listing': 44757 case 'table': 44758 case 'hr': 44759 case 'xmp': 44760 case 'h1': 44761 case 'h2': 44762 case 'h3': 44763 case 'h4': 44764 case 'h5': 44765 case 'h6': 44766 return ancestorInfo.pTagInButtonScope; 44767 44768 case 'form': 44769 return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope; 44770 44771 case 'li': 44772 return ancestorInfo.listItemTagAutoclosing; 44773 44774 case 'dd': 44775 case 'dt': 44776 return ancestorInfo.dlItemTagAutoclosing; 44777 44778 case 'button': 44779 return ancestorInfo.buttonTagInScope; 44780 44781 case 'a': 44782 // Spec says something about storing a list of markers, but it sounds 44783 // equivalent to this check. 44784 return ancestorInfo.aTagInScope; 44785 44786 case 'nobr': 44787 return ancestorInfo.nobrTagInScope; 44788 } 44789 44790 return null; 44791 }; 44792 44793 var didWarn$1 = {}; 44794 44795 validateDOMNesting = function (childTag, childText, ancestorInfo) { 44796 ancestorInfo = ancestorInfo || emptyAncestorInfo; 44797 var parentInfo = ancestorInfo.current; 44798 var parentTag = parentInfo && parentInfo.tag; 44799 44800 if (childText != null) { 44801 if (childTag != null) { 44802 error('validateDOMNesting: when childText is passed, childTag should be null'); 44803 } 44804 44805 childTag = '#text'; 44806 } 44807 44808 var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo; 44809 var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo); 44810 var invalidParentOrAncestor = invalidParent || invalidAncestor; 44811 44812 if (!invalidParentOrAncestor) { 44813 return; 44814 } 44815 44816 var ancestorTag = invalidParentOrAncestor.tag; 44817 var addendum = getCurrentFiberStackInDev(); 44818 var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum; 44819 44820 if (didWarn$1[warnKey]) { 44821 return; 44822 } 44823 44824 didWarn$1[warnKey] = true; 44825 var tagDisplayName = childTag; 44826 var whitespaceInfo = ''; 44827 44828 if (childTag === '#text') { 44829 if (/\S/.test(childText)) { 44830 tagDisplayName = 'Text nodes'; 44831 } else { 44832 tagDisplayName = 'Whitespace text nodes'; 44833 whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.'; 44834 } 44835 } else { 44836 tagDisplayName = '<' + childTag + '>'; 44837 } 44838 44839 if (invalidParent) { 44840 var info = ''; 44841 44842 if (ancestorTag === 'table' && childTag === 'tr') { 44843 info += ' Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by ' + 'the browser.'; 44844 } 44845 44846 error('validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info); 44847 } else { 44848 error('validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.', tagDisplayName, ancestorTag); 44849 } 44850 }; 44851} 44852 44853var SUPPRESS_HYDRATION_WARNING$1; 44854 44855{ 44856 SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning'; 44857} 44858 44859var SUSPENSE_START_DATA = '$'; 44860var SUSPENSE_END_DATA = '/$'; 44861var SUSPENSE_PENDING_START_DATA = '$?'; 44862var SUSPENSE_FALLBACK_START_DATA = '$!'; 44863var STYLE$1 = 'style'; 44864var eventsEnabled = null; 44865var selectionInformation = null; 44866 44867function shouldAutoFocusHostComponent(type, props) { 44868 switch (type) { 44869 case 'button': 44870 case 'input': 44871 case 'select': 44872 case 'textarea': 44873 return !!props.autoFocus; 44874 } 44875 44876 return false; 44877} 44878function getRootHostContext(rootContainerInstance) { 44879 var type; 44880 var namespace; 44881 var nodeType = rootContainerInstance.nodeType; 44882 44883 switch (nodeType) { 44884 case DOCUMENT_NODE: 44885 case DOCUMENT_FRAGMENT_NODE: 44886 { 44887 type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment'; 44888 var root = rootContainerInstance.documentElement; 44889 namespace = root ? root.namespaceURI : getChildNamespace(null, ''); 44890 break; 44891 } 44892 44893 default: 44894 { 44895 var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance; 44896 var ownNamespace = container.namespaceURI || null; 44897 type = container.tagName; 44898 namespace = getChildNamespace(ownNamespace, type); 44899 break; 44900 } 44901 } 44902 44903 { 44904 var validatedTag = type.toLowerCase(); 44905 var ancestorInfo = updatedAncestorInfo(null, validatedTag); 44906 return { 44907 namespace: namespace, 44908 ancestorInfo: ancestorInfo 44909 }; 44910 } 44911} 44912function getChildHostContext(parentHostContext, type, rootContainerInstance) { 44913 { 44914 var parentHostContextDev = parentHostContext; 44915 var namespace = getChildNamespace(parentHostContextDev.namespace, type); 44916 var ancestorInfo = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type); 44917 return { 44918 namespace: namespace, 44919 ancestorInfo: ancestorInfo 44920 }; 44921 } 44922} 44923function getPublicInstance(instance) { 44924 return instance; 44925} 44926function prepareForCommit(containerInfo) { 44927 eventsEnabled = isEnabled(); 44928 selectionInformation = getSelectionInformation(); 44929 setEnabled(false); 44930} 44931function resetAfterCommit(containerInfo) { 44932 restoreSelection(selectionInformation); 44933 setEnabled(eventsEnabled); 44934 eventsEnabled = null; 44935 44936 selectionInformation = null; 44937} 44938function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) { 44939 var parentNamespace; 44940 44941 { 44942 // TODO: take namespace into account when validating. 44943 var hostContextDev = hostContext; 44944 validateDOMNesting(type, null, hostContextDev.ancestorInfo); 44945 44946 if (typeof props.children === 'string' || typeof props.children === 'number') { 44947 var string = '' + props.children; 44948 var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type); 44949 validateDOMNesting(null, string, ownAncestorInfo); 44950 } 44951 44952 parentNamespace = hostContextDev.namespace; 44953 } 44954 44955 var domElement = createElement(type, props, rootContainerInstance, parentNamespace); 44956 precacheFiberNode(internalInstanceHandle, domElement); 44957 updateFiberProps(domElement, props); 44958 return domElement; 44959} 44960function appendInitialChild(parentInstance, child) { 44961 parentInstance.appendChild(child); 44962} 44963function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) { 44964 setInitialProperties(domElement, type, props, rootContainerInstance); 44965 return shouldAutoFocusHostComponent(type, props); 44966} 44967function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) { 44968 { 44969 var hostContextDev = hostContext; 44970 44971 if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) { 44972 var string = '' + newProps.children; 44973 var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type); 44974 validateDOMNesting(null, string, ownAncestorInfo); 44975 } 44976 } 44977 44978 return diffProperties(domElement, type, oldProps, newProps, rootContainerInstance); 44979} 44980function shouldSetTextContent(type, props) { 44981 return type === 'textarea' || type === 'option' || type === 'noscript' || typeof props.children === 'string' || typeof props.children === 'number' || typeof props.dangerouslySetInnerHTML === 'object' && props.dangerouslySetInnerHTML !== null && props.dangerouslySetInnerHTML.__html != null; 44982} 44983function shouldDeprioritizeSubtree(type, props) { 44984 return !!props.hidden; 44985} 44986function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) { 44987 { 44988 var hostContextDev = hostContext; 44989 validateDOMNesting(null, text, hostContextDev.ancestorInfo); 44990 } 44991 44992 var textNode = createTextNode(text, rootContainerInstance); 44993 precacheFiberNode(internalInstanceHandle, textNode); 44994 return textNode; 44995} 44996// if a component just imports ReactDOM (e.g. for findDOMNode). 44997// Some environments might not have setTimeout or clearTimeout. 44998 44999var scheduleTimeout = typeof setTimeout === 'function' ? setTimeout : undefined; 45000var cancelTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined; 45001var noTimeout = -1; // ------------------- 45002function commitMount(domElement, type, newProps, internalInstanceHandle) { 45003 // Despite the naming that might imply otherwise, this method only 45004 // fires if there is an `Update` effect scheduled during mounting. 45005 // This happens if `finalizeInitialChildren` returns `true` (which it 45006 // does to implement the `autoFocus` attribute on the client). But 45007 // there are also other cases when this might happen (such as patching 45008 // up text content during hydration mismatch). So we'll check this again. 45009 if (shouldAutoFocusHostComponent(type, newProps)) { 45010 domElement.focus(); 45011 } 45012} 45013function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) { 45014 // Update the props handle so that we know which props are the ones with 45015 // with current event handlers. 45016 updateFiberProps(domElement, newProps); // Apply the diff to the DOM node. 45017 45018 updateProperties(domElement, updatePayload, type, oldProps, newProps); 45019} 45020function resetTextContent(domElement) { 45021 setTextContent(domElement, ''); 45022} 45023function commitTextUpdate(textInstance, oldText, newText) { 45024 textInstance.nodeValue = newText; 45025} 45026function appendChild(parentInstance, child) { 45027 parentInstance.appendChild(child); 45028} 45029function appendChildToContainer(container, child) { 45030 var parentNode; 45031 45032 if (container.nodeType === COMMENT_NODE) { 45033 parentNode = container.parentNode; 45034 parentNode.insertBefore(child, container); 45035 } else { 45036 parentNode = container; 45037 parentNode.appendChild(child); 45038 } // This container might be used for a portal. 45039 // If something inside a portal is clicked, that click should bubble 45040 // through the React tree. However, on Mobile Safari the click would 45041 // never bubble through the *DOM* tree unless an ancestor with onclick 45042 // event exists. So we wouldn't see it and dispatch it. 45043 // This is why we ensure that non React root containers have inline onclick 45044 // defined. 45045 // https://github.com/facebook/react/issues/11918 45046 45047 45048 var reactRootContainer = container._reactRootContainer; 45049 45050 if ((reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null) { 45051 // TODO: This cast may not be sound for SVG, MathML or custom elements. 45052 trapClickOnNonInteractiveElement(parentNode); 45053 } 45054} 45055function insertBefore(parentInstance, child, beforeChild) { 45056 parentInstance.insertBefore(child, beforeChild); 45057} 45058function insertInContainerBefore(container, child, beforeChild) { 45059 if (container.nodeType === COMMENT_NODE) { 45060 container.parentNode.insertBefore(child, beforeChild); 45061 } else { 45062 container.insertBefore(child, beforeChild); 45063 } 45064} 45065function removeChild(parentInstance, child) { 45066 parentInstance.removeChild(child); 45067} 45068function removeChildFromContainer(container, child) { 45069 if (container.nodeType === COMMENT_NODE) { 45070 container.parentNode.removeChild(child); 45071 } else { 45072 container.removeChild(child); 45073 } 45074} 45075 45076function hideInstance(instance) { 45077 // pass host context to this method? 45078 45079 45080 instance = instance; 45081 var style = instance.style; 45082 45083 if (typeof style.setProperty === 'function') { 45084 style.setProperty('display', 'none', 'important'); 45085 } else { 45086 style.display = 'none'; 45087 } 45088} 45089function hideTextInstance(textInstance) { 45090 textInstance.nodeValue = ''; 45091} 45092function unhideInstance(instance, props) { 45093 instance = instance; 45094 var styleProp = props[STYLE$1]; 45095 var display = styleProp !== undefined && styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display : null; 45096 instance.style.display = dangerousStyleValue('display', display); 45097} 45098function unhideTextInstance(textInstance, text) { 45099 textInstance.nodeValue = text; 45100} // ------------------- 45101function canHydrateInstance(instance, type, props) { 45102 if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) { 45103 return null; 45104 } // This has now been refined to an element node. 45105 45106 45107 return instance; 45108} 45109function canHydrateTextInstance(instance, text) { 45110 if (text === '' || instance.nodeType !== TEXT_NODE) { 45111 // Empty strings are not parsed by HTML so there won't be a correct match here. 45112 return null; 45113 } // This has now been refined to a text node. 45114 45115 45116 return instance; 45117} 45118function isSuspenseInstancePending(instance) { 45119 return instance.data === SUSPENSE_PENDING_START_DATA; 45120} 45121function isSuspenseInstanceFallback(instance) { 45122 return instance.data === SUSPENSE_FALLBACK_START_DATA; 45123} 45124 45125function getNextHydratable(node) { 45126 // Skip non-hydratable nodes. 45127 for (; node != null; node = node.nextSibling) { 45128 var nodeType = node.nodeType; 45129 45130 if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) { 45131 break; 45132 } 45133 } 45134 45135 return node; 45136} 45137 45138function getNextHydratableSibling(instance) { 45139 return getNextHydratable(instance.nextSibling); 45140} 45141function getFirstHydratableChild(parentInstance) { 45142 return getNextHydratable(parentInstance.firstChild); 45143} 45144function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) { 45145 precacheFiberNode(internalInstanceHandle, instance); // TODO: Possibly defer this until the commit phase where all the events 45146 // get attached. 45147 45148 updateFiberProps(instance, props); 45149 var parentNamespace; 45150 45151 { 45152 var hostContextDev = hostContext; 45153 parentNamespace = hostContextDev.namespace; 45154 } 45155 45156 return diffHydratedProperties(instance, type, props, parentNamespace, rootContainerInstance); 45157} 45158function hydrateTextInstance(textInstance, text, internalInstanceHandle) { 45159 precacheFiberNode(internalInstanceHandle, textInstance); 45160 return diffHydratedText(textInstance, text); 45161} 45162function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) { 45163 var node = suspenseInstance.nextSibling; // Skip past all nodes within this suspense boundary. 45164 // There might be nested nodes so we need to keep track of how 45165 // deep we are and only break out when we're back on top. 45166 45167 var depth = 0; 45168 45169 while (node) { 45170 if (node.nodeType === COMMENT_NODE) { 45171 var data = node.data; 45172 45173 if (data === SUSPENSE_END_DATA) { 45174 if (depth === 0) { 45175 return getNextHydratableSibling(node); 45176 } else { 45177 depth--; 45178 } 45179 } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { 45180 depth++; 45181 } 45182 } 45183 45184 node = node.nextSibling; 45185 } // TODO: Warn, we didn't find the end comment boundary. 45186 45187 45188 return null; 45189} // Returns the SuspenseInstance if this node is a direct child of a 45190// SuspenseInstance. I.e. if its previous sibling is a Comment with 45191// SUSPENSE_x_START_DATA. Otherwise, null. 45192 45193function getParentSuspenseInstance(targetInstance) { 45194 var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary. 45195 // There might be nested nodes so we need to keep track of how 45196 // deep we are and only break out when we're back on top. 45197 45198 var depth = 0; 45199 45200 while (node) { 45201 if (node.nodeType === COMMENT_NODE) { 45202 var data = node.data; 45203 45204 if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { 45205 if (depth === 0) { 45206 return node; 45207 } else { 45208 depth--; 45209 } 45210 } else if (data === SUSPENSE_END_DATA) { 45211 depth++; 45212 } 45213 } 45214 45215 node = node.previousSibling; 45216 } 45217 45218 return null; 45219} 45220function commitHydratedContainer(container) { 45221 // Retry if any event replaying was blocked on this. 45222 retryIfBlockedOn(container); 45223} 45224function commitHydratedSuspenseInstance(suspenseInstance) { 45225 // Retry if any event replaying was blocked on this. 45226 retryIfBlockedOn(suspenseInstance); 45227} 45228function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) { 45229 { 45230 warnForUnmatchedText(textInstance, text); 45231 } 45232} 45233function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) { 45234 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 45235 warnForUnmatchedText(textInstance, text); 45236 } 45237} 45238function didNotHydrateContainerInstance(parentContainer, instance) { 45239 { 45240 if (instance.nodeType === ELEMENT_NODE) { 45241 warnForDeletedHydratableElement(parentContainer, instance); 45242 } else if (instance.nodeType === COMMENT_NODE) ; else { 45243 warnForDeletedHydratableText(parentContainer, instance); 45244 } 45245 } 45246} 45247function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) { 45248 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 45249 if (instance.nodeType === ELEMENT_NODE) { 45250 warnForDeletedHydratableElement(parentInstance, instance); 45251 } else if (instance.nodeType === COMMENT_NODE) ; else { 45252 warnForDeletedHydratableText(parentInstance, instance); 45253 } 45254 } 45255} 45256function didNotFindHydratableContainerInstance(parentContainer, type, props) { 45257 { 45258 warnForInsertedHydratedElement(parentContainer, type); 45259 } 45260} 45261function didNotFindHydratableContainerTextInstance(parentContainer, text) { 45262 { 45263 warnForInsertedHydratedText(parentContainer, text); 45264 } 45265} 45266function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) { 45267 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 45268 warnForInsertedHydratedElement(parentInstance, type); 45269 } 45270} 45271function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) { 45272 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 45273 warnForInsertedHydratedText(parentInstance, text); 45274 } 45275} 45276function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) { 45277 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) ; 45278} 45279 45280var randomKey = Math.random().toString(36).slice(2); 45281var internalInstanceKey = '__reactInternalInstance$' + randomKey; 45282var internalEventHandlersKey = '__reactEventHandlers$' + randomKey; 45283var internalContainerInstanceKey = '__reactContainere$' + randomKey; 45284function precacheFiberNode(hostInst, node) { 45285 node[internalInstanceKey] = hostInst; 45286} 45287function markContainerAsRoot(hostRoot, node) { 45288 node[internalContainerInstanceKey] = hostRoot; 45289} 45290function unmarkContainerAsRoot(node) { 45291 node[internalContainerInstanceKey] = null; 45292} 45293function isContainerMarkedAsRoot(node) { 45294 return !!node[internalContainerInstanceKey]; 45295} // Given a DOM node, return the closest HostComponent or HostText fiber ancestor. 45296// If the target node is part of a hydrated or not yet rendered subtree, then 45297// this may also return a SuspenseComponent or HostRoot to indicate that. 45298// Conceptually the HostRoot fiber is a child of the Container node. So if you 45299// pass the Container node as the targetNode, you will not actually get the 45300// HostRoot back. To get to the HostRoot, you need to pass a child of it. 45301// The same thing applies to Suspense boundaries. 45302 45303function getClosestInstanceFromNode(targetNode) { 45304 var targetInst = targetNode[internalInstanceKey]; 45305 45306 if (targetInst) { 45307 // Don't return HostRoot or SuspenseComponent here. 45308 return targetInst; 45309 } // If the direct event target isn't a React owned DOM node, we need to look 45310 // to see if one of its parents is a React owned DOM node. 45311 45312 45313 var parentNode = targetNode.parentNode; 45314 45315 while (parentNode) { 45316 // We'll check if this is a container root that could include 45317 // React nodes in the future. We need to check this first because 45318 // if we're a child of a dehydrated container, we need to first 45319 // find that inner container before moving on to finding the parent 45320 // instance. Note that we don't check this field on the targetNode 45321 // itself because the fibers are conceptually between the container 45322 // node and the first child. It isn't surrounding the container node. 45323 // If it's not a container, we check if it's an instance. 45324 targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey]; 45325 45326 if (targetInst) { 45327 // Since this wasn't the direct target of the event, we might have 45328 // stepped past dehydrated DOM nodes to get here. However they could 45329 // also have been non-React nodes. We need to answer which one. 45330 // If we the instance doesn't have any children, then there can't be 45331 // a nested suspense boundary within it. So we can use this as a fast 45332 // bailout. Most of the time, when people add non-React children to 45333 // the tree, it is using a ref to a child-less DOM node. 45334 // Normally we'd only need to check one of the fibers because if it 45335 // has ever gone from having children to deleting them or vice versa 45336 // it would have deleted the dehydrated boundary nested inside already. 45337 // However, since the HostRoot starts out with an alternate it might 45338 // have one on the alternate so we need to check in case this was a 45339 // root. 45340 var alternate = targetInst.alternate; 45341 45342 if (targetInst.child !== null || alternate !== null && alternate.child !== null) { 45343 // Next we need to figure out if the node that skipped past is 45344 // nested within a dehydrated boundary and if so, which one. 45345 var suspenseInstance = getParentSuspenseInstance(targetNode); 45346 45347 while (suspenseInstance !== null) { 45348 // We found a suspense instance. That means that we haven't 45349 // hydrated it yet. Even though we leave the comments in the 45350 // DOM after hydrating, and there are boundaries in the DOM 45351 // that could already be hydrated, we wouldn't have found them 45352 // through this pass since if the target is hydrated it would 45353 // have had an internalInstanceKey on it. 45354 // Let's get the fiber associated with the SuspenseComponent 45355 // as the deepest instance. 45356 var targetSuspenseInst = suspenseInstance[internalInstanceKey]; 45357 45358 if (targetSuspenseInst) { 45359 return targetSuspenseInst; 45360 } // If we don't find a Fiber on the comment, it might be because 45361 // we haven't gotten to hydrate it yet. There might still be a 45362 // parent boundary that hasn't above this one so we need to find 45363 // the outer most that is known. 45364 45365 45366 suspenseInstance = getParentSuspenseInstance(suspenseInstance); // If we don't find one, then that should mean that the parent 45367 // host component also hasn't hydrated yet. We can return it 45368 // below since it will bail out on the isMounted check later. 45369 } 45370 } 45371 45372 return targetInst; 45373 } 45374 45375 targetNode = parentNode; 45376 parentNode = targetNode.parentNode; 45377 } 45378 45379 return null; 45380} 45381/** 45382 * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent 45383 * instance, or null if the node was not rendered by this React. 45384 */ 45385 45386function getInstanceFromNode$1(node) { 45387 var inst = node[internalInstanceKey] || node[internalContainerInstanceKey]; 45388 45389 if (inst) { 45390 if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) { 45391 return inst; 45392 } else { 45393 return null; 45394 } 45395 } 45396 45397 return null; 45398} 45399/** 45400 * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding 45401 * DOM node. 45402 */ 45403 45404function getNodeFromInstance$1(inst) { 45405 if (inst.tag === HostComponent || inst.tag === HostText) { 45406 // In Fiber this, is just the state node right now. We assume it will be 45407 // a host component or host text. 45408 return inst.stateNode; 45409 } // Without this first invariant, passing a non-DOM-component triggers the next 45410 // invariant for a missing parent, which is super confusing. 45411 45412 45413 { 45414 { 45415 throw Error( "getNodeFromInstance: Invalid argument." ); 45416 } 45417 } 45418} 45419function getFiberCurrentPropsFromNode$1(node) { 45420 return node[internalEventHandlersKey] || null; 45421} 45422function updateFiberProps(node, props) { 45423 node[internalEventHandlersKey] = props; 45424} 45425 45426function getParent(inst) { 45427 do { 45428 inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. 45429 // That is depending on if we want nested subtrees (layers) to bubble 45430 // events to their parent. We could also go through parentNode on the 45431 // host node but that wouldn't work for React Native and doesn't let us 45432 // do the portal feature. 45433 } while (inst && inst.tag !== HostComponent); 45434 45435 if (inst) { 45436 return inst; 45437 } 45438 45439 return null; 45440} 45441/** 45442 * Return the lowest common ancestor of A and B, or null if they are in 45443 * different trees. 45444 */ 45445 45446 45447function getLowestCommonAncestor(instA, instB) { 45448 var depthA = 0; 45449 45450 for (var tempA = instA; tempA; tempA = getParent(tempA)) { 45451 depthA++; 45452 } 45453 45454 var depthB = 0; 45455 45456 for (var tempB = instB; tempB; tempB = getParent(tempB)) { 45457 depthB++; 45458 } // If A is deeper, crawl up. 45459 45460 45461 while (depthA - depthB > 0) { 45462 instA = getParent(instA); 45463 depthA--; 45464 } // If B is deeper, crawl up. 45465 45466 45467 while (depthB - depthA > 0) { 45468 instB = getParent(instB); 45469 depthB--; 45470 } // Walk in lockstep until we find a match. 45471 45472 45473 var depth = depthA; 45474 45475 while (depth--) { 45476 if (instA === instB || instA === instB.alternate) { 45477 return instA; 45478 } 45479 45480 instA = getParent(instA); 45481 instB = getParent(instB); 45482 } 45483 45484 return null; 45485} 45486/** 45487 * Simulates the traversal of a two-phase, capture/bubble event dispatch. 45488 */ 45489 45490function traverseTwoPhase(inst, fn, arg) { 45491 var path = []; 45492 45493 while (inst) { 45494 path.push(inst); 45495 inst = getParent(inst); 45496 } 45497 45498 var i; 45499 45500 for (i = path.length; i-- > 0;) { 45501 fn(path[i], 'captured', arg); 45502 } 45503 45504 for (i = 0; i < path.length; i++) { 45505 fn(path[i], 'bubbled', arg); 45506 } 45507} 45508/** 45509 * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that 45510 * should would receive a `mouseEnter` or `mouseLeave` event. 45511 * 45512 * Does not invoke the callback on the nearest common ancestor because nothing 45513 * "entered" or "left" that element. 45514 */ 45515 45516function traverseEnterLeave(from, to, fn, argFrom, argTo) { 45517 var common = from && to ? getLowestCommonAncestor(from, to) : null; 45518 var pathFrom = []; 45519 45520 while (true) { 45521 if (!from) { 45522 break; 45523 } 45524 45525 if (from === common) { 45526 break; 45527 } 45528 45529 var alternate = from.alternate; 45530 45531 if (alternate !== null && alternate === common) { 45532 break; 45533 } 45534 45535 pathFrom.push(from); 45536 from = getParent(from); 45537 } 45538 45539 var pathTo = []; 45540 45541 while (true) { 45542 if (!to) { 45543 break; 45544 } 45545 45546 if (to === common) { 45547 break; 45548 } 45549 45550 var _alternate = to.alternate; 45551 45552 if (_alternate !== null && _alternate === common) { 45553 break; 45554 } 45555 45556 pathTo.push(to); 45557 to = getParent(to); 45558 } 45559 45560 for (var i = 0; i < pathFrom.length; i++) { 45561 fn(pathFrom[i], 'bubbled', argFrom); 45562 } 45563 45564 for (var _i = pathTo.length; _i-- > 0;) { 45565 fn(pathTo[_i], 'captured', argTo); 45566 } 45567} 45568 45569function isInteractive(tag) { 45570 return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; 45571} 45572 45573function shouldPreventMouseEvent(name, type, props) { 45574 switch (name) { 45575 case 'onClick': 45576 case 'onClickCapture': 45577 case 'onDoubleClick': 45578 case 'onDoubleClickCapture': 45579 case 'onMouseDown': 45580 case 'onMouseDownCapture': 45581 case 'onMouseMove': 45582 case 'onMouseMoveCapture': 45583 case 'onMouseUp': 45584 case 'onMouseUpCapture': 45585 case 'onMouseEnter': 45586 return !!(props.disabled && isInteractive(type)); 45587 45588 default: 45589 return false; 45590 } 45591} 45592/** 45593 * @param {object} inst The instance, which is the source of events. 45594 * @param {string} registrationName Name of listener (e.g. `onClick`). 45595 * @return {?function} The stored callback. 45596 */ 45597 45598 45599function getListener(inst, registrationName) { 45600 var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not 45601 // live here; needs to be moved to a better place soon 45602 45603 var stateNode = inst.stateNode; 45604 45605 if (!stateNode) { 45606 // Work in progress (ex: onload events in incremental mode). 45607 return null; 45608 } 45609 45610 var props = getFiberCurrentPropsFromNode(stateNode); 45611 45612 if (!props) { 45613 // Work in progress. 45614 return null; 45615 } 45616 45617 listener = props[registrationName]; 45618 45619 if (shouldPreventMouseEvent(registrationName, inst.type, props)) { 45620 return null; 45621 } 45622 45623 if (!(!listener || typeof listener === 'function')) { 45624 { 45625 throw Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type." ); 45626 } 45627 } 45628 45629 return listener; 45630} 45631 45632/** 45633 * Some event types have a notion of different registration names for different 45634 * "phases" of propagation. This finds listeners by a given phase. 45635 */ 45636function listenerAtPhase(inst, event, propagationPhase) { 45637 var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase]; 45638 return getListener(inst, registrationName); 45639} 45640/** 45641 * A small set of propagation patterns, each of which will accept a small amount 45642 * of information, and generate a set of "dispatch ready event objects" - which 45643 * are sets of events that have already been annotated with a set of dispatched 45644 * listener functions/ids. The API is designed this way to discourage these 45645 * propagation strategies from actually executing the dispatches, since we 45646 * always want to collect the entire set of dispatches before executing even a 45647 * single one. 45648 */ 45649 45650/** 45651 * Tags a `SyntheticEvent` with dispatched listeners. Creating this function 45652 * here, allows us to not have to bind or create functions for each event. 45653 * Mutating the event's members allows us to not have to create a wrapping 45654 * "dispatch" object that pairs the event with the listener. 45655 */ 45656 45657 45658function accumulateDirectionalDispatches(inst, phase, event) { 45659 { 45660 if (!inst) { 45661 error('Dispatching inst must not be null'); 45662 } 45663 } 45664 45665 var listener = listenerAtPhase(inst, event, phase); 45666 45667 if (listener) { 45668 event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); 45669 event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); 45670 } 45671} 45672/** 45673 * Collect dispatches (must be entirely collected before dispatching - see unit 45674 * tests). Lazily allocate the array to conserve memory. We must loop through 45675 * each event and perform the traversal for each one. We cannot perform a 45676 * single traversal for the entire collection of events because each event may 45677 * have a different target. 45678 */ 45679 45680 45681function accumulateTwoPhaseDispatchesSingle(event) { 45682 if (event && event.dispatchConfig.phasedRegistrationNames) { 45683 traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); 45684 } 45685} 45686/** 45687 * Accumulates without regard to direction, does not look for phased 45688 * registration names. Same as `accumulateDirectDispatchesSingle` but without 45689 * requiring that the `dispatchMarker` be the same as the dispatched ID. 45690 */ 45691 45692 45693function accumulateDispatches(inst, ignoredDirection, event) { 45694 if (inst && event && event.dispatchConfig.registrationName) { 45695 var registrationName = event.dispatchConfig.registrationName; 45696 var listener = getListener(inst, registrationName); 45697 45698 if (listener) { 45699 event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); 45700 event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); 45701 } 45702 } 45703} 45704/** 45705 * Accumulates dispatches on an `SyntheticEvent`, but only for the 45706 * `dispatchMarker`. 45707 * @param {SyntheticEvent} event 45708 */ 45709 45710 45711function accumulateDirectDispatchesSingle(event) { 45712 if (event && event.dispatchConfig.registrationName) { 45713 accumulateDispatches(event._targetInst, null, event); 45714 } 45715} 45716 45717function accumulateTwoPhaseDispatches(events) { 45718 forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); 45719} 45720function accumulateEnterLeaveDispatches(leave, enter, from, to) { 45721 traverseEnterLeave(from, to, accumulateDispatches, leave, enter); 45722} 45723function accumulateDirectDispatches(events) { 45724 forEachAccumulated(events, accumulateDirectDispatchesSingle); 45725} 45726 45727/** 45728 * These variables store information about text content of a target node, 45729 * allowing comparison of content before and after a given event. 45730 * 45731 * Identify the node where selection currently begins, then observe 45732 * both its text content and its current position in the DOM. Since the 45733 * browser may natively replace the target node during composition, we can 45734 * use its position to find its replacement. 45735 * 45736 * 45737 */ 45738var root = null; 45739var startText = null; 45740var fallbackText = null; 45741function initialize(nativeEventTarget) { 45742 root = nativeEventTarget; 45743 startText = getText(); 45744 return true; 45745} 45746function reset() { 45747 root = null; 45748 startText = null; 45749 fallbackText = null; 45750} 45751function getData() { 45752 if (fallbackText) { 45753 return fallbackText; 45754 } 45755 45756 var start; 45757 var startValue = startText; 45758 var startLength = startValue.length; 45759 var end; 45760 var endValue = getText(); 45761 var endLength = endValue.length; 45762 45763 for (start = 0; start < startLength; start++) { 45764 if (startValue[start] !== endValue[start]) { 45765 break; 45766 } 45767 } 45768 45769 var minEnd = startLength - start; 45770 45771 for (end = 1; end <= minEnd; end++) { 45772 if (startValue[startLength - end] !== endValue[endLength - end]) { 45773 break; 45774 } 45775 } 45776 45777 var sliceTail = end > 1 ? 1 - end : undefined; 45778 fallbackText = endValue.slice(start, sliceTail); 45779 return fallbackText; 45780} 45781function getText() { 45782 if ('value' in root) { 45783 return root.value; 45784 } 45785 45786 return root.textContent; 45787} 45788 45789var EVENT_POOL_SIZE = 10; 45790/** 45791 * @interface Event 45792 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 45793 */ 45794 45795var EventInterface = { 45796 type: null, 45797 target: null, 45798 // currentTarget is set when dispatching; no use in copying it here 45799 currentTarget: function () { 45800 return null; 45801 }, 45802 eventPhase: null, 45803 bubbles: null, 45804 cancelable: null, 45805 timeStamp: function (event) { 45806 return event.timeStamp || Date.now(); 45807 }, 45808 defaultPrevented: null, 45809 isTrusted: null 45810}; 45811 45812function functionThatReturnsTrue() { 45813 return true; 45814} 45815 45816function functionThatReturnsFalse() { 45817 return false; 45818} 45819/** 45820 * Synthetic events are dispatched by event plugins, typically in response to a 45821 * top-level event delegation handler. 45822 * 45823 * These systems should generally use pooling to reduce the frequency of garbage 45824 * collection. The system should check `isPersistent` to determine whether the 45825 * event should be released into the pool after being dispatched. Users that 45826 * need a persisted event should invoke `persist`. 45827 * 45828 * Synthetic events (and subclasses) implement the DOM Level 3 Events API by 45829 * normalizing browser quirks. Subclasses do not necessarily have to implement a 45830 * DOM interface; custom application-specific events can also subclass this. 45831 * 45832 * @param {object} dispatchConfig Configuration used to dispatch this event. 45833 * @param {*} targetInst Marker identifying the event target. 45834 * @param {object} nativeEvent Native browser event. 45835 * @param {DOMEventTarget} nativeEventTarget Target node. 45836 */ 45837 45838 45839function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) { 45840 { 45841 // these have a getter/setter for warnings 45842 delete this.nativeEvent; 45843 delete this.preventDefault; 45844 delete this.stopPropagation; 45845 delete this.isDefaultPrevented; 45846 delete this.isPropagationStopped; 45847 } 45848 45849 this.dispatchConfig = dispatchConfig; 45850 this._targetInst = targetInst; 45851 this.nativeEvent = nativeEvent; 45852 var Interface = this.constructor.Interface; 45853 45854 for (var propName in Interface) { 45855 if (!Interface.hasOwnProperty(propName)) { 45856 continue; 45857 } 45858 45859 { 45860 delete this[propName]; // this has a getter/setter for warnings 45861 } 45862 45863 var normalize = Interface[propName]; 45864 45865 if (normalize) { 45866 this[propName] = normalize(nativeEvent); 45867 } else { 45868 if (propName === 'target') { 45869 this.target = nativeEventTarget; 45870 } else { 45871 this[propName] = nativeEvent[propName]; 45872 } 45873 } 45874 } 45875 45876 var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false; 45877 45878 if (defaultPrevented) { 45879 this.isDefaultPrevented = functionThatReturnsTrue; 45880 } else { 45881 this.isDefaultPrevented = functionThatReturnsFalse; 45882 } 45883 45884 this.isPropagationStopped = functionThatReturnsFalse; 45885 return this; 45886} 45887 45888_assign(SyntheticEvent.prototype, { 45889 preventDefault: function () { 45890 this.defaultPrevented = true; 45891 var event = this.nativeEvent; 45892 45893 if (!event) { 45894 return; 45895 } 45896 45897 if (event.preventDefault) { 45898 event.preventDefault(); 45899 } else if (typeof event.returnValue !== 'unknown') { 45900 event.returnValue = false; 45901 } 45902 45903 this.isDefaultPrevented = functionThatReturnsTrue; 45904 }, 45905 stopPropagation: function () { 45906 var event = this.nativeEvent; 45907 45908 if (!event) { 45909 return; 45910 } 45911 45912 if (event.stopPropagation) { 45913 event.stopPropagation(); 45914 } else if (typeof event.cancelBubble !== 'unknown') { 45915 // The ChangeEventPlugin registers a "propertychange" event for 45916 // IE. This event does not support bubbling or cancelling, and 45917 // any references to cancelBubble throw "Member not found". A 45918 // typeof check of "unknown" circumvents this issue (and is also 45919 // IE specific). 45920 event.cancelBubble = true; 45921 } 45922 45923 this.isPropagationStopped = functionThatReturnsTrue; 45924 }, 45925 45926 /** 45927 * We release all dispatched `SyntheticEvent`s after each event loop, adding 45928 * them back into the pool. This allows a way to hold onto a reference that 45929 * won't be added back into the pool. 45930 */ 45931 persist: function () { 45932 this.isPersistent = functionThatReturnsTrue; 45933 }, 45934 45935 /** 45936 * Checks if this event should be released back into the pool. 45937 * 45938 * @return {boolean} True if this should not be released, false otherwise. 45939 */ 45940 isPersistent: functionThatReturnsFalse, 45941 45942 /** 45943 * `PooledClass` looks for `destructor` on each instance it releases. 45944 */ 45945 destructor: function () { 45946 var Interface = this.constructor.Interface; 45947 45948 for (var propName in Interface) { 45949 { 45950 Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName])); 45951 } 45952 } 45953 45954 this.dispatchConfig = null; 45955 this._targetInst = null; 45956 this.nativeEvent = null; 45957 this.isDefaultPrevented = functionThatReturnsFalse; 45958 this.isPropagationStopped = functionThatReturnsFalse; 45959 this._dispatchListeners = null; 45960 this._dispatchInstances = null; 45961 45962 { 45963 Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null)); 45964 Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse)); 45965 Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse)); 45966 Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {})); 45967 Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {})); 45968 } 45969 } 45970}); 45971 45972SyntheticEvent.Interface = EventInterface; 45973/** 45974 * Helper to reduce boilerplate when creating subclasses. 45975 */ 45976 45977SyntheticEvent.extend = function (Interface) { 45978 var Super = this; 45979 45980 var E = function () {}; 45981 45982 E.prototype = Super.prototype; 45983 var prototype = new E(); 45984 45985 function Class() { 45986 return Super.apply(this, arguments); 45987 } 45988 45989 _assign(prototype, Class.prototype); 45990 45991 Class.prototype = prototype; 45992 Class.prototype.constructor = Class; 45993 Class.Interface = _assign({}, Super.Interface, Interface); 45994 Class.extend = Super.extend; 45995 addEventPoolingTo(Class); 45996 return Class; 45997}; 45998 45999addEventPoolingTo(SyntheticEvent); 46000/** 46001 * Helper to nullify syntheticEvent instance properties when destructing 46002 * 46003 * @param {String} propName 46004 * @param {?object} getVal 46005 * @return {object} defineProperty object 46006 */ 46007 46008function getPooledWarningPropertyDefinition(propName, getVal) { 46009 var isFunction = typeof getVal === 'function'; 46010 return { 46011 configurable: true, 46012 set: set, 46013 get: get 46014 }; 46015 46016 function set(val) { 46017 var action = isFunction ? 'setting the method' : 'setting the property'; 46018 warn(action, 'This is effectively a no-op'); 46019 return val; 46020 } 46021 46022 function get() { 46023 var action = isFunction ? 'accessing the method' : 'accessing the property'; 46024 var result = isFunction ? 'This is a no-op function' : 'This is set to null'; 46025 warn(action, result); 46026 return getVal; 46027 } 46028 46029 function warn(action, result) { 46030 { 46031 error("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); 46032 } 46033 } 46034} 46035 46036function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { 46037 var EventConstructor = this; 46038 46039 if (EventConstructor.eventPool.length) { 46040 var instance = EventConstructor.eventPool.pop(); 46041 EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); 46042 return instance; 46043 } 46044 46045 return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst); 46046} 46047 46048function releasePooledEvent(event) { 46049 var EventConstructor = this; 46050 46051 if (!(event instanceof EventConstructor)) { 46052 { 46053 throw Error( "Trying to release an event instance into a pool of a different type." ); 46054 } 46055 } 46056 46057 event.destructor(); 46058 46059 if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) { 46060 EventConstructor.eventPool.push(event); 46061 } 46062} 46063 46064function addEventPoolingTo(EventConstructor) { 46065 EventConstructor.eventPool = []; 46066 EventConstructor.getPooled = getPooledEvent; 46067 EventConstructor.release = releasePooledEvent; 46068} 46069 46070/** 46071 * @interface Event 46072 * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents 46073 */ 46074 46075var SyntheticCompositionEvent = SyntheticEvent.extend({ 46076 data: null 46077}); 46078 46079/** 46080 * @interface Event 46081 * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105 46082 * /#events-inputevents 46083 */ 46084 46085var SyntheticInputEvent = SyntheticEvent.extend({ 46086 data: null 46087}); 46088 46089var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space 46090 46091var START_KEYCODE = 229; 46092var canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window; 46093var documentMode = null; 46094 46095if (canUseDOM && 'documentMode' in document) { 46096 documentMode = document.documentMode; 46097} // Webkit offers a very useful `textInput` event that can be used to 46098// directly represent `beforeInput`. The IE `textinput` event is not as 46099// useful, so we don't use it. 46100 46101 46102var canUseTextInputEvent = canUseDOM && 'TextEvent' in window && !documentMode; // In IE9+, we have access to composition events, but the data supplied 46103// by the native compositionend event may be incorrect. Japanese ideographic 46104// spaces, for instance (\u3000) are not recorded correctly. 46105 46106var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11); 46107var SPACEBAR_CODE = 32; 46108var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); // Events and their corresponding property names. 46109 46110var eventTypes = { 46111 beforeInput: { 46112 phasedRegistrationNames: { 46113 bubbled: 'onBeforeInput', 46114 captured: 'onBeforeInputCapture' 46115 }, 46116 dependencies: [TOP_COMPOSITION_END, TOP_KEY_PRESS, TOP_TEXT_INPUT, TOP_PASTE] 46117 }, 46118 compositionEnd: { 46119 phasedRegistrationNames: { 46120 bubbled: 'onCompositionEnd', 46121 captured: 'onCompositionEndCapture' 46122 }, 46123 dependencies: [TOP_BLUR, TOP_COMPOSITION_END, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN] 46124 }, 46125 compositionStart: { 46126 phasedRegistrationNames: { 46127 bubbled: 'onCompositionStart', 46128 captured: 'onCompositionStartCapture' 46129 }, 46130 dependencies: [TOP_BLUR, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN] 46131 }, 46132 compositionUpdate: { 46133 phasedRegistrationNames: { 46134 bubbled: 'onCompositionUpdate', 46135 captured: 'onCompositionUpdateCapture' 46136 }, 46137 dependencies: [TOP_BLUR, TOP_COMPOSITION_UPDATE, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN] 46138 } 46139}; // Track whether we've ever handled a keypress on the space key. 46140 46141var hasSpaceKeypress = false; 46142/** 46143 * Return whether a native keypress event is assumed to be a command. 46144 * This is required because Firefox fires `keypress` events for key commands 46145 * (cut, copy, select-all, etc.) even though no character is inserted. 46146 */ 46147 46148function isKeypressCommand(nativeEvent) { 46149 return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && // ctrlKey && altKey is equivalent to AltGr, and is not a command. 46150 !(nativeEvent.ctrlKey && nativeEvent.altKey); 46151} 46152/** 46153 * Translate native top level events into event types. 46154 * 46155 * @param {string} topLevelType 46156 * @return {object} 46157 */ 46158 46159 46160function getCompositionEventType(topLevelType) { 46161 switch (topLevelType) { 46162 case TOP_COMPOSITION_START: 46163 return eventTypes.compositionStart; 46164 46165 case TOP_COMPOSITION_END: 46166 return eventTypes.compositionEnd; 46167 46168 case TOP_COMPOSITION_UPDATE: 46169 return eventTypes.compositionUpdate; 46170 } 46171} 46172/** 46173 * Does our fallback best-guess model think this event signifies that 46174 * composition has begun? 46175 * 46176 * @param {string} topLevelType 46177 * @param {object} nativeEvent 46178 * @return {boolean} 46179 */ 46180 46181 46182function isFallbackCompositionStart(topLevelType, nativeEvent) { 46183 return topLevelType === TOP_KEY_DOWN && nativeEvent.keyCode === START_KEYCODE; 46184} 46185/** 46186 * Does our fallback mode think that this event is the end of composition? 46187 * 46188 * @param {string} topLevelType 46189 * @param {object} nativeEvent 46190 * @return {boolean} 46191 */ 46192 46193 46194function isFallbackCompositionEnd(topLevelType, nativeEvent) { 46195 switch (topLevelType) { 46196 case TOP_KEY_UP: 46197 // Command keys insert or clear IME input. 46198 return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; 46199 46200 case TOP_KEY_DOWN: 46201 // Expect IME keyCode on each keydown. If we get any other 46202 // code we must have exited earlier. 46203 return nativeEvent.keyCode !== START_KEYCODE; 46204 46205 case TOP_KEY_PRESS: 46206 case TOP_MOUSE_DOWN: 46207 case TOP_BLUR: 46208 // Events are not possible without cancelling IME. 46209 return true; 46210 46211 default: 46212 return false; 46213 } 46214} 46215/** 46216 * Google Input Tools provides composition data via a CustomEvent, 46217 * with the `data` property populated in the `detail` object. If this 46218 * is available on the event object, use it. If not, this is a plain 46219 * composition event and we have nothing special to extract. 46220 * 46221 * @param {object} nativeEvent 46222 * @return {?string} 46223 */ 46224 46225 46226function getDataFromCustomEvent(nativeEvent) { 46227 var detail = nativeEvent.detail; 46228 46229 if (typeof detail === 'object' && 'data' in detail) { 46230 return detail.data; 46231 } 46232 46233 return null; 46234} 46235/** 46236 * Check if a composition event was triggered by Korean IME. 46237 * Our fallback mode does not work well with IE's Korean IME, 46238 * so just use native composition events when Korean IME is used. 46239 * Although CompositionEvent.locale property is deprecated, 46240 * it is available in IE, where our fallback mode is enabled. 46241 * 46242 * @param {object} nativeEvent 46243 * @return {boolean} 46244 */ 46245 46246 46247function isUsingKoreanIME(nativeEvent) { 46248 return nativeEvent.locale === 'ko'; 46249} // Track the current IME composition status, if any. 46250 46251 46252var isComposing = false; 46253/** 46254 * @return {?object} A SyntheticCompositionEvent. 46255 */ 46256 46257function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { 46258 var eventType; 46259 var fallbackData; 46260 46261 if (canUseCompositionEvent) { 46262 eventType = getCompositionEventType(topLevelType); 46263 } else if (!isComposing) { 46264 if (isFallbackCompositionStart(topLevelType, nativeEvent)) { 46265 eventType = eventTypes.compositionStart; 46266 } 46267 } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) { 46268 eventType = eventTypes.compositionEnd; 46269 } 46270 46271 if (!eventType) { 46272 return null; 46273 } 46274 46275 if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) { 46276 // The current composition is stored statically and must not be 46277 // overwritten while composition continues. 46278 if (!isComposing && eventType === eventTypes.compositionStart) { 46279 isComposing = initialize(nativeEventTarget); 46280 } else if (eventType === eventTypes.compositionEnd) { 46281 if (isComposing) { 46282 fallbackData = getData(); 46283 } 46284 } 46285 } 46286 46287 var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget); 46288 46289 if (fallbackData) { 46290 // Inject data generated from fallback path into the synthetic event. 46291 // This matches the property of native CompositionEventInterface. 46292 event.data = fallbackData; 46293 } else { 46294 var customData = getDataFromCustomEvent(nativeEvent); 46295 46296 if (customData !== null) { 46297 event.data = customData; 46298 } 46299 } 46300 46301 accumulateTwoPhaseDispatches(event); 46302 return event; 46303} 46304/** 46305 * @param {TopLevelType} topLevelType Number from `TopLevelType`. 46306 * @param {object} nativeEvent Native browser event. 46307 * @return {?string} The string corresponding to this `beforeInput` event. 46308 */ 46309 46310 46311function getNativeBeforeInputChars(topLevelType, nativeEvent) { 46312 switch (topLevelType) { 46313 case TOP_COMPOSITION_END: 46314 return getDataFromCustomEvent(nativeEvent); 46315 46316 case TOP_KEY_PRESS: 46317 /** 46318 * If native `textInput` events are available, our goal is to make 46319 * use of them. However, there is a special case: the spacebar key. 46320 * In Webkit, preventing default on a spacebar `textInput` event 46321 * cancels character insertion, but it *also* causes the browser 46322 * to fall back to its default spacebar behavior of scrolling the 46323 * page. 46324 * 46325 * Tracking at: 46326 * https://code.google.com/p/chromium/issues/detail?id=355103 46327 * 46328 * To avoid this issue, use the keypress event as if no `textInput` 46329 * event is available. 46330 */ 46331 var which = nativeEvent.which; 46332 46333 if (which !== SPACEBAR_CODE) { 46334 return null; 46335 } 46336 46337 hasSpaceKeypress = true; 46338 return SPACEBAR_CHAR; 46339 46340 case TOP_TEXT_INPUT: 46341 // Record the characters to be added to the DOM. 46342 var chars = nativeEvent.data; // If it's a spacebar character, assume that we have already handled 46343 // it at the keypress level and bail immediately. Android Chrome 46344 // doesn't give us keycodes, so we need to ignore it. 46345 46346 if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { 46347 return null; 46348 } 46349 46350 return chars; 46351 46352 default: 46353 // For other native event types, do nothing. 46354 return null; 46355 } 46356} 46357/** 46358 * For browsers that do not provide the `textInput` event, extract the 46359 * appropriate string to use for SyntheticInputEvent. 46360 * 46361 * @param {number} topLevelType Number from `TopLevelEventTypes`. 46362 * @param {object} nativeEvent Native browser event. 46363 * @return {?string} The fallback string for this `beforeInput` event. 46364 */ 46365 46366 46367function getFallbackBeforeInputChars(topLevelType, nativeEvent) { 46368 // If we are currently composing (IME) and using a fallback to do so, 46369 // try to extract the composed characters from the fallback object. 46370 // If composition event is available, we extract a string only at 46371 // compositionevent, otherwise extract it at fallback events. 46372 if (isComposing) { 46373 if (topLevelType === TOP_COMPOSITION_END || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) { 46374 var chars = getData(); 46375 reset(); 46376 isComposing = false; 46377 return chars; 46378 } 46379 46380 return null; 46381 } 46382 46383 switch (topLevelType) { 46384 case TOP_PASTE: 46385 // If a paste event occurs after a keypress, throw out the input 46386 // chars. Paste events should not lead to BeforeInput events. 46387 return null; 46388 46389 case TOP_KEY_PRESS: 46390 /** 46391 * As of v27, Firefox may fire keypress events even when no character 46392 * will be inserted. A few possibilities: 46393 * 46394 * - `which` is `0`. Arrow keys, Esc key, etc. 46395 * 46396 * - `which` is the pressed key code, but no char is available. 46397 * Ex: 'AltGr + d` in Polish. There is no modified character for 46398 * this key combination and no character is inserted into the 46399 * document, but FF fires the keypress for char code `100` anyway. 46400 * No `input` event will occur. 46401 * 46402 * - `which` is the pressed key code, but a command combination is 46403 * being used. Ex: `Cmd+C`. No character is inserted, and no 46404 * `input` event will occur. 46405 */ 46406 if (!isKeypressCommand(nativeEvent)) { 46407 // IE fires the `keypress` event when a user types an emoji via 46408 // Touch keyboard of Windows. In such a case, the `char` property 46409 // holds an emoji character like `\uD83D\uDE0A`. Because its length 46410 // is 2, the property `which` does not represent an emoji correctly. 46411 // In such a case, we directly return the `char` property instead of 46412 // using `which`. 46413 if (nativeEvent.char && nativeEvent.char.length > 1) { 46414 return nativeEvent.char; 46415 } else if (nativeEvent.which) { 46416 return String.fromCharCode(nativeEvent.which); 46417 } 46418 } 46419 46420 return null; 46421 46422 case TOP_COMPOSITION_END: 46423 return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data; 46424 46425 default: 46426 return null; 46427 } 46428} 46429/** 46430 * Extract a SyntheticInputEvent for `beforeInput`, based on either native 46431 * `textInput` or fallback behavior. 46432 * 46433 * @return {?object} A SyntheticInputEvent. 46434 */ 46435 46436 46437function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { 46438 var chars; 46439 46440 if (canUseTextInputEvent) { 46441 chars = getNativeBeforeInputChars(topLevelType, nativeEvent); 46442 } else { 46443 chars = getFallbackBeforeInputChars(topLevelType, nativeEvent); 46444 } // If no characters are being inserted, no BeforeInput event should 46445 // be fired. 46446 46447 46448 if (!chars) { 46449 return null; 46450 } 46451 46452 var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget); 46453 event.data = chars; 46454 accumulateTwoPhaseDispatches(event); 46455 return event; 46456} 46457/** 46458 * Create an `onBeforeInput` event to match 46459 * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents. 46460 * 46461 * This event plugin is based on the native `textInput` event 46462 * available in Chrome, Safari, Opera, and IE. This event fires after 46463 * `onKeyPress` and `onCompositionEnd`, but before `onInput`. 46464 * 46465 * `beforeInput` is spec'd but not implemented in any browsers, and 46466 * the `input` event does not provide any useful information about what has 46467 * actually been added, contrary to the spec. Thus, `textInput` is the best 46468 * available event to identify the characters that have actually been inserted 46469 * into the target node. 46470 * 46471 * This plugin is also responsible for emitting `composition` events, thus 46472 * allowing us to share composition fallback code for both `beforeInput` and 46473 * `composition` event types. 46474 */ 46475 46476 46477var BeforeInputEventPlugin = { 46478 eventTypes: eventTypes, 46479 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { 46480 var composition = extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget); 46481 var beforeInput = extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget); 46482 46483 if (composition === null) { 46484 return beforeInput; 46485 } 46486 46487 if (beforeInput === null) { 46488 return composition; 46489 } 46490 46491 return [composition, beforeInput]; 46492 } 46493}; 46494 46495/** 46496 * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary 46497 */ 46498var supportedInputTypes = { 46499 color: true, 46500 date: true, 46501 datetime: true, 46502 'datetime-local': true, 46503 email: true, 46504 month: true, 46505 number: true, 46506 password: true, 46507 range: true, 46508 search: true, 46509 tel: true, 46510 text: true, 46511 time: true, 46512 url: true, 46513 week: true 46514}; 46515 46516function isTextInputElement(elem) { 46517 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); 46518 46519 if (nodeName === 'input') { 46520 return !!supportedInputTypes[elem.type]; 46521 } 46522 46523 if (nodeName === 'textarea') { 46524 return true; 46525 } 46526 46527 return false; 46528} 46529 46530var eventTypes$1 = { 46531 change: { 46532 phasedRegistrationNames: { 46533 bubbled: 'onChange', 46534 captured: 'onChangeCapture' 46535 }, 46536 dependencies: [TOP_BLUR, TOP_CHANGE, TOP_CLICK, TOP_FOCUS, TOP_INPUT, TOP_KEY_DOWN, TOP_KEY_UP, TOP_SELECTION_CHANGE] 46537 } 46538}; 46539 46540function createAndAccumulateChangeEvent(inst, nativeEvent, target) { 46541 var event = SyntheticEvent.getPooled(eventTypes$1.change, inst, nativeEvent, target); 46542 event.type = 'change'; // Flag this event loop as needing state restore. 46543 46544 enqueueStateRestore(target); 46545 accumulateTwoPhaseDispatches(event); 46546 return event; 46547} 46548/** 46549 * For IE shims 46550 */ 46551 46552 46553var activeElement = null; 46554var activeElementInst = null; 46555/** 46556 * SECTION: handle `change` event 46557 */ 46558 46559function shouldUseChangeEvent(elem) { 46560 var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); 46561 return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; 46562} 46563 46564function manualDispatchChangeEvent(nativeEvent) { 46565 var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent)); // If change and propertychange bubbled, we'd just bind to it like all the 46566 // other events and have it go through ReactBrowserEventEmitter. Since it 46567 // doesn't, we manually listen for the events and so we have to enqueue and 46568 // process the abstract event manually. 46569 // 46570 // Batching is necessary here in order to ensure that all event handlers run 46571 // before the next rerender (including event handlers attached to ancestor 46572 // elements instead of directly on the input). Without this, controlled 46573 // components don't work properly in conjunction with event bubbling because 46574 // the component is rerendered and the value reverted before all the event 46575 // handlers can run. See https://github.com/facebook/react/issues/708. 46576 46577 batchedUpdates(runEventInBatch, event); 46578} 46579 46580function runEventInBatch(event) { 46581 runEventsInBatch(event); 46582} 46583 46584function getInstIfValueChanged(targetInst) { 46585 var targetNode = getNodeFromInstance$1(targetInst); 46586 46587 if (updateValueIfChanged(targetNode)) { 46588 return targetInst; 46589 } 46590} 46591 46592function getTargetInstForChangeEvent(topLevelType, targetInst) { 46593 if (topLevelType === TOP_CHANGE) { 46594 return targetInst; 46595 } 46596} 46597/** 46598 * SECTION: handle `input` event 46599 */ 46600 46601 46602var isInputEventSupported = false; 46603 46604if (canUseDOM) { 46605 // IE9 claims to support the input event but fails to trigger it when 46606 // deleting text, so we ignore its input events. 46607 isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9); 46608} 46609/** 46610 * (For IE <=9) Starts tracking propertychange events on the passed-in element 46611 * and override the value property so that we can distinguish user events from 46612 * value changes in JS. 46613 */ 46614 46615 46616function startWatchingForValueChange(target, targetInst) { 46617 activeElement = target; 46618 activeElementInst = targetInst; 46619 activeElement.attachEvent('onpropertychange', handlePropertyChange); 46620} 46621/** 46622 * (For IE <=9) Removes the event listeners from the currently-tracked element, 46623 * if any exists. 46624 */ 46625 46626 46627function stopWatchingForValueChange() { 46628 if (!activeElement) { 46629 return; 46630 } 46631 46632 activeElement.detachEvent('onpropertychange', handlePropertyChange); 46633 activeElement = null; 46634 activeElementInst = null; 46635} 46636/** 46637 * (For IE <=9) Handles a propertychange event, sending a `change` event if 46638 * the value of the active element has changed. 46639 */ 46640 46641 46642function handlePropertyChange(nativeEvent) { 46643 if (nativeEvent.propertyName !== 'value') { 46644 return; 46645 } 46646 46647 if (getInstIfValueChanged(activeElementInst)) { 46648 manualDispatchChangeEvent(nativeEvent); 46649 } 46650} 46651 46652function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) { 46653 if (topLevelType === TOP_FOCUS) { 46654 // In IE9, propertychange fires for most input events but is buggy and 46655 // doesn't fire when text is deleted, but conveniently, selectionchange 46656 // appears to fire in all of the remaining cases so we catch those and 46657 // forward the event if the value has changed 46658 // In either case, we don't want to call the event handler if the value 46659 // is changed from JS so we redefine a setter for `.value` that updates 46660 // our activeElementValue variable, allowing us to ignore those changes 46661 // 46662 // stopWatching() should be a noop here but we call it just in case we 46663 // missed a blur event somehow. 46664 stopWatchingForValueChange(); 46665 startWatchingForValueChange(target, targetInst); 46666 } else if (topLevelType === TOP_BLUR) { 46667 stopWatchingForValueChange(); 46668 } 46669} // For IE8 and IE9. 46670 46671 46672function getTargetInstForInputEventPolyfill(topLevelType, targetInst) { 46673 if (topLevelType === TOP_SELECTION_CHANGE || topLevelType === TOP_KEY_UP || topLevelType === TOP_KEY_DOWN) { 46674 // On the selectionchange event, the target is just document which isn't 46675 // helpful for us so just check activeElement instead. 46676 // 46677 // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire 46678 // propertychange on the first input event after setting `value` from a 46679 // script and fires only keydown, keypress, keyup. Catching keyup usually 46680 // gets it and catching keydown lets us fire an event for the first 46681 // keystroke if user does a key repeat (it'll be a little delayed: right 46682 // before the second keystroke). Other input methods (e.g., paste) seem to 46683 // fire selectionchange normally. 46684 return getInstIfValueChanged(activeElementInst); 46685 } 46686} 46687/** 46688 * SECTION: handle `click` event 46689 */ 46690 46691 46692function shouldUseClickEvent(elem) { 46693 // Use the `click` event to detect changes to checkbox and radio inputs. 46694 // This approach works across all browsers, whereas `change` does not fire 46695 // until `blur` in IE8. 46696 var nodeName = elem.nodeName; 46697 return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); 46698} 46699 46700function getTargetInstForClickEvent(topLevelType, targetInst) { 46701 if (topLevelType === TOP_CLICK) { 46702 return getInstIfValueChanged(targetInst); 46703 } 46704} 46705 46706function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) { 46707 if (topLevelType === TOP_INPUT || topLevelType === TOP_CHANGE) { 46708 return getInstIfValueChanged(targetInst); 46709 } 46710} 46711 46712function handleControlledInputBlur(node) { 46713 var state = node._wrapperState; 46714 46715 if (!state || !state.controlled || node.type !== 'number') { 46716 return; 46717 } 46718 46719 { 46720 // If controlled, assign the value attribute to the current value on blur 46721 setDefaultValue(node, 'number', node.value); 46722 } 46723} 46724/** 46725 * This plugin creates an `onChange` event that normalizes change events 46726 * across form elements. This event fires at a time when it's possible to 46727 * change the element's value without seeing a flicker. 46728 * 46729 * Supported elements are: 46730 * - input (see `isTextInputElement`) 46731 * - textarea 46732 * - select 46733 */ 46734 46735 46736var ChangeEventPlugin = { 46737 eventTypes: eventTypes$1, 46738 _isInputEventSupported: isInputEventSupported, 46739 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { 46740 var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window; 46741 var getTargetInstFunc, handleEventFunc; 46742 46743 if (shouldUseChangeEvent(targetNode)) { 46744 getTargetInstFunc = getTargetInstForChangeEvent; 46745 } else if (isTextInputElement(targetNode)) { 46746 if (isInputEventSupported) { 46747 getTargetInstFunc = getTargetInstForInputOrChangeEvent; 46748 } else { 46749 getTargetInstFunc = getTargetInstForInputEventPolyfill; 46750 handleEventFunc = handleEventsForInputEventPolyfill; 46751 } 46752 } else if (shouldUseClickEvent(targetNode)) { 46753 getTargetInstFunc = getTargetInstForClickEvent; 46754 } 46755 46756 if (getTargetInstFunc) { 46757 var inst = getTargetInstFunc(topLevelType, targetInst); 46758 46759 if (inst) { 46760 var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget); 46761 return event; 46762 } 46763 } 46764 46765 if (handleEventFunc) { 46766 handleEventFunc(topLevelType, targetNode, targetInst); 46767 } // When blurring, set the value attribute for number inputs 46768 46769 46770 if (topLevelType === TOP_BLUR) { 46771 handleControlledInputBlur(targetNode); 46772 } 46773 } 46774}; 46775 46776var SyntheticUIEvent = SyntheticEvent.extend({ 46777 view: null, 46778 detail: null 46779}); 46780 46781/** 46782 * Translation from modifier key to the associated property in the event. 46783 * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers 46784 */ 46785var modifierKeyToProp = { 46786 Alt: 'altKey', 46787 Control: 'ctrlKey', 46788 Meta: 'metaKey', 46789 Shift: 'shiftKey' 46790}; // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support 46791// getModifierState. If getModifierState is not supported, we map it to a set of 46792// modifier keys exposed by the event. In this case, Lock-keys are not supported. 46793 46794function modifierStateGetter(keyArg) { 46795 var syntheticEvent = this; 46796 var nativeEvent = syntheticEvent.nativeEvent; 46797 46798 if (nativeEvent.getModifierState) { 46799 return nativeEvent.getModifierState(keyArg); 46800 } 46801 46802 var keyProp = modifierKeyToProp[keyArg]; 46803 return keyProp ? !!nativeEvent[keyProp] : false; 46804} 46805 46806function getEventModifierState(nativeEvent) { 46807 return modifierStateGetter; 46808} 46809 46810var previousScreenX = 0; 46811var previousScreenY = 0; // Use flags to signal movementX/Y has already been set 46812 46813var isMovementXSet = false; 46814var isMovementYSet = false; 46815/** 46816 * @interface MouseEvent 46817 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 46818 */ 46819 46820var SyntheticMouseEvent = SyntheticUIEvent.extend({ 46821 screenX: null, 46822 screenY: null, 46823 clientX: null, 46824 clientY: null, 46825 pageX: null, 46826 pageY: null, 46827 ctrlKey: null, 46828 shiftKey: null, 46829 altKey: null, 46830 metaKey: null, 46831 getModifierState: getEventModifierState, 46832 button: null, 46833 buttons: null, 46834 relatedTarget: function (event) { 46835 return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement); 46836 }, 46837 movementX: function (event) { 46838 if ('movementX' in event) { 46839 return event.movementX; 46840 } 46841 46842 var screenX = previousScreenX; 46843 previousScreenX = event.screenX; 46844 46845 if (!isMovementXSet) { 46846 isMovementXSet = true; 46847 return 0; 46848 } 46849 46850 return event.type === 'mousemove' ? event.screenX - screenX : 0; 46851 }, 46852 movementY: function (event) { 46853 if ('movementY' in event) { 46854 return event.movementY; 46855 } 46856 46857 var screenY = previousScreenY; 46858 previousScreenY = event.screenY; 46859 46860 if (!isMovementYSet) { 46861 isMovementYSet = true; 46862 return 0; 46863 } 46864 46865 return event.type === 'mousemove' ? event.screenY - screenY : 0; 46866 } 46867}); 46868 46869/** 46870 * @interface PointerEvent 46871 * @see http://www.w3.org/TR/pointerevents/ 46872 */ 46873 46874var SyntheticPointerEvent = SyntheticMouseEvent.extend({ 46875 pointerId: null, 46876 width: null, 46877 height: null, 46878 pressure: null, 46879 tangentialPressure: null, 46880 tiltX: null, 46881 tiltY: null, 46882 twist: null, 46883 pointerType: null, 46884 isPrimary: null 46885}); 46886 46887var eventTypes$2 = { 46888 mouseEnter: { 46889 registrationName: 'onMouseEnter', 46890 dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER] 46891 }, 46892 mouseLeave: { 46893 registrationName: 'onMouseLeave', 46894 dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER] 46895 }, 46896 pointerEnter: { 46897 registrationName: 'onPointerEnter', 46898 dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER] 46899 }, 46900 pointerLeave: { 46901 registrationName: 'onPointerLeave', 46902 dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER] 46903 } 46904}; 46905var EnterLeaveEventPlugin = { 46906 eventTypes: eventTypes$2, 46907 46908 /** 46909 * For almost every interaction we care about, there will be both a top-level 46910 * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that 46911 * we do not extract duplicate events. However, moving the mouse into the 46912 * browser from outside will not fire a `mouseout` event. In this case, we use 46913 * the `mouseover` top-level event. 46914 */ 46915 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { 46916 var isOverEvent = topLevelType === TOP_MOUSE_OVER || topLevelType === TOP_POINTER_OVER; 46917 var isOutEvent = topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_POINTER_OUT; 46918 46919 if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0 && (nativeEvent.relatedTarget || nativeEvent.fromElement)) { 46920 // If this is an over event with a target, then we've already dispatched 46921 // the event in the out event of the other target. If this is replayed, 46922 // then it's because we couldn't dispatch against this target previously 46923 // so we have to do it now instead. 46924 return null; 46925 } 46926 46927 if (!isOutEvent && !isOverEvent) { 46928 // Must not be a mouse or pointer in or out - ignoring. 46929 return null; 46930 } 46931 46932 var win; 46933 46934 if (nativeEventTarget.window === nativeEventTarget) { 46935 // `nativeEventTarget` is probably a window object. 46936 win = nativeEventTarget; 46937 } else { 46938 // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8. 46939 var doc = nativeEventTarget.ownerDocument; 46940 46941 if (doc) { 46942 win = doc.defaultView || doc.parentWindow; 46943 } else { 46944 win = window; 46945 } 46946 } 46947 46948 var from; 46949 var to; 46950 46951 if (isOutEvent) { 46952 from = targetInst; 46953 var related = nativeEvent.relatedTarget || nativeEvent.toElement; 46954 to = related ? getClosestInstanceFromNode(related) : null; 46955 46956 if (to !== null) { 46957 var nearestMounted = getNearestMountedFiber(to); 46958 46959 if (to !== nearestMounted || to.tag !== HostComponent && to.tag !== HostText) { 46960 to = null; 46961 } 46962 } 46963 } else { 46964 // Moving to a node from outside the window. 46965 from = null; 46966 to = targetInst; 46967 } 46968 46969 if (from === to) { 46970 // Nothing pertains to our managed components. 46971 return null; 46972 } 46973 46974 var eventInterface, leaveEventType, enterEventType, eventTypePrefix; 46975 46976 if (topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_MOUSE_OVER) { 46977 eventInterface = SyntheticMouseEvent; 46978 leaveEventType = eventTypes$2.mouseLeave; 46979 enterEventType = eventTypes$2.mouseEnter; 46980 eventTypePrefix = 'mouse'; 46981 } else if (topLevelType === TOP_POINTER_OUT || topLevelType === TOP_POINTER_OVER) { 46982 eventInterface = SyntheticPointerEvent; 46983 leaveEventType = eventTypes$2.pointerLeave; 46984 enterEventType = eventTypes$2.pointerEnter; 46985 eventTypePrefix = 'pointer'; 46986 } 46987 46988 var fromNode = from == null ? win : getNodeFromInstance$1(from); 46989 var toNode = to == null ? win : getNodeFromInstance$1(to); 46990 var leave = eventInterface.getPooled(leaveEventType, from, nativeEvent, nativeEventTarget); 46991 leave.type = eventTypePrefix + 'leave'; 46992 leave.target = fromNode; 46993 leave.relatedTarget = toNode; 46994 var enter = eventInterface.getPooled(enterEventType, to, nativeEvent, nativeEventTarget); 46995 enter.type = eventTypePrefix + 'enter'; 46996 enter.target = toNode; 46997 enter.relatedTarget = fromNode; 46998 accumulateEnterLeaveDispatches(leave, enter, from, to); // If we are not processing the first ancestor, then we 46999 // should not process the same nativeEvent again, as we 47000 // will have already processed it in the first ancestor. 47001 47002 if ((eventSystemFlags & IS_FIRST_ANCESTOR) === 0) { 47003 return [leave]; 47004 } 47005 47006 return [leave, enter]; 47007 } 47008}; 47009 47010/** 47011 * inlined Object.is polyfill to avoid requiring consumers ship their own 47012 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is 47013 */ 47014function is(x, y) { 47015 return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare 47016 ; 47017} 47018 47019var objectIs = typeof Object.is === 'function' ? Object.is : is; 47020 47021var hasOwnProperty$2 = Object.prototype.hasOwnProperty; 47022/** 47023 * Performs equality by iterating through keys on an object and returning false 47024 * when any key has values which are not strictly equal between the arguments. 47025 * Returns true when the values of all keys are strictly equal. 47026 */ 47027 47028function shallowEqual(objA, objB) { 47029 if (objectIs(objA, objB)) { 47030 return true; 47031 } 47032 47033 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { 47034 return false; 47035 } 47036 47037 var keysA = Object.keys(objA); 47038 var keysB = Object.keys(objB); 47039 47040 if (keysA.length !== keysB.length) { 47041 return false; 47042 } // Test for A's keys different from B. 47043 47044 47045 for (var i = 0; i < keysA.length; i++) { 47046 if (!hasOwnProperty$2.call(objB, keysA[i]) || !objectIs(objA[keysA[i]], objB[keysA[i]])) { 47047 return false; 47048 } 47049 } 47050 47051 return true; 47052} 47053 47054var skipSelectionChangeEvent = canUseDOM && 'documentMode' in document && document.documentMode <= 11; 47055var eventTypes$3 = { 47056 select: { 47057 phasedRegistrationNames: { 47058 bubbled: 'onSelect', 47059 captured: 'onSelectCapture' 47060 }, 47061 dependencies: [TOP_BLUR, TOP_CONTEXT_MENU, TOP_DRAG_END, TOP_FOCUS, TOP_KEY_DOWN, TOP_KEY_UP, TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_SELECTION_CHANGE] 47062 } 47063}; 47064var activeElement$1 = null; 47065var activeElementInst$1 = null; 47066var lastSelection = null; 47067var mouseDown = false; 47068/** 47069 * Get an object which is a unique representation of the current selection. 47070 * 47071 * The return value will not be consistent across nodes or browsers, but 47072 * two identical selections on the same node will return identical objects. 47073 * 47074 * @param {DOMElement} node 47075 * @return {object} 47076 */ 47077 47078function getSelection$1(node) { 47079 if ('selectionStart' in node && hasSelectionCapabilities(node)) { 47080 return { 47081 start: node.selectionStart, 47082 end: node.selectionEnd 47083 }; 47084 } else { 47085 var win = node.ownerDocument && node.ownerDocument.defaultView || window; 47086 var selection = win.getSelection(); 47087 return { 47088 anchorNode: selection.anchorNode, 47089 anchorOffset: selection.anchorOffset, 47090 focusNode: selection.focusNode, 47091 focusOffset: selection.focusOffset 47092 }; 47093 } 47094} 47095/** 47096 * Get document associated with the event target. 47097 * 47098 * @param {object} nativeEventTarget 47099 * @return {Document} 47100 */ 47101 47102 47103function getEventTargetDocument(eventTarget) { 47104 return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument; 47105} 47106/** 47107 * Poll selection to see whether it's changed. 47108 * 47109 * @param {object} nativeEvent 47110 * @param {object} nativeEventTarget 47111 * @return {?SyntheticEvent} 47112 */ 47113 47114 47115function constructSelectEvent(nativeEvent, nativeEventTarget) { 47116 // Ensure we have the right element, and that the user is not dragging a 47117 // selection (this matches native `select` event behavior). In HTML5, select 47118 // fires only on input and textarea thus if there's no focused element we 47119 // won't dispatch. 47120 var doc = getEventTargetDocument(nativeEventTarget); 47121 47122 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) { 47123 return null; 47124 } // Only fire when selection has actually changed. 47125 47126 47127 var currentSelection = getSelection$1(activeElement$1); 47128 47129 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { 47130 lastSelection = currentSelection; 47131 var syntheticEvent = SyntheticEvent.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget); 47132 syntheticEvent.type = 'select'; 47133 syntheticEvent.target = activeElement$1; 47134 accumulateTwoPhaseDispatches(syntheticEvent); 47135 return syntheticEvent; 47136 } 47137 47138 return null; 47139} 47140/** 47141 * This plugin creates an `onSelect` event that normalizes select events 47142 * across form elements. 47143 * 47144 * Supported elements are: 47145 * - input (see `isTextInputElement`) 47146 * - textarea 47147 * - contentEditable 47148 * 47149 * This differs from native browser implementations in the following ways: 47150 * - Fires on contentEditable fields as well as inputs. 47151 * - Fires for collapsed selection. 47152 * - Fires after user input. 47153 */ 47154 47155 47156var SelectEventPlugin = { 47157 eventTypes: eventTypes$3, 47158 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, container) { 47159 var containerOrDoc = container || getEventTargetDocument(nativeEventTarget); // Track whether all listeners exists for this plugin. If none exist, we do 47160 // not extract events. See #3639. 47161 47162 if (!containerOrDoc || !isListeningToAllDependencies('onSelect', containerOrDoc)) { 47163 return null; 47164 } 47165 47166 var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window; 47167 47168 switch (topLevelType) { 47169 // Track the input node that has focus. 47170 case TOP_FOCUS: 47171 if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') { 47172 activeElement$1 = targetNode; 47173 activeElementInst$1 = targetInst; 47174 lastSelection = null; 47175 } 47176 47177 break; 47178 47179 case TOP_BLUR: 47180 activeElement$1 = null; 47181 activeElementInst$1 = null; 47182 lastSelection = null; 47183 break; 47184 // Don't fire the event while the user is dragging. This matches the 47185 // semantics of the native select event. 47186 47187 case TOP_MOUSE_DOWN: 47188 mouseDown = true; 47189 break; 47190 47191 case TOP_CONTEXT_MENU: 47192 case TOP_MOUSE_UP: 47193 case TOP_DRAG_END: 47194 mouseDown = false; 47195 return constructSelectEvent(nativeEvent, nativeEventTarget); 47196 // Chrome and IE fire non-standard event when selection is changed (and 47197 // sometimes when it hasn't). IE's event fires out of order with respect 47198 // to key and input events on deletion, so we discard it. 47199 // 47200 // Firefox doesn't support selectionchange, so check selection status 47201 // after each key entry. The selection changes after keydown and before 47202 // keyup, but we check on keydown as well in the case of holding down a 47203 // key, when multiple keydown events are fired but only one keyup is. 47204 // This is also our approach for IE handling, for the reason above. 47205 47206 case TOP_SELECTION_CHANGE: 47207 if (skipSelectionChangeEvent) { 47208 break; 47209 } 47210 47211 // falls through 47212 47213 case TOP_KEY_DOWN: 47214 case TOP_KEY_UP: 47215 return constructSelectEvent(nativeEvent, nativeEventTarget); 47216 } 47217 47218 return null; 47219 } 47220}; 47221 47222/** 47223 * @interface Event 47224 * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface 47225 * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent 47226 */ 47227 47228var SyntheticAnimationEvent = SyntheticEvent.extend({ 47229 animationName: null, 47230 elapsedTime: null, 47231 pseudoElement: null 47232}); 47233 47234/** 47235 * @interface Event 47236 * @see http://www.w3.org/TR/clipboard-apis/ 47237 */ 47238 47239var SyntheticClipboardEvent = SyntheticEvent.extend({ 47240 clipboardData: function (event) { 47241 return 'clipboardData' in event ? event.clipboardData : window.clipboardData; 47242 } 47243}); 47244 47245/** 47246 * @interface FocusEvent 47247 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 47248 */ 47249 47250var SyntheticFocusEvent = SyntheticUIEvent.extend({ 47251 relatedTarget: null 47252}); 47253 47254/** 47255 * `charCode` represents the actual "character code" and is safe to use with 47256 * `String.fromCharCode`. As such, only keys that correspond to printable 47257 * characters produce a valid `charCode`, the only exception to this is Enter. 47258 * The Tab-key is considered non-printable and does not have a `charCode`, 47259 * presumably because it does not produce a tab-character in browsers. 47260 * 47261 * @param {object} nativeEvent Native browser event. 47262 * @return {number} Normalized `charCode` property. 47263 */ 47264function getEventCharCode(nativeEvent) { 47265 var charCode; 47266 var keyCode = nativeEvent.keyCode; 47267 47268 if ('charCode' in nativeEvent) { 47269 charCode = nativeEvent.charCode; // FF does not set `charCode` for the Enter-key, check against `keyCode`. 47270 47271 if (charCode === 0 && keyCode === 13) { 47272 charCode = 13; 47273 } 47274 } else { 47275 // IE8 does not implement `charCode`, but `keyCode` has the correct value. 47276 charCode = keyCode; 47277 } // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux) 47278 // report Enter as charCode 10 when ctrl is pressed. 47279 47280 47281 if (charCode === 10) { 47282 charCode = 13; 47283 } // Some non-printable keys are reported in `charCode`/`keyCode`, discard them. 47284 // Must not discard the (non-)printable Enter-key. 47285 47286 47287 if (charCode >= 32 || charCode === 13) { 47288 return charCode; 47289 } 47290 47291 return 0; 47292} 47293 47294/** 47295 * Normalization of deprecated HTML5 `key` values 47296 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names 47297 */ 47298 47299var normalizeKey = { 47300 Esc: 'Escape', 47301 Spacebar: ' ', 47302 Left: 'ArrowLeft', 47303 Up: 'ArrowUp', 47304 Right: 'ArrowRight', 47305 Down: 'ArrowDown', 47306 Del: 'Delete', 47307 Win: 'OS', 47308 Menu: 'ContextMenu', 47309 Apps: 'ContextMenu', 47310 Scroll: 'ScrollLock', 47311 MozPrintableKey: 'Unidentified' 47312}; 47313/** 47314 * Translation from legacy `keyCode` to HTML5 `key` 47315 * Only special keys supported, all others depend on keyboard layout or browser 47316 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names 47317 */ 47318 47319var translateToKey = { 47320 '8': 'Backspace', 47321 '9': 'Tab', 47322 '12': 'Clear', 47323 '13': 'Enter', 47324 '16': 'Shift', 47325 '17': 'Control', 47326 '18': 'Alt', 47327 '19': 'Pause', 47328 '20': 'CapsLock', 47329 '27': 'Escape', 47330 '32': ' ', 47331 '33': 'PageUp', 47332 '34': 'PageDown', 47333 '35': 'End', 47334 '36': 'Home', 47335 '37': 'ArrowLeft', 47336 '38': 'ArrowUp', 47337 '39': 'ArrowRight', 47338 '40': 'ArrowDown', 47339 '45': 'Insert', 47340 '46': 'Delete', 47341 '112': 'F1', 47342 '113': 'F2', 47343 '114': 'F3', 47344 '115': 'F4', 47345 '116': 'F5', 47346 '117': 'F6', 47347 '118': 'F7', 47348 '119': 'F8', 47349 '120': 'F9', 47350 '121': 'F10', 47351 '122': 'F11', 47352 '123': 'F12', 47353 '144': 'NumLock', 47354 '145': 'ScrollLock', 47355 '224': 'Meta' 47356}; 47357/** 47358 * @param {object} nativeEvent Native browser event. 47359 * @return {string} Normalized `key` property. 47360 */ 47361 47362function getEventKey(nativeEvent) { 47363 if (nativeEvent.key) { 47364 // Normalize inconsistent values reported by browsers due to 47365 // implementations of a working draft specification. 47366 // FireFox implements `key` but returns `MozPrintableKey` for all 47367 // printable characters (normalized to `Unidentified`), ignore it. 47368 var key = normalizeKey[nativeEvent.key] || nativeEvent.key; 47369 47370 if (key !== 'Unidentified') { 47371 return key; 47372 } 47373 } // Browser does not implement `key`, polyfill as much of it as we can. 47374 47375 47376 if (nativeEvent.type === 'keypress') { 47377 var charCode = getEventCharCode(nativeEvent); // The enter-key is technically both printable and non-printable and can 47378 // thus be captured by `keypress`, no other non-printable key should. 47379 47380 return charCode === 13 ? 'Enter' : String.fromCharCode(charCode); 47381 } 47382 47383 if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') { 47384 // While user keyboard layout determines the actual meaning of each 47385 // `keyCode` value, almost all function keys have a universal value. 47386 return translateToKey[nativeEvent.keyCode] || 'Unidentified'; 47387 } 47388 47389 return ''; 47390} 47391 47392/** 47393 * @interface KeyboardEvent 47394 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 47395 */ 47396 47397var SyntheticKeyboardEvent = SyntheticUIEvent.extend({ 47398 key: getEventKey, 47399 location: null, 47400 ctrlKey: null, 47401 shiftKey: null, 47402 altKey: null, 47403 metaKey: null, 47404 repeat: null, 47405 locale: null, 47406 getModifierState: getEventModifierState, 47407 // Legacy Interface 47408 charCode: function (event) { 47409 // `charCode` is the result of a KeyPress event and represents the value of 47410 // the actual printable character. 47411 // KeyPress is deprecated, but its replacement is not yet final and not 47412 // implemented in any major browser. Only KeyPress has charCode. 47413 if (event.type === 'keypress') { 47414 return getEventCharCode(event); 47415 } 47416 47417 return 0; 47418 }, 47419 keyCode: function (event) { 47420 // `keyCode` is the result of a KeyDown/Up event and represents the value of 47421 // physical keyboard key. 47422 // The actual meaning of the value depends on the users' keyboard layout 47423 // which cannot be detected. Assuming that it is a US keyboard layout 47424 // provides a surprisingly accurate mapping for US and European users. 47425 // Due to this, it is left to the user to implement at this time. 47426 if (event.type === 'keydown' || event.type === 'keyup') { 47427 return event.keyCode; 47428 } 47429 47430 return 0; 47431 }, 47432 which: function (event) { 47433 // `which` is an alias for either `keyCode` or `charCode` depending on the 47434 // type of the event. 47435 if (event.type === 'keypress') { 47436 return getEventCharCode(event); 47437 } 47438 47439 if (event.type === 'keydown' || event.type === 'keyup') { 47440 return event.keyCode; 47441 } 47442 47443 return 0; 47444 } 47445}); 47446 47447/** 47448 * @interface DragEvent 47449 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 47450 */ 47451 47452var SyntheticDragEvent = SyntheticMouseEvent.extend({ 47453 dataTransfer: null 47454}); 47455 47456/** 47457 * @interface TouchEvent 47458 * @see http://www.w3.org/TR/touch-events/ 47459 */ 47460 47461var SyntheticTouchEvent = SyntheticUIEvent.extend({ 47462 touches: null, 47463 targetTouches: null, 47464 changedTouches: null, 47465 altKey: null, 47466 metaKey: null, 47467 ctrlKey: null, 47468 shiftKey: null, 47469 getModifierState: getEventModifierState 47470}); 47471 47472/** 47473 * @interface Event 47474 * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events- 47475 * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent 47476 */ 47477 47478var SyntheticTransitionEvent = SyntheticEvent.extend({ 47479 propertyName: null, 47480 elapsedTime: null, 47481 pseudoElement: null 47482}); 47483 47484/** 47485 * @interface WheelEvent 47486 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 47487 */ 47488 47489var SyntheticWheelEvent = SyntheticMouseEvent.extend({ 47490 deltaX: function (event) { 47491 return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive). 47492 'wheelDeltaX' in event ? -event.wheelDeltaX : 0; 47493 }, 47494 deltaY: function (event) { 47495 return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive). 47496 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive). 47497 'wheelDelta' in event ? -event.wheelDelta : 0; 47498 }, 47499 deltaZ: null, 47500 // Browsers without "deltaMode" is reporting in raw wheel delta where one 47501 // notch on the scroll is always +/- 120, roughly equivalent to pixels. 47502 // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or 47503 // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size. 47504 deltaMode: null 47505}); 47506 47507var 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]; 47508var SimpleEventPlugin = { 47509 // simpleEventPluginEventTypes gets populated from 47510 // the DOMEventProperties module. 47511 eventTypes: simpleEventPluginEventTypes, 47512 extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { 47513 var dispatchConfig = topLevelEventsToDispatchConfig.get(topLevelType); 47514 47515 if (!dispatchConfig) { 47516 return null; 47517 } 47518 47519 var EventConstructor; 47520 47521 switch (topLevelType) { 47522 case TOP_KEY_PRESS: 47523 // Firefox creates a keypress event for function keys too. This removes 47524 // the unwanted keypress events. Enter is however both printable and 47525 // non-printable. One would expect Tab to be as well (but it isn't). 47526 if (getEventCharCode(nativeEvent) === 0) { 47527 return null; 47528 } 47529 47530 /* falls through */ 47531 47532 case TOP_KEY_DOWN: 47533 case TOP_KEY_UP: 47534 EventConstructor = SyntheticKeyboardEvent; 47535 break; 47536 47537 case TOP_BLUR: 47538 case TOP_FOCUS: 47539 EventConstructor = SyntheticFocusEvent; 47540 break; 47541 47542 case TOP_CLICK: 47543 // Firefox creates a click event on right mouse clicks. This removes the 47544 // unwanted click events. 47545 if (nativeEvent.button === 2) { 47546 return null; 47547 } 47548 47549 /* falls through */ 47550 47551 case TOP_AUX_CLICK: 47552 case TOP_DOUBLE_CLICK: 47553 case TOP_MOUSE_DOWN: 47554 case TOP_MOUSE_MOVE: 47555 case TOP_MOUSE_UP: // TODO: Disabled elements should not respond to mouse events 47556 47557 /* falls through */ 47558 47559 case TOP_MOUSE_OUT: 47560 case TOP_MOUSE_OVER: 47561 case TOP_CONTEXT_MENU: 47562 EventConstructor = SyntheticMouseEvent; 47563 break; 47564 47565 case TOP_DRAG: 47566 case TOP_DRAG_END: 47567 case TOP_DRAG_ENTER: 47568 case TOP_DRAG_EXIT: 47569 case TOP_DRAG_LEAVE: 47570 case TOP_DRAG_OVER: 47571 case TOP_DRAG_START: 47572 case TOP_DROP: 47573 EventConstructor = SyntheticDragEvent; 47574 break; 47575 47576 case TOP_TOUCH_CANCEL: 47577 case TOP_TOUCH_END: 47578 case TOP_TOUCH_MOVE: 47579 case TOP_TOUCH_START: 47580 EventConstructor = SyntheticTouchEvent; 47581 break; 47582 47583 case TOP_ANIMATION_END: 47584 case TOP_ANIMATION_ITERATION: 47585 case TOP_ANIMATION_START: 47586 EventConstructor = SyntheticAnimationEvent; 47587 break; 47588 47589 case TOP_TRANSITION_END: 47590 EventConstructor = SyntheticTransitionEvent; 47591 break; 47592 47593 case TOP_SCROLL: 47594 EventConstructor = SyntheticUIEvent; 47595 break; 47596 47597 case TOP_WHEEL: 47598 EventConstructor = SyntheticWheelEvent; 47599 break; 47600 47601 case TOP_COPY: 47602 case TOP_CUT: 47603 case TOP_PASTE: 47604 EventConstructor = SyntheticClipboardEvent; 47605 break; 47606 47607 case TOP_GOT_POINTER_CAPTURE: 47608 case TOP_LOST_POINTER_CAPTURE: 47609 case TOP_POINTER_CANCEL: 47610 case TOP_POINTER_DOWN: 47611 case TOP_POINTER_MOVE: 47612 case TOP_POINTER_OUT: 47613 case TOP_POINTER_OVER: 47614 case TOP_POINTER_UP: 47615 EventConstructor = SyntheticPointerEvent; 47616 break; 47617 47618 default: 47619 { 47620 if (knownHTMLTopLevelTypes.indexOf(topLevelType) === -1) { 47621 error('SimpleEventPlugin: Unhandled event type, `%s`. This warning ' + 'is likely caused by a bug in React. Please file an issue.', topLevelType); 47622 } 47623 } // HTML Events 47624 // @see http://www.w3.org/TR/html5/index.html#events-0 47625 47626 47627 EventConstructor = SyntheticEvent; 47628 break; 47629 } 47630 47631 var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget); 47632 accumulateTwoPhaseDispatches(event); 47633 return event; 47634 } 47635}; 47636 47637/** 47638 * Specifies a deterministic ordering of `EventPlugin`s. A convenient way to 47639 * reason about plugins, without having to package every one of them. This 47640 * is better than having plugins be ordered in the same order that they 47641 * are injected because that ordering would be influenced by the packaging order. 47642 * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that 47643 * preventing default on events is convenient in `SimpleEventPlugin` handlers. 47644 */ 47645 47646var DOMEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin']; 47647/** 47648 * Inject modules for resolving DOM hierarchy and plugin ordering. 47649 */ 47650 47651injectEventPluginOrder(DOMEventPluginOrder); 47652setComponentTree(getFiberCurrentPropsFromNode$1, getInstanceFromNode$1, getNodeFromInstance$1); 47653/** 47654 * Some important event plugins included by default (without having to require 47655 * them). 47656 */ 47657 47658injectEventPluginsByName({ 47659 SimpleEventPlugin: SimpleEventPlugin, 47660 EnterLeaveEventPlugin: EnterLeaveEventPlugin, 47661 ChangeEventPlugin: ChangeEventPlugin, 47662 SelectEventPlugin: SelectEventPlugin, 47663 BeforeInputEventPlugin: BeforeInputEventPlugin 47664}); 47665 47666// Prefix measurements so that it's possible to filter them. 47667// Longer prefixes are hard to read in DevTools. 47668var reactEmoji = "\u269B"; 47669var warningEmoji = "\u26D4"; 47670var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; // Keep track of current fiber so that we know the path to unwind on pause. 47671// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them? 47672 47673var currentFiber = null; // If we're in the middle of user code, which fiber and method is it? 47674// Reusing `currentFiber` would be confusing for this because user code fiber 47675// can change during commit phase too, but we don't need to unwind it (since 47676// lifecycles in the commit phase don't resemble a tree). 47677 47678var currentPhase = null; 47679var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem, 47680// so we will keep track of it, and include it in the report. 47681// Track commits caused by cascading updates. 47682 47683var isCommitting = false; 47684var hasScheduledUpdateInCurrentCommit = false; 47685var hasScheduledUpdateInCurrentPhase = false; 47686var commitCountInCurrentWorkLoop = 0; 47687var effectCountInCurrentCommit = 0; 47688// to avoid stretch the commit phase with measurement overhead. 47689 47690var labelsInCurrentCommit = new Set(); 47691 47692var formatMarkName = function (markName) { 47693 return reactEmoji + " " + markName; 47694}; 47695 47696var formatLabel = function (label, warning) { 47697 var prefix = warning ? warningEmoji + " " : reactEmoji + " "; 47698 var suffix = warning ? " Warning: " + warning : ''; 47699 return "" + prefix + label + suffix; 47700}; 47701 47702var beginMark = function (markName) { 47703 performance.mark(formatMarkName(markName)); 47704}; 47705 47706var clearMark = function (markName) { 47707 performance.clearMarks(formatMarkName(markName)); 47708}; 47709 47710var endMark = function (label, markName, warning) { 47711 var formattedMarkName = formatMarkName(markName); 47712 var formattedLabel = formatLabel(label, warning); 47713 47714 try { 47715 performance.measure(formattedLabel, formattedMarkName); 47716 } catch (err) {} // If previous mark was missing for some reason, this will throw. 47717 // This could only happen if React crashed in an unexpected place earlier. 47718 // Don't pile on with more errors. 47719 // Clear marks immediately to avoid growing buffer. 47720 47721 47722 performance.clearMarks(formattedMarkName); 47723 performance.clearMeasures(formattedLabel); 47724}; 47725 47726var getFiberMarkName = function (label, debugID) { 47727 return label + " (#" + debugID + ")"; 47728}; 47729 47730var getFiberLabel = function (componentName, isMounted, phase) { 47731 if (phase === null) { 47732 // These are composite component total time measurements. 47733 return componentName + " [" + (isMounted ? 'update' : 'mount') + "]"; 47734 } else { 47735 // Composite component methods. 47736 return componentName + "." + phase; 47737 } 47738}; 47739 47740var beginFiberMark = function (fiber, phase) { 47741 var componentName = getComponentName(fiber.type) || 'Unknown'; 47742 var debugID = fiber._debugID; 47743 var isMounted = fiber.alternate !== null; 47744 var label = getFiberLabel(componentName, isMounted, phase); 47745 47746 if (isCommitting && labelsInCurrentCommit.has(label)) { 47747 // During the commit phase, we don't show duplicate labels because 47748 // there is a fixed overhead for every measurement, and we don't 47749 // want to stretch the commit phase beyond necessary. 47750 return false; 47751 } 47752 47753 labelsInCurrentCommit.add(label); 47754 var markName = getFiberMarkName(label, debugID); 47755 beginMark(markName); 47756 return true; 47757}; 47758 47759var clearFiberMark = function (fiber, phase) { 47760 var componentName = getComponentName(fiber.type) || 'Unknown'; 47761 var debugID = fiber._debugID; 47762 var isMounted = fiber.alternate !== null; 47763 var label = getFiberLabel(componentName, isMounted, phase); 47764 var markName = getFiberMarkName(label, debugID); 47765 clearMark(markName); 47766}; 47767 47768var endFiberMark = function (fiber, phase, warning) { 47769 var componentName = getComponentName(fiber.type) || 'Unknown'; 47770 var debugID = fiber._debugID; 47771 var isMounted = fiber.alternate !== null; 47772 var label = getFiberLabel(componentName, isMounted, phase); 47773 var markName = getFiberMarkName(label, debugID); 47774 endMark(label, markName, warning); 47775}; 47776 47777var shouldIgnoreFiber = function (fiber) { 47778 // Host components should be skipped in the timeline. 47779 // We could check typeof fiber.type, but does this work with RN? 47780 switch (fiber.tag) { 47781 case HostRoot: 47782 case HostComponent: 47783 case HostText: 47784 case HostPortal: 47785 case Fragment: 47786 case ContextProvider: 47787 case ContextConsumer: 47788 case Mode: 47789 return true; 47790 47791 default: 47792 return false; 47793 } 47794}; 47795 47796var clearPendingPhaseMeasurement = function () { 47797 if (currentPhase !== null && currentPhaseFiber !== null) { 47798 clearFiberMark(currentPhaseFiber, currentPhase); 47799 } 47800 47801 currentPhaseFiber = null; 47802 currentPhase = null; 47803 hasScheduledUpdateInCurrentPhase = false; 47804}; 47805 47806var pauseTimers = function () { 47807 // Stops all currently active measurements so that they can be resumed 47808 // if we continue in a later deferred loop from the same unit of work. 47809 var fiber = currentFiber; 47810 47811 while (fiber) { 47812 if (fiber._debugIsCurrentlyTiming) { 47813 endFiberMark(fiber, null, null); 47814 } 47815 47816 fiber = fiber.return; 47817 } 47818}; 47819 47820var resumeTimersRecursively = function (fiber) { 47821 if (fiber.return !== null) { 47822 resumeTimersRecursively(fiber.return); 47823 } 47824 47825 if (fiber._debugIsCurrentlyTiming) { 47826 beginFiberMark(fiber, null); 47827 } 47828}; 47829 47830var resumeTimers = function () { 47831 // Resumes all measurements that were active during the last deferred loop. 47832 if (currentFiber !== null) { 47833 resumeTimersRecursively(currentFiber); 47834 } 47835}; 47836 47837function recordEffect() { 47838 { 47839 effectCountInCurrentCommit++; 47840 } 47841} 47842function recordScheduleUpdate() { 47843 { 47844 if (isCommitting) { 47845 hasScheduledUpdateInCurrentCommit = true; 47846 } 47847 47848 if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') { 47849 hasScheduledUpdateInCurrentPhase = true; 47850 } 47851 } 47852} 47853function startWorkTimer(fiber) { 47854 { 47855 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 47856 return; 47857 } // If we pause, this is the fiber to unwind from. 47858 47859 47860 currentFiber = fiber; 47861 47862 if (!beginFiberMark(fiber, null)) { 47863 return; 47864 } 47865 47866 fiber._debugIsCurrentlyTiming = true; 47867 } 47868} 47869function cancelWorkTimer(fiber) { 47870 { 47871 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 47872 return; 47873 } // Remember we shouldn't complete measurement for this fiber. 47874 // Otherwise flamechart will be deep even for small updates. 47875 47876 47877 fiber._debugIsCurrentlyTiming = false; 47878 clearFiberMark(fiber, null); 47879 } 47880} 47881function stopWorkTimer(fiber) { 47882 { 47883 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 47884 return; 47885 } // If we pause, its parent is the fiber to unwind from. 47886 47887 47888 currentFiber = fiber.return; 47889 47890 if (!fiber._debugIsCurrentlyTiming) { 47891 return; 47892 } 47893 47894 fiber._debugIsCurrentlyTiming = false; 47895 endFiberMark(fiber, null, null); 47896 } 47897} 47898function stopFailedWorkTimer(fiber) { 47899 { 47900 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { 47901 return; 47902 } // If we pause, its parent is the fiber to unwind from. 47903 47904 47905 currentFiber = fiber.return; 47906 47907 if (!fiber._debugIsCurrentlyTiming) { 47908 return; 47909 } 47910 47911 fiber._debugIsCurrentlyTiming = false; 47912 var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary'; 47913 endFiberMark(fiber, null, warning); 47914 } 47915} 47916function startPhaseTimer(fiber, phase) { 47917 { 47918 if (!supportsUserTiming) { 47919 return; 47920 } 47921 47922 clearPendingPhaseMeasurement(); 47923 47924 if (!beginFiberMark(fiber, phase)) { 47925 return; 47926 } 47927 47928 currentPhaseFiber = fiber; 47929 currentPhase = phase; 47930 } 47931} 47932function stopPhaseTimer() { 47933 { 47934 if (!supportsUserTiming) { 47935 return; 47936 } 47937 47938 if (currentPhase !== null && currentPhaseFiber !== null) { 47939 var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null; 47940 endFiberMark(currentPhaseFiber, currentPhase, warning); 47941 } 47942 47943 currentPhase = null; 47944 currentPhaseFiber = null; 47945 } 47946} 47947function startWorkLoopTimer(nextUnitOfWork) { 47948 { 47949 currentFiber = nextUnitOfWork; 47950 47951 if (!supportsUserTiming) { 47952 return; 47953 } 47954 47955 commitCountInCurrentWorkLoop = 0; // This is top level call. 47956 // Any other measurements are performed within. 47957 47958 beginMark('(React Tree Reconciliation)'); // Resume any measurements that were in progress during the last loop. 47959 47960 resumeTimers(); 47961 } 47962} 47963function stopWorkLoopTimer(interruptedBy, didCompleteRoot) { 47964 { 47965 if (!supportsUserTiming) { 47966 return; 47967 } 47968 47969 var warning = null; 47970 47971 if (interruptedBy !== null) { 47972 if (interruptedBy.tag === HostRoot) { 47973 warning = 'A top-level update interrupted the previous render'; 47974 } else { 47975 var componentName = getComponentName(interruptedBy.type) || 'Unknown'; 47976 warning = "An update to " + componentName + " interrupted the previous render"; 47977 } 47978 } else if (commitCountInCurrentWorkLoop > 1) { 47979 warning = 'There were cascading updates'; 47980 } 47981 47982 commitCountInCurrentWorkLoop = 0; 47983 var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)'; // Pause any measurements until the next loop. 47984 47985 pauseTimers(); 47986 endMark(label, '(React Tree Reconciliation)', warning); 47987 } 47988} 47989function startCommitTimer() { 47990 { 47991 if (!supportsUserTiming) { 47992 return; 47993 } 47994 47995 isCommitting = true; 47996 hasScheduledUpdateInCurrentCommit = false; 47997 labelsInCurrentCommit.clear(); 47998 beginMark('(Committing Changes)'); 47999 } 48000} 48001function stopCommitTimer() { 48002 { 48003 if (!supportsUserTiming) { 48004 return; 48005 } 48006 48007 var warning = null; 48008 48009 if (hasScheduledUpdateInCurrentCommit) { 48010 warning = 'Lifecycle hook scheduled a cascading update'; 48011 } else if (commitCountInCurrentWorkLoop > 0) { 48012 warning = 'Caused by a cascading update in earlier commit'; 48013 } 48014 48015 hasScheduledUpdateInCurrentCommit = false; 48016 commitCountInCurrentWorkLoop++; 48017 isCommitting = false; 48018 labelsInCurrentCommit.clear(); 48019 endMark('(Committing Changes)', '(Committing Changes)', warning); 48020 } 48021} 48022function startCommitSnapshotEffectsTimer() { 48023 { 48024 if (!supportsUserTiming) { 48025 return; 48026 } 48027 48028 effectCountInCurrentCommit = 0; 48029 beginMark('(Committing Snapshot Effects)'); 48030 } 48031} 48032function stopCommitSnapshotEffectsTimer() { 48033 { 48034 if (!supportsUserTiming) { 48035 return; 48036 } 48037 48038 var count = effectCountInCurrentCommit; 48039 effectCountInCurrentCommit = 0; 48040 endMark("(Committing Snapshot Effects: " + count + " Total)", '(Committing Snapshot Effects)', null); 48041 } 48042} 48043function startCommitHostEffectsTimer() { 48044 { 48045 if (!supportsUserTiming) { 48046 return; 48047 } 48048 48049 effectCountInCurrentCommit = 0; 48050 beginMark('(Committing Host Effects)'); 48051 } 48052} 48053function stopCommitHostEffectsTimer() { 48054 { 48055 if (!supportsUserTiming) { 48056 return; 48057 } 48058 48059 var count = effectCountInCurrentCommit; 48060 effectCountInCurrentCommit = 0; 48061 endMark("(Committing Host Effects: " + count + " Total)", '(Committing Host Effects)', null); 48062 } 48063} 48064function startCommitLifeCyclesTimer() { 48065 { 48066 if (!supportsUserTiming) { 48067 return; 48068 } 48069 48070 effectCountInCurrentCommit = 0; 48071 beginMark('(Calling Lifecycle Methods)'); 48072 } 48073} 48074function stopCommitLifeCyclesTimer() { 48075 { 48076 if (!supportsUserTiming) { 48077 return; 48078 } 48079 48080 var count = effectCountInCurrentCommit; 48081 effectCountInCurrentCommit = 0; 48082 endMark("(Calling Lifecycle Methods: " + count + " Total)", '(Calling Lifecycle Methods)', null); 48083 } 48084} 48085 48086var valueStack = []; 48087var fiberStack; 48088 48089{ 48090 fiberStack = []; 48091} 48092 48093var index = -1; 48094 48095function createCursor(defaultValue) { 48096 return { 48097 current: defaultValue 48098 }; 48099} 48100 48101function pop(cursor, fiber) { 48102 if (index < 0) { 48103 { 48104 error('Unexpected pop.'); 48105 } 48106 48107 return; 48108 } 48109 48110 { 48111 if (fiber !== fiberStack[index]) { 48112 error('Unexpected Fiber popped.'); 48113 } 48114 } 48115 48116 cursor.current = valueStack[index]; 48117 valueStack[index] = null; 48118 48119 { 48120 fiberStack[index] = null; 48121 } 48122 48123 index--; 48124} 48125 48126function push(cursor, value, fiber) { 48127 index++; 48128 valueStack[index] = cursor.current; 48129 48130 { 48131 fiberStack[index] = fiber; 48132 } 48133 48134 cursor.current = value; 48135} 48136 48137var warnedAboutMissingGetChildContext; 48138 48139{ 48140 warnedAboutMissingGetChildContext = {}; 48141} 48142 48143var emptyContextObject = {}; 48144 48145{ 48146 Object.freeze(emptyContextObject); 48147} // A cursor to the current merged context object on the stack. 48148 48149 48150var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. 48151 48152var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. 48153// We use this to get access to the parent context after we have already 48154// pushed the next context provider, and now need to merge their contexts. 48155 48156var previousContext = emptyContextObject; 48157 48158function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) { 48159 { 48160 if (didPushOwnContextIfProvider && isContextProvider(Component)) { 48161 // If the fiber is a context provider itself, when we read its context 48162 // we may have already pushed its own child context on the stack. A context 48163 // provider should not "see" its own child context. Therefore we read the 48164 // previous (parent) context instead for a context provider. 48165 return previousContext; 48166 } 48167 48168 return contextStackCursor.current; 48169 } 48170} 48171 48172function cacheContext(workInProgress, unmaskedContext, maskedContext) { 48173 { 48174 var instance = workInProgress.stateNode; 48175 instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; 48176 instance.__reactInternalMemoizedMaskedChildContext = maskedContext; 48177 } 48178} 48179 48180function getMaskedContext(workInProgress, unmaskedContext) { 48181 { 48182 var type = workInProgress.type; 48183 var contextTypes = type.contextTypes; 48184 48185 if (!contextTypes) { 48186 return emptyContextObject; 48187 } // Avoid recreating masked context unless unmasked context has changed. 48188 // Failing to do this will result in unnecessary calls to componentWillReceiveProps. 48189 // This may trigger infinite loops if componentWillReceiveProps calls setState. 48190 48191 48192 var instance = workInProgress.stateNode; 48193 48194 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { 48195 return instance.__reactInternalMemoizedMaskedChildContext; 48196 } 48197 48198 var context = {}; 48199 48200 for (var key in contextTypes) { 48201 context[key] = unmaskedContext[key]; 48202 } 48203 48204 { 48205 var name = getComponentName(type) || 'Unknown'; 48206 checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev); 48207 } // Cache unmasked context so we can avoid recreating masked context unless necessary. 48208 // Context is created before the class component is instantiated so check for instance. 48209 48210 48211 if (instance) { 48212 cacheContext(workInProgress, unmaskedContext, context); 48213 } 48214 48215 return context; 48216 } 48217} 48218 48219function hasContextChanged() { 48220 { 48221 return didPerformWorkStackCursor.current; 48222 } 48223} 48224 48225function isContextProvider(type) { 48226 { 48227 var childContextTypes = type.childContextTypes; 48228 return childContextTypes !== null && childContextTypes !== undefined; 48229 } 48230} 48231 48232function popContext(fiber) { 48233 { 48234 pop(didPerformWorkStackCursor, fiber); 48235 pop(contextStackCursor, fiber); 48236 } 48237} 48238 48239function popTopLevelContextObject(fiber) { 48240 { 48241 pop(didPerformWorkStackCursor, fiber); 48242 pop(contextStackCursor, fiber); 48243 } 48244} 48245 48246function pushTopLevelContextObject(fiber, context, didChange) { 48247 { 48248 if (!(contextStackCursor.current === emptyContextObject)) { 48249 { 48250 throw Error( "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." ); 48251 } 48252 } 48253 48254 push(contextStackCursor, context, fiber); 48255 push(didPerformWorkStackCursor, didChange, fiber); 48256 } 48257} 48258 48259function processChildContext(fiber, type, parentContext) { 48260 { 48261 var instance = fiber.stateNode; 48262 var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. 48263 // It has only been added in Fiber to match the (unintentional) behavior in Stack. 48264 48265 if (typeof instance.getChildContext !== 'function') { 48266 { 48267 var componentName = getComponentName(type) || 'Unknown'; 48268 48269 if (!warnedAboutMissingGetChildContext[componentName]) { 48270 warnedAboutMissingGetChildContext[componentName] = true; 48271 48272 error('%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); 48273 } 48274 } 48275 48276 return parentContext; 48277 } 48278 48279 var childContext; 48280 startPhaseTimer(fiber, 'getChildContext'); 48281 childContext = instance.getChildContext(); 48282 stopPhaseTimer(); 48283 48284 for (var contextKey in childContext) { 48285 if (!(contextKey in childContextTypes)) { 48286 { 48287 throw Error( (getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes." ); 48288 } 48289 } 48290 } 48291 48292 { 48293 var name = getComponentName(type) || 'Unknown'; 48294 checkPropTypes(childContextTypes, childContext, 'child context', name, // In practice, there is one case in which we won't get a stack. It's when 48295 // somebody calls unstable_renderSubtreeIntoContainer() and we process 48296 // context from the parent component instance. The stack will be missing 48297 // because it's outside of the reconciliation, and so the pointer has not 48298 // been set. This is rare and doesn't matter. We'll also remove that API. 48299 getCurrentFiberStackInDev); 48300 } 48301 48302 return _assign({}, parentContext, {}, childContext); 48303 } 48304} 48305 48306function pushContextProvider(workInProgress) { 48307 { 48308 var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. 48309 // If the instance does not exist yet, we will push null at first, 48310 // and replace it on the stack later when invalidating the context. 48311 48312 var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later. 48313 // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. 48314 48315 previousContext = contextStackCursor.current; 48316 push(contextStackCursor, memoizedMergedChildContext, workInProgress); 48317 push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); 48318 return true; 48319 } 48320} 48321 48322function invalidateContextProvider(workInProgress, type, didChange) { 48323 { 48324 var instance = workInProgress.stateNode; 48325 48326 if (!instance) { 48327 { 48328 throw Error( "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." ); 48329 } 48330 } 48331 48332 if (didChange) { 48333 // Merge parent and own context. 48334 // Skip this if we're not updating due to sCU. 48335 // This avoids unnecessarily recomputing memoized values. 48336 var mergedContext = processChildContext(workInProgress, type, previousContext); 48337 instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. 48338 // It is important to unwind the context in the reverse order. 48339 48340 pop(didPerformWorkStackCursor, workInProgress); 48341 pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed. 48342 48343 push(contextStackCursor, mergedContext, workInProgress); 48344 push(didPerformWorkStackCursor, didChange, workInProgress); 48345 } else { 48346 pop(didPerformWorkStackCursor, workInProgress); 48347 push(didPerformWorkStackCursor, didChange, workInProgress); 48348 } 48349 } 48350} 48351 48352function findCurrentUnmaskedContext(fiber) { 48353 { 48354 // Currently this is only used with renderSubtreeIntoContainer; not sure if it 48355 // makes sense elsewhere 48356 if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) { 48357 { 48358 throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); 48359 } 48360 } 48361 48362 var node = fiber; 48363 48364 do { 48365 switch (node.tag) { 48366 case HostRoot: 48367 return node.stateNode.context; 48368 48369 case ClassComponent: 48370 { 48371 var Component = node.type; 48372 48373 if (isContextProvider(Component)) { 48374 return node.stateNode.__reactInternalMemoizedMergedChildContext; 48375 } 48376 48377 break; 48378 } 48379 } 48380 48381 node = node.return; 48382 } while (node !== null); 48383 48384 { 48385 { 48386 throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); 48387 } 48388 } 48389 } 48390} 48391 48392var LegacyRoot = 0; 48393var BlockingRoot = 1; 48394var ConcurrentRoot = 2; 48395 48396var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, 48397 Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, 48398 Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, 48399 Scheduler_shouldYield = Scheduler.unstable_shouldYield, 48400 Scheduler_requestPaint = Scheduler.unstable_requestPaint, 48401 Scheduler_now = Scheduler.unstable_now, 48402 Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, 48403 Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, 48404 Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, 48405 Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, 48406 Scheduler_LowPriority = Scheduler.unstable_LowPriority, 48407 Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; 48408 48409{ 48410 // Provide explicit error message when production+profiling bundle of e.g. 48411 // react-dom is used with production (non-profiling) bundle of 48412 // scheduler/tracing 48413 if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) { 48414 { 48415 throw Error( "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" ); 48416 } 48417 } 48418} 48419 48420var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use 48421// ascending numbers so we can compare them like numbers. They start at 90 to 48422// avoid clashing with Scheduler's priorities. 48423 48424var ImmediatePriority = 99; 48425var UserBlockingPriority$1 = 98; 48426var NormalPriority = 97; 48427var LowPriority = 96; 48428var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. 48429 48430var NoPriority = 90; 48431var shouldYield = Scheduler_shouldYield; 48432var requestPaint = // Fall back gracefully if we're running an older version of Scheduler. 48433Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {}; 48434var syncQueue = null; 48435var immediateQueueCallbackNode = null; 48436var isFlushingSyncQueue = false; 48437var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. 48438// This will be the case for modern browsers that support `performance.now`. In 48439// older browsers, Scheduler falls back to `Date.now`, which returns a Unix 48440// timestamp. In that case, subtract the module initialization time to simulate 48441// the behavior of performance.now and keep our times small enough to fit 48442// within 32 bits. 48443// TODO: Consider lifting this into Scheduler. 48444 48445var now = initialTimeMs < 10000 ? Scheduler_now : function () { 48446 return Scheduler_now() - initialTimeMs; 48447}; 48448function getCurrentPriorityLevel() { 48449 switch (Scheduler_getCurrentPriorityLevel()) { 48450 case Scheduler_ImmediatePriority: 48451 return ImmediatePriority; 48452 48453 case Scheduler_UserBlockingPriority: 48454 return UserBlockingPriority$1; 48455 48456 case Scheduler_NormalPriority: 48457 return NormalPriority; 48458 48459 case Scheduler_LowPriority: 48460 return LowPriority; 48461 48462 case Scheduler_IdlePriority: 48463 return IdlePriority; 48464 48465 default: 48466 { 48467 { 48468 throw Error( "Unknown priority level." ); 48469 } 48470 } 48471 48472 } 48473} 48474 48475function reactPriorityToSchedulerPriority(reactPriorityLevel) { 48476 switch (reactPriorityLevel) { 48477 case ImmediatePriority: 48478 return Scheduler_ImmediatePriority; 48479 48480 case UserBlockingPriority$1: 48481 return Scheduler_UserBlockingPriority; 48482 48483 case NormalPriority: 48484 return Scheduler_NormalPriority; 48485 48486 case LowPriority: 48487 return Scheduler_LowPriority; 48488 48489 case IdlePriority: 48490 return Scheduler_IdlePriority; 48491 48492 default: 48493 { 48494 { 48495 throw Error( "Unknown priority level." ); 48496 } 48497 } 48498 48499 } 48500} 48501 48502function runWithPriority$1(reactPriorityLevel, fn) { 48503 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); 48504 return Scheduler_runWithPriority(priorityLevel, fn); 48505} 48506function scheduleCallback(reactPriorityLevel, callback, options) { 48507 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); 48508 return Scheduler_scheduleCallback(priorityLevel, callback, options); 48509} 48510function scheduleSyncCallback(callback) { 48511 // Push this callback into an internal queue. We'll flush these either in 48512 // the next tick, or earlier if something calls `flushSyncCallbackQueue`. 48513 if (syncQueue === null) { 48514 syncQueue = [callback]; // Flush the queue in the next tick, at the earliest. 48515 48516 immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl); 48517 } else { 48518 // Push onto existing queue. Don't need to schedule a callback because 48519 // we already scheduled one when we created the queue. 48520 syncQueue.push(callback); 48521 } 48522 48523 return fakeCallbackNode; 48524} 48525function cancelCallback(callbackNode) { 48526 if (callbackNode !== fakeCallbackNode) { 48527 Scheduler_cancelCallback(callbackNode); 48528 } 48529} 48530function flushSyncCallbackQueue() { 48531 if (immediateQueueCallbackNode !== null) { 48532 var node = immediateQueueCallbackNode; 48533 immediateQueueCallbackNode = null; 48534 Scheduler_cancelCallback(node); 48535 } 48536 48537 flushSyncCallbackQueueImpl(); 48538} 48539 48540function flushSyncCallbackQueueImpl() { 48541 if (!isFlushingSyncQueue && syncQueue !== null) { 48542 // Prevent re-entrancy. 48543 isFlushingSyncQueue = true; 48544 var i = 0; 48545 48546 try { 48547 var _isSync = true; 48548 var queue = syncQueue; 48549 runWithPriority$1(ImmediatePriority, function () { 48550 for (; i < queue.length; i++) { 48551 var callback = queue[i]; 48552 48553 do { 48554 callback = callback(_isSync); 48555 } while (callback !== null); 48556 } 48557 }); 48558 syncQueue = null; 48559 } catch (error) { 48560 // If something throws, leave the remaining callbacks on the queue. 48561 if (syncQueue !== null) { 48562 syncQueue = syncQueue.slice(i + 1); 48563 } // Resume flushing in the next tick 48564 48565 48566 Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue); 48567 throw error; 48568 } finally { 48569 isFlushingSyncQueue = false; 48570 } 48571 } 48572} 48573 48574var NoMode = 0; 48575var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root 48576// tag instead 48577 48578var BlockingMode = 2; 48579var ConcurrentMode = 4; 48580var ProfileMode = 8; 48581 48582// Max 31 bit integer. The max integer size in V8 for 32-bit systems. 48583// Math.pow(2, 30) - 1 48584// 0b111111111111111111111111111111 48585var MAX_SIGNED_31_BIT_INT = 1073741823; 48586 48587var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that 48588// Never work can be committed in an inconsistent state without tearing the UI. 48589// The main example is offscreen content, like a hidden subtree. So one possible 48590// name is Offscreen. However, it also includes dehydrated Suspense boundaries, 48591// which are inconsistent in the sense that they haven't finished yet, but 48592// aren't visibly inconsistent because the server rendered HTML matches what the 48593// hydrated tree would look like. 48594 48595var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in 48596// order to be consistent. 48597 48598var Idle = 2; // Continuous Hydration is slightly higher than Idle and is used to increase 48599// priority of hover targets. 48600 48601var ContinuousHydration = 3; 48602var Sync = MAX_SIGNED_31_BIT_INT; 48603var Batched = Sync - 1; 48604var UNIT_SIZE = 10; 48605var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms. 48606 48607function msToExpirationTime(ms) { 48608 // Always subtract from the offset so that we don't clash with the magic number for NoWork. 48609 return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0); 48610} 48611function expirationTimeToMs(expirationTime) { 48612 return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; 48613} 48614 48615function ceiling(num, precision) { 48616 return ((num / precision | 0) + 1) * precision; 48617} 48618 48619function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { 48620 return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE); 48621} // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update 48622// the names to reflect. 48623 48624 48625var LOW_PRIORITY_EXPIRATION = 5000; 48626var LOW_PRIORITY_BATCH_SIZE = 250; 48627function computeAsyncExpiration(currentTime) { 48628 return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE); 48629} 48630function computeSuspenseExpiration(currentTime, timeoutMs) { 48631 // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time? 48632 return computeExpirationBucket(currentTime, timeoutMs, LOW_PRIORITY_BATCH_SIZE); 48633} // We intentionally set a higher expiration time for interactive updates in 48634// dev than in production. 48635// 48636// If the main thread is being blocked so long that you hit the expiration, 48637// it's a problem that could be solved with better scheduling. 48638// 48639// People will be more likely to notice this and fix it with the long 48640// expiration time in development. 48641// 48642// In production we opt for better UX at the risk of masking scheduling 48643// problems, by expiring fast. 48644 48645var HIGH_PRIORITY_EXPIRATION = 500 ; 48646var HIGH_PRIORITY_BATCH_SIZE = 100; 48647function computeInteractiveExpiration(currentTime) { 48648 return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE); 48649} 48650function inferPriorityFromExpirationTime(currentTime, expirationTime) { 48651 if (expirationTime === Sync) { 48652 return ImmediatePriority; 48653 } 48654 48655 if (expirationTime === Never || expirationTime === Idle) { 48656 return IdlePriority; 48657 } 48658 48659 var msUntil = expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime); 48660 48661 if (msUntil <= 0) { 48662 return ImmediatePriority; 48663 } 48664 48665 if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) { 48666 return UserBlockingPriority$1; 48667 } 48668 48669 if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) { 48670 return NormalPriority; 48671 } // TODO: Handle LowPriority 48672 // Assume anything lower has idle priority 48673 48674 48675 return IdlePriority; 48676} 48677 48678var ReactStrictModeWarnings = { 48679 recordUnsafeLifecycleWarnings: function (fiber, instance) {}, 48680 flushPendingUnsafeLifecycleWarnings: function () {}, 48681 recordLegacyContextWarning: function (fiber, instance) {}, 48682 flushLegacyContextWarning: function () {}, 48683 discardPendingWarnings: function () {} 48684}; 48685 48686{ 48687 var findStrictRoot = function (fiber) { 48688 var maybeStrictRoot = null; 48689 var node = fiber; 48690 48691 while (node !== null) { 48692 if (node.mode & StrictMode) { 48693 maybeStrictRoot = node; 48694 } 48695 48696 node = node.return; 48697 } 48698 48699 return maybeStrictRoot; 48700 }; 48701 48702 var setToSortedString = function (set) { 48703 var array = []; 48704 set.forEach(function (value) { 48705 array.push(value); 48706 }); 48707 return array.sort().join(', '); 48708 }; 48709 48710 var pendingComponentWillMountWarnings = []; 48711 var pendingUNSAFE_ComponentWillMountWarnings = []; 48712 var pendingComponentWillReceivePropsWarnings = []; 48713 var pendingUNSAFE_ComponentWillReceivePropsWarnings = []; 48714 var pendingComponentWillUpdateWarnings = []; 48715 var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about. 48716 48717 var didWarnAboutUnsafeLifecycles = new Set(); 48718 48719 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) { 48720 // Dedup strategy: Warn once per component. 48721 if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { 48722 return; 48723 } 48724 48725 if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components. 48726 instance.componentWillMount.__suppressDeprecationWarning !== true) { 48727 pendingComponentWillMountWarnings.push(fiber); 48728 } 48729 48730 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') { 48731 pendingUNSAFE_ComponentWillMountWarnings.push(fiber); 48732 } 48733 48734 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { 48735 pendingComponentWillReceivePropsWarnings.push(fiber); 48736 } 48737 48738 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 48739 pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); 48740 } 48741 48742 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { 48743 pendingComponentWillUpdateWarnings.push(fiber); 48744 } 48745 48746 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') { 48747 pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); 48748 } 48749 }; 48750 48751 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () { 48752 // We do an initial pass to gather component names 48753 var componentWillMountUniqueNames = new Set(); 48754 48755 if (pendingComponentWillMountWarnings.length > 0) { 48756 pendingComponentWillMountWarnings.forEach(function (fiber) { 48757 componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component'); 48758 didWarnAboutUnsafeLifecycles.add(fiber.type); 48759 }); 48760 pendingComponentWillMountWarnings = []; 48761 } 48762 48763 var UNSAFE_componentWillMountUniqueNames = new Set(); 48764 48765 if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) { 48766 pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) { 48767 UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component'); 48768 didWarnAboutUnsafeLifecycles.add(fiber.type); 48769 }); 48770 pendingUNSAFE_ComponentWillMountWarnings = []; 48771 } 48772 48773 var componentWillReceivePropsUniqueNames = new Set(); 48774 48775 if (pendingComponentWillReceivePropsWarnings.length > 0) { 48776 pendingComponentWillReceivePropsWarnings.forEach(function (fiber) { 48777 componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component'); 48778 didWarnAboutUnsafeLifecycles.add(fiber.type); 48779 }); 48780 pendingComponentWillReceivePropsWarnings = []; 48781 } 48782 48783 var UNSAFE_componentWillReceivePropsUniqueNames = new Set(); 48784 48785 if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) { 48786 pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) { 48787 UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component'); 48788 didWarnAboutUnsafeLifecycles.add(fiber.type); 48789 }); 48790 pendingUNSAFE_ComponentWillReceivePropsWarnings = []; 48791 } 48792 48793 var componentWillUpdateUniqueNames = new Set(); 48794 48795 if (pendingComponentWillUpdateWarnings.length > 0) { 48796 pendingComponentWillUpdateWarnings.forEach(function (fiber) { 48797 componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component'); 48798 didWarnAboutUnsafeLifecycles.add(fiber.type); 48799 }); 48800 pendingComponentWillUpdateWarnings = []; 48801 } 48802 48803 var UNSAFE_componentWillUpdateUniqueNames = new Set(); 48804 48805 if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) { 48806 pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) { 48807 UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component'); 48808 didWarnAboutUnsafeLifecycles.add(fiber.type); 48809 }); 48810 pendingUNSAFE_ComponentWillUpdateWarnings = []; 48811 } // Finally, we flush all the warnings 48812 // UNSAFE_ ones before the deprecated ones, since they'll be 'louder' 48813 48814 48815 if (UNSAFE_componentWillMountUniqueNames.size > 0) { 48816 var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); 48817 48818 error('Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '\nPlease update the following components: %s', sortedNames); 48819 } 48820 48821 if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) { 48822 var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames); 48823 48824 error('Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, " + 'refactor your code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '\nPlease update the following components: %s', _sortedNames); 48825 } 48826 48827 if (UNSAFE_componentWillUpdateUniqueNames.size > 0) { 48828 var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames); 48829 48830 error('Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2); 48831 } 48832 48833 if (componentWillMountUniqueNames.size > 0) { 48834 var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); 48835 48836 warn('componentWillMount has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '* Rename componentWillMount to UNSAFE_componentWillMount to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames3); 48837 } 48838 48839 if (componentWillReceivePropsUniqueNames.size > 0) { 48840 var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames); 48841 48842 warn('componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, refactor your " + 'code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames4); 48843 } 48844 48845 if (componentWillUpdateUniqueNames.size > 0) { 48846 var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); 48847 48848 warn('componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames5); 48849 } 48850 }; 48851 48852 var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about. 48853 48854 var didWarnAboutLegacyContext = new Set(); 48855 48856 ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) { 48857 var strictRoot = findStrictRoot(fiber); 48858 48859 if (strictRoot === null) { 48860 error('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.'); 48861 48862 return; 48863 } // Dedup strategy: Warn once per component. 48864 48865 48866 if (didWarnAboutLegacyContext.has(fiber.type)) { 48867 return; 48868 } 48869 48870 var warningsForRoot = pendingLegacyContextWarning.get(strictRoot); 48871 48872 if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') { 48873 if (warningsForRoot === undefined) { 48874 warningsForRoot = []; 48875 pendingLegacyContextWarning.set(strictRoot, warningsForRoot); 48876 } 48877 48878 warningsForRoot.push(fiber); 48879 } 48880 }; 48881 48882 ReactStrictModeWarnings.flushLegacyContextWarning = function () { 48883 pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) { 48884 if (fiberArray.length === 0) { 48885 return; 48886 } 48887 48888 var firstFiber = fiberArray[0]; 48889 var uniqueNames = new Set(); 48890 fiberArray.forEach(function (fiber) { 48891 uniqueNames.add(getComponentName(fiber.type) || 'Component'); 48892 didWarnAboutLegacyContext.add(fiber.type); 48893 }); 48894 var sortedNames = setToSortedString(uniqueNames); 48895 var firstComponentStack = getStackByFiberInDevAndProd(firstFiber); 48896 48897 error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://fb.me/react-legacy-context' + '%s', sortedNames, firstComponentStack); 48898 }); 48899 }; 48900 48901 ReactStrictModeWarnings.discardPendingWarnings = function () { 48902 pendingComponentWillMountWarnings = []; 48903 pendingUNSAFE_ComponentWillMountWarnings = []; 48904 pendingComponentWillReceivePropsWarnings = []; 48905 pendingUNSAFE_ComponentWillReceivePropsWarnings = []; 48906 pendingComponentWillUpdateWarnings = []; 48907 pendingUNSAFE_ComponentWillUpdateWarnings = []; 48908 pendingLegacyContextWarning = new Map(); 48909 }; 48910} 48911 48912var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. 48913 48914var failedBoundaries = null; 48915var setRefreshHandler = function (handler) { 48916 { 48917 resolveFamily = handler; 48918 } 48919}; 48920function resolveFunctionForHotReloading(type) { 48921 { 48922 if (resolveFamily === null) { 48923 // Hot reloading is disabled. 48924 return type; 48925 } 48926 48927 var family = resolveFamily(type); 48928 48929 if (family === undefined) { 48930 return type; 48931 } // Use the latest known implementation. 48932 48933 48934 return family.current; 48935 } 48936} 48937function resolveClassForHotReloading(type) { 48938 // No implementation differences. 48939 return resolveFunctionForHotReloading(type); 48940} 48941function resolveForwardRefForHotReloading(type) { 48942 { 48943 if (resolveFamily === null) { 48944 // Hot reloading is disabled. 48945 return type; 48946 } 48947 48948 var family = resolveFamily(type); 48949 48950 if (family === undefined) { 48951 // Check if we're dealing with a real forwardRef. Don't want to crash early. 48952 if (type !== null && type !== undefined && typeof type.render === 'function') { 48953 // ForwardRef is special because its resolved .type is an object, 48954 // but it's possible that we only have its inner render function in the map. 48955 // If that inner render function is different, we'll build a new forwardRef type. 48956 var currentRender = resolveFunctionForHotReloading(type.render); 48957 48958 if (type.render !== currentRender) { 48959 var syntheticType = { 48960 $$typeof: REACT_FORWARD_REF_TYPE, 48961 render: currentRender 48962 }; 48963 48964 if (type.displayName !== undefined) { 48965 syntheticType.displayName = type.displayName; 48966 } 48967 48968 return syntheticType; 48969 } 48970 } 48971 48972 return type; 48973 } // Use the latest known implementation. 48974 48975 48976 return family.current; 48977 } 48978} 48979function isCompatibleFamilyForHotReloading(fiber, element) { 48980 { 48981 if (resolveFamily === null) { 48982 // Hot reloading is disabled. 48983 return false; 48984 } 48985 48986 var prevType = fiber.elementType; 48987 var nextType = element.type; // If we got here, we know types aren't === equal. 48988 48989 var needsCompareFamilies = false; 48990 var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null; 48991 48992 switch (fiber.tag) { 48993 case ClassComponent: 48994 { 48995 if (typeof nextType === 'function') { 48996 needsCompareFamilies = true; 48997 } 48998 48999 break; 49000 } 49001 49002 case FunctionComponent: 49003 { 49004 if (typeof nextType === 'function') { 49005 needsCompareFamilies = true; 49006 } else if ($$typeofNextType === REACT_LAZY_TYPE) { 49007 // We don't know the inner type yet. 49008 // We're going to assume that the lazy inner type is stable, 49009 // and so it is sufficient to avoid reconciling it away. 49010 // We're not going to unwrap or actually use the new lazy type. 49011 needsCompareFamilies = true; 49012 } 49013 49014 break; 49015 } 49016 49017 case ForwardRef: 49018 { 49019 if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { 49020 needsCompareFamilies = true; 49021 } else if ($$typeofNextType === REACT_LAZY_TYPE) { 49022 needsCompareFamilies = true; 49023 } 49024 49025 break; 49026 } 49027 49028 case MemoComponent: 49029 case SimpleMemoComponent: 49030 { 49031 if ($$typeofNextType === REACT_MEMO_TYPE) { 49032 // TODO: if it was but can no longer be simple, 49033 // we shouldn't set this. 49034 needsCompareFamilies = true; 49035 } else if ($$typeofNextType === REACT_LAZY_TYPE) { 49036 needsCompareFamilies = true; 49037 } 49038 49039 break; 49040 } 49041 49042 default: 49043 return false; 49044 } // Check if both types have a family and it's the same one. 49045 49046 49047 if (needsCompareFamilies) { 49048 // Note: memo() and forwardRef() we'll compare outer rather than inner type. 49049 // This means both of them need to be registered to preserve state. 49050 // If we unwrapped and compared the inner types for wrappers instead, 49051 // then we would risk falsely saying two separate memo(Foo) 49052 // calls are equivalent because they wrap the same Foo function. 49053 var prevFamily = resolveFamily(prevType); 49054 49055 if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { 49056 return true; 49057 } 49058 } 49059 49060 return false; 49061 } 49062} 49063function markFailedErrorBoundaryForHotReloading(fiber) { 49064 { 49065 if (resolveFamily === null) { 49066 // Hot reloading is disabled. 49067 return; 49068 } 49069 49070 if (typeof WeakSet !== 'function') { 49071 return; 49072 } 49073 49074 if (failedBoundaries === null) { 49075 failedBoundaries = new WeakSet(); 49076 } 49077 49078 failedBoundaries.add(fiber); 49079 } 49080} 49081var scheduleRefresh = function (root, update) { 49082 { 49083 if (resolveFamily === null) { 49084 // Hot reloading is disabled. 49085 return; 49086 } 49087 49088 var staleFamilies = update.staleFamilies, 49089 updatedFamilies = update.updatedFamilies; 49090 flushPassiveEffects(); 49091 flushSync(function () { 49092 scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies); 49093 }); 49094 } 49095}; 49096var scheduleRoot = function (root, element) { 49097 { 49098 if (root.context !== emptyContextObject) { 49099 // Super edge case: root has a legacy _renderSubtree context 49100 // but we don't know the parentComponent so we can't pass it. 49101 // Just ignore. We'll delete this with _renderSubtree code path later. 49102 return; 49103 } 49104 49105 flushPassiveEffects(); 49106 syncUpdates(function () { 49107 updateContainer(element, root, null, null); 49108 }); 49109 } 49110}; 49111 49112function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) { 49113 { 49114 var alternate = fiber.alternate, 49115 child = fiber.child, 49116 sibling = fiber.sibling, 49117 tag = fiber.tag, 49118 type = fiber.type; 49119 var candidateType = null; 49120 49121 switch (tag) { 49122 case FunctionComponent: 49123 case SimpleMemoComponent: 49124 case ClassComponent: 49125 candidateType = type; 49126 break; 49127 49128 case ForwardRef: 49129 candidateType = type.render; 49130 break; 49131 } 49132 49133 if (resolveFamily === null) { 49134 throw new Error('Expected resolveFamily to be set during hot reload.'); 49135 } 49136 49137 var needsRender = false; 49138 var needsRemount = false; 49139 49140 if (candidateType !== null) { 49141 var family = resolveFamily(candidateType); 49142 49143 if (family !== undefined) { 49144 if (staleFamilies.has(family)) { 49145 needsRemount = true; 49146 } else if (updatedFamilies.has(family)) { 49147 if (tag === ClassComponent) { 49148 needsRemount = true; 49149 } else { 49150 needsRender = true; 49151 } 49152 } 49153 } 49154 } 49155 49156 if (failedBoundaries !== null) { 49157 if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) { 49158 needsRemount = true; 49159 } 49160 } 49161 49162 if (needsRemount) { 49163 fiber._debugNeedsRemount = true; 49164 } 49165 49166 if (needsRemount || needsRender) { 49167 scheduleWork(fiber, Sync); 49168 } 49169 49170 if (child !== null && !needsRemount) { 49171 scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies); 49172 } 49173 49174 if (sibling !== null) { 49175 scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies); 49176 } 49177 } 49178} 49179 49180var findHostInstancesForRefresh = function (root, families) { 49181 { 49182 var hostInstances = new Set(); 49183 var types = new Set(families.map(function (family) { 49184 return family.current; 49185 })); 49186 findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances); 49187 return hostInstances; 49188 } 49189}; 49190 49191function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) { 49192 { 49193 var child = fiber.child, 49194 sibling = fiber.sibling, 49195 tag = fiber.tag, 49196 type = fiber.type; 49197 var candidateType = null; 49198 49199 switch (tag) { 49200 case FunctionComponent: 49201 case SimpleMemoComponent: 49202 case ClassComponent: 49203 candidateType = type; 49204 break; 49205 49206 case ForwardRef: 49207 candidateType = type.render; 49208 break; 49209 } 49210 49211 var didMatch = false; 49212 49213 if (candidateType !== null) { 49214 if (types.has(candidateType)) { 49215 didMatch = true; 49216 } 49217 } 49218 49219 if (didMatch) { 49220 // We have a match. This only drills down to the closest host components. 49221 // There's no need to search deeper because for the purpose of giving 49222 // visual feedback, "flashing" outermost parent rectangles is sufficient. 49223 findHostInstancesForFiberShallowly(fiber, hostInstances); 49224 } else { 49225 // If there's no match, maybe there will be one further down in the child tree. 49226 if (child !== null) { 49227 findHostInstancesForMatchingFibersRecursively(child, types, hostInstances); 49228 } 49229 } 49230 49231 if (sibling !== null) { 49232 findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances); 49233 } 49234 } 49235} 49236 49237function findHostInstancesForFiberShallowly(fiber, hostInstances) { 49238 { 49239 var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances); 49240 49241 if (foundHostInstances) { 49242 return; 49243 } // If we didn't find any host children, fallback to closest host parent. 49244 49245 49246 var node = fiber; 49247 49248 while (true) { 49249 switch (node.tag) { 49250 case HostComponent: 49251 hostInstances.add(node.stateNode); 49252 return; 49253 49254 case HostPortal: 49255 hostInstances.add(node.stateNode.containerInfo); 49256 return; 49257 49258 case HostRoot: 49259 hostInstances.add(node.stateNode.containerInfo); 49260 return; 49261 } 49262 49263 if (node.return === null) { 49264 throw new Error('Expected to reach root first.'); 49265 } 49266 49267 node = node.return; 49268 } 49269 } 49270} 49271 49272function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { 49273 { 49274 var node = fiber; 49275 var foundHostInstances = false; 49276 49277 while (true) { 49278 if (node.tag === HostComponent) { 49279 // We got a match. 49280 foundHostInstances = true; 49281 hostInstances.add(node.stateNode); // There may still be more, so keep searching. 49282 } else if (node.child !== null) { 49283 node.child.return = node; 49284 node = node.child; 49285 continue; 49286 } 49287 49288 if (node === fiber) { 49289 return foundHostInstances; 49290 } 49291 49292 while (node.sibling === null) { 49293 if (node.return === null || node.return === fiber) { 49294 return foundHostInstances; 49295 } 49296 49297 node = node.return; 49298 } 49299 49300 node.sibling.return = node.return; 49301 node = node.sibling; 49302 } 49303 } 49304 49305 return false; 49306} 49307 49308function resolveDefaultProps(Component, baseProps) { 49309 if (Component && Component.defaultProps) { 49310 // Resolve default props. Taken from ReactElement 49311 var props = _assign({}, baseProps); 49312 49313 var defaultProps = Component.defaultProps; 49314 49315 for (var propName in defaultProps) { 49316 if (props[propName] === undefined) { 49317 props[propName] = defaultProps[propName]; 49318 } 49319 } 49320 49321 return props; 49322 } 49323 49324 return baseProps; 49325} 49326function readLazyComponentType(lazyComponent) { 49327 initializeLazyComponentType(lazyComponent); 49328 49329 if (lazyComponent._status !== Resolved) { 49330 throw lazyComponent._result; 49331 } 49332 49333 return lazyComponent._result; 49334} 49335 49336var valueCursor = createCursor(null); 49337var rendererSigil; 49338 49339{ 49340 // Use this to detect multiple renderers using the same context 49341 rendererSigil = {}; 49342} 49343 49344var currentlyRenderingFiber = null; 49345var lastContextDependency = null; 49346var lastContextWithAllBitsObserved = null; 49347var isDisallowedContextReadInDEV = false; 49348function resetContextDependencies() { 49349 // This is called right before React yields execution, to ensure `readContext` 49350 // cannot be called outside the render phase. 49351 currentlyRenderingFiber = null; 49352 lastContextDependency = null; 49353 lastContextWithAllBitsObserved = null; 49354 49355 { 49356 isDisallowedContextReadInDEV = false; 49357 } 49358} 49359function enterDisallowedContextReadInDEV() { 49360 { 49361 isDisallowedContextReadInDEV = true; 49362 } 49363} 49364function exitDisallowedContextReadInDEV() { 49365 { 49366 isDisallowedContextReadInDEV = false; 49367 } 49368} 49369function pushProvider(providerFiber, nextValue) { 49370 var context = providerFiber.type._context; 49371 49372 { 49373 push(valueCursor, context._currentValue, providerFiber); 49374 context._currentValue = nextValue; 49375 49376 { 49377 if (context._currentRenderer !== undefined && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) { 49378 error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.'); 49379 } 49380 49381 context._currentRenderer = rendererSigil; 49382 } 49383 } 49384} 49385function popProvider(providerFiber) { 49386 var currentValue = valueCursor.current; 49387 pop(valueCursor, providerFiber); 49388 var context = providerFiber.type._context; 49389 49390 { 49391 context._currentValue = currentValue; 49392 } 49393} 49394function calculateChangedBits(context, newValue, oldValue) { 49395 if (objectIs(oldValue, newValue)) { 49396 // No change 49397 return 0; 49398 } else { 49399 var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT; 49400 49401 { 49402 if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) { 49403 error('calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits); 49404 } 49405 } 49406 49407 return changedBits | 0; 49408 } 49409} 49410function scheduleWorkOnParentPath(parent, renderExpirationTime) { 49411 // Update the child expiration time of all the ancestors, including 49412 // the alternates. 49413 var node = parent; 49414 49415 while (node !== null) { 49416 var alternate = node.alternate; 49417 49418 if (node.childExpirationTime < renderExpirationTime) { 49419 node.childExpirationTime = renderExpirationTime; 49420 49421 if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) { 49422 alternate.childExpirationTime = renderExpirationTime; 49423 } 49424 } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) { 49425 alternate.childExpirationTime = renderExpirationTime; 49426 } else { 49427 // Neither alternate was updated, which means the rest of the 49428 // ancestor path already has sufficient priority. 49429 break; 49430 } 49431 49432 node = node.return; 49433 } 49434} 49435function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) { 49436 var fiber = workInProgress.child; 49437 49438 if (fiber !== null) { 49439 // Set the return pointer of the child to the work-in-progress fiber. 49440 fiber.return = workInProgress; 49441 } 49442 49443 while (fiber !== null) { 49444 var nextFiber = void 0; // Visit this fiber. 49445 49446 var list = fiber.dependencies; 49447 49448 if (list !== null) { 49449 nextFiber = fiber.child; 49450 var dependency = list.firstContext; 49451 49452 while (dependency !== null) { 49453 // Check if the context matches. 49454 if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) { 49455 // Match! Schedule an update on this fiber. 49456 if (fiber.tag === ClassComponent) { 49457 // Schedule a force update on the work-in-progress. 49458 var update = createUpdate(renderExpirationTime, null); 49459 update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the 49460 // update to the current fiber, too, which means it will persist even if 49461 // this render is thrown away. Since it's a race condition, not sure it's 49462 // worth fixing. 49463 49464 enqueueUpdate(fiber, update); 49465 } 49466 49467 if (fiber.expirationTime < renderExpirationTime) { 49468 fiber.expirationTime = renderExpirationTime; 49469 } 49470 49471 var alternate = fiber.alternate; 49472 49473 if (alternate !== null && alternate.expirationTime < renderExpirationTime) { 49474 alternate.expirationTime = renderExpirationTime; 49475 } 49476 49477 scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too. 49478 49479 if (list.expirationTime < renderExpirationTime) { 49480 list.expirationTime = renderExpirationTime; 49481 } // Since we already found a match, we can stop traversing the 49482 // dependency list. 49483 49484 49485 break; 49486 } 49487 49488 dependency = dependency.next; 49489 } 49490 } else if (fiber.tag === ContextProvider) { 49491 // Don't scan deeper if this is a matching provider 49492 nextFiber = fiber.type === workInProgress.type ? null : fiber.child; 49493 } else { 49494 // Traverse down. 49495 nextFiber = fiber.child; 49496 } 49497 49498 if (nextFiber !== null) { 49499 // Set the return pointer of the child to the work-in-progress fiber. 49500 nextFiber.return = fiber; 49501 } else { 49502 // No child. Traverse to next sibling. 49503 nextFiber = fiber; 49504 49505 while (nextFiber !== null) { 49506 if (nextFiber === workInProgress) { 49507 // We're back to the root of this subtree. Exit. 49508 nextFiber = null; 49509 break; 49510 } 49511 49512 var sibling = nextFiber.sibling; 49513 49514 if (sibling !== null) { 49515 // Set the return pointer of the sibling to the work-in-progress fiber. 49516 sibling.return = nextFiber.return; 49517 nextFiber = sibling; 49518 break; 49519 } // No more siblings. Traverse up. 49520 49521 49522 nextFiber = nextFiber.return; 49523 } 49524 } 49525 49526 fiber = nextFiber; 49527 } 49528} 49529function prepareToReadContext(workInProgress, renderExpirationTime) { 49530 currentlyRenderingFiber = workInProgress; 49531 lastContextDependency = null; 49532 lastContextWithAllBitsObserved = null; 49533 var dependencies = workInProgress.dependencies; 49534 49535 if (dependencies !== null) { 49536 var firstContext = dependencies.firstContext; 49537 49538 if (firstContext !== null) { 49539 if (dependencies.expirationTime >= renderExpirationTime) { 49540 // Context list has a pending update. Mark that this fiber performed work. 49541 markWorkInProgressReceivedUpdate(); 49542 } // Reset the work-in-progress list 49543 49544 49545 dependencies.firstContext = null; 49546 } 49547 } 49548} 49549function readContext(context, observedBits) { 49550 { 49551 // This warning would fire if you read context inside a Hook like useMemo. 49552 // Unlike the class check below, it's not enforced in production for perf. 49553 if (isDisallowedContextReadInDEV) { 49554 error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().'); 49555 } 49556 } 49557 49558 if (lastContextWithAllBitsObserved === context) ; else if (observedBits === false || observedBits === 0) ; else { 49559 var resolvedObservedBits; // Avoid deopting on observable arguments or heterogeneous types. 49560 49561 if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) { 49562 // Observe all updates. 49563 lastContextWithAllBitsObserved = context; 49564 resolvedObservedBits = MAX_SIGNED_31_BIT_INT; 49565 } else { 49566 resolvedObservedBits = observedBits; 49567 } 49568 49569 var contextItem = { 49570 context: context, 49571 observedBits: resolvedObservedBits, 49572 next: null 49573 }; 49574 49575 if (lastContextDependency === null) { 49576 if (!(currentlyRenderingFiber !== null)) { 49577 { 49578 throw Error( "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." ); 49579 } 49580 } // This is the first dependency for this component. Create a new list. 49581 49582 49583 lastContextDependency = contextItem; 49584 currentlyRenderingFiber.dependencies = { 49585 expirationTime: NoWork, 49586 firstContext: contextItem, 49587 responders: null 49588 }; 49589 } else { 49590 // Append a new context item. 49591 lastContextDependency = lastContextDependency.next = contextItem; 49592 } 49593 } 49594 49595 return context._currentValue ; 49596} 49597 49598var UpdateState = 0; 49599var ReplaceState = 1; 49600var ForceUpdate = 2; 49601var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`. 49602// It should only be read right after calling `processUpdateQueue`, via 49603// `checkHasForceUpdateAfterProcessing`. 49604 49605var hasForceUpdate = false; 49606var didWarnUpdateInsideUpdate; 49607var currentlyProcessingQueue; 49608 49609{ 49610 didWarnUpdateInsideUpdate = false; 49611 currentlyProcessingQueue = null; 49612} 49613 49614function initializeUpdateQueue(fiber) { 49615 var queue = { 49616 baseState: fiber.memoizedState, 49617 baseQueue: null, 49618 shared: { 49619 pending: null 49620 }, 49621 effects: null 49622 }; 49623 fiber.updateQueue = queue; 49624} 49625function cloneUpdateQueue(current, workInProgress) { 49626 // Clone the update queue from current. Unless it's already a clone. 49627 var queue = workInProgress.updateQueue; 49628 var currentQueue = current.updateQueue; 49629 49630 if (queue === currentQueue) { 49631 var clone = { 49632 baseState: currentQueue.baseState, 49633 baseQueue: currentQueue.baseQueue, 49634 shared: currentQueue.shared, 49635 effects: currentQueue.effects 49636 }; 49637 workInProgress.updateQueue = clone; 49638 } 49639} 49640function createUpdate(expirationTime, suspenseConfig) { 49641 var update = { 49642 expirationTime: expirationTime, 49643 suspenseConfig: suspenseConfig, 49644 tag: UpdateState, 49645 payload: null, 49646 callback: null, 49647 next: null 49648 }; 49649 update.next = update; 49650 49651 { 49652 update.priority = getCurrentPriorityLevel(); 49653 } 49654 49655 return update; 49656} 49657function enqueueUpdate(fiber, update) { 49658 var updateQueue = fiber.updateQueue; 49659 49660 if (updateQueue === null) { 49661 // Only occurs if the fiber has been unmounted. 49662 return; 49663 } 49664 49665 var sharedQueue = updateQueue.shared; 49666 var pending = sharedQueue.pending; 49667 49668 if (pending === null) { 49669 // This is the first update. Create a circular list. 49670 update.next = update; 49671 } else { 49672 update.next = pending.next; 49673 pending.next = update; 49674 } 49675 49676 sharedQueue.pending = update; 49677 49678 { 49679 if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) { 49680 error('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.'); 49681 49682 didWarnUpdateInsideUpdate = true; 49683 } 49684 } 49685} 49686function enqueueCapturedUpdate(workInProgress, update) { 49687 var current = workInProgress.alternate; 49688 49689 if (current !== null) { 49690 // Ensure the work-in-progress queue is a clone 49691 cloneUpdateQueue(current, workInProgress); 49692 } // Captured updates go only on the work-in-progress queue. 49693 49694 49695 var queue = workInProgress.updateQueue; // Append the update to the end of the list. 49696 49697 var last = queue.baseQueue; 49698 49699 if (last === null) { 49700 queue.baseQueue = update.next = update; 49701 update.next = update; 49702 } else { 49703 update.next = last.next; 49704 last.next = update; 49705 } 49706} 49707 49708function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) { 49709 switch (update.tag) { 49710 case ReplaceState: 49711 { 49712 var payload = update.payload; 49713 49714 if (typeof payload === 'function') { 49715 // Updater function 49716 { 49717 enterDisallowedContextReadInDEV(); 49718 49719 if ( workInProgress.mode & StrictMode) { 49720 payload.call(instance, prevState, nextProps); 49721 } 49722 } 49723 49724 var nextState = payload.call(instance, prevState, nextProps); 49725 49726 { 49727 exitDisallowedContextReadInDEV(); 49728 } 49729 49730 return nextState; 49731 } // State object 49732 49733 49734 return payload; 49735 } 49736 49737 case CaptureUpdate: 49738 { 49739 workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture; 49740 } 49741 // Intentional fallthrough 49742 49743 case UpdateState: 49744 { 49745 var _payload = update.payload; 49746 var partialState; 49747 49748 if (typeof _payload === 'function') { 49749 // Updater function 49750 { 49751 enterDisallowedContextReadInDEV(); 49752 49753 if ( workInProgress.mode & StrictMode) { 49754 _payload.call(instance, prevState, nextProps); 49755 } 49756 } 49757 49758 partialState = _payload.call(instance, prevState, nextProps); 49759 49760 { 49761 exitDisallowedContextReadInDEV(); 49762 } 49763 } else { 49764 // Partial state object 49765 partialState = _payload; 49766 } 49767 49768 if (partialState === null || partialState === undefined) { 49769 // Null and undefined are treated as no-ops. 49770 return prevState; 49771 } // Merge the partial state and the previous state. 49772 49773 49774 return _assign({}, prevState, partialState); 49775 } 49776 49777 case ForceUpdate: 49778 { 49779 hasForceUpdate = true; 49780 return prevState; 49781 } 49782 } 49783 49784 return prevState; 49785} 49786 49787function processUpdateQueue(workInProgress, props, instance, renderExpirationTime) { 49788 // This is always non-null on a ClassComponent or HostRoot 49789 var queue = workInProgress.updateQueue; 49790 hasForceUpdate = false; 49791 49792 { 49793 currentlyProcessingQueue = queue.shared; 49794 } // The last rebase update that is NOT part of the base state. 49795 49796 49797 var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet. 49798 49799 var pendingQueue = queue.shared.pending; 49800 49801 if (pendingQueue !== null) { 49802 // We have new updates that haven't been processed yet. 49803 // We'll add them to the base queue. 49804 if (baseQueue !== null) { 49805 // Merge the pending queue and the base queue. 49806 var baseFirst = baseQueue.next; 49807 var pendingFirst = pendingQueue.next; 49808 baseQueue.next = pendingFirst; 49809 pendingQueue.next = baseFirst; 49810 } 49811 49812 baseQueue = pendingQueue; 49813 queue.shared.pending = null; // TODO: Pass `current` as argument 49814 49815 var current = workInProgress.alternate; 49816 49817 if (current !== null) { 49818 var currentQueue = current.updateQueue; 49819 49820 if (currentQueue !== null) { 49821 currentQueue.baseQueue = pendingQueue; 49822 } 49823 } 49824 } // These values may change as we process the queue. 49825 49826 49827 if (baseQueue !== null) { 49828 var first = baseQueue.next; // Iterate through the list of updates to compute the result. 49829 49830 var newState = queue.baseState; 49831 var newExpirationTime = NoWork; 49832 var newBaseState = null; 49833 var newBaseQueueFirst = null; 49834 var newBaseQueueLast = null; 49835 49836 if (first !== null) { 49837 var update = first; 49838 49839 do { 49840 var updateExpirationTime = update.expirationTime; 49841 49842 if (updateExpirationTime < renderExpirationTime) { 49843 // Priority is insufficient. Skip this update. If this is the first 49844 // skipped update, the previous update/state is the new base 49845 // update/state. 49846 var clone = { 49847 expirationTime: update.expirationTime, 49848 suspenseConfig: update.suspenseConfig, 49849 tag: update.tag, 49850 payload: update.payload, 49851 callback: update.callback, 49852 next: null 49853 }; 49854 49855 if (newBaseQueueLast === null) { 49856 newBaseQueueFirst = newBaseQueueLast = clone; 49857 newBaseState = newState; 49858 } else { 49859 newBaseQueueLast = newBaseQueueLast.next = clone; 49860 } // Update the remaining priority in the queue. 49861 49862 49863 if (updateExpirationTime > newExpirationTime) { 49864 newExpirationTime = updateExpirationTime; 49865 } 49866 } else { 49867 // This update does have sufficient priority. 49868 if (newBaseQueueLast !== null) { 49869 var _clone = { 49870 expirationTime: Sync, 49871 // This update is going to be committed so we never want uncommit it. 49872 suspenseConfig: update.suspenseConfig, 49873 tag: update.tag, 49874 payload: update.payload, 49875 callback: update.callback, 49876 next: null 49877 }; 49878 newBaseQueueLast = newBaseQueueLast.next = _clone; 49879 } // Mark the event time of this update as relevant to this render pass. 49880 // TODO: This should ideally use the true event time of this update rather than 49881 // its priority which is a derived and not reverseable value. 49882 // TODO: We should skip this update if it was already committed but currently 49883 // we have no way of detecting the difference between a committed and suspended 49884 // update here. 49885 49886 49887 markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process this update. 49888 49889 newState = getStateFromUpdate(workInProgress, queue, update, newState, props, instance); 49890 var callback = update.callback; 49891 49892 if (callback !== null) { 49893 workInProgress.effectTag |= Callback; 49894 var effects = queue.effects; 49895 49896 if (effects === null) { 49897 queue.effects = [update]; 49898 } else { 49899 effects.push(update); 49900 } 49901 } 49902 } 49903 49904 update = update.next; 49905 49906 if (update === null || update === first) { 49907 pendingQueue = queue.shared.pending; 49908 49909 if (pendingQueue === null) { 49910 break; 49911 } else { 49912 // An update was scheduled from inside a reducer. Add the new 49913 // pending updates to the end of the list and keep processing. 49914 update = baseQueue.next = pendingQueue.next; 49915 pendingQueue.next = first; 49916 queue.baseQueue = baseQueue = pendingQueue; 49917 queue.shared.pending = null; 49918 } 49919 } 49920 } while (true); 49921 } 49922 49923 if (newBaseQueueLast === null) { 49924 newBaseState = newState; 49925 } else { 49926 newBaseQueueLast.next = newBaseQueueFirst; 49927 } 49928 49929 queue.baseState = newBaseState; 49930 queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue. 49931 // This should be fine because the only two other things that contribute to 49932 // expiration time are props and context. We're already in the middle of the 49933 // begin phase by the time we start processing the queue, so we've already 49934 // dealt with the props. Context in components that specify 49935 // shouldComponentUpdate is tricky; but we'll have to account for 49936 // that regardless. 49937 49938 markUnprocessedUpdateTime(newExpirationTime); 49939 workInProgress.expirationTime = newExpirationTime; 49940 workInProgress.memoizedState = newState; 49941 } 49942 49943 { 49944 currentlyProcessingQueue = null; 49945 } 49946} 49947 49948function callCallback(callback, context) { 49949 if (!(typeof callback === 'function')) { 49950 { 49951 throw Error( "Invalid argument passed as callback. Expected a function. Instead received: " + callback ); 49952 } 49953 } 49954 49955 callback.call(context); 49956} 49957 49958function resetHasForceUpdateBeforeProcessing() { 49959 hasForceUpdate = false; 49960} 49961function checkHasForceUpdateAfterProcessing() { 49962 return hasForceUpdate; 49963} 49964function commitUpdateQueue(finishedWork, finishedQueue, instance) { 49965 // Commit the effects 49966 var effects = finishedQueue.effects; 49967 finishedQueue.effects = null; 49968 49969 if (effects !== null) { 49970 for (var i = 0; i < effects.length; i++) { 49971 var effect = effects[i]; 49972 var callback = effect.callback; 49973 49974 if (callback !== null) { 49975 effect.callback = null; 49976 callCallback(callback, instance); 49977 } 49978 } 49979 } 49980} 49981 49982var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; 49983function requestCurrentSuspenseConfig() { 49984 return ReactCurrentBatchConfig.suspense; 49985} 49986 49987var fakeInternalInstance = {}; 49988var isArray = Array.isArray; // React.Component uses a shared frozen object by default. 49989// We'll use it to determine whether we need to initialize legacy refs. 49990 49991var emptyRefsObject = new React.Component().refs; 49992var didWarnAboutStateAssignmentForComponent; 49993var didWarnAboutUninitializedState; 49994var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate; 49995var didWarnAboutLegacyLifecyclesAndDerivedState; 49996var didWarnAboutUndefinedDerivedState; 49997var warnOnUndefinedDerivedState; 49998var warnOnInvalidCallback; 49999var didWarnAboutDirectlyAssigningPropsToState; 50000var didWarnAboutContextTypeAndContextTypes; 50001var didWarnAboutInvalidateContextType; 50002 50003{ 50004 didWarnAboutStateAssignmentForComponent = new Set(); 50005 didWarnAboutUninitializedState = new Set(); 50006 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set(); 50007 didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); 50008 didWarnAboutDirectlyAssigningPropsToState = new Set(); 50009 didWarnAboutUndefinedDerivedState = new Set(); 50010 didWarnAboutContextTypeAndContextTypes = new Set(); 50011 didWarnAboutInvalidateContextType = new Set(); 50012 var didWarnOnInvalidCallback = new Set(); 50013 50014 warnOnInvalidCallback = function (callback, callerName) { 50015 if (callback === null || typeof callback === 'function') { 50016 return; 50017 } 50018 50019 var key = callerName + "_" + callback; 50020 50021 if (!didWarnOnInvalidCallback.has(key)) { 50022 didWarnOnInvalidCallback.add(key); 50023 50024 error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); 50025 } 50026 }; 50027 50028 warnOnUndefinedDerivedState = function (type, partialState) { 50029 if (partialState === undefined) { 50030 var componentName = getComponentName(type) || 'Component'; 50031 50032 if (!didWarnAboutUndefinedDerivedState.has(componentName)) { 50033 didWarnAboutUndefinedDerivedState.add(componentName); 50034 50035 error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName); 50036 } 50037 } 50038 }; // This is so gross but it's at least non-critical and can be removed if 50039 // it causes problems. This is meant to give a nicer error message for 50040 // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component, 50041 // ...)) which otherwise throws a "_processChildContext is not a function" 50042 // exception. 50043 50044 50045 Object.defineProperty(fakeInternalInstance, '_processChildContext', { 50046 enumerable: false, 50047 value: function () { 50048 { 50049 { 50050 throw Error( "_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)." ); 50051 } 50052 } 50053 } 50054 }); 50055 Object.freeze(fakeInternalInstance); 50056} 50057 50058function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) { 50059 var prevState = workInProgress.memoizedState; 50060 50061 { 50062 if ( workInProgress.mode & StrictMode) { 50063 // Invoke the function an extra time to help detect side-effects. 50064 getDerivedStateFromProps(nextProps, prevState); 50065 } 50066 } 50067 50068 var partialState = getDerivedStateFromProps(nextProps, prevState); 50069 50070 { 50071 warnOnUndefinedDerivedState(ctor, partialState); 50072 } // Merge the partial state and the previous state. 50073 50074 50075 var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState); 50076 workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the 50077 // base state. 50078 50079 if (workInProgress.expirationTime === NoWork) { 50080 // Queue is always non-null for classes 50081 var updateQueue = workInProgress.updateQueue; 50082 updateQueue.baseState = memoizedState; 50083 } 50084} 50085var classComponentUpdater = { 50086 isMounted: isMounted, 50087 enqueueSetState: function (inst, payload, callback) { 50088 var fiber = get(inst); 50089 var currentTime = requestCurrentTimeForUpdate(); 50090 var suspenseConfig = requestCurrentSuspenseConfig(); 50091 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); 50092 var update = createUpdate(expirationTime, suspenseConfig); 50093 update.payload = payload; 50094 50095 if (callback !== undefined && callback !== null) { 50096 { 50097 warnOnInvalidCallback(callback, 'setState'); 50098 } 50099 50100 update.callback = callback; 50101 } 50102 50103 enqueueUpdate(fiber, update); 50104 scheduleWork(fiber, expirationTime); 50105 }, 50106 enqueueReplaceState: function (inst, payload, callback) { 50107 var fiber = get(inst); 50108 var currentTime = requestCurrentTimeForUpdate(); 50109 var suspenseConfig = requestCurrentSuspenseConfig(); 50110 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); 50111 var update = createUpdate(expirationTime, suspenseConfig); 50112 update.tag = ReplaceState; 50113 update.payload = payload; 50114 50115 if (callback !== undefined && callback !== null) { 50116 { 50117 warnOnInvalidCallback(callback, 'replaceState'); 50118 } 50119 50120 update.callback = callback; 50121 } 50122 50123 enqueueUpdate(fiber, update); 50124 scheduleWork(fiber, expirationTime); 50125 }, 50126 enqueueForceUpdate: function (inst, callback) { 50127 var fiber = get(inst); 50128 var currentTime = requestCurrentTimeForUpdate(); 50129 var suspenseConfig = requestCurrentSuspenseConfig(); 50130 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); 50131 var update = createUpdate(expirationTime, suspenseConfig); 50132 update.tag = ForceUpdate; 50133 50134 if (callback !== undefined && callback !== null) { 50135 { 50136 warnOnInvalidCallback(callback, 'forceUpdate'); 50137 } 50138 50139 update.callback = callback; 50140 } 50141 50142 enqueueUpdate(fiber, update); 50143 scheduleWork(fiber, expirationTime); 50144 } 50145}; 50146 50147function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) { 50148 var instance = workInProgress.stateNode; 50149 50150 if (typeof instance.shouldComponentUpdate === 'function') { 50151 { 50152 if ( workInProgress.mode & StrictMode) { 50153 // Invoke the function an extra time to help detect side-effects. 50154 instance.shouldComponentUpdate(newProps, newState, nextContext); 50155 } 50156 } 50157 50158 startPhaseTimer(workInProgress, 'shouldComponentUpdate'); 50159 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext); 50160 stopPhaseTimer(); 50161 50162 { 50163 if (shouldUpdate === undefined) { 50164 error('%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component'); 50165 } 50166 } 50167 50168 return shouldUpdate; 50169 } 50170 50171 if (ctor.prototype && ctor.prototype.isPureReactComponent) { 50172 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState); 50173 } 50174 50175 return true; 50176} 50177 50178function checkClassInstance(workInProgress, ctor, newProps) { 50179 var instance = workInProgress.stateNode; 50180 50181 { 50182 var name = getComponentName(ctor) || 'Component'; 50183 var renderPresent = instance.render; 50184 50185 if (!renderPresent) { 50186 if (ctor.prototype && typeof ctor.prototype.render === 'function') { 50187 error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name); 50188 } else { 50189 error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name); 50190 } 50191 } 50192 50193 if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) { 50194 error('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); 50195 } 50196 50197 if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) { 50198 error('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); 50199 } 50200 50201 if (instance.propTypes) { 50202 error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name); 50203 } 50204 50205 if (instance.contextType) { 50206 error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name); 50207 } 50208 50209 { 50210 if (instance.contextTypes) { 50211 error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name); 50212 } 50213 50214 if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) { 50215 didWarnAboutContextTypeAndContextTypes.add(ctor); 50216 50217 error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name); 50218 } 50219 } 50220 50221 if (typeof instance.componentShouldUpdate === 'function') { 50222 error('%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); 50223 } 50224 50225 if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') { 50226 error('%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component'); 50227 } 50228 50229 if (typeof instance.componentDidUnmount === 'function') { 50230 error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name); 50231 } 50232 50233 if (typeof instance.componentDidReceiveProps === 'function') { 50234 error('%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); 50235 } 50236 50237 if (typeof instance.componentWillRecieveProps === 'function') { 50238 error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name); 50239 } 50240 50241 if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') { 50242 error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name); 50243 } 50244 50245 var hasMutatedProps = instance.props !== newProps; 50246 50247 if (instance.props !== undefined && hasMutatedProps) { 50248 error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name); 50249 } 50250 50251 if (instance.defaultProps) { 50252 error('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); 50253 } 50254 50255 if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) { 50256 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); 50257 50258 error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor)); 50259 } 50260 50261 if (typeof instance.getDerivedStateFromProps === 'function') { 50262 error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); 50263 } 50264 50265 if (typeof instance.getDerivedStateFromError === 'function') { 50266 error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); 50267 } 50268 50269 if (typeof ctor.getSnapshotBeforeUpdate === 'function') { 50270 error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name); 50271 } 50272 50273 var _state = instance.state; 50274 50275 if (_state && (typeof _state !== 'object' || isArray(_state))) { 50276 error('%s.state: must be set to an object or null', name); 50277 } 50278 50279 if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') { 50280 error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name); 50281 } 50282 } 50283} 50284 50285function adoptClassInstance(workInProgress, instance) { 50286 instance.updater = classComponentUpdater; 50287 workInProgress.stateNode = instance; // The instance needs access to the fiber so that it can schedule updates 50288 50289 set(instance, workInProgress); 50290 50291 { 50292 instance._reactInternalInstance = fakeInternalInstance; 50293 } 50294} 50295 50296function constructClassInstance(workInProgress, ctor, props) { 50297 var isLegacyContextConsumer = false; 50298 var unmaskedContext = emptyContextObject; 50299 var context = emptyContextObject; 50300 var contextType = ctor.contextType; 50301 50302 { 50303 if ('contextType' in ctor) { 50304 var isValid = // Allow null for conditional declaration 50305 contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer> 50306 50307 if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { 50308 didWarnAboutInvalidateContextType.add(ctor); 50309 var addendum = ''; 50310 50311 if (contextType === undefined) { 50312 addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.'; 50313 } else if (typeof contextType !== 'object') { 50314 addendum = ' However, it is set to a ' + typeof contextType + '.'; 50315 } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { 50316 addendum = ' Did you accidentally pass the Context.Provider instead?'; 50317 } else if (contextType._context !== undefined) { 50318 // <Context.Consumer> 50319 addendum = ' Did you accidentally pass the Context.Consumer instead?'; 50320 } else { 50321 addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.'; 50322 } 50323 50324 error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum); 50325 } 50326 } 50327 } 50328 50329 if (typeof contextType === 'object' && contextType !== null) { 50330 context = readContext(contextType); 50331 } else { 50332 unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 50333 var contextTypes = ctor.contextTypes; 50334 isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined; 50335 context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject; 50336 } // Instantiate twice to help detect side-effects. 50337 50338 50339 { 50340 if ( workInProgress.mode & StrictMode) { 50341 new ctor(props, context); // eslint-disable-line no-new 50342 } 50343 } 50344 50345 var instance = new ctor(props, context); 50346 var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null; 50347 adoptClassInstance(workInProgress, instance); 50348 50349 { 50350 if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) { 50351 var componentName = getComponentName(ctor) || 'Component'; 50352 50353 if (!didWarnAboutUninitializedState.has(componentName)) { 50354 didWarnAboutUninitializedState.add(componentName); 50355 50356 error('`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName); 50357 } 50358 } // If new component APIs are defined, "unsafe" lifecycles won't be called. 50359 // Warn about these lifecycles if they are present. 50360 // Don't warn about react-lifecycles-compat polyfilled methods though. 50361 50362 50363 if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') { 50364 var foundWillMountName = null; 50365 var foundWillReceivePropsName = null; 50366 var foundWillUpdateName = null; 50367 50368 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) { 50369 foundWillMountName = 'componentWillMount'; 50370 } else if (typeof instance.UNSAFE_componentWillMount === 'function') { 50371 foundWillMountName = 'UNSAFE_componentWillMount'; 50372 } 50373 50374 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { 50375 foundWillReceivePropsName = 'componentWillReceiveProps'; 50376 } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 50377 foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps'; 50378 } 50379 50380 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { 50381 foundWillUpdateName = 'componentWillUpdate'; 50382 } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') { 50383 foundWillUpdateName = 'UNSAFE_componentWillUpdate'; 50384 } 50385 50386 if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) { 50387 var _componentName = getComponentName(ctor) || 'Component'; 50388 50389 var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()'; 50390 50391 if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { 50392 didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); 50393 50394 error('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-unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : ''); 50395 } 50396 } 50397 } 50398 } // Cache unmasked context so we can avoid recreating masked context unless necessary. 50399 // ReactFiberContext usually updates this cache but can't for newly-created instances. 50400 50401 50402 if (isLegacyContextConsumer) { 50403 cacheContext(workInProgress, unmaskedContext, context); 50404 } 50405 50406 return instance; 50407} 50408 50409function callComponentWillMount(workInProgress, instance) { 50410 startPhaseTimer(workInProgress, 'componentWillMount'); 50411 var oldState = instance.state; 50412 50413 if (typeof instance.componentWillMount === 'function') { 50414 instance.componentWillMount(); 50415 } 50416 50417 if (typeof instance.UNSAFE_componentWillMount === 'function') { 50418 instance.UNSAFE_componentWillMount(); 50419 } 50420 50421 stopPhaseTimer(); 50422 50423 if (oldState !== instance.state) { 50424 { 50425 error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component'); 50426 } 50427 50428 classComponentUpdater.enqueueReplaceState(instance, instance.state, null); 50429 } 50430} 50431 50432function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) { 50433 var oldState = instance.state; 50434 startPhaseTimer(workInProgress, 'componentWillReceiveProps'); 50435 50436 if (typeof instance.componentWillReceiveProps === 'function') { 50437 instance.componentWillReceiveProps(newProps, nextContext); 50438 } 50439 50440 if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 50441 instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); 50442 } 50443 50444 stopPhaseTimer(); 50445 50446 if (instance.state !== oldState) { 50447 { 50448 var componentName = getComponentName(workInProgress.type) || 'Component'; 50449 50450 if (!didWarnAboutStateAssignmentForComponent.has(componentName)) { 50451 didWarnAboutStateAssignmentForComponent.add(componentName); 50452 50453 error('%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName); 50454 } 50455 } 50456 50457 classComponentUpdater.enqueueReplaceState(instance, instance.state, null); 50458 } 50459} // Invokes the mount life-cycles on a previously never rendered instance. 50460 50461 50462function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) { 50463 { 50464 checkClassInstance(workInProgress, ctor, newProps); 50465 } 50466 50467 var instance = workInProgress.stateNode; 50468 instance.props = newProps; 50469 instance.state = workInProgress.memoizedState; 50470 instance.refs = emptyRefsObject; 50471 initializeUpdateQueue(workInProgress); 50472 var contextType = ctor.contextType; 50473 50474 if (typeof contextType === 'object' && contextType !== null) { 50475 instance.context = readContext(contextType); 50476 } else { 50477 var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 50478 instance.context = getMaskedContext(workInProgress, unmaskedContext); 50479 } 50480 50481 { 50482 if (instance.state === newProps) { 50483 var componentName = getComponentName(ctor) || 'Component'; 50484 50485 if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { 50486 didWarnAboutDirectlyAssigningPropsToState.add(componentName); 50487 50488 error('%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName); 50489 } 50490 } 50491 50492 if (workInProgress.mode & StrictMode) { 50493 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance); 50494 } 50495 50496 { 50497 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance); 50498 } 50499 } 50500 50501 processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); 50502 instance.state = workInProgress.memoizedState; 50503 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 50504 50505 if (typeof getDerivedStateFromProps === 'function') { 50506 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); 50507 instance.state = workInProgress.memoizedState; 50508 } // In order to support react-lifecycles-compat polyfilled components, 50509 // Unsafe lifecycles should not be invoked for components using the new APIs. 50510 50511 50512 if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { 50513 callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's 50514 // process them now. 50515 50516 processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); 50517 instance.state = workInProgress.memoizedState; 50518 } 50519 50520 if (typeof instance.componentDidMount === 'function') { 50521 workInProgress.effectTag |= Update; 50522 } 50523} 50524 50525function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) { 50526 var instance = workInProgress.stateNode; 50527 var oldProps = workInProgress.memoizedProps; 50528 instance.props = oldProps; 50529 var oldContext = instance.context; 50530 var contextType = ctor.contextType; 50531 var nextContext = emptyContextObject; 50532 50533 if (typeof contextType === 'object' && contextType !== null) { 50534 nextContext = readContext(contextType); 50535 } else { 50536 var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 50537 nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext); 50538 } 50539 50540 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 50541 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what 50542 // ever the previously attempted to render - not the "current". However, 50543 // during componentDidUpdate we pass the "current" props. 50544 // In order to support react-lifecycles-compat polyfilled components, 50545 // Unsafe lifecycles should not be invoked for components using the new APIs. 50546 50547 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { 50548 if (oldProps !== newProps || oldContext !== nextContext) { 50549 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); 50550 } 50551 } 50552 50553 resetHasForceUpdateBeforeProcessing(); 50554 var oldState = workInProgress.memoizedState; 50555 var newState = instance.state = oldState; 50556 processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); 50557 newState = workInProgress.memoizedState; 50558 50559 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { 50560 // If an update was already in progress, we should schedule an Update 50561 // effect even though we're bailing out, so that cWU/cDU are called. 50562 if (typeof instance.componentDidMount === 'function') { 50563 workInProgress.effectTag |= Update; 50564 } 50565 50566 return false; 50567 } 50568 50569 if (typeof getDerivedStateFromProps === 'function') { 50570 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); 50571 newState = workInProgress.memoizedState; 50572 } 50573 50574 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext); 50575 50576 if (shouldUpdate) { 50577 // In order to support react-lifecycles-compat polyfilled components, 50578 // Unsafe lifecycles should not be invoked for components using the new APIs. 50579 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { 50580 startPhaseTimer(workInProgress, 'componentWillMount'); 50581 50582 if (typeof instance.componentWillMount === 'function') { 50583 instance.componentWillMount(); 50584 } 50585 50586 if (typeof instance.UNSAFE_componentWillMount === 'function') { 50587 instance.UNSAFE_componentWillMount(); 50588 } 50589 50590 stopPhaseTimer(); 50591 } 50592 50593 if (typeof instance.componentDidMount === 'function') { 50594 workInProgress.effectTag |= Update; 50595 } 50596 } else { 50597 // If an update was already in progress, we should schedule an Update 50598 // effect even though we're bailing out, so that cWU/cDU are called. 50599 if (typeof instance.componentDidMount === 'function') { 50600 workInProgress.effectTag |= Update; 50601 } // If shouldComponentUpdate returned false, we should still update the 50602 // memoized state to indicate that this work can be reused. 50603 50604 50605 workInProgress.memoizedProps = newProps; 50606 workInProgress.memoizedState = newState; 50607 } // Update the existing instance's state, props, and context pointers even 50608 // if shouldComponentUpdate returns false. 50609 50610 50611 instance.props = newProps; 50612 instance.state = newState; 50613 instance.context = nextContext; 50614 return shouldUpdate; 50615} // Invokes the update life-cycles and returns false if it shouldn't rerender. 50616 50617 50618function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) { 50619 var instance = workInProgress.stateNode; 50620 cloneUpdateQueue(current, workInProgress); 50621 var oldProps = workInProgress.memoizedProps; 50622 instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps); 50623 var oldContext = instance.context; 50624 var contextType = ctor.contextType; 50625 var nextContext = emptyContextObject; 50626 50627 if (typeof contextType === 'object' && contextType !== null) { 50628 nextContext = readContext(contextType); 50629 } else { 50630 var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 50631 nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); 50632 } 50633 50634 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 50635 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what 50636 // ever the previously attempted to render - not the "current". However, 50637 // during componentDidUpdate we pass the "current" props. 50638 // In order to support react-lifecycles-compat polyfilled components, 50639 // Unsafe lifecycles should not be invoked for components using the new APIs. 50640 50641 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { 50642 if (oldProps !== newProps || oldContext !== nextContext) { 50643 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); 50644 } 50645 } 50646 50647 resetHasForceUpdateBeforeProcessing(); 50648 var oldState = workInProgress.memoizedState; 50649 var newState = instance.state = oldState; 50650 processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); 50651 newState = workInProgress.memoizedState; 50652 50653 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { 50654 // If an update was already in progress, we should schedule an Update 50655 // effect even though we're bailing out, so that cWU/cDU are called. 50656 if (typeof instance.componentDidUpdate === 'function') { 50657 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 50658 workInProgress.effectTag |= Update; 50659 } 50660 } 50661 50662 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 50663 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 50664 workInProgress.effectTag |= Snapshot; 50665 } 50666 } 50667 50668 return false; 50669 } 50670 50671 if (typeof getDerivedStateFromProps === 'function') { 50672 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); 50673 newState = workInProgress.memoizedState; 50674 } 50675 50676 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext); 50677 50678 if (shouldUpdate) { 50679 // In order to support react-lifecycles-compat polyfilled components, 50680 // Unsafe lifecycles should not be invoked for components using the new APIs. 50681 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) { 50682 startPhaseTimer(workInProgress, 'componentWillUpdate'); 50683 50684 if (typeof instance.componentWillUpdate === 'function') { 50685 instance.componentWillUpdate(newProps, newState, nextContext); 50686 } 50687 50688 if (typeof instance.UNSAFE_componentWillUpdate === 'function') { 50689 instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext); 50690 } 50691 50692 stopPhaseTimer(); 50693 } 50694 50695 if (typeof instance.componentDidUpdate === 'function') { 50696 workInProgress.effectTag |= Update; 50697 } 50698 50699 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 50700 workInProgress.effectTag |= Snapshot; 50701 } 50702 } else { 50703 // If an update was already in progress, we should schedule an Update 50704 // effect even though we're bailing out, so that cWU/cDU are called. 50705 if (typeof instance.componentDidUpdate === 'function') { 50706 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 50707 workInProgress.effectTag |= Update; 50708 } 50709 } 50710 50711 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 50712 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { 50713 workInProgress.effectTag |= Snapshot; 50714 } 50715 } // If shouldComponentUpdate returned false, we should still update the 50716 // memoized props/state to indicate that this work can be reused. 50717 50718 50719 workInProgress.memoizedProps = newProps; 50720 workInProgress.memoizedState = newState; 50721 } // Update the existing instance's state, props, and context pointers even 50722 // if shouldComponentUpdate returns false. 50723 50724 50725 instance.props = newProps; 50726 instance.state = newState; 50727 instance.context = nextContext; 50728 return shouldUpdate; 50729} 50730 50731var didWarnAboutMaps; 50732var didWarnAboutGenerators; 50733var didWarnAboutStringRefs; 50734var ownerHasKeyUseWarning; 50735var ownerHasFunctionTypeWarning; 50736 50737var warnForMissingKey = function (child) {}; 50738 50739{ 50740 didWarnAboutMaps = false; 50741 didWarnAboutGenerators = false; 50742 didWarnAboutStringRefs = {}; 50743 /** 50744 * Warn if there's no key explicitly set on dynamic arrays of children or 50745 * object keys are not valid. This allows us to keep track of children between 50746 * updates. 50747 */ 50748 50749 ownerHasKeyUseWarning = {}; 50750 ownerHasFunctionTypeWarning = {}; 50751 50752 warnForMissingKey = function (child) { 50753 if (child === null || typeof child !== 'object') { 50754 return; 50755 } 50756 50757 if (!child._store || child._store.validated || child.key != null) { 50758 return; 50759 } 50760 50761 if (!(typeof child._store === 'object')) { 50762 { 50763 throw Error( "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." ); 50764 } 50765 } 50766 50767 child._store.validated = true; 50768 var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev(); 50769 50770 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 50771 return; 50772 } 50773 50774 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; 50775 50776 error('Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.'); 50777 }; 50778} 50779 50780var isArray$1 = Array.isArray; 50781 50782function coerceRef(returnFiber, current, element) { 50783 var mixedRef = element.ref; 50784 50785 if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') { 50786 { 50787 // TODO: Clean this up once we turn on the string ref warning for 50788 // everyone, because the strict mode case will no longer be relevant 50789 if ((returnFiber.mode & StrictMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs 50790 // because these cannot be automatically converted to an arrow function 50791 // using a codemod. Therefore, we don't have to warn about string refs again. 50792 !(element._owner && element._self && element._owner.stateNode !== element._self)) { 50793 var componentName = getComponentName(returnFiber.type) || 'Component'; 50794 50795 if (!didWarnAboutStringRefs[componentName]) { 50796 { 50797 error('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 useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', mixedRef, getStackByFiberInDevAndProd(returnFiber)); 50798 } 50799 50800 didWarnAboutStringRefs[componentName] = true; 50801 } 50802 } 50803 } 50804 50805 if (element._owner) { 50806 var owner = element._owner; 50807 var inst; 50808 50809 if (owner) { 50810 var ownerFiber = owner; 50811 50812 if (!(ownerFiber.tag === ClassComponent)) { 50813 { 50814 throw Error( "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" ); 50815 } 50816 } 50817 50818 inst = ownerFiber.stateNode; 50819 } 50820 50821 if (!inst) { 50822 { 50823 throw Error( "Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue." ); 50824 } 50825 } 50826 50827 var stringRef = '' + mixedRef; // Check if previous string ref matches new string ref 50828 50829 if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) { 50830 return current.ref; 50831 } 50832 50833 var ref = function (value) { 50834 var refs = inst.refs; 50835 50836 if (refs === emptyRefsObject) { 50837 // This is a lazy pooled frozen object, so we need to initialize. 50838 refs = inst.refs = {}; 50839 } 50840 50841 if (value === null) { 50842 delete refs[stringRef]; 50843 } else { 50844 refs[stringRef] = value; 50845 } 50846 }; 50847 50848 ref._stringRef = stringRef; 50849 return ref; 50850 } else { 50851 if (!(typeof mixedRef === 'string')) { 50852 { 50853 throw Error( "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); 50854 } 50855 } 50856 50857 if (!element._owner) { 50858 { 50859 throw Error( "Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function 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." ); 50860 } 50861 } 50862 } 50863 } 50864 50865 return mixedRef; 50866} 50867 50868function throwOnInvalidObjectType(returnFiber, newChild) { 50869 if (returnFiber.type !== 'textarea') { 50870 var addendum = ''; 50871 50872 { 50873 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev(); 50874 } 50875 50876 { 50877 { 50878 throw Error( "Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + ")." + addendum ); 50879 } 50880 } 50881 } 50882} 50883 50884function warnOnFunctionType() { 50885 { 50886 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.' + getCurrentFiberStackInDev(); 50887 50888 if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { 50889 return; 50890 } 50891 50892 ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; 50893 50894 error('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.'); 50895 } 50896} // This wrapper function exists because I expect to clone the code in each path 50897// to be able to optimize each path individually by branching early. This needs 50898// a compiler or we can do it manually. Helpers that don't need this branching 50899// live outside of this function. 50900 50901 50902function ChildReconciler(shouldTrackSideEffects) { 50903 function deleteChild(returnFiber, childToDelete) { 50904 if (!shouldTrackSideEffects) { 50905 // Noop. 50906 return; 50907 } // Deletions are added in reversed order so we add it to the front. 50908 // At this point, the return fiber's effect list is empty except for 50909 // deletions, so we can just append the deletion to the list. The remaining 50910 // effects aren't added until the complete phase. Once we implement 50911 // resuming, this may not be true. 50912 50913 50914 var last = returnFiber.lastEffect; 50915 50916 if (last !== null) { 50917 last.nextEffect = childToDelete; 50918 returnFiber.lastEffect = childToDelete; 50919 } else { 50920 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; 50921 } 50922 50923 childToDelete.nextEffect = null; 50924 childToDelete.effectTag = Deletion; 50925 } 50926 50927 function deleteRemainingChildren(returnFiber, currentFirstChild) { 50928 if (!shouldTrackSideEffects) { 50929 // Noop. 50930 return null; 50931 } // TODO: For the shouldClone case, this could be micro-optimized a bit by 50932 // assuming that after the first child we've already added everything. 50933 50934 50935 var childToDelete = currentFirstChild; 50936 50937 while (childToDelete !== null) { 50938 deleteChild(returnFiber, childToDelete); 50939 childToDelete = childToDelete.sibling; 50940 } 50941 50942 return null; 50943 } 50944 50945 function mapRemainingChildren(returnFiber, currentFirstChild) { 50946 // Add the remaining children to a temporary map so that we can find them by 50947 // keys quickly. Implicit (null) keys get added to this set with their index 50948 // instead. 50949 var existingChildren = new Map(); 50950 var existingChild = currentFirstChild; 50951 50952 while (existingChild !== null) { 50953 if (existingChild.key !== null) { 50954 existingChildren.set(existingChild.key, existingChild); 50955 } else { 50956 existingChildren.set(existingChild.index, existingChild); 50957 } 50958 50959 existingChild = existingChild.sibling; 50960 } 50961 50962 return existingChildren; 50963 } 50964 50965 function useFiber(fiber, pendingProps) { 50966 // We currently set sibling to null and index to 0 here because it is easy 50967 // to forget to do before returning it. E.g. for the single child case. 50968 var clone = createWorkInProgress(fiber, pendingProps); 50969 clone.index = 0; 50970 clone.sibling = null; 50971 return clone; 50972 } 50973 50974 function placeChild(newFiber, lastPlacedIndex, newIndex) { 50975 newFiber.index = newIndex; 50976 50977 if (!shouldTrackSideEffects) { 50978 // Noop. 50979 return lastPlacedIndex; 50980 } 50981 50982 var current = newFiber.alternate; 50983 50984 if (current !== null) { 50985 var oldIndex = current.index; 50986 50987 if (oldIndex < lastPlacedIndex) { 50988 // This is a move. 50989 newFiber.effectTag = Placement; 50990 return lastPlacedIndex; 50991 } else { 50992 // This item can stay in place. 50993 return oldIndex; 50994 } 50995 } else { 50996 // This is an insertion. 50997 newFiber.effectTag = Placement; 50998 return lastPlacedIndex; 50999 } 51000 } 51001 51002 function placeSingleChild(newFiber) { 51003 // This is simpler for the single child case. We only need to do a 51004 // placement for inserting new children. 51005 if (shouldTrackSideEffects && newFiber.alternate === null) { 51006 newFiber.effectTag = Placement; 51007 } 51008 51009 return newFiber; 51010 } 51011 51012 function updateTextNode(returnFiber, current, textContent, expirationTime) { 51013 if (current === null || current.tag !== HostText) { 51014 // Insert 51015 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime); 51016 created.return = returnFiber; 51017 return created; 51018 } else { 51019 // Update 51020 var existing = useFiber(current, textContent); 51021 existing.return = returnFiber; 51022 return existing; 51023 } 51024 } 51025 51026 function updateElement(returnFiber, current, element, expirationTime) { 51027 if (current !== null) { 51028 if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path: 51029 isCompatibleFamilyForHotReloading(current, element) )) { 51030 // Move based on index 51031 var existing = useFiber(current, element.props); 51032 existing.ref = coerceRef(returnFiber, current, element); 51033 existing.return = returnFiber; 51034 51035 { 51036 existing._debugSource = element._source; 51037 existing._debugOwner = element._owner; 51038 } 51039 51040 return existing; 51041 } 51042 } // Insert 51043 51044 51045 var created = createFiberFromElement(element, returnFiber.mode, expirationTime); 51046 created.ref = coerceRef(returnFiber, current, element); 51047 created.return = returnFiber; 51048 return created; 51049 } 51050 51051 function updatePortal(returnFiber, current, portal, expirationTime) { 51052 if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) { 51053 // Insert 51054 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime); 51055 created.return = returnFiber; 51056 return created; 51057 } else { 51058 // Update 51059 var existing = useFiber(current, portal.children || []); 51060 existing.return = returnFiber; 51061 return existing; 51062 } 51063 } 51064 51065 function updateFragment(returnFiber, current, fragment, expirationTime, key) { 51066 if (current === null || current.tag !== Fragment) { 51067 // Insert 51068 var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key); 51069 created.return = returnFiber; 51070 return created; 51071 } else { 51072 // Update 51073 var existing = useFiber(current, fragment); 51074 existing.return = returnFiber; 51075 return existing; 51076 } 51077 } 51078 51079 function createChild(returnFiber, newChild, expirationTime) { 51080 if (typeof newChild === 'string' || typeof newChild === 'number') { 51081 // Text nodes don't have keys. If the previous node is implicitly keyed 51082 // we can continue to replace it without aborting even if it is not a text 51083 // node. 51084 var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime); 51085 created.return = returnFiber; 51086 return created; 51087 } 51088 51089 if (typeof newChild === 'object' && newChild !== null) { 51090 switch (newChild.$$typeof) { 51091 case REACT_ELEMENT_TYPE: 51092 { 51093 var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime); 51094 51095 _created.ref = coerceRef(returnFiber, null, newChild); 51096 _created.return = returnFiber; 51097 return _created; 51098 } 51099 51100 case REACT_PORTAL_TYPE: 51101 { 51102 var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime); 51103 51104 _created2.return = returnFiber; 51105 return _created2; 51106 } 51107 } 51108 51109 if (isArray$1(newChild) || getIteratorFn(newChild)) { 51110 var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null); 51111 51112 _created3.return = returnFiber; 51113 return _created3; 51114 } 51115 51116 throwOnInvalidObjectType(returnFiber, newChild); 51117 } 51118 51119 { 51120 if (typeof newChild === 'function') { 51121 warnOnFunctionType(); 51122 } 51123 } 51124 51125 return null; 51126 } 51127 51128 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { 51129 // Update the fiber if the keys match, otherwise return null. 51130 var key = oldFiber !== null ? oldFiber.key : null; 51131 51132 if (typeof newChild === 'string' || typeof newChild === 'number') { 51133 // Text nodes don't have keys. If the previous node is implicitly keyed 51134 // we can continue to replace it without aborting even if it is not a text 51135 // node. 51136 if (key !== null) { 51137 return null; 51138 } 51139 51140 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime); 51141 } 51142 51143 if (typeof newChild === 'object' && newChild !== null) { 51144 switch (newChild.$$typeof) { 51145 case REACT_ELEMENT_TYPE: 51146 { 51147 if (newChild.key === key) { 51148 if (newChild.type === REACT_FRAGMENT_TYPE) { 51149 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key); 51150 } 51151 51152 return updateElement(returnFiber, oldFiber, newChild, expirationTime); 51153 } else { 51154 return null; 51155 } 51156 } 51157 51158 case REACT_PORTAL_TYPE: 51159 { 51160 if (newChild.key === key) { 51161 return updatePortal(returnFiber, oldFiber, newChild, expirationTime); 51162 } else { 51163 return null; 51164 } 51165 } 51166 } 51167 51168 if (isArray$1(newChild) || getIteratorFn(newChild)) { 51169 if (key !== null) { 51170 return null; 51171 } 51172 51173 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null); 51174 } 51175 51176 throwOnInvalidObjectType(returnFiber, newChild); 51177 } 51178 51179 { 51180 if (typeof newChild === 'function') { 51181 warnOnFunctionType(); 51182 } 51183 } 51184 51185 return null; 51186 } 51187 51188 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) { 51189 if (typeof newChild === 'string' || typeof newChild === 'number') { 51190 // Text nodes don't have keys, so we neither have to check the old nor 51191 // new node for the key. If both are text nodes, they match. 51192 var matchedFiber = existingChildren.get(newIdx) || null; 51193 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime); 51194 } 51195 51196 if (typeof newChild === 'object' && newChild !== null) { 51197 switch (newChild.$$typeof) { 51198 case REACT_ELEMENT_TYPE: 51199 { 51200 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 51201 51202 if (newChild.type === REACT_FRAGMENT_TYPE) { 51203 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key); 51204 } 51205 51206 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime); 51207 } 51208 51209 case REACT_PORTAL_TYPE: 51210 { 51211 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 51212 51213 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime); 51214 } 51215 } 51216 51217 if (isArray$1(newChild) || getIteratorFn(newChild)) { 51218 var _matchedFiber3 = existingChildren.get(newIdx) || null; 51219 51220 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null); 51221 } 51222 51223 throwOnInvalidObjectType(returnFiber, newChild); 51224 } 51225 51226 { 51227 if (typeof newChild === 'function') { 51228 warnOnFunctionType(); 51229 } 51230 } 51231 51232 return null; 51233 } 51234 /** 51235 * Warns if there is a duplicate or missing key 51236 */ 51237 51238 51239 function warnOnInvalidKey(child, knownKeys) { 51240 { 51241 if (typeof child !== 'object' || child === null) { 51242 return knownKeys; 51243 } 51244 51245 switch (child.$$typeof) { 51246 case REACT_ELEMENT_TYPE: 51247 case REACT_PORTAL_TYPE: 51248 warnForMissingKey(child); 51249 var key = child.key; 51250 51251 if (typeof key !== 'string') { 51252 break; 51253 } 51254 51255 if (knownKeys === null) { 51256 knownKeys = new Set(); 51257 knownKeys.add(key); 51258 break; 51259 } 51260 51261 if (!knownKeys.has(key)) { 51262 knownKeys.add(key); 51263 break; 51264 } 51265 51266 error('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.', key); 51267 51268 break; 51269 } 51270 } 51271 51272 return knownKeys; 51273 } 51274 51275 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) { 51276 // This algorithm can't optimize by searching from both ends since we 51277 // don't have backpointers on fibers. I'm trying to see how far we can get 51278 // with that model. If it ends up not being worth the tradeoffs, we can 51279 // add it later. 51280 // Even with a two ended optimization, we'd want to optimize for the case 51281 // where there are few changes and brute force the comparison instead of 51282 // going for the Map. It'd like to explore hitting that path first in 51283 // forward-only mode and only go for the Map once we notice that we need 51284 // lots of look ahead. This doesn't handle reversal as well as two ended 51285 // search but that's unusual. Besides, for the two ended optimization to 51286 // work on Iterables, we'd need to copy the whole set. 51287 // In this first iteration, we'll just live with hitting the bad case 51288 // (adding everything to a Map) in for every insert/move. 51289 // If you change this code, also update reconcileChildrenIterator() which 51290 // uses the same algorithm. 51291 { 51292 // First, validate keys. 51293 var knownKeys = null; 51294 51295 for (var i = 0; i < newChildren.length; i++) { 51296 var child = newChildren[i]; 51297 knownKeys = warnOnInvalidKey(child, knownKeys); 51298 } 51299 } 51300 51301 var resultingFirstChild = null; 51302 var previousNewFiber = null; 51303 var oldFiber = currentFirstChild; 51304 var lastPlacedIndex = 0; 51305 var newIdx = 0; 51306 var nextOldFiber = null; 51307 51308 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) { 51309 if (oldFiber.index > newIdx) { 51310 nextOldFiber = oldFiber; 51311 oldFiber = null; 51312 } else { 51313 nextOldFiber = oldFiber.sibling; 51314 } 51315 51316 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime); 51317 51318 if (newFiber === null) { 51319 // TODO: This breaks on empty slots like null children. That's 51320 // unfortunate because it triggers the slow path all the time. We need 51321 // a better way to communicate whether this was a miss or null, 51322 // boolean, undefined, etc. 51323 if (oldFiber === null) { 51324 oldFiber = nextOldFiber; 51325 } 51326 51327 break; 51328 } 51329 51330 if (shouldTrackSideEffects) { 51331 if (oldFiber && newFiber.alternate === null) { 51332 // We matched the slot, but we didn't reuse the existing fiber, so we 51333 // need to delete the existing child. 51334 deleteChild(returnFiber, oldFiber); 51335 } 51336 } 51337 51338 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); 51339 51340 if (previousNewFiber === null) { 51341 // TODO: Move out of the loop. This only happens for the first run. 51342 resultingFirstChild = newFiber; 51343 } else { 51344 // TODO: Defer siblings if we're not at the right index for this slot. 51345 // I.e. if we had null values before, then we want to defer this 51346 // for each null value. However, we also don't want to call updateSlot 51347 // with the previous one. 51348 previousNewFiber.sibling = newFiber; 51349 } 51350 51351 previousNewFiber = newFiber; 51352 oldFiber = nextOldFiber; 51353 } 51354 51355 if (newIdx === newChildren.length) { 51356 // We've reached the end of the new children. We can delete the rest. 51357 deleteRemainingChildren(returnFiber, oldFiber); 51358 return resultingFirstChild; 51359 } 51360 51361 if (oldFiber === null) { 51362 // If we don't have any more existing children we can choose a fast path 51363 // since the rest will all be insertions. 51364 for (; newIdx < newChildren.length; newIdx++) { 51365 var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime); 51366 51367 if (_newFiber === null) { 51368 continue; 51369 } 51370 51371 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx); 51372 51373 if (previousNewFiber === null) { 51374 // TODO: Move out of the loop. This only happens for the first run. 51375 resultingFirstChild = _newFiber; 51376 } else { 51377 previousNewFiber.sibling = _newFiber; 51378 } 51379 51380 previousNewFiber = _newFiber; 51381 } 51382 51383 return resultingFirstChild; 51384 } // Add all children to a key map for quick lookups. 51385 51386 51387 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. 51388 51389 for (; newIdx < newChildren.length; newIdx++) { 51390 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime); 51391 51392 if (_newFiber2 !== null) { 51393 if (shouldTrackSideEffects) { 51394 if (_newFiber2.alternate !== null) { 51395 // The new fiber is a work in progress, but if there exists a 51396 // current, that means that we reused the fiber. We need to delete 51397 // it from the child list so that we don't add it to the deletion 51398 // list. 51399 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key); 51400 } 51401 } 51402 51403 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx); 51404 51405 if (previousNewFiber === null) { 51406 resultingFirstChild = _newFiber2; 51407 } else { 51408 previousNewFiber.sibling = _newFiber2; 51409 } 51410 51411 previousNewFiber = _newFiber2; 51412 } 51413 } 51414 51415 if (shouldTrackSideEffects) { 51416 // Any existing children that weren't consumed above were deleted. We need 51417 // to add them to the deletion list. 51418 existingChildren.forEach(function (child) { 51419 return deleteChild(returnFiber, child); 51420 }); 51421 } 51422 51423 return resultingFirstChild; 51424 } 51425 51426 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) { 51427 // This is the same implementation as reconcileChildrenArray(), 51428 // but using the iterator instead. 51429 var iteratorFn = getIteratorFn(newChildrenIterable); 51430 51431 if (!(typeof iteratorFn === 'function')) { 51432 { 51433 throw Error( "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." ); 51434 } 51435 } 51436 51437 { 51438 // We don't support rendering Generators because it's a mutation. 51439 // See https://github.com/facebook/react/issues/12995 51440 if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag 51441 newChildrenIterable[Symbol.toStringTag] === 'Generator') { 51442 if (!didWarnAboutGenerators) { 51443 error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.'); 51444 } 51445 51446 didWarnAboutGenerators = true; 51447 } // Warn about using Maps as children 51448 51449 51450 if (newChildrenIterable.entries === iteratorFn) { 51451 if (!didWarnAboutMaps) { 51452 error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.'); 51453 } 51454 51455 didWarnAboutMaps = true; 51456 } // First, validate keys. 51457 // We'll get a different iterator later for the main pass. 51458 51459 51460 var _newChildren = iteratorFn.call(newChildrenIterable); 51461 51462 if (_newChildren) { 51463 var knownKeys = null; 51464 51465 var _step = _newChildren.next(); 51466 51467 for (; !_step.done; _step = _newChildren.next()) { 51468 var child = _step.value; 51469 knownKeys = warnOnInvalidKey(child, knownKeys); 51470 } 51471 } 51472 } 51473 51474 var newChildren = iteratorFn.call(newChildrenIterable); 51475 51476 if (!(newChildren != null)) { 51477 { 51478 throw Error( "An iterable object provided no iterator." ); 51479 } 51480 } 51481 51482 var resultingFirstChild = null; 51483 var previousNewFiber = null; 51484 var oldFiber = currentFirstChild; 51485 var lastPlacedIndex = 0; 51486 var newIdx = 0; 51487 var nextOldFiber = null; 51488 var step = newChildren.next(); 51489 51490 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) { 51491 if (oldFiber.index > newIdx) { 51492 nextOldFiber = oldFiber; 51493 oldFiber = null; 51494 } else { 51495 nextOldFiber = oldFiber.sibling; 51496 } 51497 51498 var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime); 51499 51500 if (newFiber === null) { 51501 // TODO: This breaks on empty slots like null children. That's 51502 // unfortunate because it triggers the slow path all the time. We need 51503 // a better way to communicate whether this was a miss or null, 51504 // boolean, undefined, etc. 51505 if (oldFiber === null) { 51506 oldFiber = nextOldFiber; 51507 } 51508 51509 break; 51510 } 51511 51512 if (shouldTrackSideEffects) { 51513 if (oldFiber && newFiber.alternate === null) { 51514 // We matched the slot, but we didn't reuse the existing fiber, so we 51515 // need to delete the existing child. 51516 deleteChild(returnFiber, oldFiber); 51517 } 51518 } 51519 51520 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); 51521 51522 if (previousNewFiber === null) { 51523 // TODO: Move out of the loop. This only happens for the first run. 51524 resultingFirstChild = newFiber; 51525 } else { 51526 // TODO: Defer siblings if we're not at the right index for this slot. 51527 // I.e. if we had null values before, then we want to defer this 51528 // for each null value. However, we also don't want to call updateSlot 51529 // with the previous one. 51530 previousNewFiber.sibling = newFiber; 51531 } 51532 51533 previousNewFiber = newFiber; 51534 oldFiber = nextOldFiber; 51535 } 51536 51537 if (step.done) { 51538 // We've reached the end of the new children. We can delete the rest. 51539 deleteRemainingChildren(returnFiber, oldFiber); 51540 return resultingFirstChild; 51541 } 51542 51543 if (oldFiber === null) { 51544 // If we don't have any more existing children we can choose a fast path 51545 // since the rest will all be insertions. 51546 for (; !step.done; newIdx++, step = newChildren.next()) { 51547 var _newFiber3 = createChild(returnFiber, step.value, expirationTime); 51548 51549 if (_newFiber3 === null) { 51550 continue; 51551 } 51552 51553 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx); 51554 51555 if (previousNewFiber === null) { 51556 // TODO: Move out of the loop. This only happens for the first run. 51557 resultingFirstChild = _newFiber3; 51558 } else { 51559 previousNewFiber.sibling = _newFiber3; 51560 } 51561 51562 previousNewFiber = _newFiber3; 51563 } 51564 51565 return resultingFirstChild; 51566 } // Add all children to a key map for quick lookups. 51567 51568 51569 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. 51570 51571 for (; !step.done; newIdx++, step = newChildren.next()) { 51572 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime); 51573 51574 if (_newFiber4 !== null) { 51575 if (shouldTrackSideEffects) { 51576 if (_newFiber4.alternate !== null) { 51577 // The new fiber is a work in progress, but if there exists a 51578 // current, that means that we reused the fiber. We need to delete 51579 // it from the child list so that we don't add it to the deletion 51580 // list. 51581 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key); 51582 } 51583 } 51584 51585 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx); 51586 51587 if (previousNewFiber === null) { 51588 resultingFirstChild = _newFiber4; 51589 } else { 51590 previousNewFiber.sibling = _newFiber4; 51591 } 51592 51593 previousNewFiber = _newFiber4; 51594 } 51595 } 51596 51597 if (shouldTrackSideEffects) { 51598 // Any existing children that weren't consumed above were deleted. We need 51599 // to add them to the deletion list. 51600 existingChildren.forEach(function (child) { 51601 return deleteChild(returnFiber, child); 51602 }); 51603 } 51604 51605 return resultingFirstChild; 51606 } 51607 51608 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) { 51609 // There's no need to check for keys on text nodes since we don't have a 51610 // way to define them. 51611 if (currentFirstChild !== null && currentFirstChild.tag === HostText) { 51612 // We already have an existing node so let's just update it and delete 51613 // the rest. 51614 deleteRemainingChildren(returnFiber, currentFirstChild.sibling); 51615 var existing = useFiber(currentFirstChild, textContent); 51616 existing.return = returnFiber; 51617 return existing; 51618 } // The existing first child is not a text node so we need to create one 51619 // and delete the existing ones. 51620 51621 51622 deleteRemainingChildren(returnFiber, currentFirstChild); 51623 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime); 51624 created.return = returnFiber; 51625 return created; 51626 } 51627 51628 function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) { 51629 var key = element.key; 51630 var child = currentFirstChild; 51631 51632 while (child !== null) { 51633 // TODO: If key === null and child.key === null, then this only applies to 51634 // the first item in the list. 51635 if (child.key === key) { 51636 switch (child.tag) { 51637 case Fragment: 51638 { 51639 if (element.type === REACT_FRAGMENT_TYPE) { 51640 deleteRemainingChildren(returnFiber, child.sibling); 51641 var existing = useFiber(child, element.props.children); 51642 existing.return = returnFiber; 51643 51644 { 51645 existing._debugSource = element._source; 51646 existing._debugOwner = element._owner; 51647 } 51648 51649 return existing; 51650 } 51651 51652 break; 51653 } 51654 51655 case Block: 51656 51657 // We intentionally fallthrough here if enableBlocksAPI is not on. 51658 // eslint-disable-next-lined no-fallthrough 51659 51660 default: 51661 { 51662 if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path: 51663 isCompatibleFamilyForHotReloading(child, element) )) { 51664 deleteRemainingChildren(returnFiber, child.sibling); 51665 51666 var _existing3 = useFiber(child, element.props); 51667 51668 _existing3.ref = coerceRef(returnFiber, child, element); 51669 _existing3.return = returnFiber; 51670 51671 { 51672 _existing3._debugSource = element._source; 51673 _existing3._debugOwner = element._owner; 51674 } 51675 51676 return _existing3; 51677 } 51678 51679 break; 51680 } 51681 } // Didn't match. 51682 51683 51684 deleteRemainingChildren(returnFiber, child); 51685 break; 51686 } else { 51687 deleteChild(returnFiber, child); 51688 } 51689 51690 child = child.sibling; 51691 } 51692 51693 if (element.type === REACT_FRAGMENT_TYPE) { 51694 var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key); 51695 created.return = returnFiber; 51696 return created; 51697 } else { 51698 var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime); 51699 51700 _created4.ref = coerceRef(returnFiber, currentFirstChild, element); 51701 _created4.return = returnFiber; 51702 return _created4; 51703 } 51704 } 51705 51706 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) { 51707 var key = portal.key; 51708 var child = currentFirstChild; 51709 51710 while (child !== null) { 51711 // TODO: If key === null and child.key === null, then this only applies to 51712 // the first item in the list. 51713 if (child.key === key) { 51714 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) { 51715 deleteRemainingChildren(returnFiber, child.sibling); 51716 var existing = useFiber(child, portal.children || []); 51717 existing.return = returnFiber; 51718 return existing; 51719 } else { 51720 deleteRemainingChildren(returnFiber, child); 51721 break; 51722 } 51723 } else { 51724 deleteChild(returnFiber, child); 51725 } 51726 51727 child = child.sibling; 51728 } 51729 51730 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime); 51731 created.return = returnFiber; 51732 return created; 51733 } // This API will tag the children with the side-effect of the reconciliation 51734 // itself. They will be added to the side-effect list as we pass through the 51735 // children and the parent. 51736 51737 51738 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) { 51739 // This function is not recursive. 51740 // If the top level item is an array, we treat it as a set of children, 51741 // not as a fragment. Nested arrays on the other hand will be treated as 51742 // fragment nodes. Recursion happens at the normal flow. 51743 // Handle top level unkeyed fragments as if they were arrays. 51744 // This leads to an ambiguity between <>{[...]}</> and <>...</>. 51745 // We treat the ambiguous cases above the same. 51746 var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null; 51747 51748 if (isUnkeyedTopLevelFragment) { 51749 newChild = newChild.props.children; 51750 } // Handle object types 51751 51752 51753 var isObject = typeof newChild === 'object' && newChild !== null; 51754 51755 if (isObject) { 51756 switch (newChild.$$typeof) { 51757 case REACT_ELEMENT_TYPE: 51758 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime)); 51759 51760 case REACT_PORTAL_TYPE: 51761 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime)); 51762 } 51763 } 51764 51765 if (typeof newChild === 'string' || typeof newChild === 'number') { 51766 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime)); 51767 } 51768 51769 if (isArray$1(newChild)) { 51770 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime); 51771 } 51772 51773 if (getIteratorFn(newChild)) { 51774 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime); 51775 } 51776 51777 if (isObject) { 51778 throwOnInvalidObjectType(returnFiber, newChild); 51779 } 51780 51781 { 51782 if (typeof newChild === 'function') { 51783 warnOnFunctionType(); 51784 } 51785 } 51786 51787 if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) { 51788 // If the new child is undefined, and the return fiber is a composite 51789 // component, throw an error. If Fiber return types are disabled, 51790 // we already threw above. 51791 switch (returnFiber.tag) { 51792 case ClassComponent: 51793 { 51794 { 51795 var instance = returnFiber.stateNode; 51796 51797 if (instance.render._isMockFunction) { 51798 // We allow auto-mocks to proceed as if they're returning null. 51799 break; 51800 } 51801 } 51802 } 51803 // Intentionally fall through to the next case, which handles both 51804 // functions and classes 51805 // eslint-disable-next-lined no-fallthrough 51806 51807 case FunctionComponent: 51808 { 51809 var Component = returnFiber.type; 51810 51811 { 51812 { 51813 throw Error( (Component.displayName || Component.name || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." ); 51814 } 51815 } 51816 } 51817 } 51818 } // Remaining cases are all treated as empty. 51819 51820 51821 return deleteRemainingChildren(returnFiber, currentFirstChild); 51822 } 51823 51824 return reconcileChildFibers; 51825} 51826 51827var reconcileChildFibers = ChildReconciler(true); 51828var mountChildFibers = ChildReconciler(false); 51829function cloneChildFibers(current, workInProgress) { 51830 if (!(current === null || workInProgress.child === current.child)) { 51831 { 51832 throw Error( "Resuming work not yet implemented." ); 51833 } 51834 } 51835 51836 if (workInProgress.child === null) { 51837 return; 51838 } 51839 51840 var currentChild = workInProgress.child; 51841 var newChild = createWorkInProgress(currentChild, currentChild.pendingProps); 51842 workInProgress.child = newChild; 51843 newChild.return = workInProgress; 51844 51845 while (currentChild.sibling !== null) { 51846 currentChild = currentChild.sibling; 51847 newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps); 51848 newChild.return = workInProgress; 51849 } 51850 51851 newChild.sibling = null; 51852} // Reset a workInProgress child set to prepare it for a second pass. 51853 51854function resetChildFibers(workInProgress, renderExpirationTime) { 51855 var child = workInProgress.child; 51856 51857 while (child !== null) { 51858 resetWorkInProgress(child, renderExpirationTime); 51859 child = child.sibling; 51860 } 51861} 51862 51863var NO_CONTEXT = {}; 51864var contextStackCursor$1 = createCursor(NO_CONTEXT); 51865var contextFiberStackCursor = createCursor(NO_CONTEXT); 51866var rootInstanceStackCursor = createCursor(NO_CONTEXT); 51867 51868function requiredContext(c) { 51869 if (!(c !== NO_CONTEXT)) { 51870 { 51871 throw Error( "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." ); 51872 } 51873 } 51874 51875 return c; 51876} 51877 51878function getRootHostContainer() { 51879 var rootInstance = requiredContext(rootInstanceStackCursor.current); 51880 return rootInstance; 51881} 51882 51883function pushHostContainer(fiber, nextRootInstance) { 51884 // Push current root instance onto the stack; 51885 // This allows us to reset root when portals are popped. 51886 push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it. 51887 // This enables us to pop only Fibers that provide unique contexts. 51888 51889 push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack. 51890 // However, we can't just call getRootHostContext() and push it because 51891 // we'd have a different number of entries on the stack depending on 51892 // whether getRootHostContext() throws somewhere in renderer code or not. 51893 // So we push an empty value first. This lets us safely unwind on errors. 51894 51895 push(contextStackCursor$1, NO_CONTEXT, fiber); 51896 var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it. 51897 51898 pop(contextStackCursor$1, fiber); 51899 push(contextStackCursor$1, nextRootContext, fiber); 51900} 51901 51902function popHostContainer(fiber) { 51903 pop(contextStackCursor$1, fiber); 51904 pop(contextFiberStackCursor, fiber); 51905 pop(rootInstanceStackCursor, fiber); 51906} 51907 51908function getHostContext() { 51909 var context = requiredContext(contextStackCursor$1.current); 51910 return context; 51911} 51912 51913function pushHostContext(fiber) { 51914 var rootInstance = requiredContext(rootInstanceStackCursor.current); 51915 var context = requiredContext(contextStackCursor$1.current); 51916 var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique. 51917 51918 if (context === nextContext) { 51919 return; 51920 } // Track the context and the Fiber that provided it. 51921 // This enables us to pop only Fibers that provide unique contexts. 51922 51923 51924 push(contextFiberStackCursor, fiber, fiber); 51925 push(contextStackCursor$1, nextContext, fiber); 51926} 51927 51928function popHostContext(fiber) { 51929 // Do not pop unless this Fiber provided the current context. 51930 // pushHostContext() only pushes Fibers that provide unique contexts. 51931 if (contextFiberStackCursor.current !== fiber) { 51932 return; 51933 } 51934 51935 pop(contextStackCursor$1, fiber); 51936 pop(contextFiberStackCursor, fiber); 51937} 51938 51939var DefaultSuspenseContext = 0; // The Suspense Context is split into two parts. The lower bits is 51940// inherited deeply down the subtree. The upper bits only affect 51941// this immediate suspense boundary and gets reset each new 51942// boundary or suspense list. 51943 51944var SubtreeSuspenseContextMask = 1; // Subtree Flags: 51945// InvisibleParentSuspenseContext indicates that one of our parent Suspense 51946// boundaries is not currently showing visible main content. 51947// Either because it is already showing a fallback or is not mounted at all. 51948// We can use this to determine if it is desirable to trigger a fallback at 51949// the parent. If not, then we might need to trigger undesirable boundaries 51950// and/or suspend the commit to avoid hiding the parent content. 51951 51952var InvisibleParentSuspenseContext = 1; // Shallow Flags: 51953// ForceSuspenseFallback can be used by SuspenseList to force newly added 51954// items into their fallback state during one of the render passes. 51955 51956var ForceSuspenseFallback = 2; 51957var suspenseStackCursor = createCursor(DefaultSuspenseContext); 51958function hasSuspenseContext(parentContext, flag) { 51959 return (parentContext & flag) !== 0; 51960} 51961function setDefaultShallowSuspenseContext(parentContext) { 51962 return parentContext & SubtreeSuspenseContextMask; 51963} 51964function setShallowSuspenseContext(parentContext, shallowContext) { 51965 return parentContext & SubtreeSuspenseContextMask | shallowContext; 51966} 51967function addSubtreeSuspenseContext(parentContext, subtreeContext) { 51968 return parentContext | subtreeContext; 51969} 51970function pushSuspenseContext(fiber, newContext) { 51971 push(suspenseStackCursor, newContext, fiber); 51972} 51973function popSuspenseContext(fiber) { 51974 pop(suspenseStackCursor, fiber); 51975} 51976 51977function shouldCaptureSuspense(workInProgress, hasInvisibleParent) { 51978 // If it was the primary children that just suspended, capture and render the 51979 // fallback. Otherwise, don't capture and bubble to the next boundary. 51980 var nextState = workInProgress.memoizedState; 51981 51982 if (nextState !== null) { 51983 if (nextState.dehydrated !== null) { 51984 // A dehydrated boundary always captures. 51985 return true; 51986 } 51987 51988 return false; 51989 } 51990 51991 var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop. 51992 51993 if (props.fallback === undefined) { 51994 return false; 51995 } // Regular boundaries always capture. 51996 51997 51998 if (props.unstable_avoidThisFallback !== true) { 51999 return true; 52000 } // If it's a boundary we should avoid, then we prefer to bubble up to the 52001 // parent boundary if it is currently invisible. 52002 52003 52004 if (hasInvisibleParent) { 52005 return false; 52006 } // If the parent is not able to handle it, we must handle it. 52007 52008 52009 return true; 52010} 52011function findFirstSuspended(row) { 52012 var node = row; 52013 52014 while (node !== null) { 52015 if (node.tag === SuspenseComponent) { 52016 var state = node.memoizedState; 52017 52018 if (state !== null) { 52019 var dehydrated = state.dehydrated; 52020 52021 if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) { 52022 return node; 52023 } 52024 } 52025 } else if (node.tag === SuspenseListComponent && // revealOrder undefined can't be trusted because it don't 52026 // keep track of whether it suspended or not. 52027 node.memoizedProps.revealOrder !== undefined) { 52028 var didSuspend = (node.effectTag & DidCapture) !== NoEffect; 52029 52030 if (didSuspend) { 52031 return node; 52032 } 52033 } else if (node.child !== null) { 52034 node.child.return = node; 52035 node = node.child; 52036 continue; 52037 } 52038 52039 if (node === row) { 52040 return null; 52041 } 52042 52043 while (node.sibling === null) { 52044 if (node.return === null || node.return === row) { 52045 return null; 52046 } 52047 52048 node = node.return; 52049 } 52050 52051 node.sibling.return = node.return; 52052 node = node.sibling; 52053 } 52054 52055 return null; 52056} 52057 52058function createDeprecatedResponderListener(responder, props) { 52059 var eventResponderListener = { 52060 responder: responder, 52061 props: props 52062 }; 52063 52064 { 52065 Object.freeze(eventResponderListener); 52066 } 52067 52068 return eventResponderListener; 52069} 52070 52071var HasEffect = 52072/* */ 520731; // Represents the phase in which the effect (not the clean-up) fires. 52074 52075var Layout = 52076/* */ 520772; 52078var Passive$1 = 52079/* */ 520804; 52081 52082var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, 52083 ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; 52084var didWarnAboutMismatchedHooksForComponent; 52085 52086{ 52087 didWarnAboutMismatchedHooksForComponent = new Set(); 52088} 52089 52090// These are set right before calling the component. 52091var renderExpirationTime = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from 52092// the work-in-progress hook. 52093 52094var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The 52095// current hook list is the list that belongs to the current fiber. The 52096// work-in-progress hook list is a new list that will be added to the 52097// work-in-progress fiber. 52098 52099var currentHook = null; 52100var workInProgressHook = null; // Whether an update was scheduled at any point during the render phase. This 52101// does not get reset if we do another render pass; only when we're completely 52102// finished evaluating this component. This is an optimization so we know 52103// whether we need to clear render phase updates after a throw. 52104 52105var didScheduleRenderPhaseUpdate = false; 52106var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook 52107 52108var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders. 52109// The list stores the order of hooks used during the initial render (mount). 52110// Subsequent renders (updates) reference this list. 52111 52112var hookTypesDev = null; 52113var hookTypesUpdateIndexDev = -1; // In DEV, this tracks whether currently rendering component needs to ignore 52114// the dependencies for Hooks that need them (e.g. useEffect or useMemo). 52115// When true, such Hooks will always be "remounted". Only used during hot reload. 52116 52117var ignorePreviousDependencies = false; 52118 52119function mountHookTypesDev() { 52120 { 52121 var hookName = currentHookNameInDev; 52122 52123 if (hookTypesDev === null) { 52124 hookTypesDev = [hookName]; 52125 } else { 52126 hookTypesDev.push(hookName); 52127 } 52128 } 52129} 52130 52131function updateHookTypesDev() { 52132 { 52133 var hookName = currentHookNameInDev; 52134 52135 if (hookTypesDev !== null) { 52136 hookTypesUpdateIndexDev++; 52137 52138 if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) { 52139 warnOnHookMismatchInDev(hookName); 52140 } 52141 } 52142 } 52143} 52144 52145function checkDepsAreArrayDev(deps) { 52146 { 52147 if (deps !== undefined && deps !== null && !Array.isArray(deps)) { 52148 // Verify deps, but only on mount to avoid extra checks. 52149 // It's unlikely their type would change as usually you define them inline. 52150 error('%s received a final argument that is not an array (instead, received `%s`). When ' + 'specified, the final argument must be an array.', currentHookNameInDev, typeof deps); 52151 } 52152 } 52153} 52154 52155function warnOnHookMismatchInDev(currentHookName) { 52156 { 52157 var componentName = getComponentName(currentlyRenderingFiber$1.type); 52158 52159 if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) { 52160 didWarnAboutMismatchedHooksForComponent.add(componentName); 52161 52162 if (hookTypesDev !== null) { 52163 var table = ''; 52164 var secondColumnStart = 30; 52165 52166 for (var i = 0; i <= hookTypesUpdateIndexDev; i++) { 52167 var oldHookName = hookTypesDev[i]; 52168 var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName; 52169 var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up 52170 // lol @ IE not supporting String#repeat 52171 52172 while (row.length < secondColumnStart) { 52173 row += ' '; 52174 } 52175 52176 row += newHookName + '\n'; 52177 table += row; 52178 } 52179 52180 error('React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table); 52181 } 52182 } 52183 } 52184} 52185 52186function throwInvalidHookError() { 52187 { 52188 { 52189 throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); 52190 } 52191 } 52192} 52193 52194function areHookInputsEqual(nextDeps, prevDeps) { 52195 { 52196 if (ignorePreviousDependencies) { 52197 // Only true when this component is being hot reloaded. 52198 return false; 52199 } 52200 } 52201 52202 if (prevDeps === null) { 52203 { 52204 error('%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev); 52205 } 52206 52207 return false; 52208 } 52209 52210 { 52211 // Don't bother comparing lengths in prod because these arrays should be 52212 // passed inline. 52213 if (nextDeps.length !== prevDeps.length) { 52214 error('The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + prevDeps.join(', ') + "]", "[" + nextDeps.join(', ') + "]"); 52215 } 52216 } 52217 52218 for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) { 52219 if (objectIs(nextDeps[i], prevDeps[i])) { 52220 continue; 52221 } 52222 52223 return false; 52224 } 52225 52226 return true; 52227} 52228 52229function renderWithHooks(current, workInProgress, Component, props, secondArg, nextRenderExpirationTime) { 52230 renderExpirationTime = nextRenderExpirationTime; 52231 currentlyRenderingFiber$1 = workInProgress; 52232 52233 { 52234 hookTypesDev = current !== null ? current._debugHookTypes : null; 52235 hookTypesUpdateIndexDev = -1; // Used for hot reloading: 52236 52237 ignorePreviousDependencies = current !== null && current.type !== workInProgress.type; 52238 } 52239 52240 workInProgress.memoizedState = null; 52241 workInProgress.updateQueue = null; 52242 workInProgress.expirationTime = NoWork; // The following should have already been reset 52243 // currentHook = null; 52244 // workInProgressHook = null; 52245 // didScheduleRenderPhaseUpdate = false; 52246 // TODO Warn if no hooks are used at all during mount, then some are used during update. 52247 // Currently we will identify the update render as a mount because memoizedState === null. 52248 // This is tricky because it's valid for certain types of components (e.g. React.lazy) 52249 // Using memoizedState to differentiate between mount/update only works if at least one stateful hook is used. 52250 // Non-stateful hooks (e.g. context) don't get added to memoizedState, 52251 // so memoizedState would be null during updates and mounts. 52252 52253 { 52254 if (current !== null && current.memoizedState !== null) { 52255 ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV; 52256 } else if (hookTypesDev !== null) { 52257 // This dispatcher handles an edge case where a component is updating, 52258 // but no stateful hooks have been used. 52259 // We want to match the production code behavior (which will use HooksDispatcherOnMount), 52260 // but with the extra DEV validation to ensure hooks ordering hasn't changed. 52261 // This dispatcher does that. 52262 ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV; 52263 } else { 52264 ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV; 52265 } 52266 } 52267 52268 var children = Component(props, secondArg); // Check if there was a render phase update 52269 52270 if (workInProgress.expirationTime === renderExpirationTime) { 52271 // Keep rendering in a loop for as long as render phase updates continue to 52272 // be scheduled. Use a counter to prevent infinite loops. 52273 var numberOfReRenders = 0; 52274 52275 do { 52276 workInProgress.expirationTime = NoWork; 52277 52278 if (!(numberOfReRenders < RE_RENDER_LIMIT)) { 52279 { 52280 throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); 52281 } 52282 } 52283 52284 numberOfReRenders += 1; 52285 52286 { 52287 // Even when hot reloading, allow dependencies to stabilize 52288 // after first render to prevent infinite render phase updates. 52289 ignorePreviousDependencies = false; 52290 } // Start over from the beginning of the list 52291 52292 52293 currentHook = null; 52294 workInProgressHook = null; 52295 workInProgress.updateQueue = null; 52296 52297 { 52298 // Also validate hook order for cascading updates. 52299 hookTypesUpdateIndexDev = -1; 52300 } 52301 52302 ReactCurrentDispatcher.current = HooksDispatcherOnRerenderInDEV ; 52303 children = Component(props, secondArg); 52304 } while (workInProgress.expirationTime === renderExpirationTime); 52305 } // We can assume the previous dispatcher is always this one, since we set it 52306 // at the beginning of the render phase and there's no re-entrancy. 52307 52308 52309 ReactCurrentDispatcher.current = ContextOnlyDispatcher; 52310 52311 { 52312 workInProgress._debugHookTypes = hookTypesDev; 52313 } // This check uses currentHook so that it works the same in DEV and prod bundles. 52314 // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. 52315 52316 52317 var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; 52318 renderExpirationTime = NoWork; 52319 currentlyRenderingFiber$1 = null; 52320 currentHook = null; 52321 workInProgressHook = null; 52322 52323 { 52324 currentHookNameInDev = null; 52325 hookTypesDev = null; 52326 hookTypesUpdateIndexDev = -1; 52327 } 52328 52329 didScheduleRenderPhaseUpdate = false; 52330 52331 if (!!didRenderTooFewHooks) { 52332 { 52333 throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); 52334 } 52335 } 52336 52337 return children; 52338} 52339function bailoutHooks(current, workInProgress, expirationTime) { 52340 workInProgress.updateQueue = current.updateQueue; 52341 workInProgress.effectTag &= ~(Passive | Update); 52342 52343 if (current.expirationTime <= expirationTime) { 52344 current.expirationTime = NoWork; 52345 } 52346} 52347function resetHooksAfterThrow() { 52348 // We can assume the previous dispatcher is always this one, since we set it 52349 // at the beginning of the render phase and there's no re-entrancy. 52350 ReactCurrentDispatcher.current = ContextOnlyDispatcher; 52351 52352 if (didScheduleRenderPhaseUpdate) { 52353 // There were render phase updates. These are only valid for this render 52354 // phase, which we are now aborting. Remove the updates from the queues so 52355 // they do not persist to the next render. Do not remove updates from hooks 52356 // that weren't processed. 52357 // 52358 // Only reset the updates from the queue if it has a clone. If it does 52359 // not have a clone, that means it wasn't processed, and the updates were 52360 // scheduled before we entered the render phase. 52361 var hook = currentlyRenderingFiber$1.memoizedState; 52362 52363 while (hook !== null) { 52364 var queue = hook.queue; 52365 52366 if (queue !== null) { 52367 queue.pending = null; 52368 } 52369 52370 hook = hook.next; 52371 } 52372 } 52373 52374 renderExpirationTime = NoWork; 52375 currentlyRenderingFiber$1 = null; 52376 currentHook = null; 52377 workInProgressHook = null; 52378 52379 { 52380 hookTypesDev = null; 52381 hookTypesUpdateIndexDev = -1; 52382 currentHookNameInDev = null; 52383 } 52384 52385 didScheduleRenderPhaseUpdate = false; 52386} 52387 52388function mountWorkInProgressHook() { 52389 var hook = { 52390 memoizedState: null, 52391 baseState: null, 52392 baseQueue: null, 52393 queue: null, 52394 next: null 52395 }; 52396 52397 if (workInProgressHook === null) { 52398 // This is the first hook in the list 52399 currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook; 52400 } else { 52401 // Append to the end of the list 52402 workInProgressHook = workInProgressHook.next = hook; 52403 } 52404 52405 return workInProgressHook; 52406} 52407 52408function updateWorkInProgressHook() { 52409 // This function is used both for updates and for re-renders triggered by a 52410 // render phase update. It assumes there is either a current hook we can 52411 // clone, or a work-in-progress hook from a previous render pass that we can 52412 // use as a base. When we reach the end of the base list, we must switch to 52413 // the dispatcher used for mounts. 52414 var nextCurrentHook; 52415 52416 if (currentHook === null) { 52417 var current = currentlyRenderingFiber$1.alternate; 52418 52419 if (current !== null) { 52420 nextCurrentHook = current.memoizedState; 52421 } else { 52422 nextCurrentHook = null; 52423 } 52424 } else { 52425 nextCurrentHook = currentHook.next; 52426 } 52427 52428 var nextWorkInProgressHook; 52429 52430 if (workInProgressHook === null) { 52431 nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState; 52432 } else { 52433 nextWorkInProgressHook = workInProgressHook.next; 52434 } 52435 52436 if (nextWorkInProgressHook !== null) { 52437 // There's already a work-in-progress. Reuse it. 52438 workInProgressHook = nextWorkInProgressHook; 52439 nextWorkInProgressHook = workInProgressHook.next; 52440 currentHook = nextCurrentHook; 52441 } else { 52442 // Clone from the current hook. 52443 if (!(nextCurrentHook !== null)) { 52444 { 52445 throw Error( "Rendered more hooks than during the previous render." ); 52446 } 52447 } 52448 52449 currentHook = nextCurrentHook; 52450 var newHook = { 52451 memoizedState: currentHook.memoizedState, 52452 baseState: currentHook.baseState, 52453 baseQueue: currentHook.baseQueue, 52454 queue: currentHook.queue, 52455 next: null 52456 }; 52457 52458 if (workInProgressHook === null) { 52459 // This is the first hook in the list. 52460 currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook; 52461 } else { 52462 // Append to the end of the list. 52463 workInProgressHook = workInProgressHook.next = newHook; 52464 } 52465 } 52466 52467 return workInProgressHook; 52468} 52469 52470function createFunctionComponentUpdateQueue() { 52471 return { 52472 lastEffect: null 52473 }; 52474} 52475 52476function basicStateReducer(state, action) { 52477 // $FlowFixMe: Flow doesn't like mixed types 52478 return typeof action === 'function' ? action(state) : action; 52479} 52480 52481function mountReducer(reducer, initialArg, init) { 52482 var hook = mountWorkInProgressHook(); 52483 var initialState; 52484 52485 if (init !== undefined) { 52486 initialState = init(initialArg); 52487 } else { 52488 initialState = initialArg; 52489 } 52490 52491 hook.memoizedState = hook.baseState = initialState; 52492 var queue = hook.queue = { 52493 pending: null, 52494 dispatch: null, 52495 lastRenderedReducer: reducer, 52496 lastRenderedState: initialState 52497 }; 52498 var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue); 52499 return [hook.memoizedState, dispatch]; 52500} 52501 52502function updateReducer(reducer, initialArg, init) { 52503 var hook = updateWorkInProgressHook(); 52504 var queue = hook.queue; 52505 52506 if (!(queue !== null)) { 52507 { 52508 throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); 52509 } 52510 } 52511 52512 queue.lastRenderedReducer = reducer; 52513 var current = currentHook; // The last rebase update that is NOT part of the base state. 52514 52515 var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet. 52516 52517 var pendingQueue = queue.pending; 52518 52519 if (pendingQueue !== null) { 52520 // We have new updates that haven't been processed yet. 52521 // We'll add them to the base queue. 52522 if (baseQueue !== null) { 52523 // Merge the pending queue and the base queue. 52524 var baseFirst = baseQueue.next; 52525 var pendingFirst = pendingQueue.next; 52526 baseQueue.next = pendingFirst; 52527 pendingQueue.next = baseFirst; 52528 } 52529 52530 current.baseQueue = baseQueue = pendingQueue; 52531 queue.pending = null; 52532 } 52533 52534 if (baseQueue !== null) { 52535 // We have a queue to process. 52536 var first = baseQueue.next; 52537 var newState = current.baseState; 52538 var newBaseState = null; 52539 var newBaseQueueFirst = null; 52540 var newBaseQueueLast = null; 52541 var update = first; 52542 52543 do { 52544 var updateExpirationTime = update.expirationTime; 52545 52546 if (updateExpirationTime < renderExpirationTime) { 52547 // Priority is insufficient. Skip this update. If this is the first 52548 // skipped update, the previous update/state is the new base 52549 // update/state. 52550 var clone = { 52551 expirationTime: update.expirationTime, 52552 suspenseConfig: update.suspenseConfig, 52553 action: update.action, 52554 eagerReducer: update.eagerReducer, 52555 eagerState: update.eagerState, 52556 next: null 52557 }; 52558 52559 if (newBaseQueueLast === null) { 52560 newBaseQueueFirst = newBaseQueueLast = clone; 52561 newBaseState = newState; 52562 } else { 52563 newBaseQueueLast = newBaseQueueLast.next = clone; 52564 } // Update the remaining priority in the queue. 52565 52566 52567 if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) { 52568 currentlyRenderingFiber$1.expirationTime = updateExpirationTime; 52569 markUnprocessedUpdateTime(updateExpirationTime); 52570 } 52571 } else { 52572 // This update does have sufficient priority. 52573 if (newBaseQueueLast !== null) { 52574 var _clone = { 52575 expirationTime: Sync, 52576 // This update is going to be committed so we never want uncommit it. 52577 suspenseConfig: update.suspenseConfig, 52578 action: update.action, 52579 eagerReducer: update.eagerReducer, 52580 eagerState: update.eagerState, 52581 next: null 52582 }; 52583 newBaseQueueLast = newBaseQueueLast.next = _clone; 52584 } // Mark the event time of this update as relevant to this render pass. 52585 // TODO: This should ideally use the true event time of this update rather than 52586 // its priority which is a derived and not reverseable value. 52587 // TODO: We should skip this update if it was already committed but currently 52588 // we have no way of detecting the difference between a committed and suspended 52589 // update here. 52590 52591 52592 markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process this update. 52593 52594 if (update.eagerReducer === reducer) { 52595 // If this update was processed eagerly, and its reducer matches the 52596 // current reducer, we can use the eagerly computed state. 52597 newState = update.eagerState; 52598 } else { 52599 var action = update.action; 52600 newState = reducer(newState, action); 52601 } 52602 } 52603 52604 update = update.next; 52605 } while (update !== null && update !== first); 52606 52607 if (newBaseQueueLast === null) { 52608 newBaseState = newState; 52609 } else { 52610 newBaseQueueLast.next = newBaseQueueFirst; 52611 } // Mark that the fiber performed work, but only if the new state is 52612 // different from the current state. 52613 52614 52615 if (!objectIs(newState, hook.memoizedState)) { 52616 markWorkInProgressReceivedUpdate(); 52617 } 52618 52619 hook.memoizedState = newState; 52620 hook.baseState = newBaseState; 52621 hook.baseQueue = newBaseQueueLast; 52622 queue.lastRenderedState = newState; 52623 } 52624 52625 var dispatch = queue.dispatch; 52626 return [hook.memoizedState, dispatch]; 52627} 52628 52629function rerenderReducer(reducer, initialArg, init) { 52630 var hook = updateWorkInProgressHook(); 52631 var queue = hook.queue; 52632 52633 if (!(queue !== null)) { 52634 { 52635 throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); 52636 } 52637 } 52638 52639 queue.lastRenderedReducer = reducer; // This is a re-render. Apply the new render phase updates to the previous 52640 // work-in-progress hook. 52641 52642 var dispatch = queue.dispatch; 52643 var lastRenderPhaseUpdate = queue.pending; 52644 var newState = hook.memoizedState; 52645 52646 if (lastRenderPhaseUpdate !== null) { 52647 // The queue doesn't persist past this render pass. 52648 queue.pending = null; 52649 var firstRenderPhaseUpdate = lastRenderPhaseUpdate.next; 52650 var update = firstRenderPhaseUpdate; 52651 52652 do { 52653 // Process this render phase update. We don't have to check the 52654 // priority because it will always be the same as the current 52655 // render's. 52656 var action = update.action; 52657 newState = reducer(newState, action); 52658 update = update.next; 52659 } while (update !== firstRenderPhaseUpdate); // Mark that the fiber performed work, but only if the new state is 52660 // different from the current state. 52661 52662 52663 if (!objectIs(newState, hook.memoizedState)) { 52664 markWorkInProgressReceivedUpdate(); 52665 } 52666 52667 hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to 52668 // the base state unless the queue is empty. 52669 // TODO: Not sure if this is the desired semantics, but it's what we 52670 // do for gDSFP. I can't remember why. 52671 52672 if (hook.baseQueue === null) { 52673 hook.baseState = newState; 52674 } 52675 52676 queue.lastRenderedState = newState; 52677 } 52678 52679 return [newState, dispatch]; 52680} 52681 52682function mountState(initialState) { 52683 var hook = mountWorkInProgressHook(); 52684 52685 if (typeof initialState === 'function') { 52686 // $FlowFixMe: Flow doesn't like mixed types 52687 initialState = initialState(); 52688 } 52689 52690 hook.memoizedState = hook.baseState = initialState; 52691 var queue = hook.queue = { 52692 pending: null, 52693 dispatch: null, 52694 lastRenderedReducer: basicStateReducer, 52695 lastRenderedState: initialState 52696 }; 52697 var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue); 52698 return [hook.memoizedState, dispatch]; 52699} 52700 52701function updateState(initialState) { 52702 return updateReducer(basicStateReducer); 52703} 52704 52705function rerenderState(initialState) { 52706 return rerenderReducer(basicStateReducer); 52707} 52708 52709function pushEffect(tag, create, destroy, deps) { 52710 var effect = { 52711 tag: tag, 52712 create: create, 52713 destroy: destroy, 52714 deps: deps, 52715 // Circular 52716 next: null 52717 }; 52718 var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue; 52719 52720 if (componentUpdateQueue === null) { 52721 componentUpdateQueue = createFunctionComponentUpdateQueue(); 52722 currentlyRenderingFiber$1.updateQueue = componentUpdateQueue; 52723 componentUpdateQueue.lastEffect = effect.next = effect; 52724 } else { 52725 var lastEffect = componentUpdateQueue.lastEffect; 52726 52727 if (lastEffect === null) { 52728 componentUpdateQueue.lastEffect = effect.next = effect; 52729 } else { 52730 var firstEffect = lastEffect.next; 52731 lastEffect.next = effect; 52732 effect.next = firstEffect; 52733 componentUpdateQueue.lastEffect = effect; 52734 } 52735 } 52736 52737 return effect; 52738} 52739 52740function mountRef(initialValue) { 52741 var hook = mountWorkInProgressHook(); 52742 var ref = { 52743 current: initialValue 52744 }; 52745 52746 { 52747 Object.seal(ref); 52748 } 52749 52750 hook.memoizedState = ref; 52751 return ref; 52752} 52753 52754function updateRef(initialValue) { 52755 var hook = updateWorkInProgressHook(); 52756 return hook.memoizedState; 52757} 52758 52759function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { 52760 var hook = mountWorkInProgressHook(); 52761 var nextDeps = deps === undefined ? null : deps; 52762 currentlyRenderingFiber$1.effectTag |= fiberEffectTag; 52763 hook.memoizedState = pushEffect(HasEffect | hookEffectTag, create, undefined, nextDeps); 52764} 52765 52766function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { 52767 var hook = updateWorkInProgressHook(); 52768 var nextDeps = deps === undefined ? null : deps; 52769 var destroy = undefined; 52770 52771 if (currentHook !== null) { 52772 var prevEffect = currentHook.memoizedState; 52773 destroy = prevEffect.destroy; 52774 52775 if (nextDeps !== null) { 52776 var prevDeps = prevEffect.deps; 52777 52778 if (areHookInputsEqual(nextDeps, prevDeps)) { 52779 pushEffect(hookEffectTag, create, destroy, nextDeps); 52780 return; 52781 } 52782 } 52783 } 52784 52785 currentlyRenderingFiber$1.effectTag |= fiberEffectTag; 52786 hook.memoizedState = pushEffect(HasEffect | hookEffectTag, create, destroy, nextDeps); 52787} 52788 52789function mountEffect(create, deps) { 52790 { 52791 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 52792 if ('undefined' !== typeof jest) { 52793 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1); 52794 } 52795 } 52796 52797 return mountEffectImpl(Update | Passive, Passive$1, create, deps); 52798} 52799 52800function updateEffect(create, deps) { 52801 { 52802 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 52803 if ('undefined' !== typeof jest) { 52804 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1); 52805 } 52806 } 52807 52808 return updateEffectImpl(Update | Passive, Passive$1, create, deps); 52809} 52810 52811function mountLayoutEffect(create, deps) { 52812 return mountEffectImpl(Update, Layout, create, deps); 52813} 52814 52815function updateLayoutEffect(create, deps) { 52816 return updateEffectImpl(Update, Layout, create, deps); 52817} 52818 52819function imperativeHandleEffect(create, ref) { 52820 if (typeof ref === 'function') { 52821 var refCallback = ref; 52822 52823 var _inst = create(); 52824 52825 refCallback(_inst); 52826 return function () { 52827 refCallback(null); 52828 }; 52829 } else if (ref !== null && ref !== undefined) { 52830 var refObject = ref; 52831 52832 { 52833 if (!refObject.hasOwnProperty('current')) { 52834 error('Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}'); 52835 } 52836 } 52837 52838 var _inst2 = create(); 52839 52840 refObject.current = _inst2; 52841 return function () { 52842 refObject.current = null; 52843 }; 52844 } 52845} 52846 52847function mountImperativeHandle(ref, create, deps) { 52848 { 52849 if (typeof create !== 'function') { 52850 error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null'); 52851 } 52852 } // TODO: If deps are provided, should we skip comparing the ref itself? 52853 52854 52855 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null; 52856 return mountEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps); 52857} 52858 52859function updateImperativeHandle(ref, create, deps) { 52860 { 52861 if (typeof create !== 'function') { 52862 error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null'); 52863 } 52864 } // TODO: If deps are provided, should we skip comparing the ref itself? 52865 52866 52867 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null; 52868 return updateEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps); 52869} 52870 52871function mountDebugValue(value, formatterFn) {// This hook is normally a no-op. 52872 // The react-debug-hooks package injects its own implementation 52873 // so that e.g. DevTools can display custom hook values. 52874} 52875 52876var updateDebugValue = mountDebugValue; 52877 52878function mountCallback(callback, deps) { 52879 var hook = mountWorkInProgressHook(); 52880 var nextDeps = deps === undefined ? null : deps; 52881 hook.memoizedState = [callback, nextDeps]; 52882 return callback; 52883} 52884 52885function updateCallback(callback, deps) { 52886 var hook = updateWorkInProgressHook(); 52887 var nextDeps = deps === undefined ? null : deps; 52888 var prevState = hook.memoizedState; 52889 52890 if (prevState !== null) { 52891 if (nextDeps !== null) { 52892 var prevDeps = prevState[1]; 52893 52894 if (areHookInputsEqual(nextDeps, prevDeps)) { 52895 return prevState[0]; 52896 } 52897 } 52898 } 52899 52900 hook.memoizedState = [callback, nextDeps]; 52901 return callback; 52902} 52903 52904function mountMemo(nextCreate, deps) { 52905 var hook = mountWorkInProgressHook(); 52906 var nextDeps = deps === undefined ? null : deps; 52907 var nextValue = nextCreate(); 52908 hook.memoizedState = [nextValue, nextDeps]; 52909 return nextValue; 52910} 52911 52912function updateMemo(nextCreate, deps) { 52913 var hook = updateWorkInProgressHook(); 52914 var nextDeps = deps === undefined ? null : deps; 52915 var prevState = hook.memoizedState; 52916 52917 if (prevState !== null) { 52918 // Assume these are defined. If they're not, areHookInputsEqual will warn. 52919 if (nextDeps !== null) { 52920 var prevDeps = prevState[1]; 52921 52922 if (areHookInputsEqual(nextDeps, prevDeps)) { 52923 return prevState[0]; 52924 } 52925 } 52926 } 52927 52928 var nextValue = nextCreate(); 52929 hook.memoizedState = [nextValue, nextDeps]; 52930 return nextValue; 52931} 52932 52933function mountDeferredValue(value, config) { 52934 var _mountState = mountState(value), 52935 prevValue = _mountState[0], 52936 setValue = _mountState[1]; 52937 52938 mountEffect(function () { 52939 var previousConfig = ReactCurrentBatchConfig$1.suspense; 52940 ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; 52941 52942 try { 52943 setValue(value); 52944 } finally { 52945 ReactCurrentBatchConfig$1.suspense = previousConfig; 52946 } 52947 }, [value, config]); 52948 return prevValue; 52949} 52950 52951function updateDeferredValue(value, config) { 52952 var _updateState = updateState(), 52953 prevValue = _updateState[0], 52954 setValue = _updateState[1]; 52955 52956 updateEffect(function () { 52957 var previousConfig = ReactCurrentBatchConfig$1.suspense; 52958 ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; 52959 52960 try { 52961 setValue(value); 52962 } finally { 52963 ReactCurrentBatchConfig$1.suspense = previousConfig; 52964 } 52965 }, [value, config]); 52966 return prevValue; 52967} 52968 52969function rerenderDeferredValue(value, config) { 52970 var _rerenderState = rerenderState(), 52971 prevValue = _rerenderState[0], 52972 setValue = _rerenderState[1]; 52973 52974 updateEffect(function () { 52975 var previousConfig = ReactCurrentBatchConfig$1.suspense; 52976 ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; 52977 52978 try { 52979 setValue(value); 52980 } finally { 52981 ReactCurrentBatchConfig$1.suspense = previousConfig; 52982 } 52983 }, [value, config]); 52984 return prevValue; 52985} 52986 52987function startTransition(setPending, config, callback) { 52988 var priorityLevel = getCurrentPriorityLevel(); 52989 runWithPriority$1(priorityLevel < UserBlockingPriority$1 ? UserBlockingPriority$1 : priorityLevel, function () { 52990 setPending(true); 52991 }); 52992 runWithPriority$1(priorityLevel > NormalPriority ? NormalPriority : priorityLevel, function () { 52993 var previousConfig = ReactCurrentBatchConfig$1.suspense; 52994 ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; 52995 52996 try { 52997 setPending(false); 52998 callback(); 52999 } finally { 53000 ReactCurrentBatchConfig$1.suspense = previousConfig; 53001 } 53002 }); 53003} 53004 53005function mountTransition(config) { 53006 var _mountState2 = mountState(false), 53007 isPending = _mountState2[0], 53008 setPending = _mountState2[1]; 53009 53010 var start = mountCallback(startTransition.bind(null, setPending, config), [setPending, config]); 53011 return [start, isPending]; 53012} 53013 53014function updateTransition(config) { 53015 var _updateState2 = updateState(), 53016 isPending = _updateState2[0], 53017 setPending = _updateState2[1]; 53018 53019 var start = updateCallback(startTransition.bind(null, setPending, config), [setPending, config]); 53020 return [start, isPending]; 53021} 53022 53023function rerenderTransition(config) { 53024 var _rerenderState2 = rerenderState(), 53025 isPending = _rerenderState2[0], 53026 setPending = _rerenderState2[1]; 53027 53028 var start = updateCallback(startTransition.bind(null, setPending, config), [setPending, config]); 53029 return [start, isPending]; 53030} 53031 53032function dispatchAction(fiber, queue, action) { 53033 { 53034 if (typeof arguments[3] === 'function') { 53035 error("State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().'); 53036 } 53037 } 53038 53039 var currentTime = requestCurrentTimeForUpdate(); 53040 var suspenseConfig = requestCurrentSuspenseConfig(); 53041 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); 53042 var update = { 53043 expirationTime: expirationTime, 53044 suspenseConfig: suspenseConfig, 53045 action: action, 53046 eagerReducer: null, 53047 eagerState: null, 53048 next: null 53049 }; 53050 53051 { 53052 update.priority = getCurrentPriorityLevel(); 53053 } // Append the update to the end of the list. 53054 53055 53056 var pending = queue.pending; 53057 53058 if (pending === null) { 53059 // This is the first update. Create a circular list. 53060 update.next = update; 53061 } else { 53062 update.next = pending.next; 53063 pending.next = update; 53064 } 53065 53066 queue.pending = update; 53067 var alternate = fiber.alternate; 53068 53069 if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) { 53070 // This is a render phase update. Stash it in a lazily-created map of 53071 // queue -> linked list of updates. After this render pass, we'll restart 53072 // and apply the stashed updates on top of the work-in-progress hook. 53073 didScheduleRenderPhaseUpdate = true; 53074 update.expirationTime = renderExpirationTime; 53075 currentlyRenderingFiber$1.expirationTime = renderExpirationTime; 53076 } else { 53077 if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) { 53078 // The queue is currently empty, which means we can eagerly compute the 53079 // next state before entering the render phase. If the new state is the 53080 // same as the current state, we may be able to bail out entirely. 53081 var lastRenderedReducer = queue.lastRenderedReducer; 53082 53083 if (lastRenderedReducer !== null) { 53084 var prevDispatcher; 53085 53086 { 53087 prevDispatcher = ReactCurrentDispatcher.current; 53088 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 53089 } 53090 53091 try { 53092 var currentState = queue.lastRenderedState; 53093 var eagerState = lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute 53094 // it, on the update object. If the reducer hasn't changed by the 53095 // time we enter the render phase, then the eager state can be used 53096 // without calling the reducer again. 53097 53098 update.eagerReducer = lastRenderedReducer; 53099 update.eagerState = eagerState; 53100 53101 if (objectIs(eagerState, currentState)) { 53102 // Fast path. We can bail out without scheduling React to re-render. 53103 // It's still possible that we'll need to rebase this update later, 53104 // if the component re-renders for a different reason and by that 53105 // time the reducer has changed. 53106 return; 53107 } 53108 } catch (error) {// Suppress the error. It will throw again in the render phase. 53109 } finally { 53110 { 53111 ReactCurrentDispatcher.current = prevDispatcher; 53112 } 53113 } 53114 } 53115 } 53116 53117 { 53118 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 53119 if ('undefined' !== typeof jest) { 53120 warnIfNotScopedWithMatchingAct(fiber); 53121 warnIfNotCurrentlyActingUpdatesInDev(fiber); 53122 } 53123 } 53124 53125 scheduleWork(fiber, expirationTime); 53126 } 53127} 53128 53129var ContextOnlyDispatcher = { 53130 readContext: readContext, 53131 useCallback: throwInvalidHookError, 53132 useContext: throwInvalidHookError, 53133 useEffect: throwInvalidHookError, 53134 useImperativeHandle: throwInvalidHookError, 53135 useLayoutEffect: throwInvalidHookError, 53136 useMemo: throwInvalidHookError, 53137 useReducer: throwInvalidHookError, 53138 useRef: throwInvalidHookError, 53139 useState: throwInvalidHookError, 53140 useDebugValue: throwInvalidHookError, 53141 useResponder: throwInvalidHookError, 53142 useDeferredValue: throwInvalidHookError, 53143 useTransition: throwInvalidHookError 53144}; 53145var HooksDispatcherOnMountInDEV = null; 53146var HooksDispatcherOnMountWithHookTypesInDEV = null; 53147var HooksDispatcherOnUpdateInDEV = null; 53148var HooksDispatcherOnRerenderInDEV = null; 53149var InvalidNestedHooksDispatcherOnMountInDEV = null; 53150var InvalidNestedHooksDispatcherOnUpdateInDEV = null; 53151var InvalidNestedHooksDispatcherOnRerenderInDEV = null; 53152 53153{ 53154 var warnInvalidContextAccess = function () { 53155 error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().'); 53156 }; 53157 53158 var warnInvalidHookAccess = function () { 53159 error('Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks'); 53160 }; 53161 53162 HooksDispatcherOnMountInDEV = { 53163 readContext: function (context, observedBits) { 53164 return readContext(context, observedBits); 53165 }, 53166 useCallback: function (callback, deps) { 53167 currentHookNameInDev = 'useCallback'; 53168 mountHookTypesDev(); 53169 checkDepsAreArrayDev(deps); 53170 return mountCallback(callback, deps); 53171 }, 53172 useContext: function (context, observedBits) { 53173 currentHookNameInDev = 'useContext'; 53174 mountHookTypesDev(); 53175 return readContext(context, observedBits); 53176 }, 53177 useEffect: function (create, deps) { 53178 currentHookNameInDev = 'useEffect'; 53179 mountHookTypesDev(); 53180 checkDepsAreArrayDev(deps); 53181 return mountEffect(create, deps); 53182 }, 53183 useImperativeHandle: function (ref, create, deps) { 53184 currentHookNameInDev = 'useImperativeHandle'; 53185 mountHookTypesDev(); 53186 checkDepsAreArrayDev(deps); 53187 return mountImperativeHandle(ref, create, deps); 53188 }, 53189 useLayoutEffect: function (create, deps) { 53190 currentHookNameInDev = 'useLayoutEffect'; 53191 mountHookTypesDev(); 53192 checkDepsAreArrayDev(deps); 53193 return mountLayoutEffect(create, deps); 53194 }, 53195 useMemo: function (create, deps) { 53196 currentHookNameInDev = 'useMemo'; 53197 mountHookTypesDev(); 53198 checkDepsAreArrayDev(deps); 53199 var prevDispatcher = ReactCurrentDispatcher.current; 53200 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 53201 53202 try { 53203 return mountMemo(create, deps); 53204 } finally { 53205 ReactCurrentDispatcher.current = prevDispatcher; 53206 } 53207 }, 53208 useReducer: function (reducer, initialArg, init) { 53209 currentHookNameInDev = 'useReducer'; 53210 mountHookTypesDev(); 53211 var prevDispatcher = ReactCurrentDispatcher.current; 53212 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 53213 53214 try { 53215 return mountReducer(reducer, initialArg, init); 53216 } finally { 53217 ReactCurrentDispatcher.current = prevDispatcher; 53218 } 53219 }, 53220 useRef: function (initialValue) { 53221 currentHookNameInDev = 'useRef'; 53222 mountHookTypesDev(); 53223 return mountRef(initialValue); 53224 }, 53225 useState: function (initialState) { 53226 currentHookNameInDev = 'useState'; 53227 mountHookTypesDev(); 53228 var prevDispatcher = ReactCurrentDispatcher.current; 53229 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 53230 53231 try { 53232 return mountState(initialState); 53233 } finally { 53234 ReactCurrentDispatcher.current = prevDispatcher; 53235 } 53236 }, 53237 useDebugValue: function (value, formatterFn) { 53238 currentHookNameInDev = 'useDebugValue'; 53239 mountHookTypesDev(); 53240 return mountDebugValue(); 53241 }, 53242 useResponder: function (responder, props) { 53243 currentHookNameInDev = 'useResponder'; 53244 mountHookTypesDev(); 53245 return createDeprecatedResponderListener(responder, props); 53246 }, 53247 useDeferredValue: function (value, config) { 53248 currentHookNameInDev = 'useDeferredValue'; 53249 mountHookTypesDev(); 53250 return mountDeferredValue(value, config); 53251 }, 53252 useTransition: function (config) { 53253 currentHookNameInDev = 'useTransition'; 53254 mountHookTypesDev(); 53255 return mountTransition(config); 53256 } 53257 }; 53258 HooksDispatcherOnMountWithHookTypesInDEV = { 53259 readContext: function (context, observedBits) { 53260 return readContext(context, observedBits); 53261 }, 53262 useCallback: function (callback, deps) { 53263 currentHookNameInDev = 'useCallback'; 53264 updateHookTypesDev(); 53265 return mountCallback(callback, deps); 53266 }, 53267 useContext: function (context, observedBits) { 53268 currentHookNameInDev = 'useContext'; 53269 updateHookTypesDev(); 53270 return readContext(context, observedBits); 53271 }, 53272 useEffect: function (create, deps) { 53273 currentHookNameInDev = 'useEffect'; 53274 updateHookTypesDev(); 53275 return mountEffect(create, deps); 53276 }, 53277 useImperativeHandle: function (ref, create, deps) { 53278 currentHookNameInDev = 'useImperativeHandle'; 53279 updateHookTypesDev(); 53280 return mountImperativeHandle(ref, create, deps); 53281 }, 53282 useLayoutEffect: function (create, deps) { 53283 currentHookNameInDev = 'useLayoutEffect'; 53284 updateHookTypesDev(); 53285 return mountLayoutEffect(create, deps); 53286 }, 53287 useMemo: function (create, deps) { 53288 currentHookNameInDev = 'useMemo'; 53289 updateHookTypesDev(); 53290 var prevDispatcher = ReactCurrentDispatcher.current; 53291 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 53292 53293 try { 53294 return mountMemo(create, deps); 53295 } finally { 53296 ReactCurrentDispatcher.current = prevDispatcher; 53297 } 53298 }, 53299 useReducer: function (reducer, initialArg, init) { 53300 currentHookNameInDev = 'useReducer'; 53301 updateHookTypesDev(); 53302 var prevDispatcher = ReactCurrentDispatcher.current; 53303 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 53304 53305 try { 53306 return mountReducer(reducer, initialArg, init); 53307 } finally { 53308 ReactCurrentDispatcher.current = prevDispatcher; 53309 } 53310 }, 53311 useRef: function (initialValue) { 53312 currentHookNameInDev = 'useRef'; 53313 updateHookTypesDev(); 53314 return mountRef(initialValue); 53315 }, 53316 useState: function (initialState) { 53317 currentHookNameInDev = 'useState'; 53318 updateHookTypesDev(); 53319 var prevDispatcher = ReactCurrentDispatcher.current; 53320 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 53321 53322 try { 53323 return mountState(initialState); 53324 } finally { 53325 ReactCurrentDispatcher.current = prevDispatcher; 53326 } 53327 }, 53328 useDebugValue: function (value, formatterFn) { 53329 currentHookNameInDev = 'useDebugValue'; 53330 updateHookTypesDev(); 53331 return mountDebugValue(); 53332 }, 53333 useResponder: function (responder, props) { 53334 currentHookNameInDev = 'useResponder'; 53335 updateHookTypesDev(); 53336 return createDeprecatedResponderListener(responder, props); 53337 }, 53338 useDeferredValue: function (value, config) { 53339 currentHookNameInDev = 'useDeferredValue'; 53340 updateHookTypesDev(); 53341 return mountDeferredValue(value, config); 53342 }, 53343 useTransition: function (config) { 53344 currentHookNameInDev = 'useTransition'; 53345 updateHookTypesDev(); 53346 return mountTransition(config); 53347 } 53348 }; 53349 HooksDispatcherOnUpdateInDEV = { 53350 readContext: function (context, observedBits) { 53351 return readContext(context, observedBits); 53352 }, 53353 useCallback: function (callback, deps) { 53354 currentHookNameInDev = 'useCallback'; 53355 updateHookTypesDev(); 53356 return updateCallback(callback, deps); 53357 }, 53358 useContext: function (context, observedBits) { 53359 currentHookNameInDev = 'useContext'; 53360 updateHookTypesDev(); 53361 return readContext(context, observedBits); 53362 }, 53363 useEffect: function (create, deps) { 53364 currentHookNameInDev = 'useEffect'; 53365 updateHookTypesDev(); 53366 return updateEffect(create, deps); 53367 }, 53368 useImperativeHandle: function (ref, create, deps) { 53369 currentHookNameInDev = 'useImperativeHandle'; 53370 updateHookTypesDev(); 53371 return updateImperativeHandle(ref, create, deps); 53372 }, 53373 useLayoutEffect: function (create, deps) { 53374 currentHookNameInDev = 'useLayoutEffect'; 53375 updateHookTypesDev(); 53376 return updateLayoutEffect(create, deps); 53377 }, 53378 useMemo: function (create, deps) { 53379 currentHookNameInDev = 'useMemo'; 53380 updateHookTypesDev(); 53381 var prevDispatcher = ReactCurrentDispatcher.current; 53382 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 53383 53384 try { 53385 return updateMemo(create, deps); 53386 } finally { 53387 ReactCurrentDispatcher.current = prevDispatcher; 53388 } 53389 }, 53390 useReducer: function (reducer, initialArg, init) { 53391 currentHookNameInDev = 'useReducer'; 53392 updateHookTypesDev(); 53393 var prevDispatcher = ReactCurrentDispatcher.current; 53394 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 53395 53396 try { 53397 return updateReducer(reducer, initialArg, init); 53398 } finally { 53399 ReactCurrentDispatcher.current = prevDispatcher; 53400 } 53401 }, 53402 useRef: function (initialValue) { 53403 currentHookNameInDev = 'useRef'; 53404 updateHookTypesDev(); 53405 return updateRef(); 53406 }, 53407 useState: function (initialState) { 53408 currentHookNameInDev = 'useState'; 53409 updateHookTypesDev(); 53410 var prevDispatcher = ReactCurrentDispatcher.current; 53411 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 53412 53413 try { 53414 return updateState(initialState); 53415 } finally { 53416 ReactCurrentDispatcher.current = prevDispatcher; 53417 } 53418 }, 53419 useDebugValue: function (value, formatterFn) { 53420 currentHookNameInDev = 'useDebugValue'; 53421 updateHookTypesDev(); 53422 return updateDebugValue(); 53423 }, 53424 useResponder: function (responder, props) { 53425 currentHookNameInDev = 'useResponder'; 53426 updateHookTypesDev(); 53427 return createDeprecatedResponderListener(responder, props); 53428 }, 53429 useDeferredValue: function (value, config) { 53430 currentHookNameInDev = 'useDeferredValue'; 53431 updateHookTypesDev(); 53432 return updateDeferredValue(value, config); 53433 }, 53434 useTransition: function (config) { 53435 currentHookNameInDev = 'useTransition'; 53436 updateHookTypesDev(); 53437 return updateTransition(config); 53438 } 53439 }; 53440 HooksDispatcherOnRerenderInDEV = { 53441 readContext: function (context, observedBits) { 53442 return readContext(context, observedBits); 53443 }, 53444 useCallback: function (callback, deps) { 53445 currentHookNameInDev = 'useCallback'; 53446 updateHookTypesDev(); 53447 return updateCallback(callback, deps); 53448 }, 53449 useContext: function (context, observedBits) { 53450 currentHookNameInDev = 'useContext'; 53451 updateHookTypesDev(); 53452 return readContext(context, observedBits); 53453 }, 53454 useEffect: function (create, deps) { 53455 currentHookNameInDev = 'useEffect'; 53456 updateHookTypesDev(); 53457 return updateEffect(create, deps); 53458 }, 53459 useImperativeHandle: function (ref, create, deps) { 53460 currentHookNameInDev = 'useImperativeHandle'; 53461 updateHookTypesDev(); 53462 return updateImperativeHandle(ref, create, deps); 53463 }, 53464 useLayoutEffect: function (create, deps) { 53465 currentHookNameInDev = 'useLayoutEffect'; 53466 updateHookTypesDev(); 53467 return updateLayoutEffect(create, deps); 53468 }, 53469 useMemo: function (create, deps) { 53470 currentHookNameInDev = 'useMemo'; 53471 updateHookTypesDev(); 53472 var prevDispatcher = ReactCurrentDispatcher.current; 53473 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; 53474 53475 try { 53476 return updateMemo(create, deps); 53477 } finally { 53478 ReactCurrentDispatcher.current = prevDispatcher; 53479 } 53480 }, 53481 useReducer: function (reducer, initialArg, init) { 53482 currentHookNameInDev = 'useReducer'; 53483 updateHookTypesDev(); 53484 var prevDispatcher = ReactCurrentDispatcher.current; 53485 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; 53486 53487 try { 53488 return rerenderReducer(reducer, initialArg, init); 53489 } finally { 53490 ReactCurrentDispatcher.current = prevDispatcher; 53491 } 53492 }, 53493 useRef: function (initialValue) { 53494 currentHookNameInDev = 'useRef'; 53495 updateHookTypesDev(); 53496 return updateRef(); 53497 }, 53498 useState: function (initialState) { 53499 currentHookNameInDev = 'useState'; 53500 updateHookTypesDev(); 53501 var prevDispatcher = ReactCurrentDispatcher.current; 53502 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; 53503 53504 try { 53505 return rerenderState(initialState); 53506 } finally { 53507 ReactCurrentDispatcher.current = prevDispatcher; 53508 } 53509 }, 53510 useDebugValue: function (value, formatterFn) { 53511 currentHookNameInDev = 'useDebugValue'; 53512 updateHookTypesDev(); 53513 return updateDebugValue(); 53514 }, 53515 useResponder: function (responder, props) { 53516 currentHookNameInDev = 'useResponder'; 53517 updateHookTypesDev(); 53518 return createDeprecatedResponderListener(responder, props); 53519 }, 53520 useDeferredValue: function (value, config) { 53521 currentHookNameInDev = 'useDeferredValue'; 53522 updateHookTypesDev(); 53523 return rerenderDeferredValue(value, config); 53524 }, 53525 useTransition: function (config) { 53526 currentHookNameInDev = 'useTransition'; 53527 updateHookTypesDev(); 53528 return rerenderTransition(config); 53529 } 53530 }; 53531 InvalidNestedHooksDispatcherOnMountInDEV = { 53532 readContext: function (context, observedBits) { 53533 warnInvalidContextAccess(); 53534 return readContext(context, observedBits); 53535 }, 53536 useCallback: function (callback, deps) { 53537 currentHookNameInDev = 'useCallback'; 53538 warnInvalidHookAccess(); 53539 mountHookTypesDev(); 53540 return mountCallback(callback, deps); 53541 }, 53542 useContext: function (context, observedBits) { 53543 currentHookNameInDev = 'useContext'; 53544 warnInvalidHookAccess(); 53545 mountHookTypesDev(); 53546 return readContext(context, observedBits); 53547 }, 53548 useEffect: function (create, deps) { 53549 currentHookNameInDev = 'useEffect'; 53550 warnInvalidHookAccess(); 53551 mountHookTypesDev(); 53552 return mountEffect(create, deps); 53553 }, 53554 useImperativeHandle: function (ref, create, deps) { 53555 currentHookNameInDev = 'useImperativeHandle'; 53556 warnInvalidHookAccess(); 53557 mountHookTypesDev(); 53558 return mountImperativeHandle(ref, create, deps); 53559 }, 53560 useLayoutEffect: function (create, deps) { 53561 currentHookNameInDev = 'useLayoutEffect'; 53562 warnInvalidHookAccess(); 53563 mountHookTypesDev(); 53564 return mountLayoutEffect(create, deps); 53565 }, 53566 useMemo: function (create, deps) { 53567 currentHookNameInDev = 'useMemo'; 53568 warnInvalidHookAccess(); 53569 mountHookTypesDev(); 53570 var prevDispatcher = ReactCurrentDispatcher.current; 53571 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 53572 53573 try { 53574 return mountMemo(create, deps); 53575 } finally { 53576 ReactCurrentDispatcher.current = prevDispatcher; 53577 } 53578 }, 53579 useReducer: function (reducer, initialArg, init) { 53580 currentHookNameInDev = 'useReducer'; 53581 warnInvalidHookAccess(); 53582 mountHookTypesDev(); 53583 var prevDispatcher = ReactCurrentDispatcher.current; 53584 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 53585 53586 try { 53587 return mountReducer(reducer, initialArg, init); 53588 } finally { 53589 ReactCurrentDispatcher.current = prevDispatcher; 53590 } 53591 }, 53592 useRef: function (initialValue) { 53593 currentHookNameInDev = 'useRef'; 53594 warnInvalidHookAccess(); 53595 mountHookTypesDev(); 53596 return mountRef(initialValue); 53597 }, 53598 useState: function (initialState) { 53599 currentHookNameInDev = 'useState'; 53600 warnInvalidHookAccess(); 53601 mountHookTypesDev(); 53602 var prevDispatcher = ReactCurrentDispatcher.current; 53603 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; 53604 53605 try { 53606 return mountState(initialState); 53607 } finally { 53608 ReactCurrentDispatcher.current = prevDispatcher; 53609 } 53610 }, 53611 useDebugValue: function (value, formatterFn) { 53612 currentHookNameInDev = 'useDebugValue'; 53613 warnInvalidHookAccess(); 53614 mountHookTypesDev(); 53615 return mountDebugValue(); 53616 }, 53617 useResponder: function (responder, props) { 53618 currentHookNameInDev = 'useResponder'; 53619 warnInvalidHookAccess(); 53620 mountHookTypesDev(); 53621 return createDeprecatedResponderListener(responder, props); 53622 }, 53623 useDeferredValue: function (value, config) { 53624 currentHookNameInDev = 'useDeferredValue'; 53625 warnInvalidHookAccess(); 53626 mountHookTypesDev(); 53627 return mountDeferredValue(value, config); 53628 }, 53629 useTransition: function (config) { 53630 currentHookNameInDev = 'useTransition'; 53631 warnInvalidHookAccess(); 53632 mountHookTypesDev(); 53633 return mountTransition(config); 53634 } 53635 }; 53636 InvalidNestedHooksDispatcherOnUpdateInDEV = { 53637 readContext: function (context, observedBits) { 53638 warnInvalidContextAccess(); 53639 return readContext(context, observedBits); 53640 }, 53641 useCallback: function (callback, deps) { 53642 currentHookNameInDev = 'useCallback'; 53643 warnInvalidHookAccess(); 53644 updateHookTypesDev(); 53645 return updateCallback(callback, deps); 53646 }, 53647 useContext: function (context, observedBits) { 53648 currentHookNameInDev = 'useContext'; 53649 warnInvalidHookAccess(); 53650 updateHookTypesDev(); 53651 return readContext(context, observedBits); 53652 }, 53653 useEffect: function (create, deps) { 53654 currentHookNameInDev = 'useEffect'; 53655 warnInvalidHookAccess(); 53656 updateHookTypesDev(); 53657 return updateEffect(create, deps); 53658 }, 53659 useImperativeHandle: function (ref, create, deps) { 53660 currentHookNameInDev = 'useImperativeHandle'; 53661 warnInvalidHookAccess(); 53662 updateHookTypesDev(); 53663 return updateImperativeHandle(ref, create, deps); 53664 }, 53665 useLayoutEffect: function (create, deps) { 53666 currentHookNameInDev = 'useLayoutEffect'; 53667 warnInvalidHookAccess(); 53668 updateHookTypesDev(); 53669 return updateLayoutEffect(create, deps); 53670 }, 53671 useMemo: function (create, deps) { 53672 currentHookNameInDev = 'useMemo'; 53673 warnInvalidHookAccess(); 53674 updateHookTypesDev(); 53675 var prevDispatcher = ReactCurrentDispatcher.current; 53676 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 53677 53678 try { 53679 return updateMemo(create, deps); 53680 } finally { 53681 ReactCurrentDispatcher.current = prevDispatcher; 53682 } 53683 }, 53684 useReducer: function (reducer, initialArg, init) { 53685 currentHookNameInDev = 'useReducer'; 53686 warnInvalidHookAccess(); 53687 updateHookTypesDev(); 53688 var prevDispatcher = ReactCurrentDispatcher.current; 53689 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 53690 53691 try { 53692 return updateReducer(reducer, initialArg, init); 53693 } finally { 53694 ReactCurrentDispatcher.current = prevDispatcher; 53695 } 53696 }, 53697 useRef: function (initialValue) { 53698 currentHookNameInDev = 'useRef'; 53699 warnInvalidHookAccess(); 53700 updateHookTypesDev(); 53701 return updateRef(); 53702 }, 53703 useState: function (initialState) { 53704 currentHookNameInDev = 'useState'; 53705 warnInvalidHookAccess(); 53706 updateHookTypesDev(); 53707 var prevDispatcher = ReactCurrentDispatcher.current; 53708 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 53709 53710 try { 53711 return updateState(initialState); 53712 } finally { 53713 ReactCurrentDispatcher.current = prevDispatcher; 53714 } 53715 }, 53716 useDebugValue: function (value, formatterFn) { 53717 currentHookNameInDev = 'useDebugValue'; 53718 warnInvalidHookAccess(); 53719 updateHookTypesDev(); 53720 return updateDebugValue(); 53721 }, 53722 useResponder: function (responder, props) { 53723 currentHookNameInDev = 'useResponder'; 53724 warnInvalidHookAccess(); 53725 updateHookTypesDev(); 53726 return createDeprecatedResponderListener(responder, props); 53727 }, 53728 useDeferredValue: function (value, config) { 53729 currentHookNameInDev = 'useDeferredValue'; 53730 warnInvalidHookAccess(); 53731 updateHookTypesDev(); 53732 return updateDeferredValue(value, config); 53733 }, 53734 useTransition: function (config) { 53735 currentHookNameInDev = 'useTransition'; 53736 warnInvalidHookAccess(); 53737 updateHookTypesDev(); 53738 return updateTransition(config); 53739 } 53740 }; 53741 InvalidNestedHooksDispatcherOnRerenderInDEV = { 53742 readContext: function (context, observedBits) { 53743 warnInvalidContextAccess(); 53744 return readContext(context, observedBits); 53745 }, 53746 useCallback: function (callback, deps) { 53747 currentHookNameInDev = 'useCallback'; 53748 warnInvalidHookAccess(); 53749 updateHookTypesDev(); 53750 return updateCallback(callback, deps); 53751 }, 53752 useContext: function (context, observedBits) { 53753 currentHookNameInDev = 'useContext'; 53754 warnInvalidHookAccess(); 53755 updateHookTypesDev(); 53756 return readContext(context, observedBits); 53757 }, 53758 useEffect: function (create, deps) { 53759 currentHookNameInDev = 'useEffect'; 53760 warnInvalidHookAccess(); 53761 updateHookTypesDev(); 53762 return updateEffect(create, deps); 53763 }, 53764 useImperativeHandle: function (ref, create, deps) { 53765 currentHookNameInDev = 'useImperativeHandle'; 53766 warnInvalidHookAccess(); 53767 updateHookTypesDev(); 53768 return updateImperativeHandle(ref, create, deps); 53769 }, 53770 useLayoutEffect: function (create, deps) { 53771 currentHookNameInDev = 'useLayoutEffect'; 53772 warnInvalidHookAccess(); 53773 updateHookTypesDev(); 53774 return updateLayoutEffect(create, deps); 53775 }, 53776 useMemo: function (create, deps) { 53777 currentHookNameInDev = 'useMemo'; 53778 warnInvalidHookAccess(); 53779 updateHookTypesDev(); 53780 var prevDispatcher = ReactCurrentDispatcher.current; 53781 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 53782 53783 try { 53784 return updateMemo(create, deps); 53785 } finally { 53786 ReactCurrentDispatcher.current = prevDispatcher; 53787 } 53788 }, 53789 useReducer: function (reducer, initialArg, init) { 53790 currentHookNameInDev = 'useReducer'; 53791 warnInvalidHookAccess(); 53792 updateHookTypesDev(); 53793 var prevDispatcher = ReactCurrentDispatcher.current; 53794 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 53795 53796 try { 53797 return rerenderReducer(reducer, initialArg, init); 53798 } finally { 53799 ReactCurrentDispatcher.current = prevDispatcher; 53800 } 53801 }, 53802 useRef: function (initialValue) { 53803 currentHookNameInDev = 'useRef'; 53804 warnInvalidHookAccess(); 53805 updateHookTypesDev(); 53806 return updateRef(); 53807 }, 53808 useState: function (initialState) { 53809 currentHookNameInDev = 'useState'; 53810 warnInvalidHookAccess(); 53811 updateHookTypesDev(); 53812 var prevDispatcher = ReactCurrentDispatcher.current; 53813 ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 53814 53815 try { 53816 return rerenderState(initialState); 53817 } finally { 53818 ReactCurrentDispatcher.current = prevDispatcher; 53819 } 53820 }, 53821 useDebugValue: function (value, formatterFn) { 53822 currentHookNameInDev = 'useDebugValue'; 53823 warnInvalidHookAccess(); 53824 updateHookTypesDev(); 53825 return updateDebugValue(); 53826 }, 53827 useResponder: function (responder, props) { 53828 currentHookNameInDev = 'useResponder'; 53829 warnInvalidHookAccess(); 53830 updateHookTypesDev(); 53831 return createDeprecatedResponderListener(responder, props); 53832 }, 53833 useDeferredValue: function (value, config) { 53834 currentHookNameInDev = 'useDeferredValue'; 53835 warnInvalidHookAccess(); 53836 updateHookTypesDev(); 53837 return rerenderDeferredValue(value, config); 53838 }, 53839 useTransition: function (config) { 53840 currentHookNameInDev = 'useTransition'; 53841 warnInvalidHookAccess(); 53842 updateHookTypesDev(); 53843 return rerenderTransition(config); 53844 } 53845 }; 53846} 53847 53848var now$1 = Scheduler.unstable_now; 53849var commitTime = 0; 53850var profilerStartTime = -1; 53851 53852function getCommitTime() { 53853 return commitTime; 53854} 53855 53856function recordCommitTime() { 53857 53858 commitTime = now$1(); 53859} 53860 53861function startProfilerTimer(fiber) { 53862 53863 profilerStartTime = now$1(); 53864 53865 if (fiber.actualStartTime < 0) { 53866 fiber.actualStartTime = now$1(); 53867 } 53868} 53869 53870function stopProfilerTimerIfRunning(fiber) { 53871 53872 profilerStartTime = -1; 53873} 53874 53875function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { 53876 53877 if (profilerStartTime >= 0) { 53878 var elapsedTime = now$1() - profilerStartTime; 53879 fiber.actualDuration += elapsedTime; 53880 53881 if (overrideBaseTime) { 53882 fiber.selfBaseDuration = elapsedTime; 53883 } 53884 53885 profilerStartTime = -1; 53886 } 53887} 53888 53889// This may have been an insertion or a hydration. 53890 53891var hydrationParentFiber = null; 53892var nextHydratableInstance = null; 53893var isHydrating = false; 53894 53895function enterHydrationState(fiber) { 53896 53897 var parentInstance = fiber.stateNode.containerInfo; 53898 nextHydratableInstance = getFirstHydratableChild(parentInstance); 53899 hydrationParentFiber = fiber; 53900 isHydrating = true; 53901 return true; 53902} 53903 53904function deleteHydratableInstance(returnFiber, instance) { 53905 { 53906 switch (returnFiber.tag) { 53907 case HostRoot: 53908 didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance); 53909 break; 53910 53911 case HostComponent: 53912 didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance); 53913 break; 53914 } 53915 } 53916 53917 var childToDelete = createFiberFromHostInstanceForDeletion(); 53918 childToDelete.stateNode = instance; 53919 childToDelete.return = returnFiber; 53920 childToDelete.effectTag = Deletion; // This might seem like it belongs on progressedFirstDeletion. However, 53921 // these children are not part of the reconciliation list of children. 53922 // Even if we abort and rereconcile the children, that will try to hydrate 53923 // again and the nodes are still in the host tree so these will be 53924 // recreated. 53925 53926 if (returnFiber.lastEffect !== null) { 53927 returnFiber.lastEffect.nextEffect = childToDelete; 53928 returnFiber.lastEffect = childToDelete; 53929 } else { 53930 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; 53931 } 53932} 53933 53934function insertNonHydratedInstance(returnFiber, fiber) { 53935 fiber.effectTag = fiber.effectTag & ~Hydrating | Placement; 53936 53937 { 53938 switch (returnFiber.tag) { 53939 case HostRoot: 53940 { 53941 var parentContainer = returnFiber.stateNode.containerInfo; 53942 53943 switch (fiber.tag) { 53944 case HostComponent: 53945 var type = fiber.type; 53946 var props = fiber.pendingProps; 53947 didNotFindHydratableContainerInstance(parentContainer, type); 53948 break; 53949 53950 case HostText: 53951 var text = fiber.pendingProps; 53952 didNotFindHydratableContainerTextInstance(parentContainer, text); 53953 break; 53954 } 53955 53956 break; 53957 } 53958 53959 case HostComponent: 53960 { 53961 var parentType = returnFiber.type; 53962 var parentProps = returnFiber.memoizedProps; 53963 var parentInstance = returnFiber.stateNode; 53964 53965 switch (fiber.tag) { 53966 case HostComponent: 53967 var _type = fiber.type; 53968 var _props = fiber.pendingProps; 53969 didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type); 53970 break; 53971 53972 case HostText: 53973 var _text = fiber.pendingProps; 53974 didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text); 53975 break; 53976 53977 case SuspenseComponent: 53978 didNotFindHydratableSuspenseInstance(parentType, parentProps); 53979 break; 53980 } 53981 53982 break; 53983 } 53984 53985 default: 53986 return; 53987 } 53988 } 53989} 53990 53991function tryHydrate(fiber, nextInstance) { 53992 switch (fiber.tag) { 53993 case HostComponent: 53994 { 53995 var type = fiber.type; 53996 var props = fiber.pendingProps; 53997 var instance = canHydrateInstance(nextInstance, type); 53998 53999 if (instance !== null) { 54000 fiber.stateNode = instance; 54001 return true; 54002 } 54003 54004 return false; 54005 } 54006 54007 case HostText: 54008 { 54009 var text = fiber.pendingProps; 54010 var textInstance = canHydrateTextInstance(nextInstance, text); 54011 54012 if (textInstance !== null) { 54013 fiber.stateNode = textInstance; 54014 return true; 54015 } 54016 54017 return false; 54018 } 54019 54020 case SuspenseComponent: 54021 { 54022 54023 return false; 54024 } 54025 54026 default: 54027 return false; 54028 } 54029} 54030 54031function tryToClaimNextHydratableInstance(fiber) { 54032 if (!isHydrating) { 54033 return; 54034 } 54035 54036 var nextInstance = nextHydratableInstance; 54037 54038 if (!nextInstance) { 54039 // Nothing to hydrate. Make it an insertion. 54040 insertNonHydratedInstance(hydrationParentFiber, fiber); 54041 isHydrating = false; 54042 hydrationParentFiber = fiber; 54043 return; 54044 } 54045 54046 var firstAttemptedInstance = nextInstance; 54047 54048 if (!tryHydrate(fiber, nextInstance)) { 54049 // If we can't hydrate this instance let's try the next one. 54050 // We use this as a heuristic. It's based on intuition and not data so it 54051 // might be flawed or unnecessary. 54052 nextInstance = getNextHydratableSibling(firstAttemptedInstance); 54053 54054 if (!nextInstance || !tryHydrate(fiber, nextInstance)) { 54055 // Nothing to hydrate. Make it an insertion. 54056 insertNonHydratedInstance(hydrationParentFiber, fiber); 54057 isHydrating = false; 54058 hydrationParentFiber = fiber; 54059 return; 54060 } // We matched the next one, we'll now assume that the first one was 54061 // superfluous and we'll delete it. Since we can't eagerly delete it 54062 // we'll have to schedule a deletion. To do that, this node needs a dummy 54063 // fiber associated with it. 54064 54065 54066 deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance); 54067 } 54068 54069 hydrationParentFiber = fiber; 54070 nextHydratableInstance = getFirstHydratableChild(nextInstance); 54071} 54072 54073function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) { 54074 54075 var instance = fiber.stateNode; 54076 var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); // TODO: Type this specific to this type of component. 54077 54078 fiber.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there 54079 // is a new ref we mark this as an update. 54080 54081 if (updatePayload !== null) { 54082 return true; 54083 } 54084 54085 return false; 54086} 54087 54088function prepareToHydrateHostTextInstance(fiber) { 54089 54090 var textInstance = fiber.stateNode; 54091 var textContent = fiber.memoizedProps; 54092 var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber); 54093 54094 { 54095 if (shouldUpdate) { 54096 // We assume that prepareToHydrateHostTextInstance is called in a context where the 54097 // hydration parent is the parent host component of this host text. 54098 var returnFiber = hydrationParentFiber; 54099 54100 if (returnFiber !== null) { 54101 switch (returnFiber.tag) { 54102 case HostRoot: 54103 { 54104 var parentContainer = returnFiber.stateNode.containerInfo; 54105 didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent); 54106 break; 54107 } 54108 54109 case HostComponent: 54110 { 54111 var parentType = returnFiber.type; 54112 var parentProps = returnFiber.memoizedProps; 54113 var parentInstance = returnFiber.stateNode; 54114 didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent); 54115 break; 54116 } 54117 } 54118 } 54119 } 54120 } 54121 54122 return shouldUpdate; 54123} 54124 54125function skipPastDehydratedSuspenseInstance(fiber) { 54126 54127 var suspenseState = fiber.memoizedState; 54128 var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null; 54129 54130 if (!suspenseInstance) { 54131 { 54132 throw Error( "Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue." ); 54133 } 54134 } 54135 54136 return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance); 54137} 54138 54139function popToNextHostParent(fiber) { 54140 var parent = fiber.return; 54141 54142 while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) { 54143 parent = parent.return; 54144 } 54145 54146 hydrationParentFiber = parent; 54147} 54148 54149function popHydrationState(fiber) { 54150 54151 if (fiber !== hydrationParentFiber) { 54152 // We're deeper than the current hydration context, inside an inserted 54153 // tree. 54154 return false; 54155 } 54156 54157 if (!isHydrating) { 54158 // If we're not currently hydrating but we're in a hydration context, then 54159 // we were an insertion and now need to pop up reenter hydration of our 54160 // siblings. 54161 popToNextHostParent(fiber); 54162 isHydrating = true; 54163 return false; 54164 } 54165 54166 var type = fiber.type; // If we have any remaining hydratable nodes, we need to delete them now. 54167 // We only do this deeper than head and body since they tend to have random 54168 // other nodes in them. We also ignore components with pure text content in 54169 // side of them. 54170 // TODO: Better heuristic. 54171 54172 if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) { 54173 var nextInstance = nextHydratableInstance; 54174 54175 while (nextInstance) { 54176 deleteHydratableInstance(fiber, nextInstance); 54177 nextInstance = getNextHydratableSibling(nextInstance); 54178 } 54179 } 54180 54181 popToNextHostParent(fiber); 54182 54183 if (fiber.tag === SuspenseComponent) { 54184 nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber); 54185 } else { 54186 nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null; 54187 } 54188 54189 return true; 54190} 54191 54192function resetHydrationState() { 54193 54194 hydrationParentFiber = null; 54195 nextHydratableInstance = null; 54196 isHydrating = false; 54197} 54198 54199var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; 54200var didReceiveUpdate = false; 54201var didWarnAboutBadClass; 54202var didWarnAboutModulePatternComponent; 54203var didWarnAboutContextTypeOnFunctionComponent; 54204var didWarnAboutGetDerivedStateOnFunctionComponent; 54205var didWarnAboutFunctionRefs; 54206var didWarnAboutReassigningProps; 54207var didWarnAboutRevealOrder; 54208var didWarnAboutTailOptions; 54209 54210{ 54211 didWarnAboutBadClass = {}; 54212 didWarnAboutModulePatternComponent = {}; 54213 didWarnAboutContextTypeOnFunctionComponent = {}; 54214 didWarnAboutGetDerivedStateOnFunctionComponent = {}; 54215 didWarnAboutFunctionRefs = {}; 54216 didWarnAboutReassigningProps = false; 54217 didWarnAboutRevealOrder = {}; 54218 didWarnAboutTailOptions = {}; 54219} 54220 54221function reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime) { 54222 if (current === null) { 54223 // If this is a fresh new component that hasn't been rendered yet, we 54224 // won't update its child set by applying minimal side-effects. Instead, 54225 // we will add them all to the child before it gets rendered. That means 54226 // we can optimize this reconciliation pass by not tracking side-effects. 54227 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 54228 } else { 54229 // If the current child is the same as the work in progress, it means that 54230 // we haven't yet started any work on these children. Therefore, we use 54231 // the clone algorithm to create a copy of all the current children. 54232 // If we had any progressed work already, that is invalid at this point so 54233 // let's throw it out. 54234 workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderExpirationTime); 54235 } 54236} 54237 54238function forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime) { 54239 // This function is fork of reconcileChildren. It's used in cases where we 54240 // want to reconcile without matching against the existing set. This has the 54241 // effect of all current children being unmounted; even if the type and key 54242 // are the same, the old child is unmounted and a new child is created. 54243 // 54244 // To do this, we're going to go through the reconcile algorithm twice. In 54245 // the first pass, we schedule a deletion for all the current children by 54246 // passing null. 54247 workInProgress.child = reconcileChildFibers(workInProgress, current.child, null, renderExpirationTime); // In the second pass, we mount the new children. The trick here is that we 54248 // pass null in place of where we usually pass the current child set. This has 54249 // the effect of remounting all children regardless of whether their 54250 // identities match. 54251 54252 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 54253} 54254 54255function updateForwardRef(current, workInProgress, Component, nextProps, renderExpirationTime) { 54256 // TODO: current can be non-null here even if the component 54257 // hasn't yet mounted. This happens after the first render suspends. 54258 // We'll need to figure out if this is fine or can cause issues. 54259 { 54260 if (workInProgress.type !== workInProgress.elementType) { 54261 // Lazy component props can't be validated in createElement 54262 // because they're only guaranteed to be resolved here. 54263 var innerPropTypes = Component.propTypes; 54264 54265 if (innerPropTypes) { 54266 checkPropTypes(innerPropTypes, nextProps, // Resolved props 54267 'prop', getComponentName(Component), getCurrentFiberStackInDev); 54268 } 54269 } 54270 } 54271 54272 var render = Component.render; 54273 var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent 54274 54275 var nextChildren; 54276 prepareToReadContext(workInProgress, renderExpirationTime); 54277 54278 { 54279 ReactCurrentOwner$1.current = workInProgress; 54280 setIsRendering(true); 54281 nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderExpirationTime); 54282 54283 if ( workInProgress.mode & StrictMode) { 54284 // Only double-render components with Hooks 54285 if (workInProgress.memoizedState !== null) { 54286 nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderExpirationTime); 54287 } 54288 } 54289 54290 setIsRendering(false); 54291 } 54292 54293 if (current !== null && !didReceiveUpdate) { 54294 bailoutHooks(current, workInProgress, renderExpirationTime); 54295 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 54296 } // React DevTools reads this flag. 54297 54298 54299 workInProgress.effectTag |= PerformedWork; 54300 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 54301 return workInProgress.child; 54302} 54303 54304function updateMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) { 54305 if (current === null) { 54306 var type = Component.type; 54307 54308 if (isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either. 54309 Component.defaultProps === undefined) { 54310 var resolvedType = type; 54311 54312 { 54313 resolvedType = resolveFunctionForHotReloading(type); 54314 } // If this is a plain function component without default props, 54315 // and with only the default shallow comparison, we upgrade it 54316 // to a SimpleMemoComponent to allow fast path updates. 54317 54318 54319 workInProgress.tag = SimpleMemoComponent; 54320 workInProgress.type = resolvedType; 54321 54322 { 54323 validateFunctionComponentInDev(workInProgress, type); 54324 } 54325 54326 return updateSimpleMemoComponent(current, workInProgress, resolvedType, nextProps, updateExpirationTime, renderExpirationTime); 54327 } 54328 54329 { 54330 var innerPropTypes = type.propTypes; 54331 54332 if (innerPropTypes) { 54333 // Inner memo component props aren't currently validated in createElement. 54334 // We could move it there, but we'd still need this for lazy code path. 54335 checkPropTypes(innerPropTypes, nextProps, // Resolved props 54336 'prop', getComponentName(type), getCurrentFiberStackInDev); 54337 } 54338 } 54339 54340 var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime); 54341 child.ref = workInProgress.ref; 54342 child.return = workInProgress; 54343 workInProgress.child = child; 54344 return child; 54345 } 54346 54347 { 54348 var _type = Component.type; 54349 var _innerPropTypes = _type.propTypes; 54350 54351 if (_innerPropTypes) { 54352 // Inner memo component props aren't currently validated in createElement. 54353 // We could move it there, but we'd still need this for lazy code path. 54354 checkPropTypes(_innerPropTypes, nextProps, // Resolved props 54355 'prop', getComponentName(_type), getCurrentFiberStackInDev); 54356 } 54357 } 54358 54359 var currentChild = current.child; // This is always exactly one child 54360 54361 if (updateExpirationTime < renderExpirationTime) { 54362 // This will be the props with resolved defaultProps, 54363 // unlike current.memoizedProps which will be the unresolved ones. 54364 var prevProps = currentChild.memoizedProps; // Default to shallow comparison 54365 54366 var compare = Component.compare; 54367 compare = compare !== null ? compare : shallowEqual; 54368 54369 if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) { 54370 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 54371 } 54372 } // React DevTools reads this flag. 54373 54374 54375 workInProgress.effectTag |= PerformedWork; 54376 var newChild = createWorkInProgress(currentChild, nextProps); 54377 newChild.ref = workInProgress.ref; 54378 newChild.return = workInProgress; 54379 workInProgress.child = newChild; 54380 return newChild; 54381} 54382 54383function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) { 54384 // TODO: current can be non-null here even if the component 54385 // hasn't yet mounted. This happens when the inner render suspends. 54386 // We'll need to figure out if this is fine or can cause issues. 54387 { 54388 if (workInProgress.type !== workInProgress.elementType) { 54389 // Lazy component props can't be validated in createElement 54390 // because they're only guaranteed to be resolved here. 54391 var outerMemoType = workInProgress.elementType; 54392 54393 if (outerMemoType.$$typeof === REACT_LAZY_TYPE) { 54394 // We warn when you define propTypes on lazy() 54395 // so let's just skip over it to find memo() outer wrapper. 54396 // Inner props for memo are validated later. 54397 outerMemoType = refineResolvedLazyComponent(outerMemoType); 54398 } 54399 54400 var outerPropTypes = outerMemoType && outerMemoType.propTypes; 54401 54402 if (outerPropTypes) { 54403 checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps) 54404 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev); 54405 } // Inner propTypes will be validated in the function component path. 54406 54407 } 54408 } 54409 54410 if (current !== null) { 54411 var prevProps = current.memoizedProps; 54412 54413 if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload. 54414 workInProgress.type === current.type )) { 54415 didReceiveUpdate = false; 54416 54417 if (updateExpirationTime < renderExpirationTime) { 54418 // The pending update priority was cleared at the beginning of 54419 // beginWork. We're about to bail out, but there might be additional 54420 // updates at a lower priority. Usually, the priority level of the 54421 // remaining updates is accumlated during the evaluation of the 54422 // component (i.e. when processing the update queue). But since since 54423 // we're bailing out early *without* evaluating the component, we need 54424 // to account for it here, too. Reset to the value of the current fiber. 54425 // NOTE: This only applies to SimpleMemoComponent, not MemoComponent, 54426 // because a MemoComponent fiber does not have hooks or an update queue; 54427 // rather, it wraps around an inner component, which may or may not 54428 // contains hooks. 54429 // TODO: Move the reset at in beginWork out of the common path so that 54430 // this is no longer necessary. 54431 workInProgress.expirationTime = current.expirationTime; 54432 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 54433 } 54434 } 54435 } 54436 54437 return updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime); 54438} 54439 54440function updateFragment(current, workInProgress, renderExpirationTime) { 54441 var nextChildren = workInProgress.pendingProps; 54442 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 54443 return workInProgress.child; 54444} 54445 54446function updateMode(current, workInProgress, renderExpirationTime) { 54447 var nextChildren = workInProgress.pendingProps.children; 54448 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 54449 return workInProgress.child; 54450} 54451 54452function updateProfiler(current, workInProgress, renderExpirationTime) { 54453 { 54454 workInProgress.effectTag |= Update; 54455 } 54456 54457 var nextProps = workInProgress.pendingProps; 54458 var nextChildren = nextProps.children; 54459 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 54460 return workInProgress.child; 54461} 54462 54463function markRef(current, workInProgress) { 54464 var ref = workInProgress.ref; 54465 54466 if (current === null && ref !== null || current !== null && current.ref !== ref) { 54467 // Schedule a Ref effect 54468 workInProgress.effectTag |= Ref; 54469 } 54470} 54471 54472function updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime) { 54473 { 54474 if (workInProgress.type !== workInProgress.elementType) { 54475 // Lazy component props can't be validated in createElement 54476 // because they're only guaranteed to be resolved here. 54477 var innerPropTypes = Component.propTypes; 54478 54479 if (innerPropTypes) { 54480 checkPropTypes(innerPropTypes, nextProps, // Resolved props 54481 'prop', getComponentName(Component), getCurrentFiberStackInDev); 54482 } 54483 } 54484 } 54485 54486 var context; 54487 54488 { 54489 var unmaskedContext = getUnmaskedContext(workInProgress, Component, true); 54490 context = getMaskedContext(workInProgress, unmaskedContext); 54491 } 54492 54493 var nextChildren; 54494 prepareToReadContext(workInProgress, renderExpirationTime); 54495 54496 { 54497 ReactCurrentOwner$1.current = workInProgress; 54498 setIsRendering(true); 54499 nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderExpirationTime); 54500 54501 if ( workInProgress.mode & StrictMode) { 54502 // Only double-render components with Hooks 54503 if (workInProgress.memoizedState !== null) { 54504 nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderExpirationTime); 54505 } 54506 } 54507 54508 setIsRendering(false); 54509 } 54510 54511 if (current !== null && !didReceiveUpdate) { 54512 bailoutHooks(current, workInProgress, renderExpirationTime); 54513 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 54514 } // React DevTools reads this flag. 54515 54516 54517 workInProgress.effectTag |= PerformedWork; 54518 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 54519 return workInProgress.child; 54520} 54521 54522function updateClassComponent(current, workInProgress, Component, nextProps, renderExpirationTime) { 54523 { 54524 if (workInProgress.type !== workInProgress.elementType) { 54525 // Lazy component props can't be validated in createElement 54526 // because they're only guaranteed to be resolved here. 54527 var innerPropTypes = Component.propTypes; 54528 54529 if (innerPropTypes) { 54530 checkPropTypes(innerPropTypes, nextProps, // Resolved props 54531 'prop', getComponentName(Component), getCurrentFiberStackInDev); 54532 } 54533 } 54534 } // Push context providers early to prevent context stack mismatches. 54535 // During mounting we don't know the child context yet as the instance doesn't exist. 54536 // We will invalidate the child context in finishClassComponent() right after rendering. 54537 54538 54539 var hasContext; 54540 54541 if (isContextProvider(Component)) { 54542 hasContext = true; 54543 pushContextProvider(workInProgress); 54544 } else { 54545 hasContext = false; 54546 } 54547 54548 prepareToReadContext(workInProgress, renderExpirationTime); 54549 var instance = workInProgress.stateNode; 54550 var shouldUpdate; 54551 54552 if (instance === null) { 54553 if (current !== null) { 54554 // A class component without an instance only mounts if it suspended 54555 // inside a non-concurrent tree, in an inconsistent state. We want to 54556 // treat it like a new mount, even though an empty version of it already 54557 // committed. Disconnect the alternate pointers. 54558 current.alternate = null; 54559 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 54560 54561 workInProgress.effectTag |= Placement; 54562 } // In the initial pass we might need to construct the instance. 54563 54564 54565 constructClassInstance(workInProgress, Component, nextProps); 54566 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime); 54567 shouldUpdate = true; 54568 } else if (current === null) { 54569 // In a resume, we'll already have an instance we can reuse. 54570 shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime); 54571 } else { 54572 shouldUpdate = updateClassInstance(current, workInProgress, Component, nextProps, renderExpirationTime); 54573 } 54574 54575 var nextUnitOfWork = finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime); 54576 54577 { 54578 var inst = workInProgress.stateNode; 54579 54580 if (inst.props !== nextProps) { 54581 if (!didWarnAboutReassigningProps) { 54582 error('It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentName(workInProgress.type) || 'a component'); 54583 } 54584 54585 didWarnAboutReassigningProps = true; 54586 } 54587 } 54588 54589 return nextUnitOfWork; 54590} 54591 54592function finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) { 54593 // Refs should update even if shouldComponentUpdate returns false 54594 markRef(current, workInProgress); 54595 var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect; 54596 54597 if (!shouldUpdate && !didCaptureError) { 54598 // Context providers should defer to sCU for rendering 54599 if (hasContext) { 54600 invalidateContextProvider(workInProgress, Component, false); 54601 } 54602 54603 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 54604 } 54605 54606 var instance = workInProgress.stateNode; // Rerender 54607 54608 ReactCurrentOwner$1.current = workInProgress; 54609 var nextChildren; 54610 54611 if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') { 54612 // If we captured an error, but getDerivedStateFromError is not defined, 54613 // unmount all the children. componentDidCatch will schedule an update to 54614 // re-render a fallback. This is temporary until we migrate everyone to 54615 // the new API. 54616 // TODO: Warn in a future release. 54617 nextChildren = null; 54618 54619 { 54620 stopProfilerTimerIfRunning(); 54621 } 54622 } else { 54623 { 54624 setIsRendering(true); 54625 nextChildren = instance.render(); 54626 54627 if ( workInProgress.mode & StrictMode) { 54628 instance.render(); 54629 } 54630 54631 setIsRendering(false); 54632 } 54633 } // React DevTools reads this flag. 54634 54635 54636 workInProgress.effectTag |= PerformedWork; 54637 54638 if (current !== null && didCaptureError) { 54639 // If we're recovering from an error, reconcile without reusing any of 54640 // the existing children. Conceptually, the normal children and the children 54641 // that are shown on error are two different sets, so we shouldn't reuse 54642 // normal children even if their identities match. 54643 forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime); 54644 } else { 54645 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 54646 } // Memoize state using the values we just used to render. 54647 // TODO: Restructure so we never read values from the instance. 54648 54649 54650 workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it. 54651 54652 if (hasContext) { 54653 invalidateContextProvider(workInProgress, Component, true); 54654 } 54655 54656 return workInProgress.child; 54657} 54658 54659function pushHostRootContext(workInProgress) { 54660 var root = workInProgress.stateNode; 54661 54662 if (root.pendingContext) { 54663 pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context); 54664 } else if (root.context) { 54665 // Should always be set 54666 pushTopLevelContextObject(workInProgress, root.context, false); 54667 } 54668 54669 pushHostContainer(workInProgress, root.containerInfo); 54670} 54671 54672function updateHostRoot(current, workInProgress, renderExpirationTime) { 54673 pushHostRootContext(workInProgress); 54674 var updateQueue = workInProgress.updateQueue; 54675 54676 if (!(current !== null && updateQueue !== null)) { 54677 { 54678 throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); 54679 } 54680 } 54681 54682 var nextProps = workInProgress.pendingProps; 54683 var prevState = workInProgress.memoizedState; 54684 var prevChildren = prevState !== null ? prevState.element : null; 54685 cloneUpdateQueue(current, workInProgress); 54686 processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime); 54687 var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property 54688 // being called "element". 54689 54690 var nextChildren = nextState.element; 54691 54692 if (nextChildren === prevChildren) { 54693 // If the state is the same as before, that's a bailout because we had 54694 // no work that expires at this time. 54695 resetHydrationState(); 54696 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 54697 } 54698 54699 var root = workInProgress.stateNode; 54700 54701 if (root.hydrate && enterHydrationState(workInProgress)) { 54702 // If we don't have any current children this might be the first pass. 54703 // We always try to hydrate. If this isn't a hydration pass there won't 54704 // be any children to hydrate which is effectively the same thing as 54705 // not hydrating. 54706 var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 54707 workInProgress.child = child; 54708 var node = child; 54709 54710 while (node) { 54711 // Mark each child as hydrating. This is a fast path to know whether this 54712 // tree is part of a hydrating tree. This is used to determine if a child 54713 // node has fully mounted yet, and for scheduling event replaying. 54714 // Conceptually this is similar to Placement in that a new subtree is 54715 // inserted into the React tree here. It just happens to not need DOM 54716 // mutations because it already exists. 54717 node.effectTag = node.effectTag & ~Placement | Hydrating; 54718 node = node.sibling; 54719 } 54720 } else { 54721 // Otherwise reset hydration state in case we aborted and resumed another 54722 // root. 54723 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 54724 resetHydrationState(); 54725 } 54726 54727 return workInProgress.child; 54728} 54729 54730function updateHostComponent(current, workInProgress, renderExpirationTime) { 54731 pushHostContext(workInProgress); 54732 54733 if (current === null) { 54734 tryToClaimNextHydratableInstance(workInProgress); 54735 } 54736 54737 var type = workInProgress.type; 54738 var nextProps = workInProgress.pendingProps; 54739 var prevProps = current !== null ? current.memoizedProps : null; 54740 var nextChildren = nextProps.children; 54741 var isDirectTextChild = shouldSetTextContent(type, nextProps); 54742 54743 if (isDirectTextChild) { 54744 // We special case a direct text child of a host node. This is a common 54745 // case. We won't handle it as a reified child. We will instead handle 54746 // this in the host environment that also has access to this prop. That 54747 // avoids allocating another HostText fiber and traversing it. 54748 nextChildren = null; 54749 } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) { 54750 // If we're switching from a direct text child to a normal child, or to 54751 // empty, we need to schedule the text content to be reset. 54752 workInProgress.effectTag |= ContentReset; 54753 } 54754 54755 markRef(current, workInProgress); // Check the host config to see if the children are offscreen/hidden. 54756 54757 if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(type, nextProps)) { 54758 { 54759 markSpawnedWork(Never); 54760 } // Schedule this fiber to re-render at offscreen priority. Then bailout. 54761 54762 54763 workInProgress.expirationTime = workInProgress.childExpirationTime = Never; 54764 return null; 54765 } 54766 54767 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 54768 return workInProgress.child; 54769} 54770 54771function updateHostText(current, workInProgress) { 54772 if (current === null) { 54773 tryToClaimNextHydratableInstance(workInProgress); 54774 } // Nothing to do here. This is terminal. We'll do the completion step 54775 // immediately after. 54776 54777 54778 return null; 54779} 54780 54781function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) { 54782 if (_current !== null) { 54783 // A lazy component only mounts if it suspended inside a non- 54784 // concurrent tree, in an inconsistent state. We want to treat it like 54785 // a new mount, even though an empty version of it already committed. 54786 // Disconnect the alternate pointers. 54787 _current.alternate = null; 54788 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 54789 54790 workInProgress.effectTag |= Placement; 54791 } 54792 54793 var props = workInProgress.pendingProps; // We can't start a User Timing measurement with correct label yet. 54794 // Cancel and resume right after we know the tag. 54795 54796 cancelWorkTimer(workInProgress); 54797 var Component = readLazyComponentType(elementType); // Store the unwrapped component in the type. 54798 54799 workInProgress.type = Component; 54800 var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component); 54801 startWorkTimer(workInProgress); 54802 var resolvedProps = resolveDefaultProps(Component, props); 54803 var child; 54804 54805 switch (resolvedTag) { 54806 case FunctionComponent: 54807 { 54808 { 54809 validateFunctionComponentInDev(workInProgress, Component); 54810 workInProgress.type = Component = resolveFunctionForHotReloading(Component); 54811 } 54812 54813 child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime); 54814 return child; 54815 } 54816 54817 case ClassComponent: 54818 { 54819 { 54820 workInProgress.type = Component = resolveClassForHotReloading(Component); 54821 } 54822 54823 child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime); 54824 return child; 54825 } 54826 54827 case ForwardRef: 54828 { 54829 { 54830 workInProgress.type = Component = resolveForwardRefForHotReloading(Component); 54831 } 54832 54833 child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime); 54834 return child; 54835 } 54836 54837 case MemoComponent: 54838 { 54839 { 54840 if (workInProgress.type !== workInProgress.elementType) { 54841 var outerPropTypes = Component.propTypes; 54842 54843 if (outerPropTypes) { 54844 checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only 54845 'prop', getComponentName(Component), getCurrentFiberStackInDev); 54846 } 54847 } 54848 } 54849 54850 child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too 54851 updateExpirationTime, renderExpirationTime); 54852 return child; 54853 } 54854 } 54855 54856 var hint = ''; 54857 54858 { 54859 if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) { 54860 hint = ' Did you wrap a component in React.lazy() more than once?'; 54861 } 54862 } // This message intentionally doesn't mention ForwardRef or MemoComponent 54863 // because the fact that it's a separate type of work is an 54864 // implementation detail. 54865 54866 54867 { 54868 { 54869 throw Error( "Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint ); 54870 } 54871 } 54872} 54873 54874function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) { 54875 if (_current !== null) { 54876 // An incomplete component only mounts if it suspended inside a non- 54877 // concurrent tree, in an inconsistent state. We want to treat it like 54878 // a new mount, even though an empty version of it already committed. 54879 // Disconnect the alternate pointers. 54880 _current.alternate = null; 54881 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 54882 54883 workInProgress.effectTag |= Placement; 54884 } // Promote the fiber to a class and try rendering again. 54885 54886 54887 workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent` 54888 // Push context providers early to prevent context stack mismatches. 54889 // During mounting we don't know the child context yet as the instance doesn't exist. 54890 // We will invalidate the child context in finishClassComponent() right after rendering. 54891 54892 var hasContext; 54893 54894 if (isContextProvider(Component)) { 54895 hasContext = true; 54896 pushContextProvider(workInProgress); 54897 } else { 54898 hasContext = false; 54899 } 54900 54901 prepareToReadContext(workInProgress, renderExpirationTime); 54902 constructClassInstance(workInProgress, Component, nextProps); 54903 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime); 54904 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime); 54905} 54906 54907function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) { 54908 if (_current !== null) { 54909 // An indeterminate component only mounts if it suspended inside a non- 54910 // concurrent tree, in an inconsistent state. We want to treat it like 54911 // a new mount, even though an empty version of it already committed. 54912 // Disconnect the alternate pointers. 54913 _current.alternate = null; 54914 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 54915 54916 workInProgress.effectTag |= Placement; 54917 } 54918 54919 var props = workInProgress.pendingProps; 54920 var context; 54921 54922 { 54923 var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); 54924 context = getMaskedContext(workInProgress, unmaskedContext); 54925 } 54926 54927 prepareToReadContext(workInProgress, renderExpirationTime); 54928 var value; 54929 54930 { 54931 if (Component.prototype && typeof Component.prototype.render === 'function') { 54932 var componentName = getComponentName(Component) || 'Unknown'; 54933 54934 if (!didWarnAboutBadClass[componentName]) { 54935 error("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); 54936 54937 didWarnAboutBadClass[componentName] = true; 54938 } 54939 } 54940 54941 if (workInProgress.mode & StrictMode) { 54942 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null); 54943 } 54944 54945 setIsRendering(true); 54946 ReactCurrentOwner$1.current = workInProgress; 54947 value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime); 54948 setIsRendering(false); 54949 } // React DevTools reads this flag. 54950 54951 54952 workInProgress.effectTag |= PerformedWork; 54953 54954 if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) { 54955 { 54956 var _componentName = getComponentName(Component) || 'Unknown'; 54957 54958 if (!didWarnAboutModulePatternComponent[_componentName]) { 54959 error('The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName, _componentName, _componentName); 54960 54961 didWarnAboutModulePatternComponent[_componentName] = true; 54962 } 54963 } // Proceed under the assumption that this is a class instance 54964 54965 54966 workInProgress.tag = ClassComponent; // Throw out any hooks that were used. 54967 54968 workInProgress.memoizedState = null; 54969 workInProgress.updateQueue = null; // Push context providers early to prevent context stack mismatches. 54970 // During mounting we don't know the child context yet as the instance doesn't exist. 54971 // We will invalidate the child context in finishClassComponent() right after rendering. 54972 54973 var hasContext = false; 54974 54975 if (isContextProvider(Component)) { 54976 hasContext = true; 54977 pushContextProvider(workInProgress); 54978 } else { 54979 hasContext = false; 54980 } 54981 54982 workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; 54983 initializeUpdateQueue(workInProgress); 54984 var getDerivedStateFromProps = Component.getDerivedStateFromProps; 54985 54986 if (typeof getDerivedStateFromProps === 'function') { 54987 applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props); 54988 } 54989 54990 adoptClassInstance(workInProgress, value); 54991 mountClassInstance(workInProgress, Component, props, renderExpirationTime); 54992 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime); 54993 } else { 54994 // Proceed under the assumption that this is a function component 54995 workInProgress.tag = FunctionComponent; 54996 54997 { 54998 54999 if ( workInProgress.mode & StrictMode) { 55000 // Only double-render components with Hooks 55001 if (workInProgress.memoizedState !== null) { 55002 value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime); 55003 } 55004 } 55005 } 55006 55007 reconcileChildren(null, workInProgress, value, renderExpirationTime); 55008 55009 { 55010 validateFunctionComponentInDev(workInProgress, Component); 55011 } 55012 55013 return workInProgress.child; 55014 } 55015} 55016 55017function validateFunctionComponentInDev(workInProgress, Component) { 55018 { 55019 if (Component) { 55020 if (Component.childContextTypes) { 55021 error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component'); 55022 } 55023 } 55024 55025 if (workInProgress.ref !== null) { 55026 var info = ''; 55027 var ownerName = getCurrentFiberOwnerNameInDevOrNull(); 55028 55029 if (ownerName) { 55030 info += '\n\nCheck the render method of `' + ownerName + '`.'; 55031 } 55032 55033 var warningKey = ownerName || workInProgress._debugID || ''; 55034 var debugSource = workInProgress._debugSource; 55035 55036 if (debugSource) { 55037 warningKey = debugSource.fileName + ':' + debugSource.lineNumber; 55038 } 55039 55040 if (!didWarnAboutFunctionRefs[warningKey]) { 55041 didWarnAboutFunctionRefs[warningKey] = true; 55042 55043 error('Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info); 55044 } 55045 } 55046 55047 if (typeof Component.getDerivedStateFromProps === 'function') { 55048 var _componentName2 = getComponentName(Component) || 'Unknown'; 55049 55050 if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { 55051 error('%s: Function components do not support getDerivedStateFromProps.', _componentName2); 55052 55053 didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; 55054 } 55055 } 55056 55057 if (typeof Component.contextType === 'object' && Component.contextType !== null) { 55058 var _componentName3 = getComponentName(Component) || 'Unknown'; 55059 55060 if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { 55061 error('%s: Function components do not support contextType.', _componentName3); 55062 55063 didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; 55064 } 55065 } 55066 } 55067} 55068 55069var SUSPENDED_MARKER = { 55070 dehydrated: null, 55071 retryTime: NoWork 55072}; 55073 55074function shouldRemainOnFallback(suspenseContext, current, workInProgress) { 55075 // If the context is telling us that we should show a fallback, and we're not 55076 // already showing content, then we should show the fallback instead. 55077 return hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && (current === null || current.memoizedState !== null); 55078} 55079 55080function updateSuspenseComponent(current, workInProgress, renderExpirationTime) { 55081 var mode = workInProgress.mode; 55082 var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend. 55083 55084 { 55085 if (shouldSuspend(workInProgress)) { 55086 workInProgress.effectTag |= DidCapture; 55087 } 55088 } 55089 55090 var suspenseContext = suspenseStackCursor.current; 55091 var nextDidTimeout = false; 55092 var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect; 55093 55094 if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) { 55095 // Something in this boundary's subtree already suspended. Switch to 55096 // rendering the fallback children. 55097 nextDidTimeout = true; 55098 workInProgress.effectTag &= ~DidCapture; 55099 } else { 55100 // Attempting the main content 55101 if (current === null || current.memoizedState !== null) { 55102 // This is a new mount or this boundary is already showing a fallback state. 55103 // Mark this subtree context as having at least one invisible parent that could 55104 // handle the fallback state. 55105 // Boundaries without fallbacks or should be avoided are not considered since 55106 // they cannot handle preferred fallback states. 55107 if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) { 55108 suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext); 55109 } 55110 } 55111 } 55112 55113 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); 55114 pushSuspenseContext(workInProgress, suspenseContext); // This next part is a bit confusing. If the children timeout, we switch to 55115 // showing the fallback children in place of the "primary" children. 55116 // However, we don't want to delete the primary children because then their 55117 // state will be lost (both the React state and the host state, e.g. 55118 // uncontrolled form inputs). Instead we keep them mounted and hide them. 55119 // Both the fallback children AND the primary children are rendered at the 55120 // same time. Once the primary children are un-suspended, we can delete 55121 // the fallback children — don't need to preserve their state. 55122 // 55123 // The two sets of children are siblings in the host environment, but 55124 // semantically, for purposes of reconciliation, they are two separate sets. 55125 // So we store them using two fragment fibers. 55126 // 55127 // However, we want to avoid allocating extra fibers for every placeholder. 55128 // They're only necessary when the children time out, because that's the 55129 // only time when both sets are mounted. 55130 // 55131 // So, the extra fragment fibers are only used if the children time out. 55132 // Otherwise, we render the primary children directly. This requires some 55133 // custom reconciliation logic to preserve the state of the primary 55134 // children. It's essentially a very basic form of re-parenting. 55135 55136 if (current === null) { 55137 // If we're currently hydrating, try to hydrate this boundary. 55138 // But only if this has a fallback. 55139 if (nextProps.fallback !== undefined) { 55140 tryToClaimNextHydratableInstance(workInProgress); // This could've been a dehydrated suspense component. 55141 } // This is the initial mount. This branch is pretty simple because there's 55142 // no previous state that needs to be preserved. 55143 55144 55145 if (nextDidTimeout) { 55146 // Mount separate fragments for primary and fallback children. 55147 var nextFallbackChildren = nextProps.fallback; 55148 var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null); 55149 primaryChildFragment.return = workInProgress; 55150 55151 if ((workInProgress.mode & BlockingMode) === NoMode) { 55152 // Outside of blocking mode, we commit the effects from the 55153 // partially completed, timed-out tree, too. 55154 var progressedState = workInProgress.memoizedState; 55155 var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child; 55156 primaryChildFragment.child = progressedPrimaryChild; 55157 var progressedChild = progressedPrimaryChild; 55158 55159 while (progressedChild !== null) { 55160 progressedChild.return = primaryChildFragment; 55161 progressedChild = progressedChild.sibling; 55162 } 55163 } 55164 55165 var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null); 55166 fallbackChildFragment.return = workInProgress; 55167 primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the 55168 // fallback children. 55169 55170 workInProgress.memoizedState = SUSPENDED_MARKER; 55171 workInProgress.child = primaryChildFragment; 55172 return fallbackChildFragment; 55173 } else { 55174 // Mount the primary children without an intermediate fragment fiber. 55175 var nextPrimaryChildren = nextProps.children; 55176 workInProgress.memoizedState = null; 55177 return workInProgress.child = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime); 55178 } 55179 } else { 55180 // This is an update. This branch is more complicated because we need to 55181 // ensure the state of the primary children is preserved. 55182 var prevState = current.memoizedState; 55183 55184 if (prevState !== null) { 55185 // wrapped in a fragment fiber. 55186 55187 55188 var currentPrimaryChildFragment = current.child; 55189 var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; 55190 55191 if (nextDidTimeout) { 55192 // Still timed out. Reuse the current primary children by cloning 55193 // its fragment. We're going to skip over these entirely. 55194 var _nextFallbackChildren2 = nextProps.fallback; 55195 55196 var _primaryChildFragment2 = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps); 55197 55198 _primaryChildFragment2.return = workInProgress; 55199 55200 if ((workInProgress.mode & BlockingMode) === NoMode) { 55201 // Outside of blocking mode, we commit the effects from the 55202 // partially completed, timed-out tree, too. 55203 var _progressedState = workInProgress.memoizedState; 55204 55205 var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child; 55206 55207 if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) { 55208 _primaryChildFragment2.child = _progressedPrimaryChild; 55209 var _progressedChild2 = _progressedPrimaryChild; 55210 55211 while (_progressedChild2 !== null) { 55212 _progressedChild2.return = _primaryChildFragment2; 55213 _progressedChild2 = _progressedChild2.sibling; 55214 } 55215 } 55216 } // Because primaryChildFragment is a new fiber that we're inserting as the 55217 // parent of a new tree, we need to set its treeBaseDuration. 55218 55219 55220 if ( workInProgress.mode & ProfileMode) { 55221 // treeBaseDuration is the sum of all the child tree base durations. 55222 var _treeBaseDuration = 0; 55223 var _hiddenChild = _primaryChildFragment2.child; 55224 55225 while (_hiddenChild !== null) { 55226 _treeBaseDuration += _hiddenChild.treeBaseDuration; 55227 _hiddenChild = _hiddenChild.sibling; 55228 } 55229 55230 _primaryChildFragment2.treeBaseDuration = _treeBaseDuration; 55231 } // Clone the fallback child fragment, too. These we'll continue 55232 // working on. 55233 55234 55235 var _fallbackChildFragment2 = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren2); 55236 55237 _fallbackChildFragment2.return = workInProgress; 55238 _primaryChildFragment2.sibling = _fallbackChildFragment2; 55239 _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the 55240 // fallback children. 55241 55242 workInProgress.memoizedState = SUSPENDED_MARKER; 55243 workInProgress.child = _primaryChildFragment2; 55244 return _fallbackChildFragment2; 55245 } else { 55246 // No longer suspended. Switch back to showing the primary children, 55247 // and remove the intermediate fragment fiber. 55248 var _nextPrimaryChildren = nextProps.children; 55249 var currentPrimaryChild = currentPrimaryChildFragment.child; 55250 var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime); // If this render doesn't suspend, we need to delete the fallback 55251 // children. Wait until the complete phase, after we've confirmed the 55252 // fallback is no longer needed. 55253 // TODO: Would it be better to store the fallback fragment on 55254 // the stateNode? 55255 // Continue rendering the children, like we normally do. 55256 55257 workInProgress.memoizedState = null; 55258 return workInProgress.child = primaryChild; 55259 } 55260 } else { 55261 // The current tree has not already timed out. That means the primary 55262 // children are not wrapped in a fragment fiber. 55263 var _currentPrimaryChild = current.child; 55264 55265 if (nextDidTimeout) { 55266 // Timed out. Wrap the children in a fragment fiber to keep them 55267 // separate from the fallback children. 55268 var _nextFallbackChildren3 = nextProps.fallback; 55269 55270 var _primaryChildFragment3 = createFiberFromFragment( // It shouldn't matter what the pending props are because we aren't 55271 // going to render this fragment. 55272 null, mode, NoWork, null); 55273 55274 _primaryChildFragment3.return = workInProgress; 55275 _primaryChildFragment3.child = _currentPrimaryChild; 55276 55277 if (_currentPrimaryChild !== null) { 55278 _currentPrimaryChild.return = _primaryChildFragment3; 55279 } // Even though we're creating a new fiber, there are no new children, 55280 // because we're reusing an already mounted tree. So we don't need to 55281 // schedule a placement. 55282 // primaryChildFragment.effectTag |= Placement; 55283 55284 55285 if ((workInProgress.mode & BlockingMode) === NoMode) { 55286 // Outside of blocking mode, we commit the effects from the 55287 // partially completed, timed-out tree, too. 55288 var _progressedState2 = workInProgress.memoizedState; 55289 55290 var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child; 55291 55292 _primaryChildFragment3.child = _progressedPrimaryChild2; 55293 var _progressedChild3 = _progressedPrimaryChild2; 55294 55295 while (_progressedChild3 !== null) { 55296 _progressedChild3.return = _primaryChildFragment3; 55297 _progressedChild3 = _progressedChild3.sibling; 55298 } 55299 } // Because primaryChildFragment is a new fiber that we're inserting as the 55300 // parent of a new tree, we need to set its treeBaseDuration. 55301 55302 55303 if ( workInProgress.mode & ProfileMode) { 55304 // treeBaseDuration is the sum of all the child tree base durations. 55305 var _treeBaseDuration2 = 0; 55306 var _hiddenChild2 = _primaryChildFragment3.child; 55307 55308 while (_hiddenChild2 !== null) { 55309 _treeBaseDuration2 += _hiddenChild2.treeBaseDuration; 55310 _hiddenChild2 = _hiddenChild2.sibling; 55311 } 55312 55313 _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2; 55314 } // Create a fragment from the fallback children, too. 55315 55316 55317 var _fallbackChildFragment3 = createFiberFromFragment(_nextFallbackChildren3, mode, renderExpirationTime, null); 55318 55319 _fallbackChildFragment3.return = workInProgress; 55320 _primaryChildFragment3.sibling = _fallbackChildFragment3; 55321 _fallbackChildFragment3.effectTag |= Placement; 55322 _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the 55323 // fallback children. 55324 55325 workInProgress.memoizedState = SUSPENDED_MARKER; 55326 workInProgress.child = _primaryChildFragment3; 55327 return _fallbackChildFragment3; 55328 } else { 55329 // Still haven't timed out. Continue rendering the children, like we 55330 // normally do. 55331 workInProgress.memoizedState = null; 55332 var _nextPrimaryChildren2 = nextProps.children; 55333 return workInProgress.child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime); 55334 } 55335 } 55336 } 55337} 55338 55339function scheduleWorkOnFiber(fiber, renderExpirationTime) { 55340 if (fiber.expirationTime < renderExpirationTime) { 55341 fiber.expirationTime = renderExpirationTime; 55342 } 55343 55344 var alternate = fiber.alternate; 55345 55346 if (alternate !== null && alternate.expirationTime < renderExpirationTime) { 55347 alternate.expirationTime = renderExpirationTime; 55348 } 55349 55350 scheduleWorkOnParentPath(fiber.return, renderExpirationTime); 55351} 55352 55353function propagateSuspenseContextChange(workInProgress, firstChild, renderExpirationTime) { 55354 // Mark any Suspense boundaries with fallbacks as having work to do. 55355 // If they were previously forced into fallbacks, they may now be able 55356 // to unblock. 55357 var node = firstChild; 55358 55359 while (node !== null) { 55360 if (node.tag === SuspenseComponent) { 55361 var state = node.memoizedState; 55362 55363 if (state !== null) { 55364 scheduleWorkOnFiber(node, renderExpirationTime); 55365 } 55366 } else if (node.tag === SuspenseListComponent) { 55367 // If the tail is hidden there might not be an Suspense boundaries 55368 // to schedule work on. In this case we have to schedule it on the 55369 // list itself. 55370 // We don't have to traverse to the children of the list since 55371 // the list will propagate the change when it rerenders. 55372 scheduleWorkOnFiber(node, renderExpirationTime); 55373 } else if (node.child !== null) { 55374 node.child.return = node; 55375 node = node.child; 55376 continue; 55377 } 55378 55379 if (node === workInProgress) { 55380 return; 55381 } 55382 55383 while (node.sibling === null) { 55384 if (node.return === null || node.return === workInProgress) { 55385 return; 55386 } 55387 55388 node = node.return; 55389 } 55390 55391 node.sibling.return = node.return; 55392 node = node.sibling; 55393 } 55394} 55395 55396function findLastContentRow(firstChild) { 55397 // This is going to find the last row among these children that is already 55398 // showing content on the screen, as opposed to being in fallback state or 55399 // new. If a row has multiple Suspense boundaries, any of them being in the 55400 // fallback state, counts as the whole row being in a fallback state. 55401 // Note that the "rows" will be workInProgress, but any nested children 55402 // will still be current since we haven't rendered them yet. The mounted 55403 // order may not be the same as the new order. We use the new order. 55404 var row = firstChild; 55405 var lastContentRow = null; 55406 55407 while (row !== null) { 55408 var currentRow = row.alternate; // New rows can't be content rows. 55409 55410 if (currentRow !== null && findFirstSuspended(currentRow) === null) { 55411 lastContentRow = row; 55412 } 55413 55414 row = row.sibling; 55415 } 55416 55417 return lastContentRow; 55418} 55419 55420function validateRevealOrder(revealOrder) { 55421 { 55422 if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) { 55423 didWarnAboutRevealOrder[revealOrder] = true; 55424 55425 if (typeof revealOrder === 'string') { 55426 switch (revealOrder.toLowerCase()) { 55427 case 'together': 55428 case 'forwards': 55429 case 'backwards': 55430 { 55431 error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase()); 55432 55433 break; 55434 } 55435 55436 case 'forward': 55437 case 'backward': 55438 { 55439 error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase()); 55440 55441 break; 55442 } 55443 55444 default: 55445 error('"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder); 55446 55447 break; 55448 } 55449 } else { 55450 error('%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder); 55451 } 55452 } 55453 } 55454} 55455 55456function validateTailOptions(tailMode, revealOrder) { 55457 { 55458 if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) { 55459 if (tailMode !== 'collapsed' && tailMode !== 'hidden') { 55460 didWarnAboutTailOptions[tailMode] = true; 55461 55462 error('"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode); 55463 } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') { 55464 didWarnAboutTailOptions[tailMode] = true; 55465 55466 error('<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode); 55467 } 55468 } 55469 } 55470} 55471 55472function validateSuspenseListNestedChild(childSlot, index) { 55473 { 55474 var isArray = Array.isArray(childSlot); 55475 var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function'; 55476 55477 if (isArray || isIterable) { 55478 var type = isArray ? 'array' : 'iterable'; 55479 55480 error('A nested %s was passed to row #%s in <SuspenseList />. Wrap it in ' + 'an additional SuspenseList to configure its revealOrder: ' + '<SuspenseList revealOrder=...> ... ' + '<SuspenseList revealOrder=...>{%s}</SuspenseList> ... ' + '</SuspenseList>', type, index, type); 55481 55482 return false; 55483 } 55484 } 55485 55486 return true; 55487} 55488 55489function validateSuspenseListChildren(children, revealOrder) { 55490 { 55491 if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) { 55492 if (Array.isArray(children)) { 55493 for (var i = 0; i < children.length; i++) { 55494 if (!validateSuspenseListNestedChild(children[i], i)) { 55495 return; 55496 } 55497 } 55498 } else { 55499 var iteratorFn = getIteratorFn(children); 55500 55501 if (typeof iteratorFn === 'function') { 55502 var childrenIterator = iteratorFn.call(children); 55503 55504 if (childrenIterator) { 55505 var step = childrenIterator.next(); 55506 var _i = 0; 55507 55508 for (; !step.done; step = childrenIterator.next()) { 55509 if (!validateSuspenseListNestedChild(step.value, _i)) { 55510 return; 55511 } 55512 55513 _i++; 55514 } 55515 } 55516 } else { 55517 error('A single row was passed to a <SuspenseList revealOrder="%s" />. ' + 'This is not useful since it needs multiple rows. ' + 'Did you mean to pass multiple children or an array?', revealOrder); 55518 } 55519 } 55520 } 55521 } 55522} 55523 55524function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode, lastEffectBeforeRendering) { 55525 var renderState = workInProgress.memoizedState; 55526 55527 if (renderState === null) { 55528 workInProgress.memoizedState = { 55529 isBackwards: isBackwards, 55530 rendering: null, 55531 renderingStartTime: 0, 55532 last: lastContentRow, 55533 tail: tail, 55534 tailExpiration: 0, 55535 tailMode: tailMode, 55536 lastEffect: lastEffectBeforeRendering 55537 }; 55538 } else { 55539 // We can reuse the existing object from previous renders. 55540 renderState.isBackwards = isBackwards; 55541 renderState.rendering = null; 55542 renderState.renderingStartTime = 0; 55543 renderState.last = lastContentRow; 55544 renderState.tail = tail; 55545 renderState.tailExpiration = 0; 55546 renderState.tailMode = tailMode; 55547 renderState.lastEffect = lastEffectBeforeRendering; 55548 } 55549} // This can end up rendering this component multiple passes. 55550// The first pass splits the children fibers into two sets. A head and tail. 55551// We first render the head. If anything is in fallback state, we do another 55552// pass through beginWork to rerender all children (including the tail) with 55553// the force suspend context. If the first render didn't have anything in 55554// in fallback state. Then we render each row in the tail one-by-one. 55555// That happens in the completeWork phase without going back to beginWork. 55556 55557 55558function updateSuspenseListComponent(current, workInProgress, renderExpirationTime) { 55559 var nextProps = workInProgress.pendingProps; 55560 var revealOrder = nextProps.revealOrder; 55561 var tailMode = nextProps.tail; 55562 var newChildren = nextProps.children; 55563 validateRevealOrder(revealOrder); 55564 validateTailOptions(tailMode, revealOrder); 55565 validateSuspenseListChildren(newChildren, revealOrder); 55566 reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); 55567 var suspenseContext = suspenseStackCursor.current; 55568 var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback); 55569 55570 if (shouldForceFallback) { 55571 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback); 55572 workInProgress.effectTag |= DidCapture; 55573 } else { 55574 var didSuspendBefore = current !== null && (current.effectTag & DidCapture) !== NoEffect; 55575 55576 if (didSuspendBefore) { 55577 // If we previously forced a fallback, we need to schedule work 55578 // on any nested boundaries to let them know to try to render 55579 // again. This is the same as context updating. 55580 propagateSuspenseContextChange(workInProgress, workInProgress.child, renderExpirationTime); 55581 } 55582 55583 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); 55584 } 55585 55586 pushSuspenseContext(workInProgress, suspenseContext); 55587 55588 if ((workInProgress.mode & BlockingMode) === NoMode) { 55589 // Outside of blocking mode, SuspenseList doesn't work so we just 55590 // use make it a noop by treating it as the default revealOrder. 55591 workInProgress.memoizedState = null; 55592 } else { 55593 switch (revealOrder) { 55594 case 'forwards': 55595 { 55596 var lastContentRow = findLastContentRow(workInProgress.child); 55597 var tail; 55598 55599 if (lastContentRow === null) { 55600 // The whole list is part of the tail. 55601 // TODO: We could fast path by just rendering the tail now. 55602 tail = workInProgress.child; 55603 workInProgress.child = null; 55604 } else { 55605 // Disconnect the tail rows after the content row. 55606 // We're going to render them separately later. 55607 tail = lastContentRow.sibling; 55608 lastContentRow.sibling = null; 55609 } 55610 55611 initSuspenseListRenderState(workInProgress, false, // isBackwards 55612 tail, lastContentRow, tailMode, workInProgress.lastEffect); 55613 break; 55614 } 55615 55616 case 'backwards': 55617 { 55618 // We're going to find the first row that has existing content. 55619 // At the same time we're going to reverse the list of everything 55620 // we pass in the meantime. That's going to be our tail in reverse 55621 // order. 55622 var _tail = null; 55623 var row = workInProgress.child; 55624 workInProgress.child = null; 55625 55626 while (row !== null) { 55627 var currentRow = row.alternate; // New rows can't be content rows. 55628 55629 if (currentRow !== null && findFirstSuspended(currentRow) === null) { 55630 // This is the beginning of the main content. 55631 workInProgress.child = row; 55632 break; 55633 } 55634 55635 var nextRow = row.sibling; 55636 row.sibling = _tail; 55637 _tail = row; 55638 row = nextRow; 55639 } // TODO: If workInProgress.child is null, we can continue on the tail immediately. 55640 55641 55642 initSuspenseListRenderState(workInProgress, true, // isBackwards 55643 _tail, null, // last 55644 tailMode, workInProgress.lastEffect); 55645 break; 55646 } 55647 55648 case 'together': 55649 { 55650 initSuspenseListRenderState(workInProgress, false, // isBackwards 55651 null, // tail 55652 null, // last 55653 undefined, workInProgress.lastEffect); 55654 break; 55655 } 55656 55657 default: 55658 { 55659 // The default reveal order is the same as not having 55660 // a boundary. 55661 workInProgress.memoizedState = null; 55662 } 55663 } 55664 } 55665 55666 return workInProgress.child; 55667} 55668 55669function updatePortalComponent(current, workInProgress, renderExpirationTime) { 55670 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); 55671 var nextChildren = workInProgress.pendingProps; 55672 55673 if (current === null) { 55674 // Portals are special because we don't append the children during mount 55675 // but at commit. Therefore we need to track insertions which the normal 55676 // flow doesn't do during mount. This doesn't happen at the root because 55677 // the root always starts with a "current" with a null child. 55678 // TODO: Consider unifying this with how the root works. 55679 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime); 55680 } else { 55681 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime); 55682 } 55683 55684 return workInProgress.child; 55685} 55686 55687function updateContextProvider(current, workInProgress, renderExpirationTime) { 55688 var providerType = workInProgress.type; 55689 var context = providerType._context; 55690 var newProps = workInProgress.pendingProps; 55691 var oldProps = workInProgress.memoizedProps; 55692 var newValue = newProps.value; 55693 55694 { 55695 var providerPropTypes = workInProgress.type.propTypes; 55696 55697 if (providerPropTypes) { 55698 checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev); 55699 } 55700 } 55701 55702 pushProvider(workInProgress, newValue); 55703 55704 if (oldProps !== null) { 55705 var oldValue = oldProps.value; 55706 var changedBits = calculateChangedBits(context, newValue, oldValue); 55707 55708 if (changedBits === 0) { 55709 // No change. Bailout early if children are the same. 55710 if (oldProps.children === newProps.children && !hasContextChanged()) { 55711 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 55712 } 55713 } else { 55714 // The context value changed. Search for matching consumers and schedule 55715 // them to update. 55716 propagateContextChange(workInProgress, context, changedBits, renderExpirationTime); 55717 } 55718 } 55719 55720 var newChildren = newProps.children; 55721 reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); 55722 return workInProgress.child; 55723} 55724 55725var hasWarnedAboutUsingContextAsConsumer = false; 55726 55727function updateContextConsumer(current, workInProgress, renderExpirationTime) { 55728 var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In 55729 // DEV mode, we create a separate object for Context.Consumer that acts 55730 // like a proxy to Context. This proxy object adds unnecessary code in PROD 55731 // so we use the old behaviour (Context.Consumer references Context) to 55732 // reduce size and overhead. The separate object references context via 55733 // a property called "_context", which also gives us the ability to check 55734 // in DEV mode if this property exists or not and warn if it does not. 55735 55736 { 55737 if (context._context === undefined) { 55738 // This may be because it's a Context (rather than a Consumer). 55739 // Or it may be because it's older React where they're the same thing. 55740 // We only want to warn if we're sure it's a new React. 55741 if (context !== context.Consumer) { 55742 if (!hasWarnedAboutUsingContextAsConsumer) { 55743 hasWarnedAboutUsingContextAsConsumer = true; 55744 55745 error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?'); 55746 } 55747 } 55748 } else { 55749 context = context._context; 55750 } 55751 } 55752 55753 var newProps = workInProgress.pendingProps; 55754 var render = newProps.children; 55755 55756 { 55757 if (typeof render !== 'function') { 55758 error('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.'); 55759 } 55760 } 55761 55762 prepareToReadContext(workInProgress, renderExpirationTime); 55763 var newValue = readContext(context, newProps.unstable_observedBits); 55764 var newChildren; 55765 55766 { 55767 ReactCurrentOwner$1.current = workInProgress; 55768 setIsRendering(true); 55769 newChildren = render(newValue); 55770 setIsRendering(false); 55771 } // React DevTools reads this flag. 55772 55773 55774 workInProgress.effectTag |= PerformedWork; 55775 reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); 55776 return workInProgress.child; 55777} 55778 55779function markWorkInProgressReceivedUpdate() { 55780 didReceiveUpdate = true; 55781} 55782 55783function bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime) { 55784 cancelWorkTimer(workInProgress); 55785 55786 if (current !== null) { 55787 // Reuse previous dependencies 55788 workInProgress.dependencies = current.dependencies; 55789 } 55790 55791 { 55792 // Don't update "base" render times for bailouts. 55793 stopProfilerTimerIfRunning(); 55794 } 55795 55796 var updateExpirationTime = workInProgress.expirationTime; 55797 55798 if (updateExpirationTime !== NoWork) { 55799 markUnprocessedUpdateTime(updateExpirationTime); 55800 } // Check if the children have any pending work. 55801 55802 55803 var childExpirationTime = workInProgress.childExpirationTime; 55804 55805 if (childExpirationTime < renderExpirationTime) { 55806 // The children don't have any work either. We can skip them. 55807 // TODO: Once we add back resuming, we should check if the children are 55808 // a work-in-progress set. If so, we need to transfer their effects. 55809 return null; 55810 } else { 55811 // This fiber doesn't have work, but its subtree does. Clone the child 55812 // fibers and continue. 55813 cloneChildFibers(current, workInProgress); 55814 return workInProgress.child; 55815 } 55816} 55817 55818function remountFiber(current, oldWorkInProgress, newWorkInProgress) { 55819 { 55820 var returnFiber = oldWorkInProgress.return; 55821 55822 if (returnFiber === null) { 55823 throw new Error('Cannot swap the root fiber.'); 55824 } // Disconnect from the old current. 55825 // It will get deleted. 55826 55827 55828 current.alternate = null; 55829 oldWorkInProgress.alternate = null; // Connect to the new tree. 55830 55831 newWorkInProgress.index = oldWorkInProgress.index; 55832 newWorkInProgress.sibling = oldWorkInProgress.sibling; 55833 newWorkInProgress.return = oldWorkInProgress.return; 55834 newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it. 55835 55836 if (oldWorkInProgress === returnFiber.child) { 55837 returnFiber.child = newWorkInProgress; 55838 } else { 55839 var prevSibling = returnFiber.child; 55840 55841 if (prevSibling === null) { 55842 throw new Error('Expected parent to have a child.'); 55843 } 55844 55845 while (prevSibling.sibling !== oldWorkInProgress) { 55846 prevSibling = prevSibling.sibling; 55847 55848 if (prevSibling === null) { 55849 throw new Error('Expected to find the previous sibling.'); 55850 } 55851 } 55852 55853 prevSibling.sibling = newWorkInProgress; 55854 } // Delete the old fiber and place the new one. 55855 // Since the old fiber is disconnected, we have to schedule it manually. 55856 55857 55858 var last = returnFiber.lastEffect; 55859 55860 if (last !== null) { 55861 last.nextEffect = current; 55862 returnFiber.lastEffect = current; 55863 } else { 55864 returnFiber.firstEffect = returnFiber.lastEffect = current; 55865 } 55866 55867 current.nextEffect = null; 55868 current.effectTag = Deletion; 55869 newWorkInProgress.effectTag |= Placement; // Restart work from the new fiber. 55870 55871 return newWorkInProgress; 55872 } 55873} 55874 55875function beginWork(current, workInProgress, renderExpirationTime) { 55876 var updateExpirationTime = workInProgress.expirationTime; 55877 55878 { 55879 if (workInProgress._debugNeedsRemount && current !== null) { 55880 // This will restart the begin phase with a new fiber. 55881 return remountFiber(current, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.expirationTime)); 55882 } 55883 } 55884 55885 if (current !== null) { 55886 var oldProps = current.memoizedProps; 55887 var newProps = workInProgress.pendingProps; 55888 55889 if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload: 55890 workInProgress.type !== current.type )) { 55891 // If props or context changed, mark the fiber as having performed work. 55892 // This may be unset if the props are determined to be equal later (memo). 55893 didReceiveUpdate = true; 55894 } else if (updateExpirationTime < renderExpirationTime) { 55895 didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering 55896 // the begin phase. There's still some bookkeeping we that needs to be done 55897 // in this optimized path, mostly pushing stuff onto the stack. 55898 55899 switch (workInProgress.tag) { 55900 case HostRoot: 55901 pushHostRootContext(workInProgress); 55902 resetHydrationState(); 55903 break; 55904 55905 case HostComponent: 55906 pushHostContext(workInProgress); 55907 55908 if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(workInProgress.type, newProps)) { 55909 { 55910 markSpawnedWork(Never); 55911 } // Schedule this fiber to re-render at offscreen priority. Then bailout. 55912 55913 55914 workInProgress.expirationTime = workInProgress.childExpirationTime = Never; 55915 return null; 55916 } 55917 55918 break; 55919 55920 case ClassComponent: 55921 { 55922 var Component = workInProgress.type; 55923 55924 if (isContextProvider(Component)) { 55925 pushContextProvider(workInProgress); 55926 } 55927 55928 break; 55929 } 55930 55931 case HostPortal: 55932 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); 55933 break; 55934 55935 case ContextProvider: 55936 { 55937 var newValue = workInProgress.memoizedProps.value; 55938 pushProvider(workInProgress, newValue); 55939 break; 55940 } 55941 55942 case Profiler: 55943 { 55944 // Profiler should only call onRender when one of its descendants actually rendered. 55945 var hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime; 55946 55947 if (hasChildWork) { 55948 workInProgress.effectTag |= Update; 55949 } 55950 } 55951 55952 break; 55953 55954 case SuspenseComponent: 55955 { 55956 var state = workInProgress.memoizedState; 55957 55958 if (state !== null) { 55959 // whether to retry the primary children, or to skip over it and 55960 // go straight to the fallback. Check the priority of the primary 55961 // child fragment. 55962 55963 55964 var primaryChildFragment = workInProgress.child; 55965 var primaryChildExpirationTime = primaryChildFragment.childExpirationTime; 55966 55967 if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) { 55968 // The primary children have pending work. Use the normal path 55969 // to attempt to render the primary children again. 55970 return updateSuspenseComponent(current, workInProgress, renderExpirationTime); 55971 } else { 55972 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // The primary children do not have pending work with sufficient 55973 // priority. Bailout. 55974 55975 var child = bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 55976 55977 if (child !== null) { 55978 // The fallback children have pending work. Skip over the 55979 // primary children and work on the fallback. 55980 return child.sibling; 55981 } else { 55982 return null; 55983 } 55984 } 55985 } else { 55986 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); 55987 } 55988 55989 break; 55990 } 55991 55992 case SuspenseListComponent: 55993 { 55994 var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect; 55995 55996 var _hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime; 55997 55998 if (didSuspendBefore) { 55999 if (_hasChildWork) { 56000 // If something was in fallback state last time, and we have all the 56001 // same children then we're still in progressive loading state. 56002 // Something might get unblocked by state updates or retries in the 56003 // tree which will affect the tail. So we need to use the normal 56004 // path to compute the correct tail. 56005 return updateSuspenseListComponent(current, workInProgress, renderExpirationTime); 56006 } // If none of the children had any work, that means that none of 56007 // them got retried so they'll still be blocked in the same way 56008 // as before. We can fast bail out. 56009 56010 56011 workInProgress.effectTag |= DidCapture; 56012 } // If nothing suspended before and we're rendering the same children, 56013 // then the tail doesn't matter. Anything new that suspends will work 56014 // in the "together" mode, so we can continue from the state we had. 56015 56016 56017 var renderState = workInProgress.memoizedState; 56018 56019 if (renderState !== null) { 56020 // Reset to the "together" mode in case we've started a different 56021 // update in the past but didn't complete it. 56022 renderState.rendering = null; 56023 renderState.tail = null; 56024 } 56025 56026 pushSuspenseContext(workInProgress, suspenseStackCursor.current); 56027 56028 if (_hasChildWork) { 56029 break; 56030 } else { 56031 // If none of the children had any work, that means that none of 56032 // them got retried so they'll still be blocked in the same way 56033 // as before. We can fast bail out. 56034 return null; 56035 } 56036 } 56037 } 56038 56039 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime); 56040 } else { 56041 // An update was scheduled on this fiber, but there are no new props 56042 // nor legacy context. Set this to false. If an update queue or context 56043 // consumer produces a changed value, it will set this to true. Otherwise, 56044 // the component will assume the children have not changed and bail out. 56045 didReceiveUpdate = false; 56046 } 56047 } else { 56048 didReceiveUpdate = false; 56049 } // Before entering the begin phase, clear pending update priority. 56050 // TODO: This assumes that we're about to evaluate the component and process 56051 // the update queue. However, there's an exception: SimpleMemoComponent 56052 // sometimes bails out later in the begin phase. This indicates that we should 56053 // move this assignment out of the common path and into each branch. 56054 56055 56056 workInProgress.expirationTime = NoWork; 56057 56058 switch (workInProgress.tag) { 56059 case IndeterminateComponent: 56060 { 56061 return mountIndeterminateComponent(current, workInProgress, workInProgress.type, renderExpirationTime); 56062 } 56063 56064 case LazyComponent: 56065 { 56066 var elementType = workInProgress.elementType; 56067 return mountLazyComponent(current, workInProgress, elementType, updateExpirationTime, renderExpirationTime); 56068 } 56069 56070 case FunctionComponent: 56071 { 56072 var _Component = workInProgress.type; 56073 var unresolvedProps = workInProgress.pendingProps; 56074 var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps); 56075 return updateFunctionComponent(current, workInProgress, _Component, resolvedProps, renderExpirationTime); 56076 } 56077 56078 case ClassComponent: 56079 { 56080 var _Component2 = workInProgress.type; 56081 var _unresolvedProps = workInProgress.pendingProps; 56082 56083 var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps); 56084 56085 return updateClassComponent(current, workInProgress, _Component2, _resolvedProps, renderExpirationTime); 56086 } 56087 56088 case HostRoot: 56089 return updateHostRoot(current, workInProgress, renderExpirationTime); 56090 56091 case HostComponent: 56092 return updateHostComponent(current, workInProgress, renderExpirationTime); 56093 56094 case HostText: 56095 return updateHostText(current, workInProgress); 56096 56097 case SuspenseComponent: 56098 return updateSuspenseComponent(current, workInProgress, renderExpirationTime); 56099 56100 case HostPortal: 56101 return updatePortalComponent(current, workInProgress, renderExpirationTime); 56102 56103 case ForwardRef: 56104 { 56105 var type = workInProgress.type; 56106 var _unresolvedProps2 = workInProgress.pendingProps; 56107 56108 var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2); 56109 56110 return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderExpirationTime); 56111 } 56112 56113 case Fragment: 56114 return updateFragment(current, workInProgress, renderExpirationTime); 56115 56116 case Mode: 56117 return updateMode(current, workInProgress, renderExpirationTime); 56118 56119 case Profiler: 56120 return updateProfiler(current, workInProgress, renderExpirationTime); 56121 56122 case ContextProvider: 56123 return updateContextProvider(current, workInProgress, renderExpirationTime); 56124 56125 case ContextConsumer: 56126 return updateContextConsumer(current, workInProgress, renderExpirationTime); 56127 56128 case MemoComponent: 56129 { 56130 var _type2 = workInProgress.type; 56131 var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props. 56132 56133 var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3); 56134 56135 { 56136 if (workInProgress.type !== workInProgress.elementType) { 56137 var outerPropTypes = _type2.propTypes; 56138 56139 if (outerPropTypes) { 56140 checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only 56141 'prop', getComponentName(_type2), getCurrentFiberStackInDev); 56142 } 56143 } 56144 } 56145 56146 _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3); 56147 return updateMemoComponent(current, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime); 56148 } 56149 56150 case SimpleMemoComponent: 56151 { 56152 return updateSimpleMemoComponent(current, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime); 56153 } 56154 56155 case IncompleteClassComponent: 56156 { 56157 var _Component3 = workInProgress.type; 56158 var _unresolvedProps4 = workInProgress.pendingProps; 56159 56160 var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4); 56161 56162 return mountIncompleteClassComponent(current, workInProgress, _Component3, _resolvedProps4, renderExpirationTime); 56163 } 56164 56165 case SuspenseListComponent: 56166 { 56167 return updateSuspenseListComponent(current, workInProgress, renderExpirationTime); 56168 } 56169 } 56170 56171 { 56172 { 56173 throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." ); 56174 } 56175 } 56176} 56177 56178function markUpdate(workInProgress) { 56179 // Tag the fiber with an update effect. This turns a Placement into 56180 // a PlacementAndUpdate. 56181 workInProgress.effectTag |= Update; 56182} 56183 56184function markRef$1(workInProgress) { 56185 workInProgress.effectTag |= Ref; 56186} 56187 56188var appendAllChildren; 56189var updateHostContainer; 56190var updateHostComponent$1; 56191var updateHostText$1; 56192 56193{ 56194 // Mutation mode 56195 appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) { 56196 // We only have the top Fiber that was created but we need recurse down its 56197 // children to find all the terminal nodes. 56198 var node = workInProgress.child; 56199 56200 while (node !== null) { 56201 if (node.tag === HostComponent || node.tag === HostText) { 56202 appendInitialChild(parent, node.stateNode); 56203 } else if (node.tag === HostPortal) ; else if (node.child !== null) { 56204 node.child.return = node; 56205 node = node.child; 56206 continue; 56207 } 56208 56209 if (node === workInProgress) { 56210 return; 56211 } 56212 56213 while (node.sibling === null) { 56214 if (node.return === null || node.return === workInProgress) { 56215 return; 56216 } 56217 56218 node = node.return; 56219 } 56220 56221 node.sibling.return = node.return; 56222 node = node.sibling; 56223 } 56224 }; 56225 56226 updateHostContainer = function (workInProgress) {// Noop 56227 }; 56228 56229 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) { 56230 // If we have an alternate, that means this is an update and we need to 56231 // schedule a side-effect to do the updates. 56232 var oldProps = current.memoizedProps; 56233 56234 if (oldProps === newProps) { 56235 // In mutation mode, this is sufficient for a bailout because 56236 // we won't touch this node even if children changed. 56237 return; 56238 } // If we get updated because one of our children updated, we don't 56239 // have newProps so we'll have to reuse them. 56240 // TODO: Split the update API as separate for the props vs. children. 56241 // Even better would be if children weren't special cased at all tho. 56242 56243 56244 var instance = workInProgress.stateNode; 56245 var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host 56246 // component is hitting the resume path. Figure out why. Possibly 56247 // related to `hidden`. 56248 56249 var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); // TODO: Type this specific to this type of component. 56250 56251 workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there 56252 // is a new ref we mark this as an update. All the work is done in commitWork. 56253 56254 if (updatePayload) { 56255 markUpdate(workInProgress); 56256 } 56257 }; 56258 56259 updateHostText$1 = function (current, workInProgress, oldText, newText) { 56260 // If the text differs, mark it as an update. All the work in done in commitWork. 56261 if (oldText !== newText) { 56262 markUpdate(workInProgress); 56263 } 56264 }; 56265} 56266 56267function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { 56268 switch (renderState.tailMode) { 56269 case 'hidden': 56270 { 56271 // Any insertions at the end of the tail list after this point 56272 // should be invisible. If there are already mounted boundaries 56273 // anything before them are not considered for collapsing. 56274 // Therefore we need to go through the whole tail to find if 56275 // there are any. 56276 var tailNode = renderState.tail; 56277 var lastTailNode = null; 56278 56279 while (tailNode !== null) { 56280 if (tailNode.alternate !== null) { 56281 lastTailNode = tailNode; 56282 } 56283 56284 tailNode = tailNode.sibling; 56285 } // Next we're simply going to delete all insertions after the 56286 // last rendered item. 56287 56288 56289 if (lastTailNode === null) { 56290 // All remaining items in the tail are insertions. 56291 renderState.tail = null; 56292 } else { 56293 // Detach the insertion after the last node that was already 56294 // inserted. 56295 lastTailNode.sibling = null; 56296 } 56297 56298 break; 56299 } 56300 56301 case 'collapsed': 56302 { 56303 // Any insertions at the end of the tail list after this point 56304 // should be invisible. If there are already mounted boundaries 56305 // anything before them are not considered for collapsing. 56306 // Therefore we need to go through the whole tail to find if 56307 // there are any. 56308 var _tailNode = renderState.tail; 56309 var _lastTailNode = null; 56310 56311 while (_tailNode !== null) { 56312 if (_tailNode.alternate !== null) { 56313 _lastTailNode = _tailNode; 56314 } 56315 56316 _tailNode = _tailNode.sibling; 56317 } // Next we're simply going to delete all insertions after the 56318 // last rendered item. 56319 56320 56321 if (_lastTailNode === null) { 56322 // All remaining items in the tail are insertions. 56323 if (!hasRenderedATailFallback && renderState.tail !== null) { 56324 // We suspended during the head. We want to show at least one 56325 // row at the tail. So we'll keep on and cut off the rest. 56326 renderState.tail.sibling = null; 56327 } else { 56328 renderState.tail = null; 56329 } 56330 } else { 56331 // Detach the insertion after the last node that was already 56332 // inserted. 56333 _lastTailNode.sibling = null; 56334 } 56335 56336 break; 56337 } 56338 } 56339} 56340 56341function completeWork(current, workInProgress, renderExpirationTime) { 56342 var newProps = workInProgress.pendingProps; 56343 56344 switch (workInProgress.tag) { 56345 case IndeterminateComponent: 56346 case LazyComponent: 56347 case SimpleMemoComponent: 56348 case FunctionComponent: 56349 case ForwardRef: 56350 case Fragment: 56351 case Mode: 56352 case Profiler: 56353 case ContextConsumer: 56354 case MemoComponent: 56355 return null; 56356 56357 case ClassComponent: 56358 { 56359 var Component = workInProgress.type; 56360 56361 if (isContextProvider(Component)) { 56362 popContext(workInProgress); 56363 } 56364 56365 return null; 56366 } 56367 56368 case HostRoot: 56369 { 56370 popHostContainer(workInProgress); 56371 popTopLevelContextObject(workInProgress); 56372 var fiberRoot = workInProgress.stateNode; 56373 56374 if (fiberRoot.pendingContext) { 56375 fiberRoot.context = fiberRoot.pendingContext; 56376 fiberRoot.pendingContext = null; 56377 } 56378 56379 if (current === null || current.child === null) { 56380 // If we hydrated, pop so that we can delete any remaining children 56381 // that weren't hydrated. 56382 var wasHydrated = popHydrationState(workInProgress); 56383 56384 if (wasHydrated) { 56385 // If we hydrated, then we'll need to schedule an update for 56386 // the commit side-effects on the root. 56387 markUpdate(workInProgress); 56388 } 56389 } 56390 56391 updateHostContainer(workInProgress); 56392 return null; 56393 } 56394 56395 case HostComponent: 56396 { 56397 popHostContext(workInProgress); 56398 var rootContainerInstance = getRootHostContainer(); 56399 var type = workInProgress.type; 56400 56401 if (current !== null && workInProgress.stateNode != null) { 56402 updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance); 56403 56404 if (current.ref !== workInProgress.ref) { 56405 markRef$1(workInProgress); 56406 } 56407 } else { 56408 if (!newProps) { 56409 if (!(workInProgress.stateNode !== null)) { 56410 { 56411 throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); 56412 } 56413 } // This can happen when we abort work. 56414 56415 56416 return null; 56417 } 56418 56419 var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context 56420 // "stack" as the parent. Then append children as we go in beginWork 56421 // or completeWork depending on whether we want to add them top->down or 56422 // bottom->up. Top->down is faster in IE11. 56423 56424 var _wasHydrated = popHydrationState(workInProgress); 56425 56426 if (_wasHydrated) { 56427 // TODO: Move this and createInstance step into the beginPhase 56428 // to consolidate. 56429 if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) { 56430 // If changes to the hydrated node need to be applied at the 56431 // commit-phase we mark this as such. 56432 markUpdate(workInProgress); 56433 } 56434 } else { 56435 var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress); 56436 appendAllChildren(instance, workInProgress, false, false); // This needs to be set before we mount Flare event listeners 56437 56438 workInProgress.stateNode = instance; 56439 // (eg DOM renderer supports auto-focus for certain elements). 56440 // Make sure such renderers get scheduled for later work. 56441 56442 56443 if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance)) { 56444 markUpdate(workInProgress); 56445 } 56446 } 56447 56448 if (workInProgress.ref !== null) { 56449 // If there is a ref on a host node we need to schedule a callback 56450 markRef$1(workInProgress); 56451 } 56452 } 56453 56454 return null; 56455 } 56456 56457 case HostText: 56458 { 56459 var newText = newProps; 56460 56461 if (current && workInProgress.stateNode != null) { 56462 var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need 56463 // to schedule a side-effect to do the updates. 56464 56465 updateHostText$1(current, workInProgress, oldText, newText); 56466 } else { 56467 if (typeof newText !== 'string') { 56468 if (!(workInProgress.stateNode !== null)) { 56469 { 56470 throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); 56471 } 56472 } // This can happen when we abort work. 56473 56474 } 56475 56476 var _rootContainerInstance = getRootHostContainer(); 56477 56478 var _currentHostContext = getHostContext(); 56479 56480 var _wasHydrated2 = popHydrationState(workInProgress); 56481 56482 if (_wasHydrated2) { 56483 if (prepareToHydrateHostTextInstance(workInProgress)) { 56484 markUpdate(workInProgress); 56485 } 56486 } else { 56487 workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress); 56488 } 56489 } 56490 56491 return null; 56492 } 56493 56494 case SuspenseComponent: 56495 { 56496 popSuspenseContext(workInProgress); 56497 var nextState = workInProgress.memoizedState; 56498 56499 if ((workInProgress.effectTag & DidCapture) !== NoEffect) { 56500 // Something suspended. Re-render with the fallback children. 56501 workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list. 56502 56503 return workInProgress; 56504 } 56505 56506 var nextDidTimeout = nextState !== null; 56507 var prevDidTimeout = false; 56508 56509 if (current === null) { 56510 if (workInProgress.memoizedProps.fallback !== undefined) { 56511 popHydrationState(workInProgress); 56512 } 56513 } else { 56514 var prevState = current.memoizedState; 56515 prevDidTimeout = prevState !== null; 56516 56517 if (!nextDidTimeout && prevState !== null) { 56518 // We just switched from the fallback to the normal children. 56519 // Delete the fallback. 56520 // TODO: Would it be better to store the fallback fragment on 56521 // the stateNode during the begin phase? 56522 var currentFallbackChild = current.child.sibling; 56523 56524 if (currentFallbackChild !== null) { 56525 // Deletions go at the beginning of the return fiber's effect list 56526 var first = workInProgress.firstEffect; 56527 56528 if (first !== null) { 56529 workInProgress.firstEffect = currentFallbackChild; 56530 currentFallbackChild.nextEffect = first; 56531 } else { 56532 workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; 56533 currentFallbackChild.nextEffect = null; 56534 } 56535 56536 currentFallbackChild.effectTag = Deletion; 56537 } 56538 } 56539 } 56540 56541 if (nextDidTimeout && !prevDidTimeout) { 56542 // If this subtreee is running in blocking mode we can suspend, 56543 // otherwise we won't suspend. 56544 // TODO: This will still suspend a synchronous tree if anything 56545 // in the concurrent tree already suspended during this render. 56546 // This is a known bug. 56547 if ((workInProgress.mode & BlockingMode) !== NoMode) { 56548 // TODO: Move this back to throwException because this is too late 56549 // if this is a large tree which is common for initial loads. We 56550 // don't know if we should restart a render or not until we get 56551 // this marker, and this is too late. 56552 // If this render already had a ping or lower pri updates, 56553 // and this is the first time we know we're going to suspend we 56554 // should be able to immediately restart from within throwException. 56555 var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true; 56556 56557 if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) { 56558 // If this was in an invisible tree or a new render, then showing 56559 // this boundary is ok. 56560 renderDidSuspend(); 56561 } else { 56562 // Otherwise, we're going to have to hide content so we should 56563 // suspend for longer if possible. 56564 renderDidSuspendDelayIfPossible(); 56565 } 56566 } 56567 } 56568 56569 { 56570 // TODO: Only schedule updates if these values are non equal, i.e. it changed. 56571 if (nextDidTimeout || prevDidTimeout) { 56572 // If this boundary just timed out, schedule an effect to attach a 56573 // retry listener to the promise. This flag is also used to hide the 56574 // primary children. In mutation mode, we also need the flag to 56575 // *unhide* children that were previously hidden, so check if this 56576 // is currently timed out, too. 56577 workInProgress.effectTag |= Update; 56578 } 56579 } 56580 56581 return null; 56582 } 56583 56584 case HostPortal: 56585 popHostContainer(workInProgress); 56586 updateHostContainer(workInProgress); 56587 return null; 56588 56589 case ContextProvider: 56590 // Pop provider fiber 56591 popProvider(workInProgress); 56592 return null; 56593 56594 case IncompleteClassComponent: 56595 { 56596 // Same as class component case. I put it down here so that the tags are 56597 // sequential to ensure this switch is compiled to a jump table. 56598 var _Component = workInProgress.type; 56599 56600 if (isContextProvider(_Component)) { 56601 popContext(workInProgress); 56602 } 56603 56604 return null; 56605 } 56606 56607 case SuspenseListComponent: 56608 { 56609 popSuspenseContext(workInProgress); 56610 var renderState = workInProgress.memoizedState; 56611 56612 if (renderState === null) { 56613 // We're running in the default, "independent" mode. 56614 // We don't do anything in this mode. 56615 return null; 56616 } 56617 56618 var didSuspendAlready = (workInProgress.effectTag & DidCapture) !== NoEffect; 56619 var renderedTail = renderState.rendering; 56620 56621 if (renderedTail === null) { 56622 // We just rendered the head. 56623 if (!didSuspendAlready) { 56624 // This is the first pass. We need to figure out if anything is still 56625 // suspended in the rendered set. 56626 // If new content unsuspended, but there's still some content that 56627 // didn't. Then we need to do a second pass that forces everything 56628 // to keep showing their fallbacks. 56629 // We might be suspended if something in this render pass suspended, or 56630 // something in the previous committed pass suspended. Otherwise, 56631 // there's no chance so we can skip the expensive call to 56632 // findFirstSuspended. 56633 var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.effectTag & DidCapture) === NoEffect); 56634 56635 if (!cannotBeSuspended) { 56636 var row = workInProgress.child; 56637 56638 while (row !== null) { 56639 var suspended = findFirstSuspended(row); 56640 56641 if (suspended !== null) { 56642 didSuspendAlready = true; 56643 workInProgress.effectTag |= DidCapture; 56644 cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as 56645 // part of the second pass. In that case nothing will subscribe to 56646 // its thennables. Instead, we'll transfer its thennables to the 56647 // SuspenseList so that it can retry if they resolve. 56648 // There might be multiple of these in the list but since we're 56649 // going to wait for all of them anyway, it doesn't really matter 56650 // which ones gets to ping. In theory we could get clever and keep 56651 // track of how many dependencies remain but it gets tricky because 56652 // in the meantime, we can add/remove/change items and dependencies. 56653 // We might bail out of the loop before finding any but that 56654 // doesn't matter since that means that the other boundaries that 56655 // we did find already has their listeners attached. 56656 56657 var newThennables = suspended.updateQueue; 56658 56659 if (newThennables !== null) { 56660 workInProgress.updateQueue = newThennables; 56661 workInProgress.effectTag |= Update; 56662 } // Rerender the whole list, but this time, we'll force fallbacks 56663 // to stay in place. 56664 // Reset the effect list before doing the second pass since that's now invalid. 56665 56666 56667 if (renderState.lastEffect === null) { 56668 workInProgress.firstEffect = null; 56669 } 56670 56671 workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state. 56672 56673 resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately 56674 // rerender the children. 56675 56676 pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback)); 56677 return workInProgress.child; 56678 } 56679 56680 row = row.sibling; 56681 } 56682 } 56683 } else { 56684 cutOffTailIfNeeded(renderState, false); 56685 } // Next we're going to render the tail. 56686 56687 } else { 56688 // Append the rendered row to the child list. 56689 if (!didSuspendAlready) { 56690 var _suspended = findFirstSuspended(renderedTail); 56691 56692 if (_suspended !== null) { 56693 workInProgress.effectTag |= DidCapture; 56694 didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't 56695 // get lost if this row ends up dropped during a second pass. 56696 56697 var _newThennables = _suspended.updateQueue; 56698 56699 if (_newThennables !== null) { 56700 workInProgress.updateQueue = _newThennables; 56701 workInProgress.effectTag |= Update; 56702 } 56703 56704 cutOffTailIfNeeded(renderState, true); // This might have been modified. 56705 56706 if (renderState.tail === null && renderState.tailMode === 'hidden' && !renderedTail.alternate) { 56707 // We need to delete the row we just rendered. 56708 // Reset the effect list to what it was before we rendered this 56709 // child. The nested children have already appended themselves. 56710 var lastEffect = workInProgress.lastEffect = renderState.lastEffect; // Remove any effects that were appended after this point. 56711 56712 if (lastEffect !== null) { 56713 lastEffect.nextEffect = null; 56714 } // We're done. 56715 56716 56717 return null; 56718 } 56719 } else if ( // The time it took to render last row is greater than time until 56720 // the expiration. 56721 now() * 2 - renderState.renderingStartTime > renderState.tailExpiration && renderExpirationTime > Never) { 56722 // We have now passed our CPU deadline and we'll just give up further 56723 // attempts to render the main content and only render fallbacks. 56724 // The assumption is that this is usually faster. 56725 workInProgress.effectTag |= DidCapture; 56726 didSuspendAlready = true; 56727 cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this 56728 // to get it started back up to attempt the next item. If we can show 56729 // them, then they really have the same priority as this render. 56730 // So we'll pick it back up the very next render pass once we've had 56731 // an opportunity to yield for paint. 56732 56733 var nextPriority = renderExpirationTime - 1; 56734 workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority; 56735 56736 { 56737 markSpawnedWork(nextPriority); 56738 } 56739 } 56740 } 56741 56742 if (renderState.isBackwards) { 56743 // The effect list of the backwards tail will have been added 56744 // to the end. This breaks the guarantee that life-cycles fire in 56745 // sibling order but that isn't a strong guarantee promised by React. 56746 // Especially since these might also just pop in during future commits. 56747 // Append to the beginning of the list. 56748 renderedTail.sibling = workInProgress.child; 56749 workInProgress.child = renderedTail; 56750 } else { 56751 var previousSibling = renderState.last; 56752 56753 if (previousSibling !== null) { 56754 previousSibling.sibling = renderedTail; 56755 } else { 56756 workInProgress.child = renderedTail; 56757 } 56758 56759 renderState.last = renderedTail; 56760 } 56761 } 56762 56763 if (renderState.tail !== null) { 56764 // We still have tail rows to render. 56765 if (renderState.tailExpiration === 0) { 56766 // Heuristic for how long we're willing to spend rendering rows 56767 // until we just give up and show what we have so far. 56768 var TAIL_EXPIRATION_TIMEOUT_MS = 500; 56769 renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; // TODO: This is meant to mimic the train model or JND but this 56770 // is a per component value. It should really be since the start 56771 // of the total render or last commit. Consider using something like 56772 // globalMostRecentFallbackTime. That doesn't account for being 56773 // suspended for part of the time or when it's a new render. 56774 // It should probably use a global start time value instead. 56775 } // Pop a row. 56776 56777 56778 var next = renderState.tail; 56779 renderState.rendering = next; 56780 renderState.tail = next.sibling; 56781 renderState.lastEffect = workInProgress.lastEffect; 56782 renderState.renderingStartTime = now(); 56783 next.sibling = null; // Restore the context. 56784 // TODO: We can probably just avoid popping it instead and only 56785 // setting it the first time we go from not suspended to suspended. 56786 56787 var suspenseContext = suspenseStackCursor.current; 56788 56789 if (didSuspendAlready) { 56790 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback); 56791 } else { 56792 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); 56793 } 56794 56795 pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row. 56796 56797 return next; 56798 } 56799 56800 return null; 56801 } 56802 } 56803 56804 { 56805 { 56806 throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." ); 56807 } 56808 } 56809} 56810 56811function unwindWork(workInProgress, renderExpirationTime) { 56812 switch (workInProgress.tag) { 56813 case ClassComponent: 56814 { 56815 var Component = workInProgress.type; 56816 56817 if (isContextProvider(Component)) { 56818 popContext(workInProgress); 56819 } 56820 56821 var effectTag = workInProgress.effectTag; 56822 56823 if (effectTag & ShouldCapture) { 56824 workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture; 56825 return workInProgress; 56826 } 56827 56828 return null; 56829 } 56830 56831 case HostRoot: 56832 { 56833 popHostContainer(workInProgress); 56834 popTopLevelContextObject(workInProgress); 56835 var _effectTag = workInProgress.effectTag; 56836 56837 if (!((_effectTag & DidCapture) === NoEffect)) { 56838 { 56839 throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); 56840 } 56841 } 56842 56843 workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture; 56844 return workInProgress; 56845 } 56846 56847 case HostComponent: 56848 { 56849 // TODO: popHydrationState 56850 popHostContext(workInProgress); 56851 return null; 56852 } 56853 56854 case SuspenseComponent: 56855 { 56856 popSuspenseContext(workInProgress); 56857 56858 var _effectTag2 = workInProgress.effectTag; 56859 56860 if (_effectTag2 & ShouldCapture) { 56861 workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture; // Captured a suspense effect. Re-render the boundary. 56862 56863 return workInProgress; 56864 } 56865 56866 return null; 56867 } 56868 56869 case SuspenseListComponent: 56870 { 56871 popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been 56872 // caught by a nested boundary. If not, it should bubble through. 56873 56874 return null; 56875 } 56876 56877 case HostPortal: 56878 popHostContainer(workInProgress); 56879 return null; 56880 56881 case ContextProvider: 56882 popProvider(workInProgress); 56883 return null; 56884 56885 default: 56886 return null; 56887 } 56888} 56889 56890function unwindInterruptedWork(interruptedWork) { 56891 switch (interruptedWork.tag) { 56892 case ClassComponent: 56893 { 56894 var childContextTypes = interruptedWork.type.childContextTypes; 56895 56896 if (childContextTypes !== null && childContextTypes !== undefined) { 56897 popContext(interruptedWork); 56898 } 56899 56900 break; 56901 } 56902 56903 case HostRoot: 56904 { 56905 popHostContainer(interruptedWork); 56906 popTopLevelContextObject(interruptedWork); 56907 break; 56908 } 56909 56910 case HostComponent: 56911 { 56912 popHostContext(interruptedWork); 56913 break; 56914 } 56915 56916 case HostPortal: 56917 popHostContainer(interruptedWork); 56918 break; 56919 56920 case SuspenseComponent: 56921 popSuspenseContext(interruptedWork); 56922 break; 56923 56924 case SuspenseListComponent: 56925 popSuspenseContext(interruptedWork); 56926 break; 56927 56928 case ContextProvider: 56929 popProvider(interruptedWork); 56930 break; 56931 } 56932} 56933 56934function createCapturedValue(value, source) { 56935 // If the value is an error, call this function immediately after it is thrown 56936 // so the stack is accurate. 56937 return { 56938 value: value, 56939 source: source, 56940 stack: getStackByFiberInDevAndProd(source) 56941 }; 56942} 56943 56944function logCapturedError(capturedError) { 56945 56946 var error = capturedError.error; 56947 56948 { 56949 var componentName = capturedError.componentName, 56950 componentStack = capturedError.componentStack, 56951 errorBoundaryName = capturedError.errorBoundaryName, 56952 errorBoundaryFound = capturedError.errorBoundaryFound, 56953 willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling 56954 // `preventDefault()` in window `error` handler. 56955 // We record this information as an expando on the error. 56956 56957 if (error != null && error._suppressLogging) { 56958 if (errorBoundaryFound && willRetry) { 56959 // The error is recoverable and was silenced. 56960 // Ignore it and don't print the stack addendum. 56961 // This is handy for testing error boundaries without noise. 56962 return; 56963 } // The error is fatal. Since the silencing might have 56964 // been accidental, we'll surface it anyway. 56965 // However, the browser would have silenced the original error 56966 // so we'll print it first, and then print the stack addendum. 56967 56968 56969 console['error'](error); // Don't transform to our wrapper 56970 // For a more detailed description of this block, see: 56971 // https://github.com/facebook/react/pull/13384 56972 } 56973 56974 var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:'; 56975 var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow. 56976 56977 if (errorBoundaryFound && errorBoundaryName) { 56978 if (willRetry) { 56979 errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + "."); 56980 } else { 56981 errorBoundaryMessage = "This error was initially handled by the error boundary " + errorBoundaryName + ".\n" + "Recreating the tree from scratch failed so React will unmount the tree."; 56982 } 56983 } else { 56984 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.'; 56985 } 56986 56987 var combinedMessage = "" + componentNameMessage + componentStack + "\n\n" + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. 56988 // We don't include the original error message and JS stack because the browser 56989 // has already printed it. Even if the application swallows the error, it is still 56990 // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. 56991 56992 console['error'](combinedMessage); // Don't transform to our wrapper 56993 } 56994} 56995 56996var didWarnAboutUndefinedSnapshotBeforeUpdate = null; 56997 56998{ 56999 didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); 57000} 57001 57002var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set; 57003function logError(boundary, errorInfo) { 57004 var source = errorInfo.source; 57005 var stack = errorInfo.stack; 57006 57007 if (stack === null && source !== null) { 57008 stack = getStackByFiberInDevAndProd(source); 57009 } 57010 57011 var capturedError = { 57012 componentName: source !== null ? getComponentName(source.type) : null, 57013 componentStack: stack !== null ? stack : '', 57014 error: errorInfo.value, 57015 errorBoundary: null, 57016 errorBoundaryName: null, 57017 errorBoundaryFound: false, 57018 willRetry: false 57019 }; 57020 57021 if (boundary !== null && boundary.tag === ClassComponent) { 57022 capturedError.errorBoundary = boundary.stateNode; 57023 capturedError.errorBoundaryName = getComponentName(boundary.type); 57024 capturedError.errorBoundaryFound = true; 57025 capturedError.willRetry = true; 57026 } 57027 57028 try { 57029 logCapturedError(capturedError); 57030 } catch (e) { 57031 // This method must not throw, or React internal state will get messed up. 57032 // If console.error is overridden, or logCapturedError() shows a dialog that throws, 57033 // we want to report this error outside of the normal stack as a last resort. 57034 // https://github.com/facebook/react/issues/13188 57035 setTimeout(function () { 57036 throw e; 57037 }); 57038 } 57039} 57040 57041var callComponentWillUnmountWithTimer = function (current, instance) { 57042 startPhaseTimer(current, 'componentWillUnmount'); 57043 instance.props = current.memoizedProps; 57044 instance.state = current.memoizedState; 57045 instance.componentWillUnmount(); 57046 stopPhaseTimer(); 57047}; // Capture errors so they don't interrupt unmounting. 57048 57049 57050function safelyCallComponentWillUnmount(current, instance) { 57051 { 57052 invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current, instance); 57053 57054 if (hasCaughtError()) { 57055 var unmountError = clearCaughtError(); 57056 captureCommitPhaseError(current, unmountError); 57057 } 57058 } 57059} 57060 57061function safelyDetachRef(current) { 57062 var ref = current.ref; 57063 57064 if (ref !== null) { 57065 if (typeof ref === 'function') { 57066 { 57067 invokeGuardedCallback(null, ref, null, null); 57068 57069 if (hasCaughtError()) { 57070 var refError = clearCaughtError(); 57071 captureCommitPhaseError(current, refError); 57072 } 57073 } 57074 } else { 57075 ref.current = null; 57076 } 57077 } 57078} 57079 57080function safelyCallDestroy(current, destroy) { 57081 { 57082 invokeGuardedCallback(null, destroy, null); 57083 57084 if (hasCaughtError()) { 57085 var error = clearCaughtError(); 57086 captureCommitPhaseError(current, error); 57087 } 57088 } 57089} 57090 57091function commitBeforeMutationLifeCycles(current, finishedWork) { 57092 switch (finishedWork.tag) { 57093 case FunctionComponent: 57094 case ForwardRef: 57095 case SimpleMemoComponent: 57096 case Block: 57097 { 57098 return; 57099 } 57100 57101 case ClassComponent: 57102 { 57103 if (finishedWork.effectTag & Snapshot) { 57104 if (current !== null) { 57105 var prevProps = current.memoizedProps; 57106 var prevState = current.memoizedState; 57107 startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate'); 57108 var instance = finishedWork.stateNode; // We could update instance props and state here, 57109 // but instead we rely on them being set during last render. 57110 // TODO: revisit this when we implement resuming. 57111 57112 { 57113 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 57114 if (instance.props !== finishedWork.memoizedProps) { 57115 error('Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 57116 } 57117 57118 if (instance.state !== finishedWork.memoizedState) { 57119 error('Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 57120 } 57121 } 57122 } 57123 57124 var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState); 57125 57126 { 57127 var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate; 57128 57129 if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { 57130 didWarnSet.add(finishedWork.type); 57131 57132 error('%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type)); 57133 } 57134 } 57135 57136 instance.__reactInternalSnapshotBeforeUpdate = snapshot; 57137 stopPhaseTimer(); 57138 } 57139 } 57140 57141 return; 57142 } 57143 57144 case HostRoot: 57145 case HostComponent: 57146 case HostText: 57147 case HostPortal: 57148 case IncompleteClassComponent: 57149 // Nothing to do for these component types 57150 return; 57151 } 57152 57153 { 57154 { 57155 throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); 57156 } 57157 } 57158} 57159 57160function commitHookEffectListUnmount(tag, finishedWork) { 57161 var updateQueue = finishedWork.updateQueue; 57162 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; 57163 57164 if (lastEffect !== null) { 57165 var firstEffect = lastEffect.next; 57166 var effect = firstEffect; 57167 57168 do { 57169 if ((effect.tag & tag) === tag) { 57170 // Unmount 57171 var destroy = effect.destroy; 57172 effect.destroy = undefined; 57173 57174 if (destroy !== undefined) { 57175 destroy(); 57176 } 57177 } 57178 57179 effect = effect.next; 57180 } while (effect !== firstEffect); 57181 } 57182} 57183 57184function commitHookEffectListMount(tag, finishedWork) { 57185 var updateQueue = finishedWork.updateQueue; 57186 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; 57187 57188 if (lastEffect !== null) { 57189 var firstEffect = lastEffect.next; 57190 var effect = firstEffect; 57191 57192 do { 57193 if ((effect.tag & tag) === tag) { 57194 // Mount 57195 var create = effect.create; 57196 effect.destroy = create(); 57197 57198 { 57199 var destroy = effect.destroy; 57200 57201 if (destroy !== undefined && typeof destroy !== 'function') { 57202 var addendum = void 0; 57203 57204 if (destroy === null) { 57205 addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).'; 57206 } else if (typeof destroy.then === 'function') { 57207 addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + "}, [someId]); // Or [] if effect doesn't need props or state\n\n" + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching'; 57208 } else { 57209 addendum = ' You returned: ' + destroy; 57210 } 57211 57212 error('An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork)); 57213 } 57214 } 57215 } 57216 57217 effect = effect.next; 57218 } while (effect !== firstEffect); 57219 } 57220} 57221 57222function commitPassiveHookEffects(finishedWork) { 57223 if ((finishedWork.effectTag & Passive) !== NoEffect) { 57224 switch (finishedWork.tag) { 57225 case FunctionComponent: 57226 case ForwardRef: 57227 case SimpleMemoComponent: 57228 case Block: 57229 { 57230 // TODO (#17945) We should call all passive destroy functions (for all fibers) 57231 // before calling any create functions. The current approach only serializes 57232 // these for a single fiber. 57233 commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork); 57234 commitHookEffectListMount(Passive$1 | HasEffect, finishedWork); 57235 break; 57236 } 57237 } 57238 } 57239} 57240 57241function commitLifeCycles(finishedRoot, current, finishedWork, committedExpirationTime) { 57242 switch (finishedWork.tag) { 57243 case FunctionComponent: 57244 case ForwardRef: 57245 case SimpleMemoComponent: 57246 case Block: 57247 { 57248 // At this point layout effects have already been destroyed (during mutation phase). 57249 // This is done to prevent sibling component effects from interfering with each other, 57250 // e.g. a destroy function in one component should never override a ref set 57251 // by a create function in another component during the same commit. 57252 commitHookEffectListMount(Layout | HasEffect, finishedWork); 57253 57254 return; 57255 } 57256 57257 case ClassComponent: 57258 { 57259 var instance = finishedWork.stateNode; 57260 57261 if (finishedWork.effectTag & Update) { 57262 if (current === null) { 57263 startPhaseTimer(finishedWork, 'componentDidMount'); // We could update instance props and state here, 57264 // but instead we rely on them being set during last render. 57265 // TODO: revisit this when we implement resuming. 57266 57267 { 57268 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 57269 if (instance.props !== finishedWork.memoizedProps) { 57270 error('Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 57271 } 57272 57273 if (instance.state !== finishedWork.memoizedState) { 57274 error('Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 57275 } 57276 } 57277 } 57278 57279 instance.componentDidMount(); 57280 stopPhaseTimer(); 57281 } else { 57282 var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps); 57283 var prevState = current.memoizedState; 57284 startPhaseTimer(finishedWork, 'componentDidUpdate'); // We could update instance props and state here, 57285 // but instead we rely on them being set during last render. 57286 // TODO: revisit this when we implement resuming. 57287 57288 { 57289 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 57290 if (instance.props !== finishedWork.memoizedProps) { 57291 error('Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 57292 } 57293 57294 if (instance.state !== finishedWork.memoizedState) { 57295 error('Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 57296 } 57297 } 57298 } 57299 57300 instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate); 57301 stopPhaseTimer(); 57302 } 57303 } 57304 57305 var updateQueue = finishedWork.updateQueue; 57306 57307 if (updateQueue !== null) { 57308 { 57309 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 57310 if (instance.props !== finishedWork.memoizedProps) { 57311 error('Expected %s props to match memoized props before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 57312 } 57313 57314 if (instance.state !== finishedWork.memoizedState) { 57315 error('Expected %s state to match memoized state before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 57316 } 57317 } 57318 } // We could update instance props and state here, 57319 // but instead we rely on them being set during last render. 57320 // TODO: revisit this when we implement resuming. 57321 57322 57323 commitUpdateQueue(finishedWork, updateQueue, instance); 57324 } 57325 57326 return; 57327 } 57328 57329 case HostRoot: 57330 { 57331 var _updateQueue = finishedWork.updateQueue; 57332 57333 if (_updateQueue !== null) { 57334 var _instance = null; 57335 57336 if (finishedWork.child !== null) { 57337 switch (finishedWork.child.tag) { 57338 case HostComponent: 57339 _instance = getPublicInstance(finishedWork.child.stateNode); 57340 break; 57341 57342 case ClassComponent: 57343 _instance = finishedWork.child.stateNode; 57344 break; 57345 } 57346 } 57347 57348 commitUpdateQueue(finishedWork, _updateQueue, _instance); 57349 } 57350 57351 return; 57352 } 57353 57354 case HostComponent: 57355 { 57356 var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted 57357 // (eg DOM renderer may schedule auto-focus for inputs and form controls). 57358 // These effects should only be committed when components are first mounted, 57359 // aka when there is no current/alternate. 57360 57361 if (current === null && finishedWork.effectTag & Update) { 57362 var type = finishedWork.type; 57363 var props = finishedWork.memoizedProps; 57364 commitMount(_instance2, type, props); 57365 } 57366 57367 return; 57368 } 57369 57370 case HostText: 57371 { 57372 // We have no life-cycles associated with text. 57373 return; 57374 } 57375 57376 case HostPortal: 57377 { 57378 // We have no life-cycles associated with portals. 57379 return; 57380 } 57381 57382 case Profiler: 57383 { 57384 { 57385 var onRender = finishedWork.memoizedProps.onRender; 57386 57387 if (typeof onRender === 'function') { 57388 { 57389 onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions); 57390 } 57391 } 57392 } 57393 57394 return; 57395 } 57396 57397 case SuspenseComponent: 57398 { 57399 commitSuspenseHydrationCallbacks(finishedRoot, finishedWork); 57400 return; 57401 } 57402 57403 case SuspenseListComponent: 57404 case IncompleteClassComponent: 57405 case FundamentalComponent: 57406 case ScopeComponent: 57407 return; 57408 } 57409 57410 { 57411 { 57412 throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); 57413 } 57414 } 57415} 57416 57417function hideOrUnhideAllChildren(finishedWork, isHidden) { 57418 { 57419 // We only have the top Fiber that was inserted but we need to recurse down its 57420 // children to find all the terminal nodes. 57421 var node = finishedWork; 57422 57423 while (true) { 57424 if (node.tag === HostComponent) { 57425 var instance = node.stateNode; 57426 57427 if (isHidden) { 57428 hideInstance(instance); 57429 } else { 57430 unhideInstance(node.stateNode, node.memoizedProps); 57431 } 57432 } else if (node.tag === HostText) { 57433 var _instance3 = node.stateNode; 57434 57435 if (isHidden) { 57436 hideTextInstance(_instance3); 57437 } else { 57438 unhideTextInstance(_instance3, node.memoizedProps); 57439 } 57440 } else if (node.tag === SuspenseComponent && node.memoizedState !== null && node.memoizedState.dehydrated === null) { 57441 // Found a nested Suspense component that timed out. Skip over the 57442 // primary child fragment, which should remain hidden. 57443 var fallbackChildFragment = node.child.sibling; 57444 fallbackChildFragment.return = node; 57445 node = fallbackChildFragment; 57446 continue; 57447 } else if (node.child !== null) { 57448 node.child.return = node; 57449 node = node.child; 57450 continue; 57451 } 57452 57453 if (node === finishedWork) { 57454 return; 57455 } 57456 57457 while (node.sibling === null) { 57458 if (node.return === null || node.return === finishedWork) { 57459 return; 57460 } 57461 57462 node = node.return; 57463 } 57464 57465 node.sibling.return = node.return; 57466 node = node.sibling; 57467 } 57468 } 57469} 57470 57471function commitAttachRef(finishedWork) { 57472 var ref = finishedWork.ref; 57473 57474 if (ref !== null) { 57475 var instance = finishedWork.stateNode; 57476 var instanceToUse; 57477 57478 switch (finishedWork.tag) { 57479 case HostComponent: 57480 instanceToUse = getPublicInstance(instance); 57481 break; 57482 57483 default: 57484 instanceToUse = instance; 57485 } // Moved outside to ensure DCE works with this flag 57486 57487 if (typeof ref === 'function') { 57488 ref(instanceToUse); 57489 } else { 57490 { 57491 if (!ref.hasOwnProperty('current')) { 57492 error('Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork)); 57493 } 57494 } 57495 57496 ref.current = instanceToUse; 57497 } 57498 } 57499} 57500 57501function commitDetachRef(current) { 57502 var currentRef = current.ref; 57503 57504 if (currentRef !== null) { 57505 if (typeof currentRef === 'function') { 57506 currentRef(null); 57507 } else { 57508 currentRef.current = null; 57509 } 57510 } 57511} // User-originating errors (lifecycles and refs) should not interrupt 57512// deletion, so don't let them throw. Host-originating errors should 57513// interrupt deletion, so it's okay 57514 57515 57516function commitUnmount(finishedRoot, current, renderPriorityLevel) { 57517 onCommitUnmount(current); 57518 57519 switch (current.tag) { 57520 case FunctionComponent: 57521 case ForwardRef: 57522 case MemoComponent: 57523 case SimpleMemoComponent: 57524 case Block: 57525 { 57526 var updateQueue = current.updateQueue; 57527 57528 if (updateQueue !== null) { 57529 var lastEffect = updateQueue.lastEffect; 57530 57531 if (lastEffect !== null) { 57532 var firstEffect = lastEffect.next; 57533 57534 { 57535 // When the owner fiber is deleted, the destroy function of a passive 57536 // effect hook is called during the synchronous commit phase. This is 57537 // a concession to implementation complexity. Calling it in the 57538 // passive effect phase (like they usually are, when dependencies 57539 // change during an update) would require either traversing the 57540 // children of the deleted fiber again, or including unmount effects 57541 // as part of the fiber effect list. 57542 // 57543 // Because this is during the sync commit phase, we need to change 57544 // the priority. 57545 // 57546 // TODO: Reconsider this implementation trade off. 57547 var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel; 57548 runWithPriority$1(priorityLevel, function () { 57549 var effect = firstEffect; 57550 57551 do { 57552 var _destroy = effect.destroy; 57553 57554 if (_destroy !== undefined) { 57555 safelyCallDestroy(current, _destroy); 57556 } 57557 57558 effect = effect.next; 57559 } while (effect !== firstEffect); 57560 }); 57561 } 57562 } 57563 } 57564 57565 return; 57566 } 57567 57568 case ClassComponent: 57569 { 57570 safelyDetachRef(current); 57571 var instance = current.stateNode; 57572 57573 if (typeof instance.componentWillUnmount === 'function') { 57574 safelyCallComponentWillUnmount(current, instance); 57575 } 57576 57577 return; 57578 } 57579 57580 case HostComponent: 57581 { 57582 57583 safelyDetachRef(current); 57584 return; 57585 } 57586 57587 case HostPortal: 57588 { 57589 // TODO: this is recursive. 57590 // We are also not using this parent because 57591 // the portal will get pushed immediately. 57592 { 57593 unmountHostComponents(finishedRoot, current, renderPriorityLevel); 57594 } 57595 57596 return; 57597 } 57598 57599 case FundamentalComponent: 57600 { 57601 57602 return; 57603 } 57604 57605 case DehydratedFragment: 57606 { 57607 57608 return; 57609 } 57610 57611 case ScopeComponent: 57612 { 57613 57614 return; 57615 } 57616 } 57617} 57618 57619function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { 57620 // While we're inside a removed host node we don't want to call 57621 // removeChild on the inner nodes because they're removed by the top 57622 // call anyway. We also want to call componentWillUnmount on all 57623 // composites before this host node is removed from the tree. Therefore 57624 // we do an inner loop while we're still inside the host node. 57625 var node = root; 57626 57627 while (true) { 57628 commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes. 57629 // Skip portals because commitUnmount() currently visits them recursively. 57630 57631 if (node.child !== null && ( // If we use mutation we drill down into portals using commitUnmount above. 57632 // If we don't use mutation we drill down into portals here instead. 57633 node.tag !== HostPortal)) { 57634 node.child.return = node; 57635 node = node.child; 57636 continue; 57637 } 57638 57639 if (node === root) { 57640 return; 57641 } 57642 57643 while (node.sibling === null) { 57644 if (node.return === null || node.return === root) { 57645 return; 57646 } 57647 57648 node = node.return; 57649 } 57650 57651 node.sibling.return = node.return; 57652 node = node.sibling; 57653 } 57654} 57655 57656function detachFiber(current) { 57657 var alternate = current.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we 57658 // should clear the child pointer of the parent alternate to let this 57659 // get GC:ed but we don't know which for sure which parent is the current 57660 // one so we'll settle for GC:ing the subtree of this child. This child 57661 // itself will be GC:ed when the parent updates the next time. 57662 57663 current.return = null; 57664 current.child = null; 57665 current.memoizedState = null; 57666 current.updateQueue = null; 57667 current.dependencies = null; 57668 current.alternate = null; 57669 current.firstEffect = null; 57670 current.lastEffect = null; 57671 current.pendingProps = null; 57672 current.memoizedProps = null; 57673 current.stateNode = null; 57674 57675 if (alternate !== null) { 57676 detachFiber(alternate); 57677 } 57678} 57679 57680function getHostParentFiber(fiber) { 57681 var parent = fiber.return; 57682 57683 while (parent !== null) { 57684 if (isHostParent(parent)) { 57685 return parent; 57686 } 57687 57688 parent = parent.return; 57689 } 57690 57691 { 57692 { 57693 throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); 57694 } 57695 } 57696} 57697 57698function isHostParent(fiber) { 57699 return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal; 57700} 57701 57702function getHostSibling(fiber) { 57703 // We're going to search forward into the tree until we find a sibling host 57704 // node. Unfortunately, if multiple insertions are done in a row we have to 57705 // search past them. This leads to exponential search for the next sibling. 57706 // TODO: Find a more efficient way to do this. 57707 var node = fiber; 57708 57709 siblings: while (true) { 57710 // If we didn't find anything, let's try the next sibling. 57711 while (node.sibling === null) { 57712 if (node.return === null || isHostParent(node.return)) { 57713 // If we pop out of the root or hit the parent the fiber we are the 57714 // last sibling. 57715 return null; 57716 } 57717 57718 node = node.return; 57719 } 57720 57721 node.sibling.return = node.return; 57722 node = node.sibling; 57723 57724 while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) { 57725 // If it is not host node and, we might have a host node inside it. 57726 // Try to search down until we find one. 57727 if (node.effectTag & Placement) { 57728 // If we don't have a child, try the siblings instead. 57729 continue siblings; 57730 } // If we don't have a child, try the siblings instead. 57731 // We also skip portals because they are not part of this host tree. 57732 57733 57734 if (node.child === null || node.tag === HostPortal) { 57735 continue siblings; 57736 } else { 57737 node.child.return = node; 57738 node = node.child; 57739 } 57740 } // Check if this host node is stable or about to be placed. 57741 57742 57743 if (!(node.effectTag & Placement)) { 57744 // Found it! 57745 return node.stateNode; 57746 } 57747 } 57748} 57749 57750function commitPlacement(finishedWork) { 57751 57752 57753 var parentFiber = getHostParentFiber(finishedWork); // Note: these two variables *must* always be updated together. 57754 57755 var parent; 57756 var isContainer; 57757 var parentStateNode = parentFiber.stateNode; 57758 57759 switch (parentFiber.tag) { 57760 case HostComponent: 57761 parent = parentStateNode; 57762 isContainer = false; 57763 break; 57764 57765 case HostRoot: 57766 parent = parentStateNode.containerInfo; 57767 isContainer = true; 57768 break; 57769 57770 case HostPortal: 57771 parent = parentStateNode.containerInfo; 57772 isContainer = true; 57773 break; 57774 57775 case FundamentalComponent: 57776 57777 // eslint-disable-next-line-no-fallthrough 57778 57779 default: 57780 { 57781 { 57782 throw Error( "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); 57783 } 57784 } 57785 57786 } 57787 57788 if (parentFiber.effectTag & ContentReset) { 57789 // Reset the text content of the parent before doing any insertions 57790 resetTextContent(parent); // Clear ContentReset from the effect tag 57791 57792 parentFiber.effectTag &= ~ContentReset; 57793 } 57794 57795 var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its 57796 // children to find all the terminal nodes. 57797 57798 if (isContainer) { 57799 insertOrAppendPlacementNodeIntoContainer(finishedWork, before, parent); 57800 } else { 57801 insertOrAppendPlacementNode(finishedWork, before, parent); 57802 } 57803} 57804 57805function insertOrAppendPlacementNodeIntoContainer(node, before, parent) { 57806 var tag = node.tag; 57807 var isHost = tag === HostComponent || tag === HostText; 57808 57809 if (isHost || enableFundamentalAPI ) { 57810 var stateNode = isHost ? node.stateNode : node.stateNode.instance; 57811 57812 if (before) { 57813 insertInContainerBefore(parent, stateNode, before); 57814 } else { 57815 appendChildToContainer(parent, stateNode); 57816 } 57817 } else if (tag === HostPortal) ; else { 57818 var child = node.child; 57819 57820 if (child !== null) { 57821 insertOrAppendPlacementNodeIntoContainer(child, before, parent); 57822 var sibling = child.sibling; 57823 57824 while (sibling !== null) { 57825 insertOrAppendPlacementNodeIntoContainer(sibling, before, parent); 57826 sibling = sibling.sibling; 57827 } 57828 } 57829 } 57830} 57831 57832function insertOrAppendPlacementNode(node, before, parent) { 57833 var tag = node.tag; 57834 var isHost = tag === HostComponent || tag === HostText; 57835 57836 if (isHost || enableFundamentalAPI ) { 57837 var stateNode = isHost ? node.stateNode : node.stateNode.instance; 57838 57839 if (before) { 57840 insertBefore(parent, stateNode, before); 57841 } else { 57842 appendChild(parent, stateNode); 57843 } 57844 } else if (tag === HostPortal) ; else { 57845 var child = node.child; 57846 57847 if (child !== null) { 57848 insertOrAppendPlacementNode(child, before, parent); 57849 var sibling = child.sibling; 57850 57851 while (sibling !== null) { 57852 insertOrAppendPlacementNode(sibling, before, parent); 57853 sibling = sibling.sibling; 57854 } 57855 } 57856 } 57857} 57858 57859function unmountHostComponents(finishedRoot, current, renderPriorityLevel) { 57860 // We only have the top Fiber that was deleted but we need to recurse down its 57861 // children to find all the terminal nodes. 57862 var node = current; // Each iteration, currentParent is populated with node's host parent if not 57863 // currentParentIsValid. 57864 57865 var currentParentIsValid = false; // Note: these two variables *must* always be updated together. 57866 57867 var currentParent; 57868 var currentParentIsContainer; 57869 57870 while (true) { 57871 if (!currentParentIsValid) { 57872 var parent = node.return; 57873 57874 findParent: while (true) { 57875 if (!(parent !== null)) { 57876 { 57877 throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); 57878 } 57879 } 57880 57881 var parentStateNode = parent.stateNode; 57882 57883 switch (parent.tag) { 57884 case HostComponent: 57885 currentParent = parentStateNode; 57886 currentParentIsContainer = false; 57887 break findParent; 57888 57889 case HostRoot: 57890 currentParent = parentStateNode.containerInfo; 57891 currentParentIsContainer = true; 57892 break findParent; 57893 57894 case HostPortal: 57895 currentParent = parentStateNode.containerInfo; 57896 currentParentIsContainer = true; 57897 break findParent; 57898 57899 } 57900 57901 parent = parent.return; 57902 } 57903 57904 currentParentIsValid = true; 57905 } 57906 57907 if (node.tag === HostComponent || node.tag === HostText) { 57908 commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the 57909 // node from the tree. 57910 57911 if (currentParentIsContainer) { 57912 removeChildFromContainer(currentParent, node.stateNode); 57913 } else { 57914 removeChild(currentParent, node.stateNode); 57915 } // Don't visit children because we already visited them. 57916 57917 } else if (node.tag === HostPortal) { 57918 if (node.child !== null) { 57919 // When we go into a portal, it becomes the parent to remove from. 57920 // We will reassign it back when we pop the portal on the way up. 57921 currentParent = node.stateNode.containerInfo; 57922 currentParentIsContainer = true; // Visit children because portals might contain host components. 57923 57924 node.child.return = node; 57925 node = node.child; 57926 continue; 57927 } 57928 } else { 57929 commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because we may find more host components below. 57930 57931 if (node.child !== null) { 57932 node.child.return = node; 57933 node = node.child; 57934 continue; 57935 } 57936 } 57937 57938 if (node === current) { 57939 return; 57940 } 57941 57942 while (node.sibling === null) { 57943 if (node.return === null || node.return === current) { 57944 return; 57945 } 57946 57947 node = node.return; 57948 57949 if (node.tag === HostPortal) { 57950 // When we go out of the portal, we need to restore the parent. 57951 // Since we don't keep a stack of them, we will search for it. 57952 currentParentIsValid = false; 57953 } 57954 } 57955 57956 node.sibling.return = node.return; 57957 node = node.sibling; 57958 } 57959} 57960 57961function commitDeletion(finishedRoot, current, renderPriorityLevel) { 57962 { 57963 // Recursively delete all host nodes from the parent. 57964 // Detach refs and call componentWillUnmount() on the whole subtree. 57965 unmountHostComponents(finishedRoot, current, renderPriorityLevel); 57966 } 57967 57968 detachFiber(current); 57969} 57970 57971function commitWork(current, finishedWork) { 57972 57973 switch (finishedWork.tag) { 57974 case FunctionComponent: 57975 case ForwardRef: 57976 case MemoComponent: 57977 case SimpleMemoComponent: 57978 case Block: 57979 { 57980 // Layout effects are destroyed during the mutation phase so that all 57981 // destroy functions for all fibers are called before any create functions. 57982 // This prevents sibling component effects from interfering with each other, 57983 // e.g. a destroy function in one component should never override a ref set 57984 // by a create function in another component during the same commit. 57985 commitHookEffectListUnmount(Layout | HasEffect, finishedWork); 57986 return; 57987 } 57988 57989 case ClassComponent: 57990 { 57991 return; 57992 } 57993 57994 case HostComponent: 57995 { 57996 var instance = finishedWork.stateNode; 57997 57998 if (instance != null) { 57999 // Commit the work prepared earlier. 58000 var newProps = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps 58001 // as the newProps. The updatePayload will contain the real change in 58002 // this case. 58003 58004 var oldProps = current !== null ? current.memoizedProps : newProps; 58005 var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components. 58006 58007 var updatePayload = finishedWork.updateQueue; 58008 finishedWork.updateQueue = null; 58009 58010 if (updatePayload !== null) { 58011 commitUpdate(instance, updatePayload, type, oldProps, newProps); 58012 } 58013 } 58014 58015 return; 58016 } 58017 58018 case HostText: 58019 { 58020 if (!(finishedWork.stateNode !== null)) { 58021 { 58022 throw Error( "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." ); 58023 } 58024 } 58025 58026 var textInstance = finishedWork.stateNode; 58027 var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps 58028 // as the newProps. The updatePayload will contain the real change in 58029 // this case. 58030 58031 var oldText = current !== null ? current.memoizedProps : newText; 58032 commitTextUpdate(textInstance, oldText, newText); 58033 return; 58034 } 58035 58036 case HostRoot: 58037 { 58038 { 58039 var _root = finishedWork.stateNode; 58040 58041 if (_root.hydrate) { 58042 // We've just hydrated. No need to hydrate again. 58043 _root.hydrate = false; 58044 commitHydratedContainer(_root.containerInfo); 58045 } 58046 } 58047 58048 return; 58049 } 58050 58051 case Profiler: 58052 { 58053 return; 58054 } 58055 58056 case SuspenseComponent: 58057 { 58058 commitSuspenseComponent(finishedWork); 58059 attachSuspenseRetryListeners(finishedWork); 58060 return; 58061 } 58062 58063 case SuspenseListComponent: 58064 { 58065 attachSuspenseRetryListeners(finishedWork); 58066 return; 58067 } 58068 58069 case IncompleteClassComponent: 58070 { 58071 return; 58072 } 58073 } 58074 58075 { 58076 { 58077 throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); 58078 } 58079 } 58080} 58081 58082function commitSuspenseComponent(finishedWork) { 58083 var newState = finishedWork.memoizedState; 58084 var newDidTimeout; 58085 var primaryChildParent = finishedWork; 58086 58087 if (newState === null) { 58088 newDidTimeout = false; 58089 } else { 58090 newDidTimeout = true; 58091 primaryChildParent = finishedWork.child; 58092 markCommitTimeOfFallback(); 58093 } 58094 58095 if ( primaryChildParent !== null) { 58096 hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); 58097 } 58098} 58099 58100function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) { 58101 58102 var newState = finishedWork.memoizedState; 58103 58104 if (newState === null) { 58105 var current = finishedWork.alternate; 58106 58107 if (current !== null) { 58108 var prevState = current.memoizedState; 58109 58110 if (prevState !== null) { 58111 var suspenseInstance = prevState.dehydrated; 58112 58113 if (suspenseInstance !== null) { 58114 commitHydratedSuspenseInstance(suspenseInstance); 58115 } 58116 } 58117 } 58118 } 58119} 58120 58121function attachSuspenseRetryListeners(finishedWork) { 58122 // If this boundary just timed out, then it will have a set of thenables. 58123 // For each thenable, attach a listener so that when it resolves, React 58124 // attempts to re-render the boundary in the primary (pre-timeout) state. 58125 var thenables = finishedWork.updateQueue; 58126 58127 if (thenables !== null) { 58128 finishedWork.updateQueue = null; 58129 var retryCache = finishedWork.stateNode; 58130 58131 if (retryCache === null) { 58132 retryCache = finishedWork.stateNode = new PossiblyWeakSet(); 58133 } 58134 58135 thenables.forEach(function (thenable) { 58136 // Memoize using the boundary fiber to prevent redundant listeners. 58137 var retry = resolveRetryThenable.bind(null, finishedWork, thenable); 58138 58139 if (!retryCache.has(thenable)) { 58140 { 58141 if (thenable.__reactDoNotTraceInteractions !== true) { 58142 retry = tracing.unstable_wrap(retry); 58143 } 58144 } 58145 58146 retryCache.add(thenable); 58147 thenable.then(retry, retry); 58148 } 58149 }); 58150 } 58151} 58152 58153function commitResetTextContent(current) { 58154 58155 resetTextContent(current.stateNode); 58156} 58157 58158var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map; 58159 58160function createRootErrorUpdate(fiber, errorInfo, expirationTime) { 58161 var update = createUpdate(expirationTime, null); // Unmount the root by rendering null. 58162 58163 update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property 58164 // being called "element". 58165 58166 update.payload = { 58167 element: null 58168 }; 58169 var error = errorInfo.value; 58170 58171 update.callback = function () { 58172 onUncaughtError(error); 58173 logError(fiber, errorInfo); 58174 }; 58175 58176 return update; 58177} 58178 58179function createClassErrorUpdate(fiber, errorInfo, expirationTime) { 58180 var update = createUpdate(expirationTime, null); 58181 update.tag = CaptureUpdate; 58182 var getDerivedStateFromError = fiber.type.getDerivedStateFromError; 58183 58184 if (typeof getDerivedStateFromError === 'function') { 58185 var error$1 = errorInfo.value; 58186 58187 update.payload = function () { 58188 logError(fiber, errorInfo); 58189 return getDerivedStateFromError(error$1); 58190 }; 58191 } 58192 58193 var inst = fiber.stateNode; 58194 58195 if (inst !== null && typeof inst.componentDidCatch === 'function') { 58196 update.callback = function callback() { 58197 { 58198 markFailedErrorBoundaryForHotReloading(fiber); 58199 } 58200 58201 if (typeof getDerivedStateFromError !== 'function') { 58202 // To preserve the preexisting retry behavior of error boundaries, 58203 // we keep track of which ones already failed during this batch. 58204 // This gets reset before we yield back to the browser. 58205 // TODO: Warn in strict mode if getDerivedStateFromError is 58206 // not defined. 58207 markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined 58208 58209 logError(fiber, errorInfo); 58210 } 58211 58212 var error$1 = errorInfo.value; 58213 var stack = errorInfo.stack; 58214 this.componentDidCatch(error$1, { 58215 componentStack: stack !== null ? stack : '' 58216 }); 58217 58218 { 58219 if (typeof getDerivedStateFromError !== 'function') { 58220 // If componentDidCatch is the only error boundary method defined, 58221 // then it needs to call setState to recover from errors. 58222 // If no state update is scheduled then the boundary will swallow the error. 58223 if (fiber.expirationTime !== Sync) { 58224 error('%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown'); 58225 } 58226 } 58227 } 58228 }; 58229 } else { 58230 update.callback = function () { 58231 markFailedErrorBoundaryForHotReloading(fiber); 58232 }; 58233 } 58234 58235 return update; 58236} 58237 58238function attachPingListener(root, renderExpirationTime, thenable) { 58239 // Attach a listener to the promise to "ping" the root and retry. But 58240 // only if one does not already exist for the current render expiration 58241 // time (which acts like a "thread ID" here). 58242 var pingCache = root.pingCache; 58243 var threadIDs; 58244 58245 if (pingCache === null) { 58246 pingCache = root.pingCache = new PossiblyWeakMap$1(); 58247 threadIDs = new Set(); 58248 pingCache.set(thenable, threadIDs); 58249 } else { 58250 threadIDs = pingCache.get(thenable); 58251 58252 if (threadIDs === undefined) { 58253 threadIDs = new Set(); 58254 pingCache.set(thenable, threadIDs); 58255 } 58256 } 58257 58258 if (!threadIDs.has(renderExpirationTime)) { 58259 // Memoize using the thread ID to prevent redundant listeners. 58260 threadIDs.add(renderExpirationTime); 58261 var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime); 58262 thenable.then(ping, ping); 58263 } 58264} 58265 58266function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) { 58267 // The source fiber did not complete. 58268 sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid. 58269 58270 sourceFiber.firstEffect = sourceFiber.lastEffect = null; 58271 58272 if (value !== null && typeof value === 'object' && typeof value.then === 'function') { 58273 // This is a thenable. 58274 var thenable = value; 58275 58276 if ((sourceFiber.mode & BlockingMode) === NoMode) { 58277 // Reset the memoizedState to what it was before we attempted 58278 // to render it. 58279 var currentSource = sourceFiber.alternate; 58280 58281 if (currentSource) { 58282 sourceFiber.updateQueue = currentSource.updateQueue; 58283 sourceFiber.memoizedState = currentSource.memoizedState; 58284 sourceFiber.expirationTime = currentSource.expirationTime; 58285 } else { 58286 sourceFiber.updateQueue = null; 58287 sourceFiber.memoizedState = null; 58288 } 58289 } 58290 58291 var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext); // Schedule the nearest Suspense to re-render the timed out view. 58292 58293 var _workInProgress = returnFiber; 58294 58295 do { 58296 if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) { 58297 // Found the nearest boundary. 58298 // Stash the promise on the boundary fiber. If the boundary times out, we'll 58299 // attach another listener to flip the boundary back to its normal state. 58300 var thenables = _workInProgress.updateQueue; 58301 58302 if (thenables === null) { 58303 var updateQueue = new Set(); 58304 updateQueue.add(thenable); 58305 _workInProgress.updateQueue = updateQueue; 58306 } else { 58307 thenables.add(thenable); 58308 } // If the boundary is outside of blocking mode, we should *not* 58309 // suspend the commit. Pretend as if the suspended component rendered 58310 // null and keep rendering. In the commit phase, we'll schedule a 58311 // subsequent synchronous update to re-render the Suspense. 58312 // 58313 // Note: It doesn't matter whether the component that suspended was 58314 // inside a blocking mode tree. If the Suspense is outside of it, we 58315 // should *not* suspend the commit. 58316 58317 58318 if ((_workInProgress.mode & BlockingMode) === NoMode) { 58319 _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete. 58320 // But we shouldn't call any lifecycle methods or callbacks. Remove 58321 // all lifecycle effect tags. 58322 58323 sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete); 58324 58325 if (sourceFiber.tag === ClassComponent) { 58326 var currentSourceFiber = sourceFiber.alternate; 58327 58328 if (currentSourceFiber === null) { 58329 // This is a new mount. Change the tag so it's not mistaken for a 58330 // completed class component. For example, we should not call 58331 // componentWillUnmount if it is deleted. 58332 sourceFiber.tag = IncompleteClassComponent; 58333 } else { 58334 // When we try rendering again, we should not reuse the current fiber, 58335 // since it's known to be in an inconsistent state. Use a force update to 58336 // prevent a bail out. 58337 var update = createUpdate(Sync, null); 58338 update.tag = ForceUpdate; 58339 enqueueUpdate(sourceFiber, update); 58340 } 58341 } // The source fiber did not complete. Mark it with Sync priority to 58342 // indicate that it still has pending work. 58343 58344 58345 sourceFiber.expirationTime = Sync; // Exit without suspending. 58346 58347 return; 58348 } // Confirmed that the boundary is in a concurrent mode tree. Continue 58349 // with the normal suspend path. 58350 // 58351 // After this we'll use a set of heuristics to determine whether this 58352 // render pass will run to completion or restart or "suspend" the commit. 58353 // The actual logic for this is spread out in different places. 58354 // 58355 // This first principle is that if we're going to suspend when we complete 58356 // a root, then we should also restart if we get an update or ping that 58357 // might unsuspend it, and vice versa. The only reason to suspend is 58358 // because you think you might want to restart before committing. However, 58359 // it doesn't make sense to restart only while in the period we're suspended. 58360 // 58361 // Restarting too aggressively is also not good because it starves out any 58362 // intermediate loading state. So we use heuristics to determine when. 58363 // Suspense Heuristics 58364 // 58365 // If nothing threw a Promise or all the same fallbacks are already showing, 58366 // then don't suspend/restart. 58367 // 58368 // If this is an initial render of a new tree of Suspense boundaries and 58369 // those trigger a fallback, then don't suspend/restart. We want to ensure 58370 // that we can show the initial loading state as quickly as possible. 58371 // 58372 // If we hit a "Delayed" case, such as when we'd switch from content back into 58373 // a fallback, then we should always suspend/restart. SuspenseConfig applies to 58374 // this case. If none is defined, JND is used instead. 58375 // 58376 // If we're already showing a fallback and it gets "retried", allowing us to show 58377 // another level, but there's still an inner boundary that would show a fallback, 58378 // then we suspend/restart for 500ms since the last time we showed a fallback 58379 // anywhere in the tree. This effectively throttles progressive loading into a 58380 // consistent train of commits. This also gives us an opportunity to restart to 58381 // get to the completed state slightly earlier. 58382 // 58383 // If there's ambiguity due to batching it's resolved in preference of: 58384 // 1) "delayed", 2) "initial render", 3) "retry". 58385 // 58386 // We want to ensure that a "busy" state doesn't get force committed. We want to 58387 // ensure that new initial loading states can commit as soon as possible. 58388 58389 58390 attachPingListener(root, renderExpirationTime, thenable); 58391 _workInProgress.effectTag |= ShouldCapture; 58392 _workInProgress.expirationTime = renderExpirationTime; 58393 return; 58394 } // This boundary already captured during this render. Continue to the next 58395 // boundary. 58396 58397 58398 _workInProgress = _workInProgress.return; 58399 } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. 58400 // TODO: Use invariant so the message is stripped in prod? 58401 58402 58403 value = new Error((getComponentName(sourceFiber.type) || 'A React component') + ' suspended while rendering, but no fallback UI was specified.\n' + '\n' + 'Add a <Suspense fallback=...> component higher in the tree to ' + 'provide a loading indicator or placeholder to display.' + getStackByFiberInDevAndProd(sourceFiber)); 58404 } // We didn't find a boundary that could handle this type of exception. Start 58405 // over and traverse parent path again, this time treating the exception 58406 // as an error. 58407 58408 58409 renderDidError(); 58410 value = createCapturedValue(value, sourceFiber); 58411 var workInProgress = returnFiber; 58412 58413 do { 58414 switch (workInProgress.tag) { 58415 case HostRoot: 58416 { 58417 var _errorInfo = value; 58418 workInProgress.effectTag |= ShouldCapture; 58419 workInProgress.expirationTime = renderExpirationTime; 58420 58421 var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime); 58422 58423 enqueueCapturedUpdate(workInProgress, _update); 58424 return; 58425 } 58426 58427 case ClassComponent: 58428 // Capture and retry 58429 var errorInfo = value; 58430 var ctor = workInProgress.type; 58431 var instance = workInProgress.stateNode; 58432 58433 if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) { 58434 workInProgress.effectTag |= ShouldCapture; 58435 workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state 58436 58437 var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime); 58438 58439 enqueueCapturedUpdate(workInProgress, _update2); 58440 return; 58441 } 58442 58443 break; 58444 } 58445 58446 workInProgress = workInProgress.return; 58447 } while (workInProgress !== null); 58448} 58449 58450var ceil = Math.ceil; 58451var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, 58452 ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, 58453 IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; 58454var NoContext = 58455/* */ 584560; 58457var BatchedContext = 58458/* */ 584591; 58460var EventContext = 58461/* */ 584622; 58463var DiscreteEventContext = 58464/* */ 584654; 58466var LegacyUnbatchedContext = 58467/* */ 584688; 58469var RenderContext = 58470/* */ 5847116; 58472var CommitContext = 58473/* */ 5847432; 58475var RootIncomplete = 0; 58476var RootFatalErrored = 1; 58477var RootErrored = 2; 58478var RootSuspended = 3; 58479var RootSuspendedWithDelay = 4; 58480var RootCompleted = 5; 58481// Describes where we are in the React execution stack 58482var executionContext = NoContext; // The root we're working on 58483 58484var workInProgressRoot = null; // The fiber we're working on 58485 58486var workInProgress = null; // The expiration time we're rendering 58487 58488var renderExpirationTime$1 = NoWork; // Whether to root completed, errored, suspended, etc. 58489 58490var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown 58491 58492var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render. 58493// This is conceptually a time stamp but expressed in terms of an ExpirationTime 58494// because we deal mostly with expiration times in the hot path, so this avoids 58495// the conversion happening in the hot path. 58496 58497var workInProgressRootLatestProcessedExpirationTime = Sync; 58498var workInProgressRootLatestSuspenseTimeout = Sync; 58499var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only 58500// includes unprocessed updates, not work in bailed out children. 58501 58502var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately. 58503// This flag determines if it might be worthwhile to restart if an opportunity 58504// happens latere. 58505 58506var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train 58507// model where we don't commit new loading states in too quick succession. 58508 58509var globalMostRecentFallbackTime = 0; 58510var FALLBACK_THROTTLE_MS = 500; 58511var nextEffect = null; 58512var hasUncaughtError = false; 58513var firstUncaughtError = null; 58514var legacyErrorBoundariesThatAlreadyFailed = null; 58515var rootDoesHavePassiveEffects = false; 58516var rootWithPendingPassiveEffects = null; 58517var pendingPassiveEffectsRenderPriority = NoPriority; 58518var pendingPassiveEffectsExpirationTime = NoWork; 58519var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates 58520 58521var NESTED_UPDATE_LIMIT = 50; 58522var nestedUpdateCount = 0; 58523var rootWithNestedUpdates = null; 58524var NESTED_PASSIVE_UPDATE_LIMIT = 50; 58525var nestedPassiveUpdateCount = 0; 58526var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times 58527// during the commit phase. This enables them to be traced across components 58528// that spawn new work during render. E.g. hidden boundaries, suspended SSR 58529// hydration or SuspenseList. 58530 58531var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start 58532// time). However, if two updates are scheduled within the same event, we 58533// should treat their start times as simultaneous, even if the actual clock 58534// time has advanced between the first and second call. 58535// In other words, because expiration times determine how updates are batched, 58536// we want all updates of like priority that occur within the same event to 58537// receive the same expiration time. Otherwise we get tearing. 58538 58539var currentEventTime = NoWork; 58540function requestCurrentTimeForUpdate() { 58541 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { 58542 // We're inside React, so it's fine to read the actual time. 58543 return msToExpirationTime(now()); 58544 } // We're not inside React, so we may be in the middle of a browser event. 58545 58546 58547 if (currentEventTime !== NoWork) { 58548 // Use the same start time for all updates until we enter React again. 58549 return currentEventTime; 58550 } // This is the first update since React yielded. Compute a new start time. 58551 58552 58553 currentEventTime = msToExpirationTime(now()); 58554 return currentEventTime; 58555} 58556function getCurrentTime() { 58557 return msToExpirationTime(now()); 58558} 58559function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { 58560 var mode = fiber.mode; 58561 58562 if ((mode & BlockingMode) === NoMode) { 58563 return Sync; 58564 } 58565 58566 var priorityLevel = getCurrentPriorityLevel(); 58567 58568 if ((mode & ConcurrentMode) === NoMode) { 58569 return priorityLevel === ImmediatePriority ? Sync : Batched; 58570 } 58571 58572 if ((executionContext & RenderContext) !== NoContext) { 58573 // Use whatever time we're already rendering 58574 // TODO: Should there be a way to opt out, like with `runWithPriority`? 58575 return renderExpirationTime$1; 58576 } 58577 58578 var expirationTime; 58579 58580 if (suspenseConfig !== null) { 58581 // Compute an expiration time based on the Suspense timeout. 58582 expirationTime = computeSuspenseExpiration(currentTime, suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION); 58583 } else { 58584 // Compute an expiration time based on the Scheduler priority. 58585 switch (priorityLevel) { 58586 case ImmediatePriority: 58587 expirationTime = Sync; 58588 break; 58589 58590 case UserBlockingPriority$1: 58591 // TODO: Rename this to computeUserBlockingExpiration 58592 expirationTime = computeInteractiveExpiration(currentTime); 58593 break; 58594 58595 case NormalPriority: 58596 case LowPriority: 58597 // TODO: Handle LowPriority 58598 // TODO: Rename this to... something better. 58599 expirationTime = computeAsyncExpiration(currentTime); 58600 break; 58601 58602 case IdlePriority: 58603 expirationTime = Idle; 58604 break; 58605 58606 default: 58607 { 58608 { 58609 throw Error( "Expected a valid priority level" ); 58610 } 58611 } 58612 58613 } 58614 } // If we're in the middle of rendering a tree, do not update at the same 58615 // expiration time that is already rendering. 58616 // TODO: We shouldn't have to do this if the update is on a different root. 58617 // Refactor computeExpirationForFiber + scheduleUpdate so we have access to 58618 // the root when we check for this condition. 58619 58620 58621 if (workInProgressRoot !== null && expirationTime === renderExpirationTime$1) { 58622 // This is a trick to move this update into a separate batch 58623 expirationTime -= 1; 58624 } 58625 58626 return expirationTime; 58627} 58628function scheduleUpdateOnFiber(fiber, expirationTime) { 58629 checkForNestedUpdates(); 58630 warnAboutRenderPhaseUpdatesInDEV(fiber); 58631 var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime); 58632 58633 if (root === null) { 58634 warnAboutUpdateOnUnmountedFiberInDEV(fiber); 58635 return; 58636 } 58637 58638 checkForInterruption(fiber, expirationTime); 58639 recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the 58640 // priority as an argument to that function and this one. 58641 58642 var priorityLevel = getCurrentPriorityLevel(); 58643 58644 if (expirationTime === Sync) { 58645 if ( // Check if we're inside unbatchedUpdates 58646 (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering 58647 (executionContext & (RenderContext | CommitContext)) === NoContext) { 58648 // Register pending interactions on the root to avoid losing traced interaction data. 58649 schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed 58650 // root inside of batchedUpdates should be synchronous, but layout updates 58651 // should be deferred until the end of the batch. 58652 58653 performSyncWorkOnRoot(root); 58654 } else { 58655 ensureRootIsScheduled(root); 58656 schedulePendingInteractions(root, expirationTime); 58657 58658 if (executionContext === NoContext) { 58659 // Flush the synchronous work now, unless we're already working or inside 58660 // a batch. This is intentionally inside scheduleUpdateOnFiber instead of 58661 // scheduleCallbackForFiber to preserve the ability to schedule a callback 58662 // without immediately flushing it. We only do this for user-initiated 58663 // updates, to preserve historical behavior of legacy mode. 58664 flushSyncCallbackQueue(); 58665 } 58666 } 58667 } else { 58668 ensureRootIsScheduled(root); 58669 schedulePendingInteractions(root, expirationTime); 58670 } 58671 58672 if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered 58673 // discrete, even inside a discrete event. 58674 priorityLevel === UserBlockingPriority$1 || priorityLevel === ImmediatePriority)) { 58675 // This is the result of a discrete event. Track the lowest priority 58676 // discrete update per root so we can flush them early, if needed. 58677 if (rootsWithPendingDiscreteUpdates === null) { 58678 rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]); 58679 } else { 58680 var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root); 58681 58682 if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) { 58683 rootsWithPendingDiscreteUpdates.set(root, expirationTime); 58684 } 58685 } 58686 } 58687} 58688var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending 58689// work without treating it as a typical update that originates from an event; 58690// e.g. retrying a Suspense boundary isn't an update, but it does schedule work 58691// on a fiber. 58692 58693function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { 58694 // Update the source fiber's expiration time 58695 if (fiber.expirationTime < expirationTime) { 58696 fiber.expirationTime = expirationTime; 58697 } 58698 58699 var alternate = fiber.alternate; 58700 58701 if (alternate !== null && alternate.expirationTime < expirationTime) { 58702 alternate.expirationTime = expirationTime; 58703 } // Walk the parent path to the root and update the child expiration time. 58704 58705 58706 var node = fiber.return; 58707 var root = null; 58708 58709 if (node === null && fiber.tag === HostRoot) { 58710 root = fiber.stateNode; 58711 } else { 58712 while (node !== null) { 58713 alternate = node.alternate; 58714 58715 if (node.childExpirationTime < expirationTime) { 58716 node.childExpirationTime = expirationTime; 58717 58718 if (alternate !== null && alternate.childExpirationTime < expirationTime) { 58719 alternate.childExpirationTime = expirationTime; 58720 } 58721 } else if (alternate !== null && alternate.childExpirationTime < expirationTime) { 58722 alternate.childExpirationTime = expirationTime; 58723 } 58724 58725 if (node.return === null && node.tag === HostRoot) { 58726 root = node.stateNode; 58727 break; 58728 } 58729 58730 node = node.return; 58731 } 58732 } 58733 58734 if (root !== null) { 58735 if (workInProgressRoot === root) { 58736 // Received an update to a tree that's in the middle of rendering. Mark 58737 // that's unprocessed work on this root. 58738 markUnprocessedUpdateTime(expirationTime); 58739 58740 if (workInProgressRootExitStatus === RootSuspendedWithDelay) { 58741 // The root already suspended with a delay, which means this render 58742 // definitely won't finish. Since we have a new update, let's mark it as 58743 // suspended now, right before marking the incoming update. This has the 58744 // effect of interrupting the current render and switching to the update. 58745 // TODO: This happens to work when receiving an update during the render 58746 // phase, because of the trick inside computeExpirationForFiber to 58747 // subtract 1 from `renderExpirationTime` to move it into a 58748 // separate bucket. But we should probably model it with an exception, 58749 // using the same mechanism we use to force hydration of a subtree. 58750 // TODO: This does not account for low pri updates that were already 58751 // scheduled before the root started rendering. Need to track the next 58752 // pending expiration time (perhaps by backtracking the return path) and 58753 // then trigger a restart in the `renderDidSuspendDelayIfPossible` path. 58754 markRootSuspendedAtTime(root, renderExpirationTime$1); 58755 } 58756 } // Mark that the root has a pending update. 58757 58758 58759 markRootUpdatedAtTime(root, expirationTime); 58760 } 58761 58762 return root; 58763} 58764 58765function getNextRootExpirationTimeToWorkOn(root) { 58766 // Determines the next expiration time that the root should render, taking 58767 // into account levels that may be suspended, or levels that may have 58768 // received a ping. 58769 var lastExpiredTime = root.lastExpiredTime; 58770 58771 if (lastExpiredTime !== NoWork) { 58772 return lastExpiredTime; 58773 } // "Pending" refers to any update that hasn't committed yet, including if it 58774 // suspended. The "suspended" range is therefore a subset. 58775 58776 58777 var firstPendingTime = root.firstPendingTime; 58778 58779 if (!isRootSuspendedAtTime(root, firstPendingTime)) { 58780 // The highest priority pending time is not suspended. Let's work on that. 58781 return firstPendingTime; 58782 } // If the first pending time is suspended, check if there's a lower priority 58783 // pending level that we know about. Or check if we received a ping. Work 58784 // on whichever is higher priority. 58785 58786 58787 var lastPingedTime = root.lastPingedTime; 58788 var nextKnownPendingLevel = root.nextKnownPendingLevel; 58789 var nextLevel = lastPingedTime > nextKnownPendingLevel ? lastPingedTime : nextKnownPendingLevel; 58790 58791 if ( nextLevel <= Idle && firstPendingTime !== nextLevel) { 58792 // Don't work on Idle/Never priority unless everything else is committed. 58793 return NoWork; 58794 } 58795 58796 return nextLevel; 58797} // Use this function to schedule a task for a root. There's only one task per 58798// root; if a task was already scheduled, we'll check to make sure the 58799// expiration time of the existing task is the same as the expiration time of 58800// the next level that the root has work on. This function is called on every 58801// update, and right before exiting a task. 58802 58803 58804function ensureRootIsScheduled(root) { 58805 var lastExpiredTime = root.lastExpiredTime; 58806 58807 if (lastExpiredTime !== NoWork) { 58808 // Special case: Expired work should flush synchronously. 58809 root.callbackExpirationTime = Sync; 58810 root.callbackPriority = ImmediatePriority; 58811 root.callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); 58812 return; 58813 } 58814 58815 var expirationTime = getNextRootExpirationTimeToWorkOn(root); 58816 var existingCallbackNode = root.callbackNode; 58817 58818 if (expirationTime === NoWork) { 58819 // There's nothing to work on. 58820 if (existingCallbackNode !== null) { 58821 root.callbackNode = null; 58822 root.callbackExpirationTime = NoWork; 58823 root.callbackPriority = NoPriority; 58824 } 58825 58826 return; 58827 } // TODO: If this is an update, we already read the current time. Pass the 58828 // time as an argument. 58829 58830 58831 var currentTime = requestCurrentTimeForUpdate(); 58832 var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime); // If there's an existing render task, confirm it has the correct priority and 58833 // expiration time. Otherwise, we'll cancel it and schedule a new one. 58834 58835 if (existingCallbackNode !== null) { 58836 var existingCallbackPriority = root.callbackPriority; 58837 var existingCallbackExpirationTime = root.callbackExpirationTime; 58838 58839 if ( // Callback must have the exact same expiration time. 58840 existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority. 58841 existingCallbackPriority >= priorityLevel) { 58842 // Existing callback is sufficient. 58843 return; 58844 } // Need to schedule a new task. 58845 // TODO: Instead of scheduling a new task, we should be able to change the 58846 // priority of the existing one. 58847 58848 58849 cancelCallback(existingCallbackNode); 58850 } 58851 58852 root.callbackExpirationTime = expirationTime; 58853 root.callbackPriority = priorityLevel; 58854 var callbackNode; 58855 58856 if (expirationTime === Sync) { 58857 // Sync React callbacks are scheduled on a special internal queue 58858 callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); 58859 } else { 58860 callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects 58861 // ordering because tasks are processed in timeout order. 58862 { 58863 timeout: expirationTimeToMs(expirationTime) - now() 58864 }); 58865 } 58866 58867 root.callbackNode = callbackNode; 58868} // This is the entry point for every concurrent task, i.e. anything that 58869// goes through Scheduler. 58870 58871 58872function performConcurrentWorkOnRoot(root, didTimeout) { 58873 // Since we know we're in a React event, we can clear the current 58874 // event time. The next update will compute a new event time. 58875 currentEventTime = NoWork; 58876 58877 if (didTimeout) { 58878 // The render task took too long to complete. Mark the current time as 58879 // expired to synchronously render all expired work in a single batch. 58880 var currentTime = requestCurrentTimeForUpdate(); 58881 markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback. 58882 58883 ensureRootIsScheduled(root); 58884 return null; 58885 } // Determine the next expiration time to work on, using the fields stored 58886 // on the root. 58887 58888 58889 var expirationTime = getNextRootExpirationTimeToWorkOn(root); 58890 58891 if (expirationTime !== NoWork) { 58892 var originalCallbackNode = root.callbackNode; 58893 58894 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 58895 { 58896 throw Error( "Should not already be working." ); 58897 } 58898 } 58899 58900 flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack 58901 // and prepare a fresh one. Otherwise we'll continue where we left off. 58902 58903 if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) { 58904 prepareFreshStack(root, expirationTime); 58905 startWorkOnPendingInteractions(root, expirationTime); 58906 } // If we have a work-in-progress fiber, it means there's still work to do 58907 // in this root. 58908 58909 58910 if (workInProgress !== null) { 58911 var prevExecutionContext = executionContext; 58912 executionContext |= RenderContext; 58913 var prevDispatcher = pushDispatcher(); 58914 var prevInteractions = pushInteractions(root); 58915 startWorkLoopTimer(workInProgress); 58916 58917 do { 58918 try { 58919 workLoopConcurrent(); 58920 break; 58921 } catch (thrownValue) { 58922 handleError(root, thrownValue); 58923 } 58924 } while (true); 58925 58926 resetContextDependencies(); 58927 executionContext = prevExecutionContext; 58928 popDispatcher(prevDispatcher); 58929 58930 { 58931 popInteractions(prevInteractions); 58932 } 58933 58934 if (workInProgressRootExitStatus === RootFatalErrored) { 58935 var fatalError = workInProgressRootFatalError; 58936 stopInterruptedWorkLoopTimer(); 58937 prepareFreshStack(root, expirationTime); 58938 markRootSuspendedAtTime(root, expirationTime); 58939 ensureRootIsScheduled(root); 58940 throw fatalError; 58941 } 58942 58943 if (workInProgress !== null) { 58944 // There's still work left over. Exit without committing. 58945 stopInterruptedWorkLoopTimer(); 58946 } else { 58947 // We now have a consistent tree. The next step is either to commit it, 58948 // or, if something suspended, wait to commit it after a timeout. 58949 stopFinishedWorkLoopTimer(); 58950 var finishedWork = root.finishedWork = root.current.alternate; 58951 root.finishedExpirationTime = expirationTime; 58952 finishConcurrentRender(root, finishedWork, workInProgressRootExitStatus, expirationTime); 58953 } 58954 58955 ensureRootIsScheduled(root); 58956 58957 if (root.callbackNode === originalCallbackNode) { 58958 // The task node scheduled for this root is the same one that's 58959 // currently executed. Need to return a continuation. 58960 return performConcurrentWorkOnRoot.bind(null, root); 58961 } 58962 } 58963 } 58964 58965 return null; 58966} 58967 58968function finishConcurrentRender(root, finishedWork, exitStatus, expirationTime) { 58969 // Set this to null to indicate there's no in-progress render. 58970 workInProgressRoot = null; 58971 58972 switch (exitStatus) { 58973 case RootIncomplete: 58974 case RootFatalErrored: 58975 { 58976 { 58977 { 58978 throw Error( "Root did not complete. This is a bug in React." ); 58979 } 58980 } 58981 } 58982 // Flow knows about invariant, so it complains if I add a break 58983 // statement, but eslint doesn't know about invariant, so it complains 58984 // if I do. eslint-disable-next-line no-fallthrough 58985 58986 case RootErrored: 58987 { 58988 // If this was an async render, the error may have happened due to 58989 // a mutation in a concurrent event. Try rendering one more time, 58990 // synchronously, to see if the error goes away. If there are 58991 // lower priority updates, let's include those, too, in case they 58992 // fix the inconsistency. Render at Idle to include all updates. 58993 // If it was Idle or Never or some not-yet-invented time, render 58994 // at that time. 58995 markRootExpiredAtTime(root, expirationTime > Idle ? Idle : expirationTime); // We assume that this second render pass will be synchronous 58996 // and therefore not hit this path again. 58997 58998 break; 58999 } 59000 59001 case RootSuspended: 59002 { 59003 markRootSuspendedAtTime(root, expirationTime); 59004 var lastSuspendedTime = root.lastSuspendedTime; 59005 59006 if (expirationTime === lastSuspendedTime) { 59007 root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork); 59008 } // We have an acceptable loading state. We need to figure out if we 59009 // should immediately commit it or wait a bit. 59010 // If we have processed new updates during this render, we may now 59011 // have a new loading state ready. We want to ensure that we commit 59012 // that as soon as possible. 59013 59014 59015 var hasNotProcessedNewUpdates = workInProgressRootLatestProcessedExpirationTime === Sync; 59016 59017 if (hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope 59018 !( IsThisRendererActing.current)) { 59019 // If we have not processed any new updates during this pass, then 59020 // this is either a retry of an existing fallback state or a 59021 // hidden tree. Hidden trees shouldn't be batched with other work 59022 // and after that's fixed it can only be a retry. We're going to 59023 // throttle committing retries so that we don't show too many 59024 // loading states too quickly. 59025 var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time. 59026 59027 if (msUntilTimeout > 10) { 59028 if (workInProgressRootHasPendingPing) { 59029 var lastPingedTime = root.lastPingedTime; 59030 59031 if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) { 59032 // This render was pinged but we didn't get to restart 59033 // earlier so try restarting now instead. 59034 root.lastPingedTime = expirationTime; 59035 prepareFreshStack(root, expirationTime); 59036 break; 59037 } 59038 } 59039 59040 var nextTime = getNextRootExpirationTimeToWorkOn(root); 59041 59042 if (nextTime !== NoWork && nextTime !== expirationTime) { 59043 // There's additional work on this root. 59044 break; 59045 } 59046 59047 if (lastSuspendedTime !== NoWork && lastSuspendedTime !== expirationTime) { 59048 // We should prefer to render the fallback of at the last 59049 // suspended level. Ping the last suspended level to try 59050 // rendering it again. 59051 root.lastPingedTime = lastSuspendedTime; 59052 break; 59053 } // The render is suspended, it hasn't timed out, and there's no 59054 // lower priority work to do. Instead of committing the fallback 59055 // immediately, wait for more data to arrive. 59056 59057 59058 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout); 59059 break; 59060 } 59061 } // The work expired. Commit immediately. 59062 59063 59064 commitRoot(root); 59065 break; 59066 } 59067 59068 case RootSuspendedWithDelay: 59069 { 59070 markRootSuspendedAtTime(root, expirationTime); 59071 var _lastSuspendedTime = root.lastSuspendedTime; 59072 59073 if (expirationTime === _lastSuspendedTime) { 59074 root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork); 59075 } 59076 59077 if ( // do not delay if we're inside an act() scope 59078 !( IsThisRendererActing.current)) { 59079 // We're suspended in a state that should be avoided. We'll try to 59080 // avoid committing it for as long as the timeouts let us. 59081 if (workInProgressRootHasPendingPing) { 59082 var _lastPingedTime = root.lastPingedTime; 59083 59084 if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) { 59085 // This render was pinged but we didn't get to restart earlier 59086 // so try restarting now instead. 59087 root.lastPingedTime = expirationTime; 59088 prepareFreshStack(root, expirationTime); 59089 break; 59090 } 59091 } 59092 59093 var _nextTime = getNextRootExpirationTimeToWorkOn(root); 59094 59095 if (_nextTime !== NoWork && _nextTime !== expirationTime) { 59096 // There's additional work on this root. 59097 break; 59098 } 59099 59100 if (_lastSuspendedTime !== NoWork && _lastSuspendedTime !== expirationTime) { 59101 // We should prefer to render the fallback of at the last 59102 // suspended level. Ping the last suspended level to try 59103 // rendering it again. 59104 root.lastPingedTime = _lastSuspendedTime; 59105 break; 59106 } 59107 59108 var _msUntilTimeout; 59109 59110 if (workInProgressRootLatestSuspenseTimeout !== Sync) { 59111 // We have processed a suspense config whose expiration time we 59112 // can use as the timeout. 59113 _msUntilTimeout = expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now(); 59114 } else if (workInProgressRootLatestProcessedExpirationTime === Sync) { 59115 // This should never normally happen because only new updates 59116 // cause delayed states, so we should have processed something. 59117 // However, this could also happen in an offscreen tree. 59118 _msUntilTimeout = 0; 59119 } else { 59120 // If we don't have a suspense config, we're going to use a 59121 // heuristic to determine how long we can suspend. 59122 var eventTimeMs = inferTimeFromExpirationTime(workInProgressRootLatestProcessedExpirationTime); 59123 var currentTimeMs = now(); 59124 var timeUntilExpirationMs = expirationTimeToMs(expirationTime) - currentTimeMs; 59125 var timeElapsed = currentTimeMs - eventTimeMs; 59126 59127 if (timeElapsed < 0) { 59128 // We get this wrong some time since we estimate the time. 59129 timeElapsed = 0; 59130 } 59131 59132 _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the 59133 // event time is exact instead of inferred from expiration time 59134 // we don't need this. 59135 59136 if (timeUntilExpirationMs < _msUntilTimeout) { 59137 _msUntilTimeout = timeUntilExpirationMs; 59138 } 59139 } // Don't bother with a very short suspense time. 59140 59141 59142 if (_msUntilTimeout > 10) { 59143 // The render is suspended, it hasn't timed out, and there's no 59144 // lower priority work to do. Instead of committing the fallback 59145 // immediately, wait for more data to arrive. 59146 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout); 59147 break; 59148 } 59149 } // The work expired. Commit immediately. 59150 59151 59152 commitRoot(root); 59153 break; 59154 } 59155 59156 case RootCompleted: 59157 { 59158 // The work completed. Ready to commit. 59159 if ( // do not delay if we're inside an act() scope 59160 !( IsThisRendererActing.current) && workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null) { 59161 // If we have exceeded the minimum loading delay, which probably 59162 // means we have shown a spinner already, we might have to suspend 59163 // a bit longer to ensure that the spinner is shown for 59164 // enough time. 59165 var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(workInProgressRootLatestProcessedExpirationTime, expirationTime, workInProgressRootCanSuspendUsingConfig); 59166 59167 if (_msUntilTimeout2 > 10) { 59168 markRootSuspendedAtTime(root, expirationTime); 59169 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout2); 59170 break; 59171 } 59172 } 59173 59174 commitRoot(root); 59175 break; 59176 } 59177 59178 default: 59179 { 59180 { 59181 { 59182 throw Error( "Unknown root exit status." ); 59183 } 59184 } 59185 } 59186 } 59187} // This is the entry point for synchronous tasks that don't go 59188// through Scheduler 59189 59190 59191function performSyncWorkOnRoot(root) { 59192 // Check if there's expired work on this root. Otherwise, render at Sync. 59193 var lastExpiredTime = root.lastExpiredTime; 59194 var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync; 59195 59196 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 59197 { 59198 throw Error( "Should not already be working." ); 59199 } 59200 } 59201 59202 flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack 59203 // and prepare a fresh one. Otherwise we'll continue where we left off. 59204 59205 if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) { 59206 prepareFreshStack(root, expirationTime); 59207 startWorkOnPendingInteractions(root, expirationTime); 59208 } // If we have a work-in-progress fiber, it means there's still work to do 59209 // in this root. 59210 59211 59212 if (workInProgress !== null) { 59213 var prevExecutionContext = executionContext; 59214 executionContext |= RenderContext; 59215 var prevDispatcher = pushDispatcher(); 59216 var prevInteractions = pushInteractions(root); 59217 startWorkLoopTimer(workInProgress); 59218 59219 do { 59220 try { 59221 workLoopSync(); 59222 break; 59223 } catch (thrownValue) { 59224 handleError(root, thrownValue); 59225 } 59226 } while (true); 59227 59228 resetContextDependencies(); 59229 executionContext = prevExecutionContext; 59230 popDispatcher(prevDispatcher); 59231 59232 { 59233 popInteractions(prevInteractions); 59234 } 59235 59236 if (workInProgressRootExitStatus === RootFatalErrored) { 59237 var fatalError = workInProgressRootFatalError; 59238 stopInterruptedWorkLoopTimer(); 59239 prepareFreshStack(root, expirationTime); 59240 markRootSuspendedAtTime(root, expirationTime); 59241 ensureRootIsScheduled(root); 59242 throw fatalError; 59243 } 59244 59245 if (workInProgress !== null) { 59246 // This is a sync render, so we should have finished the whole tree. 59247 { 59248 { 59249 throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); 59250 } 59251 } 59252 } else { 59253 // We now have a consistent tree. Because this is a sync render, we 59254 // will commit it even if something suspended. 59255 stopFinishedWorkLoopTimer(); 59256 root.finishedWork = root.current.alternate; 59257 root.finishedExpirationTime = expirationTime; 59258 finishSyncRender(root); 59259 } // Before exiting, make sure there's a callback scheduled for the next 59260 // pending level. 59261 59262 59263 ensureRootIsScheduled(root); 59264 } 59265 59266 return null; 59267} 59268 59269function finishSyncRender(root) { 59270 // Set this to null to indicate there's no in-progress render. 59271 workInProgressRoot = null; 59272 commitRoot(root); 59273} 59274function flushDiscreteUpdates() { 59275 // TODO: Should be able to flush inside batchedUpdates, but not inside `act`. 59276 // However, `act` uses `batchedUpdates`, so there's no way to distinguish 59277 // those two cases. Need to fix this before exposing flushDiscreteUpdates 59278 // as a public API. 59279 if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) { 59280 { 59281 if ((executionContext & RenderContext) !== NoContext) { 59282 error('unstable_flushDiscreteUpdates: Cannot flush updates when React is ' + 'already rendering.'); 59283 } 59284 } // We're already rendering, so we can't synchronously flush pending work. 59285 // This is probably a nested event dispatch triggered by a lifecycle/effect, 59286 // like `el.focus()`. Exit. 59287 59288 59289 return; 59290 } 59291 59292 flushPendingDiscreteUpdates(); // If the discrete updates scheduled passive effects, flush them now so that 59293 // they fire before the next serial event. 59294 59295 flushPassiveEffects(); 59296} 59297function syncUpdates(fn, a, b, c) { 59298 return runWithPriority$1(ImmediatePriority, fn.bind(null, a, b, c)); 59299} 59300 59301function flushPendingDiscreteUpdates() { 59302 if (rootsWithPendingDiscreteUpdates !== null) { 59303 // For each root with pending discrete updates, schedule a callback to 59304 // immediately flush them. 59305 var roots = rootsWithPendingDiscreteUpdates; 59306 rootsWithPendingDiscreteUpdates = null; 59307 roots.forEach(function (expirationTime, root) { 59308 markRootExpiredAtTime(root, expirationTime); 59309 ensureRootIsScheduled(root); 59310 }); // Now flush the immediate queue. 59311 59312 flushSyncCallbackQueue(); 59313 } 59314} 59315 59316function batchedUpdates$1(fn, a) { 59317 var prevExecutionContext = executionContext; 59318 executionContext |= BatchedContext; 59319 59320 try { 59321 return fn(a); 59322 } finally { 59323 executionContext = prevExecutionContext; 59324 59325 if (executionContext === NoContext) { 59326 // Flush the immediate callbacks that were scheduled during this batch 59327 flushSyncCallbackQueue(); 59328 } 59329 } 59330} 59331function batchedEventUpdates$1(fn, a) { 59332 var prevExecutionContext = executionContext; 59333 executionContext |= EventContext; 59334 59335 try { 59336 return fn(a); 59337 } finally { 59338 executionContext = prevExecutionContext; 59339 59340 if (executionContext === NoContext) { 59341 // Flush the immediate callbacks that were scheduled during this batch 59342 flushSyncCallbackQueue(); 59343 } 59344 } 59345} 59346function discreteUpdates$1(fn, a, b, c, d) { 59347 var prevExecutionContext = executionContext; 59348 executionContext |= DiscreteEventContext; 59349 59350 try { 59351 // Should this 59352 return runWithPriority$1(UserBlockingPriority$1, fn.bind(null, a, b, c, d)); 59353 } finally { 59354 executionContext = prevExecutionContext; 59355 59356 if (executionContext === NoContext) { 59357 // Flush the immediate callbacks that were scheduled during this batch 59358 flushSyncCallbackQueue(); 59359 } 59360 } 59361} 59362function unbatchedUpdates(fn, a) { 59363 var prevExecutionContext = executionContext; 59364 executionContext &= ~BatchedContext; 59365 executionContext |= LegacyUnbatchedContext; 59366 59367 try { 59368 return fn(a); 59369 } finally { 59370 executionContext = prevExecutionContext; 59371 59372 if (executionContext === NoContext) { 59373 // Flush the immediate callbacks that were scheduled during this batch 59374 flushSyncCallbackQueue(); 59375 } 59376 } 59377} 59378function flushSync(fn, a) { 59379 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { 59380 { 59381 { 59382 throw Error( "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering." ); 59383 } 59384 } 59385 } 59386 59387 var prevExecutionContext = executionContext; 59388 executionContext |= BatchedContext; 59389 59390 try { 59391 return runWithPriority$1(ImmediatePriority, fn.bind(null, a)); 59392 } finally { 59393 executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. 59394 // Note that this will happen even if batchedUpdates is higher up 59395 // the stack. 59396 59397 flushSyncCallbackQueue(); 59398 } 59399} 59400 59401function prepareFreshStack(root, expirationTime) { 59402 root.finishedWork = null; 59403 root.finishedExpirationTime = NoWork; 59404 var timeoutHandle = root.timeoutHandle; 59405 59406 if (timeoutHandle !== noTimeout) { 59407 // The root previous suspended and scheduled a timeout to commit a fallback 59408 // state. Now that we have additional work, cancel the timeout. 59409 root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above 59410 59411 cancelTimeout(timeoutHandle); 59412 } 59413 59414 if (workInProgress !== null) { 59415 var interruptedWork = workInProgress.return; 59416 59417 while (interruptedWork !== null) { 59418 unwindInterruptedWork(interruptedWork); 59419 interruptedWork = interruptedWork.return; 59420 } 59421 } 59422 59423 workInProgressRoot = root; 59424 workInProgress = createWorkInProgress(root.current, null); 59425 renderExpirationTime$1 = expirationTime; 59426 workInProgressRootExitStatus = RootIncomplete; 59427 workInProgressRootFatalError = null; 59428 workInProgressRootLatestProcessedExpirationTime = Sync; 59429 workInProgressRootLatestSuspenseTimeout = Sync; 59430 workInProgressRootCanSuspendUsingConfig = null; 59431 workInProgressRootNextUnprocessedUpdateTime = NoWork; 59432 workInProgressRootHasPendingPing = false; 59433 59434 { 59435 spawnedWorkDuringRender = null; 59436 } 59437 59438 { 59439 ReactStrictModeWarnings.discardPendingWarnings(); 59440 } 59441} 59442 59443function handleError(root, thrownValue) { 59444 do { 59445 try { 59446 // Reset module-level state that was set during the render phase. 59447 resetContextDependencies(); 59448 resetHooksAfterThrow(); 59449 resetCurrentFiber(); 59450 59451 if (workInProgress === null || workInProgress.return === null) { 59452 // Expected to be working on a non-root fiber. This is a fatal error 59453 // because there's no ancestor that can handle it; the root is 59454 // supposed to capture all errors that weren't caught by an error 59455 // boundary. 59456 workInProgressRootExitStatus = RootFatalErrored; 59457 workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next 59458 // sibling, or the parent if there are no siblings. But since the root 59459 // has no siblings nor a parent, we set it to null. Usually this is 59460 // handled by `completeUnitOfWork` or `unwindWork`, but since we're 59461 // interntionally not calling those, we need set it here. 59462 // TODO: Consider calling `unwindWork` to pop the contexts. 59463 59464 workInProgress = null; 59465 return null; 59466 } 59467 59468 if (enableProfilerTimer && workInProgress.mode & ProfileMode) { 59469 // Record the time spent rendering before an error was thrown. This 59470 // avoids inaccurate Profiler durations in the case of a 59471 // suspended render. 59472 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true); 59473 } 59474 59475 throwException(root, workInProgress.return, workInProgress, thrownValue, renderExpirationTime$1); 59476 workInProgress = completeUnitOfWork(workInProgress); 59477 } catch (yetAnotherThrownValue) { 59478 // Something in the return path also threw. 59479 thrownValue = yetAnotherThrownValue; 59480 continue; 59481 } // Return to the normal work loop. 59482 59483 59484 return; 59485 } while (true); 59486} 59487 59488function pushDispatcher(root) { 59489 var prevDispatcher = ReactCurrentDispatcher$1.current; 59490 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; 59491 59492 if (prevDispatcher === null) { 59493 // The React isomorphic package does not include a default dispatcher. 59494 // Instead the first renderer will lazily attach one, in order to give 59495 // nicer error messages. 59496 return ContextOnlyDispatcher; 59497 } else { 59498 return prevDispatcher; 59499 } 59500} 59501 59502function popDispatcher(prevDispatcher) { 59503 ReactCurrentDispatcher$1.current = prevDispatcher; 59504} 59505 59506function pushInteractions(root) { 59507 { 59508 var prevInteractions = tracing.__interactionsRef.current; 59509 tracing.__interactionsRef.current = root.memoizedInteractions; 59510 return prevInteractions; 59511 } 59512} 59513 59514function popInteractions(prevInteractions) { 59515 { 59516 tracing.__interactionsRef.current = prevInteractions; 59517 } 59518} 59519 59520function markCommitTimeOfFallback() { 59521 globalMostRecentFallbackTime = now(); 59522} 59523function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { 59524 if (expirationTime < workInProgressRootLatestProcessedExpirationTime && expirationTime > Idle) { 59525 workInProgressRootLatestProcessedExpirationTime = expirationTime; 59526 } 59527 59528 if (suspenseConfig !== null) { 59529 if (expirationTime < workInProgressRootLatestSuspenseTimeout && expirationTime > Idle) { 59530 workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad. 59531 59532 workInProgressRootCanSuspendUsingConfig = suspenseConfig; 59533 } 59534 } 59535} 59536function markUnprocessedUpdateTime(expirationTime) { 59537 if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) { 59538 workInProgressRootNextUnprocessedUpdateTime = expirationTime; 59539 } 59540} 59541function renderDidSuspend() { 59542 if (workInProgressRootExitStatus === RootIncomplete) { 59543 workInProgressRootExitStatus = RootSuspended; 59544 } 59545} 59546function renderDidSuspendDelayIfPossible() { 59547 if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) { 59548 workInProgressRootExitStatus = RootSuspendedWithDelay; 59549 } // Check if there's a lower priority update somewhere else in the tree. 59550 59551 59552 if (workInProgressRootNextUnprocessedUpdateTime !== NoWork && workInProgressRoot !== null) { 59553 // Mark the current render as suspended, and then mark that there's a 59554 // pending update. 59555 // TODO: This should immediately interrupt the current render, instead 59556 // of waiting until the next time we yield. 59557 markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime$1); 59558 markRootUpdatedAtTime(workInProgressRoot, workInProgressRootNextUnprocessedUpdateTime); 59559 } 59560} 59561function renderDidError() { 59562 if (workInProgressRootExitStatus !== RootCompleted) { 59563 workInProgressRootExitStatus = RootErrored; 59564 } 59565} // Called during render to determine if anything has suspended. 59566// Returns false if we're not sure. 59567 59568function renderHasNotSuspendedYet() { 59569 // If something errored or completed, we can't really be sure, 59570 // so those are false. 59571 return workInProgressRootExitStatus === RootIncomplete; 59572} 59573 59574function inferTimeFromExpirationTime(expirationTime) { 59575 // We don't know exactly when the update was scheduled, but we can infer an 59576 // approximate start time from the expiration time. 59577 var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); 59578 return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; 59579} 59580 59581function inferTimeFromExpirationTimeWithSuspenseConfig(expirationTime, suspenseConfig) { 59582 // We don't know exactly when the update was scheduled, but we can infer an 59583 // approximate start time from the expiration time by subtracting the timeout 59584 // that was added to the event time. 59585 var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); 59586 return earliestExpirationTimeMs - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION); 59587} // The work loop is an extremely hot path. Tell Closure not to inline it. 59588 59589/** @noinline */ 59590 59591 59592function workLoopSync() { 59593 // Already timed out, so perform work without checking if we need to yield. 59594 while (workInProgress !== null) { 59595 workInProgress = performUnitOfWork(workInProgress); 59596 } 59597} 59598/** @noinline */ 59599 59600 59601function workLoopConcurrent() { 59602 // Perform work until Scheduler asks us to yield 59603 while (workInProgress !== null && !shouldYield()) { 59604 workInProgress = performUnitOfWork(workInProgress); 59605 } 59606} 59607 59608function performUnitOfWork(unitOfWork) { 59609 // The current, flushed, state of this fiber is the alternate. Ideally 59610 // nothing should rely on this, but relying on it here means that we don't 59611 // need an additional field on the work in progress. 59612 var current = unitOfWork.alternate; 59613 startWorkTimer(unitOfWork); 59614 setCurrentFiber(unitOfWork); 59615 var next; 59616 59617 if ( (unitOfWork.mode & ProfileMode) !== NoMode) { 59618 startProfilerTimer(unitOfWork); 59619 next = beginWork$1(current, unitOfWork, renderExpirationTime$1); 59620 stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); 59621 } else { 59622 next = beginWork$1(current, unitOfWork, renderExpirationTime$1); 59623 } 59624 59625 resetCurrentFiber(); 59626 unitOfWork.memoizedProps = unitOfWork.pendingProps; 59627 59628 if (next === null) { 59629 // If this doesn't spawn new work, complete the current work. 59630 next = completeUnitOfWork(unitOfWork); 59631 } 59632 59633 ReactCurrentOwner$2.current = null; 59634 return next; 59635} 59636 59637function completeUnitOfWork(unitOfWork) { 59638 // Attempt to complete the current unit of work, then move to the next 59639 // sibling. If there are no more siblings, return to the parent fiber. 59640 workInProgress = unitOfWork; 59641 59642 do { 59643 // The current, flushed, state of this fiber is the alternate. Ideally 59644 // nothing should rely on this, but relying on it here means that we don't 59645 // need an additional field on the work in progress. 59646 var current = workInProgress.alternate; 59647 var returnFiber = workInProgress.return; // Check if the work completed or if something threw. 59648 59649 if ((workInProgress.effectTag & Incomplete) === NoEffect) { 59650 setCurrentFiber(workInProgress); 59651 var next = void 0; 59652 59653 if ( (workInProgress.mode & ProfileMode) === NoMode) { 59654 next = completeWork(current, workInProgress, renderExpirationTime$1); 59655 } else { 59656 startProfilerTimer(workInProgress); 59657 next = completeWork(current, workInProgress, renderExpirationTime$1); // Update render duration assuming we didn't error. 59658 59659 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); 59660 } 59661 59662 stopWorkTimer(workInProgress); 59663 resetCurrentFiber(); 59664 resetChildExpirationTime(workInProgress); 59665 59666 if (next !== null) { 59667 // Completing this fiber spawned new work. Work on that next. 59668 return next; 59669 } 59670 59671 if (returnFiber !== null && // Do not append effects to parents if a sibling failed to complete 59672 (returnFiber.effectTag & Incomplete) === NoEffect) { 59673 // Append all the effects of the subtree and this fiber onto the effect 59674 // list of the parent. The completion order of the children affects the 59675 // side-effect order. 59676 if (returnFiber.firstEffect === null) { 59677 returnFiber.firstEffect = workInProgress.firstEffect; 59678 } 59679 59680 if (workInProgress.lastEffect !== null) { 59681 if (returnFiber.lastEffect !== null) { 59682 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; 59683 } 59684 59685 returnFiber.lastEffect = workInProgress.lastEffect; 59686 } // If this fiber had side-effects, we append it AFTER the children's 59687 // side-effects. We can perform certain side-effects earlier if needed, 59688 // by doing multiple passes over the effect list. We don't want to 59689 // schedule our own side-effect on our own list because if end up 59690 // reusing children we'll schedule this effect onto itself since we're 59691 // at the end. 59692 59693 59694 var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect 59695 // list. PerformedWork effect is read by React DevTools but shouldn't be 59696 // committed. 59697 59698 if (effectTag > PerformedWork) { 59699 if (returnFiber.lastEffect !== null) { 59700 returnFiber.lastEffect.nextEffect = workInProgress; 59701 } else { 59702 returnFiber.firstEffect = workInProgress; 59703 } 59704 59705 returnFiber.lastEffect = workInProgress; 59706 } 59707 } 59708 } else { 59709 // This fiber did not complete because something threw. Pop values off 59710 // the stack without entering the complete phase. If this is a boundary, 59711 // capture values if possible. 59712 var _next = unwindWork(workInProgress); // Because this fiber did not complete, don't reset its expiration time. 59713 59714 59715 if ( (workInProgress.mode & ProfileMode) !== NoMode) { 59716 // Record the render duration for the fiber that errored. 59717 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing. 59718 59719 var actualDuration = workInProgress.actualDuration; 59720 var child = workInProgress.child; 59721 59722 while (child !== null) { 59723 actualDuration += child.actualDuration; 59724 child = child.sibling; 59725 } 59726 59727 workInProgress.actualDuration = actualDuration; 59728 } 59729 59730 if (_next !== null) { 59731 // If completing this work spawned new work, do that next. We'll come 59732 // back here again. 59733 // Since we're restarting, remove anything that is not a host effect 59734 // from the effect tag. 59735 // TODO: The name stopFailedWorkTimer is misleading because Suspense 59736 // also captures and restarts. 59737 stopFailedWorkTimer(workInProgress); 59738 _next.effectTag &= HostEffectMask; 59739 return _next; 59740 } 59741 59742 stopWorkTimer(workInProgress); 59743 59744 if (returnFiber !== null) { 59745 // Mark the parent fiber as incomplete and clear its effect list. 59746 returnFiber.firstEffect = returnFiber.lastEffect = null; 59747 returnFiber.effectTag |= Incomplete; 59748 } 59749 } 59750 59751 var siblingFiber = workInProgress.sibling; 59752 59753 if (siblingFiber !== null) { 59754 // If there is more work to do in this returnFiber, do that next. 59755 return siblingFiber; 59756 } // Otherwise, return to the parent 59757 59758 59759 workInProgress = returnFiber; 59760 } while (workInProgress !== null); // We've reached the root. 59761 59762 59763 if (workInProgressRootExitStatus === RootIncomplete) { 59764 workInProgressRootExitStatus = RootCompleted; 59765 } 59766 59767 return null; 59768} 59769 59770function getRemainingExpirationTime(fiber) { 59771 var updateExpirationTime = fiber.expirationTime; 59772 var childExpirationTime = fiber.childExpirationTime; 59773 return updateExpirationTime > childExpirationTime ? updateExpirationTime : childExpirationTime; 59774} 59775 59776function resetChildExpirationTime(completedWork) { 59777 if (renderExpirationTime$1 !== Never && completedWork.childExpirationTime === Never) { 59778 // The children of this component are hidden. Don't bubble their 59779 // expiration times. 59780 return; 59781 } 59782 59783 var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time. 59784 59785 if ( (completedWork.mode & ProfileMode) !== NoMode) { 59786 // In profiling mode, resetChildExpirationTime is also used to reset 59787 // profiler durations. 59788 var actualDuration = completedWork.actualDuration; 59789 var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will 59790 // only be updated if work is done on the fiber (i.e. it doesn't bailout). 59791 // When work is done, it should bubble to the parent's actualDuration. If 59792 // the fiber has not been cloned though, (meaning no work was done), then 59793 // this value will reflect the amount of time spent working on a previous 59794 // render. In that case it should not bubble. We determine whether it was 59795 // cloned by comparing the child pointer. 59796 59797 var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child; 59798 var child = completedWork.child; 59799 59800 while (child !== null) { 59801 var childUpdateExpirationTime = child.expirationTime; 59802 var childChildExpirationTime = child.childExpirationTime; 59803 59804 if (childUpdateExpirationTime > newChildExpirationTime) { 59805 newChildExpirationTime = childUpdateExpirationTime; 59806 } 59807 59808 if (childChildExpirationTime > newChildExpirationTime) { 59809 newChildExpirationTime = childChildExpirationTime; 59810 } 59811 59812 if (shouldBubbleActualDurations) { 59813 actualDuration += child.actualDuration; 59814 } 59815 59816 treeBaseDuration += child.treeBaseDuration; 59817 child = child.sibling; 59818 } 59819 59820 completedWork.actualDuration = actualDuration; 59821 completedWork.treeBaseDuration = treeBaseDuration; 59822 } else { 59823 var _child = completedWork.child; 59824 59825 while (_child !== null) { 59826 var _childUpdateExpirationTime = _child.expirationTime; 59827 var _childChildExpirationTime = _child.childExpirationTime; 59828 59829 if (_childUpdateExpirationTime > newChildExpirationTime) { 59830 newChildExpirationTime = _childUpdateExpirationTime; 59831 } 59832 59833 if (_childChildExpirationTime > newChildExpirationTime) { 59834 newChildExpirationTime = _childChildExpirationTime; 59835 } 59836 59837 _child = _child.sibling; 59838 } 59839 } 59840 59841 completedWork.childExpirationTime = newChildExpirationTime; 59842} 59843 59844function commitRoot(root) { 59845 var renderPriorityLevel = getCurrentPriorityLevel(); 59846 runWithPriority$1(ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel)); 59847 return null; 59848} 59849 59850function commitRootImpl(root, renderPriorityLevel) { 59851 do { 59852 // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which 59853 // means `flushPassiveEffects` will sometimes result in additional 59854 // passive effects. So we need to keep flushing in a loop until there are 59855 // no more pending effects. 59856 // TODO: Might be better if `flushPassiveEffects` did not automatically 59857 // flush synchronous work at the end, to avoid factoring hazards like this. 59858 flushPassiveEffects(); 59859 } while (rootWithPendingPassiveEffects !== null); 59860 59861 flushRenderPhaseStrictModeWarningsInDEV(); 59862 59863 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 59864 { 59865 throw Error( "Should not already be working." ); 59866 } 59867 } 59868 59869 var finishedWork = root.finishedWork; 59870 var expirationTime = root.finishedExpirationTime; 59871 59872 if (finishedWork === null) { 59873 return null; 59874 } 59875 59876 root.finishedWork = null; 59877 root.finishedExpirationTime = NoWork; 59878 59879 if (!(finishedWork !== root.current)) { 59880 { 59881 throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); 59882 } 59883 } // commitRoot never returns a continuation; it always finishes synchronously. 59884 // So we can clear these now to allow a new callback to be scheduled. 59885 59886 59887 root.callbackNode = null; 59888 root.callbackExpirationTime = NoWork; 59889 root.callbackPriority = NoPriority; 59890 root.nextKnownPendingLevel = NoWork; 59891 startCommitTimer(); // Update the first and last pending times on this root. The new first 59892 // pending time is whatever is left on the root fiber. 59893 59894 var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(finishedWork); 59895 markRootFinishedAtTime(root, expirationTime, remainingExpirationTimeBeforeCommit); 59896 59897 if (root === workInProgressRoot) { 59898 // We can reset these now that they are finished. 59899 workInProgressRoot = null; 59900 workInProgress = null; 59901 renderExpirationTime$1 = NoWork; 59902 } // This indicates that the last root we worked on is not the same one that 59903 // we're committing now. This most commonly happens when a suspended root 59904 // times out. 59905 // Get the list of effects. 59906 59907 59908 var firstEffect; 59909 59910 if (finishedWork.effectTag > PerformedWork) { 59911 // A fiber's effect list consists only of its children, not itself. So if 59912 // the root has an effect, we need to add it to the end of the list. The 59913 // resulting list is the set that would belong to the root's parent, if it 59914 // had one; that is, all the effects in the tree including the root. 59915 if (finishedWork.lastEffect !== null) { 59916 finishedWork.lastEffect.nextEffect = finishedWork; 59917 firstEffect = finishedWork.firstEffect; 59918 } else { 59919 firstEffect = finishedWork; 59920 } 59921 } else { 59922 // There is no effect on the root. 59923 firstEffect = finishedWork.firstEffect; 59924 } 59925 59926 if (firstEffect !== null) { 59927 var prevExecutionContext = executionContext; 59928 executionContext |= CommitContext; 59929 var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles 59930 59931 ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass 59932 // of the effect list for each phase: all mutation effects come before all 59933 // layout effects, and so on. 59934 // The first phase a "before mutation" phase. We use this phase to read the 59935 // state of the host tree right before we mutate it. This is where 59936 // getSnapshotBeforeUpdate is called. 59937 59938 startCommitSnapshotEffectsTimer(); 59939 prepareForCommit(root.containerInfo); 59940 nextEffect = firstEffect; 59941 59942 do { 59943 { 59944 invokeGuardedCallback(null, commitBeforeMutationEffects, null); 59945 59946 if (hasCaughtError()) { 59947 if (!(nextEffect !== null)) { 59948 { 59949 throw Error( "Should be working on an effect." ); 59950 } 59951 } 59952 59953 var error = clearCaughtError(); 59954 captureCommitPhaseError(nextEffect, error); 59955 nextEffect = nextEffect.nextEffect; 59956 } 59957 } 59958 } while (nextEffect !== null); 59959 59960 stopCommitSnapshotEffectsTimer(); 59961 59962 { 59963 // Mark the current commit time to be shared by all Profilers in this 59964 // batch. This enables them to be grouped later. 59965 recordCommitTime(); 59966 } // The next phase is the mutation phase, where we mutate the host tree. 59967 59968 59969 startCommitHostEffectsTimer(); 59970 nextEffect = firstEffect; 59971 59972 do { 59973 { 59974 invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel); 59975 59976 if (hasCaughtError()) { 59977 if (!(nextEffect !== null)) { 59978 { 59979 throw Error( "Should be working on an effect." ); 59980 } 59981 } 59982 59983 var _error = clearCaughtError(); 59984 59985 captureCommitPhaseError(nextEffect, _error); 59986 nextEffect = nextEffect.nextEffect; 59987 } 59988 } 59989 } while (nextEffect !== null); 59990 59991 stopCommitHostEffectsTimer(); 59992 resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after 59993 // the mutation phase, so that the previous tree is still current during 59994 // componentWillUnmount, but before the layout phase, so that the finished 59995 // work is current during componentDidMount/Update. 59996 59997 root.current = finishedWork; // The next phase is the layout phase, where we call effects that read 59998 // the host tree after it's been mutated. The idiomatic use case for this is 59999 // layout, but class component lifecycles also fire here for legacy reasons. 60000 60001 startCommitLifeCyclesTimer(); 60002 nextEffect = firstEffect; 60003 60004 do { 60005 { 60006 invokeGuardedCallback(null, commitLayoutEffects, null, root, expirationTime); 60007 60008 if (hasCaughtError()) { 60009 if (!(nextEffect !== null)) { 60010 { 60011 throw Error( "Should be working on an effect." ); 60012 } 60013 } 60014 60015 var _error2 = clearCaughtError(); 60016 60017 captureCommitPhaseError(nextEffect, _error2); 60018 nextEffect = nextEffect.nextEffect; 60019 } 60020 } 60021 } while (nextEffect !== null); 60022 60023 stopCommitLifeCyclesTimer(); 60024 nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an 60025 // opportunity to paint. 60026 60027 requestPaint(); 60028 60029 { 60030 popInteractions(prevInteractions); 60031 } 60032 60033 executionContext = prevExecutionContext; 60034 } else { 60035 // No effects. 60036 root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were 60037 // no effects. 60038 // TODO: Maybe there's a better way to report this. 60039 60040 startCommitSnapshotEffectsTimer(); 60041 stopCommitSnapshotEffectsTimer(); 60042 60043 { 60044 recordCommitTime(); 60045 } 60046 60047 startCommitHostEffectsTimer(); 60048 stopCommitHostEffectsTimer(); 60049 startCommitLifeCyclesTimer(); 60050 stopCommitLifeCyclesTimer(); 60051 } 60052 60053 stopCommitTimer(); 60054 var rootDidHavePassiveEffects = rootDoesHavePassiveEffects; 60055 60056 if (rootDoesHavePassiveEffects) { 60057 // This commit has passive effects. Stash a reference to them. But don't 60058 // schedule a callback until after flushing layout work. 60059 rootDoesHavePassiveEffects = false; 60060 rootWithPendingPassiveEffects = root; 60061 pendingPassiveEffectsExpirationTime = expirationTime; 60062 pendingPassiveEffectsRenderPriority = renderPriorityLevel; 60063 } else { 60064 // We are done with the effect chain at this point so let's clear the 60065 // nextEffect pointers to assist with GC. If we have passive effects, we'll 60066 // clear this in flushPassiveEffects. 60067 nextEffect = firstEffect; 60068 60069 while (nextEffect !== null) { 60070 var nextNextEffect = nextEffect.nextEffect; 60071 nextEffect.nextEffect = null; 60072 nextEffect = nextNextEffect; 60073 } 60074 } // Check if there's remaining work on this root 60075 60076 60077 var remainingExpirationTime = root.firstPendingTime; 60078 60079 if (remainingExpirationTime !== NoWork) { 60080 { 60081 if (spawnedWorkDuringRender !== null) { 60082 var expirationTimes = spawnedWorkDuringRender; 60083 spawnedWorkDuringRender = null; 60084 60085 for (var i = 0; i < expirationTimes.length; i++) { 60086 scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions); 60087 } 60088 } 60089 60090 schedulePendingInteractions(root, remainingExpirationTime); 60091 } 60092 } else { 60093 // If there's no remaining work, we can clear the set of already failed 60094 // error boundaries. 60095 legacyErrorBoundariesThatAlreadyFailed = null; 60096 } 60097 60098 { 60099 if (!rootDidHavePassiveEffects) { 60100 // If there are no passive effects, then we can complete the pending interactions. 60101 // Otherwise, we'll wait until after the passive effects are flushed. 60102 // Wait to do this until after remaining work has been scheduled, 60103 // so that we don't prematurely signal complete for interactions when there's e.g. hidden work. 60104 finishPendingInteractions(root, expirationTime); 60105 } 60106 } 60107 60108 if (remainingExpirationTime === Sync) { 60109 // Count the number of times the root synchronously re-renders without 60110 // finishing. If there are too many, it indicates an infinite update loop. 60111 if (root === rootWithNestedUpdates) { 60112 nestedUpdateCount++; 60113 } else { 60114 nestedUpdateCount = 0; 60115 rootWithNestedUpdates = root; 60116 } 60117 } else { 60118 nestedUpdateCount = 0; 60119 } 60120 60121 onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any 60122 // additional work on this root is scheduled. 60123 60124 ensureRootIsScheduled(root); 60125 60126 if (hasUncaughtError) { 60127 hasUncaughtError = false; 60128 var _error3 = firstUncaughtError; 60129 firstUncaughtError = null; 60130 throw _error3; 60131 } 60132 60133 if ((executionContext & LegacyUnbatchedContext) !== NoContext) { 60134 // This is a legacy edge case. We just committed the initial mount of 60135 // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired 60136 // synchronously, but layout updates should be deferred until the end 60137 // of the batch. 60138 return null; 60139 } // If layout work was scheduled, flush it now. 60140 60141 60142 flushSyncCallbackQueue(); 60143 return null; 60144} 60145 60146function commitBeforeMutationEffects() { 60147 while (nextEffect !== null) { 60148 var effectTag = nextEffect.effectTag; 60149 60150 if ((effectTag & Snapshot) !== NoEffect) { 60151 setCurrentFiber(nextEffect); 60152 recordEffect(); 60153 var current = nextEffect.alternate; 60154 commitBeforeMutationLifeCycles(current, nextEffect); 60155 resetCurrentFiber(); 60156 } 60157 60158 if ((effectTag & Passive) !== NoEffect) { 60159 // If there are passive effects, schedule a callback to flush at 60160 // the earliest opportunity. 60161 if (!rootDoesHavePassiveEffects) { 60162 rootDoesHavePassiveEffects = true; 60163 scheduleCallback(NormalPriority, function () { 60164 flushPassiveEffects(); 60165 return null; 60166 }); 60167 } 60168 } 60169 60170 nextEffect = nextEffect.nextEffect; 60171 } 60172} 60173 60174function commitMutationEffects(root, renderPriorityLevel) { 60175 // TODO: Should probably move the bulk of this function to commitWork. 60176 while (nextEffect !== null) { 60177 setCurrentFiber(nextEffect); 60178 var effectTag = nextEffect.effectTag; 60179 60180 if (effectTag & ContentReset) { 60181 commitResetTextContent(nextEffect); 60182 } 60183 60184 if (effectTag & Ref) { 60185 var current = nextEffect.alternate; 60186 60187 if (current !== null) { 60188 commitDetachRef(current); 60189 } 60190 } // The following switch statement is only concerned about placement, 60191 // updates, and deletions. To avoid needing to add a case for every possible 60192 // bitmap value, we remove the secondary effects from the effect tag and 60193 // switch on that value. 60194 60195 60196 var primaryEffectTag = effectTag & (Placement | Update | Deletion | Hydrating); 60197 60198 switch (primaryEffectTag) { 60199 case Placement: 60200 { 60201 commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is 60202 // inserted, before any life-cycles like componentDidMount gets called. 60203 // TODO: findDOMNode doesn't rely on this any more but isMounted does 60204 // and isMounted is deprecated anyway so we should be able to kill this. 60205 60206 nextEffect.effectTag &= ~Placement; 60207 break; 60208 } 60209 60210 case PlacementAndUpdate: 60211 { 60212 // Placement 60213 commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is 60214 // inserted, before any life-cycles like componentDidMount gets called. 60215 60216 nextEffect.effectTag &= ~Placement; // Update 60217 60218 var _current = nextEffect.alternate; 60219 commitWork(_current, nextEffect); 60220 break; 60221 } 60222 60223 case Hydrating: 60224 { 60225 nextEffect.effectTag &= ~Hydrating; 60226 break; 60227 } 60228 60229 case HydratingAndUpdate: 60230 { 60231 nextEffect.effectTag &= ~Hydrating; // Update 60232 60233 var _current2 = nextEffect.alternate; 60234 commitWork(_current2, nextEffect); 60235 break; 60236 } 60237 60238 case Update: 60239 { 60240 var _current3 = nextEffect.alternate; 60241 commitWork(_current3, nextEffect); 60242 break; 60243 } 60244 60245 case Deletion: 60246 { 60247 commitDeletion(root, nextEffect, renderPriorityLevel); 60248 break; 60249 } 60250 } // TODO: Only record a mutation effect if primaryEffectTag is non-zero. 60251 60252 60253 recordEffect(); 60254 resetCurrentFiber(); 60255 nextEffect = nextEffect.nextEffect; 60256 } 60257} 60258 60259function commitLayoutEffects(root, committedExpirationTime) { 60260 // TODO: Should probably move the bulk of this function to commitWork. 60261 while (nextEffect !== null) { 60262 setCurrentFiber(nextEffect); 60263 var effectTag = nextEffect.effectTag; 60264 60265 if (effectTag & (Update | Callback)) { 60266 recordEffect(); 60267 var current = nextEffect.alternate; 60268 commitLifeCycles(root, current, nextEffect); 60269 } 60270 60271 if (effectTag & Ref) { 60272 recordEffect(); 60273 commitAttachRef(nextEffect); 60274 } 60275 60276 resetCurrentFiber(); 60277 nextEffect = nextEffect.nextEffect; 60278 } 60279} 60280 60281function flushPassiveEffects() { 60282 if (pendingPassiveEffectsRenderPriority !== NoPriority) { 60283 var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority ? NormalPriority : pendingPassiveEffectsRenderPriority; 60284 pendingPassiveEffectsRenderPriority = NoPriority; 60285 return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl); 60286 } 60287} 60288 60289function flushPassiveEffectsImpl() { 60290 if (rootWithPendingPassiveEffects === null) { 60291 return false; 60292 } 60293 60294 var root = rootWithPendingPassiveEffects; 60295 var expirationTime = pendingPassiveEffectsExpirationTime; 60296 rootWithPendingPassiveEffects = null; 60297 pendingPassiveEffectsExpirationTime = NoWork; 60298 60299 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 60300 { 60301 throw Error( "Cannot flush passive effects while already rendering." ); 60302 } 60303 } 60304 60305 var prevExecutionContext = executionContext; 60306 executionContext |= CommitContext; 60307 var prevInteractions = pushInteractions(root); 60308 60309 { 60310 // Note: This currently assumes there are no passive effects on the root fiber 60311 // because the root is not part of its own effect list. 60312 // This could change in the future. 60313 var _effect2 = root.current.firstEffect; 60314 60315 while (_effect2 !== null) { 60316 { 60317 setCurrentFiber(_effect2); 60318 invokeGuardedCallback(null, commitPassiveHookEffects, null, _effect2); 60319 60320 if (hasCaughtError()) { 60321 if (!(_effect2 !== null)) { 60322 { 60323 throw Error( "Should be working on an effect." ); 60324 } 60325 } 60326 60327 var _error5 = clearCaughtError(); 60328 60329 captureCommitPhaseError(_effect2, _error5); 60330 } 60331 60332 resetCurrentFiber(); 60333 } 60334 60335 var nextNextEffect = _effect2.nextEffect; // Remove nextEffect pointer to assist GC 60336 60337 _effect2.nextEffect = null; 60338 _effect2 = nextNextEffect; 60339 } 60340 } 60341 60342 { 60343 popInteractions(prevInteractions); 60344 finishPendingInteractions(root, expirationTime); 60345 } 60346 60347 executionContext = prevExecutionContext; 60348 flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this 60349 // exceeds the limit, we'll fire a warning. 60350 60351 nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1; 60352 return true; 60353} 60354 60355function isAlreadyFailedLegacyErrorBoundary(instance) { 60356 return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance); 60357} 60358function markLegacyErrorBoundaryAsFailed(instance) { 60359 if (legacyErrorBoundariesThatAlreadyFailed === null) { 60360 legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); 60361 } else { 60362 legacyErrorBoundariesThatAlreadyFailed.add(instance); 60363 } 60364} 60365 60366function prepareToThrowUncaughtError(error) { 60367 if (!hasUncaughtError) { 60368 hasUncaughtError = true; 60369 firstUncaughtError = error; 60370 } 60371} 60372 60373var onUncaughtError = prepareToThrowUncaughtError; 60374 60375function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { 60376 var errorInfo = createCapturedValue(error, sourceFiber); 60377 var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); 60378 enqueueUpdate(rootFiber, update); 60379 var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); 60380 60381 if (root !== null) { 60382 ensureRootIsScheduled(root); 60383 schedulePendingInteractions(root, Sync); 60384 } 60385} 60386 60387function captureCommitPhaseError(sourceFiber, error) { 60388 if (sourceFiber.tag === HostRoot) { 60389 // Error was thrown at the root. There is no parent, so the root 60390 // itself should capture it. 60391 captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); 60392 return; 60393 } 60394 60395 var fiber = sourceFiber.return; 60396 60397 while (fiber !== null) { 60398 if (fiber.tag === HostRoot) { 60399 captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); 60400 return; 60401 } else if (fiber.tag === ClassComponent) { 60402 var ctor = fiber.type; 60403 var instance = fiber.stateNode; 60404 60405 if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) { 60406 var errorInfo = createCapturedValue(error, sourceFiber); 60407 var update = createClassErrorUpdate(fiber, errorInfo, // TODO: This is always sync 60408 Sync); 60409 enqueueUpdate(fiber, update); 60410 var root = markUpdateTimeFromFiberToRoot(fiber, Sync); 60411 60412 if (root !== null) { 60413 ensureRootIsScheduled(root); 60414 schedulePendingInteractions(root, Sync); 60415 } 60416 60417 return; 60418 } 60419 } 60420 60421 fiber = fiber.return; 60422 } 60423} 60424function pingSuspendedRoot(root, thenable, suspendedTime) { 60425 var pingCache = root.pingCache; 60426 60427 if (pingCache !== null) { 60428 // The thenable resolved, so we no longer need to memoize, because it will 60429 // never be thrown again. 60430 pingCache.delete(thenable); 60431 } 60432 60433 if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) { 60434 // Received a ping at the same priority level at which we're currently 60435 // rendering. We might want to restart this render. This should mirror 60436 // the logic of whether or not a root suspends once it completes. 60437 // TODO: If we're rendering sync either due to Sync, Batched or expired, 60438 // we should probably never restart. 60439 // If we're suspended with delay, we'll always suspend so we can always 60440 // restart. If we're suspended without any updates, it might be a retry. 60441 // If it's early in the retry we can restart. We can't know for sure 60442 // whether we'll eventually process an update during this render pass, 60443 // but it's somewhat unlikely that we get to a ping before that, since 60444 // getting to the root most update is usually very fast. 60445 if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) { 60446 // Restart from the root. Don't need to schedule a ping because 60447 // we're already working on this tree. 60448 prepareFreshStack(root, renderExpirationTime$1); 60449 } else { 60450 // Even though we can't restart right now, we might get an 60451 // opportunity later. So we mark this render as having a ping. 60452 workInProgressRootHasPendingPing = true; 60453 } 60454 60455 return; 60456 } 60457 60458 if (!isRootSuspendedAtTime(root, suspendedTime)) { 60459 // The root is no longer suspended at this time. 60460 return; 60461 } 60462 60463 var lastPingedTime = root.lastPingedTime; 60464 60465 if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) { 60466 // There's already a lower priority ping scheduled. 60467 return; 60468 } // Mark the time at which this ping was scheduled. 60469 60470 60471 root.lastPingedTime = suspendedTime; 60472 60473 ensureRootIsScheduled(root); 60474 schedulePendingInteractions(root, suspendedTime); 60475} 60476 60477function retryTimedOutBoundary(boundaryFiber, retryTime) { 60478 // The boundary fiber (a Suspense component or SuspenseList component) 60479 // previously was rendered in its fallback state. One of the promises that 60480 // suspended it has resolved, which means at least part of the tree was 60481 // likely unblocked. Try rendering again, at a new expiration time. 60482 if (retryTime === NoWork) { 60483 var suspenseConfig = null; // Retries don't carry over the already committed update. 60484 60485 var currentTime = requestCurrentTimeForUpdate(); 60486 retryTime = computeExpirationForFiber(currentTime, boundaryFiber, suspenseConfig); 60487 } // TODO: Special case idle priority? 60488 60489 60490 var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime); 60491 60492 if (root !== null) { 60493 ensureRootIsScheduled(root); 60494 schedulePendingInteractions(root, retryTime); 60495 } 60496} 60497function resolveRetryThenable(boundaryFiber, thenable) { 60498 var retryTime = NoWork; // Default 60499 60500 var retryCache; 60501 60502 { 60503 retryCache = boundaryFiber.stateNode; 60504 } 60505 60506 if (retryCache !== null) { 60507 // The thenable resolved, so we no longer need to memoize, because it will 60508 // never be thrown again. 60509 retryCache.delete(thenable); 60510 } 60511 60512 retryTimedOutBoundary(boundaryFiber, retryTime); 60513} // Computes the next Just Noticeable Difference (JND) boundary. 60514// The theory is that a person can't tell the difference between small differences in time. 60515// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable 60516// difference in the experience. However, waiting for longer might mean that we can avoid 60517// showing an intermediate loading state. The longer we have already waited, the harder it 60518// is to tell small differences in time. Therefore, the longer we've already waited, 60519// the longer we can wait additionally. At some point we have to give up though. 60520// We pick a train model where the next boundary commits at a consistent schedule. 60521// These particular numbers are vague estimates. We expect to adjust them based on research. 60522 60523function jnd(timeElapsed) { 60524 return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960; 60525} 60526 60527function computeMsUntilSuspenseLoadingDelay(mostRecentEventTime, committedExpirationTime, suspenseConfig) { 60528 var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0; 60529 60530 if (busyMinDurationMs <= 0) { 60531 return 0; 60532 } 60533 60534 var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire. 60535 60536 var currentTimeMs = now(); 60537 var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(mostRecentEventTime, suspenseConfig); 60538 var timeElapsed = currentTimeMs - eventTimeMs; 60539 60540 if (timeElapsed <= busyDelayMs) { 60541 // If we haven't yet waited longer than the initial delay, we don't 60542 // have to wait any additional time. 60543 return 0; 60544 } 60545 60546 var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`. 60547 60548 return msUntilTimeout; 60549} 60550 60551function checkForNestedUpdates() { 60552 if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { 60553 nestedUpdateCount = 0; 60554 rootWithNestedUpdates = null; 60555 60556 { 60557 { 60558 throw Error( "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." ); 60559 } 60560 } 60561 } 60562 60563 { 60564 if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { 60565 nestedPassiveUpdateCount = 0; 60566 60567 error('Maximum update depth exceeded. This can happen when a component ' + "calls setState inside useEffect, but useEffect either doesn't " + 'have a dependency array, or one of the dependencies changes on ' + 'every render.'); 60568 } 60569 } 60570} 60571 60572function flushRenderPhaseStrictModeWarningsInDEV() { 60573 { 60574 ReactStrictModeWarnings.flushLegacyContextWarning(); 60575 60576 { 60577 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); 60578 } 60579 } 60580} 60581 60582function stopFinishedWorkLoopTimer() { 60583 var didCompleteRoot = true; 60584 stopWorkLoopTimer(interruptedBy, didCompleteRoot); 60585 interruptedBy = null; 60586} 60587 60588function stopInterruptedWorkLoopTimer() { 60589 // TODO: Track which fiber caused the interruption. 60590 var didCompleteRoot = false; 60591 stopWorkLoopTimer(interruptedBy, didCompleteRoot); 60592 interruptedBy = null; 60593} 60594 60595function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) { 60596 if ( workInProgressRoot !== null && updateExpirationTime > renderExpirationTime$1) { 60597 interruptedBy = fiberThatReceivedUpdate; 60598 } 60599} 60600 60601var didWarnStateUpdateForUnmountedComponent = null; 60602 60603function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { 60604 { 60605 var tag = fiber.tag; 60606 60607 if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) { 60608 // Only warn for user-defined components, not internal ones like Suspense. 60609 return; 60610 } 60611 // the problematic code almost always lies inside that component. 60612 60613 60614 var componentName = getComponentName(fiber.type) || 'ReactComponent'; 60615 60616 if (didWarnStateUpdateForUnmountedComponent !== null) { 60617 if (didWarnStateUpdateForUnmountedComponent.has(componentName)) { 60618 return; 60619 } 60620 60621 didWarnStateUpdateForUnmountedComponent.add(componentName); 60622 } else { 60623 didWarnStateUpdateForUnmountedComponent = new Set([componentName]); 60624 } 60625 60626 error("Can't perform a React state update 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 %s.%s', tag === ClassComponent ? 'the componentWillUnmount method' : 'a useEffect cleanup function', getStackByFiberInDevAndProd(fiber)); 60627 } 60628} 60629 60630var beginWork$1; 60631 60632{ 60633 var dummyFiber = null; 60634 60635 beginWork$1 = function (current, unitOfWork, expirationTime) { 60636 // If a component throws an error, we replay it again in a synchronously 60637 // dispatched event, so that the debugger will treat it as an uncaught 60638 // error See ReactErrorUtils for more information. 60639 // Before entering the begin phase, copy the work-in-progress onto a dummy 60640 // fiber. If beginWork throws, we'll use this to reset the state. 60641 var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork); 60642 60643 try { 60644 return beginWork(current, unitOfWork, expirationTime); 60645 } catch (originalError) { 60646 if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') { 60647 // Don't replay promises. Treat everything else like an error. 60648 throw originalError; 60649 } // Keep this code in sync with handleError; any changes here must have 60650 // corresponding changes there. 60651 60652 60653 resetContextDependencies(); 60654 resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the 60655 // same fiber again. 60656 // Unwind the failed stack frame 60657 60658 unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber. 60659 60660 assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); 60661 60662 if ( unitOfWork.mode & ProfileMode) { 60663 // Reset the profiler timer. 60664 startProfilerTimer(unitOfWork); 60665 } // Run beginWork again. 60666 60667 60668 invokeGuardedCallback(null, beginWork, null, current, unitOfWork, expirationTime); 60669 60670 if (hasCaughtError()) { 60671 var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. 60672 // Rethrow this error instead of the original one. 60673 60674 throw replayError; 60675 } else { 60676 // This branch is reachable if the render phase is impure. 60677 throw originalError; 60678 } 60679 } 60680 }; 60681} 60682 60683var didWarnAboutUpdateInRender = false; 60684var didWarnAboutUpdateInRenderForAnotherComponent; 60685 60686{ 60687 didWarnAboutUpdateInRenderForAnotherComponent = new Set(); 60688} 60689 60690function warnAboutRenderPhaseUpdatesInDEV(fiber) { 60691 { 60692 if (isRendering && (executionContext & RenderContext) !== NoContext) { 60693 switch (fiber.tag) { 60694 case FunctionComponent: 60695 case ForwardRef: 60696 case SimpleMemoComponent: 60697 { 60698 var renderingComponentName = workInProgress && getComponentName(workInProgress.type) || 'Unknown'; // Dedupe by the rendering component because it's the one that needs to be fixed. 60699 60700 var dedupeKey = renderingComponentName; 60701 60702 if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) { 60703 didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey); 60704 var setStateComponentName = getComponentName(fiber.type) || 'Unknown'; 60705 60706 error('Cannot update a component (`%s`) while rendering a ' + 'different component (`%s`). To locate the bad setState() call inside `%s`, ' + 'follow the stack trace as described in https://fb.me/setstate-in-render', setStateComponentName, renderingComponentName, renderingComponentName); 60707 } 60708 60709 break; 60710 } 60711 60712 case ClassComponent: 60713 { 60714 if (!didWarnAboutUpdateInRender) { 60715 error('Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure ' + 'function of props and state.'); 60716 60717 didWarnAboutUpdateInRender = true; 60718 } 60719 60720 break; 60721 } 60722 } 60723 } 60724 } 60725} // a 'shared' variable that changes when act() opens/closes in tests. 60726 60727 60728var IsThisRendererActing = { 60729 current: false 60730}; 60731function warnIfNotScopedWithMatchingAct(fiber) { 60732 { 60733 if ( IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) { 60734 error("It looks like you're using the wrong act() around your test interactions.\n" + 'Be sure to use the matching version of act() corresponding to your renderer:\n\n' + '// for react-dom:\n' + "import {act} from 'react-dom/test-utils';\n" + '// ...\n' + 'act(() => ...);\n\n' + '// for react-test-renderer:\n' + "import TestRenderer from 'react-test-renderer';\n" + 'const {act} = TestRenderer;\n' + '// ...\n' + 'act(() => ...);' + '%s', getStackByFiberInDevAndProd(fiber)); 60735 } 60736 } 60737} 60738function warnIfNotCurrentlyActingEffectsInDEV(fiber) { 60739 { 60740 if ( (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) { 60741 error('An update to %s ran an effect, but was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber)); 60742 } 60743 } 60744} 60745 60746function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { 60747 { 60748 if ( executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) { 60749 error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber)); 60750 } 60751 } 60752} 60753 60754var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler. 60755 60756var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked 60757// scheduler is the actual recommendation. The alternative could be a testing build, 60758// a new lib, or whatever; we dunno just yet. This message is for early adopters 60759// to get their tests right. 60760 60761function warnIfUnmockedScheduler(fiber) { 60762 { 60763 if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) { 60764 if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { 60765 didWarnAboutUnmockedScheduler = true; 60766 60767 error('In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler'); 60768 } 60769 } 60770 } 60771} 60772 60773function computeThreadID(root, expirationTime) { 60774 // Interaction threads are unique per root and expiration time. 60775 return expirationTime * 1000 + root.interactionThreadID; 60776} 60777 60778function markSpawnedWork(expirationTime) { 60779 60780 if (spawnedWorkDuringRender === null) { 60781 spawnedWorkDuringRender = [expirationTime]; 60782 } else { 60783 spawnedWorkDuringRender.push(expirationTime); 60784 } 60785} 60786 60787function scheduleInteractions(root, expirationTime, interactions) { 60788 60789 if (interactions.size > 0) { 60790 var pendingInteractionMap = root.pendingInteractionMap; 60791 var pendingInteractions = pendingInteractionMap.get(expirationTime); 60792 60793 if (pendingInteractions != null) { 60794 interactions.forEach(function (interaction) { 60795 if (!pendingInteractions.has(interaction)) { 60796 // Update the pending async work count for previously unscheduled interaction. 60797 interaction.__count++; 60798 } 60799 60800 pendingInteractions.add(interaction); 60801 }); 60802 } else { 60803 pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions. 60804 60805 interactions.forEach(function (interaction) { 60806 interaction.__count++; 60807 }); 60808 } 60809 60810 var subscriber = tracing.__subscriberRef.current; 60811 60812 if (subscriber !== null) { 60813 var threadID = computeThreadID(root, expirationTime); 60814 subscriber.onWorkScheduled(interactions, threadID); 60815 } 60816 } 60817} 60818 60819function schedulePendingInteractions(root, expirationTime) { 60820 60821 scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current); 60822} 60823 60824function startWorkOnPendingInteractions(root, expirationTime) { 60825 // we can accurately attribute time spent working on it, And so that cascading 60826 // work triggered during the render phase will be associated with it. 60827 60828 60829 var interactions = new Set(); 60830 root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) { 60831 if (scheduledExpirationTime >= expirationTime) { 60832 scheduledInteractions.forEach(function (interaction) { 60833 return interactions.add(interaction); 60834 }); 60835 } 60836 }); // Store the current set of interactions on the FiberRoot for a few reasons: 60837 // We can re-use it in hot functions like performConcurrentWorkOnRoot() 60838 // without having to recalculate it. We will also use it in commitWork() to 60839 // pass to any Profiler onRender() hooks. This also provides DevTools with a 60840 // way to access it when the onCommitRoot() hook is called. 60841 60842 root.memoizedInteractions = interactions; 60843 60844 if (interactions.size > 0) { 60845 var subscriber = tracing.__subscriberRef.current; 60846 60847 if (subscriber !== null) { 60848 var threadID = computeThreadID(root, expirationTime); 60849 60850 try { 60851 subscriber.onWorkStarted(interactions, threadID); 60852 } catch (error) { 60853 // If the subscriber throws, rethrow it in a separate task 60854 scheduleCallback(ImmediatePriority, function () { 60855 throw error; 60856 }); 60857 } 60858 } 60859 } 60860} 60861 60862function finishPendingInteractions(root, committedExpirationTime) { 60863 60864 var earliestRemainingTimeAfterCommit = root.firstPendingTime; 60865 var subscriber; 60866 60867 try { 60868 subscriber = tracing.__subscriberRef.current; 60869 60870 if (subscriber !== null && root.memoizedInteractions.size > 0) { 60871 var threadID = computeThreadID(root, committedExpirationTime); 60872 subscriber.onWorkStopped(root.memoizedInteractions, threadID); 60873 } 60874 } catch (error) { 60875 // If the subscriber throws, rethrow it in a separate task 60876 scheduleCallback(ImmediatePriority, function () { 60877 throw error; 60878 }); 60879 } finally { 60880 // Clear completed interactions from the pending Map. 60881 // Unless the render was suspended or cascading work was scheduled, 60882 // In which case– leave pending interactions until the subsequent render. 60883 var pendingInteractionMap = root.pendingInteractionMap; 60884 pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) { 60885 // Only decrement the pending interaction count if we're done. 60886 // If there's still work at the current priority, 60887 // That indicates that we are waiting for suspense data. 60888 if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { 60889 pendingInteractionMap.delete(scheduledExpirationTime); 60890 scheduledInteractions.forEach(function (interaction) { 60891 interaction.__count--; 60892 60893 if (subscriber !== null && interaction.__count === 0) { 60894 try { 60895 subscriber.onInteractionScheduledWorkCompleted(interaction); 60896 } catch (error) { 60897 // If the subscriber throws, rethrow it in a separate task 60898 scheduleCallback(ImmediatePriority, function () { 60899 throw error; 60900 }); 60901 } 60902 } 60903 }); 60904 } 60905 }); 60906 } 60907} 60908 60909var onScheduleFiberRoot = null; 60910var onCommitFiberRoot = null; 60911var onCommitFiberUnmount = null; 60912var hasLoggedError = false; 60913var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined'; 60914function injectInternals(internals) { 60915 if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { 60916 // No DevTools 60917 return false; 60918 } 60919 60920 var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; 60921 60922 if (hook.isDisabled) { 60923 // This isn't a real property on the hook, but it can be set to opt out 60924 // of DevTools integration and associated warnings and logs. 60925 // https://github.com/facebook/react/issues/3877 60926 return true; 60927 } 60928 60929 if (!hook.supportsFiber) { 60930 { 60931 error('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'); 60932 } // DevTools exists, even though it doesn't support Fiber. 60933 60934 60935 return true; 60936 } 60937 60938 try { 60939 var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. 60940 60941 if (true) { 60942 // Only used by Fast Refresh 60943 if (typeof hook.onScheduleFiberRoot === 'function') { 60944 onScheduleFiberRoot = function (root, children) { 60945 try { 60946 hook.onScheduleFiberRoot(rendererID, root, children); 60947 } catch (err) { 60948 if ( true && !hasLoggedError) { 60949 hasLoggedError = true; 60950 60951 error('React instrumentation encountered an error: %s', err); 60952 } 60953 } 60954 }; 60955 } 60956 } 60957 60958 onCommitFiberRoot = function (root, expirationTime) { 60959 try { 60960 var didError = (root.current.effectTag & DidCapture) === DidCapture; 60961 60962 if (enableProfilerTimer) { 60963 var currentTime = getCurrentTime(); 60964 var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime); 60965 hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); 60966 } else { 60967 hook.onCommitFiberRoot(rendererID, root, undefined, didError); 60968 } 60969 } catch (err) { 60970 if (true) { 60971 if (!hasLoggedError) { 60972 hasLoggedError = true; 60973 60974 error('React instrumentation encountered an error: %s', err); 60975 } 60976 } 60977 } 60978 }; 60979 60980 onCommitFiberUnmount = function (fiber) { 60981 try { 60982 hook.onCommitFiberUnmount(rendererID, fiber); 60983 } catch (err) { 60984 if (true) { 60985 if (!hasLoggedError) { 60986 hasLoggedError = true; 60987 60988 error('React instrumentation encountered an error: %s', err); 60989 } 60990 } 60991 } 60992 }; 60993 } catch (err) { 60994 // Catch all errors because it is unsafe to throw during initialization. 60995 { 60996 error('React instrumentation encountered an error: %s.', err); 60997 } 60998 } // DevTools exists 60999 61000 61001 return true; 61002} 61003function onScheduleRoot(root, children) { 61004 if (typeof onScheduleFiberRoot === 'function') { 61005 onScheduleFiberRoot(root, children); 61006 } 61007} 61008function onCommitRoot(root, expirationTime) { 61009 if (typeof onCommitFiberRoot === 'function') { 61010 onCommitFiberRoot(root, expirationTime); 61011 } 61012} 61013function onCommitUnmount(fiber) { 61014 if (typeof onCommitFiberUnmount === 'function') { 61015 onCommitFiberUnmount(fiber); 61016 } 61017} 61018 61019var hasBadMapPolyfill; 61020 61021{ 61022 hasBadMapPolyfill = false; 61023 61024 try { 61025 var nonExtensibleObject = Object.preventExtensions({}); 61026 var testMap = new Map([[nonExtensibleObject, null]]); 61027 var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused. 61028 // https://github.com/rollup/rollup/issues/1771 61029 // TODO: we can remove these if Rollup fixes the bug. 61030 61031 testMap.set(0, 0); 61032 testSet.add(0); 61033 } catch (e) { 61034 // TODO: Consider warning about bad polyfills 61035 hasBadMapPolyfill = true; 61036 } 61037} 61038 61039var debugCounter = 1; 61040 61041function FiberNode(tag, pendingProps, key, mode) { 61042 // Instance 61043 this.tag = tag; 61044 this.key = key; 61045 this.elementType = null; 61046 this.type = null; 61047 this.stateNode = null; // Fiber 61048 61049 this.return = null; 61050 this.child = null; 61051 this.sibling = null; 61052 this.index = 0; 61053 this.ref = null; 61054 this.pendingProps = pendingProps; 61055 this.memoizedProps = null; 61056 this.updateQueue = null; 61057 this.memoizedState = null; 61058 this.dependencies = null; 61059 this.mode = mode; // Effects 61060 61061 this.effectTag = NoEffect; 61062 this.nextEffect = null; 61063 this.firstEffect = null; 61064 this.lastEffect = null; 61065 this.expirationTime = NoWork; 61066 this.childExpirationTime = NoWork; 61067 this.alternate = null; 61068 61069 { 61070 // Note: The following is done to avoid a v8 performance cliff. 61071 // 61072 // Initializing the fields below to smis and later updating them with 61073 // double values will cause Fibers to end up having separate shapes. 61074 // This behavior/bug has something to do with Object.preventExtension(). 61075 // Fortunately this only impacts DEV builds. 61076 // Unfortunately it makes React unusably slow for some applications. 61077 // To work around this, initialize the fields below with doubles. 61078 // 61079 // Learn more about this here: 61080 // https://github.com/facebook/react/issues/14365 61081 // https://bugs.chromium.org/p/v8/issues/detail?id=8538 61082 this.actualDuration = Number.NaN; 61083 this.actualStartTime = Number.NaN; 61084 this.selfBaseDuration = Number.NaN; 61085 this.treeBaseDuration = Number.NaN; // It's okay to replace the initial doubles with smis after initialization. 61086 // This won't trigger the performance cliff mentioned above, 61087 // and it simplifies other profiler code (including DevTools). 61088 61089 this.actualDuration = 0; 61090 this.actualStartTime = -1; 61091 this.selfBaseDuration = 0; 61092 this.treeBaseDuration = 0; 61093 } // This is normally DEV-only except www when it adds listeners. 61094 // TODO: remove the User Timing integration in favor of Root Events. 61095 61096 61097 { 61098 this._debugID = debugCounter++; 61099 this._debugIsCurrentlyTiming = false; 61100 } 61101 61102 { 61103 this._debugSource = null; 61104 this._debugOwner = null; 61105 this._debugNeedsRemount = false; 61106 this._debugHookTypes = null; 61107 61108 if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') { 61109 Object.preventExtensions(this); 61110 } 61111 } 61112} // This is a constructor function, rather than a POJO constructor, still 61113// please ensure we do the following: 61114// 1) Nobody should add any instance methods on this. Instance methods can be 61115// more difficult to predict when they get optimized and they are almost 61116// never inlined properly in static compilers. 61117// 2) Nobody should rely on `instanceof Fiber` for type testing. We should 61118// always know when it is a fiber. 61119// 3) We might want to experiment with using numeric keys since they are easier 61120// to optimize in a non-JIT environment. 61121// 4) We can easily go from a constructor to a createFiber object literal if that 61122// is faster. 61123// 5) It should be easy to port this to a C struct and keep a C implementation 61124// compatible. 61125 61126 61127var createFiber = function (tag, pendingProps, key, mode) { 61128 // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors 61129 return new FiberNode(tag, pendingProps, key, mode); 61130}; 61131 61132function shouldConstruct(Component) { 61133 var prototype = Component.prototype; 61134 return !!(prototype && prototype.isReactComponent); 61135} 61136 61137function isSimpleFunctionComponent(type) { 61138 return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined; 61139} 61140function resolveLazyComponentTag(Component) { 61141 if (typeof Component === 'function') { 61142 return shouldConstruct(Component) ? ClassComponent : FunctionComponent; 61143 } else if (Component !== undefined && Component !== null) { 61144 var $$typeof = Component.$$typeof; 61145 61146 if ($$typeof === REACT_FORWARD_REF_TYPE) { 61147 return ForwardRef; 61148 } 61149 61150 if ($$typeof === REACT_MEMO_TYPE) { 61151 return MemoComponent; 61152 } 61153 } 61154 61155 return IndeterminateComponent; 61156} // This is used to create an alternate fiber to do work on. 61157 61158function createWorkInProgress(current, pendingProps) { 61159 var workInProgress = current.alternate; 61160 61161 if (workInProgress === null) { 61162 // We use a double buffering pooling technique because we know that we'll 61163 // only ever need at most two versions of a tree. We pool the "other" unused 61164 // node that we're free to reuse. This is lazily created to avoid allocating 61165 // extra objects for things that are never updated. It also allow us to 61166 // reclaim the extra memory if needed. 61167 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode); 61168 workInProgress.elementType = current.elementType; 61169 workInProgress.type = current.type; 61170 workInProgress.stateNode = current.stateNode; 61171 61172 { 61173 // DEV-only fields 61174 { 61175 workInProgress._debugID = current._debugID; 61176 } 61177 61178 workInProgress._debugSource = current._debugSource; 61179 workInProgress._debugOwner = current._debugOwner; 61180 workInProgress._debugHookTypes = current._debugHookTypes; 61181 } 61182 61183 workInProgress.alternate = current; 61184 current.alternate = workInProgress; 61185 } else { 61186 workInProgress.pendingProps = pendingProps; // We already have an alternate. 61187 // Reset the effect tag. 61188 61189 workInProgress.effectTag = NoEffect; // The effect list is no longer valid. 61190 61191 workInProgress.nextEffect = null; 61192 workInProgress.firstEffect = null; 61193 workInProgress.lastEffect = null; 61194 61195 { 61196 // We intentionally reset, rather than copy, actualDuration & actualStartTime. 61197 // This prevents time from endlessly accumulating in new commits. 61198 // This has the downside of resetting values for different priority renders, 61199 // But works for yielding (the common case) and should support resuming. 61200 workInProgress.actualDuration = 0; 61201 workInProgress.actualStartTime = -1; 61202 } 61203 } 61204 61205 workInProgress.childExpirationTime = current.childExpirationTime; 61206 workInProgress.expirationTime = current.expirationTime; 61207 workInProgress.child = current.child; 61208 workInProgress.memoizedProps = current.memoizedProps; 61209 workInProgress.memoizedState = current.memoizedState; 61210 workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so 61211 // it cannot be shared with the current fiber. 61212 61213 var currentDependencies = current.dependencies; 61214 workInProgress.dependencies = currentDependencies === null ? null : { 61215 expirationTime: currentDependencies.expirationTime, 61216 firstContext: currentDependencies.firstContext, 61217 responders: currentDependencies.responders 61218 }; // These will be overridden during the parent's reconciliation 61219 61220 workInProgress.sibling = current.sibling; 61221 workInProgress.index = current.index; 61222 workInProgress.ref = current.ref; 61223 61224 { 61225 workInProgress.selfBaseDuration = current.selfBaseDuration; 61226 workInProgress.treeBaseDuration = current.treeBaseDuration; 61227 } 61228 61229 { 61230 workInProgress._debugNeedsRemount = current._debugNeedsRemount; 61231 61232 switch (workInProgress.tag) { 61233 case IndeterminateComponent: 61234 case FunctionComponent: 61235 case SimpleMemoComponent: 61236 workInProgress.type = resolveFunctionForHotReloading(current.type); 61237 break; 61238 61239 case ClassComponent: 61240 workInProgress.type = resolveClassForHotReloading(current.type); 61241 break; 61242 61243 case ForwardRef: 61244 workInProgress.type = resolveForwardRefForHotReloading(current.type); 61245 break; 61246 } 61247 } 61248 61249 return workInProgress; 61250} // Used to reuse a Fiber for a second pass. 61251 61252function resetWorkInProgress(workInProgress, renderExpirationTime) { 61253 // This resets the Fiber to what createFiber or createWorkInProgress would 61254 // have set the values to before during the first pass. Ideally this wouldn't 61255 // be necessary but unfortunately many code paths reads from the workInProgress 61256 // when they should be reading from current and writing to workInProgress. 61257 // We assume pendingProps, index, key, ref, return are still untouched to 61258 // avoid doing another reconciliation. 61259 // Reset the effect tag but keep any Placement tags, since that's something 61260 // that child fiber is setting, not the reconciliation. 61261 workInProgress.effectTag &= Placement; // The effect list is no longer valid. 61262 61263 workInProgress.nextEffect = null; 61264 workInProgress.firstEffect = null; 61265 workInProgress.lastEffect = null; 61266 var current = workInProgress.alternate; 61267 61268 if (current === null) { 61269 // Reset to createFiber's initial values. 61270 workInProgress.childExpirationTime = NoWork; 61271 workInProgress.expirationTime = renderExpirationTime; 61272 workInProgress.child = null; 61273 workInProgress.memoizedProps = null; 61274 workInProgress.memoizedState = null; 61275 workInProgress.updateQueue = null; 61276 workInProgress.dependencies = null; 61277 61278 { 61279 // Note: We don't reset the actualTime counts. It's useful to accumulate 61280 // actual time across multiple render passes. 61281 workInProgress.selfBaseDuration = 0; 61282 workInProgress.treeBaseDuration = 0; 61283 } 61284 } else { 61285 // Reset to the cloned values that createWorkInProgress would've. 61286 workInProgress.childExpirationTime = current.childExpirationTime; 61287 workInProgress.expirationTime = current.expirationTime; 61288 workInProgress.child = current.child; 61289 workInProgress.memoizedProps = current.memoizedProps; 61290 workInProgress.memoizedState = current.memoizedState; 61291 workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so 61292 // it cannot be shared with the current fiber. 61293 61294 var currentDependencies = current.dependencies; 61295 workInProgress.dependencies = currentDependencies === null ? null : { 61296 expirationTime: currentDependencies.expirationTime, 61297 firstContext: currentDependencies.firstContext, 61298 responders: currentDependencies.responders 61299 }; 61300 61301 { 61302 // Note: We don't reset the actualTime counts. It's useful to accumulate 61303 // actual time across multiple render passes. 61304 workInProgress.selfBaseDuration = current.selfBaseDuration; 61305 workInProgress.treeBaseDuration = current.treeBaseDuration; 61306 } 61307 } 61308 61309 return workInProgress; 61310} 61311function createHostRootFiber(tag) { 61312 var mode; 61313 61314 if (tag === ConcurrentRoot) { 61315 mode = ConcurrentMode | BlockingMode | StrictMode; 61316 } else if (tag === BlockingRoot) { 61317 mode = BlockingMode | StrictMode; 61318 } else { 61319 mode = NoMode; 61320 } 61321 61322 if ( isDevToolsPresent) { 61323 // Always collect profile timings when DevTools are present. 61324 // This enables DevTools to start capturing timing at any point– 61325 // Without some nodes in the tree having empty base times. 61326 mode |= ProfileMode; 61327 } 61328 61329 return createFiber(HostRoot, null, null, mode); 61330} 61331function createFiberFromTypeAndProps(type, // React$ElementType 61332key, pendingProps, owner, mode, expirationTime) { 61333 var fiber; 61334 var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy. 61335 61336 var resolvedType = type; 61337 61338 if (typeof type === 'function') { 61339 if (shouldConstruct(type)) { 61340 fiberTag = ClassComponent; 61341 61342 { 61343 resolvedType = resolveClassForHotReloading(resolvedType); 61344 } 61345 } else { 61346 { 61347 resolvedType = resolveFunctionForHotReloading(resolvedType); 61348 } 61349 } 61350 } else if (typeof type === 'string') { 61351 fiberTag = HostComponent; 61352 } else { 61353 getTag: switch (type) { 61354 case REACT_FRAGMENT_TYPE: 61355 return createFiberFromFragment(pendingProps.children, mode, expirationTime, key); 61356 61357 case REACT_CONCURRENT_MODE_TYPE: 61358 fiberTag = Mode; 61359 mode |= ConcurrentMode | BlockingMode | StrictMode; 61360 break; 61361 61362 case REACT_STRICT_MODE_TYPE: 61363 fiberTag = Mode; 61364 mode |= StrictMode; 61365 break; 61366 61367 case REACT_PROFILER_TYPE: 61368 return createFiberFromProfiler(pendingProps, mode, expirationTime, key); 61369 61370 case REACT_SUSPENSE_TYPE: 61371 return createFiberFromSuspense(pendingProps, mode, expirationTime, key); 61372 61373 case REACT_SUSPENSE_LIST_TYPE: 61374 return createFiberFromSuspenseList(pendingProps, mode, expirationTime, key); 61375 61376 default: 61377 { 61378 if (typeof type === 'object' && type !== null) { 61379 switch (type.$$typeof) { 61380 case REACT_PROVIDER_TYPE: 61381 fiberTag = ContextProvider; 61382 break getTag; 61383 61384 case REACT_CONTEXT_TYPE: 61385 // This is a consumer 61386 fiberTag = ContextConsumer; 61387 break getTag; 61388 61389 case REACT_FORWARD_REF_TYPE: 61390 fiberTag = ForwardRef; 61391 61392 { 61393 resolvedType = resolveForwardRefForHotReloading(resolvedType); 61394 } 61395 61396 break getTag; 61397 61398 case REACT_MEMO_TYPE: 61399 fiberTag = MemoComponent; 61400 break getTag; 61401 61402 case REACT_LAZY_TYPE: 61403 fiberTag = LazyComponent; 61404 resolvedType = null; 61405 break getTag; 61406 61407 case REACT_BLOCK_TYPE: 61408 fiberTag = Block; 61409 break getTag; 61410 61411 } 61412 } 61413 61414 var info = ''; 61415 61416 { 61417 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 61418 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.'; 61419 } 61420 61421 var ownerName = owner ? getComponentName(owner.type) : null; 61422 61423 if (ownerName) { 61424 info += '\n\nCheck the render method of `' + ownerName + '`.'; 61425 } 61426 } 61427 61428 { 61429 { 61430 throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info ); 61431 } 61432 } 61433 } 61434 } 61435 } 61436 61437 fiber = createFiber(fiberTag, pendingProps, key, mode); 61438 fiber.elementType = type; 61439 fiber.type = resolvedType; 61440 fiber.expirationTime = expirationTime; 61441 return fiber; 61442} 61443function createFiberFromElement(element, mode, expirationTime) { 61444 var owner = null; 61445 61446 { 61447 owner = element._owner; 61448 } 61449 61450 var type = element.type; 61451 var key = element.key; 61452 var pendingProps = element.props; 61453 var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime); 61454 61455 { 61456 fiber._debugSource = element._source; 61457 fiber._debugOwner = element._owner; 61458 } 61459 61460 return fiber; 61461} 61462function createFiberFromFragment(elements, mode, expirationTime, key) { 61463 var fiber = createFiber(Fragment, elements, key, mode); 61464 fiber.expirationTime = expirationTime; 61465 return fiber; 61466} 61467 61468function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { 61469 { 61470 if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') { 61471 error('Profiler must specify an "id" string and "onRender" function as props'); 61472 } 61473 } 61474 61475 var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); // TODO: The Profiler fiber shouldn't have a type. It has a tag. 61476 61477 fiber.elementType = REACT_PROFILER_TYPE; 61478 fiber.type = REACT_PROFILER_TYPE; 61479 fiber.expirationTime = expirationTime; 61480 return fiber; 61481} 61482 61483function createFiberFromSuspense(pendingProps, mode, expirationTime, key) { 61484 var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag. 61485 // This needs to be fixed in getComponentName so that it relies on the tag 61486 // instead. 61487 61488 fiber.type = REACT_SUSPENSE_TYPE; 61489 fiber.elementType = REACT_SUSPENSE_TYPE; 61490 fiber.expirationTime = expirationTime; 61491 return fiber; 61492} 61493function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) { 61494 var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode); 61495 61496 { 61497 // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag. 61498 // This needs to be fixed in getComponentName so that it relies on the tag 61499 // instead. 61500 fiber.type = REACT_SUSPENSE_LIST_TYPE; 61501 } 61502 61503 fiber.elementType = REACT_SUSPENSE_LIST_TYPE; 61504 fiber.expirationTime = expirationTime; 61505 return fiber; 61506} 61507function createFiberFromText(content, mode, expirationTime) { 61508 var fiber = createFiber(HostText, content, null, mode); 61509 fiber.expirationTime = expirationTime; 61510 return fiber; 61511} 61512function createFiberFromHostInstanceForDeletion() { 61513 var fiber = createFiber(HostComponent, null, null, NoMode); // TODO: These should not need a type. 61514 61515 fiber.elementType = 'DELETED'; 61516 fiber.type = 'DELETED'; 61517 return fiber; 61518} 61519function createFiberFromPortal(portal, mode, expirationTime) { 61520 var pendingProps = portal.children !== null ? portal.children : []; 61521 var fiber = createFiber(HostPortal, pendingProps, portal.key, mode); 61522 fiber.expirationTime = expirationTime; 61523 fiber.stateNode = { 61524 containerInfo: portal.containerInfo, 61525 pendingChildren: null, 61526 // Used by persistent updates 61527 implementation: portal.implementation 61528 }; 61529 return fiber; 61530} // Used for stashing WIP properties to replay failed work in DEV. 61531 61532function assignFiberPropertiesInDEV(target, source) { 61533 if (target === null) { 61534 // This Fiber's initial properties will always be overwritten. 61535 // We only use a Fiber to ensure the same hidden class so DEV isn't slow. 61536 target = createFiber(IndeterminateComponent, null, null, NoMode); 61537 } // This is intentionally written as a list of all properties. 61538 // We tried to use Object.assign() instead but this is called in 61539 // the hottest path, and Object.assign() was too slow: 61540 // https://github.com/facebook/react/issues/12502 61541 // This code is DEV-only so size is not a concern. 61542 61543 61544 target.tag = source.tag; 61545 target.key = source.key; 61546 target.elementType = source.elementType; 61547 target.type = source.type; 61548 target.stateNode = source.stateNode; 61549 target.return = source.return; 61550 target.child = source.child; 61551 target.sibling = source.sibling; 61552 target.index = source.index; 61553 target.ref = source.ref; 61554 target.pendingProps = source.pendingProps; 61555 target.memoizedProps = source.memoizedProps; 61556 target.updateQueue = source.updateQueue; 61557 target.memoizedState = source.memoizedState; 61558 target.dependencies = source.dependencies; 61559 target.mode = source.mode; 61560 target.effectTag = source.effectTag; 61561 target.nextEffect = source.nextEffect; 61562 target.firstEffect = source.firstEffect; 61563 target.lastEffect = source.lastEffect; 61564 target.expirationTime = source.expirationTime; 61565 target.childExpirationTime = source.childExpirationTime; 61566 target.alternate = source.alternate; 61567 61568 { 61569 target.actualDuration = source.actualDuration; 61570 target.actualStartTime = source.actualStartTime; 61571 target.selfBaseDuration = source.selfBaseDuration; 61572 target.treeBaseDuration = source.treeBaseDuration; 61573 } 61574 61575 { 61576 target._debugID = source._debugID; 61577 } 61578 61579 target._debugSource = source._debugSource; 61580 target._debugOwner = source._debugOwner; 61581 target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming; 61582 target._debugNeedsRemount = source._debugNeedsRemount; 61583 target._debugHookTypes = source._debugHookTypes; 61584 return target; 61585} 61586 61587function FiberRootNode(containerInfo, tag, hydrate) { 61588 this.tag = tag; 61589 this.current = null; 61590 this.containerInfo = containerInfo; 61591 this.pendingChildren = null; 61592 this.pingCache = null; 61593 this.finishedExpirationTime = NoWork; 61594 this.finishedWork = null; 61595 this.timeoutHandle = noTimeout; 61596 this.context = null; 61597 this.pendingContext = null; 61598 this.hydrate = hydrate; 61599 this.callbackNode = null; 61600 this.callbackPriority = NoPriority; 61601 this.firstPendingTime = NoWork; 61602 this.firstSuspendedTime = NoWork; 61603 this.lastSuspendedTime = NoWork; 61604 this.nextKnownPendingLevel = NoWork; 61605 this.lastPingedTime = NoWork; 61606 this.lastExpiredTime = NoWork; 61607 61608 { 61609 this.interactionThreadID = tracing.unstable_getThreadID(); 61610 this.memoizedInteractions = new Set(); 61611 this.pendingInteractionMap = new Map(); 61612 } 61613} 61614 61615function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { 61616 var root = new FiberRootNode(containerInfo, tag, hydrate); 61617 // stateNode is any. 61618 61619 61620 var uninitializedFiber = createHostRootFiber(tag); 61621 root.current = uninitializedFiber; 61622 uninitializedFiber.stateNode = root; 61623 initializeUpdateQueue(uninitializedFiber); 61624 return root; 61625} 61626function isRootSuspendedAtTime(root, expirationTime) { 61627 var firstSuspendedTime = root.firstSuspendedTime; 61628 var lastSuspendedTime = root.lastSuspendedTime; 61629 return firstSuspendedTime !== NoWork && firstSuspendedTime >= expirationTime && lastSuspendedTime <= expirationTime; 61630} 61631function markRootSuspendedAtTime(root, expirationTime) { 61632 var firstSuspendedTime = root.firstSuspendedTime; 61633 var lastSuspendedTime = root.lastSuspendedTime; 61634 61635 if (firstSuspendedTime < expirationTime) { 61636 root.firstSuspendedTime = expirationTime; 61637 } 61638 61639 if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) { 61640 root.lastSuspendedTime = expirationTime; 61641 } 61642 61643 if (expirationTime <= root.lastPingedTime) { 61644 root.lastPingedTime = NoWork; 61645 } 61646 61647 if (expirationTime <= root.lastExpiredTime) { 61648 root.lastExpiredTime = NoWork; 61649 } 61650} 61651function markRootUpdatedAtTime(root, expirationTime) { 61652 // Update the range of pending times 61653 var firstPendingTime = root.firstPendingTime; 61654 61655 if (expirationTime > firstPendingTime) { 61656 root.firstPendingTime = expirationTime; 61657 } // Update the range of suspended times. Treat everything lower priority or 61658 // equal to this update as unsuspended. 61659 61660 61661 var firstSuspendedTime = root.firstSuspendedTime; 61662 61663 if (firstSuspendedTime !== NoWork) { 61664 if (expirationTime >= firstSuspendedTime) { 61665 // The entire suspended range is now unsuspended. 61666 root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork; 61667 } else if (expirationTime >= root.lastSuspendedTime) { 61668 root.lastSuspendedTime = expirationTime + 1; 61669 } // This is a pending level. Check if it's higher priority than the next 61670 // known pending level. 61671 61672 61673 if (expirationTime > root.nextKnownPendingLevel) { 61674 root.nextKnownPendingLevel = expirationTime; 61675 } 61676 } 61677} 61678function markRootFinishedAtTime(root, finishedExpirationTime, remainingExpirationTime) { 61679 // Update the range of pending times 61680 root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or 61681 // equal to this update as unsuspended. 61682 61683 if (finishedExpirationTime <= root.lastSuspendedTime) { 61684 // The entire suspended range is now unsuspended. 61685 root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork; 61686 } else if (finishedExpirationTime <= root.firstSuspendedTime) { 61687 // Part of the suspended range is now unsuspended. Narrow the range to 61688 // include everything between the unsuspended time (non-inclusive) and the 61689 // last suspended time. 61690 root.firstSuspendedTime = finishedExpirationTime - 1; 61691 } 61692 61693 if (finishedExpirationTime <= root.lastPingedTime) { 61694 // Clear the pinged time 61695 root.lastPingedTime = NoWork; 61696 } 61697 61698 if (finishedExpirationTime <= root.lastExpiredTime) { 61699 // Clear the expired time 61700 root.lastExpiredTime = NoWork; 61701 } 61702} 61703function markRootExpiredAtTime(root, expirationTime) { 61704 var lastExpiredTime = root.lastExpiredTime; 61705 61706 if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) { 61707 root.lastExpiredTime = expirationTime; 61708 } 61709} 61710 61711var didWarnAboutNestedUpdates; 61712var didWarnAboutFindNodeInStrictMode; 61713 61714{ 61715 didWarnAboutNestedUpdates = false; 61716 didWarnAboutFindNodeInStrictMode = {}; 61717} 61718 61719function getContextForSubtree(parentComponent) { 61720 if (!parentComponent) { 61721 return emptyContextObject; 61722 } 61723 61724 var fiber = get(parentComponent); 61725 var parentContext = findCurrentUnmaskedContext(fiber); 61726 61727 if (fiber.tag === ClassComponent) { 61728 var Component = fiber.type; 61729 61730 if (isContextProvider(Component)) { 61731 return processChildContext(fiber, Component, parentContext); 61732 } 61733 } 61734 61735 return parentContext; 61736} 61737 61738function findHostInstanceWithWarning(component, methodName) { 61739 { 61740 var fiber = get(component); 61741 61742 if (fiber === undefined) { 61743 if (typeof component.render === 'function') { 61744 { 61745 { 61746 throw Error( "Unable to find node on an unmounted component." ); 61747 } 61748 } 61749 } else { 61750 { 61751 { 61752 throw Error( "Argument appears to not be a ReactComponent. Keys: " + Object.keys(component) ); 61753 } 61754 } 61755 } 61756 } 61757 61758 var hostFiber = findCurrentHostFiber(fiber); 61759 61760 if (hostFiber === null) { 61761 return null; 61762 } 61763 61764 if (hostFiber.mode & StrictMode) { 61765 var componentName = getComponentName(fiber.type) || 'Component'; 61766 61767 if (!didWarnAboutFindNodeInStrictMode[componentName]) { 61768 didWarnAboutFindNodeInStrictMode[componentName] = true; 61769 61770 if (fiber.mode & StrictMode) { 61771 error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-find-node%s', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber)); 61772 } else { 61773 error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-find-node%s', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber)); 61774 } 61775 } 61776 } 61777 61778 return hostFiber.stateNode; 61779 } 61780} 61781 61782function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) { 61783 return createFiberRoot(containerInfo, tag, hydrate); 61784} 61785function updateContainer(element, container, parentComponent, callback) { 61786 { 61787 onScheduleRoot(container, element); 61788 } 61789 61790 var current$1 = container.current; 61791 var currentTime = requestCurrentTimeForUpdate(); 61792 61793 { 61794 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 61795 if ('undefined' !== typeof jest) { 61796 warnIfUnmockedScheduler(current$1); 61797 warnIfNotScopedWithMatchingAct(current$1); 61798 } 61799 } 61800 61801 var suspenseConfig = requestCurrentSuspenseConfig(); 61802 var expirationTime = computeExpirationForFiber(currentTime, current$1, suspenseConfig); 61803 var context = getContextForSubtree(parentComponent); 61804 61805 if (container.context === null) { 61806 container.context = context; 61807 } else { 61808 container.pendingContext = context; 61809 } 61810 61811 { 61812 if (isRendering && current !== null && !didWarnAboutNestedUpdates) { 61813 didWarnAboutNestedUpdates = true; 61814 61815 error('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(current.type) || 'Unknown'); 61816 } 61817 } 61818 61819 var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property 61820 // being called "element". 61821 61822 update.payload = { 61823 element: element 61824 }; 61825 callback = callback === undefined ? null : callback; 61826 61827 if (callback !== null) { 61828 { 61829 if (typeof callback !== 'function') { 61830 error('render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback); 61831 } 61832 } 61833 61834 update.callback = callback; 61835 } 61836 61837 enqueueUpdate(current$1, update); 61838 scheduleWork(current$1, expirationTime); 61839 return expirationTime; 61840} 61841function getPublicRootInstance(container) { 61842 var containerFiber = container.current; 61843 61844 if (!containerFiber.child) { 61845 return null; 61846 } 61847 61848 switch (containerFiber.child.tag) { 61849 case HostComponent: 61850 return getPublicInstance(containerFiber.child.stateNode); 61851 61852 default: 61853 return containerFiber.child.stateNode; 61854 } 61855} 61856 61857function markRetryTimeImpl(fiber, retryTime) { 61858 var suspenseState = fiber.memoizedState; 61859 61860 if (suspenseState !== null && suspenseState.dehydrated !== null) { 61861 if (suspenseState.retryTime < retryTime) { 61862 suspenseState.retryTime = retryTime; 61863 } 61864 } 61865} // Increases the priority of thennables when they resolve within this boundary. 61866 61867 61868function markRetryTimeIfNotHydrated(fiber, retryTime) { 61869 markRetryTimeImpl(fiber, retryTime); 61870 var alternate = fiber.alternate; 61871 61872 if (alternate) { 61873 markRetryTimeImpl(alternate, retryTime); 61874 } 61875} 61876 61877function attemptUserBlockingHydration$1(fiber) { 61878 if (fiber.tag !== SuspenseComponent) { 61879 // We ignore HostRoots here because we can't increase 61880 // their priority and they should not suspend on I/O, 61881 // since you have to wrap anything that might suspend in 61882 // Suspense. 61883 return; 61884 } 61885 61886 var expTime = computeInteractiveExpiration(requestCurrentTimeForUpdate()); 61887 scheduleWork(fiber, expTime); 61888 markRetryTimeIfNotHydrated(fiber, expTime); 61889} 61890function attemptContinuousHydration$1(fiber) { 61891 if (fiber.tag !== SuspenseComponent) { 61892 // We ignore HostRoots here because we can't increase 61893 // their priority and they should not suspend on I/O, 61894 // since you have to wrap anything that might suspend in 61895 // Suspense. 61896 return; 61897 } 61898 61899 scheduleWork(fiber, ContinuousHydration); 61900 markRetryTimeIfNotHydrated(fiber, ContinuousHydration); 61901} 61902function attemptHydrationAtCurrentPriority$1(fiber) { 61903 if (fiber.tag !== SuspenseComponent) { 61904 // We ignore HostRoots here because we can't increase 61905 // their priority other than synchronously flush it. 61906 return; 61907 } 61908 61909 var currentTime = requestCurrentTimeForUpdate(); 61910 var expTime = computeExpirationForFiber(currentTime, fiber, null); 61911 scheduleWork(fiber, expTime); 61912 markRetryTimeIfNotHydrated(fiber, expTime); 61913} 61914function findHostInstanceWithNoPortals(fiber) { 61915 var hostFiber = findCurrentHostFiberWithNoPortals(fiber); 61916 61917 if (hostFiber === null) { 61918 return null; 61919 } 61920 61921 if (hostFiber.tag === FundamentalComponent) { 61922 return hostFiber.stateNode.instance; 61923 } 61924 61925 return hostFiber.stateNode; 61926} 61927 61928var shouldSuspendImpl = function (fiber) { 61929 return false; 61930}; 61931 61932function shouldSuspend(fiber) { 61933 return shouldSuspendImpl(fiber); 61934} 61935var overrideHookState = null; 61936var overrideProps = null; 61937var scheduleUpdate = null; 61938var setSuspenseHandler = null; 61939 61940{ 61941 var copyWithSetImpl = function (obj, path, idx, value) { 61942 if (idx >= path.length) { 61943 return value; 61944 } 61945 61946 var key = path[idx]; 61947 var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); // $FlowFixMe number or string is fine here 61948 61949 updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value); 61950 return updated; 61951 }; 61952 61953 var copyWithSet = function (obj, path, value) { 61954 return copyWithSetImpl(obj, path, 0, value); 61955 }; // Support DevTools editable values for useState and useReducer. 61956 61957 61958 overrideHookState = function (fiber, id, path, value) { 61959 // For now, the "id" of stateful hooks is just the stateful hook index. 61960 // This may change in the future with e.g. nested hooks. 61961 var currentHook = fiber.memoizedState; 61962 61963 while (currentHook !== null && id > 0) { 61964 currentHook = currentHook.next; 61965 id--; 61966 } 61967 61968 if (currentHook !== null) { 61969 var newState = copyWithSet(currentHook.memoizedState, path, value); 61970 currentHook.memoizedState = newState; 61971 currentHook.baseState = newState; // We aren't actually adding an update to the queue, 61972 // because there is no update we can add for useReducer hooks that won't trigger an error. 61973 // (There's no appropriate action type for DevTools overrides.) 61974 // As a result though, React will see the scheduled update as a noop and bailout. 61975 // Shallow cloning props works as a workaround for now to bypass the bailout check. 61976 61977 fiber.memoizedProps = _assign({}, fiber.memoizedProps); 61978 scheduleWork(fiber, Sync); 61979 } 61980 }; // Support DevTools props for function components, forwardRef, memo, host components, etc. 61981 61982 61983 overrideProps = function (fiber, path, value) { 61984 fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value); 61985 61986 if (fiber.alternate) { 61987 fiber.alternate.pendingProps = fiber.pendingProps; 61988 } 61989 61990 scheduleWork(fiber, Sync); 61991 }; 61992 61993 scheduleUpdate = function (fiber) { 61994 scheduleWork(fiber, Sync); 61995 }; 61996 61997 setSuspenseHandler = function (newShouldSuspendImpl) { 61998 shouldSuspendImpl = newShouldSuspendImpl; 61999 }; 62000} 62001 62002function injectIntoDevTools(devToolsConfig) { 62003 var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; 62004 var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; 62005 return injectInternals(_assign({}, devToolsConfig, { 62006 overrideHookState: overrideHookState, 62007 overrideProps: overrideProps, 62008 setSuspenseHandler: setSuspenseHandler, 62009 scheduleUpdate: scheduleUpdate, 62010 currentDispatcherRef: ReactCurrentDispatcher, 62011 findHostInstanceByFiber: function (fiber) { 62012 var hostFiber = findCurrentHostFiber(fiber); 62013 62014 if (hostFiber === null) { 62015 return null; 62016 } 62017 62018 return hostFiber.stateNode; 62019 }, 62020 findFiberByHostInstance: function (instance) { 62021 if (!findFiberByHostInstance) { 62022 // Might not be implemented by the renderer. 62023 return null; 62024 } 62025 62026 return findFiberByHostInstance(instance); 62027 }, 62028 // React Refresh 62029 findHostInstancesForRefresh: findHostInstancesForRefresh , 62030 scheduleRefresh: scheduleRefresh , 62031 scheduleRoot: scheduleRoot , 62032 setRefreshHandler: setRefreshHandler , 62033 // Enables DevTools to append owner stacks to error messages in DEV mode. 62034 getCurrentFiber: function () { 62035 return current; 62036 } 62037 })); 62038} 62039var IsSomeRendererActing$1 = ReactSharedInternals.IsSomeRendererActing; 62040 62041function ReactDOMRoot(container, options) { 62042 this._internalRoot = createRootImpl(container, ConcurrentRoot, options); 62043} 62044 62045function ReactDOMBlockingRoot(container, tag, options) { 62046 this._internalRoot = createRootImpl(container, tag, options); 62047} 62048 62049ReactDOMRoot.prototype.render = ReactDOMBlockingRoot.prototype.render = function (children) { 62050 var root = this._internalRoot; 62051 62052 { 62053 if (typeof arguments[1] === 'function') { 62054 error('render(...): does not support the second callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().'); 62055 } 62056 62057 var container = root.containerInfo; 62058 62059 if (container.nodeType !== COMMENT_NODE) { 62060 var hostInstance = findHostInstanceWithNoPortals(root.current); 62061 62062 if (hostInstance) { 62063 if (hostInstance.parentNode !== container) { 62064 error('render(...): It looks like the React-rendered content of the ' + 'root container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + "root.unmount() to empty a root's container."); 62065 } 62066 } 62067 } 62068 } 62069 62070 updateContainer(children, root, null, null); 62071}; 62072 62073ReactDOMRoot.prototype.unmount = ReactDOMBlockingRoot.prototype.unmount = function () { 62074 { 62075 if (typeof arguments[0] === 'function') { 62076 error('unmount(...): does not support a callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().'); 62077 } 62078 } 62079 62080 var root = this._internalRoot; 62081 var container = root.containerInfo; 62082 updateContainer(null, root, null, function () { 62083 unmarkContainerAsRoot(container); 62084 }); 62085}; 62086 62087function createRootImpl(container, tag, options) { 62088 // Tag is either LegacyRoot or Concurrent Root 62089 var hydrate = options != null && options.hydrate === true; 62090 var hydrationCallbacks = options != null && options.hydrationOptions || null; 62091 var root = createContainer(container, tag, hydrate); 62092 markContainerAsRoot(root.current, container); 62093 62094 if (hydrate && tag !== LegacyRoot) { 62095 var doc = container.nodeType === DOCUMENT_NODE ? container : container.ownerDocument; 62096 eagerlyTrapReplayableEvents(container, doc); 62097 } 62098 62099 return root; 62100} 62101function createLegacyRoot(container, options) { 62102 return new ReactDOMBlockingRoot(container, LegacyRoot, options); 62103} 62104function isValidContainer(node) { 62105 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 ')); 62106} 62107 62108var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; 62109var topLevelUpdateWarnings; 62110var warnedAboutHydrateAPI = false; 62111 62112{ 62113 topLevelUpdateWarnings = function (container) { 62114 if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) { 62115 var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current); 62116 62117 if (hostInstance) { 62118 if (hostInstance.parentNode !== container) { 62119 error('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.'); 62120 } 62121 } 62122 } 62123 62124 var isRootRenderedBySomeReact = !!container._reactRootContainer; 62125 var rootEl = getReactRootElementInContainer(container); 62126 var hasNonRootReactChild = !!(rootEl && getInstanceFromNode$1(rootEl)); 62127 62128 if (hasNonRootReactChild && !isRootRenderedBySomeReact) { 62129 error('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.'); 62130 } 62131 62132 if (container.nodeType === ELEMENT_NODE && container.tagName && container.tagName.toUpperCase() === 'BODY') { 62133 error('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.'); 62134 } 62135 }; 62136} 62137 62138function getReactRootElementInContainer(container) { 62139 if (!container) { 62140 return null; 62141 } 62142 62143 if (container.nodeType === DOCUMENT_NODE) { 62144 return container.documentElement; 62145 } else { 62146 return container.firstChild; 62147 } 62148} 62149 62150function shouldHydrateDueToLegacyHeuristic(container) { 62151 var rootElement = getReactRootElementInContainer(container); 62152 return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME)); 62153} 62154 62155function legacyCreateRootFromDOMContainer(container, forceHydrate) { 62156 var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container); // First clear any existing content. 62157 62158 if (!shouldHydrate) { 62159 var warned = false; 62160 var rootSibling; 62161 62162 while (rootSibling = container.lastChild) { 62163 { 62164 if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) { 62165 warned = true; 62166 62167 error('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.'); 62168 } 62169 } 62170 62171 container.removeChild(rootSibling); 62172 } 62173 } 62174 62175 { 62176 if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) { 62177 warnedAboutHydrateAPI = true; 62178 62179 warn('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.'); 62180 } 62181 } 62182 62183 return createLegacyRoot(container, shouldHydrate ? { 62184 hydrate: true 62185 } : undefined); 62186} 62187 62188function warnOnInvalidCallback$1(callback, callerName) { 62189 { 62190 if (callback !== null && typeof callback !== 'function') { 62191 error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); 62192 } 62193 } 62194} 62195 62196function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) { 62197 { 62198 topLevelUpdateWarnings(container); 62199 warnOnInvalidCallback$1(callback === undefined ? null : callback, 'render'); 62200 } // TODO: Without `any` type, Flow says "Property cannot be accessed on any 62201 // member of intersection type." Whyyyyyy. 62202 62203 62204 var root = container._reactRootContainer; 62205 var fiberRoot; 62206 62207 if (!root) { 62208 // Initial mount 62209 root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate); 62210 fiberRoot = root._internalRoot; 62211 62212 if (typeof callback === 'function') { 62213 var originalCallback = callback; 62214 62215 callback = function () { 62216 var instance = getPublicRootInstance(fiberRoot); 62217 originalCallback.call(instance); 62218 }; 62219 } // Initial mount should not be batched. 62220 62221 62222 unbatchedUpdates(function () { 62223 updateContainer(children, fiberRoot, parentComponent, callback); 62224 }); 62225 } else { 62226 fiberRoot = root._internalRoot; 62227 62228 if (typeof callback === 'function') { 62229 var _originalCallback = callback; 62230 62231 callback = function () { 62232 var instance = getPublicRootInstance(fiberRoot); 62233 62234 _originalCallback.call(instance); 62235 }; 62236 } // Update 62237 62238 62239 updateContainer(children, fiberRoot, parentComponent, callback); 62240 } 62241 62242 return getPublicRootInstance(fiberRoot); 62243} 62244 62245function findDOMNode(componentOrElement) { 62246 { 62247 var owner = ReactCurrentOwner$3.current; 62248 62249 if (owner !== null && owner.stateNode !== null) { 62250 var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender; 62251 62252 if (!warnedAboutRefsInRender) { 62253 error('%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.type) || 'A component'); 62254 } 62255 62256 owner.stateNode._warnedAboutRefsInRender = true; 62257 } 62258 } 62259 62260 if (componentOrElement == null) { 62261 return null; 62262 } 62263 62264 if (componentOrElement.nodeType === ELEMENT_NODE) { 62265 return componentOrElement; 62266 } 62267 62268 { 62269 return findHostInstanceWithWarning(componentOrElement, 'findDOMNode'); 62270 } 62271} 62272function hydrate(element, container, callback) { 62273 if (!isValidContainer(container)) { 62274 { 62275 throw Error( "Target container is not a DOM element." ); 62276 } 62277 } 62278 62279 { 62280 var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; 62281 62282 if (isModernRoot) { 62283 error('You are calling ReactDOM.hydrate() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call createRoot(container, {hydrate: true}).render(element)?'); 62284 } 62285 } // TODO: throw or warn if we couldn't hydrate? 62286 62287 62288 return legacyRenderSubtreeIntoContainer(null, element, container, true, callback); 62289} 62290function render(element, container, callback) { 62291 if (!isValidContainer(container)) { 62292 { 62293 throw Error( "Target container is not a DOM element." ); 62294 } 62295 } 62296 62297 { 62298 var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; 62299 62300 if (isModernRoot) { 62301 error('You are calling ReactDOM.render() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call root.render(element)?'); 62302 } 62303 } 62304 62305 return legacyRenderSubtreeIntoContainer(null, element, container, false, callback); 62306} 62307function unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) { 62308 if (!isValidContainer(containerNode)) { 62309 { 62310 throw Error( "Target container is not a DOM element." ); 62311 } 62312 } 62313 62314 if (!(parentComponent != null && has(parentComponent))) { 62315 { 62316 throw Error( "parentComponent must be a valid React Component" ); 62317 } 62318 } 62319 62320 return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback); 62321} 62322function unmountComponentAtNode(container) { 62323 if (!isValidContainer(container)) { 62324 { 62325 throw Error( "unmountComponentAtNode(...): Target container is not a DOM element." ); 62326 } 62327 } 62328 62329 { 62330 var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; 62331 62332 if (isModernRoot) { 62333 error('You are calling ReactDOM.unmountComponentAtNode() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. Did you mean to call root.unmount()?'); 62334 } 62335 } 62336 62337 if (container._reactRootContainer) { 62338 { 62339 var rootEl = getReactRootElementInContainer(container); 62340 var renderedByDifferentReact = rootEl && !getInstanceFromNode$1(rootEl); 62341 62342 if (renderedByDifferentReact) { 62343 error("unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.'); 62344 } 62345 } // Unmount should not be batched. 62346 62347 62348 unbatchedUpdates(function () { 62349 legacyRenderSubtreeIntoContainer(null, null, container, false, function () { 62350 // $FlowFixMe This should probably use `delete container._reactRootContainer` 62351 container._reactRootContainer = null; 62352 unmarkContainerAsRoot(container); 62353 }); 62354 }); // If you call unmountComponentAtNode twice in quick succession, you'll 62355 // get `true` twice. That's probably fine? 62356 62357 return true; 62358 } else { 62359 { 62360 var _rootEl = getReactRootElementInContainer(container); 62361 62362 var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode$1(_rootEl)); // Check if the container itself is a React root node. 62363 62364 var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer; 62365 62366 if (hasNonRootReactChild) { 62367 error("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.'); 62368 } 62369 } 62370 62371 return false; 62372 } 62373} 62374 62375function createPortal(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. 62376implementation) { 62377 var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; 62378 return { 62379 // This tag allow us to uniquely identify this as a React Portal 62380 $$typeof: REACT_PORTAL_TYPE, 62381 key: key == null ? null : '' + key, 62382 children: children, 62383 containerInfo: containerInfo, 62384 implementation: implementation 62385 }; 62386} 62387 62388var ReactVersion = '16.14.0'; 62389 62390setAttemptUserBlockingHydration(attemptUserBlockingHydration$1); 62391setAttemptContinuousHydration(attemptContinuousHydration$1); 62392setAttemptHydrationAtCurrentPriority(attemptHydrationAtCurrentPriority$1); 62393var didWarnAboutUnstableCreatePortal = false; 62394 62395{ 62396 if (typeof Map !== 'function' || // $FlowIssue Flow incorrectly thinks Map has no prototype 62397 Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || // $FlowIssue Flow incorrectly thinks Set has no prototype 62398 Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') { 62399 error('React depends on Map and Set built-in types. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); 62400 } 62401} 62402 62403setRestoreImplementation(restoreControlledState$3); 62404setBatchingImplementation(batchedUpdates$1, discreteUpdates$1, flushDiscreteUpdates, batchedEventUpdates$1); 62405 62406function createPortal$1(children, container) { 62407 var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 62408 62409 if (!isValidContainer(container)) { 62410 { 62411 throw Error( "Target container is not a DOM element." ); 62412 } 62413 } // TODO: pass ReactDOM portal implementation as third argument 62414 // $FlowFixMe The Flow type is opaque but there's no way to actually create it. 62415 62416 62417 return createPortal(children, container, null, key); 62418} 62419 62420function renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) { 62421 62422 return unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback); 62423} 62424 62425function unstable_createPortal(children, container) { 62426 var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 62427 62428 { 62429 if (!didWarnAboutUnstableCreatePortal) { 62430 didWarnAboutUnstableCreatePortal = true; 62431 62432 warn('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.'); 62433 } 62434 } 62435 62436 return createPortal$1(children, container, key); 62437} 62438 62439var Internals = { 62440 // Keep in sync with ReactDOMUnstableNativeDependencies.js 62441 // ReactTestUtils.js, and ReactTestUtilsAct.js. This is an array for better minification. 62442 Events: [getInstanceFromNode$1, getNodeFromInstance$1, getFiberCurrentPropsFromNode$1, injectEventPluginsByName, eventNameDispatchConfigs, accumulateTwoPhaseDispatches, accumulateDirectDispatches, enqueueStateRestore, restoreStateIfNeeded, dispatchEvent, runEventsInBatch, flushPassiveEffects, IsThisRendererActing] 62443}; 62444var foundDevTools = injectIntoDevTools({ 62445 findFiberByHostInstance: getClosestInstanceFromNode, 62446 bundleType: 1 , 62447 version: ReactVersion, 62448 rendererPackageName: 'react-dom' 62449}); 62450 62451{ 62452 if (!foundDevTools && canUseDOM && window.top === window.self) { 62453 // If we're in Chrome or Firefox, provide a download link if not installed. 62454 if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) { 62455 var protocol = window.location.protocol; // Don't warn in exotic cases like chrome-extension://. 62456 62457 if (/^(https?|file):$/.test(protocol)) { 62458 // eslint-disable-next-line react-internal/no-production-logging 62459 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'); 62460 } 62461 } 62462 } 62463} 62464 62465exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; 62466exports.createPortal = createPortal$1; 62467exports.findDOMNode = findDOMNode; 62468exports.flushSync = flushSync; 62469exports.hydrate = hydrate; 62470exports.render = render; 62471exports.unmountComponentAtNode = unmountComponentAtNode; 62472exports.unstable_batchedUpdates = batchedUpdates$1; 62473exports.unstable_createPortal = unstable_createPortal; 62474exports.unstable_renderSubtreeIntoContainer = renderSubtreeIntoContainer; 62475exports.version = ReactVersion; 62476 })(); 62477} 62478 62479 62480/***/ }), 62481
vendor: 1,447 bytes, lines 62482-62526
62482/***/ "./node_modules/react-dom/index.js": 62483/*!*****************************************!*\ 62484 !*** ./node_modules/react-dom/index.js ***! 62485 \*****************************************/ 62486/*! no static exports found */ 62487/***/ (function(module, exports, __webpack_require__) { 62488 62489"use strict"; 62490 62491 62492function checkDCE() { 62493 /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ 62494 if ( 62495 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' || 62496 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function' 62497 ) { 62498 return; 62499 } 62500 if (true) { 62501 // This branch is unreachable because this function is only called 62502 // in production, but the condition is true only in development. 62503 // Therefore if the branch is still here, dead code elimination wasn't 62504 // properly applied. 62505 // Don't change the message. React DevTools relies on it. Also make sure 62506 // this message doesn't occur elsewhere in this function, or it will cause 62507 // a false positive. 62508 throw new Error('^_^'); 62509 } 62510 try { 62511 // Verify that the code above has been dead code eliminated (DCE'd). 62512 __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE); 62513 } catch (err) { 62514 // DevTools shouldn't crash React, no matter what. 62515 // We should still report in case we break this code. 62516 console.error(err); 62517 } 62518} 62519 62520if (false) {} else { 62521 module.exports = __webpack_require__(/*! ./cjs/react-dom.development.js */ "./node_modules/react-dom/cjs/react-dom.development.js"); 62522} 62523 62524 62525/***/ }), 62526
vendor: 61,065 bytes, lines 62527-64450
62527/***/ "./node_modules/react/cjs/react.development.js": 62528/*!*****************************************************!*\ 62529 !*** ./node_modules/react/cjs/react.development.js ***! 62530 \*****************************************************/ 62531/*! no static exports found */ 62532/***/ (function(module, exports, __webpack_require__) { 62533 62534"use strict"; 62535/** @license React v16.14.0 62536 * react.development.js 62537 * 62538 * Copyright (c) Facebook, Inc. and its affiliates. 62539 * 62540 * This source code is licensed under the MIT license found in the 62541 * LICENSE file in the root directory of this source tree. 62542 */ 62543 62544 62545 62546 62547 62548if (true) { 62549 (function() { 62550'use strict'; 62551 62552var _assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js"); 62553var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "./node_modules/prop-types/checkPropTypes.js"); 62554 62555var ReactVersion = '16.14.0'; 62556 62557// The Symbol used to tag the ReactElement-like types. If there is no native Symbol 62558// nor polyfill, then a plain number is used for performance. 62559var hasSymbol = typeof Symbol === 'function' && Symbol.for; 62560var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; 62561var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; 62562var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; 62563var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; 62564var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; 62565var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; 62566var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary 62567var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; 62568var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; 62569var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; 62570var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; 62571var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; 62572var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; 62573var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; 62574var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; 62575var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; 62576var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; 62577var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 62578var FAUX_ITERATOR_SYMBOL = '@@iterator'; 62579function getIteratorFn(maybeIterable) { 62580 if (maybeIterable === null || typeof maybeIterable !== 'object') { 62581 return null; 62582 } 62583 62584 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 62585 62586 if (typeof maybeIterator === 'function') { 62587 return maybeIterator; 62588 } 62589 62590 return null; 62591} 62592 62593/** 62594 * Keeps track of the current dispatcher. 62595 */ 62596var ReactCurrentDispatcher = { 62597 /** 62598 * @internal 62599 * @type {ReactComponent} 62600 */ 62601 current: null 62602}; 62603 62604/** 62605 * Keeps track of the current batch's configuration such as how long an update 62606 * should suspend for if it needs to. 62607 */ 62608var ReactCurrentBatchConfig = { 62609 suspense: null 62610}; 62611 62612/** 62613 * Keeps track of the current owner. 62614 * 62615 * The current owner is the component who should own any components that are 62616 * currently being constructed. 62617 */ 62618var ReactCurrentOwner = { 62619 /** 62620 * @internal 62621 * @type {ReactComponent} 62622 */ 62623 current: null 62624}; 62625 62626var BEFORE_SLASH_RE = /^(.*)[\\\/]/; 62627function describeComponentFrame (name, source, ownerName) { 62628 var sourceInfo = ''; 62629 62630 if (source) { 62631 var path = source.fileName; 62632 var fileName = path.replace(BEFORE_SLASH_RE, ''); 62633 62634 { 62635 // In DEV, include code for a common special case: 62636 // prefer "folder/index.js" instead of just "index.js". 62637 if (/^index\./.test(fileName)) { 62638 var match = path.match(BEFORE_SLASH_RE); 62639 62640 if (match) { 62641 var pathBeforeSlash = match[1]; 62642 62643 if (pathBeforeSlash) { 62644 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ''); 62645 fileName = folderName + '/' + fileName; 62646 } 62647 } 62648 } 62649 } 62650 62651 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')'; 62652 } else if (ownerName) { 62653 sourceInfo = ' (created by ' + ownerName + ')'; 62654 } 62655 62656 return '\n in ' + (name || 'Unknown') + sourceInfo; 62657} 62658 62659var Resolved = 1; 62660function refineResolvedLazyComponent(lazyComponent) { 62661 return lazyComponent._status === Resolved ? lazyComponent._result : null; 62662} 62663 62664function getWrappedName(outerType, innerType, wrapperName) { 62665 var functionName = innerType.displayName || innerType.name || ''; 62666 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); 62667} 62668 62669function getComponentName(type) { 62670 if (type == null) { 62671 // Host root, text node or just invalid type. 62672 return null; 62673 } 62674 62675 { 62676 if (typeof type.tag === 'number') { 62677 error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); 62678 } 62679 } 62680 62681 if (typeof type === 'function') { 62682 return type.displayName || type.name || null; 62683 } 62684 62685 if (typeof type === 'string') { 62686 return type; 62687 } 62688 62689 switch (type) { 62690 case REACT_FRAGMENT_TYPE: 62691 return 'Fragment'; 62692 62693 case REACT_PORTAL_TYPE: 62694 return 'Portal'; 62695 62696 case REACT_PROFILER_TYPE: 62697 return "Profiler"; 62698 62699 case REACT_STRICT_MODE_TYPE: 62700 return 'StrictMode'; 62701 62702 case REACT_SUSPENSE_TYPE: 62703 return 'Suspense'; 62704 62705 case REACT_SUSPENSE_LIST_TYPE: 62706 return 'SuspenseList'; 62707 } 62708 62709 if (typeof type === 'object') { 62710 switch (type.$$typeof) { 62711 case REACT_CONTEXT_TYPE: 62712 return 'Context.Consumer'; 62713 62714 case REACT_PROVIDER_TYPE: 62715 return 'Context.Provider'; 62716 62717 case REACT_FORWARD_REF_TYPE: 62718 return getWrappedName(type, type.render, 'ForwardRef'); 62719 62720 case REACT_MEMO_TYPE: 62721 return getComponentName(type.type); 62722 62723 case REACT_BLOCK_TYPE: 62724 return getComponentName(type.render); 62725 62726 case REACT_LAZY_TYPE: 62727 { 62728 var thenable = type; 62729 var resolvedThenable = refineResolvedLazyComponent(thenable); 62730 62731 if (resolvedThenable) { 62732 return getComponentName(resolvedThenable); 62733 } 62734 62735 break; 62736 } 62737 } 62738 } 62739 62740 return null; 62741} 62742 62743var ReactDebugCurrentFrame = {}; 62744var currentlyValidatingElement = null; 62745function setCurrentlyValidatingElement(element) { 62746 { 62747 currentlyValidatingElement = element; 62748 } 62749} 62750 62751{ 62752 // Stack implementation injected by the current renderer. 62753 ReactDebugCurrentFrame.getCurrentStack = null; 62754 62755 ReactDebugCurrentFrame.getStackAddendum = function () { 62756 var stack = ''; // Add an extra top frame while an element is being validated 62757 62758 if (currentlyValidatingElement) { 62759 var name = getComponentName(currentlyValidatingElement.type); 62760 var owner = currentlyValidatingElement._owner; 62761 stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type)); 62762 } // Delegate to the injected renderer-specific implementation 62763 62764 62765 var impl = ReactDebugCurrentFrame.getCurrentStack; 62766 62767 if (impl) { 62768 stack += impl() || ''; 62769 } 62770 62771 return stack; 62772 }; 62773} 62774 62775/** 62776 * Used by act() to track whether you're inside an act() scope. 62777 */ 62778var IsSomeRendererActing = { 62779 current: false 62780}; 62781 62782var ReactSharedInternals = { 62783 ReactCurrentDispatcher: ReactCurrentDispatcher, 62784 ReactCurrentBatchConfig: ReactCurrentBatchConfig, 62785 ReactCurrentOwner: ReactCurrentOwner, 62786 IsSomeRendererActing: IsSomeRendererActing, 62787 // Used by renderers to avoid bundling object-assign twice in UMD bundles: 62788 assign: _assign 62789}; 62790 62791{ 62792 _assign(ReactSharedInternals, { 62793 // These should not be included in production. 62794 ReactDebugCurrentFrame: ReactDebugCurrentFrame, 62795 // Shim for React DOM 16.0.0 which still destructured (but not used) this. 62796 // TODO: remove in React 17.0. 62797 ReactComponentTreeHook: {} 62798 }); 62799} 62800 62801// by calls to these methods by a Babel plugin. 62802// 62803// In PROD (or in packages without access to React internals), 62804// they are left as they are instead. 62805 62806function warn(format) { 62807 { 62808 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 62809 args[_key - 1] = arguments[_key]; 62810 } 62811 62812 printWarning('warn', format, args); 62813 } 62814} 62815function error(format) { 62816 { 62817 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 62818 args[_key2 - 1] = arguments[_key2]; 62819 } 62820 62821 printWarning('error', format, args); 62822 } 62823} 62824 62825function printWarning(level, format, args) { 62826 // When changing this logic, you might want to also 62827 // update consoleWithStackDev.www.js as well. 62828 { 62829 var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0; 62830 62831 if (!hasExistingStack) { 62832 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 62833 var stack = ReactDebugCurrentFrame.getStackAddendum(); 62834 62835 if (stack !== '') { 62836 format += '%s'; 62837 args = args.concat([stack]); 62838 } 62839 } 62840 62841 var argsWithFormat = args.map(function (item) { 62842 return '' + item; 62843 }); // Careful: RN currently depends on this prefix 62844 62845 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it 62846 // breaks IE9: https://github.com/facebook/react/issues/13610 62847 // eslint-disable-next-line react-internal/no-production-logging 62848 62849 Function.prototype.apply.call(console[level], console, argsWithFormat); 62850 62851 try { 62852 // --- Welcome to debugging React --- 62853 // This error was thrown as a convenience so that you can use this stack 62854 // to find the callsite that caused this warning to fire. 62855 var argIndex = 0; 62856 var message = 'Warning: ' + format.replace(/%s/g, function () { 62857 return args[argIndex++]; 62858 }); 62859 throw new Error(message); 62860 } catch (x) {} 62861 } 62862} 62863 62864var didWarnStateUpdateForUnmountedComponent = {}; 62865 62866function warnNoop(publicInstance, callerName) { 62867 { 62868 var _constructor = publicInstance.constructor; 62869 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; 62870 var warningKey = componentName + "." + callerName; 62871 62872 if (didWarnStateUpdateForUnmountedComponent[warningKey]) { 62873 return; 62874 } 62875 62876 error("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); 62877 62878 didWarnStateUpdateForUnmountedComponent[warningKey] = true; 62879 } 62880} 62881/** 62882 * This is the abstract API for an update queue. 62883 */ 62884 62885 62886var ReactNoopUpdateQueue = { 62887 /** 62888 * Checks whether or not this composite component is mounted. 62889 * @param {ReactClass} publicInstance The instance we want to test. 62890 * @return {boolean} True if mounted, false otherwise. 62891 * @protected 62892 * @final 62893 */ 62894 isMounted: function (publicInstance) { 62895 return false; 62896 }, 62897 62898 /** 62899 * Forces an update. This should only be invoked when it is known with 62900 * certainty that we are **not** in a DOM transaction. 62901 * 62902 * You may want to call this when you know that some deeper aspect of the 62903 * component's state has changed but `setState` was not called. 62904 * 62905 * This will not invoke `shouldComponentUpdate`, but it will invoke 62906 * `componentWillUpdate` and `componentDidUpdate`. 62907 * 62908 * @param {ReactClass} publicInstance The instance that should rerender. 62909 * @param {?function} callback Called after component is updated. 62910 * @param {?string} callerName name of the calling function in the public API. 62911 * @internal 62912 */ 62913 enqueueForceUpdate: function (publicInstance, callback, callerName) { 62914 warnNoop(publicInstance, 'forceUpdate'); 62915 }, 62916 62917 /** 62918 * Replaces all of the state. Always use this or `setState` to mutate state. 62919 * You should treat `this.state` as immutable. 62920 * 62921 * There is no guarantee that `this.state` will be immediately updated, so 62922 * accessing `this.state` after calling this method may return the old value. 62923 * 62924 * @param {ReactClass} publicInstance The instance that should rerender. 62925 * @param {object} completeState Next state. 62926 * @param {?function} callback Called after component is updated. 62927 * @param {?string} callerName name of the calling function in the public API. 62928 * @internal 62929 */ 62930 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { 62931 warnNoop(publicInstance, 'replaceState'); 62932 }, 62933 62934 /** 62935 * Sets a subset of the state. This only exists because _pendingState is 62936 * internal. This provides a merging strategy that is not available to deep 62937 * properties which is confusing. TODO: Expose pendingState or don't use it 62938 * during the merge. 62939 * 62940 * @param {ReactClass} publicInstance The instance that should rerender. 62941 * @param {object} partialState Next partial state to be merged with state. 62942 * @param {?function} callback Called after component is updated. 62943 * @param {?string} Name of the calling function in the public API. 62944 * @internal 62945 */ 62946 enqueueSetState: function (publicInstance, partialState, callback, callerName) { 62947 warnNoop(publicInstance, 'setState'); 62948 } 62949}; 62950 62951var emptyObject = {}; 62952 62953{ 62954 Object.freeze(emptyObject); 62955} 62956/** 62957 * Base class helpers for the updating state of a component. 62958 */ 62959 62960 62961function Component(props, context, updater) { 62962 this.props = props; 62963 this.context = context; // If a component has string refs, we will assign a different object later. 62964 62965 this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the 62966 // renderer. 62967 62968 this.updater = updater || ReactNoopUpdateQueue; 62969} 62970 62971Component.prototype.isReactComponent = {}; 62972/** 62973 * Sets a subset of the state. Always use this to mutate 62974 * state. You should treat `this.state` as immutable. 62975 * 62976 * There is no guarantee that `this.state` will be immediately updated, so 62977 * accessing `this.state` after calling this method may return the old value. 62978 * 62979 * There is no guarantee that calls to `setState` will run synchronously, 62980 * as they may eventually be batched together. You can provide an optional 62981 * callback that will be executed when the call to setState is actually 62982 * completed. 62983 * 62984 * When a function is provided to setState, it will be called at some point in 62985 * the future (not synchronously). It will be called with the up to date 62986 * component arguments (state, props, context). These values can be different 62987 * from this.* because your function may be called after receiveProps but before 62988 * shouldComponentUpdate, and this new state, props, and context will not yet be 62989 * assigned to this. 62990 * 62991 * @param {object|function} partialState Next partial state or function to 62992 * produce next partial state to be merged with current state. 62993 * @param {?function} callback Called after state is updated. 62994 * @final 62995 * @protected 62996 */ 62997 62998Component.prototype.setState = function (partialState, callback) { 62999 if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) { 63000 { 63001 throw Error( "setState(...): takes an object of state variables to update or a function which returns an object of state variables." ); 63002 } 63003 } 63004 63005 this.updater.enqueueSetState(this, partialState, callback, 'setState'); 63006}; 63007/** 63008 * Forces an update. This should only be invoked when it is known with 63009 * certainty that we are **not** in a DOM transaction. 63010 * 63011 * You may want to call this when you know that some deeper aspect of the 63012 * component's state has changed but `setState` was not called. 63013 * 63014 * This will not invoke `shouldComponentUpdate`, but it will invoke 63015 * `componentWillUpdate` and `componentDidUpdate`. 63016 * 63017 * @param {?function} callback Called after update is complete. 63018 * @final 63019 * @protected 63020 */ 63021 63022 63023Component.prototype.forceUpdate = function (callback) { 63024 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); 63025}; 63026/** 63027 * Deprecated APIs. These APIs used to exist on classic React classes but since 63028 * we would like to deprecate them, we're not going to move them over to this 63029 * modern base class. Instead, we define a getter that warns if it's accessed. 63030 */ 63031 63032 63033{ 63034 var deprecatedAPIs = { 63035 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], 63036 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] 63037 }; 63038 63039 var defineDeprecationWarning = function (methodName, info) { 63040 Object.defineProperty(Component.prototype, methodName, { 63041 get: function () { 63042 warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); 63043 63044 return undefined; 63045 } 63046 }); 63047 }; 63048 63049 for (var fnName in deprecatedAPIs) { 63050 if (deprecatedAPIs.hasOwnProperty(fnName)) { 63051 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); 63052 } 63053 } 63054} 63055 63056function ComponentDummy() {} 63057 63058ComponentDummy.prototype = Component.prototype; 63059/** 63060 * Convenience component with default shallow equality check for sCU. 63061 */ 63062 63063function PureComponent(props, context, updater) { 63064 this.props = props; 63065 this.context = context; // If a component has string refs, we will assign a different object later. 63066 63067 this.refs = emptyObject; 63068 this.updater = updater || ReactNoopUpdateQueue; 63069} 63070 63071var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); 63072pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods. 63073 63074_assign(pureComponentPrototype, Component.prototype); 63075 63076pureComponentPrototype.isPureReactComponent = true; 63077 63078// an immutable object with a single mutable value 63079function createRef() { 63080 var refObject = { 63081 current: null 63082 }; 63083 63084 { 63085 Object.seal(refObject); 63086 } 63087 63088 return refObject; 63089} 63090 63091var hasOwnProperty = Object.prototype.hasOwnProperty; 63092var RESERVED_PROPS = { 63093 key: true, 63094 ref: true, 63095 __self: true, 63096 __source: true 63097}; 63098var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs; 63099 63100{ 63101 didWarnAboutStringRefs = {}; 63102} 63103 63104function hasValidRef(config) { 63105 { 63106 if (hasOwnProperty.call(config, 'ref')) { 63107 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; 63108 63109 if (getter && getter.isReactWarning) { 63110 return false; 63111 } 63112 } 63113 } 63114 63115 return config.ref !== undefined; 63116} 63117 63118function hasValidKey(config) { 63119 { 63120 if (hasOwnProperty.call(config, 'key')) { 63121 var getter = Object.getOwnPropertyDescriptor(config, 'key').get; 63122 63123 if (getter && getter.isReactWarning) { 63124 return false; 63125 } 63126 } 63127 } 63128 63129 return config.key !== undefined; 63130} 63131 63132function defineKeyPropWarningGetter(props, displayName) { 63133 var warnAboutAccessingKey = function () { 63134 { 63135 if (!specialPropKeyWarningShown) { 63136 specialPropKeyWarningShown = true; 63137 63138 error('%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); 63139 } 63140 } 63141 }; 63142 63143 warnAboutAccessingKey.isReactWarning = true; 63144 Object.defineProperty(props, 'key', { 63145 get: warnAboutAccessingKey, 63146 configurable: true 63147 }); 63148} 63149 63150function defineRefPropWarningGetter(props, displayName) { 63151 var warnAboutAccessingRef = function () { 63152 { 63153 if (!specialPropRefWarningShown) { 63154 specialPropRefWarningShown = true; 63155 63156 error('%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); 63157 } 63158 } 63159 }; 63160 63161 warnAboutAccessingRef.isReactWarning = true; 63162 Object.defineProperty(props, 'ref', { 63163 get: warnAboutAccessingRef, 63164 configurable: true 63165 }); 63166} 63167 63168function warnIfStringRefCannotBeAutoConverted(config) { 63169 { 63170 if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) { 63171 var componentName = getComponentName(ReactCurrentOwner.current.type); 63172 63173 if (!didWarnAboutStringRefs[componentName]) { 63174 error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref); 63175 63176 didWarnAboutStringRefs[componentName] = true; 63177 } 63178 } 63179 } 63180} 63181/** 63182 * Factory method to create a new React element. This no longer adheres to 63183 * the class pattern, so do not use new to call it. Also, instanceof check 63184 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check 63185 * if something is a React Element. 63186 * 63187 * @param {*} type 63188 * @param {*} props 63189 * @param {*} key 63190 * @param {string|object} ref 63191 * @param {*} owner 63192 * @param {*} self A *temporary* helper to detect places where `this` is 63193 * different from the `owner` when React.createElement is called, so that we 63194 * can warn. We want to get rid of owner and replace string `ref`s with arrow 63195 * functions, and as long as `this` and owner are the same, there will be no 63196 * change in behavior. 63197 * @param {*} source An annotation object (added by a transpiler or otherwise) 63198 * indicating filename, line number, and/or other information. 63199 * @internal 63200 */ 63201 63202 63203var ReactElement = function (type, key, ref, self, source, owner, props) { 63204 var element = { 63205 // This tag allows us to uniquely identify this as a React Element 63206 $$typeof: REACT_ELEMENT_TYPE, 63207 // Built-in properties that belong on the element 63208 type: type, 63209 key: key, 63210 ref: ref, 63211 props: props, 63212 // Record the component responsible for creating this element. 63213 _owner: owner 63214 }; 63215 63216 { 63217 // The validation flag is currently mutative. We put it on 63218 // an external backing store so that we can freeze the whole object. 63219 // This can be replaced with a WeakMap once they are implemented in 63220 // commonly used development environments. 63221 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make 63222 // the validation flag non-enumerable (where possible, which should 63223 // include every environment we run tests in), so the test framework 63224 // ignores it. 63225 63226 Object.defineProperty(element._store, 'validated', { 63227 configurable: false, 63228 enumerable: false, 63229 writable: true, 63230 value: false 63231 }); // self and source are DEV only properties. 63232 63233 Object.defineProperty(element, '_self', { 63234 configurable: false, 63235 enumerable: false, 63236 writable: false, 63237 value: self 63238 }); // Two elements created in two different places should be considered 63239 // equal for testing purposes and therefore we hide it from enumeration. 63240 63241 Object.defineProperty(element, '_source', { 63242 configurable: false, 63243 enumerable: false, 63244 writable: false, 63245 value: source 63246 }); 63247 63248 if (Object.freeze) { 63249 Object.freeze(element.props); 63250 Object.freeze(element); 63251 } 63252 } 63253 63254 return element; 63255}; 63256/** 63257 * Create and return a new ReactElement of the given type. 63258 * See https://reactjs.org/docs/react-api.html#createelement 63259 */ 63260 63261function createElement(type, config, children) { 63262 var propName; // Reserved names are extracted 63263 63264 var props = {}; 63265 var key = null; 63266 var ref = null; 63267 var self = null; 63268 var source = null; 63269 63270 if (config != null) { 63271 if (hasValidRef(config)) { 63272 ref = config.ref; 63273 63274 { 63275 warnIfStringRefCannotBeAutoConverted(config); 63276 } 63277 } 63278 63279 if (hasValidKey(config)) { 63280 key = '' + config.key; 63281 } 63282 63283 self = config.__self === undefined ? null : config.__self; 63284 source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object 63285 63286 for (propName in config) { 63287 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 63288 props[propName] = config[propName]; 63289 } 63290 } 63291 } // Children can be more than one argument, and those are transferred onto 63292 // the newly allocated props object. 63293 63294 63295 var childrenLength = arguments.length - 2; 63296 63297 if (childrenLength === 1) { 63298 props.children = children; 63299 } else if (childrenLength > 1) { 63300 var childArray = Array(childrenLength); 63301 63302 for (var i = 0; i < childrenLength; i++) { 63303 childArray[i] = arguments[i + 2]; 63304 } 63305 63306 { 63307 if (Object.freeze) { 63308 Object.freeze(childArray); 63309 } 63310 } 63311 63312 props.children = childArray; 63313 } // Resolve default props 63314 63315 63316 if (type && type.defaultProps) { 63317 var defaultProps = type.defaultProps; 63318 63319 for (propName in defaultProps) { 63320 if (props[propName] === undefined) { 63321 props[propName] = defaultProps[propName]; 63322 } 63323 } 63324 } 63325 63326 { 63327 if (key || ref) { 63328 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; 63329 63330 if (key) { 63331 defineKeyPropWarningGetter(props, displayName); 63332 } 63333 63334 if (ref) { 63335 defineRefPropWarningGetter(props, displayName); 63336 } 63337 } 63338 } 63339 63340 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); 63341} 63342function cloneAndReplaceKey(oldElement, newKey) { 63343 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); 63344 return newElement; 63345} 63346/** 63347 * Clone and return a new ReactElement using element as the starting point. 63348 * See https://reactjs.org/docs/react-api.html#cloneelement 63349 */ 63350 63351function cloneElement(element, config, children) { 63352 if (!!(element === null || element === undefined)) { 63353 { 63354 throw Error( "React.cloneElement(...): The argument must be a React element, but you passed " + element + "." ); 63355 } 63356 } 63357 63358 var propName; // Original props are copied 63359 63360 var props = _assign({}, element.props); // Reserved names are extracted 63361 63362 63363 var key = element.key; 63364 var ref = element.ref; // Self is preserved since the owner is preserved. 63365 63366 var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a 63367 // transpiler, and the original source is probably a better indicator of the 63368 // true owner. 63369 63370 var source = element._source; // Owner will be preserved, unless ref is overridden 63371 63372 var owner = element._owner; 63373 63374 if (config != null) { 63375 if (hasValidRef(config)) { 63376 // Silently steal the ref from the parent. 63377 ref = config.ref; 63378 owner = ReactCurrentOwner.current; 63379 } 63380 63381 if (hasValidKey(config)) { 63382 key = '' + config.key; 63383 } // Remaining properties override existing props 63384 63385 63386 var defaultProps; 63387 63388 if (element.type && element.type.defaultProps) { 63389 defaultProps = element.type.defaultProps; 63390 } 63391 63392 for (propName in config) { 63393 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 63394 if (config[propName] === undefined && defaultProps !== undefined) { 63395 // Resolve default props 63396 props[propName] = defaultProps[propName]; 63397 } else { 63398 props[propName] = config[propName]; 63399 } 63400 } 63401 } 63402 } // Children can be more than one argument, and those are transferred onto 63403 // the newly allocated props object. 63404 63405 63406 var childrenLength = arguments.length - 2; 63407 63408 if (childrenLength === 1) { 63409 props.children = children; 63410 } else if (childrenLength > 1) { 63411 var childArray = Array(childrenLength); 63412 63413 for (var i = 0; i < childrenLength; i++) { 63414 childArray[i] = arguments[i + 2]; 63415 } 63416 63417 props.children = childArray; 63418 } 63419 63420 return ReactElement(element.type, key, ref, self, source, owner, props); 63421} 63422/** 63423 * Verifies the object is a ReactElement. 63424 * See https://reactjs.org/docs/react-api.html#isvalidelement 63425 * @param {?object} object 63426 * @return {boolean} True if `object` is a ReactElement. 63427 * @final 63428 */ 63429 63430function isValidElement(object) { 63431 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; 63432} 63433 63434var SEPARATOR = '.'; 63435var SUBSEPARATOR = ':'; 63436/** 63437 * Escape and wrap key so it is safe to use as a reactid 63438 * 63439 * @param {string} key to be escaped. 63440 * @return {string} the escaped key. 63441 */ 63442 63443function escape(key) { 63444 var escapeRegex = /[=:]/g; 63445 var escaperLookup = { 63446 '=': '=0', 63447 ':': '=2' 63448 }; 63449 var escapedString = ('' + key).replace(escapeRegex, function (match) { 63450 return escaperLookup[match]; 63451 }); 63452 return '$' + escapedString; 63453} 63454/** 63455 * TODO: Test that a single child and an array with one item have the same key 63456 * pattern. 63457 */ 63458 63459 63460var didWarnAboutMaps = false; 63461var userProvidedKeyEscapeRegex = /\/+/g; 63462 63463function escapeUserProvidedKey(text) { 63464 return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/'); 63465} 63466 63467var POOL_SIZE = 10; 63468var traverseContextPool = []; 63469 63470function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) { 63471 if (traverseContextPool.length) { 63472 var traverseContext = traverseContextPool.pop(); 63473 traverseContext.result = mapResult; 63474 traverseContext.keyPrefix = keyPrefix; 63475 traverseContext.func = mapFunction; 63476 traverseContext.context = mapContext; 63477 traverseContext.count = 0; 63478 return traverseContext; 63479 } else { 63480 return { 63481 result: mapResult, 63482 keyPrefix: keyPrefix, 63483 func: mapFunction, 63484 context: mapContext, 63485 count: 0 63486 }; 63487 } 63488} 63489 63490function releaseTraverseContext(traverseContext) { 63491 traverseContext.result = null; 63492 traverseContext.keyPrefix = null; 63493 traverseContext.func = null; 63494 traverseContext.context = null; 63495 traverseContext.count = 0; 63496 63497 if (traverseContextPool.length < POOL_SIZE) { 63498 traverseContextPool.push(traverseContext); 63499 } 63500} 63501/** 63502 * @param {?*} children Children tree container. 63503 * @param {!string} nameSoFar Name of the key path so far. 63504 * @param {!function} callback Callback to invoke with each child found. 63505 * @param {?*} traverseContext Used to pass information throughout the traversal 63506 * process. 63507 * @return {!number} The number of children in this subtree. 63508 */ 63509 63510 63511function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { 63512 var type = typeof children; 63513 63514 if (type === 'undefined' || type === 'boolean') { 63515 // All of the above are perceived as null. 63516 children = null; 63517 } 63518 63519 var invokeCallback = false; 63520 63521 if (children === null) { 63522 invokeCallback = true; 63523 } else { 63524 switch (type) { 63525 case 'string': 63526 case 'number': 63527 invokeCallback = true; 63528 break; 63529 63530 case 'object': 63531 switch (children.$$typeof) { 63532 case REACT_ELEMENT_TYPE: 63533 case REACT_PORTAL_TYPE: 63534 invokeCallback = true; 63535 } 63536 63537 } 63538 } 63539 63540 if (invokeCallback) { 63541 callback(traverseContext, children, // If it's the only child, treat the name as if it was wrapped in an array 63542 // so that it's consistent if the number of children grows. 63543 nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); 63544 return 1; 63545 } 63546 63547 var child; 63548 var nextName; 63549 var subtreeCount = 0; // Count of children found in the current subtree. 63550 63551 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; 63552 63553 if (Array.isArray(children)) { 63554 for (var i = 0; i < children.length; i++) { 63555 child = children[i]; 63556 nextName = nextNamePrefix + getComponentKey(child, i); 63557 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); 63558 } 63559 } else { 63560 var iteratorFn = getIteratorFn(children); 63561 63562 if (typeof iteratorFn === 'function') { 63563 63564 { 63565 // Warn about using Maps as children 63566 if (iteratorFn === children.entries) { 63567 if (!didWarnAboutMaps) { 63568 warn('Using Maps as children is deprecated and will be removed in ' + 'a future major release. Consider converting children to ' + 'an array of keyed ReactElements instead.'); 63569 } 63570 63571 didWarnAboutMaps = true; 63572 } 63573 } 63574 63575 var iterator = iteratorFn.call(children); 63576 var step; 63577 var ii = 0; 63578 63579 while (!(step = iterator.next()).done) { 63580 child = step.value; 63581 nextName = nextNamePrefix + getComponentKey(child, ii++); 63582 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); 63583 } 63584 } else if (type === 'object') { 63585 var addendum = ''; 63586 63587 { 63588 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum(); 63589 } 63590 63591 var childrenString = '' + children; 63592 63593 { 63594 { 63595 throw Error( "Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ")." + addendum ); 63596 } 63597 } 63598 } 63599 } 63600 63601 return subtreeCount; 63602} 63603/** 63604 * Traverses children that are typically specified as `props.children`, but 63605 * might also be specified through attributes: 63606 * 63607 * - `traverseAllChildren(this.props.children, ...)` 63608 * - `traverseAllChildren(this.props.leftPanelChildren, ...)` 63609 * 63610 * The `traverseContext` is an optional argument that is passed through the 63611 * entire traversal. It can be used to store accumulations or anything else that 63612 * the callback might find relevant. 63613 * 63614 * @param {?*} children Children tree object. 63615 * @param {!function} callback To invoke upon traversing each child. 63616 * @param {?*} traverseContext Context for traversal. 63617 * @return {!number} The number of children in this subtree. 63618 */ 63619 63620 63621function traverseAllChildren(children, callback, traverseContext) { 63622 if (children == null) { 63623 return 0; 63624 } 63625 63626 return traverseAllChildrenImpl(children, '', callback, traverseContext); 63627} 63628/** 63629 * Generate a key string that identifies a component within a set. 63630 * 63631 * @param {*} component A component that could contain a manual key. 63632 * @param {number} index Index that is used if a manual key is not provided. 63633 * @return {string} 63634 */ 63635 63636 63637function getComponentKey(component, index) { 63638 // Do some typechecking here since we call this blindly. We want to ensure 63639 // that we don't block potential future ES APIs. 63640 if (typeof component === 'object' && component !== null && component.key != null) { 63641 // Explicit key 63642 return escape(component.key); 63643 } // Implicit key determined by the index in the set 63644 63645 63646 return index.toString(36); 63647} 63648 63649function forEachSingleChild(bookKeeping, child, name) { 63650 var func = bookKeeping.func, 63651 context = bookKeeping.context; 63652 func.call(context, child, bookKeeping.count++); 63653} 63654/** 63655 * Iterates through children that are typically specified as `props.children`. 63656 * 63657 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach 63658 * 63659 * The provided forEachFunc(child, index) will be called for each 63660 * leaf child. 63661 * 63662 * @param {?*} children Children tree container. 63663 * @param {function(*, int)} forEachFunc 63664 * @param {*} forEachContext Context for forEachContext. 63665 */ 63666 63667 63668function forEachChildren(children, forEachFunc, forEachContext) { 63669 if (children == null) { 63670 return children; 63671 } 63672 63673 var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext); 63674 traverseAllChildren(children, forEachSingleChild, traverseContext); 63675 releaseTraverseContext(traverseContext); 63676} 63677 63678function mapSingleChildIntoContext(bookKeeping, child, childKey) { 63679 var result = bookKeeping.result, 63680 keyPrefix = bookKeeping.keyPrefix, 63681 func = bookKeeping.func, 63682 context = bookKeeping.context; 63683 var mappedChild = func.call(context, child, bookKeeping.count++); 63684 63685 if (Array.isArray(mappedChild)) { 63686 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) { 63687 return c; 63688 }); 63689 } else if (mappedChild != null) { 63690 if (isValidElement(mappedChild)) { 63691 mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as 63692 // traverseAllChildren used to do for objects as children 63693 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey); 63694 } 63695 63696 result.push(mappedChild); 63697 } 63698} 63699 63700function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) { 63701 var escapedPrefix = ''; 63702 63703 if (prefix != null) { 63704 escapedPrefix = escapeUserProvidedKey(prefix) + '/'; 63705 } 63706 63707 var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context); 63708 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext); 63709 releaseTraverseContext(traverseContext); 63710} 63711/** 63712 * Maps children that are typically specified as `props.children`. 63713 * 63714 * See https://reactjs.org/docs/react-api.html#reactchildrenmap 63715 * 63716 * The provided mapFunction(child, key, index) will be called for each 63717 * leaf child. 63718 * 63719 * @param {?*} children Children tree container. 63720 * @param {function(*, int)} func The map function. 63721 * @param {*} context Context for mapFunction. 63722 * @return {object} Object containing the ordered map of results. 63723 */ 63724 63725 63726function mapChildren(children, func, context) { 63727 if (children == null) { 63728 return children; 63729 } 63730 63731 var result = []; 63732 mapIntoWithKeyPrefixInternal(children, result, null, func, context); 63733 return result; 63734} 63735/** 63736 * Count the number of children that are typically specified as 63737 * `props.children`. 63738 * 63739 * See https://reactjs.org/docs/react-api.html#reactchildrencount 63740 * 63741 * @param {?*} children Children tree container. 63742 * @return {number} The number of children. 63743 */ 63744 63745 63746function countChildren(children) { 63747 return traverseAllChildren(children, function () { 63748 return null; 63749 }, null); 63750} 63751/** 63752 * Flatten a children object (typically specified as `props.children`) and 63753 * return an array with appropriately re-keyed children. 63754 * 63755 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray 63756 */ 63757 63758 63759function toArray(children) { 63760 var result = []; 63761 mapIntoWithKeyPrefixInternal(children, result, null, function (child) { 63762 return child; 63763 }); 63764 return result; 63765} 63766/** 63767 * Returns the first child in a collection of children and verifies that there 63768 * is only one child in the collection. 63769 * 63770 * See https://reactjs.org/docs/react-api.html#reactchildrenonly 63771 * 63772 * The current implementation of this function assumes that a single child gets 63773 * passed without a wrapper, but the purpose of this helper function is to 63774 * abstract away the particular structure of children. 63775 * 63776 * @param {?object} children Child collection structure. 63777 * @return {ReactElement} The first and only `ReactElement` contained in the 63778 * structure. 63779 */ 63780 63781 63782function onlyChild(children) { 63783 if (!isValidElement(children)) { 63784 { 63785 throw Error( "React.Children.only expected to receive a single React element child." ); 63786 } 63787 } 63788 63789 return children; 63790} 63791 63792function createContext(defaultValue, calculateChangedBits) { 63793 if (calculateChangedBits === undefined) { 63794 calculateChangedBits = null; 63795 } else { 63796 { 63797 if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') { 63798 error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits); 63799 } 63800 } 63801 } 63802 63803 var context = { 63804 $$typeof: REACT_CONTEXT_TYPE, 63805 _calculateChangedBits: calculateChangedBits, 63806 // As a workaround to support multiple concurrent renderers, we categorize 63807 // some renderers as primary and others as secondary. We only expect 63808 // there to be two concurrent renderers at most: React Native (primary) and 63809 // Fabric (secondary); React DOM (primary) and React ART (secondary). 63810 // Secondary renderers store their context values on separate fields. 63811 _currentValue: defaultValue, 63812 _currentValue2: defaultValue, 63813 // Used to track how many concurrent renderers this context currently 63814 // supports within in a single renderer. Such as parallel server rendering. 63815 _threadCount: 0, 63816 // These are circular 63817 Provider: null, 63818 Consumer: null 63819 }; 63820 context.Provider = { 63821 $$typeof: REACT_PROVIDER_TYPE, 63822 _context: context 63823 }; 63824 var hasWarnedAboutUsingNestedContextConsumers = false; 63825 var hasWarnedAboutUsingConsumerProvider = false; 63826 63827 { 63828 // A separate object, but proxies back to the original context object for 63829 // backwards compatibility. It has a different $$typeof, so we can properly 63830 // warn for the incorrect usage of Context as a Consumer. 63831 var Consumer = { 63832 $$typeof: REACT_CONTEXT_TYPE, 63833 _context: context, 63834 _calculateChangedBits: context._calculateChangedBits 63835 }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here 63836 63837 Object.defineProperties(Consumer, { 63838 Provider: { 63839 get: function () { 63840 if (!hasWarnedAboutUsingConsumerProvider) { 63841 hasWarnedAboutUsingConsumerProvider = true; 63842 63843 error('Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?'); 63844 } 63845 63846 return context.Provider; 63847 }, 63848 set: function (_Provider) { 63849 context.Provider = _Provider; 63850 } 63851 }, 63852 _currentValue: { 63853 get: function () { 63854 return context._currentValue; 63855 }, 63856 set: function (_currentValue) { 63857 context._currentValue = _currentValue; 63858 } 63859 }, 63860 _currentValue2: { 63861 get: function () { 63862 return context._currentValue2; 63863 }, 63864 set: function (_currentValue2) { 63865 context._currentValue2 = _currentValue2; 63866 } 63867 }, 63868 _threadCount: { 63869 get: function () { 63870 return context._threadCount; 63871 }, 63872 set: function (_threadCount) { 63873 context._threadCount = _threadCount; 63874 } 63875 }, 63876 Consumer: { 63877 get: function () { 63878 if (!hasWarnedAboutUsingNestedContextConsumers) { 63879 hasWarnedAboutUsingNestedContextConsumers = true; 63880 63881 error('Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?'); 63882 } 63883 63884 return context.Consumer; 63885 } 63886 } 63887 }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty 63888 63889 context.Consumer = Consumer; 63890 } 63891 63892 { 63893 context._currentRenderer = null; 63894 context._currentRenderer2 = null; 63895 } 63896 63897 return context; 63898} 63899 63900function lazy(ctor) { 63901 var lazyType = { 63902 $$typeof: REACT_LAZY_TYPE, 63903 _ctor: ctor, 63904 // React uses these fields to store the result. 63905 _status: -1, 63906 _result: null 63907 }; 63908 63909 { 63910 // In production, this would just set it on the object. 63911 var defaultProps; 63912 var propTypes; 63913 Object.defineProperties(lazyType, { 63914 defaultProps: { 63915 configurable: true, 63916 get: function () { 63917 return defaultProps; 63918 }, 63919 set: function (newDefaultProps) { 63920 error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); 63921 63922 defaultProps = newDefaultProps; // Match production behavior more closely: 63923 63924 Object.defineProperty(lazyType, 'defaultProps', { 63925 enumerable: true 63926 }); 63927 } 63928 }, 63929 propTypes: { 63930 configurable: true, 63931 get: function () { 63932 return propTypes; 63933 }, 63934 set: function (newPropTypes) { 63935 error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); 63936 63937 propTypes = newPropTypes; // Match production behavior more closely: 63938 63939 Object.defineProperty(lazyType, 'propTypes', { 63940 enumerable: true 63941 }); 63942 } 63943 } 63944 }); 63945 } 63946 63947 return lazyType; 63948} 63949 63950function forwardRef(render) { 63951 { 63952 if (render != null && render.$$typeof === REACT_MEMO_TYPE) { 63953 error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).'); 63954 } else if (typeof render !== 'function') { 63955 error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render); 63956 } else { 63957 if (render.length !== 0 && render.length !== 2) { 63958 error('forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.'); 63959 } 63960 } 63961 63962 if (render != null) { 63963 if (render.defaultProps != null || render.propTypes != null) { 63964 error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?'); 63965 } 63966 } 63967 } 63968 63969 return { 63970 $$typeof: REACT_FORWARD_REF_TYPE, 63971 render: render 63972 }; 63973} 63974 63975function isValidElementType(type) { 63976 return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. 63977 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); 63978} 63979 63980function memo(type, compare) { 63981 { 63982 if (!isValidElementType(type)) { 63983 error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type); 63984 } 63985 } 63986 63987 return { 63988 $$typeof: REACT_MEMO_TYPE, 63989 type: type, 63990 compare: compare === undefined ? null : compare 63991 }; 63992} 63993 63994function resolveDispatcher() { 63995 var dispatcher = ReactCurrentDispatcher.current; 63996 63997 if (!(dispatcher !== null)) { 63998 { 63999 throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); 64000 } 64001 } 64002 64003 return dispatcher; 64004} 64005 64006function useContext(Context, unstable_observedBits) { 64007 var dispatcher = resolveDispatcher(); 64008 64009 { 64010 if (unstable_observedBits !== undefined) { 64011 error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : ''); 64012 } // TODO: add a more generic warning for invalid values. 64013 64014 64015 if (Context._context !== undefined) { 64016 var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs 64017 // and nobody should be using this in existing code. 64018 64019 if (realContext.Consumer === Context) { 64020 error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?'); 64021 } else if (realContext.Provider === Context) { 64022 error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?'); 64023 } 64024 } 64025 } 64026 64027 return dispatcher.useContext(Context, unstable_observedBits); 64028} 64029function useState(initialState) { 64030 var dispatcher = resolveDispatcher(); 64031 return dispatcher.useState(initialState); 64032} 64033function useReducer(reducer, initialArg, init) { 64034 var dispatcher = resolveDispatcher(); 64035 return dispatcher.useReducer(reducer, initialArg, init); 64036} 64037function useRef(initialValue) { 64038 var dispatcher = resolveDispatcher(); 64039 return dispatcher.useRef(initialValue); 64040} 64041function useEffect(create, deps) { 64042 var dispatcher = resolveDispatcher(); 64043 return dispatcher.useEffect(create, deps); 64044} 64045function useLayoutEffect(create, deps) { 64046 var dispatcher = resolveDispatcher(); 64047 return dispatcher.useLayoutEffect(create, deps); 64048} 64049function useCallback(callback, deps) { 64050 var dispatcher = resolveDispatcher(); 64051 return dispatcher.useCallback(callback, deps); 64052} 64053function useMemo(create, deps) { 64054 var dispatcher = resolveDispatcher(); 64055 return dispatcher.useMemo(create, deps); 64056} 64057function useImperativeHandle(ref, create, deps) { 64058 var dispatcher = resolveDispatcher(); 64059 return dispatcher.useImperativeHandle(ref, create, deps); 64060} 64061function useDebugValue(value, formatterFn) { 64062 { 64063 var dispatcher = resolveDispatcher(); 64064 return dispatcher.useDebugValue(value, formatterFn); 64065 } 64066} 64067 64068var propTypesMisspellWarningShown; 64069 64070{ 64071 propTypesMisspellWarningShown = false; 64072} 64073 64074function getDeclarationErrorAddendum() { 64075 if (ReactCurrentOwner.current) { 64076 var name = getComponentName(ReactCurrentOwner.current.type); 64077 64078 if (name) { 64079 return '\n\nCheck the render method of `' + name + '`.'; 64080 } 64081 } 64082 64083 return ''; 64084} 64085 64086function getSourceInfoErrorAddendum(source) { 64087 if (source !== undefined) { 64088 var fileName = source.fileName.replace(/^.*[\\\/]/, ''); 64089 var lineNumber = source.lineNumber; 64090 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; 64091 } 64092 64093 return ''; 64094} 64095 64096function getSourceInfoErrorAddendumForProps(elementProps) { 64097 if (elementProps !== null && elementProps !== undefined) { 64098 return getSourceInfoErrorAddendum(elementProps.__source); 64099 } 64100 64101 return ''; 64102} 64103/** 64104 * Warn if there's no key explicitly set on dynamic arrays of children or 64105 * object keys are not valid. This allows us to keep track of children between 64106 * updates. 64107 */ 64108 64109 64110var ownerHasKeyUseWarning = {}; 64111 64112function getCurrentComponentErrorInfo(parentType) { 64113 var info = getDeclarationErrorAddendum(); 64114 64115 if (!info) { 64116 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; 64117 64118 if (parentName) { 64119 info = "\n\nCheck the top-level render call using <" + parentName + ">."; 64120 } 64121 } 64122 64123 return info; 64124} 64125/** 64126 * Warn if the element doesn't have an explicit key assigned to it. 64127 * This element is in an array. The array could grow and shrink or be 64128 * reordered. All children that haven't already been validated are required to 64129 * have a "key" property assigned to it. Error statuses are cached so a warning 64130 * will only be shown once. 64131 * 64132 * @internal 64133 * @param {ReactElement} element Element that requires a key. 64134 * @param {*} parentType element's parent's type. 64135 */ 64136 64137 64138function validateExplicitKey(element, parentType) { 64139 if (!element._store || element._store.validated || element.key != null) { 64140 return; 64141 } 64142 64143 element._store.validated = true; 64144 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); 64145 64146 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 64147 return; 64148 } 64149 64150 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a 64151 // property, it may be the creator of the child that's responsible for 64152 // assigning it a key. 64153 64154 var childOwner = ''; 64155 64156 if (element && element._owner && element._owner !== ReactCurrentOwner.current) { 64157 // Give the component that originally created this child. 64158 childOwner = " It was passed a child from " + getComponentName(element._owner.type) + "."; 64159 } 64160 64161 setCurrentlyValidatingElement(element); 64162 64163 { 64164 error('Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner); 64165 } 64166 64167 setCurrentlyValidatingElement(null); 64168} 64169/** 64170 * Ensure that every element either is passed in a static location, in an 64171 * array with an explicit keys property defined, or in an object literal 64172 * with valid key property. 64173 * 64174 * @internal 64175 * @param {ReactNode} node Statically passed child of any type. 64176 * @param {*} parentType node's parent's type. 64177 */ 64178 64179 64180function validateChildKeys(node, parentType) { 64181 if (typeof node !== 'object') { 64182 return; 64183 } 64184 64185 if (Array.isArray(node)) { 64186 for (var i = 0; i < node.length; i++) { 64187 var child = node[i]; 64188 64189 if (isValidElement(child)) { 64190 validateExplicitKey(child, parentType); 64191 } 64192 } 64193 } else if (isValidElement(node)) { 64194 // This element was passed in a valid location. 64195 if (node._store) { 64196 node._store.validated = true; 64197 } 64198 } else if (node) { 64199 var iteratorFn = getIteratorFn(node); 64200 64201 if (typeof iteratorFn === 'function') { 64202 // Entry iterators used to provide implicit keys, 64203 // but now we print a separate warning for them later. 64204 if (iteratorFn !== node.entries) { 64205 var iterator = iteratorFn.call(node); 64206 var step; 64207 64208 while (!(step = iterator.next()).done) { 64209 if (isValidElement(step.value)) { 64210 validateExplicitKey(step.value, parentType); 64211 } 64212 } 64213 } 64214 } 64215 } 64216} 64217/** 64218 * Given an element, validate that its props follow the propTypes definition, 64219 * provided by the type. 64220 * 64221 * @param {ReactElement} element 64222 */ 64223 64224 64225function validatePropTypes(element) { 64226 { 64227 var type = element.type; 64228 64229 if (type === null || type === undefined || typeof type === 'string') { 64230 return; 64231 } 64232 64233 var name = getComponentName(type); 64234 var propTypes; 64235 64236 if (typeof type === 'function') { 64237 propTypes = type.propTypes; 64238 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. 64239 // Inner props are checked in the reconciler. 64240 type.$$typeof === REACT_MEMO_TYPE)) { 64241 propTypes = type.propTypes; 64242 } else { 64243 return; 64244 } 64245 64246 if (propTypes) { 64247 setCurrentlyValidatingElement(element); 64248 checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum); 64249 setCurrentlyValidatingElement(null); 64250 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { 64251 propTypesMisspellWarningShown = true; 64252 64253 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown'); 64254 } 64255 64256 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) { 64257 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); 64258 } 64259 } 64260} 64261/** 64262 * Given a fragment, validate that it can only be provided with fragment props 64263 * @param {ReactElement} fragment 64264 */ 64265 64266 64267function validateFragmentProps(fragment) { 64268 { 64269 setCurrentlyValidatingElement(fragment); 64270 var keys = Object.keys(fragment.props); 64271 64272 for (var i = 0; i < keys.length; i++) { 64273 var key = keys[i]; 64274 64275 if (key !== 'children' && key !== 'key') { 64276 error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); 64277 64278 break; 64279 } 64280 } 64281 64282 if (fragment.ref !== null) { 64283 error('Invalid attribute `ref` supplied to `React.Fragment`.'); 64284 } 64285 64286 setCurrentlyValidatingElement(null); 64287 } 64288} 64289function createElementWithValidation(type, props, children) { 64290 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to 64291 // succeed and there will likely be errors in render. 64292 64293 if (!validType) { 64294 var info = ''; 64295 64296 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 64297 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."; 64298 } 64299 64300 var sourceInfo = getSourceInfoErrorAddendumForProps(props); 64301 64302 if (sourceInfo) { 64303 info += sourceInfo; 64304 } else { 64305 info += getDeclarationErrorAddendum(); 64306 } 64307 64308 var typeString; 64309 64310 if (type === null) { 64311 typeString = 'null'; 64312 } else if (Array.isArray(type)) { 64313 typeString = 'array'; 64314 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { 64315 typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />"; 64316 info = ' Did you accidentally export a JSX literal instead of a component?'; 64317 } else { 64318 typeString = typeof type; 64319 } 64320 64321 { 64322 error('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); 64323 } 64324 } 64325 64326 var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used. 64327 // TODO: Drop this when these are no longer allowed as the type argument. 64328 64329 if (element == null) { 64330 return element; 64331 } // Skip key warning if the type isn't valid since our key validation logic 64332 // doesn't expect a non-string/function type and can throw confusing errors. 64333 // We don't want exception behavior to differ between dev and prod. 64334 // (Rendering will throw with a helpful message and as soon as the type is 64335 // fixed, the key warnings will appear.) 64336 64337 64338 if (validType) { 64339 for (var i = 2; i < arguments.length; i++) { 64340 validateChildKeys(arguments[i], type); 64341 } 64342 } 64343 64344 if (type === REACT_FRAGMENT_TYPE) { 64345 validateFragmentProps(element); 64346 } else { 64347 validatePropTypes(element); 64348 } 64349 64350 return element; 64351} 64352var didWarnAboutDeprecatedCreateFactory = false; 64353function createFactoryWithValidation(type) { 64354 var validatedFactory = createElementWithValidation.bind(null, type); 64355 validatedFactory.type = type; 64356 64357 { 64358 if (!didWarnAboutDeprecatedCreateFactory) { 64359 didWarnAboutDeprecatedCreateFactory = true; 64360 64361 warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.'); 64362 } // Legacy hook: remove it 64363 64364 64365 Object.defineProperty(validatedFactory, 'type', { 64366 enumerable: false, 64367 get: function () { 64368 warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); 64369 64370 Object.defineProperty(this, 'type', { 64371 value: type 64372 }); 64373 return type; 64374 } 64375 }); 64376 } 64377 64378 return validatedFactory; 64379} 64380function cloneElementWithValidation(element, props, children) { 64381 var newElement = cloneElement.apply(this, arguments); 64382 64383 for (var i = 2; i < arguments.length; i++) { 64384 validateChildKeys(arguments[i], newElement.type); 64385 } 64386 64387 validatePropTypes(newElement); 64388 return newElement; 64389} 64390 64391{ 64392 64393 try { 64394 var frozenObject = Object.freeze({}); 64395 var testMap = new Map([[frozenObject, null]]); 64396 var testSet = new Set([frozenObject]); // This is necessary for Rollup to not consider these unused. 64397 // https://github.com/rollup/rollup/issues/1771 64398 // TODO: we can remove these if Rollup fixes the bug. 64399 64400 testMap.set(0, 0); 64401 testSet.add(0); 64402 } catch (e) { 64403 } 64404} 64405 64406var createElement$1 = createElementWithValidation ; 64407var cloneElement$1 = cloneElementWithValidation ; 64408var createFactory = createFactoryWithValidation ; 64409var Children = { 64410 map: mapChildren, 64411 forEach: forEachChildren, 64412 count: countChildren, 64413 toArray: toArray, 64414 only: onlyChild 64415}; 64416 64417exports.Children = Children; 64418exports.Component = Component; 64419exports.Fragment = REACT_FRAGMENT_TYPE; 64420exports.Profiler = REACT_PROFILER_TYPE; 64421exports.PureComponent = PureComponent; 64422exports.StrictMode = REACT_STRICT_MODE_TYPE; 64423exports.Suspense = REACT_SUSPENSE_TYPE; 64424exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals; 64425exports.cloneElement = cloneElement$1; 64426exports.createContext = createContext; 64427exports.createElement = createElement$1; 64428exports.createFactory = createFactory; 64429exports.createRef = createRef; 64430exports.forwardRef = forwardRef; 64431exports.isValidElement = isValidElement; 64432exports.lazy = lazy; 64433exports.memo = memo; 64434exports.useCallback = useCallback; 64435exports.useContext = useContext; 64436exports.useDebugValue = useDebugValue; 64437exports.useEffect = useEffect; 64438exports.useImperativeHandle = useImperativeHandle; 64439exports.useLayoutEffect = useLayoutEffect; 64440exports.useMemo = useMemo; 64441exports.useReducer = useReducer; 64442exports.useRef = useRef; 64443exports.useState = useState; 64444exports.version = ReactVersion; 64445 })(); 64446} 64447 64448 64449/***/ }), 64450
vendor: 430 bytes, lines 64451-64467
64451/***/ "./node_modules/react/index.js": 64452/*!*************************************!*\ 64453 !*** ./node_modules/react/index.js ***! 64454 \*************************************/ 64455/*! no static exports found */ 64456/***/ (function(module, exports, __webpack_require__) { 64457 64458"use strict"; 64459 64460 64461if (false) {} else { 64462 module.exports = __webpack_require__(/*! ./cjs/react.development.js */ "./node_modules/react/cjs/react.development.js"); 64463} 64464 64465 64466/***/ }), 64467
vendor: 9,367 bytes, lines 64468-64828
64468/***/ "./node_modules/scheduler/cjs/scheduler-tracing.development.js": 64469/*!*********************************************************************!*\ 64470 !*** ./node_modules/scheduler/cjs/scheduler-tracing.development.js ***! 64471 \*********************************************************************/ 64472/*! no static exports found */ 64473/***/ (function(module, exports, __webpack_require__) { 64474 64475"use strict"; 64476/** @license React v0.19.1 64477 * scheduler-tracing.development.js 64478 * 64479 * Copyright (c) Facebook, Inc. and its affiliates. 64480 * 64481 * This source code is licensed under the MIT license found in the 64482 * LICENSE file in the root directory of this source tree. 64483 */ 64484 64485 64486 64487 64488 64489if (true) { 64490 (function() { 64491'use strict'; 64492 64493var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs. 64494 64495var interactionIDCounter = 0; 64496var threadIDCounter = 0; // Set of currently traced interactions. 64497// Interactions "stack"– 64498// Meaning that newly traced interactions are appended to the previously active set. 64499// When an interaction goes out of scope, the previous set (if any) is restored. 64500 64501exports.__interactionsRef = null; // Listener(s) to notify when interactions begin and end. 64502 64503exports.__subscriberRef = null; 64504 64505{ 64506 exports.__interactionsRef = { 64507 current: new Set() 64508 }; 64509 exports.__subscriberRef = { 64510 current: null 64511 }; 64512} 64513function unstable_clear(callback) { 64514 64515 var prevInteractions = exports.__interactionsRef.current; 64516 exports.__interactionsRef.current = new Set(); 64517 64518 try { 64519 return callback(); 64520 } finally { 64521 exports.__interactionsRef.current = prevInteractions; 64522 } 64523} 64524function unstable_getCurrent() { 64525 { 64526 return exports.__interactionsRef.current; 64527 } 64528} 64529function unstable_getThreadID() { 64530 return ++threadIDCounter; 64531} 64532function unstable_trace(name, timestamp, callback) { 64533 var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID; 64534 64535 var interaction = { 64536 __count: 1, 64537 id: interactionIDCounter++, 64538 name: name, 64539 timestamp: timestamp 64540 }; 64541 var prevInteractions = exports.__interactionsRef.current; // Traced interactions should stack/accumulate. 64542 // To do that, clone the current interactions. 64543 // The previous set will be restored upon completion. 64544 64545 var interactions = new Set(prevInteractions); 64546 interactions.add(interaction); 64547 exports.__interactionsRef.current = interactions; 64548 var subscriber = exports.__subscriberRef.current; 64549 var returnValue; 64550 64551 try { 64552 if (subscriber !== null) { 64553 subscriber.onInteractionTraced(interaction); 64554 } 64555 } finally { 64556 try { 64557 if (subscriber !== null) { 64558 subscriber.onWorkStarted(interactions, threadID); 64559 } 64560 } finally { 64561 try { 64562 returnValue = callback(); 64563 } finally { 64564 exports.__interactionsRef.current = prevInteractions; 64565 64566 try { 64567 if (subscriber !== null) { 64568 subscriber.onWorkStopped(interactions, threadID); 64569 } 64570 } finally { 64571 interaction.__count--; // If no async work was scheduled for this interaction, 64572 // Notify subscribers that it's completed. 64573 64574 if (subscriber !== null && interaction.__count === 0) { 64575 subscriber.onInteractionScheduledWorkCompleted(interaction); 64576 } 64577 } 64578 } 64579 } 64580 } 64581 64582 return returnValue; 64583} 64584function unstable_wrap(callback) { 64585 var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID; 64586 64587 var wrappedInteractions = exports.__interactionsRef.current; 64588 var subscriber = exports.__subscriberRef.current; 64589 64590 if (subscriber !== null) { 64591 subscriber.onWorkScheduled(wrappedInteractions, threadID); 64592 } // Update the pending async work count for the current interactions. 64593 // Update after calling subscribers in case of error. 64594 64595 64596 wrappedInteractions.forEach(function (interaction) { 64597 interaction.__count++; 64598 }); 64599 var hasRun = false; 64600 64601 function wrapped() { 64602 var prevInteractions = exports.__interactionsRef.current; 64603 exports.__interactionsRef.current = wrappedInteractions; 64604 subscriber = exports.__subscriberRef.current; 64605 64606 try { 64607 var returnValue; 64608 64609 try { 64610 if (subscriber !== null) { 64611 subscriber.onWorkStarted(wrappedInteractions, threadID); 64612 } 64613 } finally { 64614 try { 64615 returnValue = callback.apply(undefined, arguments); 64616 } finally { 64617 exports.__interactionsRef.current = prevInteractions; 64618 64619 if (subscriber !== null) { 64620 subscriber.onWorkStopped(wrappedInteractions, threadID); 64621 } 64622 } 64623 } 64624 64625 return returnValue; 64626 } finally { 64627 if (!hasRun) { 64628 // We only expect a wrapped function to be executed once, 64629 // But in the event that it's executed more than once– 64630 // Only decrement the outstanding interaction counts once. 64631 hasRun = true; // Update pending async counts for all wrapped interactions. 64632 // If this was the last scheduled async work for any of them, 64633 // Mark them as completed. 64634 64635 wrappedInteractions.forEach(function (interaction) { 64636 interaction.__count--; 64637 64638 if (subscriber !== null && interaction.__count === 0) { 64639 subscriber.onInteractionScheduledWorkCompleted(interaction); 64640 } 64641 }); 64642 } 64643 } 64644 } 64645 64646 wrapped.cancel = function cancel() { 64647 subscriber = exports.__subscriberRef.current; 64648 64649 try { 64650 if (subscriber !== null) { 64651 subscriber.onWorkCanceled(wrappedInteractions, threadID); 64652 } 64653 } finally { 64654 // Update pending async counts for all wrapped interactions. 64655 // If this was the last scheduled async work for any of them, 64656 // Mark them as completed. 64657 wrappedInteractions.forEach(function (interaction) { 64658 interaction.__count--; 64659 64660 if (subscriber && interaction.__count === 0) { 64661 subscriber.onInteractionScheduledWorkCompleted(interaction); 64662 } 64663 }); 64664 } 64665 }; 64666 64667 return wrapped; 64668} 64669 64670var subscribers = null; 64671 64672{ 64673 subscribers = new Set(); 64674} 64675 64676function unstable_subscribe(subscriber) { 64677 { 64678 subscribers.add(subscriber); 64679 64680 if (subscribers.size === 1) { 64681 exports.__subscriberRef.current = { 64682 onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted, 64683 onInteractionTraced: onInteractionTraced, 64684 onWorkCanceled: onWorkCanceled, 64685 onWorkScheduled: onWorkScheduled, 64686 onWorkStarted: onWorkStarted, 64687 onWorkStopped: onWorkStopped 64688 }; 64689 } 64690 } 64691} 64692function unstable_unsubscribe(subscriber) { 64693 { 64694 subscribers.delete(subscriber); 64695 64696 if (subscribers.size === 0) { 64697 exports.__subscriberRef.current = null; 64698 } 64699 } 64700} 64701 64702function onInteractionTraced(interaction) { 64703 var didCatchError = false; 64704 var caughtError = null; 64705 subscribers.forEach(function (subscriber) { 64706 try { 64707 subscriber.onInteractionTraced(interaction); 64708 } catch (error) { 64709 if (!didCatchError) { 64710 didCatchError = true; 64711 caughtError = error; 64712 } 64713 } 64714 }); 64715 64716 if (didCatchError) { 64717 throw caughtError; 64718 } 64719} 64720 64721function onInteractionScheduledWorkCompleted(interaction) { 64722 var didCatchError = false; 64723 var caughtError = null; 64724 subscribers.forEach(function (subscriber) { 64725 try { 64726 subscriber.onInteractionScheduledWorkCompleted(interaction); 64727 } catch (error) { 64728 if (!didCatchError) { 64729 didCatchError = true; 64730 caughtError = error; 64731 } 64732 } 64733 }); 64734 64735 if (didCatchError) { 64736 throw caughtError; 64737 } 64738} 64739 64740function onWorkScheduled(interactions, threadID) { 64741 var didCatchError = false; 64742 var caughtError = null; 64743 subscribers.forEach(function (subscriber) { 64744 try { 64745 subscriber.onWorkScheduled(interactions, threadID); 64746 } catch (error) { 64747 if (!didCatchError) { 64748 didCatchError = true; 64749 caughtError = error; 64750 } 64751 } 64752 }); 64753 64754 if (didCatchError) { 64755 throw caughtError; 64756 } 64757} 64758 64759function onWorkStarted(interactions, threadID) { 64760 var didCatchError = false; 64761 var caughtError = null; 64762 subscribers.forEach(function (subscriber) { 64763 try { 64764 subscriber.onWorkStarted(interactions, threadID); 64765 } catch (error) { 64766 if (!didCatchError) { 64767 didCatchError = true; 64768 caughtError = error; 64769 } 64770 } 64771 }); 64772 64773 if (didCatchError) { 64774 throw caughtError; 64775 } 64776} 64777 64778function onWorkStopped(interactions, threadID) { 64779 var didCatchError = false; 64780 var caughtError = null; 64781 subscribers.forEach(function (subscriber) { 64782 try { 64783 subscriber.onWorkStopped(interactions, threadID); 64784 } catch (error) { 64785 if (!didCatchError) { 64786 didCatchError = true; 64787 caughtError = error; 64788 } 64789 } 64790 }); 64791 64792 if (didCatchError) { 64793 throw caughtError; 64794 } 64795} 64796 64797function onWorkCanceled(interactions, threadID) { 64798 var didCatchError = false; 64799 var caughtError = null; 64800 subscribers.forEach(function (subscriber) { 64801 try { 64802 subscriber.onWorkCanceled(interactions, threadID); 64803 } catch (error) { 64804 if (!didCatchError) { 64805 didCatchError = true; 64806 caughtError = error; 64807 } 64808 } 64809 }); 64810 64811 if (didCatchError) { 64812 throw caughtError; 64813 } 64814} 64815 64816exports.unstable_clear = unstable_clear; 64817exports.unstable_getCurrent = unstable_getCurrent; 64818exports.unstable_getThreadID = unstable_getThreadID; 64819exports.unstable_subscribe = unstable_subscribe; 64820exports.unstable_trace = unstable_trace; 64821exports.unstable_unsubscribe = unstable_unsubscribe; 64822exports.unstable_wrap = unstable_wrap; 64823 })(); 64824} 64825 64826 64827/***/ }), 64828
vendor: 24,094 bytes, lines 64829-65698
64829/***/ "./node_modules/scheduler/cjs/scheduler.development.js": 64830/*!*************************************************************!*\ 64831 !*** ./node_modules/scheduler/cjs/scheduler.development.js ***! 64832 \*************************************************************/ 64833/*! no static exports found */ 64834/***/ (function(module, exports, __webpack_require__) { 64835 64836"use strict"; 64837/** @license React v0.19.1 64838 * scheduler.development.js 64839 * 64840 * Copyright (c) Facebook, Inc. and its affiliates. 64841 * 64842 * This source code is licensed under the MIT license found in the 64843 * LICENSE file in the root directory of this source tree. 64844 */ 64845 64846 64847 64848 64849 64850if (true) { 64851 (function() { 64852'use strict'; 64853 64854var enableSchedulerDebugging = false; 64855var enableProfiling = true; 64856 64857var requestHostCallback; 64858var requestHostTimeout; 64859var cancelHostTimeout; 64860var shouldYieldToHost; 64861var requestPaint; 64862 64863if ( // If Scheduler runs in a non-DOM environment, it falls back to a naive 64864// implementation using setTimeout. 64865typeof window === 'undefined' || // Check if MessageChannel is supported, too. 64866typeof MessageChannel !== 'function') { 64867 // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore, 64868 // fallback to a naive implementation. 64869 var _callback = null; 64870 var _timeoutID = null; 64871 64872 var _flushCallback = function () { 64873 if (_callback !== null) { 64874 try { 64875 var currentTime = exports.unstable_now(); 64876 var hasRemainingTime = true; 64877 64878 _callback(hasRemainingTime, currentTime); 64879 64880 _callback = null; 64881 } catch (e) { 64882 setTimeout(_flushCallback, 0); 64883 throw e; 64884 } 64885 } 64886 }; 64887 64888 var initialTime = Date.now(); 64889 64890 exports.unstable_now = function () { 64891 return Date.now() - initialTime; 64892 }; 64893 64894 requestHostCallback = function (cb) { 64895 if (_callback !== null) { 64896 // Protect against re-entrancy. 64897 setTimeout(requestHostCallback, 0, cb); 64898 } else { 64899 _callback = cb; 64900 setTimeout(_flushCallback, 0); 64901 } 64902 }; 64903 64904 requestHostTimeout = function (cb, ms) { 64905 _timeoutID = setTimeout(cb, ms); 64906 }; 64907 64908 cancelHostTimeout = function () { 64909 clearTimeout(_timeoutID); 64910 }; 64911 64912 shouldYieldToHost = function () { 64913 return false; 64914 }; 64915 64916 requestPaint = exports.unstable_forceFrameRate = function () {}; 64917} else { 64918 // Capture local references to native APIs, in case a polyfill overrides them. 64919 var performance = window.performance; 64920 var _Date = window.Date; 64921 var _setTimeout = window.setTimeout; 64922 var _clearTimeout = window.clearTimeout; 64923 64924 if (typeof console !== 'undefined') { 64925 // TODO: Scheduler no longer requires these methods to be polyfilled. But 64926 // maybe we want to continue warning if they don't exist, to preserve the 64927 // option to rely on it in the future? 64928 var requestAnimationFrame = window.requestAnimationFrame; 64929 var cancelAnimationFrame = window.cancelAnimationFrame; // TODO: Remove fb.me link 64930 64931 if (typeof requestAnimationFrame !== 'function') { 64932 // Using console['error'] to evade Babel and ESLint 64933 console['error']("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); 64934 } 64935 64936 if (typeof cancelAnimationFrame !== 'function') { 64937 // Using console['error'] to evade Babel and ESLint 64938 console['error']("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); 64939 } 64940 } 64941 64942 if (typeof performance === 'object' && typeof performance.now === 'function') { 64943 exports.unstable_now = function () { 64944 return performance.now(); 64945 }; 64946 } else { 64947 var _initialTime = _Date.now(); 64948 64949 exports.unstable_now = function () { 64950 return _Date.now() - _initialTime; 64951 }; 64952 } 64953 64954 var isMessageLoopRunning = false; 64955 var scheduledHostCallback = null; 64956 var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main 64957 // thread, like user events. By default, it yields multiple times per frame. 64958 // It does not attempt to align with frame boundaries, since most tasks don't 64959 // need to be frame aligned; for those that do, use requestAnimationFrame. 64960 64961 var yieldInterval = 5; 64962 var deadline = 0; // TODO: Make this configurable 64963 64964 { 64965 // `isInputPending` is not available. Since we have no way of knowing if 64966 // there's pending input, always yield at the end of the frame. 64967 shouldYieldToHost = function () { 64968 return exports.unstable_now() >= deadline; 64969 }; // Since we yield every frame regardless, `requestPaint` has no effect. 64970 64971 64972 requestPaint = function () {}; 64973 } 64974 64975 exports.unstable_forceFrameRate = function (fps) { 64976 if (fps < 0 || fps > 125) { 64977 // Using console['error'] to evade Babel and ESLint 64978 console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing framerates higher than 125 fps is not unsupported'); 64979 return; 64980 } 64981 64982 if (fps > 0) { 64983 yieldInterval = Math.floor(1000 / fps); 64984 } else { 64985 // reset the framerate 64986 yieldInterval = 5; 64987 } 64988 }; 64989 64990 var performWorkUntilDeadline = function () { 64991 if (scheduledHostCallback !== null) { 64992 var currentTime = exports.unstable_now(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync 64993 // cycle. This means there's always time remaining at the beginning of 64994 // the message event. 64995 64996 deadline = currentTime + yieldInterval; 64997 var hasTimeRemaining = true; 64998 64999 try { 65000 var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime); 65001 65002 if (!hasMoreWork) { 65003 isMessageLoopRunning = false; 65004 scheduledHostCallback = null; 65005 } else { 65006 // If there's more work, schedule the next message event at the end 65007 // of the preceding one. 65008 port.postMessage(null); 65009 } 65010 } catch (error) { 65011 // If a scheduler task throws, exit the current browser task so the 65012 // error can be observed. 65013 port.postMessage(null); 65014 throw error; 65015 } 65016 } else { 65017 isMessageLoopRunning = false; 65018 } // Yielding to the browser will give it a chance to paint, so we can 65019 }; 65020 65021 var channel = new MessageChannel(); 65022 var port = channel.port2; 65023 channel.port1.onmessage = performWorkUntilDeadline; 65024 65025 requestHostCallback = function (callback) { 65026 scheduledHostCallback = callback; 65027 65028 if (!isMessageLoopRunning) { 65029 isMessageLoopRunning = true; 65030 port.postMessage(null); 65031 } 65032 }; 65033 65034 requestHostTimeout = function (callback, ms) { 65035 taskTimeoutID = _setTimeout(function () { 65036 callback(exports.unstable_now()); 65037 }, ms); 65038 }; 65039 65040 cancelHostTimeout = function () { 65041 _clearTimeout(taskTimeoutID); 65042 65043 taskTimeoutID = -1; 65044 }; 65045} 65046 65047function push(heap, node) { 65048 var index = heap.length; 65049 heap.push(node); 65050 siftUp(heap, node, index); 65051} 65052function peek(heap) { 65053 var first = heap[0]; 65054 return first === undefined ? null : first; 65055} 65056function pop(heap) { 65057 var first = heap[0]; 65058 65059 if (first !== undefined) { 65060 var last = heap.pop(); 65061 65062 if (last !== first) { 65063 heap[0] = last; 65064 siftDown(heap, last, 0); 65065 } 65066 65067 return first; 65068 } else { 65069 return null; 65070 } 65071} 65072 65073function siftUp(heap, node, i) { 65074 var index = i; 65075 65076 while (true) { 65077 var parentIndex = index - 1 >>> 1; 65078 var parent = heap[parentIndex]; 65079 65080 if (parent !== undefined && compare(parent, node) > 0) { 65081 // The parent is larger. Swap positions. 65082 heap[parentIndex] = node; 65083 heap[index] = parent; 65084 index = parentIndex; 65085 } else { 65086 // The parent is smaller. Exit. 65087 return; 65088 } 65089 } 65090} 65091 65092function siftDown(heap, node, i) { 65093 var index = i; 65094 var length = heap.length; 65095 65096 while (index < length) { 65097 var leftIndex = (index + 1) * 2 - 1; 65098 var left = heap[leftIndex]; 65099 var rightIndex = leftIndex + 1; 65100 var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those. 65101 65102 if (left !== undefined && compare(left, node) < 0) { 65103 if (right !== undefined && compare(right, left) < 0) { 65104 heap[index] = right; 65105 heap[rightIndex] = node; 65106 index = rightIndex; 65107 } else { 65108 heap[index] = left; 65109 heap[leftIndex] = node; 65110 index = leftIndex; 65111 } 65112 } else if (right !== undefined && compare(right, node) < 0) { 65113 heap[index] = right; 65114 heap[rightIndex] = node; 65115 index = rightIndex; 65116 } else { 65117 // Neither child is smaller. Exit. 65118 return; 65119 } 65120 } 65121} 65122 65123function compare(a, b) { 65124 // Compare sort index first, then task id. 65125 var diff = a.sortIndex - b.sortIndex; 65126 return diff !== 0 ? diff : a.id - b.id; 65127} 65128 65129// TODO: Use symbols? 65130var NoPriority = 0; 65131var ImmediatePriority = 1; 65132var UserBlockingPriority = 2; 65133var NormalPriority = 3; 65134var LowPriority = 4; 65135var IdlePriority = 5; 65136 65137var runIdCounter = 0; 65138var mainThreadIdCounter = 0; 65139var profilingStateSize = 4; 65140var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer 65141typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer 65142typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9 65143; 65144var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks 65145 65146var PRIORITY = 0; 65147var CURRENT_TASK_ID = 1; 65148var CURRENT_RUN_ID = 2; 65149var QUEUE_SIZE = 3; 65150 65151{ 65152 profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue 65153 // array might include canceled tasks. 65154 65155 profilingState[QUEUE_SIZE] = 0; 65156 profilingState[CURRENT_TASK_ID] = 0; 65157} // Bytes per element is 4 65158 65159 65160var INITIAL_EVENT_LOG_SIZE = 131072; 65161var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes 65162 65163var eventLogSize = 0; 65164var eventLogBuffer = null; 65165var eventLog = null; 65166var eventLogIndex = 0; 65167var TaskStartEvent = 1; 65168var TaskCompleteEvent = 2; 65169var TaskErrorEvent = 3; 65170var TaskCancelEvent = 4; 65171var TaskRunEvent = 5; 65172var TaskYieldEvent = 6; 65173var SchedulerSuspendEvent = 7; 65174var SchedulerResumeEvent = 8; 65175 65176function logEvent(entries) { 65177 if (eventLog !== null) { 65178 var offset = eventLogIndex; 65179 eventLogIndex += entries.length; 65180 65181 if (eventLogIndex + 1 > eventLogSize) { 65182 eventLogSize *= 2; 65183 65184 if (eventLogSize > MAX_EVENT_LOG_SIZE) { 65185 // Using console['error'] to evade Babel and ESLint 65186 console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.'); 65187 stopLoggingProfilingEvents(); 65188 return; 65189 } 65190 65191 var newEventLog = new Int32Array(eventLogSize * 4); 65192 newEventLog.set(eventLog); 65193 eventLogBuffer = newEventLog.buffer; 65194 eventLog = newEventLog; 65195 } 65196 65197 eventLog.set(entries, offset); 65198 } 65199} 65200 65201function startLoggingProfilingEvents() { 65202 eventLogSize = INITIAL_EVENT_LOG_SIZE; 65203 eventLogBuffer = new ArrayBuffer(eventLogSize * 4); 65204 eventLog = new Int32Array(eventLogBuffer); 65205 eventLogIndex = 0; 65206} 65207function stopLoggingProfilingEvents() { 65208 var buffer = eventLogBuffer; 65209 eventLogSize = 0; 65210 eventLogBuffer = null; 65211 eventLog = null; 65212 eventLogIndex = 0; 65213 return buffer; 65214} 65215function markTaskStart(task, ms) { 65216 { 65217 profilingState[QUEUE_SIZE]++; 65218 65219 if (eventLog !== null) { 65220 // performance.now returns a float, representing milliseconds. When the 65221 // event is logged, it's coerced to an int. Convert to microseconds to 65222 // maintain extra degrees of precision. 65223 logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]); 65224 } 65225 } 65226} 65227function markTaskCompleted(task, ms) { 65228 { 65229 profilingState[PRIORITY] = NoPriority; 65230 profilingState[CURRENT_TASK_ID] = 0; 65231 profilingState[QUEUE_SIZE]--; 65232 65233 if (eventLog !== null) { 65234 logEvent([TaskCompleteEvent, ms * 1000, task.id]); 65235 } 65236 } 65237} 65238function markTaskCanceled(task, ms) { 65239 { 65240 profilingState[QUEUE_SIZE]--; 65241 65242 if (eventLog !== null) { 65243 logEvent([TaskCancelEvent, ms * 1000, task.id]); 65244 } 65245 } 65246} 65247function markTaskErrored(task, ms) { 65248 { 65249 profilingState[PRIORITY] = NoPriority; 65250 profilingState[CURRENT_TASK_ID] = 0; 65251 profilingState[QUEUE_SIZE]--; 65252 65253 if (eventLog !== null) { 65254 logEvent([TaskErrorEvent, ms * 1000, task.id]); 65255 } 65256 } 65257} 65258function markTaskRun(task, ms) { 65259 { 65260 runIdCounter++; 65261 profilingState[PRIORITY] = task.priorityLevel; 65262 profilingState[CURRENT_TASK_ID] = task.id; 65263 profilingState[CURRENT_RUN_ID] = runIdCounter; 65264 65265 if (eventLog !== null) { 65266 logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]); 65267 } 65268 } 65269} 65270function markTaskYield(task, ms) { 65271 { 65272 profilingState[PRIORITY] = NoPriority; 65273 profilingState[CURRENT_TASK_ID] = 0; 65274 profilingState[CURRENT_RUN_ID] = 0; 65275 65276 if (eventLog !== null) { 65277 logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]); 65278 } 65279 } 65280} 65281function markSchedulerSuspended(ms) { 65282 { 65283 mainThreadIdCounter++; 65284 65285 if (eventLog !== null) { 65286 logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]); 65287 } 65288 } 65289} 65290function markSchedulerUnsuspended(ms) { 65291 { 65292 if (eventLog !== null) { 65293 logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]); 65294 } 65295 } 65296} 65297 65298/* eslint-disable no-var */ 65299// Math.pow(2, 30) - 1 65300// 0b111111111111111111111111111111 65301 65302var maxSigned31BitInt = 1073741823; // Times out immediately 65303 65304var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out 65305 65306var USER_BLOCKING_PRIORITY = 250; 65307var NORMAL_PRIORITY_TIMEOUT = 5000; 65308var LOW_PRIORITY_TIMEOUT = 10000; // Never times out 65309 65310var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap 65311 65312var taskQueue = []; 65313var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. 65314 65315var taskIdCounter = 1; // Pausing the scheduler is useful for debugging. 65316var currentTask = null; 65317var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. 65318 65319var isPerformingWork = false; 65320var isHostCallbackScheduled = false; 65321var isHostTimeoutScheduled = false; 65322 65323function advanceTimers(currentTime) { 65324 // Check for tasks that are no longer delayed and add them to the queue. 65325 var timer = peek(timerQueue); 65326 65327 while (timer !== null) { 65328 if (timer.callback === null) { 65329 // Timer was cancelled. 65330 pop(timerQueue); 65331 } else if (timer.startTime <= currentTime) { 65332 // Timer fired. Transfer to the task queue. 65333 pop(timerQueue); 65334 timer.sortIndex = timer.expirationTime; 65335 push(taskQueue, timer); 65336 65337 { 65338 markTaskStart(timer, currentTime); 65339 timer.isQueued = true; 65340 } 65341 } else { 65342 // Remaining timers are pending. 65343 return; 65344 } 65345 65346 timer = peek(timerQueue); 65347 } 65348} 65349 65350function handleTimeout(currentTime) { 65351 isHostTimeoutScheduled = false; 65352 advanceTimers(currentTime); 65353 65354 if (!isHostCallbackScheduled) { 65355 if (peek(taskQueue) !== null) { 65356 isHostCallbackScheduled = true; 65357 requestHostCallback(flushWork); 65358 } else { 65359 var firstTimer = peek(timerQueue); 65360 65361 if (firstTimer !== null) { 65362 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); 65363 } 65364 } 65365 } 65366} 65367 65368function flushWork(hasTimeRemaining, initialTime) { 65369 { 65370 markSchedulerUnsuspended(initialTime); 65371 } // We'll need a host callback the next time work is scheduled. 65372 65373 65374 isHostCallbackScheduled = false; 65375 65376 if (isHostTimeoutScheduled) { 65377 // We scheduled a timeout but it's no longer needed. Cancel it. 65378 isHostTimeoutScheduled = false; 65379 cancelHostTimeout(); 65380 } 65381 65382 isPerformingWork = true; 65383 var previousPriorityLevel = currentPriorityLevel; 65384 65385 try { 65386 if (enableProfiling) { 65387 try { 65388 return workLoop(hasTimeRemaining, initialTime); 65389 } catch (error) { 65390 if (currentTask !== null) { 65391 var currentTime = exports.unstable_now(); 65392 markTaskErrored(currentTask, currentTime); 65393 currentTask.isQueued = false; 65394 } 65395 65396 throw error; 65397 } 65398 } else { 65399 // No catch in prod codepath. 65400 return workLoop(hasTimeRemaining, initialTime); 65401 } 65402 } finally { 65403 currentTask = null; 65404 currentPriorityLevel = previousPriorityLevel; 65405 isPerformingWork = false; 65406 65407 { 65408 var _currentTime = exports.unstable_now(); 65409 65410 markSchedulerSuspended(_currentTime); 65411 } 65412 } 65413} 65414 65415function workLoop(hasTimeRemaining, initialTime) { 65416 var currentTime = initialTime; 65417 advanceTimers(currentTime); 65418 currentTask = peek(taskQueue); 65419 65420 while (currentTask !== null && !(enableSchedulerDebugging )) { 65421 if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { 65422 // This currentTask hasn't expired, and we've reached the deadline. 65423 break; 65424 } 65425 65426 var callback = currentTask.callback; 65427 65428 if (callback !== null) { 65429 currentTask.callback = null; 65430 currentPriorityLevel = currentTask.priorityLevel; 65431 var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; 65432 markTaskRun(currentTask, currentTime); 65433 var continuationCallback = callback(didUserCallbackTimeout); 65434 currentTime = exports.unstable_now(); 65435 65436 if (typeof continuationCallback === 'function') { 65437 currentTask.callback = continuationCallback; 65438 markTaskYield(currentTask, currentTime); 65439 } else { 65440 { 65441 markTaskCompleted(currentTask, currentTime); 65442 currentTask.isQueued = false; 65443 } 65444 65445 if (currentTask === peek(taskQueue)) { 65446 pop(taskQueue); 65447 } 65448 } 65449 65450 advanceTimers(currentTime); 65451 } else { 65452 pop(taskQueue); 65453 } 65454 65455 currentTask = peek(taskQueue); 65456 } // Return whether there's additional work 65457 65458 65459 if (currentTask !== null) { 65460 return true; 65461 } else { 65462 var firstTimer = peek(timerQueue); 65463 65464 if (firstTimer !== null) { 65465 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); 65466 } 65467 65468 return false; 65469 } 65470} 65471 65472function unstable_runWithPriority(priorityLevel, eventHandler) { 65473 switch (priorityLevel) { 65474 case ImmediatePriority: 65475 case UserBlockingPriority: 65476 case NormalPriority: 65477 case LowPriority: 65478 case IdlePriority: 65479 break; 65480 65481 default: 65482 priorityLevel = NormalPriority; 65483 } 65484 65485 var previousPriorityLevel = currentPriorityLevel; 65486 currentPriorityLevel = priorityLevel; 65487 65488 try { 65489 return eventHandler(); 65490 } finally { 65491 currentPriorityLevel = previousPriorityLevel; 65492 } 65493} 65494 65495function unstable_next(eventHandler) { 65496 var priorityLevel; 65497 65498 switch (currentPriorityLevel) { 65499 case ImmediatePriority: 65500 case UserBlockingPriority: 65501 case NormalPriority: 65502 // Shift down to normal priority 65503 priorityLevel = NormalPriority; 65504 break; 65505 65506 default: 65507 // Anything lower than normal priority should remain at the current level. 65508 priorityLevel = currentPriorityLevel; 65509 break; 65510 } 65511 65512 var previousPriorityLevel = currentPriorityLevel; 65513 currentPriorityLevel = priorityLevel; 65514 65515 try { 65516 return eventHandler(); 65517 } finally { 65518 currentPriorityLevel = previousPriorityLevel; 65519 } 65520} 65521 65522function unstable_wrapCallback(callback) { 65523 var parentPriorityLevel = currentPriorityLevel; 65524 return function () { 65525 // This is a fork of runWithPriority, inlined for performance. 65526 var previousPriorityLevel = currentPriorityLevel; 65527 currentPriorityLevel = parentPriorityLevel; 65528 65529 try { 65530 return callback.apply(this, arguments); 65531 } finally { 65532 currentPriorityLevel = previousPriorityLevel; 65533 } 65534 }; 65535} 65536 65537function timeoutForPriorityLevel(priorityLevel) { 65538 switch (priorityLevel) { 65539 case ImmediatePriority: 65540 return IMMEDIATE_PRIORITY_TIMEOUT; 65541 65542 case UserBlockingPriority: 65543 return USER_BLOCKING_PRIORITY; 65544 65545 case IdlePriority: 65546 return IDLE_PRIORITY; 65547 65548 case LowPriority: 65549 return LOW_PRIORITY_TIMEOUT; 65550 65551 case NormalPriority: 65552 default: 65553 return NORMAL_PRIORITY_TIMEOUT; 65554 } 65555} 65556 65557function unstable_scheduleCallback(priorityLevel, callback, options) { 65558 var currentTime = exports.unstable_now(); 65559 var startTime; 65560 var timeout; 65561 65562 if (typeof options === 'object' && options !== null) { 65563 var delay = options.delay; 65564 65565 if (typeof delay === 'number' && delay > 0) { 65566 startTime = currentTime + delay; 65567 } else { 65568 startTime = currentTime; 65569 } 65570 65571 timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel); 65572 } else { 65573 timeout = timeoutForPriorityLevel(priorityLevel); 65574 startTime = currentTime; 65575 } 65576 65577 var expirationTime = startTime + timeout; 65578 var newTask = { 65579 id: taskIdCounter++, 65580 callback: callback, 65581 priorityLevel: priorityLevel, 65582 startTime: startTime, 65583 expirationTime: expirationTime, 65584 sortIndex: -1 65585 }; 65586 65587 { 65588 newTask.isQueued = false; 65589 } 65590 65591 if (startTime > currentTime) { 65592 // This is a delayed task. 65593 newTask.sortIndex = startTime; 65594 push(timerQueue, newTask); 65595 65596 if (peek(taskQueue) === null && newTask === peek(timerQueue)) { 65597 // All tasks are delayed, and this is the task with the earliest delay. 65598 if (isHostTimeoutScheduled) { 65599 // Cancel an existing timeout. 65600 cancelHostTimeout(); 65601 } else { 65602 isHostTimeoutScheduled = true; 65603 } // Schedule a timeout. 65604 65605 65606 requestHostTimeout(handleTimeout, startTime - currentTime); 65607 } 65608 } else { 65609 newTask.sortIndex = expirationTime; 65610 push(taskQueue, newTask); 65611 65612 { 65613 markTaskStart(newTask, currentTime); 65614 newTask.isQueued = true; 65615 } // Schedule a host callback, if needed. If we're already performing work, 65616 // wait until the next time we yield. 65617 65618 65619 if (!isHostCallbackScheduled && !isPerformingWork) { 65620 isHostCallbackScheduled = true; 65621 requestHostCallback(flushWork); 65622 } 65623 } 65624 65625 return newTask; 65626} 65627 65628function unstable_pauseExecution() { 65629} 65630 65631function unstable_continueExecution() { 65632 65633 if (!isHostCallbackScheduled && !isPerformingWork) { 65634 isHostCallbackScheduled = true; 65635 requestHostCallback(flushWork); 65636 } 65637} 65638 65639function unstable_getFirstCallbackNode() { 65640 return peek(taskQueue); 65641} 65642 65643function unstable_cancelCallback(task) { 65644 { 65645 if (task.isQueued) { 65646 var currentTime = exports.unstable_now(); 65647 markTaskCanceled(task, currentTime); 65648 task.isQueued = false; 65649 } 65650 } // Null out the callback to indicate the task has been canceled. (Can't 65651 // remove from the queue because you can't remove arbitrary nodes from an 65652 // array based heap, only the first one.) 65653 65654 65655 task.callback = null; 65656} 65657 65658function unstable_getCurrentPriorityLevel() { 65659 return currentPriorityLevel; 65660} 65661 65662function unstable_shouldYield() { 65663 var currentTime = exports.unstable_now(); 65664 advanceTimers(currentTime); 65665 var firstTask = peek(taskQueue); 65666 return firstTask !== currentTask && currentTask !== null && firstTask !== null && firstTask.callback !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost(); 65667} 65668 65669var unstable_requestPaint = requestPaint; 65670var unstable_Profiling = { 65671 startLoggingProfilingEvents: startLoggingProfilingEvents, 65672 stopLoggingProfilingEvents: stopLoggingProfilingEvents, 65673 sharedProfilingBuffer: sharedProfilingBuffer 65674} ; 65675 65676exports.unstable_IdlePriority = IdlePriority; 65677exports.unstable_ImmediatePriority = ImmediatePriority; 65678exports.unstable_LowPriority = LowPriority; 65679exports.unstable_NormalPriority = NormalPriority; 65680exports.unstable_Profiling = unstable_Profiling; 65681exports.unstable_UserBlockingPriority = UserBlockingPriority; 65682exports.unstable_cancelCallback = unstable_cancelCallback; 65683exports.unstable_continueExecution = unstable_continueExecution; 65684exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel; 65685exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode; 65686exports.unstable_next = unstable_next; 65687exports.unstable_pauseExecution = unstable_pauseExecution; 65688exports.unstable_requestPaint = unstable_requestPaint; 65689exports.unstable_runWithPriority = unstable_runWithPriority; 65690exports.unstable_scheduleCallback = unstable_scheduleCallback; 65691exports.unstable_shouldYield = unstable_shouldYield; 65692exports.unstable_wrapCallback = unstable_wrapCallback; 65693 })(); 65694} 65695 65696 65697/***/ }), 65698
vendor: 458 bytes, lines 65699-65715
65699/***/ "./node_modules/scheduler/index.js": 65700/*!*****************************************!*\ 65701 !*** ./node_modules/scheduler/index.js ***! 65702 \*****************************************/ 65703/*! no static exports found */ 65704/***/ (function(module, exports, __webpack_require__) { 65705 65706"use strict"; 65707 65708 65709if (false) {} else { 65710 module.exports = __webpack_require__(/*! ./cjs/scheduler.development.js */ "./node_modules/scheduler/cjs/scheduler.development.js"); 65711} 65712 65713 65714/***/ }), 65715
vendor: 482 bytes, lines 65716-65732
65716/***/ "./node_modules/scheduler/tracing.js": 65717/*!*******************************************!*\ 65718 !*** ./node_modules/scheduler/tracing.js ***! 65719 \*******************************************/ 65720/*! no static exports found */ 65721/***/ (function(module, exports, __webpack_require__) { 65722 65723"use strict"; 65724 65725 65726if (false) {} else { 65727 module.exports = __webpack_require__(/*! ./cjs/scheduler-tracing.development.js */ "./node_modules/scheduler/cjs/scheduler-tracing.development.js"); 65728} 65729 65730 65731/***/ }), 65732
vendor: 724 bytes, lines 65733-65763
65733/***/ "./node_modules/webpack/buildin/global.js": 65734/*!***********************************!*\ 65735 !*** (webpack)/buildin/global.js ***! 65736 \***********************************/ 65737/*! no static exports found */ 65738/***/ (function(module, exports) { 65739 65740var g; 65741 65742// This works in non-strict mode 65743g = (function() { 65744 return this; 65745})(); 65746 65747try { 65748 // This works if eval is allowed (see CSP) 65749 g = g || new Function("return this")(); 65750} catch (e) { 65751 // This works if the window reference is available 65752 if (typeof window === "object") g = window; 65753} 65754 65755// g can still be undefined, but nothing to do about it... 65756// We return undefined, instead of nothing here, so it's 65757// easier to handle this case. if(!global) { ...} 65758 65759module.exports = g; 65760 65761 65762/***/ }), 65763
vendor: 749 bytes, lines 65764-65796
65764/***/ "./node_modules/webpack/buildin/module.js": 65765/*!***********************************!*\ 65766 !*** (webpack)/buildin/module.js ***! 65767 \***********************************/ 65768/*! no static exports found */ 65769/***/ (function(module, exports) { 65770 65771module.exports = function(module) { 65772 if (!module.webpackPolyfill) { 65773 module.deprecate = function() {}; 65774 module.paths = []; 65775 // module.parent = undefined by default 65776 if (!module.children) module.children = []; 65777 Object.defineProperty(module, "loaded", { 65778 enumerable: true, 65779 get: function() { 65780 return module.l; 65781 } 65782 }); 65783 Object.defineProperty(module, "id", { 65784 enumerable: true, 65785 get: function() { 65786 return module.i; 65787 } 65788 }); 65789 module.webpackPolyfill = 1; 65790 } 65791 return module; 65792}; 65793 65794 65795/***/ }), 65796
65797/***/ "./themes/bhittacms-news3/js/app.js": 65798/*!******************************************!*\ 65799 !*** ./themes/bhittacms-news3/js/app.js ***! 65800 \******************************************/ 65801/*! no static exports found */ 65802/***/ (function(module, exports, __webpack_require__) { 65803 65804/** 65805 * First we will load all of this project's JavaScript dependencies which 65806 * includes React and other helpers. It's a great starting point while 65807 * building robust, powerful web applications using React + Laravel. 65808 */ 65809__webpack_require__(/*! ./bootstrap */ "./themes/bhittacms-news3/js/bootstrap.js"); 65810/** 65811 * Next, we will create a fresh React component instance and attach it to 65812 * the page. Then, you may begin adding components to this application 65813 * or customize the JavaScript scaffolding to fit your unique needs. 65814 */ 65815 65816 65817__webpack_require__(/*! ./components/Example */ "./themes/bhittacms-news3/js/components/Example.js"); 65818 65819__webpack_require__(/*! ./components/Poll */ "./themes/bhittacms-news3/js/components/Poll.js"); 65820 65821__webpack_require__(/*! ./components/Result */ "./themes/bhittacms-news3/js/components/Result.js"); 65822 65823__webpack_require__(/*! ./components/Options */ "./themes/bhittacms-news3/js/components/Options.js"); 65824 65825/***/ }), 65826
65827/***/ "./themes/bhittacms-news3/js/bootstrap.js": 65828/*!************************************************!*\ 65829 !*** ./themes/bhittacms-news3/js/bootstrap.js ***! 65830 \************************************************/ 65831/*! no static exports found */ 65832/***/ (function(module, exports, __webpack_require__) { 65833 65834window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"); 65835/** 65836 * We'll load jQuery and the Bootstrap jQuery plugin which provides support 65837 * for JavaScript based Bootstrap features such as modals and tabs. This 65838 * code may be modified to fit the specific needs of your application. 65839 */ 65840 65841try { 65842 window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"]; 65843 window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); 65844 65845 __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js"); 65846} catch (e) {} 65847/** 65848 * We'll load the axios HTTP library which allows us to easily issue requests 65849 * to our Laravel back-end. This library automatically handles sending the 65850 * CSRF token as a header based on the value of the "XSRF" token cookie. 65851 */ 65852 65853 65854window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js"); 65855window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 65856/** 65857 * Echo exposes an expressive API for subscribing to channels and listening 65858 * for events that are broadcast by Laravel. Echo and event broadcasting 65859 * allows your team to easily build robust real-time web applications. 65860 */ 65861// import Echo from 'laravel-echo'; 65862// window.Pusher = require('pusher-js'); 65863// window.Echo = new Echo({ 65864// broadcaster: 'pusher', 65865// key: process.env.MIX_PUSHER_APP_KEY, 65866// cluster: process.env.MIX_PUSHER_APP_CLUSTER, 65867// forceTLS: true 65868// }); 65869 65870/***/ }), 65871
65872/***/ "./themes/bhittacms-news3/js/components/Example.js": 65873/*!*********************************************************!*\ 65874 !*** ./themes/bhittacms-news3/js/components/Example.js ***! 65875 \*********************************************************/ 65876/*! exports provided: default */ 65877/***/ (function(module, __webpack_exports__, __webpack_require__) { 65878 65879"use strict"; 65880__webpack_require__.r(__webpack_exports__); 65881/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); 65882/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 65883/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js"); 65884/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__); 65885 65886 65887 65888function Example() { 65889 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 65890 className: "container" 65891 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 65892 className: "row justify-content-center" 65893 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 65894 className: "col-md-8" 65895 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 65896 className: "card" 65897 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 65898 className: "card-header" 65899 }, "Example Component"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 65900 className: "card-body" 65901 }, "I'm an example component!"))))); 65902} 65903 65904/* harmony default export */ __webpack_exports__["default"] = (Example); 65905 65906if (document.getElementById('example')) { 65907 react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(Example, null), document.getElementById('example')); 65908} 65909 65910/***/ }), 65911
vendor: 4,543 bytes, lines 65912-65975
65912/***/ "./themes/bhittacms-news3/js/components/Options.js": 65913/*!*********************************************************!*\ 65914 !*** ./themes/bhittacms-news3/js/components/Options.js ***! 65915 \*********************************************************/ 65916/*! exports provided: default */ 65917/***/ (function(module, __webpack_exports__, __webpack_require__) { 65918 65919"use strict"; 65920__webpack_require__.r(__webpack_exports__); 65921/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Options; }); 65922/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); 65923/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 65924function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 65925 65926function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 65927 65928function _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); } } 65929 65930function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 65931 65932function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 65933 65934function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 65935 65936function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 65937 65938function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 65939 65940function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 65941 65942function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 65943 65944function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 65945 65946 65947 65948var Options = /*#__PURE__*/function (_Component) { 65949 _inherits(Options, _Component); 65950 65951 var _super = _createSuper(Options); 65952 65953 function Options() { 65954 _classCallCheck(this, Options); 65955 65956 return _super.apply(this, arguments); 65957 } 65958 65959 _createClass(Options, [{ 65960 key: "updateChange", 65961 value: function updateChange(e) { 65962 var selected = e.target.value; 65963 this.props.handleChange(selected); 65964 } 65965 }, { 65966 key: "render", 65967 value: function render() { 65968 if (!this.props.options) { 65969 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null, "Loading..."); 65970 } 65971 65972 console.log(this.props.options.length); 65973 65974 if (this.props.options.length == 2) { 65975 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
65976 className: "options-box" 65977 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("form", { 65978 className: "poll-options", 65979 method: "get", 65980 action: "" 65981 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("fieldset", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 65982 className: "form-group" 65983 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 65984 className: "radio first" 65985 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("label", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("input", { 65986 type: "radio", 65987 name: "optionsRadios", 65988 onChange: this.updateChange.bind(this), 65989 value: this.props.options[0].id 65990 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 65991 className: "circle" 65992 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 65993 className: "check" 65994 }), this.props.options[0].options)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 65995 className: "radio" 65996 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("label", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("input", { 65997 type: "radio", 65998 name: "optionsRadios", 65999 onChange: this.updateChange.bind(this), 66000 value: this.props.options[1].id 66001 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66002 className: "circle" 66003 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66004 className: "check" 66005 }), this.props.options[1].options))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66006 className: "action-area" 66007 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", { 66008 href: "javascript:void(0)", 66009 title: "\u092E\u0924 \u0926\u093F\u0928\u0941\u0939\u094B\u0938\u094D", 66010 className: "btn btn-default", 66011 onClick: this.props.addCount 66012 }, "\u092E\u0924 \u0926\u093F\u0928\u0941\u0939\u094B\u0938\u094D ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66013 className: "left-icon lnr lnr-checkmark-circle" 66014 })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", { 66015 href: "javascript:void(0)", 66016 title: "\u0928\u0924\u093F\u091C\u093E \u0939\u0947\u0930\u094D\u0928\u0941\u0939\u094B\u0938\u094D", 66017 className: "btn btn-default view-result", 66018 onClick: this.props.showResult 66019 }, "\u0928\u0924\u093F\u091C\u093E \u0939\u0947\u0930\u094D\u0928\u0941\u0939\u094B\u0938\u094D ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66020 className: "left-icon lnr lnr-chevron-right" 66021 })))))); 66022 } else if (this.props.options.length == 3) { 66023 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66024 className: "options-box" 66025 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("form", { 66026 className: "poll-options", 66027 method: "get", 66028 action: "" 66029 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("fieldset", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66030 className: "form-group" 66031 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66032 className: "radio first" 66033 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("label", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("input", { 66034 type: "radio", 66035 name: "optionsRadios", 66036 onChange: this.updateChange.bind(this), 66037 value: this.props.options[0].id 66038 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66039 className: "circle" 66040 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66041 className: "check" 66042 }), this.props.options[0].options)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66043 className: "radio" 66044 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("label", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("input", { 66045 type: "radio", 66046 name: "optionsRadios", 66047 onChange: this.updateChange.bind(this), 66048 value: this.props.options[1].id 66049 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66050 className: "circle" 66051 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66052 className: "check" 66053 }), this.props.options[1].options)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66054 className: "radio" 66055 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("label", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("input", { 66056 type: "radio", 66057 name: "optionsRadios", 66058 onChange: this.updateChange.bind(this), 66059 value: this.props.options[2].id 66060 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66061 className: "circle" 66062 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66063 className: "check" 66064 }), this.props.options[2].options))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66065 className: "action-area" 66066 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", { 66067 href: "javascript:void(0)", 66068 title: "\u092E\u0924 \u0926\u093F\u0928\u0941\u0939\u094B\u0938\u094D", 66069 className: "btn btn-default", 66070 onClick: this.props.addCount 66071 }, "\u092E\u0924 \u0926\u093F\u0928\u0941\u0939\u094B\u0938\u094D ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66072 className: "left-icon lnr lnr-checkmark-circle" 66073 })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", { 66074 href: "javascript:void(0)", 66075 title: "\u0928\u0924\u093F\u091C\u093E \u0939\u0947\u0930\u094D\u0928\u0941\u0939\u094B\u0938\u094D", 66076 className: "btn btn-default view-result", 66077 onClick: this.props.showResult 66078 }, "\u0928\u0924\u093F\u091C\u093E \u0939\u0947\u0930\u094D\u0928\u0941\u0939\u094B\u0938\u094D ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66079 className: "left-icon lnr lnr-chevron-right" 66080 })))))); 66081 } else { 66082 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
66083 className: "options-box" 66084 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("form", { 66085 className: "poll-options", 66086 method: "get", 66087 action: "" 66088 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("fieldset", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66089 className: "form-group" 66090 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66091 className: "radio first" 66092 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("label", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("input", { 66093 type: "radio", 66094 name: "optionsRadios", 66095 onChange: this.updateChange.bind(this), 66096 value: this.props.options[0].id 66097 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66098 className: "circle" 66099 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66100 className: "check" 66101 }), this.props.options[0].options)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66102 className: "radio" 66103 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("label", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("input", { 66104 type: "radio", 66105 name: "optionsRadios", 66106 onChange: this.updateChange.bind(this), 66107 value: this.props.options[1].id 66108 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66109 className: "circle" 66110 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66111 className: "check" 66112 }), this.props.options[1].options)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66113 className: "radio" 66114 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("label", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("input", { 66115 type: "radio", 66116 name: "optionsRadios", 66117 onChange: this.updateChange.bind(this), 66118 value: this.props.options[2].id 66119 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66120 className: "circle" 66121 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66122 className: "check" 66123 }), this.props.options[2].options)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66124 className: "radio" 66125 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("label", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("input", { 66126 type: "radio", 66127 name: "optionsRadios", 66128 onChange: this.updateChange.bind(this), 66129 value: this.props.options[3].id 66130 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66131 className: "circle" 66132 }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66133 className: "check" 66134 }), this.props.options[3].options))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66135 className: "action-area" 66136 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", { 66137 href: "javascript:void(0)", 66138 title: "\u092E\u0924 \u0926\u093F\u0928\u0941\u0939\u094B\u0938\u094D", 66139 className: "btn btn-default", 66140 onClick: this.props.addCount 66141 }, "\u092E\u0924 \u0926\u093F\u0928\u0941\u0939\u094B\u0938\u094D ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66142 className: "left-icon lnr lnr-checkmark-circle" 66143 })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("a", { 66144 href: "javascript:void(0)", 66145 title: "\u0928\u0924\u093F\u091C\u093E \u0939\u0947\u0930\u094D\u0928\u0941\u0939\u094B\u0938\u094D", 66146 className: "btn btn-default view-result", 66147 onClick: this.props.showResult 66148 }, "\u0928\u0924\u093F\u091C\u093E \u0939\u0947\u0930\u094D\u0928\u0941\u0939\u094B\u0938\u094D ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66149 className: "left-icon lnr lnr-chevron-right" 66150 })))))); 66151 } 66152 } 66153 }]); 66154 66155 return Options; 66156}(react__WEBPACK_IMPORTED_MODULE_0__["Component"]); 66157 66158 66159 66160/***/ }), 66161
vendor: 4,118 bytes, lines 66162-66197
66162/***/ "./themes/bhittacms-news3/js/components/Poll.js": 66163/*!******************************************************!*\ 66164 !*** ./themes/bhittacms-news3/js/components/Poll.js ***! 66165 \******************************************************/ 66166/*! exports provided: default */ 66167/***/ (function(module, __webpack_exports__, __webpack_require__) { 66168 66169"use strict"; 66170__webpack_require__.r(__webpack_exports__); 66171/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); 66172/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 66173/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js"); 66174/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__); 66175/* harmony import */ var _Result__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Result */ "./themes/bhittacms-news3/js/components/Result.js"); 66176/* harmony import */ var _Options__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Options */ "./themes/bhittacms-news3/js/components/Options.js"); 66177function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 66178 66179function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 66180 66181function _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); } } 66182 66183function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 66184 66185function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 66186 66187function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 66188 66189function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 66190 66191function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 66192 66193function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 66194 66195function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 66196 66197function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o
66197) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 66198 66199 66200 66201 66202 66203 66204var Poll = /*#__PURE__*/function (_Component) { 66205 _inherits(Poll, _Component); 66206 66207 var _super = _createSuper(Poll); 66208 66209 function Poll(props) { 66210 var _this; 66211 66212 _classCallCheck(this, Poll); 66213 66214 _this = _super.call(this, props); 66215 _this.state = { 66216 data: { 66217 question: [] 66218 }, 66219 selected: '', 66220 status: false 66221 }; // this.handleChange = this.handleChange.bind(this); 66222 // this.addCount = this.addCount.bind(this); 66223 // this.showResult = this.showResult.bind(this); 66224 // this.renderData = this.renderData.bind(this); 66225 66226 return _this; 66227 } 66228 66229 _createClass(Poll, [{ 66230 key: "componentDidMount", 66231 value: function componentDidMount() { 66232 var _this2 = this; 66233 66234 fetch('/api/pollData').then(function (response) { 66235 return response.json(); 66236 }).then(function (data) { 66237 _this2.setState({ 66238 data: data 66239 }); 66240 }); 66241 } 66242 }, { 66243 key: "handleChange", 66244 value: function handleChange(selected) { 66245 this.setState({ 66246 selected: selected 66247 }); 66248 } 66249 }, { 66250 key: "addCount", 66251 value: function addCount(event) { 66252 var _this3 = this; 66253 66254 var baseUrl = document.querySelector('meta[name="baseUrl"]').getAttribute('content'); 66255 var url = baseUrl + '/api/pollDataUpdate/' + this.state.selected; 66256 axios({ 66257 method: 'get', 66258 url: url, 66259 data: { 66260 id: this.state.selected 66261 } 66262 }).then(function (response) { 66263 // console.log(response.data); 66264 var in1hr = 1 / 24; // localStorage.setItem('userSelected', this.state.selected) 66265 66266 Cookies.set('userSelected', _this3.state.selected, { 66267 expires: in1hr 66268 }); // console.log(Cookies.get('userSelected')); 66269 66270 _this3.showResult(); 66271 66272 _this3.setState({ 66273 data: response.data.data 66274 }); 66275 }); // event.preventDefault(); 66276 } // pollAnimation(){ 66277 // $('.bar').width('0%'); 66278 // $('.bar').waypoint(function () { 66279 // $('.bar').each(function () { 66280 // var width = $(this).attr("data-percentage"); 66281 // $(this).animate({ 66282 // width: width 66283 // }, { 66284 // duration: 2000, 66285 // //easing: 'easeOutExpo', 66286 // }); 66287 // }); 66288 // }, { 66289 // offset: '100%' 66290 // }); 66291 // } 66292 66293 }, { 66294 key: "showResult", 66295 value: function showResult() { 66296 this.setState({ 66297 status: !this.state.status 66298 }); 66299 console.log(this.state.status); 66300 } 66301 }, { 66302 key: "renderData", 66303 value: function renderData() { 66304 console.log(this.state.status); // Cookies.remove('userSelected'); 66305 // console.log(Cookies.get('userSelected')); 66306 66307 if (this.state.status) { 66308 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Result__WEBPACK_IMPORTED_MODULE_2__["default"], { 66309 options: this.state.data.options 66310 })); 66311 } else { 66312 if (Cookies.get('userSelected') == undefined) { 66313 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Options__WEBPACK_IMPORTED_MODULE_3__["default"], { 66314 options: this.state.data.options, 66315 handleChange: this.handleChange.bind(this), 66316 addCount: this.addCount.bind(this), 66317 showResult: this.showResult.bind(this) 66318 }); 66319 } 66320 66321 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Result__WEBPACK_IMPORTED_MODULE_2__["default"], { 66322 options: this.state.data.options 66323 }); 66324 } 66325 } 66326 }, { 66327 key: "render", 66328 value: function render() { 66329 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66330 className: "items poll-system white" 66331 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66332 className: "main-title" 66333 }, this.state.data.question), this.renderData()); 66334 } 66335 }]); 66336 66337 return Poll; 66338}(react__WEBPACK_IMPORTED_MODULE_0__["Component"]); 66339 66340/* harmony default export */ __webpack_exports__["default"] = (Poll); 66341 66342if (document.getElementById('poll')) { 66343 react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(Poll, null), document.getElementById('poll')); 66344} 66345 66346/***/ }), 66347
66348/***/ "./themes/bhittacms-news3/js/components/Result.js": 66349/*!********************************************************!*\ 66350 !*** ./themes/bhittacms-news3/js/components/Result.js ***! 66351 \********************************************************/ 66352/*! exports provided: default */ 66353/***/ (function(module, __webpack_exports__, __webpack_require__) { 66354 66355"use strict"; 66356__webpack_require__.r(__webpack_exports__); 66357/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Result; }); 66358/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); 66359/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 66360function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 66361 66362function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 66363 66364function _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); } } 66365 66366function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 66367 66368function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 66369 66370function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 66371 66372function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 66373 66374function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 66375 66376function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 66377 66378function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 66379 66380function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 66381 66382 66383 66384var Result = /*#__PURE__*/function (_Component) { 66385 _inherits(Result, _Component); 66386 66387 var _super = _createSuper(Result); 66388 66389 function Result() { 66390 _classCallCheck(this, Result); 66391 66392 return _super.apply(this, arguments); 66393 } 66394 66395 _createClass(Result, [{ 66396 key: "calculatePercentage", 66397 value: function calculatePercentage(opt) { 66398 var i; 66399 var total = 0; 66400 var count = this.props.options.length; 66401 66402 for (i = 0; i < count; i++) { 66403 total = total + this.props.options[i].total_count; 66404 } 66405 66406 if (opt == 0) { 66407 return 0; 66408 } 66409 66410 console.log(opt, total); 66411 var result = Math.round(opt / total * 100); 66412 return result; 66413 } 66414 }, { 66415 key: "render", 66416 value: function render() { 66417 var containerStyles = { 66418 width: '100%', 66419 backgroundColor: "#f5f5f5" 66420 }; 66421 66422 if (!this.props.options) { 66423 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null, "Loading..."); 66424 } 66425 66426 if (this.props.options.length == 2) { 66427 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66428 className: "boundary-box" 66429 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66430 className: "poll-result" 66431 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66432 className: "row pollresult" 66433 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66434 className: "col-xs-12 col-sm-12 col-md-12" 66435 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66436 className: "bar-chart-wrapper" 66437 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h5", { 66438 className: "bar-chart-text" 66439 }, this.props.options[0].options, " ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66440 className: "push-right" 66441 }, this.calculatePercentage(this.props.options[0].total_count), "%")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66442 className: "bar-wrapper", 66443 style: containerStyles 66444 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66445 className: "bar", 66446 style: { 66447 width: this.calculatePercentage(this.props.options[0].total_count) + '%' 66448 }, 66449 "data-percentage": "90%" 66450 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66451 className: "col-xs-12 col-sm-12 col-md-12" 66452 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66453 className: "bar-chart-wrapper" 66454 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h5", { 66455 className: "bar-chart-text" 66456 }, this.props.options[1].options, " ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66457 className: "push-right" 66458 }, this.calculatePercentage(this.props.options[1].total_count), "%")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66459 className: "bar-wrapper", 66460 style: containerStyles 66461 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66462 className: "bar", 66463 style: { 66464 width: this.calculatePercentage(this.props.options[1].total_count) + '%' 66465 }, 66466 "data-percentage": "90%" 66467 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null)))))))); 66468 } else if (this.props.options.length == 3) { 66469 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66470 className: "boundary-box" 66471 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66472 className: "poll-result" 66473 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66474 className: "row pollresult" 66475 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66476 className: "col-xs-12 col-sm-12 col-md-12" 66477 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66478 className: "bar-chart-wrapper" 66479 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h5", { 66480 className: "bar-chart-text" 66481 }, this.props.options[0].options, " ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66482 className: "push-right" 66483 }, this.calculatePercentage(this.props.options[0].total_count), "%")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66484 className: "bar-wrapper", 66485 style: containerStyles 66486 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66487 className: "bar", 66488 style: { 66489 width: this.calculatePercentage(this.props.options[0].total_count) + '%' 66490 }, 66491 "data-percentage": "90%" 66492 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66493 className: "col-xs-12 col-sm-12 col-md-12" 66494 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66495 className: "bar-chart-wrapper" 66496 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h5", { 66497 className: "bar-chart-text" 66498 }, this.props.options[1].options, " ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66499 className: "push-right" 66500 }, this.calculatePercentage(this.props.options[1].total_count), "%")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66501 className: "bar-wrapper", 66502 style: containerStyles 66503 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66504 className: "bar", 66505 style: { 66506 width: this.calculatePercentage(this.props.options[1].total_count) + '%' 66507 }, 66508 "data-percentage": "90%" 66509 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66510 className: "col-xs-12 col-sm-12 col-md-12" 66511 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66512 className: "bar-chart-wrapper" 66513 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h5", { 66514 className: "bar-chart-text" 66515 }, this.props.options[2].options, " ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66516 className: "push-right" 66517 }, this.calculatePercentage(this.props.options[2].total_count), "%")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66518 className: "bar-wrapper", 66519 style: containerStyles 66520 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66521 className: "bar", 66522 style: { 66523 width: this.calculatePercentage(this.props.options[2].total_count) + '%' 66524 }, 66525 "data-percentage": "90%" 66526 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null)))))))); 66527 } else { 66528 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66529 className: "boundary-box" 66530 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66531 className: "poll-result" 66532 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66533 className: "row pollresult" 66534 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66535 className: "col-xs-12 col-sm-12 col-md-12" 66536 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66537 className: "bar-chart-wrapper" 66538 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h5", { 66539 className: "bar-chart-text" 66540 }, this.props.options[0].options, " ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66541 className: "push-right" 66542 }, this.calculatePercentage(this.props.options[0].total_count), "%")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66543 className: "bar-wrapper", 66544 style: containerStyles 66545 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66546 className: "bar", 66547 style: { 66548 width: this.calculatePercentage(this.props.options[0].total_count) + '%' 66549 }, 66550 "data-percentage": "90%" 66551 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66552 className: "col-xs-12 col-sm-12 col-md-12" 66553 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66554 className: "bar-chart-wrapper" 66555 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h5", { 66556 className: "bar-chart-text" 66557 }, this.props.options[1].options, " ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66558 className: "push-right" 66559 }, this.calculatePercentage(this.props.options[1].total_count), "%")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66560 className: "bar-wrapper", 66561 style: containerStyles 66562 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66563 className: "bar", 66564 style: { 66565 width: this.calculatePercentage(this.props.options[1].total_count) + '%' 66566 }, 66567 "data-percentage": "90%" 66568 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66569 className: "col-xs-12 col-sm-12 col-md-12" 66570 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66571 className: "bar-chart-wrapper" 66572 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h5", { 66573 className: "bar-chart-text" 66574 }, this.props.options[2].options, " ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66575 className: "push-right" 66576 }, this.calculatePercentage(this.props.options[2].total_count), "%")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66577 className: "bar-wrapper", 66578 style: containerStyles 66579 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66580 className: "bar", 66581 style: { 66582 width: this.calculatePercentage(this.props.options[2].total_count) + '%' 66583 }, 66584 "data-percentage": "90%" 66585 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66586 className: "col-xs-12 col-sm-12 col-md-12" 66587 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66588 className: "bar-chart-wrapper" 66589 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h5", { 66590 className: "bar-chart-text" 66591 }, this.props.options[3].options, " ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", { 66592 className: "push-right" 66593 }, this.calculatePercentage(this.props.options[3].total_count), "%")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66594 className: "bar-wrapper", 66595 style: containerStyles 66596 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", { 66597 className: "bar", 66598 style: { 66599 width: this.calculatePercentage(this.props.options[3].total_count) + '%' 66600 }, 66601 "data-percentage": "9
666010%" 66602 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("span", null)))))))); 66603 } 66604 } 66605 }]); 66606 66607 return Result; 66608}(react__WEBPACK_IMPORTED_MODULE_0__["Component"]); 66609 66610 66611 66612/***/ }), 66613
66614/***/ "./themes/bhittacms-news3/sass/app.scss": 66615/*!**********************************************!*\ 66616 !*** ./themes/bhittacms-news3/sass/app.scss ***! 66617 \**********************************************/ 66618/*! no static exports found */ 66619/***/ (function(module, exports) { 66620 66621// removed by extract-text-webpack-plugin 66622 66623/***/ })
66623, 66624 66625/***/ 0: 66626/*!***************************************************************************************!*\ 66627 !*** multi ./themes/bhittacms-news3/js/app.js ./themes/bhittacms-news3/sass/app.scss ***! 66628 \***************************************************************************************/ 66629/*! no static exports found */ 66630/***/ (function(module, exports, __webpack_require__) { 66631 66632__webpack_require__(/*! /opt/lampp/htdocs/bhittacms-master/themes/bhittacms-news3/js/app.js */"./themes/bhittacms-news3/js/app.js"); 66633module.exports = __webpack_require__(/*! /opt/lampp/htdocs/bhittacms-master/themes/bhittacms-news3/sass/app.scss */"./themes/bhittacms-news3/sass/app.scss"); 66634 66635 66636/***/ }) 66637 66638/******/ });
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.